source: branches/comu-utf8/html/forgot/index.php @ 15099

Revision 15099, 4.8 KB checked in by Yammy, 17 years ago (diff)

UTF-8変換済みファイルインポート
1.3.4ベース

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