Библиотека для cis, online, cms1
This commit is contained in:
commit
3c2e614d87
269 changed files with 39854 additions and 0 deletions
86
core/error.php
Normal file
86
core/error.php
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
// Report simple running errors
|
||||
define('ERROR_FILE', 'phedor@edu.yar.ru');
|
||||
define('ERROR_TYPE', 1);
|
||||
|
||||
ini_set('error_reporting', 0);
|
||||
ini_set('display_errors', 0);
|
||||
error_reporting(0);
|
||||
|
||||
function get_error_name($id) {
|
||||
$names = array(1 => 'E_ERROR',
|
||||
2 => 'E_WARNING',
|
||||
4 => 'E_PARSE',
|
||||
8 => 'E_NOTICE',
|
||||
16 => 'E_CORE_ERROR',
|
||||
32 => 'E_CORE_WARNING',
|
||||
64 => 'E_COMPILE_ERROR',
|
||||
128 => 'E_COMPILE_WARNING',
|
||||
256 => 'E_USER_ERROR',
|
||||
512 => 'E_USER_WARNING',
|
||||
1024 => 'E_USER_NOTICE',
|
||||
2048 => 'E_STRICT',
|
||||
4096 => 'E_RECOVERABLE_ERROR',
|
||||
8192 => 'E_DEPRECATED',
|
||||
16384 => 'E_USER_DEPRECATED',
|
||||
30719 => 'E_ALL');
|
||||
return $names[$id];
|
||||
}
|
||||
|
||||
|
||||
function send_error($description) {
|
||||
$message = "request: " . "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] . "\n";
|
||||
$message .= "from: " . $_SERVER['REMOTE_ADDR'] . "\n";
|
||||
if(isset($_SERVER['HTTP_REFERER'])) $message .= "referer: " . $_SERVER['HTTP_REFERER'] . "\n";
|
||||
$message .= "post:" . var_export($_POST, true) . "\n";
|
||||
$message .= "description: " . $description;
|
||||
|
||||
// error_log($message, ERROR_TYPE, ERROR_FILE);
|
||||
return false;
|
||||
}
|
||||
|
||||
function error_handler($errno, $errstr, $errfile, $errline) {
|
||||
$message = "request: " . "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] . "\n";
|
||||
$message .= "from: " . $_SERVER['REMOTE_ADDR'] . "\n";
|
||||
if(isset($_SERVER['HTTP_REFERER'])) $message .= "referer: " . $_SERVER['HTTP_REFERER'] . "\n";
|
||||
$message .= "post:" . var_export($_POST, true) . "\n";
|
||||
$message .= "type: " . get_error_name($errno) . "\n"
|
||||
. "error: " . $errstr . "\n"
|
||||
. "line: " . $errline . "\n"
|
||||
. "file: " . $errfile;
|
||||
|
||||
// error_log($message, ERROR_TYPE, ERROR_FILE);
|
||||
return false;
|
||||
}
|
||||
|
||||
function shutdown() {
|
||||
$error = error_get_last();
|
||||
$message = "request: " . "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] . "\n";
|
||||
$message .= "from: " . $_SERVER['REMOTE_ADDR'] . "\n";
|
||||
if(isset($_SERVER['HTTP_REFERER'])) $message .= "referer: " . $_SERVER['HTTP_REFERER'] . "\n";
|
||||
if (is_array($error)) {
|
||||
foreach ($error as $info => $string) {
|
||||
$message .= "{$info}: {$string}\n";
|
||||
}
|
||||
}
|
||||
|
||||
error_log($message, ERROR_TYPE, ERROR_FILE);
|
||||
}
|
||||
|
||||
function exception_handler($exception) {
|
||||
$message = "request: " . "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] . "\n";
|
||||
$message .= "from: " . $_SERVER['REMOTE_ADDR'] . "\n";
|
||||
if(isset($_SERVER['HTTP_REFERER'])) $message .= "referer: " . $_SERVER['HTTP_REFERER'] . "\n";
|
||||
$message .=
|
||||
"file: " . $exception->getFile() . "\n"
|
||||
. "line: " . $exception->getLine() . "\n"
|
||||
. "message: " . $exception->getMessage() . "\n"
|
||||
. "trace: " . $exception->getTraceAsString();
|
||||
error_log($message, ERROR_TYPE, ERROR_FILE);
|
||||
return true;
|
||||
}
|
||||
|
||||
set_exception_handler('exception_handler');
|
||||
set_error_handler("error_handler");
|
||||
//register_shutdown_function('shutdown');
|
||||
Loading…
Add table
Add a link
Reference in a new issue