/Error.class.php
PHP | 73 lines | 46 code | 7 blank | 20 comment | 3 complexity | 8c0f632f708db7b353b02fd12ab87c6c MD5 | raw file
- <?php
- /*****************************************************
- * Error.class.php -- Error handling class
- *
- * Created by Kristian Ljungkvist 07/10/2002
- * KLH 2005/08/19 (changed email address for error notification, commented out the echo)
- * KLH 2005/09/27 (changed name of error log file, turned off logging)
- * KLH 2005/10/24 (turned on logging for this Engineering version of the file)
- *
- *****************************************************/
- // we will do our own error handling
- error_reporting(0);
- set_error_handler("userErrorHandler");
- // user defined error handling function
- function userErrorHandler ($errno, $errmsg, $filename, $linenum, $vars)
- {
- // timestamp for the error entry
- $dt = date("Y-m-d H:i:s (T)");
- // define an assoc array of error string
- // in reality the only entries we should
- // consider are 2,8,256,512 and 1024
- $errortype = array (
- 1 => "Error",
- 2 => "Warning",
- 4 => "Parsing Error",
- 8 => "Notice",
- 16 => "Core Error",
- 32 => "Core Warning",
- 64 => "Compile Error",
- 128 => "Compile Warning",
- 256 => "User Error",
- 512 => "User Warning",
- 1024=> "User Notice"
- );
- // set of errors for which a var trace will be saved
- $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
-
-
- $err = 'Script generating error: ' . $_SERVER['PHP_SELF'] .".\n";
- $err .= 'Server Address: ' . $_SERVER['SERVER_ADDR'] . ".\n";
- $err .= 'Query String: ' . $_SERVER['QUERY_STRING']. ".\n";
- $err .= 'Request from address: ' . $_SERVER['REMOTE_ADDR'] . ".\n";
- $err .= 'Client User-Agent: "' . $_SERVER['HTTP_USER_AGENT'] . "\".\n";
- $err .= 'Referrer string: "' . $_SERVER['HTTP_REFERER'] . "\".\n\n";
- $err .= 'IndividualID from Cookie: ' . $_COOKIE["iid"] ."\n";
- $err .= 'TeamID from Cookie: ' . $_COOKIE["tid"] ."\n";
- $err .= "<errorentry>\n";
- $err .= "\t<datetime>".$dt."</datetime>\n";
- $err .= "\t<errornum>".$errno."</errornum>\n";
- $err .= "\t<errortype>".$errortype[$errno]."</errortype>\n";
- $err .= "\t<errormsg>".$errmsg."</errormsg>\n";
- $err .= "\t<scriptname>".$filename."</scriptname>\n";
- $err .= "\t<scriptlinenum>".$linenum."</scriptlinenum>\n";
- //echo $err;
- if (in_array($errno, $user_errors))
- $err .= "\t<vartrace>".wddx_serialize_value($vars,"Variables")."</vartrace>\n";
- $err .= "</errorentry>\n\n";
-
- // save to the error log, and e-mail me if there is a critical user error
- //error_log($err, 3, "errors_engr.log");
- if ($errno == E_USER_ERROR) {
- mail("ken@sciencebuddies.org","Critical User Error",$err);
- mail("kristian.ljungkvist@gmail.com","Critical User Error",$err);
- echo '<html><head><META name="ROBOTS" content="NOINDEX,NOFOLLOW"></head><body><p><h1>Announcement</h1></p><p>Our site is currently experiencing high traffic volume. We apologize for the inconvenience. Please check back later.</p><p>-- The Science Buddies Staff</p></body></html>';
- // echo "<html><body><p>Our site is currently experiencing high traffic volume. We apologize for the inconvenience. Please check back later.</p><p>The Science Buddies Staff</p></body></html>";
- die;
- }
- }
- ?>