Dunstan-style Error Page

Overview

This is another plugin that I used on my old site and now I’m modifying it to make it WP friendly. It’s basically the same 404 error page that Dunstan Orchard uses on his 1976design.com/blog site. Install the file to your plugins directory, activate, configure, and enjoy!

Compatibility

WordPress Versions:

  • 2.1
  • 2.0
  • 1.5
  • In theory, it should work with 1.2.*, but it has not been tested.

Installation

  1. Downloaded the latest version of the plugin (below)
  2. Rename the downloaded file to afdn_error_page.php
  3. Upload to your plugins directory (typically /wp-content/plugins/)
  4. Activate the plugin
  5. Configure the plugin under Options > Error Page in the administration panel
  6. Find the 404.php file for the theme you are using, usually located at /wp-content/themes/*YOUR_THEME_NAME*/404.php
  7. Delete everything in the 404.php file and replace it with:
          <?php afdn_error_page(); ?>
    
  8. Enjoy!

Download

Latest version:

Changelog
1.3.1
….

1.3
….

1.2

Got all the Akismetfeatures working. While the plugin will work without an API Key, you really should get one. All comments that are tagged as spam by Akismet are placed into an array in the WPDB. You can manage it from the regular Error Page management window. I used the Akismet Comment Spam plugin as a basis for a lot of the UI, so things should be pretty familiar.

4-22-2006 – http://dev.wp-plugins.org/browser/dunstan-error-page/tags/1.2/
1.1

Layed the foundation for Akismet spam testing. If you have a valid API key, detailed error reports will be checked against for spam. YOU DO NOT NEED AN API KEY FOR THE PLUGIN TO WORK. My name was also hardcoded in one last place, so I took care of that. There was an issue with checking the referer that would return a false negative if the actual URL wasn’t preceded with WWW, so that’s fixed. I also coded some things in a rather crappy way, so I cleaned that up. Most of the plugin is now commented, so that should help anyone try to figure out what the heck I was thinking.

4-22-2006 – http://dev.wp-plugins.org/browser/dunstan-error-page/tags/1.1/
0.82

Thanks to Ozh for the heads up on some hardcoded text that should have been dynamic and for suggesting securing the email form.

12-29-2005 – http://dev.wp-plugins.org/browser/dunstan-error-page/tags/0.82/
0.8

NOTICE: Copyright format changed from MIT to GNU GPL as of version 0.8

Embeded error page code into plugin file….if that makes sense.

12-28-2005 – http://dev.wp-plugins.org/browser/dunstan-error-page/tags/0.8/
0.7

Added functionality for redirected error pages.

8-25-2005 – http://dev.wp-plugins.org/browser/dunstan-error-page/tags/0.7/
0.5

Inital public release

6-24-2005 – http://dev.wp-plugins.org/browser/dunstan-error-page/tags/0.5/

