source: branches/comu/html/regist/index.php @ 11729

Revision 11729, 6.1 KB checked in by nanasess, 20 years ago (diff)

UTF-8 へ変換

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