source: branches/feature-module-update/data/class/pages/forgot/LC_Page_Forgot.php @ 15532

Revision 15532, 6.8 KB checked in by nanasess, 17 years ago (diff)

svn:mime-type 修正

  • 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 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8// {{{ requires
9require_once(CLASS_PATH . "pages/LC_Page.php");
10
11/**
12 * パスワード発行 のページクラス.
13 *
14 * @package Page
15 * @author LOCKON CO.,LTD.
16 * @version $Id$
17 */
18class LC_Page_Forgot extends LC_Page {
19
20    // {{{ properties
21
22    /** エラーメッセージ */
23    var $errmsg;
24
25    /** 秘密の質問の答え */
26    var $arrReminder;
27
28    /** 変更後パスワード */
29    var $temp_password;
30
31    // }}}
32    // {{{ functions
33
34    /**
35     * Page を初期化する.
36     *
37     * @return void
38     */
39    function init() {
40        parent::init();
41        $this->tpl_mainpage = 'forgot/index.tpl';
42        $this->tpl_mainno = '';
43    }
44
45    /**
46     * Page のプロセス.
47     *
48     * @return void
49     */
50    function process() {
51        $conn = new SC_DBConn();
52        $objView = new SC_SiteView();
53        $objSess = new SC_Session();
54
55        // 店舗基本情報を取得
56        $objDb = new SC_Helper_DB_Ex();
57        $CONF = $objb->sf_getBasisData();
58
59        // クッキー管理クラス
60        $objCookie = new SC_Cookie(COOKIE_EXPIRE);
61
62        if ( $_POST['mode'] == 'mail_check' ){
63            //メアド入力時
64            $_POST['email'] = strtolower($_POST['email']);
65            $sql = "SELECT * FROM dtb_customer WHERE email ILIKE ? AND status = 2 AND del_flg = 0";
66            $result = $conn->getAll($sql, array($_POST['email']) );
67
68            if ( $result[0]['reminder'] ){      // 本会員登録済みの場合
69                // 入力emailが存在する
70                $_SESSION['forgot']['email'] = $_POST['email'];
71                $_SESSION['forgot']['reminder'] = $result[0]['reminder'];
72                // ヒミツの答え入力画面
73                $this->Reminder = $arrReminder[$_SESSION['forgot']['reminder']];
74                $this->tpl_mainpage = 'forgot/secret.tpl';
75            } else {
76                $sql = "SELECT customer_id FROM dtb_customer WHERE email ILIKE ? AND status = 1 AND del_flg = 0";   //仮登録中の確認
77                $result = $conn->getAll($sql, array($_POST['email']) );
78                if ($result) {
79                    $this->errmsg = "ご入力のemailアドレスは現在仮登録中です。<br>登録の際にお送りしたメールのURLにアクセスし、<br>本会員登録をお願いします。";
80                } else {        // 登録していない場合
81                    $this->errmsg = "ご入力のemailアドレスは登録されていません";
82                }
83            }
84
85        } elseif( $_POST['mode'] == 'secret_check' ){
86            //ヒミツの答え入力時
87
88            if ( $_SESSION['forgot']['email'] ) {
89                // ヒミツの答えの回答が正しいかチェック
90
91                $sql = "SELECT * FROM dtb_customer WHERE email ILIKE ? AND del_flg = 0";
92                $result = $conn->getAll($sql, array($_SESSION['forgot']['email']) );
93                $data = $result[0];
94
95                if ( $data['reminder_answer'] === $_POST['input_reminder'] ){
96                    // ヒミツの答えが正しい
97
98                    // 新しいパスワードを設定する
99                    $this->temp_password = gfMakePassword(8);
100
101                    if(FORGOT_MAIL == 1) {
102                        // メールで変更通知をする
103                        $this->lfSendMail($CONF, $_SESSION['forgot']['email'], $data['name01'], $this->temp_password);
104                    }
105
106                    // DBを書き換える
107                    $sql = "UPDATE dtb_customer SET password = ?, update_date = now() WHERE customer_id = ?";
108                    $conn->query( $sql, array( sha1($this->temp_password . ":" . AUTH_MAGIC) ,$data['customer_id']) );
109
110                    // 完了画面の表示
111                    $this->tpl_mainpage = 'forgot/complete.tpl';
112
113                    // セッション変数の解放
114                    $_SESSION['forgot'] = array();
115                    unset($_SESSION['forgot']);
116
117                } else {
118                    // ヒミツの答えが正しくない
119
120                    $this->Reminder = $arrReminder[$_SESSION['forgot']['reminder']];
121                    $this->errmsg = "パスワードを忘れたときの質問に対する回答が正しくありません";
122                    $this->tpl_mainpage = 'forgot/secret.tpl';
123
124                }
125
126
127            } else {
128                // アクセス元が不正または、セッション保持期間が切れている
129                $this->errmsg = "emailアドレスを再度登録してください。<br />前回の入力から時間が経っていますと、本メッセージが表示される可能性があります。";
130            }
131        }
132
133        // デフォルト入力
134        if($_POST['email'] != "") {
135            // POST値を入力
136            $this->tpl_login_email = $_POST['email'];
137        } else {
138            // クッキー値を入力
139            $this->tpl_login_email = $objCookie->getCookie('login_email');
140        }
141
142        //---- ページ表示
143        $objView->assignobj($this);
144        $objView->display($this->tpl_mainpage);
145    }
146
147    /**
148     * デストラクタ.
149     *
150     * @return void
151     */
152    function destroy() {
153        parent::destroy();
154    }
155
156    /**
157     * パスワード変更お知らせメールを送信する.
158     *
159     * @param array $CONF 店舗基本情報の配列
160     * @param string $email 送信先メールアドレス
161     * @param string $customer_name 送信先氏名
162     * @param string $temp_password 変更後のパスワード
163     * @return void
164     */
165    function lfSendMail($CONF, $email, $customer_name, $temp_password){
166        // パスワード変更お知らせメール送信
167
168        $objPage = new LC_Page();
169        $objPage->customer_name = $customer_name;
170        $objPage->temp_password = $temp_password;
171        $objMailText = new SC_SiteView();
172        $objMailText->assignobj($objPage);
173
174        $toCustomerMail = $objMailText->fetch("mail_templates/forgot_mail.tpl");
175        $objMail = new GC_SendMail();
176
177        $objMail->setItem(
178                              ''                                // 宛先
179                            , "パスワードが変更されました" ."【" .$CONF["shop_name"]. "】"     // サブジェクト
180                            , $toCustomerMail                   // 本文
181                            , $CONF["email03"]                  // 配送元アドレス
182                            , $CONF["shop_name"]                // 配送元 名前
183                            , $CONF["email03"]                  // reply_to
184                            , $CONF["email04"]                  // return_path
185                            , $CONF["email04"]                  //  Errors_to
186
187                                                            );
188        $objMail->setTo($email, $customer_name ." 様");
189        $objMail->sendMail();
190    }
191}
192?>
Note: See TracBrowser for help on using the repository browser.