source: branches/version-2_13-dev/data/class/pages/frontparts/LC_Page_FrontParts_LoginCheck.php @ 22857

Revision 22857, 9.3 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

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