|
|
|
<?php
function reported()
{
$domain = 'mydomain.com';
// ---------------------------------------------------------------
if( isset($_COOKIE['error']) )
{
$_COOKIE['error'] = unserialize( $_COOKIE['error'] );
if( in_array($_SERVER['REQUEST_URI'], $_COOKIE['error']) )
{
return TRUE;
}
}
$_COOKIE['error'][] = $_SERVER['REQUEST_URI'];
$value = serialize( $_COOKIE['error'] );
setcookie( 'error', $value, time() + 24*60*60, '/', './'.$domain, 0 );
unset( $domain, $value );
return FALSE;
}
function error($error='Undefined')
{
if( !reported() )
{
$to = 'someone@example.com';
$subject = "Error type $error has occured on $_SERVER['REQUEST_URI']";
// set the MESSAGE: e-mail
$message = " $error has occured on page:\n"
." http://www.{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}\n"
." Referring Page: ".( isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'Unknown' )." \n"
." Time: ".date('r')."\n"
." From IP: {$_SERVER['REMOTE_ADDR']}\n\n"
."Please Investigate the problem ASAP";
$headers = "From: webserver@{$_SERVER['SERVER_NAME']}\n"
."Reply-To: webserver@{$_SERVER['SERVER_NAME']}\n"
."X-Mailer: PHP/".phpversion();
// send the email
mail( $to, $subject, $message, $headers );
}
}
/*
EXAMPLE for a 404 error page.
error($error='404 Error');
*/
?> |
|
| Error mailing logging facility Categories : PHP, Errors and Logging, Email | | | DB Connection Function with error handling and email failure notices Categories : PHP, MySQL, Errors and Logging, Databases, Errors and Logging | | | An email validation script that actually checks against the recipient's mail server. Categories : Email, Complete Programs, PHP, Network, Debugging | | | Sending email with random details Categories : PHP, Email, Debugging | | | A Custom Error Handling And Debugging Class Categories : PHP, PHP Classes, Debugging, Errors and Logging | | | [PHP5] PHP Debugger and Helper Categories : PHP, PHP Classes, Errors and Logging, Debugging, XML | | | Protect your mailto: email addresses from bots - pure PHP Categories : PHP, Email, Security | | | Visits-tracking Categories : PHP, Databases, MySQL, Errors and Logging, Functions | | | Solution to those 'tell-a-friend' type email issues Categories : PHP, Email, Databases, MySQL | | | Building a basic error handler with custom error types Categories : PHP, PHP Classes, Errors and Logging | | | PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use! Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP | | | phpEasyMail: An easy way to send data from HTML-forms via EMail. Categories : Email, HTML and PHP, Complete Programs, PHP | | | validateEmail 2.0 - upgraded version of the old validateEmail function used to validate email
addresses via SMTP and regex. Categories : Email, Regexps, PHP | | | Broadcast HTML Email Categories : PHP, Email, MySQL, Databases | | | POP3 Class Categories : PHP Classes, PHP, Email | |
|
|