/**
  * Display an error message
  *
  * @access	public
  * @param	string	the error message
  * @param	string	any "swap" values
  * @param	boolean	whether to localize the message
  * @return	string	sends the application/error_db.php template		
  */
 function display_error($error = '', $swap = '', $native = FALSE)
 {
     $LANG = new CI_Language();
     $LANG->load('db');
     $heading = 'MySQL Error';
     if ($native == TRUE) {
         $message = $error;
     } else {
         $message = !is_array($error) ? array(str_replace('%s', $swap, $LANG->line($error))) : $error;
     }
     if (!class_exists('CI_Exceptions')) {
         include BASEPATH . 'libraries/Exceptions' . EXT;
     }
     $error = new CI_Exceptions();
     echo $error->show_error('An Error Was Encountered', $message, 'error_db');
     exit;
 }
示例#2
0
 function show_php_error($severity, $message, $filepath, $line)
 {
     // don't do this unless specifically allowed
     if (wpci_display_errors()) {
         parent::show_php_errors($severity, $message, $filepath, $line);
     }
 }
 public function show_php_error($severity, $message, $filepath, $line)
 {
     $ci =& get_instance();
     // this allows different params for different environments
     $ci->config->load('email_php_errors');
     // if it's enabled
     if (config_item('email_php_errors')) {
         // set up email with config values
         $ci->load->library('email');
         $ci->email->from(config_item('php_error_from'));
         $ci->email->to(config_item('php_error_to'));
         // set up subject
         $subject = config_item('php_error_subject');
         $subject = $this->_replace_short_tags($subject, $severity, $message, $filepath, $line);
         $ci->email->subject($subject);
         // set up content
         $content = config_item('php_error_content');
         $content = $this->_replace_short_tags($content, $severity, $message, $filepath, $line);
         // set message and send
         $ci->email->message($content);
         $ci->email->send();
     }
     $msg = 'Severity: ' . $severity . '  --> ' . $message . ' ' . $filepath . ' ' . $line;
     // do the rest of the codeigniter stuff
     parent::show_php_error($severity, $message, $filepath, $line);
 }
 /**
  * Initialize execption class
  *
  * @return    void
  */
 public function __construct()
 {
     parent::__construct();
     if (function_exists('get_instance') && class_exists('CI_Controller', false)) {
         $this->ci = get_instance();
     }
 }
 function show_404($lang_id = 'br')
 {
     if (is_callable('redirect') && is_callable('site_url_lang')) {
         redirect(site_url_lang('/404', $lang_id));
     } else {
         parent::show_404();
     }
 }
示例#6
0
 function __construct()
 {
     parent::__construct();
     if (class_exists('CI_Controller')) {
         $this->ci =& get_instance();
     } else {
         require_once ARCHPATH . 'helpers/x_helper.php';
     }
 }
示例#7
0
 function _remap($method)
 {
     // This page has been routed to with pages/view/whatever
     if ($this->uri->rsegment(1, '') . '/' . $method == 'pages/view') {
         $url_segments = $this->uri->total_rsegments() > 0 ? $this->uri->rsegment_array() : array($this->default_segment);
         $url_segments = array_slice($url_segments, 2);
     } else {
         $url_segments = $this->uri->total_segments() > 0 ? $this->uri->segment_array() : array($this->default_segment);
     }
     // Fetch this page from the database via cache
     $page = $this->cache->model('pages_m', 'get_by_path', array($url_segments));
     // If page is missing or not live (and not an admin) show 404
     if (!$page || $page->status == 'draft' && !$this->user_lib->check_role('admin')) {
         // Try and get an error page. If its been deleted, show nasty 404
         if (!($page = $this->cache->model('pages_m', 'get_by_path', array('404')))) {
             log_message('error', '404 Page Not Found --> ' . implode('/', $url_segments));
             $EXP = new CI_Exceptions();
             echo $EXP->show_error('', '', 'error_404', 404);
             exit;
         }
     }
     // 404 page? Set the right status
     if ($page->slug == '404') {
         $this->output->set_status_header(404);
     }
     // Not got a meta title? Use slogan for homepage or the normal page title for other pages
     if ($page->meta_title == '') {
         $page->meta_title = $this->viewing_homepage ? $this->settings->item('site_slogan') : $page->title;
     }
     // If the GET variable isbasic exists, do not use a wrapper
     if (!($page->layout = $this->page_layouts_m->get($page->layout_id))) {
         // Some pillock deleted the page layout, use the default and pray to god they didnt delete that too
         $page->layout = $this->page_layouts_m->get(1);
     }
     // Parser does not need ALL information for this bit, and I hate the Dwoo object syntax
     $page_array = array('page' => (array) $page);
     // Parse the layout string and output
     $page->layout->body = $this->parser->string_parse(stripslashes($page->layout->body), $page_array, TRUE);
     // Define data elements
     $this->data->page =& $page;
     $this->data->page->layout = $page->layout;
     // Create page output
     $this->template->title($page->meta_title)->set_metadata('keywords', $page->meta_keywords)->set_metadata('description', $page->meta_description)->build('index', $this->data);
 }
 function show_404($page = '', $log_error = TRUE)
 {
     $this->config =& get_config();
     $base_url = $this->config['base_url'];
     header("location: " . $base_url . 'error/h404/' . $page);
     //include()
     //include($this->absolute_path() . "index.php?error/404/" . $page);
     die;
     // Header didn't redirect, go to a backup
     parent::show_404($page, $log_error);
 }
