コード例 #1
0
 /**
  * Opens the log specified by $name. If no name is given
  * it will receive a default name
  * @param string $name the name of the file
  */
 public static function open($name = null)
 {
     if (is_null($name)) {
         $name = 'sa_' . date('Y-m-d') . '.log';
     }
     self::$fp = @fopen(SAE_LOGS_DIR . $name, 'a');
 }
コード例 #2
0
 /**
  * Handles the page specified by $name
  * @param string $name The page name
  */
 public static function handle($name)
 {
     $page = null;
     try {
         $page =& self::tryToGetPage($name);
     } catch (Exception $e) {
         try {
             SALog::log($e->getMessage(), SA_LOG_WARNING);
             $page =& self::tryToGetPage(self::$app->getErrorPageName());
         } catch (Exception $e) {
             SADebug::trace($e->getMessage(), __FILE__, __LINE__, __METHOD__);
         }
     }
     if (is_null($page)) {
         self::$app->resign("Could not create the page {$name}");
     }
     self::$app->setCurrentPage($page);
     try {
         $page->init();
         $page->runEvents();
         $page->beforeDisplay();
         $page->display();
         $page->afterDisplay();
     } catch (Exception $e) {
         SADebug::trace($e->getMessage(), __FILE__, __LINE__, __METHOD__);
     }
 }
コード例 #3
0
 /**
  * logs and displays the specified error message
  * @param string $message error message
  * @param string $file the file name in which the error occured
  * @param string $line the line number from $file where the error occured
  * @param string $method the method name where the error occured
  */
 public static function trace($message, $file = __FILE__, $line = __LINE__, $method = __METHOD__)
 {
     SALog::log("{$file} on line {$line} - {$method}: {$message}", SA_LOG_ERROR);
     if (!in_array($_SERVER['REMOTE_ADDR'], self::$displayFor)) {
         return;
     }
     print "<div style='padding:2px; background-color:lightyellow; border:1px dashed red;'>{$file} on line {$line}<br><strong>{$method}</strong>: <span style='color:red'>{$message}</span></div>";
 }
コード例 #4
0
 /**
  * The default constructor which must be called explicitely by each subclass
  */
 function __construct(SApplication &$app, $name)
 {
     SALog::log("in page {$name} constructor", SA_LOG_NOTICE);
     parent::Smarty();
     $this->app =& $app;
     $this->assign_by_ref('app', $app);
     $this->name = $name;
     $this->template = "{$name}.tpl";
     $appHome = $app->getHomeDirectory();
     $this->plugins_dir = array('plugins', SA_CORE_DIR . 'sa_smarty_plugins');
     $this->layoutDir = "{$appHome}/Layouts";
     $this->template_dir = "{$appHome}/Templates";
     $this->compile_dir = "{$appHome}/Templates_c";
     $this->use_sub_dirs = true;
     $this->headers = array('Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', 'Last-Modified' => gmdate('D, d M Y H:i:s') . ' GMT', 'Cache-Control' => 'no-store, no-cache, must-revalidate', 'Pragma' => 'no-cache');
 }
コード例 #5
0
 /**
  * quits the application and logs the reason
  * @param string $message reason
  * @param int $errorCode error code
  */
 public function resign($message, $errorCode = 1)
 {
     SALog::log($message, $errorCode ? SA_LOG_ERROR : SA_LOG_NOTICE);
     exit($errorCode);
 }