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