#996 ✓ resolved
Chris Morgan

Website needs a 404 page (currently scary PHP include warning and no 404)

Reported by Chris Morgan | December 3rd, 2010 @ 12:38 AM | in 1.3.0 (closed)

The message you get when you go to an invalid page scares me.

For example, http://processingjs.org/404:

Warning: include(content/404.html) [function.include]: failed to open stream: No such file or directory in /home/processingjs/processingjs.org/index.php on line 91

Warning: include() [function.include]: Failed opening 'content/404.html' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/processingjs/processingjs.org/index.php on line 91

I've tried breaking into it with a variety of potentially malicious methods (me? I'm friendly :-)), but it seems to be secure enough. But still, it's yucky to produce that, it should have a good animated Processing.js-powered 404 sketch instead (the type that people will watch entranced for five minutes, until they've forgotten what they were really looking for when they came across the error).

Additionally, it would be good for some aliases to be created; for example, documentation for image() used to be at http://processingjs.org/reference/image() and is now at http://processingjs.org/reference/image_, but the former is still indexed (and ranked higher) by Google.

(Incidentally, if you give an extension, e.g. http://processingjs.org/404.404, you get a genuine 404 page, telling you the 404 404 is a 404 - common but not good.)

Comments and changes to this ticket

  • Pomax

    Pomax December 3rd, 2010 @ 04:07 PM

    • State changed from “new” to “home-page”
    • Assigned user set to “Daniel H”
  • Daniel H

    Daniel H December 14th, 2010 @ 01:39 PM

    • Milestone set to 1.1 Code Freeze
    • Milestone order changed from “197839” to “0”
  • Daniel H

    Daniel H December 21st, 2010 @ 10:57 AM

    • Milestone order changed from “7” to “0”

    This is a two part problem I guess.

    Seems to me the best way to handle this is to put the include in a try catch and if it fails to include the file it defaults to the reference page, or just in general includes a page that says could not find what they were looking for, please try one of the following links: reference, learning, exhibition, etc, etc.

    The 2nd part is the 404 page itself

  • Daniel H

    Daniel H January 15th, 2011 @ 11:17 PM

    • Milestone changed from 1.1 Code Freeze to 1.2
    • Milestone order changed from “9” to “0”
  • Daniel H

    Daniel H April 8th, 2011 @ 10:30 PM

    • Milestone order changed from “2” to “0”

    I fixed this with simple "file does not exist" messages for both the include and the 404 issue

    see:
    http://processingjs.org/404.404
    http://processingjs.org/404

    We can write a nice pjs sketch for it at any time and add it.

    for now, no more scary includes if 404 errors

  • Daniel H

    Daniel H April 8th, 2011 @ 11:42 PM

    • State changed from “home-page” to “peer-review-requested”
    • Assigned user changed from “Daniel H” to “Pomax”

    gonna give this to pomax for PR and let him decide if he wants to make a sketch for these pages and to check best practices against what i did.

    added ErrorDocument to .htaccess for 404.php
    check before the include() for the page your visiting with file_exists()

  • Pomax

    Pomax April 11th, 2011 @ 11:34 PM

    • State changed from “peer-review-requested” to “assigned”
    • Assigned user changed from “Pomax” to “Daniel H”

    that's the precautions I would take, althoug I would change the text to "That page could not be found", or something similar (since the web user isn't asking for files). I'm going to have to find some time to come up with a cool 404 though. Shall we open a new ticket for that, since the actual "404"ing works well?

  • annasob

    annasob April 15th, 2011 @ 01:15 PM

    • Milestone cleared.
    • Milestone order changed from “6” to “0”

    This can wait till release :)

  • Jon Buckley

    Jon Buckley May 11th, 2011 @ 10:38 AM

    • Milestone set to 1.2
    • Milestone order changed from “2” to “0”
  • Daniel H

    Daniel H May 13th, 2011 @ 05:08 PM

    • State changed from “assigned” to “peer-review-requested”
    • Title changed from “Website needs a cool 404 page (currently scary PHP include warning and no 404)” to “Website needs a 404 page (currently scary PHP include warning and no 404)”
    • Assigned user changed from “Daniel H” to “Pomax”
    • Milestone order changed from “1” to “0”

    cleaned up the wording and look so they are at least nice and now say page not found rather than file not found

    with links to return to the home page

  • Pomax

    Pomax May 13th, 2011 @ 07:18 PM

    • State changed from “peer-review-requested” to “assigned”
    • Title changed from “Website needs a 404 page (currently scary PHP include warning and no 404)” to “Website needs a cool 404 page (currently scary PHP include warning and no 404)”
    • Assigned user changed from “Pomax” to “Daniel H”

    looks good overall, although the skeleton appears to be missing for things like http://processingjs.org/reference/pjs%20directive_.fawefw

  • Daniel H

    Daniel H May 13th, 2011 @ 08:53 PM

    • State changed from “assigned” to “peer-review-requested”
    • Assigned user changed from “Daniel H” to “Pomax”

    there are two different areas I've added content too

    the 404.php page is the basic black and white page with nothing on it. i can add the skin around it or make that page redirect to http://processingjs.org/404 but if there is something wrong with the site and pages are missing or if the index page goes missing then it would redirect in an infinite loop.

    id prefer to have pure 404 urls point to the basic black empty page with a link to home with no other site dependencies in case those dependencies are also missing it could 404 those and cause an infinite loop of redirection. Bad url rewrites can just have text inserted saying page not found like it is now at http://processingjs.org/404.

    agree?

  • Daniel H

    Daniel H May 13th, 2011 @ 08:53 PM

    • Title changed from “Website needs a cool 404 page (currently scary PHP include warning and no 404)” to “Website needs a 404 page (currently scary PHP include warning and no 404)”
  • Pomax

    Pomax May 13th, 2011 @ 08:57 PM

    • State changed from “peer-review-requested” to “super-review-requested”
    • Assigned user changed from “Pomax” to “annasob”

    that makes sense. PR+ from my end.

  • Chris Morgan

    Chris Morgan May 13th, 2011 @ 09:54 PM

    Daniel H: I don't understand your reasoning at all. A full 404 page with images and references to other things isn't a problem; if perchance they weren't there, the resources would just fail to load. Unless they will in themselves trigger production of content - for example, in an iframe, which we don't want to do anyway - it can never cause any form of recursion. And unstyled 404 pages are bad things to have.

    There's also a problem with the unstyled 404 page as it stands at http://processingjs.org/404.404 - <a href=\"http://www.processingjs.org\"> will make a link to http://www.processingjs.org/\"http://www.processingjs.org\".

    At present, I am not happy with the state of the situation. True, the PHP include() warning has been removed, but the more important part of my request has not been dealt with at all yet; pages like /404 which say now correctly say "page not found" are nevertheless returning HTTP Status 200 OK. They should be returning 404 Not Found. Otherwise it reduces what search engines and other spiders can do with it as they can't ever detect a missing page and will just index broken links. And you can't use a link checker to assist in quality verification for the site.

  • Daniel H

    Daniel H May 13th, 2011 @ 11:15 PM

    • State changed from “super-review-requested” to “review-needs-work”
    • Assigned user changed from “annasob” to “Daniel H”

    what i meant about the recursive part was if i start adding the main site skin into the 404.php page with a bunch of include(missingfile.html) and missingfile.html was the file that did not exist and triggered the 404 in the first place will it not then try to load the missingfile.html in the 404.php file and then trigger a 404 loading the 404 triggering an include of the missing file triggering a 404... etc etc.

    trying to include files in the 404 which are missing will just infinitely try to include them, fail, and trigger a 404 repeating the cycle?

    Including images is fine but not include() ing files that might not exist in the future due to a rename/move/delete

    I see your point with this though

    but the more important part of my request has not been dealt with at all yet; 
    pages like /404 which say now correctly say "page not found" are nevertheless 
    returning HTTP Status 200 OK. They should be returning 404 Not Found.
    

    not sure how to handle this in php. I can write whatever code necessary in the index.php page if an included file does not exist but I'm not sure how to trigger a 404 header instead of 200. I'll look into this.

    I fixed the issue with the link to "http://www.processingjs.org/"http://www.processingjs.org"" just now.

  • Pomax

    Pomax May 14th, 2011 @ 12:17 AM

    Make php send a 404 header:

    <?php
    header("HTTP/1.0 404 Not Found");
    ?>
    
  • Chris Morgan

    Chris Morgan May 14th, 2011 @ 12:46 AM

    I think that you should just ignore that possibility, as the include()d files should always exist - if they don't it's likely a catastrophic failure of the whole site (most likely permissions) and so it won't be any good protecting from it in the output. Or, if you really cared, fail the include()s silently. Bear in mind that include() on non-existent files will just raise a PHP warning - it won't cause any form of recursion. include() on local files loads the local file, it doesn't load it via HTTP.

  • Daniel H

    Daniel H May 16th, 2011 @ 11:29 PM

    • State changed from “review-needs-work” to “super-review-requested”
    • Assigned user changed from “Daniel H” to “Pomax”

    http://processingjs.org/404 now sets the header to:
    [22:57:33.269] GET http://processingjs.org/404 [HTTP/1.1 404 Not Found 297ms]

    http://processingjs.org/404.404 continues to set the header:
    [23:28:10.047] GET http://processingjs.org/404.404 [HTTP/1.1 404 Not Found 231ms]

    the 404 page now includes the site wrapping pages and the 2 are consistent and both set the header to 404

    Chris? comments please.

  • Chris Morgan

    Chris Morgan May 17th, 2011 @ 07:08 AM

    All looks good to me. Thanks :-)

  • Jon Buckley

    Jon Buckley May 17th, 2011 @ 11:23 AM

    • Milestone changed from 1.2 to 1.3.0
    • Milestone order changed from “5” to “0”
  • Pomax

    Pomax May 28th, 2011 @ 02:38 PM

    • State changed from “super-review-requested” to “review-looks-good”
    • Assigned user changed from “Pomax” to “Daniel H”

    looks good to me.

  • Daniel H

    Daniel H May 31st, 2011 @ 09:31 PM

    • State changed from “review-looks-good” to “resolved”

    marking resolved

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Processing.js is an open programming language for people who want to program images, animation, and interactions for the web without using Flash or Java applets. Processing.js uses Javascript to draw shapes and manipulate images on the HTML5 Canvas element. The code is light-weight, simple to learn and makes an ideal tool for visualizing data, creating user-interfaces and developing web-based games.

Shared Ticket Bins

Tags

Pages