ACC SHELL
<?php
class ErrorController extends Zend_Controller_Action {
/**
* This action handles
* - Application errors
* - Errors in the controller chain arising from missing
* controller classes and/or action methods
*/
public function errorAction() {
$errors = $this->_getParam ( 'error_handler' );
$this->_response->clearBody();
switch ( $errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER :
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION :
// 404 error -- controller or action not found
$this->getResponse ()->setRawHeader (
'HTTP/1.1 404 Not Found' );
$this->view->title = 'HTTP/1.1 404 Nenalezeno';
break;
default :
$this->_handleError($errors->exception);
$e = $errors->exception;
if($e instanceof Zend_Acl_Exception){
$this->_forward('forbidden','error','admin',array('exception'=>$e));
} else if($e instanceof USE_Exception_PageNotFound){
$this->_forward('not-found','error','admin',array('exception'=>$e));
} else {
$this->view->title = 'Chyba aplikace';
}
break;
}
$this->view->exception = $errors->exception;
}
public function forbiddenAction()
{
$e = $this->_getParam('exception');
$this->getResponse()
->setRawHeader('HTTP/1.1 403 Forbidden');
$this->view->message = 'Nemáte dostatečná oprávnění';
}
public function notFoundAction()
{
$e = $this->_getParam('exception');
$this->getResponse()
->setRawHeader('HTTP/1.1 404 Not Found');
$this->view->message = $e->getMessage();
TF_Debug::logNotFound($this->_request);
}
protected function _handleError(Exception $e){
if($_SERVER['SERVER_ADDR'] != '127.0.0.1'){
$mail = new Zend_Mail('utf-8');
$mail->addTo('tomas.fejfar@gmail.com');
$mail->setFrom('info@suitup.cz');
$mail->setSubject('Exception: '.$e->getMessage());
$html = '
<h1>Exception</h1>
<p>'.$e->getMessage().'</p>
<p>'.$_SERVER['HTTP_REFERER'].'</p>
<p><a href="http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'">'.$_SERVER['REQUEST_URI'].'</a></p>
<pre>'.$e->getTraceAsString().'</pre>
<pre>'.serialize($e->getTrace()).'</pre>
';
$mail->setBodyHtml($html, 'utf-8');
$mail->send();
}
}
}
ACC SHELL 2018