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

Revision 21144, 7.5 KB checked in by nanasess, 13 years ago (diff)

#1413 ログインエラーを alert に

  • mypage/login.php を対応
  • 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-2011 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        $objCustomer = new SC_Customer_Ex();
69        // クッキー管理クラス
70        $objCookie = new SC_Cookie_Ex(COOKIE_EXPIRE);
71        // パラメーター管理クラス
72        $objFormParam = new SC_FormParam_Ex();
73
74        // パラメーター情報の初期化
75        $this->lfInitParam($objFormParam);
76
77        // リクエスト値をフォームにセット
78        $objFormParam->setParam($_POST);
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                SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR);
93            }
94
95            // 入力チェック後の値を取得
96            $arrForm = $objFormParam->getHashArray();
97
98            // クッキー保存判定
99            if ($arrForm['login_memory'] == '1' && $arrForm['login_email'] != '') {
100                $objCookie->setCookie('login_email', $arrForm['login_email']);
101            } else {
102                $objCookie->setCookie('login_email', '');
103            }
104
105            // 遷移先の制御
106            if (count($arrErr) == 0) {
107                // ログイン判定
108                $loginFailFlag = false;
109                if(SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
110                    // モバイルサイト
111                    if(!$objCustomer->getCustomerDataFromMobilePhoneIdPass($arrForm['login_pass']) &&
112                       !$objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'], true)) {
113                        $loginFailFlag = true;
114                    }
115                } else {
116                    // モバイルサイト以外
117                    if(!$objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'])) {
118                        $loginFailFlag = true;
119                    }
120                }
121
122                // ログイン処理
123                if ($loginFailFlag == false) {
124                    if(SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
125                        // ログインが成功した場合は携帯端末IDを保存する。
126                        $objCustomer->updateMobilePhoneId();
127
128                        /*
129                         * email がモバイルドメインでは無く,
130                         * 携帯メールアドレスが登録されていない場合
131                         */
132                        $objMobile = new SC_Helper_Mobile_Ex();
133                        if (!$objMobile->gfIsMobileMailAddress($objCustomer->getValue('email'))) {
134                            if (!$objCustomer->hasValue('email_mobile')) {
135                                SC_Response_Ex::sendRedirectFromUrlPath('entry/email_mobile.php');
136                                exit;
137                            }
138                        }
139                    }
140
141                    // --- ログインに成功した場合
142                    if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
143                        echo SC_Utils_Ex::jsonEncode(array('success' => $_POST['url']));
144                    } else {
145                        SC_Response_Ex::sendRedirect($_POST['url']);
146                    }
147                    exit;
148                } else {
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                    $ret = $objQuery->count("dtb_customer", $where, array($arrForm['login_email'], $arrForm['login_email']));
154                    // ログインエラー表示
155                    if($ret > 0) {
156                        SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR);
157                    } else {
158                        SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR);
159                    }
160                }
161            } else {
162                // XXX 到達しない?
163                // 入力エラーの場合、元のアドレスに戻す。
164                SC_Response_Ex::sendRedirect($_POST['url']);
165                exit;
166            }
167
168            break;
169        case 'logout':
170            // --- ログアウト
171
172            // ログイン情報の解放
173            $objCustomer->EndSession();
174            // 画面遷移の制御
175            $mypage_url_search = strpos('.'.$_POST['url'], 'mypage');
176            if ($mypage_url_search == 2) {
177                // マイページログイン中はログイン画面へ移行
178                SC_Response_Ex::sendRedirectFromUrlPath('mypage/login.php');
179            } else {
180                // 上記以外の場合、トップへ遷移
181                SC_Response_Ex::sendRedirect(HTTP_URL);
182            }
183            exit;
184
185            break;
186        default:
187            break;
188        }
189
190    }
191
192    /**
193     * デストラクタ.
194     *
195     * @return void
196     */
197    function destroy() {
198        parent::destroy();
199    }
200
201    /**
202     * パラメーター情報の初期化.
203     *
204     * @param SC_FormParam $objFormParam パラメーター管理クラス
205     * @return void
206     */
207    function lfInitParam(&$objFormParam) {
208        $objFormParam->addParam('記憶する', 'login_memory', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
209        $objFormParam->addParam('メールアドレス', 'login_email', MTEXT_LEN, 'a', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
210        $objFormParam->addParam('パスワード', 'login_pass', PASSWORD_MAX_LEN, '', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
211    }
212}
213?>
Note: See TracBrowser for help on using the repository browser.