/** * Dual-purpose PHP error and exception handler. Uses the kohana_error_page * view to display the message. * * @param integer|object exception object or error code * @param string error message * @param string filename * @param integer line number * @return void */ public static function exception_handler($exception, $message = NULL, $file = NULL, $line = NULL) { // PHP errors have 5 args, always $PHP_ERROR = func_num_args() === 5; // Test to see if errors should be displayed if ($PHP_ERROR and (error_reporting() & $exception) === 0) { return; } // This is useful for hooks to determine if a page has an error self::$has_error = TRUE; // Error handling will use exactly 5 args, every time if ($PHP_ERROR) { $code = $exception; $type = 'PHP Error'; $template = 'kohana_error_page'; } else { $code = $exception->getCode(); $type = get_class($exception); $message = $exception->getMessage(); $file = $exception->getFile(); $line = $exception->getLine(); $template = $exception instanceof Kohana_Exception ? $exception->getTemplate() : 'kohana_error_page'; } if (is_numeric($code)) { $codes = self::lang('errors'); if (!empty($codes[$code])) { list($level, $error, $description) = $codes[$code]; } else { $level = 1; $error = $PHP_ERROR ? 'Unknown Error' : get_class($exception); $description = ''; } } else { // Custom error message, this will never be logged $level = 5; $error = $code; $description = ''; } // Remove the DOCROOT from the path, as a security precaution $file = str_replace('\\', '/', realpath($file)); $file = preg_replace('|^' . preg_quote(DOCROOT) . '|', '', $file); if ($level <= self::$configuration['core']['log_threshold']) { // Log the error self::log('error', self::lang('core.uncaught_exception', $type, $message, $file, $line)); } if ($PHP_ERROR) { $description = self::lang('errors.' . E_RECOVERABLE_ERROR); $description = is_array($description) ? $description[2] : ''; if (!headers_sent()) { // Send the 500 header header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error'); } } else { if (method_exists($exception, 'sendHeaders') and !headers_sent()) { // Send the headers if they have not already been sent $exception->sendHeaders(); } } while (ob_get_level() > self::$buffer_level) { // Close open buffers ob_end_clean(); } // Test if display_errors is on if (self::$configuration['core']['display_errors'] === TRUE) { if (!IN_PRODUCTION and $line != FALSE) { // Remove the first entry of debug_backtrace(), it is the exception_handler call $trace = $PHP_ERROR ? array_slice(debug_backtrace(), 1) : $exception->getTrace(); // Beautify backtrace $trace = self::backtrace($trace); } // Load the error require self::find_file('views', empty($template) ? 'kohana_error_page' : $template); } else { // Get the i18n messages $error = self::lang('core.generic_error'); $message = self::lang('core.errors_disabled', url::site(), url::site(Router::$current_uri)); // Load the errors_disabled view require self::find_file('views', 'kohana_error_disabled'); } if (!Event::has_run('system.shutdown')) { // Run the shutdown even to ensure a clean exit Event::run('system.shutdown'); } // Turn off error reporting error_reporting(0); exit; }
*/ ?> <div class="bg"> <h2> <?php echo Kohana::lang('ui_admin.checkins'); ?> </h2> <?php Event::run('ushahidi_action.admin_checkins_custom_layout'); ?> <?php // Kill the rest of the page if this event has been utilized by a plugin if (!Event::has_run('ushahidi_action.admin_checkins_custom_layout')) { ?> <!-- tabs --> <div class="tabs"> <!-- tab --> <div class="tab"> <ul> <li><a href="#" onClick="checkinsAction('d', 'DELETE', '')"><?php echo utf8::strtoupper(Kohana::lang('ui_main.delete')); ?> </a></li> </ul> </div> </div> <?php
* @module API Controller * @copyright Ushahidi - http://www.ushahidi.com * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL) */ ?> <div class="bg"> <h2> <?php admin::messages_subtabs($service_id); ?> </h2> <?php Event::run('ushahidi_action.admin_messages_custom_layout'); // Kill the rest of the page if this event has been utilized by a plugin if (!Event::has_run('ushahidi_action.admin_messages_custom_layout')) { ?> <!-- tabs --> <div class="tabs"> <!-- tabset --> <ul class="tabset"> <li><a href="<?php echo url::site() . "admin/messages/index/" . $service_id; ?> ?type=1" <?php if ($type == '1') { echo "class=\"active\""; } ?> ><?php
/** * Sends a page redirect header and runs the system.redirect Event. * * @param mixed string site URI or URL to redirect to, or array of strings if method is 300 * @param string HTTP method of redirect * @return void */ public static function redirect($uri = '', $method = '302') { if (Event::has_run('system.send_headers')) { return FALSE; } $codes = array('refresh' => 'Refresh', '300' => 'Multiple Choices', '301' => 'Moved Permanently', '302' => 'Found', '303' => 'See Other', '304' => 'Not Modified', '305' => 'Use Proxy', '307' => 'Temporary Redirect'); // Validate the method and default to 302 $method = isset($codes[$method]) ? (string) $method : '302'; if ($method === '300') { $uri = (array) $uri; $output = '<ul>'; foreach ($uri as $link) { $output .= '<li>' . html::anchor($link) . '</li>'; } $output .= '</ul>'; // The first URI will be used for the Location header $uri = $uri[0]; } else { $output = '<p>' . html::anchor($uri) . '</p>'; } // Run the redirect event Event::run('system.redirect', $uri); if (strpos($uri, '://') === FALSE) { // HTTP headers expect absolute URLs $uri = url::site($uri, request::protocol()); } if ($method === 'refresh') { header('Refresh: 0; url=' . $uri); } else { header('HTTP/1.1 ' . $method . ' ' . $codes[$method]); header('Location: ' . $uri); } // We are about to exit, so run the send_headers event Event::run('system.send_headers'); exit('<h1>' . $method . ' - ' . $codes[$method] . '</h1>' . $output); }
/** * Kohana output handler. Called during ob_clean, ob_flush, and their variants. * * @param string current output buffer * @return string */ public static function output_buffer($output) { // Could be flushing, so send headers first if (!Event::has_run('system.send_headers')) { // Run the send_headers event Event::run('system.send_headers'); } // Set final output Kohana::$output = $output; // Set and return the final output return Kohana::$output; }
/** * Sends a page redirect header. * * @param mixed string site URI or URL to redirect to, or array of strings if method is 300 * @param string HTTP method of redirect * @return void */ public static function redirect($uri = '', $method = '302') { if (Event::has_run('system.send_headers')) { return; } $uri = (array) $uri; for ($i = 0, $count_uri = count($uri); $i < $count_uri; $i++) { if (strpos($uri[$i], '://') === FALSE) { $uri[$i] = url::site($uri[$i]); } } if ($method == '300') { if ($count_uri > 0) { header('HTTP/1.1 300 Multiple Choices'); header('Location: ' . $uri[0]); $choices = ''; foreach ($uri as $href) { $choices .= '<li><a href="' . $href . '">' . $href . '</a></li>'; } exit('<h1>301 - Multiple Choices:</h1><ul>' . $choices . '</ul>'); } } else { $uri = $uri[0]; if ($method == 'refresh') { header('Refresh: 0; url=' . $uri); } else { $codes = array('301' => 'Moved Permanently', '302' => 'Found', '303' => 'See Other', '304' => 'Not Modified', '305' => 'Use Proxy', '307' => 'Temporary Redirect'); $method = isset($codes[$method]) ? $method : '302'; header('HTTP/1.1 ' . $method . ' ' . $codes[$method]); header('Location: ' . $uri); } exit('<h1>' . $method . ' - ' . $codes[$method] . '</h1><p><a href="' . $uri . '">' . $uri . '</a></p>'); } }
/** * 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; }
/** * 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; // Set and return the final output return self::$output; }