1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2013 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_EX_REALDIR . 'page_extends/LC_Page_Ex.php'; |
---|
26 | |
---|
27 | /** |
---|
28 | * 会員登録のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id:LC_Page_Entry.php 15532 2007-08-31 14:39:46Z nanasess $ |
---|
33 | */ |
---|
34 | class LC_Page_Entry extends LC_Page_Ex |
---|
35 | { |
---|
36 | |
---|
37 | // {{{ properties |
---|
38 | |
---|
39 | // }}} |
---|
40 | // {{{ functions |
---|
41 | |
---|
42 | /** |
---|
43 | * Page を初期化する. |
---|
44 | * @return void |
---|
45 | */ |
---|
46 | function init() |
---|
47 | { |
---|
48 | parent::init(); |
---|
49 | $masterData = new SC_DB_MasterData_Ex(); |
---|
50 | $this->arrPref = $masterData->getMasterData('mtb_pref'); |
---|
51 | $this->arrJob = $masterData->getMasterData('mtb_job'); |
---|
52 | $this->arrReminder = $masterData->getMasterData('mtb_reminder'); |
---|
53 | |
---|
54 | // 生年月日選択肢の取得 |
---|
55 | $objDate = new SC_Date_Ex(BIRTH_YEAR, date('Y',strtotime('now'))); |
---|
56 | $this->arrYear = $objDate->getYear('', START_BIRTH_YEAR, ''); |
---|
57 | $this->arrMonth = $objDate->getMonth(true); |
---|
58 | $this->arrDay = $objDate->getDay(true); |
---|
59 | |
---|
60 | $this->httpCacheControl('nocache'); |
---|
61 | } |
---|
62 | |
---|
63 | /** |
---|
64 | * Page のプロセス. |
---|
65 | * |
---|
66 | * @return void |
---|
67 | */ |
---|
68 | function process() |
---|
69 | { |
---|
70 | parent::process(); |
---|
71 | $this->action(); |
---|
72 | $this->sendResponse(); |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * Page のプロセス |
---|
77 | * @return void |
---|
78 | */ |
---|
79 | function action() |
---|
80 | { |
---|
81 | |
---|
82 | $objFormParam = new SC_FormParam_Ex(); |
---|
83 | |
---|
84 | SC_Helper_Customer_Ex::sfCustomerEntryParam($objFormParam); |
---|
85 | $objFormParam->setParam($_POST); |
---|
86 | $arrForm = $objFormParam->getHashArray(); |
---|
87 | |
---|
88 | // PC時は規約ページからの遷移でなければエラー画面へ遷移する |
---|
89 | if ($this->lfCheckReferer($arrForm, $_SERVER['HTTP_REFERER']) === false) { |
---|
90 | SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true); |
---|
91 | } |
---|
92 | |
---|
93 | // mobile用(戻るボタンでの遷移かどうかを判定) |
---|
94 | if (!empty($arrForm['return'])) { |
---|
95 | $_POST['mode'] = 'return'; |
---|
96 | } |
---|
97 | |
---|
98 | switch ($this->getMode()) { |
---|
99 | case 'confirm': |
---|
100 | if (isset($_POST['submit_address'])) { |
---|
101 | // 入力エラーチェック |
---|
102 | $this->arrErr = $this->lfCheckError($_POST); |
---|
103 | // 入力エラーの場合は終了 |
---|
104 | if (count($this->arrErr) == 0) { |
---|
105 | // 郵便番号検索文作成 |
---|
106 | $zipcode = $_POST['zip01'] . $_POST['zip02']; |
---|
107 | |
---|
108 | // 郵便番号検索 |
---|
109 | $arrAdsList = SC_Utils_Ex::sfGetAddress($zipcode); |
---|
110 | |
---|
111 | // 郵便番号が発見された場合 |
---|
112 | if (!empty($arrAdsList)) { |
---|
113 | $data['pref'] = $arrAdsList[0]['state']; |
---|
114 | $data['addr01'] = $arrAdsList[0]['city']. $arrAdsList[0]['town']; |
---|
115 | $objFormParam->setParam($data); |
---|
116 | |
---|
117 | // 該当無し |
---|
118 | } else { |
---|
119 | $this->arrErr['zip01'] = '※該当する住所が見つかりませんでした。<br>'; |
---|
120 | } |
---|
121 | } |
---|
122 | $this->arrForm = $objFormParam->getHashArray(); |
---|
123 | break; |
---|
124 | } |
---|
125 | |
---|
126 | //-- 確認 |
---|
127 | $this->arrErr = SC_Helper_Customer_Ex::sfCustomerEntryErrorCheck($objFormParam); |
---|
128 | $this->arrForm = $objFormParam->getHashArray(); |
---|
129 | // 入力エラーなし |
---|
130 | if (empty($this->arrErr)) { |
---|
131 | //パスワード表示 |
---|
132 | $this->passlen = SC_Utils_Ex::sfPassLen(strlen($this->arrForm['password'])); |
---|
133 | |
---|
134 | $this->tpl_mainpage = 'entry/confirm.tpl'; |
---|
135 | $this->tpl_title = '会員登録(確認ページ)'; |
---|
136 | } |
---|
137 | break; |
---|
138 | case 'complete': |
---|
139 | //-- 会員登録と完了画面 |
---|
140 | $this->arrErr = SC_Helper_Customer_Ex::sfCustomerEntryErrorCheck($objFormParam); |
---|
141 | $this->arrForm = $objFormParam->getHashArray(); |
---|
142 | if (empty($this->arrErr)) { |
---|
143 | |
---|
144 | $uniqid = $this->lfRegistCustomerData($this->lfMakeSqlVal($objFormParam)); |
---|
145 | |
---|
146 | $this->lfSendMail($uniqid, $this->arrForm); |
---|
147 | |
---|
148 | // 仮会員が無効の場合 |
---|
149 | if (CUSTOMER_CONFIRM_MAIL == false) { |
---|
150 | // ログイン状態にする |
---|
151 | $objCustomer = new SC_Customer_Ex(); |
---|
152 | $objCustomer->setLogin($this->arrForm['email']); |
---|
153 | } |
---|
154 | |
---|
155 | // 完了ページに移動させる。 |
---|
156 | SC_Response_Ex::sendRedirect('complete.php', array('ci' => SC_Helper_Customer_Ex::sfGetCustomerId($uniqid))); |
---|
157 | } |
---|
158 | break; |
---|
159 | case 'return': |
---|
160 | $this->arrForm = $objFormParam->getHashArray(); |
---|
161 | break; |
---|
162 | default: |
---|
163 | break; |
---|
164 | } |
---|
165 | |
---|
166 | } |
---|
167 | |
---|
168 | /** |
---|
169 | * デストラクタ. |
---|
170 | * |
---|
171 | * @return void |
---|
172 | */ |
---|
173 | function destroy() |
---|
174 | { |
---|
175 | parent::destroy(); |
---|
176 | } |
---|
177 | |
---|
178 | // }}} |
---|
179 | // {{{ protected functions |
---|
180 | /** |
---|
181 | * 会員情報の登録 |
---|
182 | * |
---|
183 | * @access private |
---|
184 | * @return uniqid |
---|
185 | */ |
---|
186 | function lfRegistCustomerData($sqlval) |
---|
187 | { |
---|
188 | SC_Helper_Customer_Ex::sfEditCustomerData($sqlval); |
---|
189 | return $sqlval['secret_key']; |
---|
190 | } |
---|
191 | |
---|
192 | /** |
---|
193 | * 会員登録に必要なSQLパラメーターの配列を生成する. |
---|
194 | * |
---|
195 | * フォームに入力された情報を元に, SQLパラメーターの配列を生成する. |
---|
196 | * モバイル端末の場合は, email を email_mobile にコピーし, |
---|
197 | * mobile_phone_id に携帯端末IDを格納する. |
---|
198 | * |
---|
199 | * @param mixed $objFormParam |
---|
200 | * @access private |
---|
201 | * @return $arrResults |
---|
202 | */ |
---|
203 | function lfMakeSqlVal(&$objFormParam) |
---|
204 | { |
---|
205 | $arrForm = $objFormParam->getHashArray(); |
---|
206 | $arrResults = $objFormParam->getDbArray(); |
---|
207 | |
---|
208 | // 生年月日の作成 |
---|
209 | $arrResults['birth'] = SC_Utils_Ex::sfGetTimestamp($arrForm['year'], $arrForm['month'], $arrForm['day']); |
---|
210 | |
---|
211 | // 仮会員 1 本会員 2 |
---|
212 | $arrResults['status'] = (CUSTOMER_CONFIRM_MAIL == true) ? '1' : '2'; |
---|
213 | |
---|
214 | /* |
---|
215 | * secret_keyは、テーブルで重複許可されていない場合があるので、 |
---|
216 | * 本会員登録では利用されないがセットしておく。 |
---|
217 | */ |
---|
218 | $arrResults['secret_key'] = SC_Helper_Customer_Ex::sfGetUniqSecretKey(); |
---|
219 | |
---|
220 | // 入会時ポイント |
---|
221 | $CONF = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
222 | $arrResults['point'] = $CONF['welcome_point']; |
---|
223 | |
---|
224 | if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { |
---|
225 | // 携帯メールアドレス |
---|
226 | $arrResults['email_mobile'] = $arrResults['email']; |
---|
227 | // PHONE_IDを取り出す |
---|
228 | $arrResults['mobile_phone_id'] = SC_MobileUserAgent_Ex::getId(); |
---|
229 | } |
---|
230 | return $arrResults; |
---|
231 | } |
---|
232 | |
---|
233 | /** |
---|
234 | * 会員登録完了メール送信する |
---|
235 | * |
---|
236 | * @access private |
---|
237 | * @return void |
---|
238 | */ |
---|
239 | function lfSendMail($uniqid, $arrForm) |
---|
240 | { |
---|
241 | $CONF = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
242 | |
---|
243 | $objMailText = new SC_SiteView_Ex(); |
---|
244 | $objMailText->setPage($this); |
---|
245 | $objMailText->assign('CONF', $CONF); |
---|
246 | $objMailText->assign('name01', $arrForm['name01']); |
---|
247 | $objMailText->assign('name02', $arrForm['name02']); |
---|
248 | $objMailText->assign('uniqid', $uniqid); |
---|
249 | $objMailText->assignobj($this); |
---|
250 | |
---|
251 | $objHelperMail = new SC_Helper_Mail_Ex(); |
---|
252 | $objHelperMail->setPage($this); |
---|
253 | |
---|
254 | // 仮会員が有効の場合 |
---|
255 | if (CUSTOMER_CONFIRM_MAIL == true) { |
---|
256 | $subject = $objHelperMail->sfMakeSubject('会員登録のご確認'); |
---|
257 | $toCustomerMail = $objMailText->fetch('mail_templates/customer_mail.tpl'); |
---|
258 | } else { |
---|
259 | $subject = $objHelperMail->sfMakeSubject('会員登録のご完了'); |
---|
260 | $toCustomerMail = $objMailText->fetch('mail_templates/customer_regist_mail.tpl'); |
---|
261 | } |
---|
262 | |
---|
263 | $objMail = new SC_SendMail_Ex(); |
---|
264 | $objMail->setItem( |
---|
265 | '' // 宛先 |
---|
266 | , $subject // サブジェクト |
---|
267 | , $toCustomerMail // 本文 |
---|
268 | , $CONF['email03'] // 配送元アドレス |
---|
269 | , $CONF['shop_name'] // 配送元 名前 |
---|
270 | , $CONF['email03'] // reply_to |
---|
271 | , $CONF['email04'] // return_path |
---|
272 | , $CONF['email04'] // Errors_to |
---|
273 | , $CONF['email01'] // Bcc |
---|
274 | ); |
---|
275 | // 宛先の設定 |
---|
276 | $objMail->setTo($arrForm['email'], |
---|
277 | $arrForm['name01'] . $arrForm['name02'] .' 様'); |
---|
278 | |
---|
279 | $objMail->sendMail(); |
---|
280 | } |
---|
281 | |
---|
282 | /** |
---|
283 | * kiyaku.php からの遷移の妥当性をチェックする |
---|
284 | * |
---|
285 | * 以下の内容をチェックし, 妥当であれば true を返す. |
---|
286 | * 1. 規約ページからの遷移かどうか |
---|
287 | * 2. PC及びスマートフォンかどうか |
---|
288 | * 3. $post に何も含まれていないかどうか |
---|
289 | * |
---|
290 | * @access protected |
---|
291 | * @param array $post $_POST のデータ |
---|
292 | * @param string $referer $_SERVER['HTTP_REFERER'] のデータ |
---|
293 | * @return boolean kiyaku.php からの妥当な遷移であれば true |
---|
294 | */ |
---|
295 | function lfCheckReferer(&$post, $referer) |
---|
296 | { |
---|
297 | |
---|
298 | if (SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE |
---|
299 | && empty($post) |
---|
300 | && (preg_match('/kiyaku.php/', basename($referer)) === 0)) { |
---|
301 | return false; |
---|
302 | } |
---|
303 | return true; |
---|
304 | } |
---|
305 | |
---|
306 | /** |
---|
307 | * 入力エラーのチェック. |
---|
308 | * |
---|
309 | * @param array $arrRequest リクエスト値($_GET) |
---|
310 | * @return array $arrErr エラーメッセージ配列 |
---|
311 | */ |
---|
312 | function lfCheckError($arrRequest) |
---|
313 | { |
---|
314 | // パラメーター管理クラス |
---|
315 | $objFormParam = new SC_FormParam_Ex(); |
---|
316 | // パラメーター情報の初期化 |
---|
317 | $objFormParam->addParam('郵便番号1', 'zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK')); |
---|
318 | $objFormParam->addParam('郵便番号2', 'zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK')); |
---|
319 | // // リクエスト値をセット |
---|
320 | $arrData['zip01'] = $arrRequest['zip01']; |
---|
321 | $arrData['zip02'] = $arrRequest['zip02']; |
---|
322 | $objFormParam->setParam($arrData); |
---|
323 | // エラーチェック |
---|
324 | $arrErr = $objFormParam->checkError(); |
---|
325 | // 親ウィンドウの戻り値を格納するinputタグのnameのエラーチェック |
---|
326 | if (!$this->lfInputNameCheck($addData['zip01'])) { |
---|
327 | $arrErr['zip01'] = '※ 入力形式が不正です。<br />'; |
---|
328 | } |
---|
329 | if (!$this->lfInputNameCheck($arrdata['zip02'])) { |
---|
330 | $arrErr['zip02'] = '※ 入力形式が不正です。<br />'; |
---|
331 | } |
---|
332 | |
---|
333 | return $arrErr; |
---|
334 | } |
---|
335 | |
---|
336 | /** |
---|
337 | * エラーチェック. |
---|
338 | * |
---|
339 | * @param string $value |
---|
340 | * @return エラーなし:true エラー:false |
---|
341 | */ |
---|
342 | function lfInputNameCheck($value) |
---|
343 | { |
---|
344 | // 半角英数字と_(アンダーバー), []以外の文字を使用していたらエラー |
---|
345 | if (strlen($value) > 0 && !preg_match("/^[a-zA-Z0-9_\[\]]+$/", $value)) { |
---|
346 | return false; |
---|
347 | } |
---|
348 | |
---|
349 | return true; |
---|
350 | } |
---|
351 | } |
---|