source: branches/version-2_13_0/data/class/pages/frontparts/LC_Page_FrontParts_LoginCheck.php @ 23126

Revision 23126, 9.5 KB checked in by m_uehara, 11 years ago (diff)

#2348 r23116 - r23125 をマージ

  • 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-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
24require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
25
26/**
27 * ログインチェック のページクラス.
28 *
29 * TODO mypage/LC_Page_Mypage_LoginCheck と統合
30 *
31 * @package Page
32 * @author LOCKON CO.,LTD.
33 * @version $Id:LC_Page_FrontParts_LoginCheck.php 15532 2007-08-31 14:39:46Z nanasess $
34 */
35class LC_Page_FrontParts_LoginCheck extends LC_Page_Ex
36{
37    /**
38     * Page を初期化する.
39     *
40     * @return void
41     */
42    public function init()
43    {
44        $this->skip_load_page_layout = true;
45        parent::init();
46    }
47
48    /**
49     * Page のプロセス.
50     *
51     * @return void
52     */
53    public function process()
54    {
55        $this->action();
56        $this->sendResponse();
57    }
58
59    /**
60     * Page のアクション.
61     *
62     * @return void
63     */
64    public function action()
65    {
66        //決済処理中ステータスのロールバック
67        $objPurchase = new SC_Helper_Purchase_Ex();
68        $objPurchase->checkSessionPendingOrder();
69        $objPurchase->checkDbMyPendignOrder();
70        $objPurchase->checkDbAllPendingOrder();
71
72        // 会員管理クラス
73        $objCustomer = new SC_Customer_Ex();
74        // クッキー管理クラス
75        $objCookie = new SC_Cookie_Ex();
76        // パラメーター管理クラス
77        $objFormParam = new SC_FormParam_Ex();
78
79        // パラメーター情報の初期化
80        $this->lfInitParam($objFormParam);
81
82        // リクエスト値をフォームにセット
83        $objFormParam->setParam($_POST);
84
85        $url = htmlspecialchars($_POST['url'], ENT_QUOTES);
86
87        // モードによって分岐
88        switch ($this->getMode()) {
89            case 'login':
90                // --- ログイン
91
92                // 入力値のエラーチェック
93                $objFormParam->trimParam();
94                $objFormParam->toLower('login_email');
95                $arrErr = $objFormParam->checkError();
96
97                // エラーの場合はエラー画面に遷移
98                if (count($arrErr) > 0) {
99                    if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
100                        echo $this->lfGetErrorMessage(TEMP_LOGIN_ERROR);
101                        SC_Response_Ex::actionExit();
102                    } else {
103                        SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR);
104                        SC_Response_Ex::actionExit();
105                    }
106                }
107
108                // 入力チェック後の値を取得
109                $arrForm = $objFormParam->getHashArray();
110
111                // クッキー保存判定
112                if ($arrForm['login_memory'] == '1' && $arrForm['login_email'] != '') {
113                    $objCookie->setCookie('login_email', $arrForm['login_email']);
114                } else {
115                    $objCookie->setCookie('login_email', '');
116                }
117
118                // 遷移先の制御
119                if (count($arrErr) == 0) {
120                    // ログイン処理
121                    if ($objCustomer->doLogin($arrForm['login_email'], $arrForm['login_pass'])) {
122                        if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
123                            // ログインが成功した場合は携帯端末IDを保存する。
124                            $objCustomer->updateMobilePhoneId();
125
126                            /*
127                             * email がモバイルドメインでは無く,
128                             * 携帯メールアドレスが登録されていない場合
129                             */
130                            $objMobile = new SC_Helper_Mobile_Ex();
131                            if (!$objMobile->gfIsMobileMailAddress($objCustomer->getValue('email'))) {
132                                if (!$objCustomer->hasValue('email_mobile')) {
133                                    SC_Response_Ex::sendRedirectFromUrlPath('entry/email_mobile.php');
134                                    SC_Response_Ex::actionExit();
135                                }
136                            }
137                        }
138
139                        // --- ログインに成功した場合
140                        if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
141                            echo SC_Utils_Ex::jsonEncode(array('success' => $url));
142                        } else {
143                            SC_Response_Ex::sendRedirect($url);
144                        }
145                        SC_Response_Ex::actionExit();
146                    } else {
147                        // --- ログインに失敗した場合
148
149                        // ブルートフォースアタック対策
150                        // ログイン失敗時に遅延させる
151                        sleep(LOGIN_RETRY_INTERVAL);
152
153                        $arrForm['login_email'] = strtolower($arrForm['login_email']);
154                        $objQuery = SC_Query_Ex::getSingletonInstance();
155                        $where = '(email = ? OR email_mobile = ?) AND status = 1 AND del_flg = 0';
156                        $exists = $objQuery->exists('dtb_customer', $where, array($arrForm['login_email'], $arrForm['login_email']));
157                        // ログインエラー表示 TODO リファクタリング
158                        if ($exists) {
159                            if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
160                                echo $this->lfGetErrorMessage(TEMP_LOGIN_ERROR);
161                                SC_Response_Ex::actionExit();
162                            } else {
163                                SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR);
164                                SC_Response_Ex::actionExit();
165                            }
166                        } else {
167                            if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
168                                echo $this->lfGetErrorMessage(SITE_LOGIN_ERROR);
169                                SC_Response_Ex::actionExit();
170                            } else {
171                                SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR);
172                                SC_Response_Ex::actionExit();
173                            }
174                        }
175                    }
176                } else {
177                    // XXX 到達しない?
178                    // 入力エラーの場合、元のアドレスに戻す。
179                    SC_Response_Ex::sendRedirect($url);
180                    SC_Response_Ex::actionExit();
181                }
182
183                break;
184            case 'logout':
185                // --- ログアウト
186
187                // ログイン情報の解放
188                $objCustomer->EndSession();
189                // 画面遷移の制御
190                $mypage_url_search = strpos('.'.$url, 'mypage');
191                if ($mypage_url_search == 2) {
192                    // マイページログイン中はログイン画面へ移行
193                    SC_Response_Ex::sendRedirectFromUrlPath('mypage/login.php');
194                } else {
195                    // 上記以外の場合、トップへ遷移
196                    SC_Response_Ex::sendRedirect(HTTP_URL);
197                }
198                SC_Response_Ex::actionExit();
199
200                break;
201            default:
202                break;
203        }
204
205    }
206
207    /**
208     * パラメーター情報の初期化.
209     *
210     * @param  SC_FormParam $objFormParam パラメーター管理クラス
211     * @return void
212     */
213    public function lfInitParam(&$objFormParam)
214    {
215        $objFormParam->addParam('記憶する', 'login_memory', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
216        $objFormParam->addParam('メールアドレス', 'login_email', MTEXT_LEN, 'a', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
217        $objFormParam->addParam('パスワード', 'login_pass', PASSWORD_MAX_LEN, '', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
218    }
219
220    /**
221     * エラーメッセージを JSON 形式で返す.
222     *
223     * TODO リファクタリング
224     * この関数は主にスマートフォンで使用します.
225     *
226     * @param integer エラーコード
227     * @return string JSON 形式のエラーメッセージ
228     * @see LC_PageError
229     */
230    public function lfGetErrorMessage($error)
231    {
232        switch ($error) {
233            case TEMP_LOGIN_ERROR:
234                $msg = "メールアドレスもしくはパスワードが正しくありません。\n本登録がお済みでない場合は、仮登録メールに記載されているURLより本登録を行ってください。";
235                break;
236            case SITE_LOGIN_ERROR:
237            default:
238                $msg = 'メールアドレスもしくはパスワードが正しくありません。';
239        }
240
241        return SC_Utils_Ex::jsonEncode(array('login_error' => $msg));
242    }
243}
Note: See TracBrowser for help on using the repository browser.