Esempio n. 1
0
 /**
  * セッションのクラスを初期化する。
  */
 public static function startup()
 {
     if (!self::$started) {
         self::$session = $_SESSION;
         self::$started = true;
     }
 }
Esempio n. 2
0
 public function fetch($template, $cache_id = null, $compile_id = null, $parent = null, $display = false)
 {
     $attributes = Vizualizer::attr();
     // 標準で使用できるパラメータを登録
     $templateEngine = $attributes["template"];
     $templateEngine->assign("configure", Vizualizer_Configure::values());
     $templateEngine->assign("post", Vizualizer::request());
     $templateEngine->assign("attr", $attributes);
     $templateEngine->assign("session", Vizualizer_Session::values());
     $templateEngine->assign("sessionName", session_name());
     $templateEngine->assign("sessionId", session_id());
     // リソースの利用を判定
     $prefix = substr($template, 0, strpos($template, ":"));
     if (ctype_alpha($prefix) && $prefix != "file") {
         return $this->core->fetch($template, $cache_id, $compile_id, $parent, $display);
     } else {
         if (file_exists(Vizualizer_Configure::get("site_home") . $attributes["userTemplate"] . "/" . $template)) {
             return $this->core->fetch($template, $cache_id, $compile_id, $parent, $display);
         } elseif (file_exists(Vizualizer_Configure::get("site_home") . $attributes["userTemplate"] . "/err404.html")) {
             return $this->core->fetch("err404.html", $cache_id, $compile_id, $parent, $display);
         } else {
             header("HTTP/1.0 404 Not Found");
             echo "ファイルが存在しません。";
             exit;
         }
     }
 }
Esempio n. 3
0
 /**
  * 登録オペレータを設定する内部処理です。
  */
 protected function updateOperatorInfo()
 {
     try {
         if (class_exists("VizualizerAdmin")) {
             $operator = Vizualizer_Session::get(VizualizerAdmin::SESSION_KEY);
             if (is_array($operator) && array_key_exists("operator_id", $operator) && $operator["operator_id"] > 0) {
                 if ($this->operator_id > 0) {
                     $this->create_operator_id = $this->update_operator_id = $operator["operator_id"];
                 } else {
                     $this->operator_id = $this->create_operator_id = $this->update_operator_id = $operator["operator_id"];
                 }
             }
         }
     } catch (Exception $e) {
         // Adminパッケージを使っていない場合は、登録者/更新者IDの設定をスキップする。
     }
 }
Esempio n. 4
0
 /**
  * メッセージログを出力する。
  *
  * @param string $prefix ログの種別
  * @param string $message エラーメッセージ
  * @param Exception $exception エラーの原因となった例外オブジェクト
  */
 private static function writeMessage($prefix, $message, $exception = null)
 {
     try {
         if (Vizualizer_Configure::get("site_code") !== null && Vizualizer_Configure::get("site_code") !== "") {
             $siteCode = self::$logFilePrefix . Vizualizer_Configure::get("site_code");
         } else {
             $siteCode = self::$logFilePrefix . "default";
         }
         // ログディレクトリが無い場合は自動的に作成
         $logHome = Vizualizer_Configure::get("log_root") . DIRECTORY_SEPARATOR;
         if (!is_dir($logHome)) {
             mkdir($logHome);
             @chmod($logHome, 0777);
         }
         if (is_dir($logHome) && is_writable($logHome)) {
             // 現在のログファイルが10MB以上の場合ローテーションする。
             if (file_exists($logHome . $siteCode . ".log") && filesize($logHome . $siteCode . ".log") > 1024 * 1024 * 10) {
                 // 現行のログファイルをoldに移動させる。
                 if (($fp = fopen($logHome . $siteCode . ".log", "r")) !== FALSE) {
                     if (flock($fp, LOCK_EX | LOCK_NB)) {
                         @rename($logHome . $siteCode . ".log", $logHome . $siteCode . "_old.log");
                         flock($fp, LOCK_UN);
                         fclose($fp);
                     }
                     if (file_exists($logHome . $siteCode . "_old.log")) {
                         $logHistorys = Vizualizer_Configure::get("max_logs");
                         for ($index = $logHistorys - 1; $index > 0; $index--) {
                             if (file_exists($logHome . $siteCode . "_" . $index . ".log")) {
                                 @rename($logHome . $siteCode . "_" . $index . ".log", $logHome . $siteCode . "_" . ($index + 1) . ".log");
                             }
                         }
                         @rename($logHome . $siteCode . "_old.log", $logHome . $siteCode . "_1.log");
                     }
                 }
             }
             // ログファイルに記載
             $logFile = $logHome . $siteCode . ".log";
             if (($fp = fopen($logFile, "a+")) !== FALSE) {
                 if (class_exists("VizualizerAdmin")) {
                     $operator = Vizualizer_Session::get(VizualizerAdmin::SESSION_KEY);
                     if (is_array($operator) && array_key_exists("operator_id", $operator) && $operator["operator_id"] > 0) {
                         $prefix .= "][" . $operator["login_id"];
                     }
                 }
                 fwrite($fp, "[" . $_SERVER["SERVER_NAME"] . "][" . Vizualizer_Data_Calendar::now() . "][" . $prefix . "]" . $message . "\r\n");
                 if (self::$logOutputStandard) {
                     echo "[" . $_SERVER["SERVER_NAME"] . "][" . Vizualizer_Data_Calendar::now() . "][" . $prefix . "]" . $message . "\r\n";
                 }
                 if ($exception != null) {
                     fwrite($fp, "[" . $_SERVER["SERVER_NAME"] . "][" . Vizualizer_Data_Calendar::now() . "][" . $prefix . "]" . $exception->getMessage() . "\r\n");
                     if (self::$logOutputStandard) {
                         echo "[" . $_SERVER["SERVER_NAME"] . "][" . Vizualizer_Data_Calendar::now() . "][" . $prefix . "]" . $exception->getMessage() . "\r\n";
                     }
                     fwrite($fp, "[" . $_SERVER["SERVER_NAME"] . "][" . Vizualizer_Data_Calendar::now() . "][" . $prefix . "]" . $exception->getTraceAsString());
                     if (self::$logOutputStandard) {
                         echo "[" . $_SERVER["SERVER_NAME"] . "][" . Vizualizer_Data_Calendar::now() . "][" . $prefix . "]" . $exception->getTraceAsString();
                     }
                 }
                 fclose($fp);
                 @chmod($logFile, 0666);
             }
         }
     } catch (Exception $e) {
         // エラーログ出力に失敗した場合は無限ネストの可能性があるため、例外を無効にする。
     }
 }
