Changeset 20095
- Timestamp:
- 2011/02/04 18:46:46 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/class/pages/entry/LC_Page_Entry.php
r20089 r20095 104 104 $this->objFormParam->addParam("メールマガジン", "mailmaga_flg", INT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK")); 105 105 106 if ( $this->isMobile === false){106 if (SC_Display::detectDevice() !== DEVICE_TYPE_MOBILE){ 107 107 $this->objFormParam->addParam("FAX番号1", 'fax01', TEL_ITEM_LEN, "n", array("SPTAB_CHECK")); 108 108 $this->objFormParam->addParam("FAX番号2", 'fax02', TEL_ITEM_LEN, "n", array("SPTAB_CHECK")); … … 121 121 */ 122 122 function action() { 123 $this->lfPreMode(); 123 // PC時は規約ページからの遷移でなければエラー画面へ遷移する 124 if ($this->lfCheckReferer($_POST, $_SERVER['HTTP_REFERER']) === false) { 125 SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true); 126 } 127 128 // mobile用(戻るボタンでの遷移かどうかを判定) 129 if (!empty($_POST["return"])) { 130 $_POST["mode"] = "return"; 131 } 132 133 if ($_SERVER["REQUEST_METHOD"] == "POST") { 134 if (!SC_Helper_Session_Ex::isValidToken()) { 135 SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true); 136 } 137 } 138 139 $this->objFormParam->setParam($_POST); // POST値の取得 140 $this->objFormParam->convParam(); 141 $this->objFormParam->toLower('email'); 142 $this->objFormParam->toLower('email02'); 124 143 $this->arrForm = $this->objFormParam->getHashArray(); 125 144 126 145 switch ($this->getMode()) { 127 146 case 'confirm': 128 //-- 確認129 $this->arrErr = $this->lfErrorCheck( );147 //-- 確認 148 $this->arrErr = $this->lfErrorCheck($this->arrForm); 130 149 // 入力エラーなし 131 150 if(empty($this->arrErr)) { … … 139 158 case 'complete': 140 159 //-- 会員登録と完了画面 141 $this->arrErr = $this->lfErrorCheck( );160 $this->arrErr = $this->lfErrorCheck($this->arrForm); 142 161 if(empty($this->arrErr)) { 143 $uniqid = $this->lfRegistData( );162 $uniqid = $this->lfRegistData($this->arrForm, $this->objFormParam->getDbArray()); 144 163 145 164 $this->tpl_mainpage = 'entry/complete.tpl'; 146 165 $this->tpl_title = '会員登録(完了ページ)'; 147 148 $this->lfSendMail($uniqid); 166 $this->lfSendMail($uniqid, $this->arrForm); 167 168 // 仮会員が無効の場合 169 if(CUSTOMER_CONFIRM_MAIL == false) { 170 // ログイン状態にする 171 $objCustomer = new SC_Customer(); 172 $objCustomer->setLogin($this->arrForm["email"]); 173 } 149 174 150 175 // 完了ページに移動させる。 … … 170 195 // }}} 171 196 // {{{ protected functions 172 173 174 /**175 * lfPreMode197 /** 198 * lfRegistData 199 * 200 * 会員情報の登録 176 201 * 177 202 * @access public 178 203 * @return void 179 204 */ 180 function lfPreMode() { 181 // PC時は規約ページからの遷移でなければエラー画面へ遷移する 182 $this->lfCheckReferer(); 183 184 // mobile用(戻るボタンでの遷移かどうかを判定) 185 if (!empty($_POST["return"])) { 186 $_POST["mode"] = "return"; 187 } 188 189 //CSRF対策 190 $this->lfCheckCSRF(); 191 192 $this->objFormParam->setParam($_POST); // POST値の取得 193 $this->objFormParam->convParam(); 194 $this->objFormParam->toLower('email'); 195 $this->objFormParam->toLower('email02'); 196 } 197 198 199 /** 200 * lfRegistData 201 * 202 * 会員情報の登録 203 * 204 * @access public 205 * @return void 206 */ 207 function lfRegistData() { 208 $objQuery = new SC_Query(); 205 function lfRegistData($arrForm, $arrResults) { 206 $objQuery = SC_Query::getSingletonInstance(); 209 207 //-- 登録実行 210 $sqlval = $this->lfMakeSqlVal( );208 $sqlval = $this->lfMakeSqlVal($arrForm, $arrResults); 211 209 $objQuery->begin(); 212 210 SC_Helper_Customer_Ex::sfEditCustomerData($sqlval); … … 218 216 219 217 /** 220 * lfMakeSqlVal 221 * 222 * 会員登録に必要なsqlを作成する 218 * 会員登録に必要なSQLパラメータの配列を生成する. 219 * 220 * フォームに入力された情報を元に, SQLパラメータの配列を生成する. 221 * モバイル端末の場合は, email を email_mobile にコピーし, 222 * mobile_phone_id に携帯端末IDを格納する. 223 * 224 * @access protected 225 * @param array $arrForm フォームパラメータの配列 226 * @param array $arrResults 結果用の配列. SC_FormParam::getDbArray() の結果 227 * @return array SQLパラメータの配列 228 * @see SC_FormParam::getDbArray() 229 */ 230 function lfMakeSqlVal($arrForm, $arrResults) { 231 // 生年月日の作成 232 $arrResults['birth'] = SC_Utils_Ex::sfGetTimestamp($arrForm['year'], $arrForm['month'], $arrForm['day']); 233 234 // 仮会員 1 本会員 2 235 $arrResults["status"] = (CUSTOMER_CONFIRM_MAIL == true) ? "1" : "2"; 236 237 /* 238 * secret_keyは、テーブルで重複許可されていない場合があるので、 239 * 本会員登録では利用されないがセットしておく。 240 */ 241 $arrResults["secret_key"] = SC_Helper_Customer_Ex::sfGetUniqSecretKey(); 242 243 // 入会時ポイント 244 $CONF = SC_Helper_DB_Ex::sfGetBasisData(); 245 $arrResults["point"] = $CONF["welcome_point"]; 246 247 if (SC_Display::detectDevice() == DEVICE_TYPE_MOBILE) { 248 // 携帯メールアドレス 249 $arrResults['email_mobile'] = $arrResults['email']; 250 // PHONE_IDを取り出す 251 $arrResults['mobile_phone_id'] = SC_MobileUserAgent::getId(); 252 } 253 return $arrResults; 254 } 255 256 257 /** 258 * 会員登録完了メール送信する 223 259 * 224 260 * @access public 225 261 * @return void 226 262 */ 227 function lfMakeSqlVal() { 228 $arrRet = $this->objFormParam->getHashArray(); 229 $sqlval = $this->objFormParam->getDbArray(); 230 231 // 登録データの作成 232 $sqlval['birth'] = SC_Utils_Ex::sfGetTimestamp($arrRet['year'], $arrRet['month'], $arrRet['day']); 233 234 // 仮会員 1 本会員 2 235 $sqlval["status"] = (CUSTOMER_CONFIRM_MAIL == true) ? "1" : "2"; 236 237 /* 238 secret_keyは、テーブルで重複許可されていない場合があるので、 239 本会員登録では利用されないがセットしておく。 240 */ 241 $sqlval["secret_key"] = SC_Helper_Customer_Ex::sfGetUniqSecretKey(); // 会員登録キー 242 243 $CONF = SC_Helper_DB_Ex::sfGetBasisData(); 244 $sqlval["point"] = $CONF["welcome_point"]; // 入会時ポイント 245 246 if ($this->isMobile === true) { 247 // 携帯メールアドレス 248 $sqlval['email_mobile'] = $sqlval['email']; 249 //PHONE_IDを取り出す 250 $sqlval['mobile_phone_id'] = SC_MobileUserAgent::getId(); 251 } 252 253 return $sqlval; 254 } 255 256 257 /** 258 * lfSendMail 259 * 260 * @access public 261 * @return void 262 */ 263 function lfSendMail($uniqid){ 264 // 完了メール送信 265 $arrRet = $this->objFormParam->getHashArray(); 266 $this->name01 = $arrRet['name01']; 267 $this->name02 = $arrRet['name02']; 268 $this->uniqid = $uniqid; 263 function lfSendMail($uniqid, $arrForm){ 269 264 $CONF = SC_Helper_DB_Ex::sfGetBasisData(); 270 $this->CONF = $CONF; 265 271 266 $objMailText = new SC_SiteView(); 267 $objMailText->assign("CONF", $CONF); 268 $objMailText->assign("name01", $arrForm['name01']); 269 $objMailText->assign("name02", $arrForm['name02']); 270 $objMailText->assign("uniqid", $uniqid); 272 271 $objMailText->assignobj($this); 273 272 … … 276 275 // 仮会員が有効の場合 277 276 if(CUSTOMER_CONFIRM_MAIL == true) { 278 $subject = $objHelperMail->sfMakeSubject('会員登録のご確認');277 $subject = $objHelperMail->sfMakeSubject('会員登録のご確認'); 279 278 $toCustomerMail = $objMailText->fetch("mail_templates/customer_mail.tpl"); 280 279 } else { 281 $subject = $objHelperMail->sfMakeSubject('会員登録のご完了');280 $subject = $objHelperMail->sfMakeSubject('会員登録のご完了'); 282 281 $toCustomerMail = $objMailText->fetch("mail_templates/customer_regist_mail.tpl"); 283 // ログイン状態にする284 $objCustomer = new SC_Customer();285 $objCustomer->setLogin($arrRet["email"]);286 282 } 287 283 288 284 $objMail = new SC_SendMail(); 289 285 $objMail->setItem( 290 291 292 293 294 295 296 297 298 286 '' // 宛先 287 , $subject // サブジェクト 288 , $toCustomerMail // 本文 289 , $CONF["email03"] // 配送元アドレス 290 , $CONF["shop_name"] // 配送元 名前 291 , $CONF["email03"] // reply_to 292 , $CONF["email04"] // return_path 293 , $CONF["email04"] // Errors_to 294 , $CONF["email01"] // Bcc 299 295 ); 300 296 // 宛先の設定 301 $name = $arrRet["name01"] . $arrRet["name02"] ." 様"; 302 $objMail->setTo($arrRet["email"], $name); 297 $objMail->setTo($arrForm["email"], 298 $arrForm["name01"] . $arrForm["name02"] ." 様"); 299 303 300 $objMail->sendMail(); 304 301 } … … 313 310 * @return void 314 311 */ 315 function lfErrorCheck($arr ay) {312 function lfErrorCheck($arrForm) { 316 313 317 314 // 入力データを渡す。 318 $arrRet = $this->objFormParam->getHashArray(); 319 $objErr = new SC_CheckError($arrRet); 315 $objErr = new SC_CheckError($arrForm); 320 316 $objErr->arrErr = $this->objFormParam->checkError(); 321 317 … … 323 319 $objErr->doFunc(array("郵便番号", "zip01", "zip02"), array("ALL_EXIST_CHECK")); 324 320 $objErr->doFunc(array("生年月日", "year", "month", "day"), array("CHECK_BIRTHDAY")); 325 if ($this->isMobile === false){ 321 322 if (SC_Display::detectDevice() !== DEVICE_TYPE_MOBILE){ 326 323 $objErr->doFunc(array('パスワード', 'パスワード(確認)', "password", "password02") ,array("EQUAL_CHECK")); 327 324 $objErr->doFunc(array('メールアドレス', 'メールアドレス(確認)', "email", "email02") ,array("EQUAL_CHECK")); … … 336 333 337 334 /** 338 * lfCheckReferer 339 * 340 * @access public 341 * @return void 342 */ 343 function lfCheckReferer(){ 344 /** 345 * 規約ページからの遷移でなければエラー画面へ遷移する 346 */ 347 if ($this->isMobile === FALSE 348 && empty($_POST) 349 && !preg_match('/kiyaku.php/', basename($_SERVER['HTTP_REFERER'])) 350 ) { 351 SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true); 352 } 353 } 354 355 356 /** 357 * lfCheckCSRF 358 * 359 * @access public 360 * @return void 361 */ 362 function lfCheckCSRF() { 363 if ($_SERVER["REQUEST_METHOD"] == "POST") { 364 if (!SC_Helper_Session_Ex::isValidToken()) { 365 SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true); 335 * kiyaku.php からの遷移の妥当性をチェックする 336 * 337 * 以下の内容をチェックし, 妥当であれば true を返す. 338 * 1. 規約ページからの遷移かどうか 339 * 2. PC及びスマートフォンかどうか 340 * 3. $post に何も含まれていないかどうか 341 * 342 * @access protected 343 * @param array $post $_POST のデータ 344 * @param string $referer $_SERVER['HTTP_REFERER'] のデータ 345 * @return boolean kiyaku.php からの妥当な遷移であれば true 346 */ 347 function lfCheckReferer(&$post, $referer){ 348 349 if (SC_Display::detectDevice() !== DEVICE_TYPE_MOBILE 350 && empty($post) 351 && (preg_match('/kiyaku.php/', basename($referer)) === 0)) { 352 return false; 366 353 } 367 }354 return true; 368 355 } 369 356 }
Note: See TracChangeset
for help on using the changeset viewer.