Exemplo n.º 1
0
 /**
  * Run!
  *
  * @return void
  */
 protected static function run()
 {
     // Get the RenderedPage (if applicable)
     if (ob_get_length()) {
         self::$rendered_page = ob_get_contents();
         ob_clean();
     }
     // Setup the FileLinesArray
     if (is_file(self::$filename)) {
         self::$file_lines_array = file(self::$filename);
     } elseif (strpos(self::$filename, 'eval()') !== false) {
         self::$file_lines_array = array('File listing unavailable; eval()\'d code');
     } else {
         self::$file_lines_array = array('File Not Found: ' . self::$filename);
     }
     // set up the message body
     if (self::$additional_message) {
         self::$message_body = htmlentities(self::$additional_message) . '<br>' . htmlentities(self::$message);
     } else {
         self::$message_body = htmlentities(self::$message);
     }
     // replace spaces with non-breaking spaces
     self::$message_body = str_replace(" ", "&nbsp;", str_replace("\n", "<br>\n", self::$message_body));
     // this makes a bit cleaner format
     self::$message_body = str_replace(":&nbsp;", ": ", self::$message_body);
     // determine datetime
     $microtime = microtime();
     $microtime_parts = explode(' ', $microtime);
     $microtime = substr($microtime_parts[0], 2);
     $timestamp = $microtime_parts[1];
     // assign time info to local props
     self::$date_time_of_error = date('l, F j Y, g:i:s.' . $microtime . ' A T', $timestamp);
     self::$iso_date_time_of_error = date('Y-m-d H:i:s T', $timestamp);
     // cleanup
     unset($microtime);
     unset($microtime_parts);
     unset($microtime);
     unset($timestamp);
     // generate the error dump
     if (!ob_get_level()) {
         ob_start();
     }
     // special ajax handling
     if (ICE_AJAX_REQUEST) {
         // reset the buffer
         while (ob_get_level()) {
             ob_end_clean();
         }
         // setup the friendly response
         header('Content-Type: text/html');
         // spit out the error
         print '0[[[s]]]';
         // spit out message?
         if (defined('ICE_ERROR_AJAX_MESSAGE')) {
             // spit out customizable error
             print ICE_ERROR_AJAX_MESSAGE;
         } else {
             // spit out default error
             print 'An error has occured. Spitting out debug info is on our TODO list!';
         }
     } else {
         // wicked bad error there, kid
         header('HTTP/1.1 500 Internal Server Error');
         // load error page if defined
         if (defined('ICE_ERROR_PAGE_PATH') && ICE_ERROR_PAGE_PATH) {
             // reset the buffer
             while (ob_get_level()) {
                 ob_end_clean();
             }
             // load the error page
             require ICE_ERROR_PAGE_PATH;
         } else {
             // load dump template
             require dirname(__FILE__) . '/dump.php';
         }
     }
     exit;
 }