| 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->fnErrorCheck($_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'] = '※該当する住所が見つかりませんでした。<br>'; |
---|
| 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 = '会員登録(確認ページ)'; |
---|
| 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->tpl_mainpage = 'entry/complete.tpl'; |
---|
| 143 | $this->tpl_title = '会員登録(完了ページ)'; |
---|
| 144 | $this->lfSendMail($uniqid, $this->arrForm); |
---|
| 145 | |
---|
| 146 | // 仮会員が無効の場合 |
---|
| 147 | if (CUSTOMER_CONFIRM_MAIL == false) { |
---|
| 148 | // ログイン状態にする |
---|
| 149 | $objCustomer = new SC_Customer_Ex(); |
---|
| 150 | $objCustomer->setLogin($this->arrForm['email']); |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | // 完了ページに移動させる。 |
---|
| 154 | SC_Response_Ex::sendRedirect('complete.php', array('ci' => SC_Helper_Customer_Ex::sfGetCustomerId($uniqid))); |
---|
| 155 | } |
---|
| 156 | break; |
---|
| 157 | case 'return': |
---|
| 158 | $this->arrForm = $objFormParam->getHashArray(); |
---|
| 159 | break; |
---|
| 160 | default: |
---|
| 161 | break; |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | } |
---|
| 165 | |
---|
| 166 | /** |
---|
| 167 | * デストラクタ. |
---|
| 168 | * |
---|
| 169 | * @return void |
---|
| 170 | */ |
---|
| 171 | function destroy() { |
---|
| 172 | parent::destroy(); |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | // }}} |
---|
| 176 | // {{{ protected functions |
---|
| 177 | /** |
---|
| 178 | * 会員情報の登録 |
---|
| 179 | * |
---|
| 180 | * @access private |
---|
| 181 | * @return uniqid |
---|
| 182 | */ |
---|
| 183 | function lfRegistCustomerData($sqlval) { |
---|
| 184 | SC_Helper_Customer_Ex::sfEditCustomerData($sqlval); |
---|
| 185 | return $sqlval['secret_key']; |
---|
| 186 | } |
---|
| 187 | |
---|
| 188 | /** |
---|
| 189 | * 会員登録に必要なSQLパラメーターの配列を生成する. |
---|
| 190 | * |
---|
| 191 | * フォームに入力された情報を元に, SQLパラメーターの配列を生成する. |
---|
| 192 | * モバイル端末の場合は, email を email_mobile にコピーし, |
---|
| 193 | * mobile_phone_id に携帯端末IDを格納する. |
---|
| 194 | * |
---|
| 195 | * @param mixed $objFormParam |
---|
| 196 | * @access private |
---|
| 197 | * @return $arrResults |
---|
| 198 | */ |
---|
| 199 | function lfMakeSqlVal(&$objFormParam) { |
---|
| 200 | $arrForm = $objFormParam->getHashArray(); |
---|
| 201 | $arrResults = $objFormParam->getDbArray(); |
---|
| 202 | |
---|
| 203 | // 生年月日の作成 |
---|
| 204 | $arrResults['birth'] = SC_Utils_Ex::sfGetTimestamp($arrForm['year'], $arrForm['month'], $arrForm['day']); |
---|
| 205 | |
---|
| 206 | // 仮会員 1 本会員 2 |
---|
| 207 | $arrResults['status'] = (CUSTOMER_CONFIRM_MAIL == true) ? '1' : '2'; |
---|
| 208 | |
---|
| 209 | /* |
---|
| 210 | * secret_keyは、テーブルで重複許可されていない場合があるので、 |
---|
| 211 | * 本会員登録では利用されないがセットしておく。 |
---|
| 212 | */ |
---|
| 213 | $arrResults['secret_key'] = SC_Helper_Customer_Ex::sfGetUniqSecretKey(); |
---|
| 214 | |
---|
| 215 | // 入会時ポイント |
---|
| 216 | $CONF = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
| 217 | $arrResults['point'] = $CONF['welcome_point']; |
---|
| 218 | |
---|
| 219 | if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { |
---|
| 220 | // 携帯メールアドレス |
---|
| 221 | $arrResults['email_mobile'] = $arrResults['email']; |
---|
| 222 | // PHONE_IDを取り出す |
---|
| 223 | $arrResults['mobile_phone_id'] = SC_MobileUserAgent_Ex::getId(); |
---|
| 224 | } |
---|
| 225 | return $arrResults; |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | /** |
---|
| 229 | * 会員登録完了メール送信する |
---|
| 230 | * |
---|
| 231 | * @access private |
---|
| 232 | * @return void |
---|
| 233 | */ |
---|
| 234 | function lfSendMail($uniqid, $arrForm) { |
---|
| 235 | $CONF = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
| 236 | |
---|
| 237 | $objMailText = new SC_SiteView_Ex(); |
---|
| 238 | $objMailText->setPage($this); |
---|
| 239 | $objMailText->assign('CONF', $CONF); |
---|
| 240 | $objMailText->assign('name01', $arrForm['name01']); |
---|
| 241 | $objMailText->assign('name02', $arrForm['name02']); |
---|
| 242 | $objMailText->assign('uniqid', $uniqid); |
---|
| 243 | $objMailText->assignobj($this); |
---|
| 244 | |
---|
| 245 | $objHelperMail = new SC_Helper_Mail_Ex(); |
---|
| 246 | $objHelperMail->setPage($this); |
---|
| 247 | |
---|
| 248 | // 仮会員が有効の場合 |
---|
| 249 | if (CUSTOMER_CONFIRM_MAIL == true) { |
---|
| 250 | $subject = $objHelperMail->sfMakeSubject('会員登録のご確認'); |
---|
| 251 | $toCustomerMail = $objMailText->fetch('mail_templates/customer_mail.tpl'); |
---|
| 252 | } else { |
---|
| 253 | $subject = $objHelperMail->sfMakeSubject('会員登録のご完了'); |
---|
| 254 | $toCustomerMail = $objMailText->fetch('mail_templates/customer_regist_mail.tpl'); |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | $objMail = new SC_SendMail(); |
---|
| 258 | $objMail->setItem( |
---|
| 259 | '' // 宛先 |
---|
| 260 | , $subject // サブジェクト |
---|
| 261 | , $toCustomerMail // 本文 |
---|
| 262 | , $CONF['email03'] // 配送元アドレス |
---|
| 263 | , $CONF['shop_name'] // 配送元 名前 |
---|
| 264 | , $CONF['email03'] // reply_to |
---|
| 265 | , $CONF['email04'] // return_path |
---|
| 266 | , $CONF['email04'] // Errors_to |
---|
| 267 | , $CONF['email01'] // Bcc |
---|
| 268 | ); |
---|
| 269 | // 宛先の設定 |
---|
| 270 | $objMail->setTo($arrForm['email'], |
---|
| 271 | $arrForm['name01'] . $arrForm['name02'] .' 様'); |
---|
| 272 | |
---|
| 273 | $objMail->sendMail(); |
---|
| 274 | } |
---|
| 275 | |
---|
| 276 | /** |
---|
| 277 | * kiyaku.php からの遷移の妥当性をチェックする |
---|
| 278 | * |
---|
| 279 | * 以下の内容をチェックし, 妥当であれば true を返す. |
---|
| 280 | * 1. 規約ページからの遷移かどうか |
---|
| 281 | * 2. PC及びスマートフォンかどうか |
---|
| 282 | * 3. $post に何も含まれていないかどうか |
---|
| 283 | * |
---|
| 284 | * @access protected |
---|
| 285 | * @param array $post $_POST のデータ |
---|
| 286 | * @param string $referer $_SERVER['HTTP_REFERER'] のデータ |
---|
| 287 | * @return boolean kiyaku.php からの妥当な遷移であれば true |
---|
| 288 | */ |
---|
| 289 | function lfCheckReferer(&$post, $referer) { |
---|
| 290 | |
---|
| 291 | if (SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE |
---|
| 292 | && empty($post) |
---|
| 293 | && (preg_match('/kiyaku.php/', basename($referer)) === 0)) { |
---|
| 294 | return false; |
---|
| 295 | } |
---|
| 296 | return true; |
---|
| 297 | } |
---|
| 298 | |
---|
| 299 | /** |
---|
| 300 | * 入力エラーのチェック. |
---|
| 301 | * |
---|
| 302 | * @param array $arrRequest リクエスト値($_GET) |
---|
| 303 | * @return array $arrErr エラーメッセージ配列 |
---|
| 304 | */ |
---|
| 305 | function fnErrorCheck($arrRequest) { |
---|
| 306 | // パラメーター管理クラス |
---|
| 307 | $objFormParam = new SC_FormParam_Ex(); |
---|
| 308 | // パラメーター情報の初期化 |
---|
| 309 | $objFormParam->addParam('郵便番号1', 'zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK')); |
---|
| 310 | $objFormParam->addParam('郵便番号2', 'zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK')); |
---|
| 311 | // // リクエスト値をセット |
---|
| 312 | $arrData['zip01'] = $arrRequest['zip01']; |
---|
| 313 | $arrData['zip02'] = $arrRequest['zip02']; |
---|
| 314 | $objFormParam->setParam($arrData); |
---|
| 315 | // エラーチェック |
---|
| 316 | $arrErr = $objFormParam->checkError(); |
---|
| 317 | // 親ウィンドウの戻り値を格納するinputタグのnameのエラーチェック |
---|
| 318 | if (!$this->lfInputNameCheck($addData['zip01'])) { |
---|
| 319 | $arrErr['zip01'] = '※ 入力形式が不正です。<br />'; |
---|
| 320 | } |
---|
| 321 | if (!$this->lfInputNameCheck($arrdata['zip02'])) { |
---|
| 322 | $arrErr['zip02'] = '※ 入力形式が不正です。<br />'; |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | return $arrErr; |
---|
| 326 | } |
---|
| 327 | |
---|
| 328 | /** |
---|
| 329 | * エラーチェック. |
---|
| 330 | * |
---|
| 331 | * @param string $value |
---|
| 332 | * @return エラーなし:true エラー:false |
---|
| 333 | */ |
---|
| 334 | function lfInputNameCheck($value) { |
---|
| 335 | // 半角英数字と_(アンダーバー), []以外の文字を使用していたらエラー |
---|
| 336 | if (strlen($value) > 0 && !preg_match("/^[a-zA-Z0-9_\[\]]+$/", $value)) { |
---|
| 337 | return false; |
---|
| 338 | } |
---|
| 339 | |
---|
| 340 | return true; |
---|
| 341 | } |
---|
| 342 | } |
---|