function fatalErrorShutdownHandler() { $last_error = error_get_last(); if ($last_error['type'] === E_ERROR) { // fatal error myErrorHandler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); } }
function fatalErrorShutdownHandler() { //echo 'being called'; $last_error = error_get_last(); //print_r($last_error); if ($last_error['type'] === E_ERROR) { // fatal error myErrorHandler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); } }
} // Build xml string from Quicktime data $stcoA = GetAtom($videtrak, "stco", 0); $stszA = GetAtom($videtrak, "stsz", 0); $stscA = GetAtom($videtrak, "stsc", 0); $stco_num = unpack("N1/N1num", $stcoA[0]); $stco_num = $stco_num["num"]; $stsz_num = unpack("N2/N1num", $stszA[0]); $stsz_num = $stsz_num["num"]; $stsc_num = unpack("N1/N1num", $stscA[0]); $stsc_num = $stsc_num["num"]; $stco = unpack("N2/N" . $stco_num . "tile", $stcoA[0]); $stsz = unpack("N3/N" . $stsz_num . "tile", $stszA[0]); $stsc = unpack("N2/N" . $stsc_num * 3 . "s2c", $stscA[0]); if ($stsz_num != count($tiles)) { myErrorHandler(-1, "Inconsistent number of tiles in tracks."); } if ($stco_num != $stsz_num) { $stsc["s2c" . (1 + $stsc_num * 3)] = $stco_num + 1; $stsz_index = 0; $stco_index = 0; $new_stco = array(); for ($s2c = 0; $s2c < $stsc_num; $s2c++) { for ($chunk = $stsc["s2c" . (1 + $s2c * 3)]; $chunk < $stsc["s2c" . (4 + $s2c * 3)]; $chunk++) { $stco_index++; $base = $stco["tile" . $stco_index]; //$base=0; $offset = 0; $c_numtiles = $stsc["s2c" . (2 + $s2c * 3)]; for ($tile = 0; $tile < $c_numtiles; $tile++) { $stsz_index++;
/** * Query an HTTP(S) URL with the given request parameters and return the * response headers and status code. The socket is returned as well and * will point to the begining of the response payload (after all headers * have been read), and must be closed with fclose(). * @param $url the request URL * @param $request the request method may optionally be overridden. * @param $timeout connection and read timeout in seconds */ function http_request($request, $timeout = 5) { $url = $request['url']; // Extract the hostname from url $parts = parse_url($url); if (array_key_exists('host', $parts)) { $remote = $parts['host']; } else { return myErrorHandler("url ({$url}) has no host. Is it relative?"); } if (array_key_exists('port', $parts)) { $port = $parts['port']; } else { $port = 0; } // Beware that RFC2616 (HTTP/1.1) defines header fields as case-insensitive entities. $request_headers = ""; foreach ($request['headers'] as $name => $value) { switch (strtolower($name)) { //omit some headers case "keep-alive": case "connection": case "cookie": //TODO: we don't handle any compression encodings. compression //can cause a problem if client communication is already being //compressed by the server/app that integrates this script //(which would double compress the content, once from the remote //server to us, and once from us to the client, but the client //would de-compress only once). //TODO: we don't handle any compression encodings. compression //can cause a problem if client communication is already being //compressed by the server/app that integrates this script //(which would double compress the content, once from the remote //server to us, and once from us to the client, but the client //would de-compress only once). case "accept-encoding": break; // correct the host parameter // correct the host parameter case "host": $host_info = $remote; if ($port) { $host_info .= ':' . $port; } $request_headers .= "{$name}: {$host_info}\r\n"; break; // forward all other headers // forward all other headers default: $request_headers .= "{$name}: {$value}\r\n"; break; } } //set fsockopen transport scheme, and the default port switch (strtolower($parts['scheme'])) { case 'https': $scheme = 'ssl://'; if (!$port) { $port = 443; } break; case 'http': $scheme = ''; if (!$port) { $port = 80; } break; default: //some other transports are available but not really supported //by this script: http://php.net/manual/en/transports.inet.php $scheme = $parts['scheme'] . '://'; if (!$port) { return myErrorHandler("Unknown scheme ({$scheme}) and no port."); } break; } //we make the request with socket operations since we don't want to //depend on the curl extension, and the higher level wrappers don't //give us usable error information. $sock = @fsockopen("{$scheme}{$remote}", $port, $errno, $errstr, $timeout); if (!$sock) { return myErrorHandler("Unable to open URL ({$url}): {$errstr}"); } //the timeout in fsockopen is only for the connection, the following //is for reading the content stream_set_timeout($sock, $timeout); //an absolute url should only be specified for proxy requests if (array_key_exists('path', $parts)) { $path_info = $parts['path']; } else { $path_info = '/'; } if (array_key_exists('query', $parts)) { $path_info .= '?' . $parts['query']; } if (array_key_exists('fragment', $parts)) { $path_info .= '#' . $parts['fragment']; } $out = $request["method"] . " " . $path_info . " " . $request["protocol"] . "\r\n" . $request_headers . "Connection: close\r\n\r\n"; fwrite($sock, $out); fwrite($sock, $request['payload']); $header_str = stream_get_line($sock, 1024 * 16, "\r\n\r\n"); $headers = http_parse_headers($header_str); $status_line = array_shift($headers); // get http status preg_match('|HTTP/\\d+\\.\\d+\\s+(\\d+)\\s+.*|i', $status_line, $match); $status = $match[1]; return array('headers' => $headers, 'socket' => $sock, 'status' => $status); }
function query($query) { global $cfg; // разбираем запрос $type = $this->parseQuery($query); // выполняем запрос try { $result = $this->link->query($query); // получаем результаты if (in_array($type, array('SELECT', 'SHOW'))) { $result->setFetchMode(PDO::FETCH_OBJ); while ($row = $result->fetch()) { $res[] = $row; } } elseif (in_array($type, array('INSERT'))) { $res[] = $this->link->lastInsertId(); } // увеличиваем счетчик запросов $this->callsCount++; // если дебаг включен то добавляем запрос в лог if ($cfg['debug'] == true) { $this->callsDebug[] = $query; } if ($this->rawDebug == true) { logError($query); } } catch (PDOException $e) { myErrorHandler(0, $e->getMessage() . "\n" . $query, __FILE__, __LINE__); } return isset($res) ? $res : NULL; }
function myErrorHandler($no = null, $msg = null, $file = null, $line = null, $plus = null) { $no1 = $no; if (!$no) { #called as shutdown function $error = error_get_last(); if ($error !== NULL && $error["type"] == 1) { $no = E_ERROR; $msg = $error['message']; $file = $error['file']; $line = $error['line']; } } static $errors; if ($no === 1 && $errors) { $s = ''; foreach ($errors as $k => $v) { $s .= '-' . $k . ' ' . $v . "\n"; } $errors = []; file_put_contents(ini_get('error_log'), $s, FILE_APPEND); return; /*records all encountered errors*/ } $errorType = [E_DEPRECATED => 0, E_NOTICE => 0, E_USER_NOTICE => 0, E_STRICT => 0, E_ERROR => 'ERROR', E_WARNING => 'WARNING', E_PARSE => 'PARSING ERROR', E_CORE_ERROR => 'CORE ERROR', E_CORE_WARNING => 'CORE WARNING', E_COMPILE_ERROR => 'COMPILE ERROR', E_COMPILE_WARNING => 'COMPILE WARNING', E_USER_ERROR => 'USER ERROR', E_USER_WARNING => 'USER WARNING', E_RECOVERABLE_ERROR => 'RECOVERABLE ERROR']; if (array_key_exists($no, $errorType)) { $no = $errorType[$no]; } else { $no = 'others'; } #if($error){echo in_array($no,[null,'ignore']);print_r(compact('no','error','msg'));} if (in_array($no, [null, 'ignore'])) { return; } #0 matches all string #specials if (strpos($msg, 'annot redeclare')) { Dbm(SU . ' fun defined ' . $msg, db2()); } if (!$msg) { return 0; } #stand error handler continues here :) $msg=SU; if (strpos($msg, "\n") !== false) { $msg = explode("\n", $msg); $msg = reset($msg); } #no stack trace !! $errors[str_replace('/z/', '', $file) . ':' . $line] = $no . ' : ' . $msg; #if($no=='WARNING')throw new \Exception($msg,$no1);#no catch: uncaught exception .. if ($no == 'ERROR') { #fatal, no more would be handler if (stripos($error['message'], 'Call to undefined function') !== false) { $f = 'lib/fun.map.php'; if (!$_ENV['funmap'] && is_file($f)) { $_ENV['funmap'] = unserialize(file_get_contents($f)); #tion r302 -> fun.php } if (preg_match('#function ([^\\(]+)\\(\\) #', $error['message'], $m)) { if (array_key_exists($m[1], $_ENV['funmap'])) { $load = new $m[1](); #requires autoload.php } } } myErrorHandler(1); ob_end_clean(); header("HTTP/1.0 500 Internal Server Error", 1, 500); if (AJAX) { die('/*500*/'); } #js or css echo "<html><head><title>500 error</title><style>body{background:#003;color:#AAA;}</style></head><body><table width=100% height=100% border=0 align=center><tr><td><center><h1>500 - une erreur est survenue<br>" . (is_string($m) ? $m : '') . "<br><a href='/'><img src='http://x24.fr/immologo1.png'><br>Retour a l'accueil</a></h1><br><form action='http://google.fr/search' method=get><input type=hidden name=q value='site:" . H . "'><input name=q><input type=submit value=rechercher></form></td></tr></table>" . $f . "</body></html>"; die; return 1; } return compact('msg', 'file', 'line'); #for try catch block }
function myErrorHandler_silent($errno, $errstr, $errfile, $errline) { myErrorHandler($errno, $errstr, $errfile, $errline, true); }