error.php (1045B)
1 <?php 2 class ControllerStartupError extends Controller { 3 public function index() { 4 $this->registry->set('log', new Log($this->config->get('config_error_filename'))); 5 6 set_error_handler(array($this, 'handler')); 7 } 8 9 public function handler($code, $message, $file, $line) { 10 // error suppressed with @ 11 if (error_reporting() === 0) { 12 return false; 13 } 14 15 switch ($code) { 16 case E_NOTICE: 17 case E_USER_NOTICE: 18 $error = 'Notice'; 19 break; 20 case E_WARNING: 21 case E_USER_WARNING: 22 $error = 'Warning'; 23 break; 24 case E_ERROR: 25 case E_USER_ERROR: 26 $error = 'Fatal Error'; 27 break; 28 default: 29 $error = 'Unknown'; 30 break; 31 } 32 33 if ($this->config->get('config_error_display')) { 34 echo '<b>' . $error . '</b>: ' . $message . ' in <b>' . $file . '</b> on line <b>' . $line . '</b>'; 35 } 36 37 if ($this->config->get('config_error_log')) { 38 $this->log->write('PHP ' . $error . ': ' . $message . ' in ' . $file . ' on line ' . $line); 39 } 40 41 return true; 42 } 43 }