Esempio n. 1
0
 /**
  * Fired when an error occurs
  * @return
  */
 public function errorAction()
 {
     # Fetch
     $Registry = Zend_Registry::getInstance();
     $errors = $this->_getParam('error_handler');
     $Exception = $errors->exception;
     $Request = $errors->request;
     $env = $this->getInvokeArg('env');
     $messages = array();
     # Use defined error layout
     $this->getHelper('layout')->disableLayout();
     # Use defined error view
     $template = $this->getHelper('App')->getApp()->getConfig('error.template');
     if ($template) {
         $this->_helper->viewRenderer($template);
     }
     # Fetch Exceptor
     $Exceptor = new Bal_Exceptor($Exception);
     # Handle
     $error = $Exceptor->getId();
     switch ($error) {
         case 'error-application-404':
             $this->getResponse()->setHttpResponseCode(404);
             break;
         default:
             $this->getResponse()->setHttpResponseCode(500);
             break;
     }
     # Apply
     $this->view->error = $error;
     $this->view->title = $Exceptor->getTitle();
     $this->view->messages = $Exceptor->getMessages();
     $this->view->exceptor = $Exceptor->toString();
     # Profiler
     $Profiler = isset($Registery->Profiler) ? $Registery->Profiler : null;
     # Assign
     $this->view->env = $env;
     $this->view->exception = $Exception;
     $this->view->request = $Request;
     $this->view->profiler = $Profiler;
     # Apply
     $this->view->headTitle()->append('Error');
     $this->view->page = 'error';
     # Log the error
     $Exceptor->log();
     # Done
     return true;
 }
Esempio n. 2
0
 public function subscribeAction()
 {
     # Prepare
     $App = $this->getHelper('App');
     $Request = $this->getRequest();
     $Response = $this->getResponse();
     $Log = Bal_App::getLog();
     # --------------------------
     # Fetch
     $email = fetch_param('subscribe.email', $Request->getParam('email'));
     # Subscribe
     try {
         $Subscriber = new User();
         $Subscriber->email = $email;
         $Subscriber->setTags('newsletter');
         $Subscriber->save();
         # Log
         $log_details = array('Subscriber' => $Subscriber->toArray());
         $Log->log(array('log-subscriber-save', $log_details), Bal_Log::NOTICE, array('friendly' => true, 'class' => 'success', 'details' => $log_details));
     } catch (Exception $Exception) {
         # Log the Event
         $Exceptor = new Bal_Exceptor($Exception);
         $Exceptor->log();
     }
     # --------------------------
     # Done
     return $this->_forward('index');
 }
Esempio n. 3
0
 /**
  * Handle any uncaught Zend Framework Exceptions
  */
 private function _initZendExceptions()
 {
     # Prepare
     $this->bootstrap('zend-run');
     global $Exceptions;
     # Error Handling
     if (!empty($Exceptions)) {
         # An Error Occured
         if (class_exists('Bal_Exceptor') && class_exists('Bal_Log')) {
             # Log Exceptions
             if (is_traversable($Exceptions)) {
                 foreach ($Exceptions as $Exception) {
                     # Log Exceptions
                     $Exceptor = new Bal_Exceptor($Exception);
                     $Exceptor->log();
                 }
             }
             # Try to Dispatch the Error Controller
             try {
                 # Fetch
                 $FrontController = Zend_Controller_Front::getInstance();
                 //$Response = $FrontController->getResponse();
                 //$Request = $FrontController->getRequest();
                 # Apply
                 //$Request->setDispatched(false);
                 //$Response->setException(new Exception('An uncaught error has occurred'));
                 # Dispatch
                 //$FrontController->dispatch($Request, $Response);
                 $FrontController->dispatch();
             } catch (Exception $Exception) {
                 # Log Exception
                 $Exceptor = new Bal_Exceptor($Exception);
                 $Exceptor->log();
                 # Display a Error Page
                 echo '<!DOCTYPE html><html><head><title>An error has occurred.</title></head><body>' . '<h1>An error has occurred.</h1>' . '<h2>Error Log</h2>' . Bal_Log::getInstance()->render() . '<h2>Error Details</h2>' . '<pre>' . '$_GET = ' . "\n" . var_export($_GET, true) . "\n\n" . '$_POST = ' . "\n" . var_export($_POST, true) . "\n\n" . '$_SERVER = ' . "\n" . var_export($_SERVER, true) . "\n\n" . '$_ENV = ' . "\n" . var_export($_SERVER, true) . "\n\n" . 'php.include_path = ' . "\n" . var_export(get_include_path(), true) . "\n\n" . '</pre>' . '</body></html>';
             }
         } else {
             echo '<!DOCTYPE html><html><head><title>An error has occurred.</title></head><body>' . '<h1>An error has occurred.</h1>' . '</body></html>';
         }
     }
 }
Esempio n. 4
0
 public function contentPositionAction()
 {
     # Prepare
     $Request = $this->getRequest();
     $json = json_decode($Request->getPost('json'), true);
     $positions = $json['positions'];
     # --------------------------
     # Handle
     try {
         $data = array('success' => false);
         if (!empty($positions)) {
             foreach ($positions as $id => $position) {
                 $Content = Doctrine::getTable('Content')->find($id);
                 $Content->position = $position;
                 $Content->save();
             }
             $data = array('success' => true);
         }
     } catch (Exception $Exception) {
         # Log the Event and Continue
         $Exceptor = new Bal_Exceptor($Exception);
         $Exceptor->log();
     }
     # --------------------------
     # Respond
     $this->getHelper('json')->sendJson($data);
 }