| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * This file is part of EC-CUBE |
|---|
| 4 | * |
|---|
| 5 | * Copyright(c) 2000-2007 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_PATH . "pages/LC_Page.php"); |
|---|
| 26 | |
|---|
| 27 | /** |
|---|
| 28 | * 会員登録のページクラス. |
|---|
| 29 | * |
|---|
| 30 | * @package Page |
|---|
| 31 | * @author LOCKON CO.,LTD. |
|---|
| 32 | * @version $Id$ |
|---|
| 33 | */ |
|---|
| 34 | class LC_Page_Regist extends LC_Page { |
|---|
| 35 | |
|---|
| 36 | // {{{ properties |
|---|
| 37 | |
|---|
| 38 | /** ページ情報の配列 */ |
|---|
| 39 | var $arrInfo; |
|---|
| 40 | |
|---|
| 41 | /** 設定情報 */ |
|---|
| 42 | var $CONF; |
|---|
| 43 | |
|---|
| 44 | // }}} |
|---|
| 45 | // {{{ functions |
|---|
| 46 | |
|---|
| 47 | /** |
|---|
| 48 | * Page を初期化する. |
|---|
| 49 | * |
|---|
| 50 | * @return void |
|---|
| 51 | */ |
|---|
| 52 | function init() { |
|---|
| 53 | parent::init(); |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | /** |
|---|
| 57 | * Page のプロセス. |
|---|
| 58 | * |
|---|
| 59 | * @return void |
|---|
| 60 | */ |
|---|
| 61 | function process() { |
|---|
| 62 | $objQuery = new SC_Query(); |
|---|
| 63 | $objView = new SC_SiteView(); |
|---|
| 64 | $objSiteInfo = $objView->objSiteInfo; |
|---|
| 65 | $objCustomer = new SC_Customer(); |
|---|
| 66 | $objDb = new SC_Helper_DB_Ex(); |
|---|
| 67 | $this->CONF = $objDb->sf_getBasisData(); |
|---|
| 68 | $this->arrInfo = $objSiteInfo->data; |
|---|
| 69 | |
|---|
| 70 | // キャンペーンからの登録の場合の処理 |
|---|
| 71 | |
|---|
| 72 | if(!empty($_GET["cp"])) { |
|---|
| 73 | $etc_val = array("cp" => $_GET['cp']); |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | //-- 本登録完了のためにメールから接続した場合 |
|---|
| 77 | if ($_GET["mode"] == "regist") { |
|---|
| 78 | |
|---|
| 79 | //-- 入力チェック |
|---|
| 80 | $this->arrErr = $this->lfErrorCheck($_GET); |
|---|
| 81 | if ($this->arrErr) { |
|---|
| 82 | SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, "", true, $this->arrErr["id"]); |
|---|
| 83 | } else { |
|---|
| 84 | $registSecretKey = $this->lfRegistData($_GET); //本会員登録(フラグ変更) |
|---|
| 85 | $this->lfSendRegistMail($registSecretKey); //本会員登録完了メール送信 |
|---|
| 86 | |
|---|
| 87 | // ログイン済みの状態にする。 |
|---|
| 88 | $email = $objQuery->get("dtb_customer", "email", "secret_key = ?", array($registSecretKey)); |
|---|
| 89 | $objCustomer->setLogin($email); |
|---|
| 90 | $this->sendRedirect($this->getLocation("./complete.php", $etc_val)); |
|---|
| 91 | exit; |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | //-- それ以外のアクセスは無効とする |
|---|
| 95 | } else { |
|---|
| 96 | SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, "", true, "無効なアクセスです。"); |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | //---- ページ表示 |
|---|
| 100 | $objView->assignobj($this); |
|---|
| 101 | $objView->display(SITE_FRAME); |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | /** |
|---|
| 106 | * モバイルページを初期化する. |
|---|
| 107 | * |
|---|
| 108 | * @return void |
|---|
| 109 | */ |
|---|
| 110 | function mobileInit() { |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | /** |
|---|
| 114 | * Page のプロセス(モバイル). |
|---|
| 115 | * |
|---|
| 116 | * @return void |
|---|
| 117 | */ |
|---|
| 118 | function mobileProcess() { |
|---|
| 119 | $objQuery = new SC_Query(); |
|---|
| 120 | $objView = new SC_MobileView(); |
|---|
| 121 | $objSiteInfo = $objView->objSiteInfo; |
|---|
| 122 | $objCustomer = new SC_Customer(); |
|---|
| 123 | $objDb = new SC_Helper_DB_Ex(); |
|---|
| 124 | $this->CONF = $objDb->sf_getBasisData(); |
|---|
| 125 | $arrInfo = $objSiteInfo->data; |
|---|
| 126 | |
|---|
| 127 | //-- 本登録完了のためにメールから接続した場合 |
|---|
| 128 | if ($_GET["mode"] == "regist") { |
|---|
| 129 | |
|---|
| 130 | //-- 入力チェック |
|---|
| 131 | $this->arrErr = $this->lfErrorCheck($_GET); |
|---|
| 132 | if ($this->arrErr) { |
|---|
| 133 | $this->tpl_mainpage = 'regist/error.tpl'; |
|---|
| 134 | $this->tpl_title = 'エラー'; |
|---|
| 135 | |
|---|
| 136 | } else { |
|---|
| 137 | $registSecretKey = $this->lfRegistData($_GET); //本会員登録(フラグ変更) |
|---|
| 138 | $this->lfSendRegistMail($registSecretKey); //本会員登録完了メール送信 |
|---|
| 139 | |
|---|
| 140 | // ログイン済みの状態にする。 |
|---|
| 141 | |
|---|
| 142 | $email = $objQuery->get("dtb_customer", "email", "secret_key = ?", array($registSecretKey)); |
|---|
| 143 | $objCustomer->setLogin($email); |
|---|
| 144 | $this->sendRedirect($this->getLocation("./complete.php"), true); |
|---|
| 145 | exit; |
|---|
| 146 | } |
|---|
| 147 | |
|---|
| 148 | //-- それ以外のアクセスは無効とする |
|---|
| 149 | } else { |
|---|
| 150 | $this->arrErr["id"] = "無効なアクセスです。"; |
|---|
| 151 | $this->tpl_mainpage = 'regist/error.tpl'; |
|---|
| 152 | $this->tpl_title = 'エラー'; |
|---|
| 153 | } |
|---|
| 154 | |
|---|
| 155 | //---- ページ表示 |
|---|
| 156 | $objView->assignobj($this); |
|---|
| 157 | $objView->display(SITE_FRAME); |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | /** |
|---|
| 161 | * デストラクタ. |
|---|
| 162 | * |
|---|
| 163 | * @return void |
|---|
| 164 | */ |
|---|
| 165 | function destroy() { |
|---|
| 166 | parent::destroy(); |
|---|
| 167 | } |
|---|
| 168 | |
|---|
| 169 | //---- 登録 |
|---|
| 170 | function lfRegistData($array) { |
|---|
| 171 | $objQuery = new SC_Query(); |
|---|
| 172 | $this->arrInfo; |
|---|
| 173 | |
|---|
| 174 | do { |
|---|
| 175 | $secret = SC_Utils_Ex::sfGetUniqRandomId("r"); |
|---|
| 176 | } while( ($result = $objQuery->getOne("SELECT COUNT(*) FROM dtb_customer WHERE secret_key = ?", array($secret)) ) != 0); |
|---|
| 177 | |
|---|
| 178 | $sql = "SELECT email FROM dtb_customer WHERE secret_key = ? AND status = 1"; |
|---|
| 179 | $email = $objQuery->getOne($sql, array($array["id"])); |
|---|
| 180 | |
|---|
| 181 | $objQuery->begin(); |
|---|
| 182 | $arrRegist["secret_key"] = $secret; // 本登録ID発行 |
|---|
| 183 | $arrRegist["status"] = 2; |
|---|
| 184 | $arrRegist["update_date"] = "NOW()"; |
|---|
| 185 | |
|---|
| 186 | $where = "secret_key = ? AND status = 1"; |
|---|
| 187 | |
|---|
| 188 | $arrRet = $objQuery->select("point", "dtb_customer", $where, array($array["id"])); |
|---|
| 189 | // 会員登録時の加算ポイント(購入時会員登録の場合は、ポイント加算) |
|---|
| 190 | $arrRegist['point'] = $arrRet[0]['point'] + $arrInfo['welcome_point']; |
|---|
| 191 | |
|---|
| 192 | $objQuery->update("dtb_customer", $arrRegist, $where, array($array["id"])); |
|---|
| 193 | |
|---|
| 194 | /* 購入時の自動会員登録は行わないためDEL |
|---|
| 195 | // 購入時登録の場合、その回の購入を会員購入とみなす。 |
|---|
| 196 | // 会員情報の読み込み |
|---|
| 197 | $where1 = "secret_key = ? AND status = 2"; |
|---|
| 198 | $customer = $objQuery->select("*", "dtb_customer", $where1, array($secret)); |
|---|
| 199 | // 初回購入情報の読み込み |
|---|
| 200 | $order_temp_id = $objQuery->get("dtb_order_temp", "order_temp_id"); |
|---|
| 201 | // 購入情報の更新 |
|---|
| 202 | if ($order_temp_id != null) { |
|---|
| 203 | $arrCustomer['customer_id'] = $customer[0]['customer_id']; |
|---|
| 204 | $where3 = "order_temp_id = ?"; |
|---|
| 205 | $objQuery->update("dtb_order_temp", $arrCustomer, $where3, array($order_temp_id)); |
|---|
| 206 | $objQuery->update("dtb_order", $arrCustomer, $where3, array($order_temp_id)); |
|---|
| 207 | } |
|---|
| 208 | */ |
|---|
| 209 | |
|---|
| 210 | $sql = "SELECT mailmaga_flg FROM dtb_customer WHERE email = ?"; |
|---|
| 211 | $result = $objQuery->getOne($sql, array($email)); |
|---|
| 212 | |
|---|
| 213 | switch($result) { |
|---|
| 214 | // 仮HTML |
|---|
| 215 | case '4': |
|---|
| 216 | $arrRegistMail["mailmaga_flg"] = 1; |
|---|
| 217 | break; |
|---|
| 218 | // 仮TEXT |
|---|
| 219 | case '5': |
|---|
| 220 | $arrRegistMail["mailmaga_flg"] = 2; |
|---|
| 221 | break; |
|---|
| 222 | // 仮なし |
|---|
| 223 | case '6': |
|---|
| 224 | $arrRegistMail["mailmaga_flg"] = 3; |
|---|
| 225 | break; |
|---|
| 226 | default: |
|---|
| 227 | $arrRegistMail["mailmaga_flg"] = $result; |
|---|
| 228 | break; |
|---|
| 229 | } |
|---|
| 230 | |
|---|
| 231 | $objQuery->update("dtb_customer", $arrRegistMail, "email = " . SC_Utils_Ex::sfQuoteSmart($email). " AND del_flg = 0"); |
|---|
| 232 | $objQuery->commit(); |
|---|
| 233 | |
|---|
| 234 | return $secret; // 本登録IDを返す |
|---|
| 235 | } |
|---|
| 236 | |
|---|
| 237 | //---- 入力エラーチェック |
|---|
| 238 | function lfErrorCheck($array) { |
|---|
| 239 | |
|---|
| 240 | $objQuery = new SC_Query(); |
|---|
| 241 | $objErr = new SC_CheckError($array); |
|---|
| 242 | |
|---|
| 243 | $objErr->doFunc(array("仮登録ID", 'id'), array("EXIST_CHECK")); |
|---|
| 244 | if (! EregI("^[[:alnum:]]+$",$array["id"] )) { |
|---|
| 245 | $objErr->arrErr["id"] = "無効なURLです。メールに記載されている本会員登録用URLを再度ご確認ください。"; |
|---|
| 246 | } |
|---|
| 247 | if (! $objErr->arrErr["id"]) { |
|---|
| 248 | |
|---|
| 249 | $sql = "SELECT customer_id FROM dtb_customer WHERE secret_key = ? AND status = 1 AND del_flg = 0"; |
|---|
| 250 | $result = $objQuery->getOne($sql, array($array["id"])); |
|---|
| 251 | |
|---|
| 252 | if (! is_numeric($result)) { |
|---|
| 253 | $objErr->arrErr["id"] = "※ 既に会員登録が完了しているか、無効なURLです。<br>"; |
|---|
| 254 | return $objErr->arrErr; |
|---|
| 255 | |
|---|
| 256 | } |
|---|
| 257 | } |
|---|
| 258 | |
|---|
| 259 | return $objErr->arrErr; |
|---|
| 260 | } |
|---|
| 261 | |
|---|
| 262 | //---- 正会員登録完了メール送信 |
|---|
| 263 | function lfSendRegistMail($registSecretKey) { |
|---|
| 264 | $objQuery = new SC_Query(); |
|---|
| 265 | $objHelperMail = new SC_Helper_Mail_Ex(); |
|---|
| 266 | |
|---|
| 267 | //-- 姓名を取得 |
|---|
| 268 | $sql = "SELECT email, name01, name02 FROM dtb_customer WHERE secret_key = ?"; |
|---|
| 269 | $result = $objQuery->getAll($sql, array($registSecretKey)); |
|---|
| 270 | $data = $result[0]; |
|---|
| 271 | |
|---|
| 272 | //-- メール送信 |
|---|
| 273 | $objMailText = new SC_SiteView(); |
|---|
| 274 | $objMailText->assign("CONF", $this->CONF); |
|---|
| 275 | $objMailText->assign("name01", $data["name01"]); |
|---|
| 276 | $objMailText->assign("name02", $data["name02"]); |
|---|
| 277 | $toCustomerMail = $objMailText->fetch("mail_templates/customer_regist_mail.tpl"); |
|---|
| 278 | $subject = $objHelperMail->sfMakesubject($objQuery, $objMailText, $this, '会員登録が完了しました。'); |
|---|
| 279 | $objMail = new SC_SendMail(); |
|---|
| 280 | |
|---|
| 281 | $objMail->setItem( |
|---|
| 282 | '' // 宛先 |
|---|
| 283 | , $subject // サブジェクト |
|---|
| 284 | , $toCustomerMail // 本文 |
|---|
| 285 | , $this->CONF["email03"] // 配送元アドレス |
|---|
| 286 | , $this->CONF["shop_name"] // 配送元 名前 |
|---|
| 287 | , $this->CONF["email03"] // reply_to |
|---|
| 288 | , $this->CONF["email04"] // return_path |
|---|
| 289 | , $this->CONF["email04"] // Errors_to |
|---|
| 290 | ); |
|---|
| 291 | // 宛先の設定 |
|---|
| 292 | $name = $data["name01"] . $data["name02"] ." 様"; |
|---|
| 293 | $objMail->setTo($data["email"], $name); |
|---|
| 294 | $objMail->sendMail(); |
|---|
| 295 | } |
|---|
| 296 | } |
|---|
| 297 | ?> |
|---|