public static function code_error_handler($error_code, $error_string, $error_file, $error_line) { /*if(!(error_reporting() & $error_code)) { return; }*/ switch ($error_code) { case E_USER_ERROR: $error_type = 'PROBLEM'; if (pts_client::is_client_debug_mode() == false) { $error_file = null; $error_line = 0; } break; case E_USER_NOTICE: if (pts_client::is_client_debug_mode() == false) { return; } $error_type = 'NOTICE'; break; case E_USER_WARNING: $error_type = 'NOTICE'; // Yes, report warnings as a notice if (pts_client::is_client_debug_mode() == false) { $error_file = null; $error_line = 0; } break; case E_ERROR: case E_PARSE: $error_type = 'ERROR'; break; case E_WARNING: case E_NOTICE: $error_type = 'NOTICE'; if (($s = strpos($error_string, 'Undefined ')) !== false && ($x = strpos($error_string, ': ', $s)) !== false) { $error_string = 'Undefined: ' . substr($error_string, $x + 2); } else { $ignore_errors = array('Name or service not known', 'HTTP request failed', 'fopen', 'fsockopen', 'file_get_contents', 'failed to connect', 'unable to connect', 'directory not empty'); foreach ($ignore_errors as $error_check) { if (stripos($error_string, $error_check) !== false) { return; } } } break; default: $error_type = $error_code; break; } if (pts_client::$pts_logger != false) { pts_client::$pts_logger->report_error($error_type, $error_string, $error_file, $error_line); } if (pts_client::$display != false) { pts_client::$display->triggered_system_error($error_type, $error_string, $error_file, $error_line); } else { echo PHP_EOL . $error_string; if ($error_file != null && $error_line != null) { echo ' in ' . $error_file . ':' . $error_line; } echo PHP_EOL; } if ($error_type == 'ERROR') { exit(1); } }