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

Revision 21402, 9.3 KB checked in by Seasoft, 12 years ago (diff)

2.12系へマイルストーン変更となったチケット分を差し戻し
r21376 #1582,#1526,#1449 作業を簡単にするため、本来対象外のチケット(#1526,#1449)も含めた
r21375 #1581
r21374 #797
r21373 #1583,#1526 作業を簡単にするため、本来対象外のチケット(#1526)も含めた
r21372 #1576
r21371 #1581

  • 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                if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
93                    echo $this->lfGetErrorMessage(TEMP_LOGIN_ERROR);
94                    exit;
95                } else {
96                    SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR);
97                    exit;
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                $loginFailFlag = false;
115                if(SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
116                    // モバイルサイト
117                    if(!$objCustomer->getCustomerDataFromMobilePhoneIdPass($arrForm['login_pass']) &&
118                       !$objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'], true)) {
119                        $loginFailFlag = true;
120                    }
121                } else {
122                    // モバイルサイト以外
123                    if(!$objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'])) {
124                        $loginFailFlag = true;
125                    }
126                }
127
128                // ログイン処理
129                if ($loginFailFlag == false) {
130                    if(SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
131                        // ログインが成功した場合は携帯端末IDを保存する。
132                        $objCustomer->updateMobilePhoneId();
133
134                        /*
135                         * email がモバイルドメインでは無く,
136                         * 携帯メールアドレスが登録されていない場合
137                         */
138                        $objMobile = new SC_Helper_Mobile_Ex();
139                        if (!$objMobile->gfIsMobileMailAddress($objCustomer->getValue('email'))) {
140                            if (!$objCustomer->hasValue('email_mobile')) {
141                                SC_Response_Ex::sendRedirectFromUrlPath('entry/email_mobile.php');
142                                exit;
143                            }
144                        }
145                    }
146
147                    // --- ログインに成功した場合
148                    if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
149                        echo SC_Utils_Ex::jsonEncode(array('success' => $_POST['url']));
150                    } else {
151                        SC_Response_Ex::sendRedirect($_POST['url']);
152                    }
153                    exit;
154                } else {
155                    // --- ログインに失敗した場合
156                    $arrForm['login_email'] = strtolower($arrForm['login_email']);
157                    $objQuery = SC_Query_Ex::getSingletonInstance();
158                    $where = '(email = ? OR email_mobile = ?) AND status = 1 AND del_flg = 0';
159                    $ret = $objQuery->count("dtb_customer", $where, array($arrForm['login_email'], $arrForm['login_email']));
160                    // ログインエラー表示 TODO リファクタリング
161                    if($ret > 0) {
162                        if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
163                            echo $this->lfGetErrorMessage(TEMP_LOGIN_ERROR);
164                            exit;
165                        } else {
166                            SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR);
167                            exit;
168                        }
169                    } else {
170                        if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
171                            echo $this->lfGetErrorMessage(SITE_LOGIN_ERROR);
172                            exit;
173                        } else {
174                            SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR);
175                            exit;
176                        }
177                    }
178                }
179            } else {
180                // XXX 到達しない?
181                // 入力エラーの場合、元のアドレスに戻す。
182                SC_Response_Ex::sendRedirect($_POST['url']);
183                exit;
184            }
185
186            break;
187        case 'logout':
188            // --- ログアウト
189
190            // ログイン情報の解放
191            $objCustomer->EndSession();
192            // 画面遷移の制御
193            $mypage_url_search = strpos('.'.$_POST['url'], 'mypage');
194            if ($mypage_url_search == 2) {
195                // マイページログイン中はログイン画面へ移行
196                SC_Response_Ex::sendRedirectFromUrlPath('mypage/login.php');
197            } else {
198                // 上記以外の場合、トップへ遷移
199                SC_Response_Ex::sendRedirect(HTTP_URL);
200            }
201            exit;
202
203            break;
204        default:
205            break;
206        }
207
208    }
209
210    /**
211     * デストラクタ.
212     *
213     * @return void
214     */
215    function destroy() {
216        parent::destroy();
217    }
218
219    /**
220     * パラメーター情報の初期化.
221     *
222     * @param SC_FormParam $objFormParam パラメーター管理クラス
223     * @return void
224     */
225    function lfInitParam(&$objFormParam) {
226        $objFormParam->addParam('記憶する', 'login_memory', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
227        $objFormParam->addParam('メールアドレス', 'login_email', MTEXT_LEN, 'a', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
228        $objFormParam->addParam('パスワード', 'login_pass', PASSWORD_MAX_LEN, '', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
229    }
230
231    /**
232     * エラーメッセージを JSON 形式で返す.
233     *
234     * TODO リファクタリング
235     * この関数は主にスマートフォンで使用します.
236     *
237     * @param integer エラーコード
238     * @return string JSON 形式のエラーメッセージ
239     * @see LC_PageError
240     */
241    function lfGetErrorMessage($error) {
242        switch ($error) {
243            case TEMP_LOGIN_ERROR:
244                $msg = "メールアドレスもしくはパスワードが正しくありません。\n本登録がお済みでない場合は、仮登録メールに記載されているURLより本登録を行ってください。";
245                break;
246            case SITE_LOGIN_ERROR:
247            default:
248                $msg = "メールアドレスもしくはパスワードが正しくありません。";
249        }
250        return SC_Utils_Ex::jsonEncode(array('login_error' => $msg));
251    }
252}
253?>
Note: See TracBrowser for help on using the repository browser.