コード例 #1
0
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
コード例 #2
0
 public function dispatchLoopShutdown()
 {
     $exceptions = $this->getResponse()->getException();
     foreach ($exceptions ? array_reverse($exceptions) : array() as $e) {
         Base_Helper_Log::getInstance()->log($e->getMessage() . $e->getTraceAsString());
     }
 }
コード例 #3
0
 public function errorAction()
 {
     $errors = $this->_getParam('error_handler');
     if (!$errors || !$errors instanceof ArrayObject) {
         $this->view->message = 'You have reached the error page';
         $this->_response->setBody($this->view->render('exception_for_client.phtml'));
         return;
     }
     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:
             $this->getResponse()->setHttpResponseCode(404);
             $this->view->message = 'Page not found';
             break;
         default:
             $this->getResponse()->setHttpResponseCode(500);
             $this->view->message = 'Application error';
             break;
     }
     $this->view->exception_for_client = false;
     if ($this->getInvokeArg('displayExceptions') == true) {
         $this->view->exception_for_client = true;
     }
     $this->view->exception = $errors->exception;
     $this->view->request = $errors->request;
     $this->_response->setBody($this->view->render('exception_for_client.phtml'));
     Base_Helper_Log::getInstance()->log($this->view->render('exception.phtml'));
 }
コード例 #4
0
 public static function sendMail($content)
 {
     $front = Zend_Controller_Front::getInstance();
     $email = new Base_Php_Overloader($front->getParam("bootstrap")->getOption('smtp'));
     $smtp = $email->domain;
     $username = $email->username;
     $password = $email->password;
     $port = $email->port;
     $config = new Zend_Mail_Transport_Smtp($smtp, array('auth' => 'login', 'username' => $username, 'password' => $password, 'ssl' => "ssl", 'port' => $port));
     Zend_Mail::setDefaultTransport($config);
     $mail = new Zend_Mail('UTF-8');
     $mail->setBodyHtml($content['body']);
     // Email body
     $mail->setFrom($content['sender'], $content['nameSender']);
     // Sender (Email, Name)
     $mail->addTo(isset($content['recipient']) ? $content['recipient'] : '', isset($content['nameRecipient']) ? $content['nameRecipient'] : '');
     // Recipient (Email, Name)
     $mail->addCc($content['sender'], $content['nameSender']);
     // CC to // Reply to Sender
     $mail->setSubject($content['subject']);
     // Subject Email
     try {
         $flag = $mail->send($config);
     } catch (Zend_Exception $e) {
         Base_Helper_Log::getInstance()->log(PHP_EOL . date('H:i:s :::: ') . ' [MAIL] ' . $e->getMessage());
         $flag = false;
     }
     if ($flag) {
         return true;
     } else {
         return false;
     }
 }