/**
  * Send this response object to output.
  */
 public function send()
 {
     $e = $this->getException();
     $tpd = $this->template_data;
     // variable $tpd is accessible in each template file
     if (is_null($e) || $e instanceof NoticeException || $e instanceof WarningException) {
         $templates_path = sprintf("%s/", Config::getAbsoluteFolderPath(Config::KEY_DIR_APP_TEMPLATES));
         // include Master header template
         if (!empty($templates_path) && is_file($templates_path . self::HEADER_TEMPLATE_FILE)) {
             include $templates_path . self::HEADER_TEMPLATE_FILE;
         }
         // make exception box
         if (!is_null($e)) {
             echo $this->getExceptionBox();
         }
         // make content (only for null or Notice exception)
         if ((is_null($e) || $e instanceof NoticeException) && !empty($this->template_file) && is_file($templates_path . $this->template_file)) {
             include $templates_path . $this->template_file;
         }
         // include Master footer template
         if (!empty($templates_path) && is_file($templates_path . self::FOOTER_TEMPLATE_FILE)) {
             include $templates_path . self::FOOTER_TEMPLATE_FILE;
         }
     } else {
         System::redirect(Config::get(Config::KEY_SITE_FQDN) . Config::get(Config::KEY_SHUTDOWN_PAGE));
     }
 }
Beispiel #2
0
 /**
  * Save exception into databse.
  *
  * @param Phoenix\Core\Database $db
  *            database object
  * @param \Exception $e
  *            exception object
  * @return void
  */
 public static function saveToDatabase(Database $db, Exception $e)
 {
     try {
         $r = InternalLogDao::insertRecord($db, get_class($e), $e->getCode(), $e->getTraceAsString(), $e->getMessage());
         if ($r != 1) {
             throw new WarningException(FrameworkExceptions::W_DB_INVALID_SQL_ACTION);
         }
     } catch (WarningException $ex) {
         self::saveToFile(new FailureException(FrameworkExceptions::F_LOGGER_UNABLE_SAVE_WARNING));
         self::saveToFile($e);
         System::redirect(Config::get(Config::KEY_SITE_FQDN) . Config::get(Config::KEY_SHUTDOWN_PAGE));
     }
 }
Beispiel #3
0
 /**
  * Resolve proxy request.
  *
  * @todo cache
  * @todo file download + condition
  * @throws Phoenix\Exceptions\WarningException
  */
 private function performProxyRequest()
 {
     $token = $this->request->getUrl()->getQueryParameter(FrontController::URL_GET_TOKEN);
     // @todo load from cache
     // load from db
     $proxy_item = ProxyDao::getProxyItemByValidToken($this->db, $token);
     if ($proxy_item == Database::EMPTY_RESULT) {
         throw new WarningException(FrameworkExceptions::W_INVALID_TOKEN);
     }
     $proxy_item = $proxy_item[0];
     // detect type of request
     if (is_null($proxy_item->getRoute()) && is_null($proxy_item->getAction()) && !is_null($proxy_item->getData())) {
         // external link to redirect on (data=url)
         System::redirect($proxy_item->getData());
     } else {
         if (!is_null($proxy_item->getRoute()) && !is_null($proxy_item->getAction())) {
             $config_route = Config::get(Config::KEY_APP_PROXY_FILE_ROUTE);
             $config_action = Config::get(Config::KEY_APP_PROXY_FILE_ACTION);
             if (!empty($config_route) && !empty($config_action) && $proxy_item->getRoute() == $config_route && $proxy_item->getAction() == $config_action && !is_null($proxy_item->getData())) {
                 // @todo file download
             } else {
                 // internal rewrite link to app (data=query string part of url saved as json)
                 $_GET = array();
                 $_GET[FrontController::URL_GET_ROUTE] = $proxy_item->getRoute();
                 $_GET[FrontController::URL_GET_ACTION] = $proxy_item->getAction();
                 $_GET[FrontController::URL_GET_FORMAT] = ${$this}->response_format;
                 if (!is_null($proxy_item->getData())) {
                     // decode json data and put into GET
                     $_GET = array_merge($_GET, json_decode($proxy_item->getData(), true));
                 }
                 $this->request = RequestFactory::createRequest();
                 $this->performFrontControllerRequest();
                 return;
             }
         } else {
             throw new WarningException(FrameworkExceptions::W_INVALID_TOKEN);
         }
     }
 }