source: branches/version-2_5-dev/data/class/pages/forgot/LC_Page_Forgot.php @ 20116

Revision 20116, 12.1 KB checked in by nanasess, 13 years ago (diff)
  • svn properties を再設定
  • 再設定用のスクリプト追加
  • 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_REALDIR . "pages/LC_Page.php");
26
27/**
28 * パスワード発行 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Forgot extends LC_Page {
35
36    // {{{ properties
37
38    /** フォームパラメータの配列 */
39    var $objFormParam;
40
41    /** 秘密の質問の答え */
42    var $arrReminder;
43
44    /** 変更後パスワード */
45    var $temp_password;
46
47    /** エラーメッセージ */
48    var $errmsg;
49
50    // }}}
51    // {{{ functions
52
53    /**
54     * Page を初期化する.
55     *
56     * @return void
57     */
58    function init() {
59        parent::init();
60        $this->tpl_title = "パスワードを忘れた方";
61        $this->tpl_mainpage = 'forgot/index.tpl';
62        $this->tpl_mainno = '';
63        $masterData = new SC_DB_MasterData_Ex();
64        $this->arrReminder = $masterData->getMasterData("mtb_reminder");
65        $this->device_type = SC_Display::detectDevice();
66        $this->httpCacheControl('nocache');
67        // デフォルトログインアドレスロード
68        $objCookie = new SC_Cookie(COOKIE_EXPIRE);
69        $this->tpl_login_email = $objCookie->getCookie('login_email');       
70    }
71
72    /**
73     * Page のプロセス.
74     *
75     * @return void
76     */
77    function process() {
78        $this->action();
79        $this->sendResponse();
80    }
81
82    /**
83     * Page のアクション.
84     *
85     * @return void
86     */
87    function action() {
88        // 不正アクセスチェック
89        if ($_SERVER["REQUEST_METHOD"] == "POST") {
90            if (!SC_Helper_Session_Ex::isValidToken()) {
91                SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
92            }
93        }
94       
95        // パラメータ管理クラス
96        $objFormParam = new SC_FormParam();
97
98        switch($this->getMode()) {
99            case 'mail_check':
100                $this->lfInitMailCheckParam($objFormParam, $this->device_type);
101                $objFormParam->setParam($_POST);
102                $objFormParam->convParam();
103                $objFormParam->toLower('email');
104                $this->arrForm = $objFormParam->getHashArray();
105                $this->arrErr = $objFormParam->checkError();
106                if (SC_Utils_Ex::isBlank($this->arrErr)) {
107                    $this->errmsg = $this->lfCheckForgotMail($this->arrForm, $this->arrReminder);
108                    if(SC_Utils_Ex::isBlank($this->errmsg)) {
109                        $this->tpl_mainpage = 'forgot/secret.tpl';
110                    }
111                }
112                break;
113            case 'secret_check':
114                $this->lfInitSecretCheckParam($objFormParam, $this->device_type);
115                $objFormParam->setParam($_POST);
116                $objFormParam->convParam();
117                $objFormParam->toLower('email');
118                $this->arrForm = $objFormParam->getHashArray();
119                $this->arrErr = $objFormParam->checkError();
120                if (SC_Utils_Ex::isBlank($this->arrErr)) {
121                    $this->errmsg = $this->lfCheckForgotSecret($this->arrForm, $this->arrReminder);
122                    if(SC_Utils_Ex::isBlank($this->errmsg)) {
123                        // 完了ページへ移動する
124                        $this->tpl_mainpage = 'forgot/complete.tpl';
125                        // transactionidを更新させたいので呼び出し元(ログインフォーム側)をリロード。
126                        $this->tpl_onload .= 'opener.location.reload(true);';
127                    }else{
128                        // 秘密の答えが一致しなかった
129                        $this->tpl_mainpage = 'forgot/secret.tpl';
130                    }
131                }else{
132                    // 入力値エラー
133                    $this->tpl_mainpage = 'forgot/secret.tpl';
134                }
135                break;
136            default:
137                break;
138        }
139
140        $this->transactionid = SC_Helper_Session_Ex::getToken();
141       
142        // ポップアップ用テンプレート設定
143        if($this->device_type == DEVICE_TYPE_PC) {
144            $this->setTemplate($this->tpl_mainpage);
145        }
146    }
147
148    /**
149     * メールアドレス・名前確認
150     *
151     * @param array $arrForm フォーム入力値
152     * @param array $arrReminder リマインダー質問リスト
153     * @return string エラー文字列 問題が無ければNULL
154     */
155    function lfCheckForgotMail(&$arrForm, &$arrReminder) {
156        $errmsg = NULL;
157        $objQuery =& SC_Query::getSingletonInstance();
158        $where = "(email Like ? OR email_mobile Like ?) AND name01 Like ? AND name02 Like ? AND del_flg = 0";
159        $arrVal = array($arrForm['email'], $arrForm['email'], $arrForm['name01'], $arrForm['name02']);
160        $result = $objQuery->select("reminder, status", "dtb_customer", $where, $arrVal);
161        if (isset($result[0]['reminder']) and isset($arrReminder[$result[0]['reminder']])) {
162            // 会員状態の確認
163            if($result[0]['status'] == '2') {
164                // 正会員
165                $arrForm['reminder'] = $result[0]['reminder'];
166            } else if ($result[0]['status'] == '1') {
167                // 仮会員
168                $errmsg = 'ご入力のemailアドレスは現在仮登録中です。<br/>登録の際にお送りしたメールのURLにアクセスし、<br/>本会員登録をお願いします。';
169            }
170        } else {
171            $errmsg = 'お名前に間違いがあるか、このメールアドレスは登録されていません。';
172        }
173        return $errmsg;
174    }
175   
176    /**
177     * メールアドレス確認におけるパラメーター情報の初期化
178     *
179     * @param array $objFormParam フォームパラメータークラス
180     * @param array $device_type デバイスタイプ
181     * @return void
182     */
183    function lfInitMailCheckParam(&$objFormParam, $device_type) {
184        $objFormParam->addParam("お名前(姓)", 'name01', STEXT_LEN, "aKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
185        $objFormParam->addParam("お名前(名)", 'name02', STEXT_LEN, "aKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" , "MAX_LENGTH_CHECK"));
186        if ($device_type === DEVICE_TYPE_MOBILE){
187            $objFormParam->addParam('メールアドレス', "email", MTEXT_LEN, "a", array("EXIST_CHECK", "EMAIL_CHECK", "NO_SPTAB" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK","MOBILE_EMAIL_CHECK"));
188        } else {
189            $objFormParam->addParam('メールアドレス', "email", MTEXT_LEN, "a", array("NO_SPTAB", "EXIST_CHECK", "EMAIL_CHECK", "SPTAB_CHECK" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
190        }
191        return;
192    }
193
194    /**
195     * 秘密の質問確認
196     *
197     * @param array $arrForm フォーム入力値
198     * @param array $arrReminder リマインダー質問リスト
199     * @return string エラー文字列 問題が無ければNULL
200     */
201    function lfCheckForgotSecret(&$arrForm, &$arrReminder) {
202        $errmsg = '';
203        $objQuery =& SC_Query::getSingletonInstance();
204        $cols = "customer_id, reminder, reminder_answer, salt";
205        $table = "dtb_customer";
206        $where = "(email Like ? OR email_mobile Like ?)"
207                    . " AND name01 Like ? AND name02 Like ?"
208                    . " AND status = 2 AND del_flg = 0";
209        $arrVal = array($arrForm['email'], $arrForm['email'],
210                            $arrForm['name01'], $arrForm['name02']);
211        $result = $objQuery->select($cols, $table, $where, $arrVal);
212        if (isset($result[0]['reminder']) and isset($arrReminder[$result[0]['reminder']])
213                and $result[0]['reminder'] == $arrForm['reminder']) {
214           
215            if (SC_Utils_Ex::sfIsMatchHashPassword($arrForm['reminder_answer'],
216                     $result[0]['reminder_answer'], $result[0]['salt'])) {
217                // 秘密の答えが一致
218                // 新しいパスワードを設定する
219                $new_password = GC_Utils_Ex::gfMakePassword(8);
220                if(FORGOT_MAIL == 1) {
221                    // メールで変更通知をする
222                    $objDb = new SC_Helper_DB_Ex();
223                    $CONF = $objDb->sfGetBasisData();
224                    $this->lfSendMail($CONF, $arrForm['email'], $arrForm['name01'], $new_password);
225                }
226                $sqlval = array();
227                $sqlval['password'] = $new_password;
228                SC_Helper_Customer_Ex::sfEditCustomerData($sqlval, $result[0]['customer_id']);
229                $arrForm['new_password'] = $new_password;
230            } else {
231                // 秘密の答えが一致しなかった
232                $errmsg = '秘密の質問が一致しませんでした。';
233            }
234        } else {
235            //不正なアクセス リマインダー値が前画面と異なる。
236            // 新リファクタリング基準ではここで遷移は不許可なのでエラー表示
237            //SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
238            $errmsg = '秘密の質問が一致しませんでした。';
239        }
240        return $errmsg;
241    }
242
243    /**
244     * 秘密の質問確認におけるパラメーター情報の初期化
245     *
246     * @param array $objFormParam フォームパラメータークラス
247     * @param array $device_type デバイスタイプ
248     * @return void
249     */
250    function lfInitSecretCheckParam(&$objFormParam, $device_type) {
251        // メールチェックと同等のチェックを再度行う
252        $this->lfInitMailCheckParam($objFormParam, $device_type);
253        // 秘密の質問チェックの追加
254        $objFormParam->addParam("パスワード確認用の質問", "reminder", STEXT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK"));
255        $objFormParam->addParam("パスワード確認用の質問の答え", "reminder_answer", STEXT_LEN, "aKV", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
256        return;
257    }
258
259    /**
260     * デストラクタ.
261     *
262     * @return void
263     */
264    function destroy() {
265        parent::destroy();
266    }
267
268    /**
269     * パスワード変更お知らせメールを送信する.
270     *
271     * @param array $CONF 店舗基本情報の配列
272     * @param string $email 送信先メールアドレス
273     * @param string $customer_name 送信先氏名
274     * @param string $new_password 変更後の新パスワード
275     * @return void
276     *
277     * FIXME: メールテンプレート編集の方に足すのが望ましい
278     */
279    function lfSendMail(&$CONF, $email, $customer_name, $new_password){
280        // パスワード変更お知らせメール送信
281        $objMailText = new SC_SiteView(false);
282        $objMailText->assign('customer_name', $customer_name);
283        $objMailText->assign('new_password', $new_password);
284        $toCustomerMail = $objMailText->fetch("mail_templates/forgot_mail.tpl");
285        // メール送信オブジェクトによる送信処理
286        $objMail = new SC_SendMail();
287        $objMail->setItem(
288            '' //宛先
289            , $toCustomerMail //本文
290            , $CONF['email03'] //配送元アドレス
291            , $CONF['shop_name'] // 配送元名
292            , $CONF['email03'] // reply to
293            , $CONF['email04'] //return_path
294            , $CONF['email04'] // errors_to
295            );
296        $objMail->setTo($email, $customer_name ." 様");
297        $objMail->sendMail();
298        return;
299    }
300
301}
302?>
Note: See TracBrowser for help on using the repository browser.