Page 1 of 3 123 LastLast
Results 1 to 10 of 30
  1. #1
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,401
    Plugin Contributions
    87

    Default Generate an e-mail on page-not-found (404) errors [support thread]

    I got tired of scouring my Apache logs for 404 errors, so wrote this little update that will send an e-mail to the address of your choice as part of the page_not_found processing.

    Installation is short and simple (see the readme). You'll need to edit /includes/languages/english/YOURTEMPLATE/page_not_found.php to contain your desired e-mail address.


    See download here: http://www.zen-cart.com/downloads.php?do=file&id=1090

  2. #2
    Join Date
    Mar 2010
    Location
    UK
    Posts
    445
    Plugin Contributions
    0

    Default Re: Generate an e-mail on page-not-found (404) errors

    If you have a Google WebmasterTools account, there's a neat little report in there listing all the URLs that Google finds as 'not found' and all the pages that have those links on.

    Most of the time, the list will contain URLs for removed products, but it's worth a scan every now and again.

  3. #3
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,401
    Plugin Contributions
    87

    Default Re: Generate an e-mail on page-not-found (404) errors

    Thanks for the info, g1smd. My focus for developing this little add-on was more to get a notification for accesses that are likely someone groping around my site, of the like

    www.example.com/admin

    ... when I've followed the security guidelines and renamed that folder.

  4. #4
    Join Date
    Mar 2010
    Location
    UK
    Posts
    445
    Plugin Contributions
    0

    Default Re: Generate an e-mail on page-not-found (404) errors

    OK. That works too.

    Additionally, I like to add this in the .htaccess file in the /admin/ folder:

    Code:
    Order Deny,Allow
    Deny from all
    Allow from 11.22.33
    which allows access from a small range of IP addresses.

  5. #5
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,401
    Plugin Contributions
    87

    Default Re: Generate an e-mail on page-not-found (404) errors

    Oops! There was an error in the first release (the observer class was not being instantiated).

    I've just uploaded v1.1 to correct the error in class.emailFor404.php from

    Code:
     function emailFor404() {
        if (SEND_404_ERRORS_EMAIL_TO_STATUS == '1' and SEND_404_ERRORS_EMAILS_TO != '') {
          $this->attach($this, array('NOTIFY_HEADER_END_PAGE_NOT_FOUND'));
        }
      }
    to

    Code:
     function emailFor404() {
        global $zco_notifier;
        if (SEND_404_ERRORS_EMAIL_TO_STATUS == '1' and SEND_404_ERRORS_EMAILS_TO != '') {
          $zco_notifier->attach($this, array('NOTIFY_HEADER_END_PAGE_NOT_FOUND'));
        }
      }

  6. #6
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Generate an e-mail on page-not-found (404) errors

    The $this-> approach will work fine in 1.3.9 and newer.
    For 1.3.8 and older you may have to use the old $zco_notifier-> approach instead.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  7. #7
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,401
    Plugin Contributions
    87

    Default Email on 404 (page-not-found) errors [support thread]

    I've updated this add-on to v1.2 (http://www.zen-cart.com/downloads.php?do=file&id=1090), including a switch to enable/disable the archiving of these emails.

  8. #8
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,571
    Plugin Contributions
    30

    Default email body text not included in email

    Hi,
    Just tried out this latest version on ZC 1.5.

    I receive the email but the text is not passed, its always:

    A 404 Error Was Generated

    $EMAIL_MESSAGE_HTML
    Strangely the email is in html format irrespective of the format chosen in the admin.
    I get the same results with an (almost) vanilla 1.5 installation.
    It tried it local/Xampp and remote hosting, same result.

    regards
    Steve
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  9. #9
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,401
    Plugin Contributions
    87

    Default Re: email body text not included in email

    I'm having a devil of a time replicating this. I've tried changing my CHARSET to utf-8 (which I'm assuming you're using), tried running as a logged-in or guest customer, changing my admin email format from HTML to Text and back. Regardless of these settings, I'm always receiving a Text-format message:
    Code:
    A user at host address [xxxx] with IP address [yyyy] generated a 404 using the query string [/index.php?main_page=elsewhere].
    The settings in my Configuration->Email Settings are
    Code:
    E-Mail Transport Method 	PHP 	 
    E-Mail Linefeeds 	LF
    Use MIME HTML When Sending Emails 	true
    What are your email settings?

  10. #10
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,401
    Plugin Contributions
    87

    Default Re: email body text not included in email

    torvista, would you try this updated version of /includes/classes/class.emailFor404.php and let me know if it works?

    Code:
    <?php
    class emailFor404 extends base {
    
     /**  constructor method !
       *
       * Attach observer class to the global $zco_notifier and watch for a single notifier event.
       */
      function emailFor404() {
        global $zco_notifier;
        if (SEND_404_ERRORS_EMAIL_TO_STATUS == '1' and SEND_404_ERRORS_EMAILS_TO != '' and SEND_404_ERRORS_EMAILS_TO != '[email protected]') {
          $zco_notifier->attach($this, array('NOTIFY_HEADER_END_PAGE_NOT_FOUND'));
        }
      }
    
    
     /**   Actual Method that does the desired activity
       *
       * Called by observed class when any of the notifiable events occur
       *
       * @param object $class
       * @param string $eventID
       */
      function update(&$class, $eventID, $paramsArray = array()) {
        // BOF Send email to admin for 404 errors
        $email_text = sprintf(EMAIL_PAGE_NOT_FOUND_CONTENT, $_SESSION['customers_host_address'], $_SESSION['customers_ip_address'], $_ENV['REQUEST_URI'])."\n\n";
        $email_subject = EMAIL_PAGE_NOT_FOUND_SUBJECT;
        $module = (SEND_404_ERRORS_EMAILS_ARCHIVE != '0') ? 'default' : 'no_archive';
        $html_msg['EMAIL_SUBJECT'] = EMAIL_PAGE_NOT_FOUND_SUBJECT;
        $html_msg['EMAIL_MESSAGE_HTML'] = str_replace('\n','',$email_text);
        zen_mail('', SEND_404_ERRORS_EMAILS_TO, $email_subject, $email_text, STORE_NAME, EMAIL_FROM, $html_msg, $module);
        // EOF Send email to admin for 404 errors
      }
    }
    ?>

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. v151 Site Map/Page Not Found: Combined [Support Thread]
    By lat9 in forum All Other Contributions/Addons
    Replies: 7
    Last Post: 4 Jan 2016, 02:19 PM
  2. Replies: 2
    Last Post: 24 Jun 2010, 11:20 PM
  3. 404 Not Found Page Not Found not working!
    By NamSingh in forum Basic Configuration
    Replies: 0
    Last Post: 15 Oct 2006, 10:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR