/** * Handles error messages * * @param int $type The error code * @param string $message A string describing the error * @param string $file The filename in which the error occurred * @param int $line The line number on which the error occurred * @author Jason Warner <*****@*****.**> * @since Beta 2.0 * @return void **/ function error($type, $message, $file = null, $line = 0) { global $set; // Get the settings! if (isset($_GET['debug']) || function_exists('error_fatal') || !(error_reporting() & $type)) { return; } include $set['include_path'] . '/lib/error.php'; switch ($type) { // Triggered Quicksilver Forums errors case QUICKSILVER_ERROR: exit(error_warning($message, $file, $line)); break; // Triggered Quicksilver Forums notices and alerts // Triggered Quicksilver Forums notices and alerts case QUICKSILVER_NOTICE: exit(error_notice($message)); break; // Database errors // Database errors case QUICKSILVER_QUERY_ERROR: exit(error_fatal($type, $message, $file, $line)); break; // PHP errors // PHP errors default: exit(error_fatal($type, $message, $file, $line)); break; } }
/** * Returns notices output rendering and reset notices * * @return string */ function error_notices_render() { if (option('debug') && option('env') > ENV_PRODUCTION) { $notices = error_notice(); error_notice(null); // reset notices $c_view_dir = option('views_dir'); // keep for restore after render option('views_dir', option('limonade_views_dir')); $o = render('_notices.html.php', null, array('notices' => $notices)); option('views_dir', $c_view_dir); // restore current views dir return $o; } }
/** * Default error handler * * @param string $errno * @param string $errstr * @param string $errfile * @param string $errline * @return string error output */ function error_default_handler($errno, $errstr, $errfile, $errline) { $is_http_err = http_response_status_is_valid($errno); $http_error_code = $is_http_err ? $errno : SERVER_ERROR; status($http_error_code); if (($errno == E_USER_NOTICE || $errno == E_NOTICE) && option('debug')) { $o = "<p>[" . error_type($errno) . "] "; $o .= "{$errstr} in <strong>{$errfile}</strong> line <strong>{$errline}</strong>: "; $o .= "</p>"; error_notice($o); return; } return $http_error_code == NOT_FOUND ? error_not_found_output($errno, $errstr, $errfile, $errline) : error_server_error_output($errno, $errstr, $errfile, $errline); }
/** * Handles error messages * * @param int $type The error code * @param string $message A string describing the error * @param string $file The filename in which the error occurred * @param int $line The line number on which the error occurred * @author Jason Warner <*****@*****.**> * @since Beta 2.0 * @return void **/ function error($type, $message, $file = null, $line = 0) { if (isset($_GET['debug']) || function_exists('error_fatal') || !(error_reporting() & $type)) { return; } $include = './lib/error.php'; if (!file_exists($include)) { $include = '.' . $include; // Admin Center errors } include $include; switch ($type) { // Triggered Quicksilver Forums errors case QUICKSILVER_ERROR: exit(error_warning($message, $file, $line)); break; // Triggered Quicksilver Forums notices and alerts // Triggered Quicksilver Forums notices and alerts case QUICKSILVER_NOTICE: exit(error_notice($message)); break; // Database errors // Database errors case QUICKSILVER_QUERY_ERROR: exit(error_fatal($type, $message, $file, $line)); break; // PHP errors // PHP errors default: exit(error_fatal($type, $message, $file, $line)); break; } }
/** * Returns notices output rendering and reset notices * * @return string */ function error_notices_render() { if (option('debug') && option('env') > ENV_PRODUCTION) { $notices = error_notice(); error_notice(null); // reset notices if (empty($notices)) { return ''; } ob_start(); ?> <div class="lim-debug lim-notices"> <h4> → Notices and warnings</h4> <dl> <?php $cpt = 1; foreach ($notices as $notice) { ?> <dt>[<?php echo $cpt . '. ' . error_type($notice['errno']); ?> ]</dt> <dd> <?php echo $notice['errstr']; ?> in <strong><code><?php echo $notice['errfile']; ?> </code></strong> line <strong><code><?php echo $notice['errline']; ?> </code></strong> </dd> <?php $cpt++; } ?> </dl> <hr> </div> <?php return ob_get_clean(); } }