示例#9
0
 public function show_php_error($severity, $message, $filepath, $line)
 {
     require_once APPPATH . 'helpers/response_helper.php';
     if (ResponseIsJson()) {
         ResponseCrossSite(['error' => ['message' => $message, 'file' => $filepath, 'line' => $line, 'severity' => $severity]], 403);
     } else {
         $OUT =& load_class('output', 'core');
         $OUT->set_content_type('text/html');
         parent::show_php_error($severity, $message, $filepath, $line);
     }
 }
示例#10
0
 /**
  * Construct
  *
  * Sets the error handlers.
  *
  * @access	public
  * @return	void
  */
 public function __construct()
 {
     parent::__construct();
     //Set the Exception Handler
     set_exception_handler(array('MY_Exceptions', 'exception_handler'));
     // Set the Error Handler
     set_error_handler(array('MY_Exceptions', 'error_handler'));
     // Set the handler for shutdown to catch Parse errors
     register_shutdown_function(array('MY_Exceptions', 'shutdown_handler'));
     // This is a hack to set the default timezone if it isn't set. Not setting it causes issues.
     date_default_timezone_set(date_default_timezone_get());
 }
示例#11
0
 function show_exception($exception)
 {
     if (!is_null($CI =& get_instance())) {
         $message = $exception->getMessage();
         if (empty($message)) {
             $message = '(null)';
         }
         $error_data['exception'] = $exception;
         $error_data['message'] = $message;
         $CI->load->helper('email');
         report_error('error_exception', $error_data);
     }
     return parent::show_exception($exception);
 }
示例#12
0
 function __construct()
 {
     parent::__construct();
     if (class_exists('CI_Controller')) {
         $CI =& get_instance();
         if (!empty($CI)) {
             $CI->lang->load_gettext();
         } else {
             $GLOBALS['LANG']->load_gettext();
         }
     } else {
         require_once ARCHPATH . 'helpers/x_helper' . EXT;
     }
 }
示例#13
0
 /**
  * PHP error handler
  *
  * Overriding the error handler to be a little more efficient/helpful.
  * When executed on a dev/staging environment we want the normal error reporting
  * but when executed on a production box we want errors to be logged to the DB and
  * any output muted. Sever errors should generate an exception in the CodeBase project
  *
  * @access	private
  * @param	string	a message to pass to the view, if any
  * @param	boolean	whether to log the error or not
  * @return	void
  */
 function show_php_error($severity, $message, $filepath, $line)
 {
     $_temp = new stdClass();
     $_temp->severity = $severity;
     $_temp->message = $message;
     $_temp->filepath = $filepath;
     $_temp->line = $line;
     // --------------------------------------------------------------------------
     $this->error_has_occurred = TRUE;
     $this->recent_errors[] = $_temp;
     // --------------------------------------------------------------------------
     unset($_temp);
     // --------------------------------------------------------------------------
     return parent::show_php_error($severity, $message, $filepath, $line);
 }
示例#14
0
 /** 
  * Controller 
  * 
  * @access public 
  */
 function My_Exceptions()
 {
     parent::__construct();
 }
示例#15
0
 /**
  * Constructor
  *
  */
 function MY_Exceptions()
 {
     parent::CI_Exceptions();
     $this->ob_level = ob_get_level();
     // Note:  Do not log messages from this constructor.
 }
示例#16
0
 /**
  * Class constructor
  *
  */
 public function __construct()
 {
     parent::__construct();
     // Note: Do not log messages from this constructor.
 }
 /**
  * Class constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->CI =& get_instance();
 }
示例#18
0
 function MY_Exceptions()
 {
     parent::CI_Exceptions();
 }
示例#19
0
 function __construct()
 {
     parent::__construct();
     log_message('debug', 'MY_Exceptions Class Initialized');
 }
示例#20
0
 /**
  * General Error Page
  *
  * This function takes an error message as input
  * (either as a string or an array) and displays
  * it using the specified template.
  *
  * @access	private
  * @param	string	the heading
  * @param	string	the message
  * @param	string	the template name
  * @return	string
  */
 function show_error($heading, $message, $template = 'error_general', $status_code = 500)
 {
     // If we are in production, then lets dump out now.
     if (IN_PRODUCTION) {
         return parent::show_error($heading, $message, $template, $status_code);
     }
     if (!headers_sent()) {
         set_status_header($status_code);
     }
     $trace = debug_backtrace();
     $file = NULL;
     $line = NULL;
     $is_from_app = FALSE;
     if (isset($trace[1]['file']) and strpos($trace[1]['file'], APPPATH) === 0) {
         $is_from_app = !self::is_extension($trace[1]['file']);
     }
     // If the application called show_error, don't output a backtrace, just the error
     if ($is_from_app) {
         $message = '<p>' . implode('</p><p>', !is_array($message) ? array($message) : $message) . '</p>';
         if (ob_get_level() > $this->ob_level + 1) {
             ob_end_flush();
         }
         ob_start();
         include APPPATH . 'errors/' . $template . EXT;
         $buffer = ob_get_contents();
         ob_end_clean();
         return $buffer;
     }
     $message = implode(' / ', !is_array($message) ? array($message) : $message);
     // If the system called show_error, so lets find the actual file and line in application/ that caused it.
     foreach ($trace as $call) {
         if (isset($call['file']) and strpos($call['file'], APPPATH) === 0 and !self::is_extension($call['file'])) {
             $file = $call['file'];
             $line = $call['line'];
             break;
         }
     }
     unset($trace);
     self::exception_handler(new ErrorException($message, E_ERROR, 0, $file, $line));
     return;
 }
