[15278] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[18701] | 5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
[15278] | 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
[16582] | 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. |
---|
[15278] | 22 | */ |
---|
| 23 | |
---|
| 24 | // {{{ requires |
---|
[20344] | 25 | require_once(CLASS_EX_REALDIR . "page_extends/LC_Page_Ex.php"); |
---|
[15278] | 26 | |
---|
| 27 | /** |
---|
| 28 | * パスワード発行 のページクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
[19961] | 32 | * @version $Id$ |
---|
[15278] | 33 | */ |
---|
[20344] | 34 | class LC_Page_Forgot extends LC_Page_Ex { |
---|
[15278] | 35 | |
---|
| 36 | // {{{ properties |
---|
| 37 | |
---|
[19995] | 38 | /** フォームパラメータの配列 */ |
---|
| 39 | var $objFormParam; |
---|
[20041] | 40 | |
---|
[15278] | 41 | /** 秘密の質問の答え */ |
---|
| 42 | var $arrReminder; |
---|
| 43 | |
---|
| 44 | /** 変更後パスワード */ |
---|
| 45 | var $temp_password; |
---|
[20041] | 46 | |
---|
[19995] | 47 | /** エラーメッセージ */ |
---|
| 48 | var $errmsg; |
---|
[15278] | 49 | |
---|
| 50 | // }}} |
---|
| 51 | // {{{ functions |
---|
| 52 | |
---|
| 53 | /** |
---|
| 54 | * Page を初期化する. |
---|
| 55 | * |
---|
| 56 | * @return void |
---|
| 57 | */ |
---|
| 58 | function init() { |
---|
| 59 | parent::init(); |
---|
[19961] | 60 | $this->tpl_title = "パスワードを忘れた方"; |
---|
[19824] | 61 | $this->tpl_mainpage = 'forgot/index.tpl'; |
---|
[15278] | 62 | $this->tpl_mainno = ''; |
---|
[19995] | 63 | $masterData = new SC_DB_MasterData_Ex(); |
---|
| 64 | $this->arrReminder = $masterData->getMasterData("mtb_reminder"); |
---|
[20484] | 65 | $this->device_type = SC_Display_Ex::detectDevice(); |
---|
[19995] | 66 | $this->httpCacheControl('nocache'); |
---|
[20104] | 67 | // デフォルトログインアドレスロード |
---|
| 68 | $objCookie = new SC_Cookie(COOKIE_EXPIRE); |
---|
| 69 | $this->tpl_login_email = $objCookie->getCookie('login_email'); |
---|
[15278] | 70 | } |
---|
| 71 | |
---|
| 72 | /** |
---|
| 73 | * Page のプロセス. |
---|
| 74 | * |
---|
| 75 | * @return void |
---|
| 76 | */ |
---|
| 77 | function process() { |
---|
[19661] | 78 | $this->action(); |
---|
| 79 | $this->sendResponse(); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | /** |
---|
| 83 | * Page のアクション. |
---|
| 84 | * |
---|
| 85 | * @return void |
---|
| 86 | */ |
---|
| 87 | function action() { |
---|
[20104] | 88 | // パラメータ管理クラス |
---|
| 89 | $objFormParam = new SC_FormParam(); |
---|
| 90 | |
---|
[20041] | 91 | switch($this->getMode()) { |
---|
[19995] | 92 | case 'mail_check': |
---|
[20104] | 93 | $this->lfInitMailCheckParam($objFormParam, $this->device_type); |
---|
| 94 | $objFormParam->setParam($_POST); |
---|
| 95 | $objFormParam->convParam(); |
---|
| 96 | $objFormParam->toLower('email'); |
---|
| 97 | $this->arrForm = $objFormParam->getHashArray(); |
---|
| 98 | $this->arrErr = $objFormParam->checkError(); |
---|
| 99 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
| 100 | $this->errmsg = $this->lfCheckForgotMail($this->arrForm, $this->arrReminder); |
---|
| 101 | if(SC_Utils_Ex::isBlank($this->errmsg)) { |
---|
| 102 | $this->tpl_mainpage = 'forgot/secret.tpl'; |
---|
| 103 | } |
---|
| 104 | } |
---|
[19995] | 105 | break; |
---|
| 106 | case 'secret_check': |
---|
[20104] | 107 | $this->lfInitSecretCheckParam($objFormParam, $this->device_type); |
---|
| 108 | $objFormParam->setParam($_POST); |
---|
| 109 | $objFormParam->convParam(); |
---|
| 110 | $objFormParam->toLower('email'); |
---|
| 111 | $this->arrForm = $objFormParam->getHashArray(); |
---|
| 112 | $this->arrErr = $objFormParam->checkError(); |
---|
| 113 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
| 114 | $this->errmsg = $this->lfCheckForgotSecret($this->arrForm, $this->arrReminder); |
---|
| 115 | if(SC_Utils_Ex::isBlank($this->errmsg)) { |
---|
| 116 | // 完了ページへ移動する |
---|
| 117 | $this->tpl_mainpage = 'forgot/complete.tpl'; |
---|
| 118 | // transactionidを更新させたいので呼び出し元(ログインフォーム側)をリロード。 |
---|
| 119 | $this->tpl_onload .= 'opener.location.reload(true);'; |
---|
| 120 | }else{ |
---|
| 121 | // 秘密の答えが一致しなかった |
---|
| 122 | $this->tpl_mainpage = 'forgot/secret.tpl'; |
---|
| 123 | } |
---|
| 124 | }else{ |
---|
| 125 | // 入力値エラー |
---|
| 126 | $this->tpl_mainpage = 'forgot/secret.tpl'; |
---|
| 127 | } |
---|
[19995] | 128 | break; |
---|
| 129 | default: |
---|
| 130 | break; |
---|
| 131 | } |
---|
[15278] | 132 | |
---|
[20104] | 133 | // ポップアップ用テンプレート設定 |
---|
| 134 | if($this->device_type == DEVICE_TYPE_PC) { |
---|
[19995] | 135 | $this->setTemplate($this->tpl_mainpage); |
---|
| 136 | } |
---|
| 137 | } |
---|
[20041] | 138 | |
---|
[20104] | 139 | /** |
---|
| 140 | * メールアドレス・名前確認 |
---|
| 141 | * |
---|
| 142 | * @param array $arrForm フォーム入力値 |
---|
| 143 | * @param array $arrReminder リマインダー質問リスト |
---|
| 144 | * @return string エラー文字列 問題が無ければNULL |
---|
| 145 | */ |
---|
| 146 | function lfCheckForgotMail(&$arrForm, &$arrReminder) { |
---|
| 147 | $errmsg = NULL; |
---|
| 148 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
| 149 | $where = "(email Like ? OR email_mobile Like ?) AND name01 Like ? AND name02 Like ? AND del_flg = 0"; |
---|
| 150 | $arrVal = array($arrForm['email'], $arrForm['email'], $arrForm['name01'], $arrForm['name02']); |
---|
| 151 | $result = $objQuery->select("reminder, status", "dtb_customer", $where, $arrVal); |
---|
| 152 | if (isset($result[0]['reminder']) and isset($arrReminder[$result[0]['reminder']])) { |
---|
| 153 | // 会員状態の確認 |
---|
| 154 | if($result[0]['status'] == '2') { |
---|
| 155 | // 正会員 |
---|
| 156 | $arrForm['reminder'] = $result[0]['reminder']; |
---|
| 157 | } else if ($result[0]['status'] == '1') { |
---|
| 158 | // 仮会員 |
---|
| 159 | $errmsg = 'ご入力のemailアドレスは現在仮登録中です。<br/>登録の際にお送りしたメールのURLにアクセスし、<br/>本会員登録をお願いします。'; |
---|
[15278] | 160 | } |
---|
[20104] | 161 | } else { |
---|
| 162 | $errmsg = 'お名前に間違いがあるか、このメールアドレスは登録されていません。'; |
---|
[19995] | 163 | } |
---|
[20104] | 164 | return $errmsg; |
---|
[19995] | 165 | } |
---|
[20104] | 166 | |
---|
| 167 | /** |
---|
| 168 | * メールアドレス確認におけるパラメーター情報の初期化 |
---|
| 169 | * |
---|
| 170 | * @param array $objFormParam フォームパラメータークラス |
---|
| 171 | * @param array $device_type デバイスタイプ |
---|
| 172 | * @return void |
---|
| 173 | */ |
---|
| 174 | function lfInitMailCheckParam(&$objFormParam, $device_type) { |
---|
| 175 | $objFormParam->addParam("お名前(姓)", 'name01', STEXT_LEN, "aKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK")); |
---|
| 176 | $objFormParam->addParam("お名前(名)", 'name02', STEXT_LEN, "aKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" , "MAX_LENGTH_CHECK")); |
---|
| 177 | if ($device_type === DEVICE_TYPE_MOBILE){ |
---|
| 178 | $objFormParam->addParam('メールアドレス', "email", MTEXT_LEN, "a", array("EXIST_CHECK", "EMAIL_CHECK", "NO_SPTAB" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK","MOBILE_EMAIL_CHECK")); |
---|
[19995] | 179 | } else { |
---|
[20104] | 180 | $objFormParam->addParam('メールアドレス', "email", MTEXT_LEN, "a", array("NO_SPTAB", "EXIST_CHECK", "EMAIL_CHECK", "SPTAB_CHECK" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK")); |
---|
[19995] | 181 | } |
---|
[20104] | 182 | return; |
---|
[19995] | 183 | } |
---|
[15278] | 184 | |
---|
[20104] | 185 | /** |
---|
| 186 | * 秘密の質問確認 |
---|
| 187 | * |
---|
| 188 | * @param array $arrForm フォーム入力値 |
---|
| 189 | * @param array $arrReminder リマインダー質問リスト |
---|
| 190 | * @return string エラー文字列 問題が無ければNULL |
---|
| 191 | */ |
---|
| 192 | function lfCheckForgotSecret(&$arrForm, &$arrReminder) { |
---|
| 193 | $errmsg = ''; |
---|
| 194 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
| 195 | $cols = "customer_id, reminder, reminder_answer, salt"; |
---|
| 196 | $table = "dtb_customer"; |
---|
| 197 | $where = "(email Like ? OR email_mobile Like ?)" |
---|
| 198 | . " AND name01 Like ? AND name02 Like ?" |
---|
| 199 | . " AND status = 2 AND del_flg = 0"; |
---|
| 200 | $arrVal = array($arrForm['email'], $arrForm['email'], |
---|
| 201 | $arrForm['name01'], $arrForm['name02']); |
---|
| 202 | $result = $objQuery->select($cols, $table, $where, $arrVal); |
---|
| 203 | if (isset($result[0]['reminder']) and isset($arrReminder[$result[0]['reminder']]) |
---|
| 204 | and $result[0]['reminder'] == $arrForm['reminder']) { |
---|
| 205 | |
---|
| 206 | if (SC_Utils_Ex::sfIsMatchHashPassword($arrForm['reminder_answer'], |
---|
| 207 | $result[0]['reminder_answer'], $result[0]['salt'])) { |
---|
| 208 | // 秘密の答えが一致 |
---|
| 209 | // 新しいパスワードを設定する |
---|
| 210 | $new_password = GC_Utils_Ex::gfMakePassword(8); |
---|
| 211 | if(FORGOT_MAIL == 1) { |
---|
| 212 | // メールで変更通知をする |
---|
| 213 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 214 | $CONF = $objDb->sfGetBasisData(); |
---|
| 215 | $this->lfSendMail($CONF, $arrForm['email'], $arrForm['name01'], $new_password); |
---|
[15278] | 216 | } |
---|
[20104] | 217 | $sqlval = array(); |
---|
| 218 | $sqlval['password'] = $new_password; |
---|
| 219 | SC_Helper_Customer_Ex::sfEditCustomerData($sqlval, $result[0]['customer_id']); |
---|
| 220 | $arrForm['new_password'] = $new_password; |
---|
[15278] | 221 | } else { |
---|
[20104] | 222 | // 秘密の答えが一致しなかった |
---|
| 223 | $errmsg = '秘密の質問が一致しませんでした。'; |
---|
[15278] | 224 | } |
---|
| 225 | } else { |
---|
[20104] | 226 | //不正なアクセス リマインダー値が前画面と異なる。 |
---|
| 227 | // 新リファクタリング基準ではここで遷移は不許可なのでエラー表示 |
---|
| 228 | //SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true); |
---|
| 229 | $errmsg = '秘密の質問が一致しませんでした。'; |
---|
[15278] | 230 | } |
---|
[20104] | 231 | return $errmsg; |
---|
[19995] | 232 | } |
---|
[20041] | 233 | |
---|
[20104] | 234 | /** |
---|
| 235 | * 秘密の質問確認におけるパラメーター情報の初期化 |
---|
| 236 | * |
---|
| 237 | * @param array $objFormParam フォームパラメータークラス |
---|
| 238 | * @param array $device_type デバイスタイプ |
---|
| 239 | * @return void |
---|
| 240 | */ |
---|
| 241 | function lfInitSecretCheckParam(&$objFormParam, $device_type) { |
---|
[19995] | 242 | // メールチェックと同等のチェックを再度行う |
---|
[20104] | 243 | $this->lfInitMailCheckParam($objFormParam, $device_type); |
---|
[19995] | 244 | // 秘密の質問チェックの追加 |
---|
[20104] | 245 | $objFormParam->addParam("パスワード確認用の質問", "reminder", STEXT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK")); |
---|
| 246 | $objFormParam->addParam("パスワード確認用の質問の答え", "reminder_answer", STEXT_LEN, "aKV", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 247 | return; |
---|
[19995] | 248 | } |
---|
[15278] | 249 | |
---|
| 250 | /** |
---|
| 251 | * デストラクタ. |
---|
| 252 | * |
---|
| 253 | * @return void |
---|
| 254 | */ |
---|
| 255 | function destroy() { |
---|
| 256 | parent::destroy(); |
---|
| 257 | } |
---|
| 258 | |
---|
| 259 | /** |
---|
| 260 | * パスワード変更お知らせメールを送信する. |
---|
| 261 | * |
---|
| 262 | * @param array $CONF 店舗基本情報の配列 |
---|
| 263 | * @param string $email 送信先メールアドレス |
---|
| 264 | * @param string $customer_name 送信先氏名 |
---|
[20104] | 265 | * @param string $new_password 変更後の新パスワード |
---|
[15278] | 266 | * @return void |
---|
[19995] | 267 | * |
---|
[20104] | 268 | * FIXME: メールテンプレート編集の方に足すのが望ましい |
---|
[15278] | 269 | */ |
---|
[20104] | 270 | function lfSendMail(&$CONF, $email, $customer_name, $new_password){ |
---|
| 271 | // パスワード変更お知らせメール送信 |
---|
[20306] | 272 | $objMailText = new SC_SiteView_Ex(false); |
---|
[20104] | 273 | $objMailText->assign('customer_name', $customer_name); |
---|
| 274 | $objMailText->assign('new_password', $new_password); |
---|
[15278] | 275 | $toCustomerMail = $objMailText->fetch("mail_templates/forgot_mail.tpl"); |
---|
[20104] | 276 | // メール送信オブジェクトによる送信処理 |
---|
[16322] | 277 | $objMail = new SC_SendMail(); |
---|
[15278] | 278 | $objMail->setItem( |
---|
[20104] | 279 | '' //宛先 |
---|
| 280 | , $toCustomerMail //本文 |
---|
| 281 | , $CONF['email03'] //配送元アドレス |
---|
| 282 | , $CONF['shop_name'] // 配送元名 |
---|
| 283 | , $CONF['email03'] // reply to |
---|
| 284 | , $CONF['email04'] //return_path |
---|
| 285 | , $CONF['email04'] // errors_to |
---|
| 286 | ); |
---|
[15278] | 287 | $objMail->setTo($email, $customer_name ." 様"); |
---|
| 288 | $objMail->sendMail(); |
---|
[20104] | 289 | return; |
---|
[15278] | 290 | } |
---|
[16156] | 291 | |
---|
| 292 | } |
---|
[15278] | 293 | ?> |
---|