186 Replies to “Dunstan-style Error Page”

  1. Pingback: Nerhood Weblog
  2. Pingback: Sebastians Blog
  3. Your instructions seem to be missing a crucial part: what to put in the 404.php file (step seven). What do I need to put in the file for this plugin to work?

  4. Great idea – that’s a really nice plugin.

    I tweaked it slightly – I didn’t want to use a table for the 404 page content, and wanted everything to display sequentially, rather than grouped like it was (it didn’t fit with my theme).

    It’d be really cool if a future version let you say “display all section with line breaks between them, or preserve table structure” as an option.

  5. Thanks Andrew – very much nicer than the standard 404 page!

    If anyone happens to be trying to figure out where to get the API key*, go to your WP-Admin area and click
    Plugins > Akismet Configuration … and there it is.

    *the plugin asks for it and links you to wordpress.com, which has some sort of strange loop effect going on.

  6. Warning: call_user_func_array(): First argumented is expected to be a valid callback, ‘afdn_error_page_myManagementSubpanel’ was given in /home/thesup3/public_html/wp-includes/plugin.php on line 123

  7. If I activate the plugin I get the following error when I try to go the Manage/Error Page screen.

    Warning: call_user_func_array() [function.call-user-func-array]: First argumented is expected to be a valid callback, ‘afdn_error_page_myManagementSubpanel’ was given in /home/eckernet/public_html/wp-includes/plugin.php on line 123

  8. ** Same as above for Kevin, as posted 21st February **

    If I activate the plugin I get the following error when I try to go the Manage/Error Page screen.

    Warning: call_user_func_array() [function.call-user-func-array]: First argumented is expected to be a valid callback, ‘afdn_error_page_myManagementSubpanel’ was given in /home/eckernet/public_html/wp-includes/plugin.php on line 123

  9. I installed a fresh copy of WP and tested it out and didn’t get any errors. So this might take some more time to track down. My current guess is that it might be conflicting with another plugin.

  10. Hi Andrew,
    I experience a strange problem.
    I use WP 2.1.1 with your plugin.
    It works perfectly in FireFox, but I get a standard ‘The page cannot be found’ error when using Internet Explorer 6 .
    Any suggestions?
    Cor

  11. If you force a refresh while using IE6, the true error page will load. I vaguely recall a “bug” being mentioned a while back on the Apache site that said that IE would not load an error page sent by the server it was was less than so many KBs. Unfortunately, I don’t remember what version of IE and how many KBs were needed.

    I also tested it on IE5, and that worked properly, which is weird.

    I’ll see what else I can dig up, but that’s a start.

  12. Thank you Andrew.
    I have tried the refresh in IE6 to no avail.
    I have also tried both direct load and redirect – still the same.
    I have cleared files and history on IE6 – same.
    You may want to test mentpro.com
    Regards
    Cor

  13. Try force refreshing (Ctrl + F5).
    It looks like your using Apache, so I’m not sure what the issue is.

    I’ve also been testing on your site and mine.

    Apache makes a note below the ErrorDocument documentation:

    Microsoft Internet Explorer (MSIE) will by default ignore server-generated error messages when they are “too small” and substitute its own “friendly” error messages. The size threshold varies depending on the type of error, but in general, if you make your error document greater than 512 bytes, then MSIE will show the server-generated error rather than masking it. More information is available in Microsoft Knowledge Base article Q294807.

    My best recommendation is to inflate the size of the error document. But some garbage text between two comment tags and see what that does.

    If that works, I’ll roll that option into the next version. Which I hope to start work on sooner rather then later.

  14. Andrew,
    Thank you for the suggestion.
    I have increased the file size of 404.php to 9k. I have included into the file.
    It still works fine on FireFox. IE6: After much testing, it works about 55% of the time. Where the refresh (shift F5) previously didn’t work at all, it now works after +- the third try.
    If you do find anything else, would you be so kind as to inform me?

    BTW, the ‘Leave A Comment’ Plugin is excellent. Would you like to share the name of the plugin?
    Cor

  15. General Note:

    I just added a donation button on the side bar (to the right), so if you *really* like my plugins (and/or me) you might consider making a donation. I’ve been spending more and more time writing and supporting plugins. I?m a college student (3rd year Elect. Eng.) and really only do this programming thing on the side for the love of it.

  16. Pingback: WP?? - drin@mel
  17. Recently spammers have been using this plugin to send me gobs of “Quick Error Report” emails…ideas to stop this??? ….other than removing the plugin?

  18. Kevin,

    I think your best bet would be to disable the quick error report part. There are several ways you could do it, but the easiest and cleanest is to just remove lines 395 to 403:

    <h2>Quick error report</h2>
    ...
    </form>
    

    I see what else I can do for the next version.

  19. Hi Andrew really a nice job.
    Just one thing: when i receive the Quick error report email the field referrer and bad page are empty.
    I’ve done everything you said in your installation tips, but nothing happens…

  20. Enrico,

    Can you give me some more details:
    What version of WordPress?
    What version of Dunstan-style Error Page?
    What server are you using (Apache? IIS?) and what version, if known?
    Also, what settings are you using for the Dunstan-style Error Page?

  21. Ok Andrew! 🙂
    I am using Wp 2.1.2, Error Page v1.3.1, Apache 1.3.37.
    These are the options (I’ve localized the php file so I have to retranslate the terms, sorry):

    Check update: yes.
    404 mode: redirect

    Thanks very much for your patience!
    Enrico

  22. I’m trying to use this plug-in for a newly created site, which I’ve used previously for my own site, but this time when it is enabled I simply get a blank page when I try to access my site.

    I tried running through the php at the command line and I got this:
    PHP Parse error: syntax error, unexpected $end in …./afdn_error_page.php on line 503

    WordPress 2.1.2 with Dunstan-style 1.3.1 on apache

  23. I have a couple questions you may be able to help with…

    I have modded this plugin just a little bit to fit my theme/layout and I’ve also made it so that for the quick submit form that the name and email text boxes are there. In both forms, when you submit the email comes from basically my server, so its this abnormal email address. How do I make it so that the name and email address that they entered goes in that place? So that if Bob Somebody submits those forms, it says that it is from Bob Somebody and not kahil@yadayadayadayada, etc.

    Also, how do I make it so that the name and email boxes are required before the email is sent?

    Thank you

  24. Kahil,

    Mostly as an FYI, the whole point of having the “quick error report” was so that the user didn’t have to enter any information in if they didn’t want to.

    In any event, you’ll want to modify a couple of lines. Start with line 282:

    mail(get_option('admin_email'), '['.get_option("blogname").'] 404 Quick Error Report', $message);
    

    Modify it to:

    $headers = 'From: '.$_POST["name"].' <'.$_POST&#91;"email"&#93;.'>' . "\r\n" .
    mail(get_option('admin_email'), '['.get_option("blogname").'] 404 Quick Error Report', $message, $headers);
    

    …adding the $headers variable and then referencing at the end of the mail() function.

    You’re also going to want to do the same thing with line 309, modifying it to:

    $headers = 'From: '.$_POST["name"].' <'.$_POST&#91;"email"&#93;.'>' . "\r\n" .
    mail(get_option('admin_email'), '['.get_option("blogname").'] 404 Error Report', $message, $headers);
    

    Checking to make sure the name and email boxes have been filled before the email is sent can be accomplished a few different ways. The easiest way would probably be way to use some Javascript, http://www.thesitewizard.com/archive/validation.shtml is a good place to start.

  25. Hi Andrew, Ive just installed the plugin and changed the 404.php file like it says in the instructions, activated the plugin and added the akismet API key. However I didnt understand one thing in the Options.

    “If you don’t have access to your Apache config file or .htaccess file, of if you don’t use Apache, you can use GET tags to send the information to the script. The tags are named “referer” and “requested”.

    The error page shows up as expected for a 404 page, the form, the last 5 blog entries, quick error report etc are all there, but when i send an email thru quick form or when i click on quick error report, im not receiving any email at the blog admin address.

    Thanks for you help
    PS: i use WP 2.1.2. K2/ 3 column K2

  26. Andrew: Thanks for the great plugin. One question: is there any way to prevent the reporting of e-mail addresses as bad pages? I get a bunch of spam and all of them report a bad e-mail address that doesn’t exist anywhere on my site – I don’t post e-mail addresses at all. If there were some way to black any 404 Error report that reports an e-mail address as the bad page, that would be great. Thanks! -Carlton Bale

  27. Carlton,

    You could do a quick filter check and match against “mailto” or something like that. That’s interesting that you’re getting those kind of error reports. Can you give me any more details?

  28. Andrew,
    I’ve posted the contents of several of the 404 error reports that are getting through as well as one that was caught by Akismet. Please let me know when you’ve downloaded the file so I can delete it.

    http://www.carltonbale.com/hosted/404_error_report.zip

    I disabled the plugin because of the all the messages I’m getting and because there are e-mail address cc’d on some of them. I’m afraid they might be valid and copied on spam messages.

  29. Carlton,

    I downloaded the file, however there’s really not anything I can do with it. The plugin checks the contents against Akismet. Akismet is the one that actually determines if the report is spam or not.

  30. I’m getting this strange error:

    Warning: unserialize() expects parameter 1 to be string, array given in /public_html/wp-content/plugins/afdn_error_page.php on line 155

  31. Fraser,

    I do know about the bug and it will be fixed in the next version. School just got out and I’m on my way back to Seattle, so I’m not really in the coding mood right now.

    I’ll try to get the next release out soon though.

  32. Pingback: Planet Wordpress
  33. Hello Andrew,

    Its Marcelo Again, 3 comments up, I had some Warning messages when I made the installation, but i realized that it was just some bad configuration. Your plugin is working perfectly in one of my blogs.
    Mexico Global Warming Articles

    Thanks for all your tech support. Sites like yours make people come over and over again. I´ll be glad to write a post about this good plugin. In some way to thank you for your efforts.

    Thanks Again.

  34. Hello Andrew,
    I’m trying to install the plugin onto WP 2.2 but i can0t activate it.
    It tells me the it encountered a fatal error…
    Any help please?

    Thank you.

  35. @Luca:

    I don’t know why it isn’t working with your WP 2.2 install. You make make sure that it’s in the wp-content/plugins folder and not in a sub-folder beneath that.

    You also might try running the debug tool and see if that helps.

    I haven’t done extensive testing with 2.2 for the current version because I’m working on an upgrade that will be have more features and have better integration.

  36. Hey I think you missed an named anchor

    405:  &lt;td width="50%" valign="top"&gt;
    <strong>406:       &lt;a name="quick"&gt;</strong>
    407:       &lt;h2&gt;Feedback request&lt;/h2&gt;
    

    Clicking on the Error Report Form link doesn’t do anything unless this anchor exists.

  37. Search feature doesn’t work.
    plugin wrote this search url:

    action=”http://onlinedatingpost.com/wordpress”

    That is not the right search link and simply reloads the page. I use Google search in my sidebar so I pasted that code into the sidebar and it works perfectly.

  38. Pingback: Plugins
  39. This is really odd, but the plugin was working fine for me the other day. I haven’t changed anything with the plugin files, but all of a sudden today it is displaying the error page contents twice on the 404 page. I’m running WP version 2.3.3. Could this possibly be the cause of the problem?

  40. there seems to be some new bug… it only started happening when I upgraded wordpress to the newest version not too long ago. i am getting spam reports daily.

  41. wow… i dont know if its just a coincidence or not, but ever since i left my previous comment, the spam error reports have just poured in…… 🙁

  42. @Kahil, et al:

    Sorry that you’re having problems, I’m assuming you’re using WP 2.3.3? I’m working on revising the code and hope to have a new release soon.

    One of the issues I’m working on is what to do with the forms because A) I find that people don’t use them (especially the form with feedback); which makes the entire form idea B) more trouble then it’s worth.

    I’ve also been noticing more and more spam slipping through Akismet on my regular comments, so it might also be an Akismet issue.

  43. well, maybe add captcha or some other kind of verification and that should dramatically reduce that issue….at least i’d think it would. I do have the newest version of wordpress. I love the format, layout and overall idea of this plugin, its great. But as of right now, I disabled it because the email’s have been getting out of control. I just changed my 404 page to have everything but the form, etc. What I didn’t understand is that a lot of the email addresses that were submitting these and getting through, were also in the caught spam list. even the names were the same. maybe ur right, there must be some issues going on over at akismet… we want it to work full time and its only working part time. sucks…

  44. This uplugin is not working.

    Parse error: syntax error, unexpected $end in C:\www\wp-content\plugins\afdn_error_page.php on line 503

  45. nice plugin. I had some problem with my theme’s plugin so i looked around and found yours. its cool. However, I have a small problem. since it inherit theme design, in my case, the vertical line (separating content and sidebar on regular page) appears on error page. and it looks annoying. check this http://www.mitixa.com/xyz.htm … it will take to error page. is there any workaround ? your help is appreciated. thank in advance.

  46. @mitixa:

    I took a look at your site and it appears that the line is part of the background image for your blog: http://www.mitixa.com/wp-content/themes/ganjapress-10/images/ganjapressbg.jpg

    Because I was curious (which is to say that I won’t do this for everyone who asks), I was able to whip up some CSS code to fix your issue:
    #content{ background: #FFF !important; border-left: 10px solid #679A01 !important; border-right: 10px solid #679A01; }

    On line 345, after < ?php get_header(); ?>, put the following code:

    <style type="text/css" media="screen">#content{ background: #FFF !important; border-left: 10px solid #679A01 !important; border-right: 10px solid #679A01; }</style>

    …and you should be set.

  47. hi Andrew,i have tried to install your new version but i can’t get anything on my site.i am getting the result as a blank white page.could you please solve out my problem in installing the new version.hope you will reply soon.
    ==============================================
    Sandy
    Social Bookmarking

  48. can you post *exactly* what’s in your 404.php file in 2.7.1? I feel as though there’s something missing as simply placing

    
    
    

    as your instructions say, doesn’t work. Any help would be greatly appreciated.

    1. @bob

      Sorry about that. I changed code markup formats and didn’t get everything converted. So yes, there is some missing code:

      <?php afdn_error_page(); ?>

      I’ve also updated the documentation.

  49. Dear Andrew,

    My theme doesn’t have a 404 error page, it has this stuff in the Main Index Template:

    // END of: If there are any posts
    // If there are no posts:
    else :
    ?>

  50. Hi!

    I’ve had the default 404 page forever, and I found your plugin. But, when I intentionally mess up the url so I get my 404 page, I have a slight problem.

    First, the entire sidebar loads as well. That’s fine and everything, but it messes up and squishes all the content on the right of the page, where the 404 page is at. There’s no Title to the page, and the boxes and such are either on top of each other or squished together. Could you tell me where I need to go to tweak these?

    I took out all the contents of the default 404 page (actually I just commented it all out, but it should show ONLY the php code to load the new page) and it shouldn’t be calling on the 404.css page anymore. So I’m at a loss.

  51. Nevermind on all the help I asked for. I managed to style the content in my stylesheet and edit the plugin extensively so that the table displayed correctly.

    Turns out the comment box on the last form was not dynamically sized, probably because of the rest of my site’s stylepage. That messed up the table and so on. So i found the problems and managed to fix them.

    Take a look:

    http://joyphillip.davensjournal.com/error

    I’m rather proud of my job if I do say so myself.

  52. We used the following PHP to compress files to improve load time. However this stops the plugin working.

    Any ideas?

  53. @Eddie Miller:

    I’ve been having issues with code in the comments. You’ll have to email me the code until I get the issue worked out. Also, I’m on vacation until August. So while I’d be happy to take a quick look, I may not be able to provide you with a definitive answer until later.

  54. Hi, I use your plugin on all my WordPress installations and seems to work fine all the way up to 2.8.4.

    Except on my test site on my local machine (running WordPress with a XAMPP local server setup). On that one, it gives me this error (see below).

    Could the fact that it’s a local server environment be breaking it, or something else? Let me know. Thanks!

    Parse error: syntax error, unexpected $end in C:\XAMPP\htdocs\wordpress\wp-content\plugins\dunstan-error-page\afdn_error_page.php on line 503

  55. Shalom,

    Everything worked great except the link to “Submit an error report form” which did nothing so I added this: to it & all works greater now.

    Shalom,
    Frank

Leave a Reply

Your email address will not be published. Required fields are marked *