1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2010 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 | // {{{ requires |
---|
25 | require_once(CLASS_FILE_PATH . "pages/LC_Page.php"); |
---|
26 | |
---|
27 | /** |
---|
28 | * ログインチェック のページクラス. |
---|
29 | * |
---|
30 | * TODO mypage/LC_Page_Mypage_LoginCheck と統合 |
---|
31 | * |
---|
32 | * @package Page |
---|
33 | * @author LOCKON CO.,LTD. |
---|
34 | * @version $Id:LC_Page_FrontParts_LoginCheck.php 15532 2007-08-31 14:39:46Z nanasess $ |
---|
35 | */ |
---|
36 | class LC_Page_FrontParts_LoginCheck extends LC_Page { |
---|
37 | |
---|
38 | // }}} |
---|
39 | // {{{ functions |
---|
40 | |
---|
41 | /** |
---|
42 | * Page を初期化する. |
---|
43 | * |
---|
44 | * @return void |
---|
45 | */ |
---|
46 | function init() { |
---|
47 | parent::init(); |
---|
48 | |
---|
49 | } |
---|
50 | |
---|
51 | /** |
---|
52 | * Page のプロセス. |
---|
53 | * |
---|
54 | * @return void |
---|
55 | */ |
---|
56 | function process() { |
---|
57 | $this->action(); |
---|
58 | $this->sendResponse(); |
---|
59 | } |
---|
60 | |
---|
61 | /** |
---|
62 | * Page のアクション. |
---|
63 | * |
---|
64 | * @return void |
---|
65 | */ |
---|
66 | function action() { |
---|
67 | $objCustomer = new SC_Customer(); |
---|
68 | // 不正なURLがPOSTされた場合はエラー表示 |
---|
69 | if (!SC_Helper_Session_Ex::isValidToken()) { |
---|
70 | GC_Utils_Ex::gfPrintLog('invalid access :login_check.php $POST["url"]=' . $_POST['url']); |
---|
71 | SC_Utils_Ex::sfDispSiteError(PAGE_ERROR); |
---|
72 | } |
---|
73 | // クッキー管理クラス |
---|
74 | $objCookie = new SC_Cookie(COOKIE_EXPIRE); |
---|
75 | // パラメータ管理クラス |
---|
76 | $this->objFormParam = new SC_FormParam(); |
---|
77 | // パラメータ情報の初期化 |
---|
78 | $this->lfInitParam(); |
---|
79 | //パスワード・Eメールにある空白をトリム |
---|
80 | $_POST["login_email"] = preg_replace('/^[ \r\n]*(.*?)[ \r\n]*$/u', '$1', $_POST["login_email"]); |
---|
81 | $_POST["login_pass"] = trim($_POST["login_pass"]); //認証用 |
---|
82 | $_POST["login_pass1"] = $_POST["login_pass"]; //最小桁数比較用 |
---|
83 | $_POST["login_pass2"] = $_POST["login_pass"]; //最大桁数比較用 |
---|
84 | // POST値の取得 |
---|
85 | $this->objFormParam->setParam($_POST); |
---|
86 | |
---|
87 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
88 | |
---|
89 | switch($_POST['mode']) { |
---|
90 | case 'login': |
---|
91 | $this->objFormParam->toLower('login_email'); |
---|
92 | $arrErr = $this->objFormParam->checkError(); |
---|
93 | |
---|
94 | // エラーの場合はエラー画面に遷移 |
---|
95 | if (count($arrErr) > 0) { |
---|
96 | SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR); |
---|
97 | } |
---|
98 | $arrForm = $this->objFormParam->getHashArray(); |
---|
99 | // クッキー保存判定 |
---|
100 | if ($arrForm['login_memory'] == "1" && $arrForm['login_email'] != "") { |
---|
101 | $objCookie->setCookie('login_email', $_POST['login_email']); |
---|
102 | } else { |
---|
103 | $objCookie->setCookie('login_email', ''); |
---|
104 | } |
---|
105 | |
---|
106 | if(count($arrErr) == 0) { |
---|
107 | if($objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'], true)) { |
---|
108 | $this->objDisplay->redirect($this->getLocation(URL_PATH, array(), false)); |
---|
109 | exit; |
---|
110 | } else { |
---|
111 | $arrForm['login_email'] = strtolower($arrForm['login_email']); |
---|
112 | $objQuery = new SC_Query; |
---|
113 | $where = "(email = ? OR email_mobile = ?) AND status = 1 AND del_flg = 0"; |
---|
114 | $ret = $objQuery->count("dtb_customer", $where, array($arrForm['login_email'], $arrForm['login_email'])); |
---|
115 | |
---|
116 | if($ret > 0) { |
---|
117 | SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR); |
---|
118 | } else { |
---|
119 | SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR); |
---|
120 | } |
---|
121 | } |
---|
122 | } else { |
---|
123 | // 入力エラーの場合、元のアドレスに戻す。 |
---|
124 | $this->objDisplay->redirect($this->getLocation($_POST['url'], array(), false)); |
---|
125 | exit; |
---|
126 | } |
---|
127 | break; |
---|
128 | case 'logout': |
---|
129 | // ログイン情報の解放 |
---|
130 | $objCustomer->EndSession(); |
---|
131 | $mypage_url_search = strpos('.'.$_POST['url'], "mypage"); |
---|
132 | //マイページログイン中はログイン画面へ移行 |
---|
133 | if ($mypage_url_search == 2){ |
---|
134 | $this->objDisplay->redirect($this->getLocation(URL_PATH . "mypage/login.php", array(), false)); |
---|
135 | }else{ |
---|
136 | $this->objDisplay->redirect($this->getLocation(URL_PATH, array(), false)); |
---|
137 | } |
---|
138 | exit; |
---|
139 | break; |
---|
140 | } |
---|
141 | } |
---|
142 | |
---|
143 | /** |
---|
144 | * デストラクタ. |
---|
145 | * |
---|
146 | * @return void |
---|
147 | */ |
---|
148 | function destroy() { |
---|
149 | parent::destroy(); |
---|
150 | } |
---|
151 | |
---|
152 | /* パラメータ情報の初期化 */ |
---|
153 | function lfInitParam() { |
---|
154 | $this->objFormParam->addParam("記憶する", "login_memory", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
155 | $this->objFormParam->addParam("メールアドレス", "login_email", MTEXT_LEN, "a", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "EMAIL_CHECK", "NO_SPTAB" ,"EMAIL_CHAR_CHECK")); |
---|
156 | $this->objFormParam->addParam("パスワード", "login_pass", PASSWORD_LEN1, "", array("EXIST_CHECK")); |
---|
157 | $this->objFormParam->addParam("パスワード", "login_pass1", PASSWORD_LEN1, "", array("EXIST_CHECK", "MIN_LENGTH_CHECK")); |
---|
158 | $this->objFormParam->addParam("パスワード", "login_pass2", PASSWORD_LEN2, "", array("EXIST_CHECK", "MAX_LENGTH_CHECK")); |
---|
159 | } |
---|
160 | } |
---|
161 | ?> |
---|