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