| 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 | $this->action(); |
|---|
| 68 | $this->sendResponse(); |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | /** |
|---|
| 72 | * Page のプロセス |
|---|
| 73 | * @return void |
|---|
| 74 | */ |
|---|
| 75 | function action() { |
|---|
| 76 | $objFormParam = new SC_FormParam_Ex(); |
|---|
| 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_Ex(); |
|---|
| 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 | * 会員登録に必要なSQLパラメータの配列を生成する. |
|---|
| 156 | * |
|---|
| 157 | * フォームに入力された情報を元に, SQLパラメータの配列を生成する. |
|---|
| 158 | * モバイル端末の場合は, email を email_mobile にコピーし, |
|---|
| 159 | * mobile_phone_id に携帯端末IDを格納する. |
|---|
| 160 | * |
|---|
| 161 | * @param mixed $objFormParam |
|---|
| 162 | * @access private |
|---|
| 163 | * @return $arrResults |
|---|
| 164 | */ |
|---|
| 165 | function lfMakeSqlVal(&$objFormParam) { |
|---|
| 166 | $arrForm = $objFormParam->getHashArray(); |
|---|
| 167 | $arrResults = $objFormParam->getDbArray(); |
|---|
| 168 | |
|---|
| 169 | // 生年月日の作成 |
|---|
| 170 | $arrResults['birth'] = SC_Utils_Ex::sfGetTimestamp($arrForm['year'], $arrForm['month'], $arrForm['day']); |
|---|
| 171 | |
|---|
| 172 | // 仮会員 1 本会員 2 |
|---|
| 173 | $arrResults['status'] = (CUSTOMER_CONFIRM_MAIL == true) ? "1" : "2"; |
|---|
| 174 | |
|---|
| 175 | /* |
|---|
| 176 | * secret_keyは、テーブルで重複許可されていない場合があるので、 |
|---|
| 177 | * 本会員登録では利用されないがセットしておく。 |
|---|
| 178 | */ |
|---|
| 179 | $arrResults["secret_key"] = SC_Helper_Customer_Ex::sfGetUniqSecretKey(); |
|---|
| 180 | |
|---|
| 181 | // 入会時ポイント |
|---|
| 182 | $CONF = SC_Helper_DB_Ex::sfGetBasisData(); |
|---|
| 183 | $arrResults['point'] = $CONF["welcome_point"]; |
|---|
| 184 | |
|---|
| 185 | if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { |
|---|
| 186 | // 携帯メールアドレス |
|---|
| 187 | $arrResults['email_mobile'] = $arrResults['email']; |
|---|
| 188 | // PHONE_IDを取り出す |
|---|
| 189 | $arrResults['mobile_phone_id'] = SC_MobileUserAgent_Ex::getId(); |
|---|
| 190 | } |
|---|
| 191 | return $arrResults; |
|---|
| 192 | } |
|---|
| 193 | |
|---|
| 194 | /** |
|---|
| 195 | * 会員登録完了メール送信する |
|---|
| 196 | * |
|---|
| 197 | * @access private |
|---|
| 198 | * @return void |
|---|
| 199 | */ |
|---|
| 200 | function lfSendMail($uniqid, $arrForm){ |
|---|
| 201 | $CONF = SC_Helper_DB_Ex::sfGetBasisData(); |
|---|
| 202 | |
|---|
| 203 | $objMailText = new SC_SiteView_Ex(); |
|---|
| 204 | $objMailText->assign('CONF', $CONF); |
|---|
| 205 | $objMailText->assign("name01", $arrForm['name01']); |
|---|
| 206 | $objMailText->assign("name02", $arrForm['name02']); |
|---|
| 207 | $objMailText->assign('uniqid', $uniqid); |
|---|
| 208 | $objMailText->assignobj($this); |
|---|
| 209 | |
|---|
| 210 | $objHelperMail = new SC_Helper_Mail_Ex(); |
|---|
| 211 | |
|---|
| 212 | // 仮会員が有効の場合 |
|---|
| 213 | if(CUSTOMER_CONFIRM_MAIL == true) { |
|---|
| 214 | $subject = $objHelperMail->sfMakeSubject('会員登録のご確認'); |
|---|
| 215 | $toCustomerMail = $objMailText->fetch("mail_templates/customer_mail.tpl"); |
|---|
| 216 | } else { |
|---|
| 217 | $subject = $objHelperMail->sfMakeSubject('会員登録のご完了'); |
|---|
| 218 | $toCustomerMail = $objMailText->fetch("mail_templates/customer_regist_mail.tpl"); |
|---|
| 219 | } |
|---|
| 220 | |
|---|
| 221 | $objMail = new SC_SendMail(); |
|---|
| 222 | $objMail->setItem( |
|---|
| 223 | '' // 宛先 |
|---|
| 224 | , $subject // サブジェクト |
|---|
| 225 | , $toCustomerMail // 本文 |
|---|
| 226 | , $CONF["email03"] // 配送元アドレス |
|---|
| 227 | , $CONF["shop_name"] // 配送元 名前 |
|---|
| 228 | , $CONF["email03"] // reply_to |
|---|
| 229 | , $CONF["email04"] // return_path |
|---|
| 230 | , $CONF["email04"] // Errors_to |
|---|
| 231 | , $CONF["email01"] // Bcc |
|---|
| 232 | ); |
|---|
| 233 | // 宛先の設定 |
|---|
| 234 | $objMail->setTo($arrForm['email'], |
|---|
| 235 | $arrForm["name01"] . $arrForm["name02"] ." 様"); |
|---|
| 236 | |
|---|
| 237 | $objMail->sendMail(); |
|---|
| 238 | } |
|---|
| 239 | |
|---|
| 240 | /** |
|---|
| 241 | * kiyaku.php からの遷移の妥当性をチェックする |
|---|
| 242 | * |
|---|
| 243 | * 以下の内容をチェックし, 妥当であれば true を返す. |
|---|
| 244 | * 1. 規約ページからの遷移かどうか |
|---|
| 245 | * 2. PC及びスマートフォンかどうか |
|---|
| 246 | * 3. $post に何も含まれていないかどうか |
|---|
| 247 | * |
|---|
| 248 | * @access protected |
|---|
| 249 | * @param array $post $_POST のデータ |
|---|
| 250 | * @param string $referer $_SERVER['HTTP_REFERER'] のデータ |
|---|
| 251 | * @return boolean kiyaku.php からの妥当な遷移であれば true |
|---|
| 252 | */ |
|---|
| 253 | function lfCheckReferer(&$post, $referer){ |
|---|
| 254 | |
|---|
| 255 | if (SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE |
|---|
| 256 | && empty($post) |
|---|
| 257 | && (preg_match('/kiyaku.php/', basename($referer)) === 0)) { |
|---|
| 258 | return false; |
|---|
| 259 | } |
|---|
| 260 | return true; |
|---|
| 261 | } |
|---|
| 262 | } |
|---|