| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * This file is part of EC-CUBE |
|---|
| 4 | * |
|---|
| 5 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
|---|
| 6 | * |
|---|
| 7 | * http://www.lockon.co.jp/ |
|---|
| 8 | * |
|---|
| 9 | * This program is free software; you can redistribute it and/or |
|---|
| 10 | * modify it under the terms of the GNU General Public License |
|---|
| 11 | * as published by the Free Software Foundation; either version 2 |
|---|
| 12 | * of the License, or (at your option) any later version. |
|---|
| 13 | * |
|---|
| 14 | * This program is distributed in the hope that it will be useful, |
|---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | * GNU General Public License for more details. |
|---|
| 18 | * |
|---|
| 19 | * You should have received a copy of the GNU General Public License |
|---|
| 20 | * along with this program; if not, write to the Free Software |
|---|
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 22 | */ |
|---|
| 23 | |
|---|
| 24 | /** |
|---|
| 25 | * アプリケーションの初期設定クラス. |
|---|
| 26 | * |
|---|
| 27 | * @author LOCKON CO.,LTD. |
|---|
| 28 | * @version $Id$ |
|---|
| 29 | */ |
|---|
| 30 | class SC_Initial |
|---|
| 31 | { |
|---|
| 32 | |
|---|
| 33 | // {{{ cunstructor |
|---|
| 34 | |
|---|
| 35 | /** |
|---|
| 36 | * コンストラクタ. |
|---|
| 37 | */ |
|---|
| 38 | function __construct() |
|---|
| 39 | { |
|---|
| 40 | |
|---|
| 41 | /** EC-CUBEのバージョン */ |
|---|
| 42 | define('ECCUBE_VERSION', '2.12.3-dev'); |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | // }}} |
|---|
| 46 | // {{{ functions |
|---|
| 47 | |
|---|
| 48 | /** |
|---|
| 49 | * 初期設定を行う. |
|---|
| 50 | * |
|---|
| 51 | * @access protected |
|---|
| 52 | * @return void |
|---|
| 53 | */ |
|---|
| 54 | function init() |
|---|
| 55 | { |
|---|
| 56 | $this->requireInitialConfig(); |
|---|
| 57 | $this->defineDSN(); // requireInitialConfig メソッドより後で実行 |
|---|
| 58 | $this->defineDirectoryIndex(); |
|---|
| 59 | $this->defineConstants(); |
|---|
| 60 | $this->defineParameter(); // defineDirectoryIndex メソッドより後で実行 |
|---|
| 61 | $this->complementParameter(); // defineConstants メソッドより後で実行 |
|---|
| 62 | $this->phpconfigInit(); // defineConstants メソッドより後で実行 |
|---|
| 63 | $this->createCacheDir(); // defineConstants メソッドより後で実行 |
|---|
| 64 | $this->stripslashesDeepGpc(); |
|---|
| 65 | $this->resetSuperglobalsRequest(); // stripslashesDeepGpc メソッドより後で実行 |
|---|
| 66 | $this->setTimezone(); // 本当はエラーハンドラーより先に読みたい気も |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | /** |
|---|
| 70 | * 初期設定ファイルを読み込み, パスの設定を行う. |
|---|
| 71 | * |
|---|
| 72 | * @access protected |
|---|
| 73 | * @return void |
|---|
| 74 | */ |
|---|
| 75 | function requireInitialConfig() |
|---|
| 76 | { |
|---|
| 77 | |
|---|
| 78 | define('CONFIG_REALFILE', realpath(dirname(__FILE__)) . '/../config/config.php'); |
|---|
| 79 | if (file_exists(CONFIG_REALFILE)) { |
|---|
| 80 | require_once CONFIG_REALFILE; |
|---|
| 81 | } |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | /** |
|---|
| 85 | * DSN を定義する. |
|---|
| 86 | * |
|---|
| 87 | * @access protected |
|---|
| 88 | * @return void |
|---|
| 89 | * @deprecated 下位互換用 |
|---|
| 90 | */ |
|---|
| 91 | function defineDSN() |
|---|
| 92 | { |
|---|
| 93 | if (defined('DB_TYPE') && defined('DB_USER') && defined('DB_PASSWORD') |
|---|
| 94 | && defined('DB_SERVER') && defined('DB_PORT') && defined('DB_NAME') |
|---|
| 95 | ) { |
|---|
| 96 | $dsn = DB_TYPE . '://' . DB_USER . ':' . DB_PASSWORD . '@' . DB_SERVER . ':' . DB_PORT . '/' . DB_NAME; |
|---|
| 97 | /** サイト用DB */ |
|---|
| 98 | // ここで生成した DSN は使用せず, SC_Query のコンストラクタでパラメータを設定する. |
|---|
| 99 | define('DEFAULT_DSN', $dsn); |
|---|
| 100 | } |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | /** |
|---|
| 104 | * @deprecated |
|---|
| 105 | */ |
|---|
| 106 | function setErrorReporting() |
|---|
| 107 | { |
|---|
| 108 | error_reporting(E_ALL & ~E_NOTICE); |
|---|
| 109 | // PHP 5.3.0対応 |
|---|
| 110 | if (error_reporting() > 6143) { |
|---|
| 111 | error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); |
|---|
| 112 | } |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | /** |
|---|
| 116 | * マルチバイト文字列設定を行う. |
|---|
| 117 | * |
|---|
| 118 | * TODO SJIS-win や, eucJP-win への対応 |
|---|
| 119 | * |
|---|
| 120 | * @access protected |
|---|
| 121 | * @return void |
|---|
| 122 | */ |
|---|
| 123 | function phpconfigInit() |
|---|
| 124 | { |
|---|
| 125 | ini_set('html_errors', '1'); |
|---|
| 126 | ini_set('mbstring.http_input', CHAR_CODE); |
|---|
| 127 | ini_set('mbstring.http_output', CHAR_CODE); |
|---|
| 128 | ini_set('auto_detect_line_endings', 1); |
|---|
| 129 | ini_set('default_charset', CHAR_CODE); |
|---|
| 130 | ini_set('mbstring.detect_order', 'auto'); |
|---|
| 131 | ini_set('mbstring.substitute_character', 'none'); |
|---|
| 132 | |
|---|
| 133 | mb_language('ja'); // mb_internal_encoding() より前に |
|---|
| 134 | // TODO .htaccess の mbstring.language を削除できないか検討 |
|---|
| 135 | |
|---|
| 136 | mb_internal_encoding(CHAR_CODE); // mb_language() より後で |
|---|
| 137 | |
|---|
| 138 | ini_set('arg_separator.output', '&'); |
|---|
| 139 | |
|---|
| 140 | //ロケールを明示的に設定 |
|---|
| 141 | $res = setlocale(LC_ALL, LOCALE); |
|---|
| 142 | if ($res === FALSE) { |
|---|
| 143 | // TODO: Windows上のロケール設定が正常に働かない場合があることに暫定的に対応 |
|---|
| 144 | // ''を指定するとApache実行環境の環境変数が使われる |
|---|
| 145 | // See also: http://php.net/manual/ja/function.setlocale.php |
|---|
| 146 | setlocale(LC_ALL, ''); |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | // #1849 (文字エンコーディングの検出を制御する) |
|---|
| 150 | mb_detect_order(array('UTF-8', 'SJIS-win', 'eucJP-win')); |
|---|
| 151 | } |
|---|
| 152 | |
|---|
| 153 | /** |
|---|
| 154 | * 定数 DIR_INDEX_PATH を設定する. |
|---|
| 155 | * |
|---|
| 156 | * @access protected |
|---|
| 157 | * @return void |
|---|
| 158 | */ |
|---|
| 159 | function defineDirectoryIndex() |
|---|
| 160 | { |
|---|
| 161 | |
|---|
| 162 | // DirectoryIndex の実ファイル名 |
|---|
| 163 | if (!defined('DIR_INDEX_FILE')) { |
|---|
| 164 | define('DIR_INDEX_FILE', 'index.php'); |
|---|
| 165 | } |
|---|
| 166 | |
|---|
| 167 | $useFilenameDirIndex = is_bool(USE_FILENAME_DIR_INDEX) |
|---|
| 168 | ? USE_FILENAME_DIR_INDEX |
|---|
| 169 | : (isset($_SERVER['SERVER_SOFTWARE']) ? substr($_SERVER['SERVER_SOFTWARE'], 0, 13) == 'Microsoft-IIS' : false) |
|---|
| 170 | ; |
|---|
| 171 | |
|---|
| 172 | // DIR_INDEX_FILE にアクセスする時の URL のファイル名部を定義する |
|---|
| 173 | if ($useFilenameDirIndex === true) { |
|---|
| 174 | // ファイル名を使用する |
|---|
| 175 | define('DIR_INDEX_PATH', DIR_INDEX_FILE); |
|---|
| 176 | } else { |
|---|
| 177 | // ファイル名を使用しない |
|---|
| 178 | define('DIR_INDEX_PATH', ''); |
|---|
| 179 | } |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | /** |
|---|
| 183 | * パラメータを設定する. |
|---|
| 184 | * |
|---|
| 185 | * mtb_constants.php を読み込んで定数として定義する. |
|---|
| 186 | * キャッシュディレクトリに存在しない場合は, 初期データからコピーする. |
|---|
| 187 | * |
|---|
| 188 | * @access protected |
|---|
| 189 | * @return void |
|---|
| 190 | */ |
|---|
| 191 | function defineParameter() |
|---|
| 192 | { |
|---|
| 193 | |
|---|
| 194 | $errorMessage |
|---|
| 195 | = '<div style="color: #F00; font-weight: bold; background-color: #FEB; text-align: center">' |
|---|
| 196 | . CACHE_REALDIR |
|---|
| 197 | . ' にユーザ書込み権限(777等)を付与して下さい。</div>'; |
|---|
| 198 | |
|---|
| 199 | // 定数を設定 |
|---|
| 200 | if (is_file(CACHE_REALDIR . 'mtb_constants.php')) { |
|---|
| 201 | require_once CACHE_REALDIR . 'mtb_constants.php'; |
|---|
| 202 | |
|---|
| 203 | // キャッシュが無ければ, 初期データからコピー |
|---|
| 204 | } elseif (is_file(CACHE_REALDIR . '../mtb_constants_init.php')) { |
|---|
| 205 | |
|---|
| 206 | $mtb_constants = file_get_contents(CACHE_REALDIR . '../mtb_constants_init.php'); |
|---|
| 207 | if (is_writable(CACHE_REALDIR)) { |
|---|
| 208 | $handle = fopen(CACHE_REALDIR . 'mtb_constants.php', 'w'); |
|---|
| 209 | if (!$handle) { |
|---|
| 210 | die($errorMessage); |
|---|
| 211 | } |
|---|
| 212 | if (fwrite($handle, $mtb_constants) === false) { |
|---|
| 213 | die($errorMessage); |
|---|
| 214 | } |
|---|
| 215 | fclose($handle); |
|---|
| 216 | |
|---|
| 217 | require_once CACHE_REALDIR . 'mtb_constants.php'; |
|---|
| 218 | } else { |
|---|
| 219 | die($errorMessage); |
|---|
| 220 | } |
|---|
| 221 | } else { |
|---|
| 222 | die(CACHE_REALDIR . '../mtb_constants_init.php が存在しません'); |
|---|
| 223 | } |
|---|
| 224 | } |
|---|
| 225 | |
|---|
| 226 | /** |
|---|
| 227 | * パラメーターの補完 |
|---|
| 228 | * |
|---|
| 229 | * ソースのみ差し替えたバージョンアップを考慮したもの。 |
|---|
| 230 | * $this->defineIfNotDefined() で定義することを想定 |
|---|
| 231 | * |
|---|
| 232 | * @access protected |
|---|
| 233 | * @return void |
|---|
| 234 | */ |
|---|
| 235 | function complementParameter() |
|---|
| 236 | { |
|---|
| 237 | } |
|---|
| 238 | |
|---|
| 239 | /** |
|---|
| 240 | * 各種キャッシュディレクトリを生成する. |
|---|
| 241 | * |
|---|
| 242 | * Smarty キャッシュディレクトリを生成する. |
|---|
| 243 | * |
|---|
| 244 | * @access protected |
|---|
| 245 | * @return void |
|---|
| 246 | */ |
|---|
| 247 | function createCacheDir() |
|---|
| 248 | { |
|---|
| 249 | if (defined('HTML_REALDIR')) { |
|---|
| 250 | umask(0); |
|---|
| 251 | if (!file_exists(COMPILE_REALDIR)) { |
|---|
| 252 | mkdir(COMPILE_REALDIR); |
|---|
| 253 | } |
|---|
| 254 | |
|---|
| 255 | if (!file_exists(MOBILE_COMPILE_REALDIR)) { |
|---|
| 256 | mkdir(MOBILE_COMPILE_REALDIR); |
|---|
| 257 | } |
|---|
| 258 | |
|---|
| 259 | if (!file_exists(SMARTPHONE_COMPILE_REALDIR)) { |
|---|
| 260 | mkdir(SMARTPHONE_COMPILE_REALDIR); |
|---|
| 261 | } |
|---|
| 262 | |
|---|
| 263 | if (!file_exists(COMPILE_ADMIN_REALDIR)) { |
|---|
| 264 | mkdir(COMPILE_ADMIN_REALDIR); |
|---|
| 265 | } |
|---|
| 266 | } |
|---|
| 267 | } |
|---|
| 268 | |
|---|
| 269 | /** |
|---|
| 270 | * 定数定義 |
|---|
| 271 | * |
|---|
| 272 | * @access protected |
|---|
| 273 | * @return void |
|---|
| 274 | */ |
|---|
| 275 | function defineConstants() |
|---|
| 276 | { |
|---|
| 277 | // LC_Page_Error用 |
|---|
| 278 | /** 指定商品ページがない */ |
|---|
| 279 | define('PRODUCT_NOT_FOUND', 1); |
|---|
| 280 | /** カート内が空 */ |
|---|
| 281 | define('CART_EMPTY', 2); |
|---|
| 282 | /** ページ推移エラー */ |
|---|
| 283 | define('PAGE_ERROR', 3); |
|---|
| 284 | /** 購入処理中のカート商品追加エラー */ |
|---|
| 285 | define('CART_ADD_ERROR', 4); |
|---|
| 286 | /** 他にも購入手続きが行われた場合 */ |
|---|
| 287 | define('CANCEL_PURCHASE', 5); |
|---|
| 288 | /** 指定カテゴリページがない */ |
|---|
| 289 | define('CATEGORY_NOT_FOUND', 6); |
|---|
| 290 | /** ログインに失敗 */ |
|---|
| 291 | define('SITE_LOGIN_ERROR', 7); |
|---|
| 292 | /** 会員専用ページへのアクセスエラー */ |
|---|
| 293 | define('CUSTOMER_ERROR', 8); |
|---|
| 294 | /** 購入時の売り切れエラー */ |
|---|
| 295 | define('SOLD_OUT', 9); |
|---|
| 296 | /** カート内商品の読込エラー */ |
|---|
| 297 | define('CART_NOT_FOUND', 10); |
|---|
| 298 | /** ポイントの不足 */ |
|---|
| 299 | define('LACK_POINT', 11); |
|---|
| 300 | /** 仮登録者がログインに失敗 */ |
|---|
| 301 | define('TEMP_LOGIN_ERROR', 12); |
|---|
| 302 | /** URLエラー */ |
|---|
| 303 | define('URL_ERROR', 13); |
|---|
| 304 | /** ファイル解凍エラー */ |
|---|
| 305 | define('EXTRACT_ERROR', 14); |
|---|
| 306 | /** FTPダウンロードエラー */ |
|---|
| 307 | define('FTP_DOWNLOAD_ERROR', 15); |
|---|
| 308 | /** FTPログインエラー */ |
|---|
| 309 | define('FTP_LOGIN_ERROR', 16); |
|---|
| 310 | /** FTP接続エラー */ |
|---|
| 311 | define('FTP_CONNECT_ERROR', 17); |
|---|
| 312 | /** DB作成エラー */ |
|---|
| 313 | define('CREATE_DB_ERROR', 18); |
|---|
| 314 | /** DBインポートエラー */ |
|---|
| 315 | define('DB_IMPORT_ERROR', 19); |
|---|
| 316 | /** 設定ファイル存在エラー */ |
|---|
| 317 | define('FILE_NOT_FOUND', 20); |
|---|
| 318 | /** 書き込みエラー */ |
|---|
| 319 | define('WRITE_FILE_ERROR', 21); |
|---|
| 320 | /** DB接続エラー */ |
|---|
| 321 | define('DB_CONNECT_ERROR', 22); |
|---|
| 322 | /** ダウンロードファイル存在エラー */ |
|---|
| 323 | define('DOWNFILE_NOT_FOUND', 22); |
|---|
| 324 | /** フリーメッセージ */ |
|---|
| 325 | define('FREE_ERROR_MSG', 999); |
|---|
| 326 | |
|---|
| 327 | // LC_Page_Error_DispError用 |
|---|
| 328 | /** ログイン失敗 */ |
|---|
| 329 | define('LOGIN_ERROR', 1); |
|---|
| 330 | /** アクセス失敗(タイムアウト等) */ |
|---|
| 331 | define('ACCESS_ERROR', 2); |
|---|
| 332 | /** アクセス権限違反 */ |
|---|
| 333 | define('AUTH_ERROR', 3); |
|---|
| 334 | /** 不正な遷移エラー */ |
|---|
| 335 | define('INVALID_MOVE_ERRORR', 4); |
|---|
| 336 | |
|---|
| 337 | // オーナーズストア通信関連 |
|---|
| 338 | /** オーナーズストア通信ステータス */ |
|---|
| 339 | define('OSTORE_STATUS_ERROR', 'ERROR'); |
|---|
| 340 | /** オーナーズストア通信ステータス */ |
|---|
| 341 | define('OSTORE_STATUS_SUCCESS', 'SUCCESS'); |
|---|
| 342 | /** オーナーズストア通信エラーコード */ |
|---|
| 343 | define('OSTORE_E_UNKNOWN', '1000'); |
|---|
| 344 | /** オーナーズストア通信エラーコード */ |
|---|
| 345 | define('OSTORE_E_INVALID_PARAM', '1001'); |
|---|
| 346 | /** オーナーズストア通信エラーコード */ |
|---|
| 347 | define('OSTORE_E_NO_CUSTOMER', '1002'); |
|---|
| 348 | /** オーナーズストア通信エラーコード */ |
|---|
| 349 | define('OSTORE_E_WRONG_URL_PASS', '1003'); |
|---|
| 350 | /** オーナーズストア通信エラーコード */ |
|---|
| 351 | define('OSTORE_E_NO_PRODUCTS', '1004'); |
|---|
| 352 | /** オーナーズストア通信エラーコード */ |
|---|
| 353 | define('OSTORE_E_NO_DL_DATA', '1005'); |
|---|
| 354 | /** オーナーズストア通信エラーコード */ |
|---|
| 355 | define('OSTORE_E_DL_DATA_OPEN', '1006'); |
|---|
| 356 | /** オーナーズストア通信エラーコード */ |
|---|
| 357 | define('OSTORE_E_DLLOG_AUTH', '1007'); |
|---|
| 358 | /** オーナーズストア通信エラーコード */ |
|---|
| 359 | define('OSTORE_E_C_ADMIN_AUTH', '2001'); |
|---|
| 360 | /** オーナーズストア通信エラーコード */ |
|---|
| 361 | define('OSTORE_E_C_HTTP_REQ', '2002'); |
|---|
| 362 | /** オーナーズストア通信エラーコード */ |
|---|
| 363 | define('OSTORE_E_C_HTTP_RESP', '2003'); |
|---|
| 364 | /** オーナーズストア通信エラーコード */ |
|---|
| 365 | define('OSTORE_E_C_FAILED_JSON_PARSE', '2004'); |
|---|
| 366 | /** オーナーズストア通信エラーコード */ |
|---|
| 367 | define('OSTORE_E_C_NO_KEY', '2005'); |
|---|
| 368 | /** オーナーズストア通信エラーコード */ |
|---|
| 369 | define('OSTORE_E_C_INVALID_ACCESS', '2006'); |
|---|
| 370 | /** オーナーズストア通信エラーコード */ |
|---|
| 371 | define('OSTORE_E_C_INVALID_PARAM', '2007'); |
|---|
| 372 | /** オーナーズストア通信エラーコード */ |
|---|
| 373 | define('OSTORE_E_C_AUTOUP_DISABLE', '2008'); |
|---|
| 374 | /** オーナーズストア通信エラーコード */ |
|---|
| 375 | define('OSTORE_E_C_PERMISSION', '2009'); |
|---|
| 376 | /** オーナーズストア通信エラーコード */ |
|---|
| 377 | define('OSTORE_E_C_BATCH_ERR', '2010'); |
|---|
| 378 | |
|---|
| 379 | // プラグイン関連 |
|---|
| 380 | /** プラグインの状態:アップロード済み */ |
|---|
| 381 | define('PLUGIN_STATUS_UPLOADED', '1'); |
|---|
| 382 | /** プラグインの状態:インストール済み */ |
|---|
| 383 | define('PLUGIN_STATUS_INSTALLED', '2'); |
|---|
| 384 | /** プラグイン有効/無効:有効 */ |
|---|
| 385 | define('PLUGIN_ENABLE_TRUE', '1'); |
|---|
| 386 | /** プラグイン有効/無効:無効 */ |
|---|
| 387 | define('PLUGIN_ENABLE_FALSE', '2'); |
|---|
| 388 | |
|---|
| 389 | // CSV入出力関連 |
|---|
| 390 | /** CSV入出力列設定有効無効フラグ: 有効 */ |
|---|
| 391 | define('CSV_COLUMN_STATUS_FLG_ENABLE', 1); |
|---|
| 392 | /** CSV入出力列設定有効無効フラグ: 無効 */ |
|---|
| 393 | define('CSV_COLUMN_STATUS_FLG_DISABLE', 2); |
|---|
| 394 | /** CSV入出力列設定読み書きフラグ: 読み書き可能 */ |
|---|
| 395 | define('CSV_COLUMN_RW_FLG_READ_WRITE', 1); |
|---|
| 396 | /** CSV入出力列設定読み書きフラグ: 読み込みのみ可能 */ |
|---|
| 397 | define('CSV_COLUMN_RW_FLG_READ_ONLY', 2); |
|---|
| 398 | /** CSV入出力列設定読み書きフラグ: キー列 */ |
|---|
| 399 | define('CSV_COLUMN_RW_FLG_KEY_FIELD', 3); |
|---|
| 400 | |
|---|
| 401 | // 配置ID |
|---|
| 402 | /** 配置ID: 未使用 */ |
|---|
| 403 | define('TARGET_ID_UNUSED', 0); |
|---|
| 404 | /** 配置ID: LeftNavi */ |
|---|
| 405 | define('TARGET_ID_LEFT', 1); |
|---|
| 406 | /** 配置ID: MainHead */ |
|---|
| 407 | define('TARGET_ID_MAIN_HEAD', 2); |
|---|
| 408 | /** 配置ID: RightNavi */ |
|---|
| 409 | define('TARGET_ID_RIGHT', 3); |
|---|
| 410 | /** 配置ID: MainFoot */ |
|---|
| 411 | define('TARGET_ID_MAIN_FOOT', 4); |
|---|
| 412 | /** 配置ID: TopNavi */ |
|---|
| 413 | define('TARGET_ID_TOP', 5); |
|---|
| 414 | /** 配置ID: BottomNavi */ |
|---|
| 415 | define('TARGET_ID_BOTTOM', 6); |
|---|
| 416 | /** 配置ID: HeadNavi */ |
|---|
| 417 | define('TARGET_ID_HEAD', 7); |
|---|
| 418 | /** 配置ID: HeadTopNavi */ |
|---|
| 419 | define('TARGET_ID_HEAD_TOP', 8); |
|---|
| 420 | /** 配置ID: FooterBottomNavi */ |
|---|
| 421 | define('TARGET_ID_FOOTER_BOTTOM', 9); |
|---|
| 422 | /** 配置ID: HeaderInternalNavi */ |
|---|
| 423 | define('TARGET_ID_HEADER_INTERNAL', 10); |
|---|
| 424 | |
|---|
| 425 | // 他 |
|---|
| 426 | /** アクセス成功 */ |
|---|
| 427 | define('SUCCESS', 0); |
|---|
| 428 | /** 無制限フラグ: 無制限 */ |
|---|
| 429 | define('UNLIMITED_FLG_UNLIMITED', '1'); |
|---|
| 430 | /** 無制限フラグ: 制限有り */ |
|---|
| 431 | define('UNLIMITED_FLG_LIMITED', '0'); |
|---|
| 432 | } |
|---|
| 433 | |
|---|
| 434 | /** |
|---|
| 435 | * クォートされた文字列のクォート部分を再帰的に取り除く. |
|---|
| 436 | * |
|---|
| 437 | * {@link http://jp2.php.net/manual/ja/function.get-magic-quotes-gpc.php PHP Manual} の記事を参考に実装。 |
|---|
| 438 | * $_REQUEST は後続の処理で再構成されるため、本処理では外している。 |
|---|
| 439 | * この関数は, PHP5以上を対象とし, PHP4 の場合は何もしない. |
|---|
| 440 | * |
|---|
| 441 | * @return void |
|---|
| 442 | */ |
|---|
| 443 | function stripslashesDeepGpc() |
|---|
| 444 | { |
|---|
| 445 | // Strip magic quotes from request data. |
|---|
| 446 | if (get_magic_quotes_gpc() |
|---|
| 447 | && version_compare(PHP_VERSION, '5.0.0', '>=')) { |
|---|
| 448 | // Create lamba style unescaping function (for portability) |
|---|
| 449 | $quotes_sybase = strtolower(ini_get('magic_quotes_sybase')); |
|---|
| 450 | $unescape_function = (empty($quotes_sybase) || $quotes_sybase === 'off') ? 'stripslashes($value)' : 'str_replace("\'\'","\'",$value)'; |
|---|
| 451 | $stripslashes_deep = create_function('&$value, $fn', ' |
|---|
| 452 | if (is_string($value)) { |
|---|
| 453 | $value = ' . $unescape_function . '; |
|---|
| 454 | } else if (is_array($value)) { |
|---|
| 455 | foreach ($value as &$v) $fn($v, $fn); |
|---|
| 456 | } |
|---|
| 457 | '); |
|---|
| 458 | |
|---|
| 459 | // Unescape data |
|---|
| 460 | $stripslashes_deep($_POST, $stripslashes_deep); |
|---|
| 461 | $stripslashes_deep($_GET, $stripslashes_deep); |
|---|
| 462 | $stripslashes_deep($_COOKIE, $stripslashes_deep); |
|---|
| 463 | } |
|---|
| 464 | } |
|---|
| 465 | |
|---|
| 466 | /** |
|---|
| 467 | * スーパーグローバル変数「$_REQUEST」を再セット |
|---|
| 468 | * |
|---|
| 469 | * variables_order ディレクティブによる差を吸収する。 |
|---|
| 470 | * |
|---|
| 471 | * @access protected |
|---|
| 472 | * @return void |
|---|
| 473 | */ |
|---|
| 474 | function resetSuperglobalsRequest() |
|---|
| 475 | { |
|---|
| 476 | $_REQUEST = array_merge($_GET, $_POST); |
|---|
| 477 | } |
|---|
| 478 | |
|---|
| 479 | /** |
|---|
| 480 | * 指定された名前の定数が存在しない場合、指定された値で定義 |
|---|
| 481 | * |
|---|
| 482 | * @param string $name 定数の名前。 |
|---|
| 483 | * @param mixed $value 定数の値。 |
|---|
| 484 | * @return void |
|---|
| 485 | */ |
|---|
| 486 | function defineIfNotDefined($name, $value = null) |
|---|
| 487 | { |
|---|
| 488 | if (!defined($name)) { |
|---|
| 489 | define($name, $value); |
|---|
| 490 | } |
|---|
| 491 | } |
|---|
| 492 | |
|---|
| 493 | /** |
|---|
| 494 | * タイムゾーンを設定 |
|---|
| 495 | * |
|---|
| 496 | * @return void |
|---|
| 497 | */ |
|---|
| 498 | function setTimezone() |
|---|
| 499 | { |
|---|
| 500 | date_default_timezone_set('Asia/Tokyo'); |
|---|
| 501 | } |
|---|
| 502 | } |
|---|