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

Revision 20496, 7.4 KB checked in by shutta, 13 years ago (diff)

SC_Cookieクラスのclass_extends対応

  • 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-2010 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();
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                    SC_Response_Ex::sendRedirect($_POST['url']);
143                    exit;
144                } else {
145                    // --- ログインに失敗した場合
146                    $arrForm['login_email'] = strtolower($arrForm['login_email']);
147                    $objQuery = SC_Query::getSingletonInstance();
148                    $where = '(email = ? OR email_mobile = ?) AND status = 1 AND del_flg = 0';
149                    $ret = $objQuery->count("dtb_customer", $where, array($arrForm['login_email'], $arrForm['login_email']));
150                    // ログインエラー表示
151                    if($ret > 0) {
152                        SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR);
153                    } else {
154                        SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR);
155                    }
156                }
157            } else {
158                // 入力エラーの場合、元のアドレスに戻す。
159                // FIXME $_POST['url'] には、URL ではなく、url-path が渡るもよう。HTTPS 利用に関わる問題も考えられるので、URL が渡るように改善した方が良いように感じる。
160                SC_Response_Ex::sendRedirect($_POST['url']);
161                exit;
162            }
163
164            break;
165        case 'logout':
166            // --- ログアウト
167
168            // ログイン情報の解放
169            $objCustomer->EndSession();
170            // 画面遷移の制御
171            $mypage_url_search = strpos('.'.$_POST['url'], 'mypage');
172            if ($mypage_url_search == 2) {
173                // マイページログイン中はログイン画面へ移行
174                SC_Response_Ex::sendRedirectFromUrlPath('mypage/login.php');
175            } else {
176                // 上記以外の場合、トップへ遷移
177                SC_Response_Ex::sendRedirect(HTTP_URL);
178            }
179            exit;
180
181            break;
182        default:
183            break;
184        }
185
186    }
187
188    /**
189     * デストラクタ.
190     *
191     * @return void
192     */
193    function destroy() {
194        parent::destroy();
195    }
196
197    /**
198     * パラメータ情報の初期化.
199     *
200     * @param SC_FormParam $objFormParam パラメータ管理クラス
201     * @return void
202     */
203    function lfInitParam(&$objFormParam) {
204        $objFormParam->addParam('記憶する', 'login_memory', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
205        $objFormParam->addParam('メールアドレス', 'login_email', MTEXT_LEN, 'a', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
206        $objFormParam->addParam('パスワード', 'login_pass', PASSWORD_MAX_LEN, '', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
207    }
208}
209?>
Note: See TracBrowser for help on using the repository browser.