1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2011 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 | $objFormParam = new SC_FormParam_Ex(); |
---|
78 | |
---|
79 | SC_Helper_Customer_Ex::sfCustomerEntryParam($objFormParam); |
---|
80 | $objFormParam->setParam($_POST); |
---|
81 | $arrForm = $objFormParam->getHashArray(); |
---|
82 | |
---|
83 | // PC時は規約ページからの遷移でなければエラー画面へ遷移する |
---|
84 | if ($this->lfCheckReferer($arrForm, $_SERVER['HTTP_REFERER']) === false) { |
---|
85 | SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true); |
---|
86 | } |
---|
87 | |
---|
88 | // mobile用(戻るボタンでの遷移かどうかを判定) |
---|
89 | if (!empty($arrForm['return'])) { |
---|
90 | $_POST['mode'] = 'return'; |
---|
91 | } |
---|
92 | |
---|
93 | switch ($this->getMode()) { |
---|
94 | case 'confirm': |
---|
95 | //-- 確認 |
---|
96 | $this->arrErr = SC_Helper_Customer_Ex::sfCustomerEntryErrorCheck($objFormParam); |
---|
97 | $this->arrForm = $objFormParam->getHashArray(); |
---|
98 | // 入力エラーなし |
---|
99 | if (empty($this->arrErr)) { |
---|
100 | //パスワード表示 |
---|
101 | $this->passlen = SC_Utils_Ex::sfPassLen(strlen($this->arrForm['password'])); |
---|
102 | |
---|
103 | $this->tpl_mainpage = 'entry/confirm.tpl'; |
---|
104 | $this->tpl_title = '会員登録(確認ページ)'; |
---|
105 | } |
---|
106 | break; |
---|
107 | case 'complete': |
---|
108 | //-- 会員登録と完了画面 |
---|
109 | $this->arrErr = SC_Helper_Customer_Ex::sfCustomerEntryErrorCheck($objFormParam); |
---|
110 | $this->arrForm = $objFormParam->getHashArray(); |
---|
111 | if (empty($this->arrErr)) { |
---|
112 | |
---|
113 | $uniqid = $this->lfRegistCustomerData($this->lfMakeSqlVal($objFormParam)); |
---|
114 | |
---|
115 | $this->tpl_mainpage = 'entry/complete.tpl'; |
---|
116 | $this->tpl_title = '会員登録(完了ページ)'; |
---|
117 | $this->lfSendMail($uniqid, $this->arrForm); |
---|
118 | |
---|
119 | // 仮会員が無効の場合 |
---|
120 | if (CUSTOMER_CONFIRM_MAIL == false) { |
---|
121 | // ログイン状態にする |
---|
122 | $objCustomer = new SC_Customer_Ex(); |
---|
123 | $objCustomer->setLogin($this->arrForm['email']); |
---|
124 | } |
---|
125 | |
---|
126 | // 完了ページに移動させる。 |
---|
127 | SC_Response_Ex::sendRedirect('complete.php', array('ci' => SC_Helper_Customer_Ex::sfGetCustomerId($uniqid))); |
---|
128 | } |
---|
129 | break; |
---|
130 | case 'return': |
---|
131 | $this->arrForm = $objFormParam->getHashArray(); |
---|
132 | break; |
---|
133 | default: |
---|
134 | break; |
---|
135 | } |
---|
136 | } |
---|
137 | |
---|
138 | /** |
---|
139 | * デストラクタ. |
---|
140 | * |
---|
141 | * @return void |
---|
142 | */ |
---|
143 | function destroy() { |
---|
144 | parent::destroy(); |
---|
145 | } |
---|
146 | |
---|
147 | // }}} |
---|
148 | // {{{ protected functions |
---|
149 | /** |
---|
150 | * 会員情報の登録 |
---|
151 | * |
---|
152 | * @access private |
---|
153 | * @return uniqid |
---|
154 | */ |
---|
155 | function lfRegistCustomerData($sqlval) { |
---|
156 | SC_Helper_Customer_Ex::sfEditCustomerData($sqlval); |
---|
157 | return $sqlval['secret_key']; |
---|
158 | } |
---|
159 | |
---|
160 | /** |
---|
161 | * 会員登録に必要なSQLパラメーターの配列を生成する. |
---|
162 | * |
---|
163 | * フォームに入力された情報を元に, SQLパラメーターの配列を生成する. |
---|
164 | * モバイル端末の場合は, email を email_mobile にコピーし, |
---|
165 | * mobile_phone_id に携帯端末IDを格納する. |
---|
166 | * |
---|
167 | * @param mixed $objFormParam |
---|
168 | * @access private |
---|
169 | * @return $arrResults |
---|
170 | */ |
---|
171 | function lfMakeSqlVal(&$objFormParam) { |
---|
172 | $arrForm = $objFormParam->getHashArray(); |
---|
173 | $arrResults = $objFormParam->getDbArray(); |
---|
174 | |
---|
175 | // 生年月日の作成 |
---|
176 | $arrResults['birth'] = SC_Utils_Ex::sfGetTimestamp($arrForm['year'], $arrForm['month'], $arrForm['day']); |
---|
177 | |
---|
178 | // 仮会員 1 本会員 2 |
---|
179 | $arrResults['status'] = (CUSTOMER_CONFIRM_MAIL == true) ? '1' : '2'; |
---|
180 | |
---|
181 | /* |
---|
182 | * secret_keyは、テーブルで重複許可されていない場合があるので、 |
---|
183 | * 本会員登録では利用されないがセットしておく。 |
---|
184 | */ |
---|
185 | $arrResults['secret_key'] = SC_Helper_Customer_Ex::sfGetUniqSecretKey(); |
---|
186 | |
---|
187 | // 入会時ポイント |
---|
188 | $CONF = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
189 | $arrResults['point'] = $CONF['welcome_point']; |
---|
190 | |
---|
191 | if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { |
---|
192 | // 携帯メールアドレス |
---|
193 | $arrResults['email_mobile'] = $arrResults['email']; |
---|
194 | // PHONE_IDを取り出す |
---|
195 | $arrResults['mobile_phone_id'] = SC_MobileUserAgent_Ex::getId(); |
---|
196 | } |
---|
197 | return $arrResults; |
---|
198 | } |
---|
199 | |
---|
200 | /** |
---|
201 | * 会員登録完了メール送信する |
---|
202 | * |
---|
203 | * @access private |
---|
204 | * @return void |
---|
205 | */ |
---|
206 | function lfSendMail($uniqid, $arrForm) { |
---|
207 | $CONF = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
208 | |
---|
209 | $objMailText = new SC_SiteView_Ex(); |
---|
210 | $objMailText->assign('CONF', $CONF); |
---|
211 | $objMailText->assign('name01', $arrForm['name01']); |
---|
212 | $objMailText->assign('name02', $arrForm['name02']); |
---|
213 | $objMailText->assign('uniqid', $uniqid); |
---|
214 | $objMailText->assignobj($this); |
---|
215 | |
---|
216 | $objHelperMail = new SC_Helper_Mail_Ex(); |
---|
217 | |
---|
218 | // 仮会員が有効の場合 |
---|
219 | if (CUSTOMER_CONFIRM_MAIL == true) { |
---|
220 | $subject = $objHelperMail->sfMakeSubject('会員登録のご確認'); |
---|
221 | $toCustomerMail = $objMailText->fetch('mail_templates/customer_mail.tpl'); |
---|
222 | } else { |
---|
223 | $subject = $objHelperMail->sfMakeSubject('会員登録のご完了'); |
---|
224 | $toCustomerMail = $objMailText->fetch('mail_templates/customer_regist_mail.tpl'); |
---|
225 | } |
---|
226 | |
---|
227 | $objMail = new SC_SendMail(); |
---|
228 | $objMail->setItem( |
---|
229 | '' // 宛先 |
---|
230 | , $subject // サブジェクト |
---|
231 | , $toCustomerMail // 本文 |
---|
232 | , $CONF['email03'] // 配送元アドレス |
---|
233 | , $CONF['shop_name'] // 配送元 名前 |
---|
234 | , $CONF['email03'] // reply_to |
---|
235 | , $CONF['email04'] // return_path |
---|
236 | , $CONF['email04'] // Errors_to |
---|
237 | , $CONF['email01'] // Bcc |
---|
238 | ); |
---|
239 | // 宛先の設定 |
---|
240 | $objMail->setTo($arrForm['email'], |
---|
241 | $arrForm['name01'] . $arrForm['name02'] .' 様'); |
---|
242 | |
---|
243 | $objMail->sendMail(); |
---|
244 | } |
---|
245 | |
---|
246 | /** |
---|
247 | * kiyaku.php からの遷移の妥当性をチェックする |
---|
248 | * |
---|
249 | * 以下の内容をチェックし, 妥当であれば true を返す. |
---|
250 | * 1. 規約ページからの遷移かどうか |
---|
251 | * 2. PC及びスマートフォンかどうか |
---|
252 | * 3. $post に何も含まれていないかどうか |
---|
253 | * |
---|
254 | * @access protected |
---|
255 | * @param array $post $_POST のデータ |
---|
256 | * @param string $referer $_SERVER['HTTP_REFERER'] のデータ |
---|
257 | * @return boolean kiyaku.php からの妥当な遷移であれば true |
---|
258 | */ |
---|
259 | function lfCheckReferer(&$post, $referer) { |
---|
260 | |
---|
261 | if (SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE |
---|
262 | && empty($post) |
---|
263 | && (preg_match('/kiyaku.php/', basename($referer)) === 0)) { |
---|
264 | return false; |
---|
265 | } |
---|
266 | return true; |
---|
267 | } |
---|
268 | } |
---|