Source for file LC_Page.php
Documentation is available at LC_Page.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
* http://www.lockon.co.jp/
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once DATA_REALDIR . 'module/Net/URL.php';
* Web Page を制御する Page クラスは必ずこのクラスを継承する.
* PHP4 ではこのような抽象クラスを作っても継承先で何でもできてしまうため、
* あまり意味がないが、アーキテクトを統一するために作っておく.
* @author LOCKON CO.,LTD.
* @version $Id:LC_Page.php 15532 2007-08-31 14:39:46Z nanasess $
/** HTML ロード後に実行する JavaScript コード */
$this->timeStart = SC_Utils_Ex::sfMicrotimeFloat();
$this->tpl_authority = $_SESSION['authority'];
$this->objDisplay = new SC_Display_Ex();
$layout = new SC_Helper_PageLayout_Ex();
$layout->sfGetPageLayout($this, false, $_SERVER['PHP_SELF'],
$this->objDisplay->detectDevice());
$this->objPlugin = new SC_Helper_Plugin_Ex();
$this->objPlugin->preProcess($this);
$this->arrSiteInfo = SC_Helper_DB_Ex::sfGetBasisData();
if (isset ($this->objPlugin)) { // FIXME モバイルエラー応急対応
$this->objPlugin->process($this);
$this->objDisplay->prepare($this);
$this->objDisplay->response->write();
$this->objDisplay->prepare($this);
$this->objDisplay->addHeader("Content-disposition", "attachment; filename=${file_name}");
$this->objDisplay->addHeader("Content-type", "application/octet-stream; name=${file_name}");
$this->objDisplay->addHeader("Cache-Control", "");
$this->objDisplay->addHeader('Pragma', "");
$this->objDisplay->response->body = $data;
$this->objDisplay->response->write();
// 一定時間以上かかったページの場合、ログ出力する。
// エラー画面の表示では $this->timeStart が出力されない
if (defined('PAGE_DISPLAY_TIME_LOG_MODE') && PAGE_DISPLAY_TIME_LOG_MODE == true && isset ($this->timeStart)) {
$timeEnd = SC_Utils_Ex::sfMicrotimeFloat();
$timeExecTime = $timeEnd - $this->timeStart;
if (defined('PAGE_DISPLAY_TIME_LOG_MIN_EXEC_TIME') && $timeExecTime >= (float) PAGE_DISPLAY_TIME_LOG_MIN_EXEC_TIME) {
$logMsg = sprintf("PAGE_DISPLAY_TIME_LOG [%.2fsec]", $timeExecTime);
GC_Utils_Ex::gfPrintLog($logMsg);
* 以下の順序で 引数 $path から URL を取得する.
* 1. realpath($path) で $path の 絶対パスを取得
* 2. $_SERVER['DOCUMENT_ROOT'] と一致する文字列を削除
* 3. $useSSL の値に応じて, HTTP_URL 又は, HTTPS_URL を付与する.
* 返り値に, QUERY_STRING を含めたい場合は, key => value 形式
* @param string $path 結果を取得するためのパス
* @param array $param URL に付与するパラメーターの配列
* @param mixed $useSSL 結果に HTTPS_URL を使用する場合 true,
* HTTP_URL を使用する場合 false,
* デフォルト 'escape' 現在のスキーマを使用
* @return string $path の存在する http(s):// から始まる絶対パス
function getLocation($path, $param = array(), $useSSL = 'escape') {
$url = HTTPS_URL . $rootPath;
} elseif ($useSSL === false){
$url = HTTP_URL . $rootPath;
} elseif ($useSSL == 'escape') {
if (SC_Utils_Ex::sfIsHTTPS()) {
$url = HTTPS_URL . $rootPath;
$url = HTTP_URL . $rootPath;
die("[BUG] Illegal Parametor of \$useSSL ");
$netURL = new Net_URL($url);
foreach ($param as $key => $val) {
$netURL->addQueryString($key, $val);
return $netURL->getURL();
* EC-CUBE のWEBルート(/html/)を / としたパスを返す
* @param string $path 結果を取得するためのパス
* @return string EC-CUBE のWEBルート(/html/)を / としたパス
// Windowsの場合は, ディレクトリの区切り文字を\から/に変換する
// PHP 5.1 対策 ( http://xoops.ec-cube.net/modules/newbb/viewtopic.php?topic_id=4277&forum=9 )
if (substr($path, 0, 1) == '/') {
// $path が / で終わっている場合、realpath によって削られた末尾の / を復元する。
if (substr($path, - 1, 1) == '/' && substr($realPath, - 1, 1) != '/') {
// HTML_REALDIR を削除した文字列を取得.
$rootPath = ltrim($rootPath, '/');
* @deprecated 決済モジュール互換のため
* クライアント・プロキシのキャッシュを制御する.
* @param string $mode (nocache/private)
header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
header('Pragma: no-cache'); // anti-proxy
header('Expires:'); // anti-mozilla
header("Cache-Control: private, max-age={$cache_expire}, pre-check={$cache_expire}"); // HTTP/1.1 client
* リクエストパラメーター 'mode' を取得する.
* 1. $_GET['mode'] の値を取得する.
* 2. 1 が存在しない場合は $_POST['mode'] の値を取得する.
* 3. どちらも存在しない場合は null を返す.
* mode に, 半角英数字とアンダーバー(_) 以外の文字列が検出された場合は null を
* @return string $_GET['mode'] 又は $_POST['mode'] の文字列
$pattern = '/^[a-zA-Z0-9_]+$/';
if (isset ($_GET['mode']) && preg_match($pattern, $_GET['mode'])) {
} elseif (isset ($_POST['mode']) && preg_match($pattern, $_POST['mode'])) {
* 生成されたトランザクショントークンの妥当性を検証し,
* この関数は, 基本的に init() 関数で呼び出され, POST アクセスの場合は自動的に
* ページによって検証タイミングなどを制御する必要がある場合は, この関数を
* @param boolean $is_admin 管理画面でエラー表示をする場合 true
if ($_SERVER["REQUEST_METHOD"] == 'POST') {
if (!SC_Helper_Session_Ex::isValidToken(false)) {
SC_Utils_Ex::sfDispError(INVALID_MOVE_ERRORR);
SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
* トランザクショントークンを取得し, 設定する.
* @param string $mess ログメッセージ
* @param string $log_level ログレベル("Info" or "Debug")
function log($mess, $log_level) {
$mess = $mess . " user=" . $_SESSION['customer']['customer_id'];
GC_Utils_Ex::gfFrontLog($mess, $log_level);
* @param mixed $val デバックする要素
SC_Utils_Ex::sfPrintR($val);
Documentation generated on Fri, 24 Feb 2012 14:00:59 +0900 by Seasoft
|