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_REALDIR . "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 | // URLチェック |
---|
68 | if ( !SC_Helper_Session_Ex::isValidToken() ) { |
---|
69 | GC_Utils_Ex::gfPrintLog('invalid access :login_check.php $POST["url"]=' . $_POST['url']); |
---|
70 | SC_Utils_Ex::sfDispSiteError(PAGE_ERROR); |
---|
71 | } |
---|
72 | |
---|
73 | // 会員管理クラス |
---|
74 | $objCustomer = new SC_Customer(); |
---|
75 | // クッキー管理クラス |
---|
76 | $objCookie = new SC_Cookie(COOKIE_EXPIRE); |
---|
77 | // パラメータ管理クラス |
---|
78 | $this->objFormParam = new SC_FormParam(); |
---|
79 | |
---|
80 | // パラメータ情報の初期化 |
---|
81 | $this->lfInitParam($this->objFormParam); |
---|
82 | |
---|
83 | // リクエスト値をフォームにセット |
---|
84 | $this->objFormParam->setParam($this->lfConvertParam($_POST)); |
---|
85 | |
---|
86 | // モードによって分岐 |
---|
87 | switch ($this->getMode()) { |
---|
88 | case 'login': |
---|
89 | // --- ログイン |
---|
90 | |
---|
91 | // 入力値のエラーチェック |
---|
92 | $this->objFormParam->toLower('login_email'); |
---|
93 | $arrErr = $this->objFormParam->checkError(); |
---|
94 | |
---|
95 | // エラーの場合はエラー画面に遷移 |
---|
96 | if (count($arrErr) > 0) { |
---|
97 | SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR); |
---|
98 | } |
---|
99 | |
---|
100 | // 入力チェック後の値を取得 |
---|
101 | $arrForm = $this->objFormParam->getHashArray(); |
---|
102 | |
---|
103 | // クッキー保存判定 |
---|
104 | if ($arrForm['login_memory'] == '1' && $arrForm['login_email'] != '') { |
---|
105 | $objCookie->setCookie('login_email', $arrForm['login_email']); |
---|
106 | } else { |
---|
107 | $objCookie->setCookie('login_email', ''); |
---|
108 | } |
---|
109 | |
---|
110 | // 遷移先の制御 |
---|
111 | if (count($arrErr) == 0) { |
---|
112 | // ログイン処理 |
---|
113 | if ($objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'], true)) { |
---|
114 | // --- ログインに成功した場合 |
---|
115 | SC_Response_Ex::sendRedirect(HTTP_URL); |
---|
116 | exit; |
---|
117 | } else { |
---|
118 | // --- ログインに失敗した場合 |
---|
119 | $arrForm['login_email'] = strtolower($arrForm['login_email']); |
---|
120 | $objQuery = SC_Query::getSingletonInstance(); |
---|
121 | $where = '(email = ? OR email_mobile = ?) AND status = 1 AND del_flg = 0'; |
---|
122 | $ret = $objQuery->count("dtb_customer", $where, array($arrForm['login_email'], $arrForm['login_email'])); |
---|
123 | // ログインエラー表示 |
---|
124 | if($ret > 0) { |
---|
125 | SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR); |
---|
126 | } else { |
---|
127 | SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR); |
---|
128 | } |
---|
129 | } |
---|
130 | } else { |
---|
131 | // 入力エラーの場合、元のアドレスに戻す。 |
---|
132 | // FIXME $_POST['url'] には、URL ではなく、url-path が渡るもよう。HTTPS 利用に関わる問題も考えられるので、URL が渡るように改善した方が良いように感じる。 |
---|
133 | SC_Response_Ex::sendRedirect($_POST['url']); |
---|
134 | exit; |
---|
135 | } |
---|
136 | |
---|
137 | break; |
---|
138 | case 'logout': |
---|
139 | // --- ログアウト |
---|
140 | |
---|
141 | // ログイン情報の解放 |
---|
142 | $objCustomer->EndSession(); |
---|
143 | // 画面遷移の制御 |
---|
144 | $mypage_url_search = strpos('.'.$_POST['url'], 'mypage'); |
---|
145 | if ($mypage_url_search == 2) { |
---|
146 | // マイページログイン中はログイン画面へ移行 |
---|
147 | SC_Response_Ex::sendRedirectFromUrlPath('mypage/login.php'); |
---|
148 | } else { |
---|
149 | // 上記以外の場合、トップへ遷移 |
---|
150 | SC_Response_Ex::sendRedirect(HTTP_URL); |
---|
151 | } |
---|
152 | exit; |
---|
153 | |
---|
154 | break; |
---|
155 | default: |
---|
156 | break; |
---|
157 | } |
---|
158 | |
---|
159 | } |
---|
160 | |
---|
161 | /** |
---|
162 | * デストラクタ. |
---|
163 | * |
---|
164 | * @return void |
---|
165 | */ |
---|
166 | function destroy() { |
---|
167 | parent::destroy(); |
---|
168 | } |
---|
169 | |
---|
170 | /** |
---|
171 | * パラメータ情報の初期化. |
---|
172 | * |
---|
173 | * @param SC_FormParam $objFormParam パラメータ管理クラス |
---|
174 | * @return SC_FormParam $objFormParam 初期化したパラメータ管理クラスを返す |
---|
175 | */ |
---|
176 | function lfInitParam(&$objFormParam) { |
---|
177 | $objFormParam->addParam('記憶する', 'login_memory', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
178 | $objFormParam->addParam('メールアドレス', 'login_email', MTEXT_LEN, 'a', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'EMAIL_CHECK', 'NO_SPTAB' ,'EMAIL_CHAR_CHECK')); |
---|
179 | $objFormParam->addParam('パスワード', 'login_pass', PASSWORD_LEN1, '', array('EXIST_CHECK')); |
---|
180 | $objFormParam->addParam('パスワード', 'login_pass1', PASSWORD_LEN1, '', array('EXIST_CHECK', 'MIN_LENGTH_CHECK')); |
---|
181 | $objFormParam->addParam('パスワード', 'login_pass2', PASSWORD_LEN2, '', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); |
---|
182 | return $objFormParam; |
---|
183 | } |
---|
184 | |
---|
185 | /** |
---|
186 | * リクエスト値の整形. |
---|
187 | * |
---|
188 | * @param array $arrRequest リクエスト |
---|
189 | * @return array $arrRequest 整形したリクエストを返す |
---|
190 | */ |
---|
191 | function lfConvertParam($arrRequest) { |
---|
192 | // パスワード・Eメールにある空白をトリム |
---|
193 | $arrRequest['login_email'] = preg_replace('/^[ \r\n]*(.*?)[ \r\n]*$/u', '$1', $arrRequest['login_email']); |
---|
194 | $arrRequest['login_pass'] = trim($arrRequest['login_pass']); //認証用 |
---|
195 | $arrRequest['login_pass1'] = $arrRequest['login_pass']; //最小桁数比較用 |
---|
196 | $arrRequest['login_pass2'] = $arrRequest['login_pass']; //最大桁数比較用 |
---|
197 | return $arrRequest; |
---|
198 | } |
---|
199 | |
---|
200 | } |
---|
201 | ?> |
---|