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

Revision 20344, 8.5 KB checked in by shutta, 13 years ago (diff)

LC_Pageクラスの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();
69        // クッキー管理クラス
70        $objCookie = new SC_Cookie(COOKIE_EXPIRE);
71        // パラメータ管理クラス
72        $this->objFormParam = new SC_FormParam();
73
74        // パラメータ情報の初期化
75        $this->lfInitParam($this->objFormParam);
76
77        // リクエスト値をフォームにセット
78        $this->objFormParam->setParam($this->lfConvertParam($_POST));
79
80        // モードによって分岐
81        switch ($this->getMode()) {
82        case 'login':
83            // --- ログイン
84
85            // 入力値のエラーチェック
86            $this->objFormParam->toLower('login_email');
87            $arrErr = $this->objFormParam->checkError();
88
89            // エラーの場合はエラー画面に遷移
90            if (count($arrErr) > 0) {
91                SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR);
92            }
93
94            // 入力チェック後の値を取得
95            $arrForm = $this->objFormParam->getHashArray();
96
97            // クッキー保存判定
98            if ($arrForm['login_memory'] == '1' && $arrForm['login_email'] != '') {
99                $objCookie->setCookie('login_email', $arrForm['login_email']);
100            } else {
101                $objCookie->setCookie('login_email', '');
102            }
103
104            // 遷移先の制御
105            if (count($arrErr) == 0) {
106                // ログイン判定
107                $loginFailFlag = false;
108                if(SC_Display::detectDevice() === DEVICE_TYPE_MOBILE) {
109                    // モバイルサイト
110                    if(!$objCustomer->getCustomerDataFromMobilePhoneIdPass($arrForm['login_pass']) &&
111                       !$objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'], true)) {
112                        $loginFailFlag = true;
113                    }
114                } else {
115                    // モバイルサイト以外
116                    if(!$objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'])) {
117                        $loginFailFlag = true;
118                    }
119                }
120
121                // ログイン処理
122                if ($loginFailFlag == false) {
123                    if(SC_Display::detectDevice() === DEVICE_TYPE_MOBILE) {
124                        // ログインが成功した場合は携帯端末IDを保存する。
125                        $objCustomer->updateMobilePhoneId();
126
127                        /*
128                         * email がモバイルドメインでは無く,
129                         * 携帯メールアドレスが登録されていない場合
130                         */
131                        $objMobile = new SC_Helper_Mobile_Ex();
132                        if (!$objMobile->gfIsMobileMailAddress($objCustomer->getValue('email'))) {
133                            if (!$objCustomer->hasValue('email_mobile')) {
134                                SC_Response_Ex::sendRedirectFromUrlPath('entry/email_mobile.php');
135                                exit;
136                            }
137                        }
138                    }
139
140                    // --- ログインに成功した場合
141                    SC_Response_Ex::sendRedirect($_POST['url']);
142                    exit;
143                } else {
144                    // --- ログインに失敗した場合
145                    $arrForm['login_email'] = strtolower($arrForm['login_email']);
146                    $objQuery = SC_Query::getSingletonInstance();
147                    $where = '(email = ? OR email_mobile = ?) AND status = 1 AND del_flg = 0';
148                    $ret = $objQuery->count("dtb_customer", $where, array($arrForm['login_email'], $arrForm['login_email']));
149                    // ログインエラー表示
150                    if($ret > 0) {
151                        SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR);
152                    } else {
153                        SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR);
154                    }
155                }
156            } else {
157                // 入力エラーの場合、元のアドレスに戻す。
158                // FIXME $_POST['url'] には、URL ではなく、url-path が渡るもよう。HTTPS 利用に関わる問題も考えられるので、URL が渡るように改善した方が良いように感じる。
159                SC_Response_Ex::sendRedirect($_POST['url']);
160                exit;
161            }
162
163            break;
164        case 'logout':
165            // --- ログアウト
166
167            // ログイン情報の解放
168            $objCustomer->EndSession();
169            // 画面遷移の制御
170            $mypage_url_search = strpos('.'.$_POST['url'], 'mypage');
171            if ($mypage_url_search == 2) {
172                // マイページログイン中はログイン画面へ移行
173                SC_Response_Ex::sendRedirectFromUrlPath('mypage/login.php');
174            } else {
175                // 上記以外の場合、トップへ遷移
176                SC_Response_Ex::sendRedirect(HTTP_URL);
177            }
178            exit;
179
180            break;
181        default:
182            break;
183        }
184
185    }
186
187    /**
188     * デストラクタ.
189     *
190     * @return void
191     */
192    function destroy() {
193        parent::destroy();
194    }
195
196    /**
197     * パラメータ情報の初期化.
198     *
199     * @param SC_FormParam $objFormParam パラメータ管理クラス
200     * @return SC_FormParam $objFormParam 初期化したパラメータ管理クラスを返す
201     */
202    function lfInitParam(&$objFormParam) {
203        $objFormParam->addParam('記憶する', 'login_memory', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
204        $objFormParam->addParam('メールアドレス', 'login_email', MTEXT_LEN, 'a', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NO_SPTAB' ,'EMAIL_CHAR_CHECK'));
205        $objFormParam->addParam('パスワード', 'login_pass', PASSWORD_LEN1, '', array('EXIST_CHECK'));
206        $objFormParam->addParam('パスワード', 'login_pass1', PASSWORD_LEN1, '', array('EXIST_CHECK', 'MIN_LENGTH_CHECK'));
207        $objFormParam->addParam('パスワード', 'login_pass2', PASSWORD_LEN2, '', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
208        return $objFormParam;
209    }
210
211    /**
212     * リクエスト値の整形.
213     *
214     * @param array $arrRequest リクエスト
215     * @return array $arrRequest 整形したリクエストを返す
216     */
217    function lfConvertParam($arrRequest) {
218        // パスワード・Eメールにある空白をトリム
219        $arrRequest['login_email'] = preg_replace('/^[  \r\n]*(.*?)[  \r\n]*$/u', '$1', $arrRequest['login_email']);
220        $arrRequest['login_pass'] = trim($arrRequest['login_pass']); //認証用
221        $arrRequest['login_pass1'] = $arrRequest['login_pass'];      //最小桁数比較用
222        $arrRequest['login_pass2'] = $arrRequest['login_pass'];      //最大桁数比較用
223        return $arrRequest;
224    }
225
226}
227?>
Note: See TracBrowser for help on using the repository browser.