Changeset 22922 for branches/version-2_13-dev/data/class/SC_Initial.php
- Timestamp:
- 2013/06/29 17:38:04 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_13-dev/data/class/SC_Initial.php
r22856 r22922 58 58 $this->resetSuperglobalsRequest(); // stripslashesDeepGpc メソッドより後で実行 59 59 $this->setTimezone(); // 本当はエラーハンドラーより先に読みたい気も 60 $this->normalizeHostname(); // defineConstants メソッドより後で実行 60 61 } 61 62 … … 489 490 date_default_timezone_set('Asia/Tokyo'); 490 491 } 492 493 /** 494 * ホスト名を正規化する 495 * 496 * @return void 497 */ 498 function normalizeHostname() 499 { 500 if ( 501 // パラメーター 502 !USE_NORMALIZE_HOSTNAME 503 // コマンドライン実行の場合 504 || !isset($_SERVER['REQUEST_URI']) 505 // POSTの場合 506 || $_SERVER['REQUEST_METHOD'] === 'POST' 507 ) { 508 // 処理せず戻る 509 return; 510 } 511 512 $netUrlRequest = new Net_URL($_SERVER['REQUEST_URI']); 513 // 要求を受けたホスト名 514 $request_hostname = $netUrlRequest->host; 515 516 $netUrlCorrect = new Net_URL(SC_Utils_Ex::sfIsHTTPS() ? HTTPS_URL : HTTP_URL); 517 // 設定上のホスト名 518 $correct_hostname = $netUrlCorrect->host; 519 520 // ホスト名が不一致の場合 521 if ($request_hostname !== $correct_hostname) { 522 // ホスト名を書き換え 523 $netUrlRequest->host = $correct_hostname; 524 // 正しい URL 525 $correct_url = $netUrlRequest->getUrl(); 526 // 警告 527 $msg = 'ホスト名不一致を検出。リダイレクト実行。'; 528 $msg .= '要求値=' . var_export($request_hostname, true) . ' '; 529 $msg .= '設定値=' . var_export($correct_hostname, true) . ' '; 530 $msg .= 'リダイレクト先=' . var_export($correct_url, true) . ' '; 531 trigger_error($msg, E_USER_WARNING); 532 // リダイレクト(恒久的) 533 SC_Response_Ex::sendHttpStatus(301); 534 SC_Response_Ex::sendRedirect($correct_url); 535 } 536 } 491 537 }
Note: See TracChangeset
for help on using the changeset viewer.