示例#21
0
 /**
  * __construct()
  * Class constructor.
  */
 public function __construct()
 {
     parent::__construct();
 }
示例#22
0
 /**
  * 404 method
  * @access public
  * @param array $url_segments The URL segments
  * @return void
  */
 public function _404($url_segments)
 {
     // Try and get an error page. If its been deleted, show nasty 404
     if (!($page = $this->cache->model('pages_m', 'get_by_path', array('404')))) {
         log_message('error', '404 Page Not Found --> ' . implode('/', $url_segments));
         $EXP = new CI_Exceptions();
         echo $EXP->show_error('', '', 'error_404', 404);
         exit;
     }
     return $page;
 }
示例#23
0
 function NIS_Exceptions()
 {
     parent::CI_Exceptions();
     $this->CI =& get_instance();
 }
/**
* Exception Handler
*
* This is the custom exception handler we defined at the
* top of this file. The main reason we use this is permit 
* PHP errors to be logged in our own log files since we may 
* not have access to server logs. Since this function
* effectively intercepts PHP errors, however, we also need
* to display errors based on the current error_reporting level.
* We do that with the use of a PHP error template.
*
* @access	private
* @return	void
*/
function _exception_handler($severity, $message, $filepath, $line)
{
    global $config;
    // We don't bother with "strict" notices since they will fill up
    // the log file with information that isn't normally very
    // helpful.  For example, if you are running PHP 5 and you
    // use version 4 style class functions (without prefixes
    // like "public", "private", etc.) you'll get notices telling
    // you that these have been deprecated.
    if ($severity == E_STRICT) {
        return;
    }
    // Send the PHP error to the log file...
    if (!class_exists('CI_Exceptions')) {
        include_once BASEPATH . 'libraries/Exceptions.php';
    }
    $error = new CI_Exceptions();
    // Should we display the error?
    // We'll get the current error_reporting level and add its bits
    // with the severity bits to find out.
    if (($severity & error_reporting()) == $severity) {
        $error->show_php_error($severity, $message, $filepath, $line);
    }
    // Should we log the error?  No?  We're done...
    if ($config['log_errors'] === FALSE) {
        return;
    }
    $error->log_exception($severity, $message, $filepath, $line);
}
示例#25
0
 public function __construct()
 {
     parent::CI_Exceptions();
 }
 function log_exception($severity, $message, $filepath, $line)
 {
     parent::log_exception($severity, $message, $filepath, $line);
 }
 /**
  * Native PHP error handler
  *
  * @access	private
  * @param	string	the error severity
  * @param	string	the error string
  * @param	string	the error filepath
  * @param	string	the error line number
  * @return	string
  */
 function show_php_error($severity, $message, $filepath, $line)
 {
     if ($this->input->is_ajax_request()) {
         $severity = !isset($this->levels[$severity]) ? $severity : $this->levels[$severity];
         $filepath = str_replace("\\", "/", $filepath);
         // For safety reasons we do not show the full file path
         if (FALSE !== strpos($filepath, '/')) {
             $x = explode('/', $filepath);
             $filepath = $x[count($x) - 2] . '/' . end($x);
         }
         if (ob_get_level() > $this->ob_level + 1) {
             ob_end_clean();
         }
         ob_start();
         include APPPATH . 'errors/error_php.php';
         $msg = ob_get_contents();
         ob_end_clean();
         $this->output->cleanup()->error(500, $msg);
     } else {
         parent::show_php_error($severity, $message, $filepath, $line);
     }
 }
示例#28
0
 public function show_php_error($severity, $message, $filepath, $line)
 {
     self::log_exception($severity, $message, $filepath, $line);
     parent::show_php_error($severity, $message, $filepath, $line);
 }
 function log_exception($severity, $message, $filepath, $line)
 {
     if (($severity & error_reporting()) == $severity) {
         return parent::log_exception($severity, $message, $filepath, $line);
     }
 }