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

Revision 19787, 8.8 KB checked in by fukuran, 13 years ago (diff)

#880(mobile/sphoneディレクトリを削除)に対応する、
影響の少ない部分を先行してコミット

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • 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_PATH . "pages/LC_Page.php");
26
27/**
28 * パスワード発行 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id:LC_Page_Forgot.php 15532 2007-08-31 14:39:46Z nanasess $
33 */
34class LC_Page_Forgot extends LC_Page {
35
36    // {{{ properties
37
38    /** エラーメッセージ */
39    var $errmsg;
40
41    /** 秘密の質問の答え */
42    var $arrReminder;
43
44    /** 変更後パスワード */
45    var $temp_password;
46
47    // }}}
48    // {{{ functions
49
50    /**
51     * Page を初期化する.
52     *
53     * @return void
54     */
55    function init() {
56        parent::init();
57        $this->tpl_mainpage = 'forgot/index.tpl';
58        $this->tpl_mainno = '';
59    }
60
61    /**
62     * Page のプロセス.
63     *
64     * @return void
65     */
66    function process() {
67        $this->action();
68        $this->sendResponse();
69    }
70
71    /**
72     * Page のアクション.
73     *
74     * @return void
75     */
76    function action() {
77        $objQuery = new SC_Query();
78        $objSess = new SC_Session();
79
80        // 店舗基本情報を取得
81        $objDb = new SC_Helper_DB_Ex();
82        $CONF = $objDb->sfGetBasisData();
83
84        $masterData = new SC_DB_MasterData_Ex();
85        $arrReminder = $masterData->getMasterData("mtb_reminder");
86
87        // クッキー管理クラス
88        $objCookie = new SC_Cookie(COOKIE_EXPIRE);
89
90        if (!isset($_POST['mode'])) $_POST['mode'] = "";
91        if (!isset($_POST['email'])) $_POST['email'] = "";
92
93        if ( $_POST['mode'] == 'mail_check' ){
94            //メアド入力時
95            $_POST['email'] = strtolower($_POST['email']);
96            // FIXME DBチェックの前に妥当性チェックするべき
97            $sql = "SELECT * FROM dtb_customer WHERE (email = ? OR email_mobile = ?) AND status = 2 AND del_flg = 0";
98            $result = $objQuery->getAll($sql, array($_POST['email'], $_POST['email']) );
99
100            // 本会員登録済みの場合
101            if (isset($result[0]['reminder']) &&  $result[0]['reminder']){
102                // 入力emailが存在する
103                $_SESSION['forgot']['email'] = $_POST['email'];
104                $_SESSION['forgot']['reminder'] = $result[0]['reminder'];
105                // ヒミツの答え入力画面
106                $this->Reminder = $arrReminder[$_SESSION['forgot']['reminder']];
107                $this->tpl_mainpage = 'forgot/secret.tpl';
108            } else {
109                $sql = "SELECT customer_id FROM dtb_customer WHERE (email = ? OR email_mobile = ?) AND status = 1 AND del_flg = 0"; //仮登録中の確認
110                $result = $objQuery->getAll($sql, array($_POST['email'], $_POST['email']) );
111                if ($result) {
112                    $this->errmsg = "ご入力のemailアドレスは現在仮登録中です。<br>登録の際にお送りしたメールのURLにアクセスし、<br>本会員登録をお願いします。";
113                } else {        // 登録していない場合
114                    $this->errmsg = "ご入力のemailアドレスは登録されていません";
115                }
116            }
117
118        } elseif( $_POST['mode'] == 'secret_check' ){
119            //ヒミツの答え入力時
120
121            if ( $_SESSION['forgot']['email'] ) {
122                // ヒミツの答えの回答が正しいかチェック
123
124                $sql = "SELECT * FROM dtb_customer WHERE (email = ? OR email_mobile = ?) AND del_flg = 0";
125                $result = $objQuery->getAll($sql, array($_SESSION['forgot']['email'], $_SESSION['forgot']['email']));
126                $data = $result[0];
127
128                if ( $data['reminder_answer'] === $_POST['input_reminder'] ){
129                    // ヒミツの答えが正しい
130
131                    // 新しいパスワードを設定する
132                    $this->temp_password = GC_Utils_Ex::gfMakePassword(8);
133
134                    if(FORGOT_MAIL == 1) {
135                        // メールで変更通知をする
136                        $this->lfSendMail($CONF, $_SESSION['forgot']['email'], $data['name01'], $this->temp_password);
137                    }
138
139                    // DBを書き換える
140                    $sql = "UPDATE dtb_customer SET password = ?, update_date = now() WHERE customer_id = ?";
141                    $objQuery->query( $sql, array( sha1($this->temp_password . ":" . AUTH_MAGIC) ,$data['customer_id']) );
142
143                    // 完了画面の表示
144                    $this->tpl_mainpage = 'forgot/complete.tpl';
145
146                    // セッション変数の解放
147                    $_SESSION['forgot'] = array();
148                    unset($_SESSION['forgot']);
149
150                } else {
151                    // ヒミツの答えが正しくない
152
153                    $this->Reminder = $arrReminder[$_SESSION['forgot']['reminder']];
154                    $this->errmsg = "パスワードを忘れたときの質問に対する回答が正しくありません";
155                    $this->tpl_mainpage = 'forgot/secret.tpl';
156
157                }
158
159
160            } else {
161                // アクセス元が不正または、セッション保持期間が切れている
162                $this->errmsg = "emailアドレスを再度登録してください。<br />前回の入力から時間が経っていますと、本メッセージが表示される可能性があります。";
163            }
164        }
165
166        // デフォルト入力
167        if($_POST['email'] != "") {
168            // POST値を入力
169            $this->tpl_login_email = $_POST['email'];
170        } else {
171            // クッキー値を入力
172            $this->tpl_login_email = $objCookie->getCookie('login_email');
173        }
174
175        // モバイルサイトの場合はトークン生成
176        if (defined("MOBILE_SITE") && MOBILE_SITE) {
177            $this->createMobileToken();
178        }
179    }
180
181    /**
182     * デストラクタ.
183     *
184     * @return void
185     */
186    function destroy() {
187        parent::destroy();
188    }
189
190    /**
191     * パスワード変更お知らせメールを送信する.
192     *
193     * @param array $CONF 店舗基本情報の配列
194     * @param string $email 送信先メールアドレス
195     * @param string $customer_name 送信先氏名
196     * @param string $temp_password 変更後のパスワード
197     * @return void
198     */
199    function lfSendMail($CONF, $email, $customer_name, $temp_password){
200        // パスワード変更お知らせメール送信
201        $this->customer_name = $customer_name;
202        $this->temp_password = $temp_password;
203        $objMailText = new SC_SiteView(false);
204        $objMailText->assignobj($this);
205
206        $toCustomerMail = $objMailText->fetch("mail_templates/forgot_mail.tpl");
207        $objMail = new SC_SendMail();
208
209        $objMail->setItem(
210                              ''                                // 宛先
211                            , "パスワードが変更されました" ."【" .$CONF["shop_name"]. "】"     // サブジェクト
212                            , $toCustomerMail                   // 本文
213                            , $CONF["email03"]                  // 配送元アドレス
214                            , $CONF["shop_name"]                // 配送元 名前
215                            , $CONF["email03"]                  // reply_to
216                            , $CONF["email04"]                  // return_path
217                            , $CONF["email04"]                  //  Errors_to
218
219                                                            );
220        $objMail->setTo($email, $customer_name ." 様");
221        $objMail->sendMail();
222    }
223
224    /**
225     * モバイル空メール用のトークン作成
226     *
227     * @return void
228     */
229    function createMobileToken() {
230        $objMobile = new SC_Helper_Mobile_Ex();
231        // 空メール用のトークンを作成。
232        if (MOBILE_USE_KARA_MAIL) {
233            $token = $objMobile->gfPrepareKaraMail('forgot/' . DIR_INDEX_URL);
234            if ($token !== false) {
235                $objPage->tpl_kara_mail_to = MOBILE_KARA_MAIL_ADDRESS_USER . MOBILE_KARA_MAIL_ADDRESS_DELIMITER . 'forgot_' . $token . '@' . MOBILE_KARA_MAIL_ADDRESS_DOMAIN;
236    }
237}
238    }
239}
240?>
Note: See TracBrowser for help on using the repository browser.