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

Revision 21804, 10.2 KB checked in by h_yoshimoto, 12 years ago (diff)

#1791 htmlspecialchars処理を追加

  • 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() {
[21596]67
[20076]68        // 会員管理クラス
[20490]69        $objCustomer = new SC_Customer_Ex();
[15367]70        // クッキー管理クラス
[20496]71        $objCookie = new SC_Cookie_Ex(COOKIE_EXPIRE);
[20970]72        // パラメーター管理クラス
[20501]73        $objFormParam = new SC_FormParam_Ex();
[20159]74
[20970]75        // パラメーター情報の初期化
[20433]76        $this->lfInitParam($objFormParam);
[20159]77
[20076]78        // リクエスト値をフォームにセット
[20433]79        $objFormParam->setParam($_POST);
[21804]80       
81        $url = htmlspecialchars($_POST['url']);
[20159]82
[20076]83        // モードによって分岐
84        switch ($this->getMode()) {
[21526]85            case 'login':
86                // --- ログイン
[20159]87
[21526]88                // 入力値のエラーチェック
89                $objFormParam->trimParam();
90                $objFormParam->toLower('login_email');
91                $arrErr = $objFormParam->checkError();
[20159]92
[21526]93                // エラーの場合はエラー画面に遷移
94                if (count($arrErr) > 0) {
95                    if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
96                        echo $this->lfGetErrorMessage(TEMP_LOGIN_ERROR);
[21743]97                        SC_Response_Ex::actionExit();
[21526]98                    } else {
99                        SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR);
[21743]100                        SC_Response_Ex::actionExit();
[21526]101                    }
[21145]102                }
[20159]103
[21526]104                // 入力チェック後の値を取得
105                $arrForm = $objFormParam->getHashArray();
[20159]106
[21526]107                // クッキー保存判定
108                if ($arrForm['login_memory'] == '1' && $arrForm['login_email'] != '') {
109                    $objCookie->setCookie('login_email', $arrForm['login_email']);
[20159]110                } else {
[21526]111                    $objCookie->setCookie('login_email', '');
[20159]112                }
[21804]113               
[21526]114                // 遷移先の制御
115                if (count($arrErr) == 0) {
116                    // ログイン判定
117                    $loginFailFlag = false;
[21441]118                    if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
[21526]119                        // モバイルサイト
[21527]120                        if (!$objCustomer->getCustomerDataFromMobilePhoneIdPass($arrForm['login_pass']) &&
121                            !$objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'], true)
122                        ) {
[21526]123                            $loginFailFlag = true;
124                        }
125                    } else {
126                        // モバイルサイト以外
127                        if (!$objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'])) {
128                            $loginFailFlag = true;
129                        }
130                    }
[20159]131
[21526]132                    // ログイン処理
133                    if ($loginFailFlag == false) {
134                        if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
135                            // ログインが成功した場合は携帯端末IDを保存する。
136                            $objCustomer->updateMobilePhoneId();
137
138                            /*
139                             * email がモバイルドメインでは無く,
140                             * 携帯メールアドレスが登録されていない場合
141                             */
142                            $objMobile = new SC_Helper_Mobile_Ex();
143                            if (!$objMobile->gfIsMobileMailAddress($objCustomer->getValue('email'))) {
144                                if (!$objCustomer->hasValue('email_mobile')) {
[21596]145
[21526]146                                    SC_Response_Ex::sendRedirectFromUrlPath('entry/email_mobile.php');
[21743]147                                    SC_Response_Ex::actionExit();
[21526]148                                }
[20159]149                            }
150                        }
[21596]151
[21526]152                        // --- ログインに成功した場合
[21145]153                        if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
[21804]154                            echo SC_Utils_Ex::jsonEncode(array('success' => $url));
[21145]155                        } else {
[21804]156                            SC_Response_Ex::sendRedirect($url);
157                        }                       
[21743]158                        SC_Response_Ex::actionExit();
[20108]159                    } else {
[21526]160                        // --- ログインに失敗した場合
[21791]161
162                        // ブルートフォースアタック対策
163                        // ログイン失敗時に遅延させる
164                        sleep(LOGIN_RETRY_INTERVAL);
165
[21526]166                        $arrForm['login_email'] = strtolower($arrForm['login_email']);
167                        $objQuery = SC_Query_Ex::getSingletonInstance();
168                        $where = '(email = ? OR email_mobile = ?) AND status = 1 AND del_flg = 0';
169                        $exists = $objQuery->exists('dtb_customer', $where, array($arrForm['login_email'], $arrForm['login_email']));
170                        // ログインエラー表示 TODO リファクタリング
171                        if ($exists) {
172                            if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
173                                echo $this->lfGetErrorMessage(TEMP_LOGIN_ERROR);
[21743]174                                SC_Response_Ex::actionExit();
[21526]175                            } else {
176                                SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR);
[21743]177                                SC_Response_Ex::actionExit();
[21526]178                            }
[21145]179                        } else {
[21526]180                            if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
181                                echo $this->lfGetErrorMessage(SITE_LOGIN_ERROR);
[21743]182                                SC_Response_Ex::actionExit();
[21526]183                            } else {
184                                SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR);
[21743]185                                SC_Response_Ex::actionExit();
[21526]186                            }
[21145]187                        }
[20108]188                    }
[21526]189                } else {
190                    // XXX 到達しない?
191                    // 入力エラーの場合、元のアドレスに戻す。
[21804]192                    SC_Response_Ex::sendRedirect($url);
[21743]193                    SC_Response_Ex::actionExit();
[20108]194                }
[20159]195
[21526]196                break;
197            case 'logout':
198                // --- ログアウト
[20159]199
[21526]200                // ログイン情報の解放
201                $objCustomer->EndSession();
202                // 画面遷移の制御
[21804]203                $mypage_url_search = strpos('.'.$url, 'mypage');
[21526]204                if ($mypage_url_search == 2) {
[21596]205
[21526]206                    // マイページログイン中はログイン画面へ移行
207                    SC_Response_Ex::sendRedirectFromUrlPath('mypage/login.php');
208                } else {
[21596]209
[21526]210                    // 上記以外の場合、トップへ遷移
211                    SC_Response_Ex::sendRedirect(HTTP_URL);
212                }
[21743]213                SC_Response_Ex::actionExit();
[20159]214
[21526]215                break;
216            default:
217                break;
[15367]218        }
[21743]219
[15367]220    }
221
222    /**
223     * デストラクタ.
224     *
225     * @return void
226     */
227    function destroy() {
228        parent::destroy();
229    }
230
[20076]231    /**
[20970]232     * パラメーター情報の初期化.
[20076]233     *
[20970]234     * @param SC_FormParam $objFormParam パラメーター管理クラス
[20433]235     * @return void
[20076]236     */
237    function lfInitParam(&$objFormParam) {
238        $objFormParam->addParam('記憶する', 'login_memory', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
[20433]239        $objFormParam->addParam('メールアドレス', 'login_email', MTEXT_LEN, 'a', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
240        $objFormParam->addParam('パスワード', 'login_pass', PASSWORD_MAX_LEN, '', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
[20076]241    }
[21145]242
243    /**
244     * エラーメッセージを JSON 形式で返す.
245     *
246     * TODO リファクタリング
247     * この関数は主にスマートフォンで使用します.
248     *
249     * @param integer エラーコード
250     * @return string JSON 形式のエラーメッセージ
251     * @see LC_PageError
252     */
253    function lfGetErrorMessage($error) {
254        switch ($error) {
255            case TEMP_LOGIN_ERROR:
256                $msg = "メールアドレスもしくはパスワードが正しくありません。\n本登録がお済みでない場合は、仮登録メールに記載されているURLより本登録を行ってください。";
257                break;
258            case SITE_LOGIN_ERROR:
259            default:
[21514]260                $msg = 'メールアドレスもしくはパスワードが正しくありません。';
[21145]261        }
262        return SC_Utils_Ex::jsonEncode(array('login_error' => $msg));
263    }
[15367]264}
Note: See TracBrowser for help on using the repository browser.