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

Revision 19961, 9.0 KB checked in by kotani, 13 years ago (diff)

#748 モバイル/スマートフォンのデザイン管理機能:モバイルデザイン対応

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