/** * Handle fatal errors. * * @param Zend_Log $logger */ public function fatalError($logger) { if (!is_null(error_get_last())) { $e = error_get_last(); $environment = Zend_Registry::get('configGlobal')->environment; switch ($environment) { case 'production': $message = 'The system has encountered the following error:<br/><h3>'; $message .= htmlspecialchars($e['message'], ENT_QUOTES, 'UTF-8') . '<br/>'; $message .= 'In ' . htmlspecialchars($e['file'], ENT_QUOTES, 'UTF-8') . ', line: ' . htmlspecialchars($e['line'], ENT_QUOTES, 'UTF-8') . '<br/>'; $message .= 'At ' . date('H:i:s Y-m-d') . '</h3><br/>'; $message .= 'Please notify your administrator with this information.<br/>'; if ($e['type'] == E_NOTICE) { $e['typeText'] = 'E_NOTICE'; } elseif ($e['type'] == E_ERROR) { $e['typeText'] = 'E_ERROR'; } elseif ($e['type'] == 4) { $e['typeText'] = '4'; } elseif ($e['type'] == E_WARNING) { $e['typeText'] = 'E_WARNING'; } elseif ($e['type'] == E_PARSE) { $e['typeText '] = 'E_PARSE'; } elseif ($e['type'] == E_RECOVERABLE_ERROR) { $e['typeText '] = 'E_RECOVERABLE_ERROR'; } elseif ($e['type'] == E_COMPILE_ERROR) { $e['typeText '] = 'E_COMPILE_ERROR'; } else { return; } header('content-type: text/html'); if (count(ob_list_handlers()) > 0) { ob_clean(); } echo $message; $this->_environment = $environment; break; default: $this->_server = $_SERVER; if ($e['type'] == E_NOTICE) { $e['typeText'] = 'E_NOTICE'; } elseif ($e['type'] == E_ERROR) { $e['typeText'] = 'E_ERROR'; } elseif ($e['type'] == 4) { $e['typeText'] = '4'; } elseif ($e['type'] == E_WARNING) { $e['typeText'] = 'E_WARNING'; } elseif ($e['type'] == E_PARSE) { $e['typeText '] = 'E_PARSE'; } elseif ($e['type'] == E_RECOVERABLE_ERROR) { $e['typeText '] = 'E_RECOVERABLE_ERROR'; } elseif ($e['type'] == E_COMPILE_ERROR) { $e['typeText '] = 'E_COMPILE_ERROR'; } else { return; } if (count(ob_list_handlers()) > 0) { ob_clean(); } $db = Zend_Registry::get('dbAdapter'); $table = $db->listTables(); if (file_exists(LOCAL_CONFIGS_PATH . '/database.local.ini') && empty($table)) { $fc = Zend_Controller_Front::getInstance(); $webroot = $fc->getBaseUrl(); echo "Midas Server is not installed. <a href='" . $webroot . "/install?reset=true'>Click here to reset Midas Server and go to the installation page.</a>"; return; } header('content-type: text/plain'); echo $this->getFatalErrorMessage($e); } $logger->crit($this->getFatalErrorMessage($e)); $logger->__destruct(); } }