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

Revision 19788, 8.7 KB checked in by nanasess, 13 years ago (diff)

#881(冗長な tpl_mainpage の削除)

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