Posted on 2012-08-17
Last Modified: 2012-09-13
Can someone send me or point out a really "Hardy" error reporting script that will email me when there is an error in my script, with line number and everything?

Thank you in advance.
Question by:rgranlund
    LVL 107

    Accepted Solution

    I have to teach a PHP class today, so I can't write it out for you, but here is a strategy that I have used in the past, and that has worked very, very well.

    I have a CRON job that runs once per second.  It reads all of the files in all of my web root directories (I used all but you might omit images, videos, etc.) into a data string, and makes an md5() digest from the string.  Then it reads a "checkpoint" file that contains the last md5() digest.  If the two strings are the same, it dies silently.

    However if the md5() strings are not the same, something has changed in the web directory tree.  This change could be the result of me updating a script, in which case I will expect a message.  Or it could be the result of a hack (!) or the output of an error_log().  In that case the script will send an email message using mail().  Then it writes the new md5() string into the checkpoint file before it dies.

    So to bring the pieces together, here is what you do...

    1. Set error_reporting(E_ALL)
    2. Set display errors off (see ini_set() for more information)
    3. Set log errors on
    4. Set up your CRON job to monitor the error log file
    5. Start the CRON and trigger an error to test the setup.
    LVL 29

    Expert Comment

    by:Olaf Doschke
    Nice idea, Ray,

    also for hacks. It doesn't help to protect from hacks of a database, but that's also not applicable as data isn't meant to be static. There are other indicators to watch about that and it's a topic of it's own.
    It's  a nice security measure to check all the static parts of a web site remain static.

    Bye, Olaf.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
    I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now