Пример #1
0
 function ak_development_error_handler($error_number, $error_message, $file, $line)
 {
     static $_sent_errors = array(), $_errors_shown = false;
     $error_number = $error_number & error_reporting();
     if ($error_number == 0) {
         return;
     }
     /**
      * resetting content-encoding header to nil,
      * if it was set to gzip before, otherwise we get an encoding error
      */
     if (AK_WEB_REQUEST) {
         $headers = headers_list();
         if (in_array('Content-Encoding: gzip', $headers) || in_array('Content-Encoding: xgzip', $headers)) {
             header('Content-Encoding: none');
         }
     }
     while (ob_get_level()) {
         ob_end_clean();
     }
     if (!defined('E_STRICT')) {
         define('E_STRICT', 2048);
     }
     if (!defined('E_RECOVERABLE_ERROR')) {
         define('E_RECOVERABLE_ERROR', 4096);
     }
     switch ($error_number) {
         case E_ERROR:
             $error_type = "Error";
             break;
         case E_WARNING:
             $error_type = "Warning";
             break;
         case E_PARSE:
             $error_type = "Parse Error";
             break;
         case E_NOTICE:
             $error_type = "Notice";
             break;
         case E_CORE_ERROR:
             $error_type = "Core Error";
             break;
         case E_CORE_WARNING:
             $error_type = "Core Warning";
             break;
         case E_COMPILE_ERROR:
             $error_type = "Compile Error";
             break;
         case E_COMPILE_WARNING:
             $error_type = "Compile Warning";
             break;
         case E_USER_ERROR:
             $error_type = "User Error";
             break;
         case E_USER_WARNING:
             $error_type = "User Warning";
             break;
         case E_USER_NOTICE:
             $error_type = "User Notice";
             break;
         case E_STRICT:
             $error_type = "Strict Notice";
             break;
         case E_RECOVERABLE_ERROR:
             $error_type = "Recoverable Error";
             break;
         default:
             $error_type = "Unknown error ({$error_number})";
             break;
     }
     if (isset($_sent_errors[$error_type . $error_message])) {
         return;
     } else {
         $_sent_errors[$error_type . $error_message] = true;
     }
     AK_DEBUG_OUTPUT_AS_HTML ? print '<pre>' : null;
     //$result = ": <h3>$error_message</h3> in  $file on line $line\n";
     $result = "<div style='text-align:left;'><h3 style='padding:5px; background-color:#f00;color:#fff'>({$error_type}) {$error_message}</h3>";
     //$result .= ak_show_source_line($file, $line);
     //ak_show_app_backtrace();
     if (AK_DEBUG_OUTPUT_AS_HTML) {
         $result .= " <a href='javascript:void(0);' onclick='ak_lib_backtrace = document.getElementById(\"ak_lib_backtrace\").style.display = \"block\";document.getElementById(\"ak_app_backtrace\").style.display = \"none\";this.style.display = \"none\"'>show full trace</a>";
         $result .= '<div id="ak_app_backtrace">' . ak_backtrace(true) . '</div>';
     }
     $result .= '<div id="ak_lib_backtrace" style="display:none">' . ak_backtrace() . '</div>';
     if (!$_errors_shown && $line > 0) {
         $_app_files_shown = true;
         foreach (ak_get_application_included_files($file) as $type => $files) {
             $result .= "<h2>{$type}</h2>";
             $result .= "<ul>";
             foreach ($files as $k => $file) {
                 $result .= "<li style='margin:0;padding:0;'>" . $file['path'] . (empty($file['original_path']) ? '' : " <a href='#" . md5($file['original_path']) . '-' . $line . "' onclick='element_{$k} = document.getElementById(\"ak_debug_{$k}\"); element_{$k}.style.display = (element_{$k}.style.display == \"none\"?\"block\":\"none\");'>show source</a>\n                <div id='ak_debug_{$k}' style='display:none;'>" . ak_highlight_file($file['original_path'], $line) . "</div>") . "</li>";
             }
             $result .= "</ul><div style='clear:both;'></div>";
         }
     }
     $result .= '</div>';
     echo !AK_DEBUG_OUTPUT_AS_HTML ? html_entity_decode(strip_tags($result)) : '<div style="background-color:#fff;margin:10px;padding:10px;color:#000;font-family:sans-serif;border-bottom:3px solid #f00;font-size:12px;">' . $result . '</div>';
     AK_DEBUG_OUTPUT_AS_HTML ? print '</pre>' : null;
 }
Пример #2
0
 public function failTransaction()
 {
     if(AK_DEBUG && !empty($this->connection->debug)){
         Ak::trace(ak_backtrace(), null, null, null, false);
     }
     return $this->connection->FailTrans();
 }