| 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
|
|---|
| 4 | *
|
|---|
| 5 | * http://www.lockon.co.jp/
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | require_once("../require.php");
|
|---|
| 9 |
|
|---|
| 10 | //---- ページ表示クラス
|
|---|
| 11 | class LC_Page {
|
|---|
| 12 |
|
|---|
| 13 | var $arrSession;
|
|---|
| 14 | var $tpl_mainpage;
|
|---|
| 15 | var $arrPref;
|
|---|
| 16 |
|
|---|
| 17 | function LC_Page() {
|
|---|
| 18 | $this->tpl_css = '/css/layout/regist/index.css'; // メインCSSパス
|
|---|
| 19 | }
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | $objConn = new SC_DBConn();
|
|---|
| 23 | $objPage = new LC_Page();
|
|---|
| 24 | $objView = new SC_MobileView();
|
|---|
| 25 | $objSiteInfo = $objView->objSiteInfo;
|
|---|
| 26 | $objCustomer = new SC_Customer();
|
|---|
| 27 | $CONF = sf_getBasisData();
|
|---|
| 28 | $arrInfo = $objSiteInfo->data;
|
|---|
| 29 |
|
|---|
| 30 | //-- 本登録完了のためにメールから接続した場合
|
|---|
| 31 | if ($_GET["mode"] == "regist") {
|
|---|
| 32 |
|
|---|
| 33 | //-- 入力チェック
|
|---|
| 34 | $objPage->arrErr = lfErrorCheck($_GET);
|
|---|
| 35 | if ($objPage->arrErr) {
|
|---|
| 36 | $objPage->tpl_mainpage = 'regist/error.tpl';
|
|---|
| 37 | $objPage->tpl_css = "/css/layout/regist/error.css";
|
|---|
| 38 | $objPage->tpl_title = 'エラー';
|
|---|
| 39 |
|
|---|
| 40 | } else {
|
|---|
| 41 | //$objPage->tpl_mainpage = 'regist/complete.tpl';
|
|---|
| 42 | //$objPage->tpl_title = ' 会員登録(完了ページ)';
|
|---|
| 43 | $registSecretKey = lfRegistData($_GET); //本会員登録(フラグ変更)
|
|---|
| 44 | lfSendRegistMail($registSecretKey); //本会員登録完了メール送信
|
|---|
| 45 |
|
|---|
| 46 | // ログイン済みの状態にする。
|
|---|
| 47 | $objQuery = new SC_Query();
|
|---|
| 48 | $email = $objQuery->get("dtb_customer", "email", "secret_key = ?", array($registSecretKey));
|
|---|
| 49 | $objCustomer->setLogin($email);
|
|---|
| 50 | header("Location: " . gfAddSessionId("./complete.php"));
|
|---|
| 51 | exit;
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | //-- それ以外のアクセスは無効とする
|
|---|
| 55 | } else {
|
|---|
| 56 | $objPage->arrErr["id"] = "無効なアクセスです。";
|
|---|
| 57 | $objPage->tpl_mainpage = 'regist/error.tpl';
|
|---|
| 58 | $objPage->tpl_css = "/css/layout/regist/error.css";
|
|---|
| 59 | $objPage->tpl_title = 'エラー';
|
|---|
| 60 |
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | //---- ページ表示
|
|---|
| 64 | $objView->assignobj($objPage);
|
|---|
| 65 | $objView->display(SITE_FRAME);
|
|---|
| 66 |
|
|---|
| 67 | //---- 登録
|
|---|
| 68 | function lfRegistData($array) {
|
|---|
| 69 | global $objConn;
|
|---|
| 70 | global $arrInfo;
|
|---|
| 71 |
|
|---|
| 72 | do {
|
|---|
| 73 | $secret = sfGetUniqRandomId("r");
|
|---|
| 74 | } while( ($result = $objConn->getOne("SELECT COUNT(*) FROM dtb_customer WHERE secret_key = ?", array($secret)) ) != 0);
|
|---|
| 75 |
|
|---|
| 76 | $sql = "SELECT email FROM dtb_customer WHERE secret_key = ? AND status = 1";
|
|---|
| 77 | $email = $objConn->getOne($sql, array($array["id"]));
|
|---|
| 78 |
|
|---|
| 79 | $objConn->query("BEGIN");
|
|---|
| 80 | $arrRegist["secret_key"] = $secret; // 本登録ID発行
|
|---|
| 81 | $arrRegist["status"] = 2;
|
|---|
| 82 | $arrRegist["update_date"] = "NOW()";
|
|---|
| 83 |
|
|---|
| 84 | $objQuery = new SC_Query();
|
|---|
| 85 | $where = "secret_key = ? AND status = 1";
|
|---|
| 86 |
|
|---|
| 87 | $arrRet = $objQuery->select("point", "dtb_customer", $where, array($array["id"]));
|
|---|
| 88 | // 会員登録時の加算ポイント(購入時会員登録の場合は、ポイント加算)
|
|---|
| 89 | $arrRegist['point'] = $arrRet[0]['point'] + addslashes($arrInfo['welcome_point']);
|
|---|
| 90 |
|
|---|
| 91 | $objQuery->update("dtb_customer", $arrRegist, $where, array($array["id"]));
|
|---|
| 92 |
|
|---|
| 93 | /* 購入時の自動会員登録は行わないためDEL
|
|---|
| 94 | // 購入時登録の場合、その回の購入を会員購入とみなす。
|
|---|
| 95 | // 会員情報の読み込み
|
|---|
| 96 | $where1 = "secret_key = ? AND status = 2";
|
|---|
| 97 | $customer = $objQuery->select("*", "dtb_customer", $where1, array($secret));
|
|---|
| 98 | // 初回購入情報の読み込み
|
|---|
| 99 | $order_temp_id = $objQuery->get("dtb_order_temp", "order_temp_id");
|
|---|
| 100 | // 購入情報の更新
|
|---|
| 101 | if ($order_temp_id != null) {
|
|---|
| 102 | $arrCustomer['customer_id'] = $customer[0]['customer_id'];
|
|---|
| 103 | $where3 = "order_temp_id = ?";
|
|---|
| 104 | $objQuery->update("dtb_order_temp", $arrCustomer, $where3, array($order_temp_id));
|
|---|
| 105 | $objQuery->update("dtb_order", $arrCustomer, $where3, array($order_temp_id));
|
|---|
| 106 | }
|
|---|
| 107 | */
|
|---|
| 108 |
|
|---|
| 109 | $sql = "SELECT mailmaga_flg FROM dtb_customer WHERE email = ?";
|
|---|
| 110 | $result = $objConn->getOne($sql, array($email));
|
|---|
| 111 |
|
|---|
| 112 | switch($result) {
|
|---|
| 113 | // 仮HTML
|
|---|
| 114 | case '4':
|
|---|
| 115 | $arrRegistMail["mailmaga_flg"] = 1;
|
|---|
| 116 | break;
|
|---|
| 117 | // 仮TEXT
|
|---|
| 118 | case '5':
|
|---|
| 119 | $arrRegistMail["mailmaga_flg"] = 2;
|
|---|
| 120 | break;
|
|---|
| 121 | // 仮なし
|
|---|
| 122 | case '6':
|
|---|
| 123 | $arrRegistMail["mailmaga_flg"] = 3;
|
|---|
| 124 | break;
|
|---|
| 125 | default:
|
|---|
| 126 | $arrRegistMail["mailmaga_flg"] = $result;
|
|---|
| 127 | break;
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | $objQuery->update("dtb_customer", $arrRegistMail, "email = '" .addslashes($email). "' AND del_flg = 0");
|
|---|
| 131 | $objConn->query("COMMIT");
|
|---|
| 132 |
|
|---|
| 133 | return $secret; // 本登録IDを返す
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | //---- 入力エラーチェック
|
|---|
| 137 | function lfErrorCheck($array) {
|
|---|
| 138 |
|
|---|
| 139 | global $objConn;
|
|---|
| 140 | $objErr = new SC_CheckError($array);
|
|---|
| 141 |
|
|---|
| 142 | $objErr->doFunc(array("仮登録ID", 'id'), array("EXIST_CHECK"));
|
|---|
| 143 | if (! EregI("^[[:alnum:]]+$",$array["id"] )) {
|
|---|
| 144 | $objErr->arrErr["id"] = "無効なURLです。メールに記載されている本会員登録用URLを再度ご確認ください。";
|
|---|
| 145 | }
|
|---|
| 146 | if (! $objErr->arrErr["id"]) {
|
|---|
| 147 |
|
|---|
| 148 | $sql = "SELECT customer_id FROM dtb_customer WHERE secret_key = ? AND status = 1 AND del_flg = 0";
|
|---|
| 149 | $result = $objConn->getOne($sql, array($array["id"]));
|
|---|
| 150 |
|
|---|
| 151 | if (! is_numeric($result)) {
|
|---|
| 152 | $objErr->arrErr["id"] .= "※ 既に会員登録が完了しているか、無効なURLです。<br>";
|
|---|
| 153 | return $objErr->arrErr;
|
|---|
| 154 |
|
|---|
| 155 | }
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | return $objErr->arrErr;
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | //---- 正会員登録完了メール送信
|
|---|
| 162 | function lfSendRegistMail($registSecretKey) {
|
|---|
| 163 | global $objConn;
|
|---|
| 164 | global $CONF;
|
|---|
| 165 |
|
|---|
| 166 | //-- 姓名を取得
|
|---|
| 167 | $sql = "SELECT email, name01, name02 FROM dtb_customer WHERE secret_key = ?";
|
|---|
| 168 | $result = $objConn->getAll($sql, array($registSecretKey));
|
|---|
| 169 | $data = $result[0];
|
|---|
| 170 |
|
|---|
| 171 | //-- メール送信
|
|---|
| 172 | $objMailText = new SC_MobileView();
|
|---|
| 173 | $objMailText->assign("CONF", $CONF);
|
|---|
| 174 | $objMailText->assign("name01", $data["name01"]);
|
|---|
| 175 | $objMailText->assign("name02", $data["name02"]);
|
|---|
| 176 | $toCustomerMail = $objMailText->fetch("mail_templates/customer_regist_mail.tpl");
|
|---|
| 177 | $subject = sfMakeSubject('本会員登録が完了しました。');
|
|---|
| 178 | $objMail = new GC_SendMail();
|
|---|
| 179 |
|
|---|
| 180 | $objMail->setItem(
|
|---|
| 181 | '' // 宛先
|
|---|
| 182 | , $subject//"【" .$CONF["shop_name"]. "】".ENTRY_CUSTOMER_REGIST_SUBJECT // サブジェクト
|
|---|
| 183 | , $toCustomerMail // 本文
|
|---|
| 184 | , $CONF["email03"] // 配送元アドレス
|
|---|
| 185 | , $CONF["shop_name"] // 配送元 名前
|
|---|
| 186 | , $CONF["email03"] // reply_to
|
|---|
| 187 | , $CONF["email04"] // return_path
|
|---|
| 188 | , $CONF["email04"] // Errors_to
|
|---|
| 189 | );
|
|---|
| 190 | // 宛先の設定
|
|---|
| 191 | $name = $data["name01"] . $data["name02"] ." 様";
|
|---|
| 192 | $objMail->setTo($data["email"], $name);
|
|---|
| 193 | $objMail->sendMail();
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | ?>
|
|---|