Пример #1
0
 /**
  * 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));
     }
 }
Пример #2
0
 public function testConfigPaths()
 {
     Config::set(Config::KEY_DIR_ROOT, "/srv/www");
     $this->assertEquals("/srv/www", Config::get(Config::KEY_DIR_ROOT));
     $this->assertEquals("/App", Config::get(Config::KEY_DIR_APP));
     $this->assertEquals("/srv/www", Config::getAbsoluteFolderPath(Config::KEY_DIR_ROOT));
     $this->assertEquals("/srv/www/App", Config::getAbsoluteFolderPath(Config::KEY_DIR_APP));
     $this->assertEquals("/srv/www/App/Templates", Config::getAbsoluteFolderPath(Config::KEY_DIR_APP_TEMPLATES));
     $this->assertNull(Config::getAbsoluteFolderPath(999));
 }
Пример #3
0
 /**
  * Save exception into log file.
  *
  * @param \Exception $e
  *            exception object
  * @return void
  */
 public static function saveToFile(Exception $e)
 {
     $path = Config::getAbsoluteFolderPath(Config::KEY_DIR_LOG);
     $files = Files::findAllFiles($path, array(".", ".."));
     $out_file = $path;
     sort($files);
     $reg_files = array();
     foreach ($files as $file) {
         $r = explode("/", $file);
         if (preg_match("/^([0-9]+)\\.log\$/i", $r[1], $matches)) {
             $reg_files[$matches[1]] = filesize($file);
         }
     }
     $last = count($reg_files);
     if ($last > 0 && $reg_files[$last - 1] <= Config::get(Config::KEY_LOG_SIZE)) {
         $out_file .= "/" . ($last - 1) . ".log";
     } else {
         $out_file .= "/" . $last . ".log";
     }
     file_put_contents($out_file, sprintf("\n>> %s [%d] %s\n%s\n%s", get_class($e), $e->getCode(), date("Y-m-d H:i:s"), $e->getTraceAsString(), $e->getMessage()), FILE_APPEND | LOCK_EX);
 }