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