| 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 | class SC_SiteSession |
---|
| 26 | { |
---|
| 27 | /* コンストラクタ */ |
---|
| 28 | public function __construct() |
---|
| 29 | { |
---|
| 30 | // 前ページでの登録成功判定を引き継ぐ |
---|
| 31 | $_SESSION['site']['pre_regist_success'] = |
---|
| 32 | isset($_SESSION['site']['regist_success']) |
---|
| 33 | ? $_SESSION['site']['regist_success'] : ''; |
---|
| 34 | |
---|
| 35 | $_SESSION['site']['regist_success'] = false; |
---|
| 36 | $_SESSION['site']['pre_page'] = |
---|
| 37 | isset($_SESSION['site']['now_page']) |
---|
| 38 | ? $_SESSION['site']['now_page'] : ''; |
---|
| 39 | |
---|
| 40 | $_SESSION['site']['now_page'] = $_SERVER['SCRIPT_NAME']; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | /* 前ページが正当であるかの判定 */ |
---|
| 44 | public function isPrePage() |
---|
| 45 | { |
---|
| 46 | if ($_SESSION['site']['pre_page'] != '' && $_SESSION['site']['now_page'] != '') { |
---|
| 47 | if ($_SESSION['site']['pre_regist_success'] || $_SESSION['site']['pre_page'] == $_SESSION['site']['now_page']) { |
---|
| 48 | return true; |
---|
| 49 | } |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | return false; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | public function setNowPage($path) |
---|
| 56 | { |
---|
| 57 | $_SESSION['site']['now_page'] = $path; |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | /* 値の取得 */ |
---|
| 61 | public function getValue($keyname) |
---|
| 62 | { |
---|
| 63 | return $_SESSION['site'][$keyname]; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | /* ユニークIDの取得 */ |
---|
| 67 | public function getUniqId() |
---|
| 68 | { |
---|
| 69 | // ユニークIDがセットされていない場合はセットする。 |
---|
| 70 | if (!isset($_SESSION['site']['uniqid']) || $_SESSION['site']['uniqid'] == '') { |
---|
| 71 | $this->setUniqId(); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | return $_SESSION['site']['uniqid']; |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | /* ユニークIDのセット */ |
---|
| 78 | public function setUniqId() |
---|
| 79 | { |
---|
| 80 | // 予測されないようにランダム文字列を付与する。 |
---|
| 81 | $_SESSION['site']['uniqid'] = SC_Utils_Ex::sfGetUniqRandomId(); |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | /* ユニークIDのチェック */ |
---|
| 85 | public function checkUniqId() |
---|
| 86 | { |
---|
| 87 | if (!empty($_POST['uniqid'])) { |
---|
| 88 | if ($_POST['uniqid'] != $_SESSION['site']['uniqid']) { |
---|
| 89 | return false; |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | return true; |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | /* ユニークIDの解除 */ |
---|
| 97 | public function unsetUniqId() |
---|
| 98 | { |
---|
| 99 | $_SESSION['site']['uniqid'] = ''; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | /* 登録成功を記録 */ |
---|
| 103 | public function setRegistFlag() |
---|
| 104 | { |
---|
| 105 | $_SESSION['site']['regist_success'] = true; |
---|
| 106 | } |
---|
| 107 | } |
---|