/** * Eight output handler. * * @param string current output buffer * @return string */ public static function output_buffer($output) { if (!Event::has_run('system.send_headers')) { // Run the send_headers event, specifically for cookies being set Event::run('system.send_headers'); } // Set final output self::$output = $output; // Look for errors in the output buffer if (!self::$configuration['core']['display_errors'] && self::$configuration['core']['catch_all_errors']) { if (preg_match('#<phperror>.*</phperror>#is', self::$output, $matches)) { // We only care about the first error $match = $matches[0]; // Pull some info out of the error preg_match('#error:(.*)\\ in\\ (.*)\\ on\\ line ([0-9]+)#i', strip_tags($match), $matches); $error = new Eight_Exception_PHP(E_ERROR, trim($matches[1]), trim($matches[2]), trim($matches[3])); // Log the error self::log('error', Eight_Exception_PHP::text($error)); self::log_save(); // Show the pretty error page self::$output = file_get_contents(self::find_file('views', 'eight/error_disabled', TRUE)); } } // Set and return the final output return self::$output; }