98 lines
3.2 KiB
PHP
Raw Normal View History

2010-11-22 12:50:12 +00:00
<?php
class ErrorController extends Zend_Controller_Action
{
2015-07-08 13:48:28 +00:00
protected $theme;
2015-07-08 20:38:22 +00:00
public function init()
{
// --- Theme
$this->theme = Zend_Registry::get('theme');
}
2012-05-20 16:31:28 +00:00
2011-01-05 09:59:49 +00:00
public function errorAction()
2010-11-22 12:50:12 +00:00
{
2012-01-25 10:56:12 +00:00
$params = $this->getRequest()->getParams();
$unknow = array('MSOffice', '_vti_bin', 'crossdomain.xml');
if (in_array($params['controller'], $unknow)){
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
2012-05-20 16:31:28 +00:00
echo '';
} else {
2012-01-25 10:56:12 +00:00
$errors = $this->_getParam('error_handler');
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
2012-05-20 16:31:28 +00:00
2012-01-25 10:56:12 +00:00
// 404 error -- controller or action not found
$this->getResponse()->setHttpResponseCode(404);
$this->view->message = 'Page not found';
break;
2012-05-20 16:31:28 +00:00
2012-01-25 10:56:12 +00:00
default:
// application error
$this->getResponse()->setHttpResponseCode(500);
$this->view->message = 'Application error';
break;
}
2012-05-20 16:31:28 +00:00
$user = new Scores_Utilisateur();
2012-01-25 10:56:12 +00:00
//Envoyer les erreurs par mail
if (APPLICATION_ENV != 'development') {
$message = '';
$message.= 'Erreur Applicative : ';
$message.= "\n";
$message.= 'Message : '.$errors->exception->getMessage();
$message.= "\n";
$message.= 'Utilisateur : '.$user->getLogin();
$message.= "\n";
$message.= "File :".$errors->exception->getFile().", Ligne : ".$errors->exception->getLine();
$message.= "\n";
$message.= "Detail :\n".$errors->exception->getTraceAsString();
$message.= "\n\n";
$message.= "Request Parameters :\n ".print_r($this->getRequest()->getParams(), true)."\n";
$message.= "Referer : ".$_SERVER['HTTP_REFERER']."\n";
$c = Zend_Registry::get('config');
$mail = new Scores_Mail_Method();
$mail->setSubject('[ERREUR APPLICATIVE] - '.$c->profil->server->name.' -'.date('Ymd'));
2015-06-11 15:29:14 +00:00
$mail->setBodyText($message);
$mail->setFromKey('supportdev');
$mail->addToKey('supportdev');
2015-06-11 15:29:14 +00:00
$mail->execute();
}
2012-01-25 10:56:12 +00:00
// Log exception, if logger available
if ($log = $this->getLog()) {
$log->crit($this->view->message, $errors->exception);
}
2012-05-20 16:31:28 +00:00
2012-01-25 10:56:12 +00:00
// conditionally display exceptions
if ($this->getInvokeArg('displayExceptions') == true) {
$this->view->exception = $errors->exception;
}
2012-05-20 16:31:28 +00:00
2012-01-25 10:56:12 +00:00
$this->view->request = $errors->request;
2010-11-22 12:50:12 +00:00
}
}
2012-05-20 16:31:28 +00:00
public function soapAction(){}
2012-05-20 16:31:28 +00:00
public function permsAction(){}
2012-05-20 16:31:28 +00:00
2011-11-23 11:22:03 +00:00
public function paramsAction(){}
2010-11-22 12:50:12 +00:00
public function getLog()
{
$bootstrap = $this->getInvokeArg('bootstrap');
if (!$bootstrap->hasPluginResource('Log')) {
return false;
}
$log = $bootstrap->getResource('Log');
return $log;
}
}