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
RevLine 
[15367]1<?php
2/*
[16582]3 * This file is part of EC-CUBE
4 *
[20764]5 * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
[15367]6 *
7 * http://www.lockon.co.jp/
[16582]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.
[15367]22 */
23
24// {{{ requires
[20534]25require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
[15367]26
27/**
28 * ログインチェック のページクラス.
29 *
[16084]30 * TODO mypage/LC_Page_Mypage_LoginCheck と統合
31 *
[15367]32 * @package Page
33 * @author LOCKON CO.,LTD.
[15623]34 * @version $Id:LC_Page_FrontParts_LoginCheck.php 15532 2007-08-31 14:39:46Z nanasess $
[15367]35 */
[20344]36class LC_Page_FrontParts_LoginCheck extends LC_Page_Ex {
[15367]37
38    // }}}
39    // {{{ functions
40
41    /**
42     * Page を初期化する.
43     *
44     * @return void
45     */
46    function init() {
47        parent::init();
[16055]48
[15367]49    }
50
51    /**
52     * Page のプロセス.
53     *
54     * @return void
55     */
56    function process() {
[19661]57        $this->action();
58        $this->sendResponse();
59    }
60
61    /**
62     * Page のアクション.
63     *
64     * @return void
65     */
66    function action() {
[20076]67        // 会員管理クラス
[20490]68        $objCustomer = new SC_Customer_Ex();
[15367]69        // クッキー管理クラス
[20496]70        $objCookie = new SC_Cookie_Ex(COOKIE_EXPIRE);
[20970]71        // パラメーター管理クラス
[20501]72        $objFormParam = new SC_FormParam_Ex();
[20159]73
[20970]74        // パラメーター情報の初期化
[20433]75        $this->lfInitParam($objFormParam);
[20159]76
[20076]77        // リクエスト値をフォームにセット
[20433]78        $objFormParam->setParam($_POST);
[20159]79
[20076]80        // モードによって分岐
81        switch ($this->getMode()) {
[15367]82        case 'login':
[20108]83            // --- ログイン
[20159]84
[20108]85            // 入力値のエラーチェック
[20433]86            $objFormParam->trimParam();
87            $objFormParam->toLower('login_email');
88            $arrErr = $objFormParam->checkError();
[20159]89
[20108]90            // エラーの場合はエラー画面に遷移
91            if (count($arrErr) > 0) {
92                SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR);
93            }
[20159]94
[20108]95            // 入力チェック後の値を取得
[20433]96            $arrForm = $objFormParam->getHashArray();
[20159]97
[20108]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            }
[20159]104
[20108]105            // 遷移先の制御
106            if (count($arrErr) == 0) {
[20159]107                // ログイン判定
108                $loginFailFlag = false;
[20484]109                if(SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
[20159]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
[20108]122                // ログイン処理
[20159]123                if ($loginFailFlag == false) {
[20484]124                    if(SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
[20159]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
[20108]141                    // --- ログインに成功した場合
[21144]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                    }
[20108]147                    exit;
148                } else {
149                    // --- ログインに失敗した場合
150                    $arrForm['login_email'] = strtolower($arrForm['login_email']);
[20507]151                    $objQuery = SC_Query_Ex::getSingletonInstance();
[20108]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 {
[21144]162                // XXX 到達しない?
[20108]163                // 入力エラーの場合、元のアドレスに戻す。
164                SC_Response_Ex::sendRedirect($_POST['url']);
165                exit;
166            }
[20159]167
[15367]168            break;
169        case 'logout':
[20108]170            // --- ログアウト
[20159]171
[20108]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;
[20159]184
[15367]185            break;
[20076]186        default:
187            break;
[15367]188        }
[20159]189
[15367]190    }
191
192    /**
193     * デストラクタ.
194     *
195     * @return void
196     */
197    function destroy() {
198        parent::destroy();
199    }
200
[20076]201    /**
[20970]202     * パラメーター情報の初期化.
[20076]203     *
[20970]204     * @param SC_FormParam $objFormParam パラメーター管理クラス
[20433]205     * @return void
[20076]206     */
207    function lfInitParam(&$objFormParam) {
208        $objFormParam->addParam('記憶する', 'login_memory', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
[20433]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'));
[20076]211    }
[15367]212}
213?>
Note: See TracBrowser for help on using the repository browser.