source: branches/version-2_12-multilang/data/class/pages/frontparts/LC_Page_FrontParts_LoginCheck.php @ 22503

Revision 22503, 9.3 KB checked in by m_uehara, 11 years ago (diff)

#2084 メッセージIDの振り直し

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2012 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
25require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.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 */
36class LC_Page_FrontParts_LoginCheck extends LC_Page_Ex {
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
68        // 会員管理クラス
69        $objCustomer = new SC_Customer_Ex();
70        // クッキー管理クラス
71        $objCookie = new SC_Cookie_Ex();
72        // パラメーター管理クラス
73        $objFormParam = new SC_FormParam_Ex();
74
75        // パラメーター情報の初期化
76        $this->lfInitParam($objFormParam);
77
78        // リクエスト値をフォームにセット
79        $objFormParam->setParam($_POST);
80
81        $url = htmlspecialchars($_POST['url'], ENT_QUOTES);
82
83        // モードによって分岐
84        switch ($this->getMode()) {
85            case 'login':
86                // --- ログイン
87
88                // 入力値のエラーチェック
89                $objFormParam->trimParam();
90                $objFormParam->toLower('login_email');
91                $arrErr = $objFormParam->checkError();
92
93                // エラーの場合はエラー画面に遷移
94                if (count($arrErr) > 0) {
95                    if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
96                        echo $this->lfGetErrorMessage(TEMP_LOGIN_ERROR);
97                        SC_Response_Ex::actionExit();
98                    } else {
99                        SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR);
100                        SC_Response_Ex::actionExit();
101                    }
102                }
103
104                // 入力チェック後の値を取得
105                $arrForm = $objFormParam->getHashArray();
106
107                // クッキー保存判定
108                if ($arrForm['login_memory'] == '1' && $arrForm['login_email'] != '') {
109                    $objCookie->setCookie('login_email', $arrForm['login_email']);
110                } else {
111                    $objCookie->setCookie('login_email', '');
112                }
113
114                // 遷移先の制御
115                if (count($arrErr) == 0) {
116                    // ログイン処理
117                    if ($objCustomer->doLogin($arrForm['login_email'], $arrForm['login_pass'])) {
118                        if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
119                            // ログインが成功した場合は携帯端末IDを保存する。
120                            $objCustomer->updateMobilePhoneId();
121
122                            /*
123                             * email がモバイルドメインでは無く,
124                             * 携帯メールアドレスが登録されていない場合
125                             */
126                            $objMobile = new SC_Helper_Mobile_Ex();
127                            if (!$objMobile->gfIsMobileMailAddress($objCustomer->getValue('email'))) {
128                                if (!$objCustomer->hasValue('email_mobile')) {
129
130                                    SC_Response_Ex::sendRedirectFromUrlPath('entry/email_mobile.php');
131                                    SC_Response_Ex::actionExit();
132                                }
133                            }
134                        }
135
136                        // --- ログインに成功した場合
137                        if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
138                            echo SC_Utils_Ex::jsonEncode(array('success' => $url));
139                        } else {
140                            SC_Response_Ex::sendRedirect($url);
141                        }                       
142                        SC_Response_Ex::actionExit();
143                    } else {
144                        // --- ログインに失敗した場合
145
146                        // ブルートフォースアタック対策
147                        // ログイン失敗時に遅延させる
148                        sleep(LOGIN_RETRY_INTERVAL);
149
150                        $arrForm['login_email'] = strtolower($arrForm['login_email']);
151                        $objQuery = SC_Query_Ex::getSingletonInstance();
152                        $where = '(email = ? OR email_mobile = ?) AND status = 1 AND del_flg = 0';
153                        $exists = $objQuery->exists('dtb_customer', $where, array($arrForm['login_email'], $arrForm['login_email']));
154                        // ログインエラー表示 TODO リファクタリング
155                        if ($exists) {
156                            if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
157                                echo $this->lfGetErrorMessage(TEMP_LOGIN_ERROR);
158                                SC_Response_Ex::actionExit();
159                            } else {
160                                SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR);
161                                SC_Response_Ex::actionExit();
162                            }
163                        } else {
164                            if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
165                                echo $this->lfGetErrorMessage(SITE_LOGIN_ERROR);
166                                SC_Response_Ex::actionExit();
167                            } else {
168                                SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR);
169                                SC_Response_Ex::actionExit();
170                            }
171                        }
172                    }
173                } else {
174                    // XXX 到達しない?
175                    // 入力エラーの場合、元のアドレスに戻す。
176                    SC_Response_Ex::sendRedirect($url);
177                    SC_Response_Ex::actionExit();
178                }
179
180                break;
181            case 'logout':
182                // --- ログアウト
183
184                // ログイン情報の解放
185                $objCustomer->EndSession();
186                // 画面遷移の制御
187                $mypage_url_search = strpos('.'.$url, 'mypage');
188                if ($mypage_url_search == 2) {
189
190                    // マイページログイン中はログイン画面へ移行
191                    SC_Response_Ex::sendRedirectFromUrlPath('mypage/login.php');
192                } else {
193
194                    // 上記以外の場合、トップへ遷移
195                    SC_Response_Ex::sendRedirect(HTTP_URL);
196                }
197                SC_Response_Ex::actionExit();
198
199                break;
200            default:
201                break;
202        }
203
204    }
205
206    /**
207     * デストラクタ.
208     *
209     * @return void
210     */
211    function destroy() {
212        parent::destroy();
213    }
214
215    /**
216     * パラメーター情報の初期化.
217     *
218     * @param SC_FormParam $objFormParam パラメーター管理クラス
219     * @return void
220     */
221    function lfInitParam(&$objFormParam) {
222        $objFormParam->addParam(t('c_Record_01'), 'login_memory', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
223        $objFormParam->addParam(t('c_E-mail address_01'), 'login_email', MTEXT_LEN, 'a', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
224        $objFormParam->addParam(t('c_Password_01'), 'login_pass', PASSWORD_MAX_LEN, '', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
225    }
226
227    /**
228     * エラーメッセージを JSON 形式で返す.
229     *
230     * TODO リファクタリング
231     * この関数は主にスマートフォンで使用します.
232     *
233     * @param integer エラーコード
234     * @return string JSON 形式のエラーメッセージ
235     * @see LC_PageError
236     */
237    function lfGetErrorMessage($error) {
238        switch ($error) {
239            case TEMP_LOGIN_ERROR:
240                $msg = t('c_The e-mail address or password is not correct.\nIf you have not completed registration, access the registration page from the URL given to you in an e-mail._01');
241                break;
242            case SITE_LOGIN_ERROR:
243            default:
244                $msg = t('LC_Page_FrontParts_LoginCheck_002');
245        }
246        return SC_Utils_Ex::jsonEncode(array('login_error' => $msg));
247    }
248}
Note: See TracBrowser for help on using the repository browser.