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_REALDIR . "pages/LC_Page.php"); |
---|
26 | |
---|
27 | /** |
---|
28 | * パスワード発行 のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_Forgot extends LC_Page { |
---|
35 | |
---|
36 | // {{{ properties |
---|
37 | |
---|
38 | /** フォームパラメータの配列 */ |
---|
39 | var $objFormParam; |
---|
40 | |
---|
41 | /** 秘密の質問の答え */ |
---|
42 | var $arrReminder; |
---|
43 | |
---|
44 | /** 変更後パスワード */ |
---|
45 | var $temp_password; |
---|
46 | |
---|
47 | /** エラーメッセージ */ |
---|
48 | var $errmsg; |
---|
49 | |
---|
50 | // }}} |
---|
51 | // {{{ functions |
---|
52 | |
---|
53 | /** |
---|
54 | * Page を初期化する. |
---|
55 | * |
---|
56 | * @return void |
---|
57 | */ |
---|
58 | function init() { |
---|
59 | parent::init(); |
---|
60 | $this->tpl_title = "パスワードを忘れた方"; |
---|
61 | $this->tpl_mainpage = 'forgot/index.tpl'; |
---|
62 | $this->tpl_mainno = ''; |
---|
63 | $masterData = new SC_DB_MasterData_Ex(); |
---|
64 | $this->arrReminder = $masterData->getMasterData("mtb_reminder"); |
---|
65 | $this->isMobile = Net_UserAgent_Mobile::isMobile(); |
---|
66 | $this->httpCacheControl('nocache'); |
---|
67 | } |
---|
68 | |
---|
69 | /** |
---|
70 | * Page のプロセス. |
---|
71 | * |
---|
72 | * @return void |
---|
73 | */ |
---|
74 | function process() { |
---|
75 | $this->action(); |
---|
76 | $this->sendResponse(); |
---|
77 | } |
---|
78 | |
---|
79 | /** |
---|
80 | * Page のアクション. |
---|
81 | * |
---|
82 | * @return void |
---|
83 | */ |
---|
84 | function action() { |
---|
85 | $objQuery = new SC_Query(); |
---|
86 | |
---|
87 | if ($_SERVER["REQUEST_METHOD"] == "POST") { |
---|
88 | if (!SC_Helper_Session_Ex::isValidToken()) { |
---|
89 | SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true); |
---|
90 | } |
---|
91 | } |
---|
92 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
93 | |
---|
94 | switch($_POST["mode"]) { |
---|
95 | case 'mail_check': |
---|
96 | $this->lfForgotMailCheck(); |
---|
97 | break; |
---|
98 | case 'secret_check': |
---|
99 | $this->lfForgotSecretCheck(); |
---|
100 | break; |
---|
101 | default: |
---|
102 | $this->lfForgotDefault(); |
---|
103 | break; |
---|
104 | } |
---|
105 | |
---|
106 | $this->transactionid = SC_Helper_Session_Ex::getToken(); |
---|
107 | |
---|
108 | if ($this->isMobile) { |
---|
109 | // モバイルサイトの場合はトークン生成 |
---|
110 | $this->createMobileToken(); |
---|
111 | } else { |
---|
112 | // モバイルサイト以外の場合、ポップアップ用テンプレートファイル設定 |
---|
113 | $this->setTemplate($this->tpl_mainpage); |
---|
114 | } |
---|
115 | } |
---|
116 | |
---|
117 | // 最初に開いた時の処理(メールアドレス入力画面) |
---|
118 | function lfForgotDefault() { |
---|
119 | // クッキー管理クラス |
---|
120 | $objCookie = new SC_Cookie(COOKIE_EXPIRE); |
---|
121 | $this->tpl_login_email = $objCookie->getCookie('login_email'); |
---|
122 | } |
---|
123 | |
---|
124 | // メールアドレス確認(秘密の質問入力画面) |
---|
125 | function lfForgotMailCheck() { |
---|
126 | // パラメータ管理クラス,パラメータ情報の初期化 |
---|
127 | $this->objFormParam = new SC_FormParam(); |
---|
128 | $this->lfMailCheckInitParam(); |
---|
129 | // POST値の取得 |
---|
130 | $this->objFormParam->setParam($_POST); |
---|
131 | $this->objFormParam->convParam(); |
---|
132 | $this->objFormParam->toLower('email'); |
---|
133 | $this->arrForm = $this->objFormParam->getHashArray(); |
---|
134 | //エラーチェック |
---|
135 | $this->arrErr = $this->lfMailCheckErrorCheck(); |
---|
136 | if (count($this->arrErr) == 0) { |
---|
137 | $email = $this->arrForm['email']; |
---|
138 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
139 | $where = "(email Like ? OR email_mobile Like ?) AND name01 Like ? AND name02 Like ? AND del_flg = 0"; |
---|
140 | $arrVal = array($this->arrForm['email'], $this->arrForm['email'], $this->arrForm['name01'], $this->arrForm['name02']); |
---|
141 | $result = $objQuery->select("reminder, status", "dtb_customer", $where, $arrVal); |
---|
142 | if (isset($result[0]['reminder']) and isset($this->arrReminder[$result[0]['reminder']])) { |
---|
143 | if($result[0]['status'] == '2') { |
---|
144 | // 有効な情報であるため、秘密の質問確認へ遷移 |
---|
145 | $this->tpl_mainpage = 'forgot/secret.tpl'; |
---|
146 | $this->arrForm['reminder'] = $result[0]['reminder']; |
---|
147 | } else if ($result[0]['status'] == '1') { |
---|
148 | $this->errmsg = 'ご入力のemailアドレスは現在仮登録中です。<br/>登録の際にお送りしたメールのURLにアクセスし、<br/>本会員登録をお願いします。'; |
---|
149 | } |
---|
150 | } else { |
---|
151 | $this->errmsg = 'お名前に間違いがあるか、このメールアドレスは登録されていません。'; |
---|
152 | } |
---|
153 | } |
---|
154 | } |
---|
155 | |
---|
156 | // メールアドレス確認におけるエラーチェック |
---|
157 | function lfMailCheckErrorCheck() { |
---|
158 | // 入力データを渡す |
---|
159 | $arrRet = $this->objFormParam->getHashArray(); |
---|
160 | $objErr = new SC_CheckError($arrRet); |
---|
161 | $objErr->arrErr = $this->objFormParam->checkError(); |
---|
162 | return $objErr->arrErr; |
---|
163 | } |
---|
164 | |
---|
165 | // メールアドレス確認におけるパラメーター情報の初期化 |
---|
166 | function lfMailCheckInitParam() { |
---|
167 | $this->objFormParam->addParam("お名前(姓)", 'name01', STEXT_LEN, "aKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK")); |
---|
168 | $this->objFormParam->addParam("お名前(名)", 'name02', STEXT_LEN, "aKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" , "MAX_LENGTH_CHECK")); |
---|
169 | if ($this->isMobile == false){ |
---|
170 | $this->objFormParam->addParam('メールアドレス', "email", MTEXT_LEN, "a", array("NO_SPTAB", "EXIST_CHECK", "EMAIL_CHECK", "SPTAB_CHECK" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK")); |
---|
171 | } else { |
---|
172 | $this->objFormParam->addParam('メールアドレス', "email", MTEXT_LEN, "a", array("EXIST_CHECK", "EMAIL_CHECK", "NO_SPTAB" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK","MOBILE_EMAIL_CHECK")); |
---|
173 | } |
---|
174 | |
---|
175 | } |
---|
176 | |
---|
177 | // 秘密の質問確認 |
---|
178 | function lfForgotSecretCheck() { |
---|
179 | // パラメータ管理クラス,パラメータ情報の初期化 |
---|
180 | $this->objFormParam = new SC_FormParam(); |
---|
181 | $this->lfSecretCheckInitParam(); |
---|
182 | // POST値の取得 |
---|
183 | $this->objFormParam->setParam($_POST); |
---|
184 | $this->objFormParam->convParam(); |
---|
185 | $this->objFormParam->toLower('email'); |
---|
186 | $this->arrForm = $this->objFormParam->getHashArray(); |
---|
187 | //エラーチェック |
---|
188 | $this->arrErr = $this->lfSecretCheckErrorCheck(); |
---|
189 | if (count($this->arrErr) == 0) { |
---|
190 | $email = $this->arrForm['email']; |
---|
191 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
192 | $where = "(email Like ? OR email_mobile Like ?) AND name01 Like ? AND name02 Like ? AND status = 2 AND del_flg = 0"; |
---|
193 | $arrVal = array($this->arrForm['email'], $this->arrForm['email'], $this->arrForm['name01'], $this->arrForm['name02']); |
---|
194 | $result = $objQuery->select("customer_id, reminder, reminder_answer, salt", "dtb_customer", $where, $arrVal); |
---|
195 | if (isset($result[0]['reminder']) and isset($this->arrReminder[$result[0]['reminder']]) |
---|
196 | and $result[0]['reminder'] == $this->arrForm['reminder']) { |
---|
197 | |
---|
198 | if (SC_Utils_Ex::sfIsMatchHashPassword($this->arrForm['reminder_answer'], $result[0]['reminder_answer'], $result[0]['salt'])) { |
---|
199 | // 秘密の答えが一致 |
---|
200 | // 新しいパスワードを設定する |
---|
201 | $this->temp_password = GC_Utils_Ex::gfMakePassword(8); |
---|
202 | |
---|
203 | if(FORGOT_MAIL == 1) { |
---|
204 | // メールで変更通知をする |
---|
205 | $objDb = new SC_Helper_DB_Ex(); |
---|
206 | $CONF = $objDb->sfGetBasisData(); |
---|
207 | $this->lfSendMail($CONF, $this->arrForm['email'], $this->arrForm['name01'], $this->temp_password); |
---|
208 | } |
---|
209 | $sqlval = array(); |
---|
210 | $sqlval['password'] = $this->temp_password; |
---|
211 | SC_Helper_Customer_Ex::sfEditCustomerData($sqlval, $result[0]['customer_id']); |
---|
212 | |
---|
213 | // 完了ページへ移動する |
---|
214 | $this->tpl_mainpage = 'forgot/complete.tpl'; |
---|
215 | // transactionidの都合で呼び出し元をリロード。 |
---|
216 | $this->tpl_onload .= 'opener.location.reload(true);'; |
---|
217 | } else { |
---|
218 | // 秘密の答えが一致しなかった |
---|
219 | $this->tpl_mainpage = 'forgot/secret.tpl'; |
---|
220 | $this->errmsg = '秘密の質問が一致しませんでした。'; |
---|
221 | } |
---|
222 | } else { |
---|
223 | //不正なアクセス |
---|
224 | SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true); |
---|
225 | } |
---|
226 | } else { |
---|
227 | $this->tpl_mainpage = 'forgot/secret.tpl'; |
---|
228 | } |
---|
229 | } |
---|
230 | |
---|
231 | function lfSecretCheckInitParam() { |
---|
232 | // メールチェックと同等のチェックを再度行う |
---|
233 | $this->lfMailCheckInitParam(); |
---|
234 | // 秘密の質問チェックの追加 |
---|
235 | $this->objFormParam->addParam("パスワード確認用の質問", "reminder", STEXT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK")); |
---|
236 | $this->objFormParam->addParam("パスワード確認用の質問の答え", "reminder_answer", STEXT_LEN, "aKV", array("EXIST_CHECK","SPTAB_CHECK" , "MAX_LENGTH_CHECK")); |
---|
237 | } |
---|
238 | |
---|
239 | // 秘密の答え確認におけるエラーチェック |
---|
240 | function lfSecretCheckErrorCheck() { |
---|
241 | // 入力データを渡す |
---|
242 | $arrRet = $this->objFormParam->getHashArray(); |
---|
243 | $objErr = new SC_CheckError($arrRet); |
---|
244 | $objErr->arrErr = $this->objFormParam->checkError(); |
---|
245 | return $objErr->arrErr; |
---|
246 | } |
---|
247 | |
---|
248 | /** |
---|
249 | * デストラクタ. |
---|
250 | * |
---|
251 | * @return void |
---|
252 | */ |
---|
253 | function destroy() { |
---|
254 | parent::destroy(); |
---|
255 | } |
---|
256 | |
---|
257 | /** |
---|
258 | * パスワード変更お知らせメールを送信する. |
---|
259 | * |
---|
260 | * @param array $CONF 店舗基本情報の配列 |
---|
261 | * @param string $email 送信先メールアドレス |
---|
262 | * @param string $customer_name 送信先氏名 |
---|
263 | * @param string $temp_password 変更後のパスワード |
---|
264 | * @return void |
---|
265 | * |
---|
266 | * FIXME: メールテンプレート編集の方に足すのが望ましい? |
---|
267 | */ |
---|
268 | function lfSendMail($CONF, $email, $customer_name, $temp_password){ |
---|
269 | // パスワード変更お知らせメール送信 |
---|
270 | $this->customer_name = $customer_name; |
---|
271 | $this->temp_password = $temp_password; |
---|
272 | $objMailText = new SC_SiteView(false); |
---|
273 | $objMailText->assignobj($this); |
---|
274 | |
---|
275 | $toCustomerMail = $objMailText->fetch("mail_templates/forgot_mail.tpl"); |
---|
276 | $objMail = new SC_SendMail(); |
---|
277 | |
---|
278 | $objMail->setItem( |
---|
279 | '' // 宛先 |
---|
280 | , "パスワードが変更されました" ."【" .$CONF["shop_name"]. "】" // サブジェクト |
---|
281 | , $toCustomerMail // 本文 |
---|
282 | , $CONF["email03"] // 配送元アドレス |
---|
283 | , $CONF["shop_name"] // 配送元 名前 |
---|
284 | , $CONF["email03"] // reply_to |
---|
285 | , $CONF["email04"] // return_path |
---|
286 | , $CONF["email04"] // Errors_to |
---|
287 | |
---|
288 | ); |
---|
289 | $objMail->setTo($email, $customer_name ." 様"); |
---|
290 | $objMail->sendMail(); |
---|
291 | } |
---|
292 | |
---|
293 | /** |
---|
294 | * モバイル空メール用のトークン作成 |
---|
295 | * |
---|
296 | * @return void |
---|
297 | * |
---|
298 | * FIXME: この処理の有効性が不明 |
---|
299 | */ |
---|
300 | function createMobileToken() { |
---|
301 | $objMobile = new SC_Helper_Mobile_Ex(); |
---|
302 | // 空メール用のトークンを作成。 |
---|
303 | if (MOBILE_USE_KARA_MAIL) { |
---|
304 | $token = $objMobile->gfPrepareKaraMail('forgot/' . DIR_INDEX_URL); |
---|
305 | if ($token !== false) { |
---|
306 | $objPage->tpl_kara_mail_to = MOBILE_KARA_MAIL_ADDRESS_USER . MOBILE_KARA_MAIL_ADDRESS_DELIMITER . 'forgot_' . $token . '@' . MOBILE_KARA_MAIL_ADDRESS_DOMAIN; |
---|
307 | } |
---|
308 | } |
---|
309 | } |
---|
310 | } |
---|
311 | ?> |
---|