Esempio n. 5
0
 /**
  * 終了処理です。
  * ここでは何も行いません。
  */
 public static function stop()
 {
     Vizualizer_Session::shutdown();
 }
Esempio n. 6
0
 public function clear()
 {
     $this->parameters[TEMPLATE_DIRECTORY] = array();
     Vizualizer_Session::set(Vizualizer::INPUT_KEY, $this->parameters);
 }
Esempio n. 7
0
 /**
  * 登録日時や登録オペレータなどを設定する内部処理です。
  */
 protected function updateRegisterInfo()
 {
     // データ作成日/更新日は自動的に設定する。
     try {
         if (!$this->ignoreOperator && class_exists("VizualizerAdmin")) {
             $operator = Vizualizer_Session::get(VizualizerAdmin::SESSION_KEY);
             if (is_array($operator) && array_key_exists("operator_id", $operator) && $operator["operator_id"] > 0) {
                 if ($this->operator_id > 0) {
                     $this->create_operator_id = $this->update_operator_id = $operator["operator_id"];
                 } else {
                     $this->operator_id = $this->create_operator_id = $this->update_operator_id = $operator["operator_id"];
                 }
             }
         }
     } catch (Exception $e) {
         // Adminパッケージを使っていない場合は、登録者/更新者IDの設定をスキップする。
     }
     $this->create_time = $this->update_time = Vizualizer_Data_Calendar::now()->date("Y-m-d H:i:s");
 }
Esempio n. 8
0
 /**
  * ページ出力用のメソッドをオーバーライドしています。
  * 携帯のページについて、SJISに変換し、カナを半角にしています。
  *
  * @access public
  */
 public function display($template, $cache_id = null, $compile_id = null, $parent = null)
 {
     // キャッシュ無効にするヘッダを送信
     header("P3P: CP='UNI CUR OUR'");
     header("Expires: Thu, 01 Dec 1994 16:00:00 GMT");
     header("Last-Modified: " . Vizualizer::now()->gmDate("D, d M Y H:i:s") . " GMT");
     if (array_key_exists("HTTPS", $_SERVER) && $_SERVER['HTTPS'] == 'on') {
         header("Cache-Control: must-revalidate");
         header("Cache-Control: post-check=0, pre-check=0", false);
     } else {
         header("Cache-Control: no-cache, must-revalidate");
         header("Cache-Control: post-check=0, pre-check=0", false);
         header("Pragma: no-cache");
     }
     $attr = Vizualizer::attr();
     $templateEngine = $attr["template"];
     $templateEngine->assign("configure", Vizualizer_Configure::values());
     $templateEngine->assign("post", Vizualizer::request());
     $templateEngine->assign("attr", $attr);
     $templateEngine->assign("session", Vizualizer_Session::values());
     $templateEngine->assign("sessionName", session_name());
     $templateEngine->assign("sessionId", session_id());
     // display template
     Vizualizer_Logger::writeDebug("Template Dir : " . var_export($this->template_dir, true));
     if (Vizualizer_Configure::get("device")->isFuturePhone()) {
         // モバイルの時は出力するHTMLをデータとして取得
         $content = trim($this->core->fetch($template, $cache_id, $compile_id, $parent));
         // カタカナを半角にする。
         $content = mb_convert_kana($content, "k");
         // ソフトバンク以外の場合は、SJISエンコーディングに変換
         if (Vizualizer_Configure::get("device")->getDeviceType() != "Softbank") {
             header("Content-Type: text/html; charset=Shift_JIS");
             if (preg_match("/<meta\\s+http-equiv\\s*=\\s*\"Content-Type\"\\s+content\\s*=\\s*\"([^;]+);\\s*charset=utf-8\"\\s*\\/?>/i", $content, $params) > 0) {
                 header("Content-Type: " . $params[1] . "; charset=Shift_JIS");
                 $content = str_replace($params[0], "<meta http-equiv=\"Content-Type\" content=\"" . $params[1] . "; charset=Shift_JIS\" />", $content);
             } else {
                 header("Content-Type: text/html; charset=Shift_JIS");
             }
             echo mb_convert_encoding($content, "Shift_JIS", "UTF-8");
         } else {
             header("Content-Type: text/html; charset=UTF-8");
             echo $content;
         }
     } else {
         header("Content-Type: text/html; charset=UTF-8");
         echo trim($this->fetch($template, $cache_id, $compile_id, $parent));
     }
 }