source: branches/feature-module-update/html/regist/index.php @ 15078

Revision 15078, 6.1 KB checked in by nanasess, 17 years ago (diff)

r15064 から svn cp
とりあえず暫定コミット.

  • UTF-8 に変更
  • slib.php, glib.php のクラス化
  • LC_Page の抽象化(一部)
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 $objQuery;
75    global $objConn;
76    global $arrInfo;
77   
78    do {
79        $secret = sfGetUniqRandomId("r");
80    } while( ($result = $objConn->getOne("SELECT COUNT(*) FROM dtb_customer WHERE secret_key = ?", array($secret)) ) != 0);
81
82    $sql = "SELECT email FROM dtb_customer WHERE secret_key = ? AND status = 1";
83    $email = $objConn->getOne($sql, array($array["id"]));
84
85    $objConn->query("BEGIN");
86    $arrRegist["secret_key"] = $secret; // 本登録ID発行
87    $arrRegist["status"] = 2;
88    $arrRegist["update_date"] = "NOW()";
89   
90    $objQuery = new SC_Query();
91    $where = "secret_key = ? AND status = 1";
92   
93    $arrRet = $objQuery->select("point", "dtb_customer", $where, array($array["id"]));
94    // 会員登録時の加算ポイント(購入時会員登録の場合は、ポイント加算)
95    $arrRegist['point'] = $arrRet[0]['point'] + addslashes($arrInfo['welcome_point']);
96   
97    $objQuery->update("dtb_customer", $arrRegist, $where, array($array["id"]));
98
99    /* 購入時の自動会員登録は行わないためDEL
100    // 購入時登録の場合、その回の購入を会員購入とみなす。
101    // 会員情報の読み込み
102    $where1 = "secret_key = ? AND status = 2";
103    $customer = $objQuery->select("*", "dtb_customer", $where1, array($secret));
104    // 初回購入情報の読み込み
105    $order_temp_id = $objQuery->get("dtb_order_temp", "order_temp_id");
106    // 購入情報の更新
107    if ($order_temp_id != null) {
108        $arrCustomer['customer_id'] = $customer[0]['customer_id'];
109        $where3 = "order_temp_id = ?";
110        $objQuery->update("dtb_order_temp", $arrCustomer, $where3, array($order_temp_id));
111        $objQuery->update("dtb_order", $arrCustomer, $where3, array($order_temp_id));
112    }
113    */
114
115    $sql = "SELECT mailmaga_flg FROM dtb_customer WHERE email = ?";
116    $result = $objConn->getOne($sql, array($email));
117   
118    switch($result) {
119    // 仮HTML
120    case '4':
121        $arrRegistMail["mailmaga_flg"] = 1;
122        break;
123    // 仮TEXT
124    case '5':
125        $arrRegistMail["mailmaga_flg"] = 2;
126        break;
127    // 仮なし
128    case '6':
129        $arrRegistMail["mailmaga_flg"] = 3;
130        break;
131    default:
132        $arrRegistMail["mailmaga_flg"] = $result;
133        break;
134    }
135
136    $objQuery->update("dtb_customer", $arrRegistMail, "email = '" .addslashes($email). "' AND del_flg = 0");
137    $objConn->query("COMMIT");
138       
139    return $secret;     // 本登録IDを返す
140}
141
142//---- 入力エラーチェック
143function lfErrorCheck($array) {
144
145    global $objConn;
146    $objErr = new SC_CheckError($array);
147
148    $objErr->doFunc(array("仮登録ID", 'id'), array("EXIST_CHECK"));
149    if (! EregI("^[[:alnum:]]+$",$array["id"] )) {
150        $objErr->arrErr["id"] = "無効なURLです。メールに記載されている本会員登録用URLを再度ご確認ください。";
151    }
152    if (! $objErr->arrErr["id"]) {
153
154        $sql = "SELECT customer_id FROM dtb_customer WHERE secret_key = ? AND status = 1 AND del_flg = 0";
155        $result = $objConn->getOne($sql, array($array["id"]));
156
157        if (! is_numeric($result)) {
158            $objErr->arrErr["id"] .= "※ 既に会員登録が完了しているか、無効なURLです。<br>";
159            return $objErr->arrErr;
160
161        }
162    }
163
164    return $objErr->arrErr;
165}
166
167//---- 正会員登録完了メール送信
168function lfSendRegistMail($registSecretKey) {
169    global $objConn;
170    global $CONF;
171
172    //-- 姓名を取得
173    $sql = "SELECT email, name01, name02 FROM dtb_customer WHERE secret_key = ?";
174    $result = $objConn->getAll($sql, array($registSecretKey));
175    $data = $result[0];
176   
177    //-- メール送信
178    $objMailText = new SC_SiteView();
179    $objMailText->assign("CONF", $CONF);
180    $objMailText->assign("name01", $data["name01"]);
181    $objMailText->assign("name02", $data["name02"]);
182    $toCustomerMail = $objMailText->fetch("mail_templates/customer_regist_mail.tpl");
183    $subject = sfMakeSubject('会員登録が完了しました。');
184    $objMail = new GC_SendMail();
185
186    $objMail->setItem(
187                          ''                                // 宛先
188                        , $subject//"【" .$CONF["shop_name"]. "】".ENTRY_CUSTOMER_REGIST_SUBJECT      // サブジェクト
189                        , $toCustomerMail                   // 本文
190                        , $CONF["email03"]                  // 配送元アドレス
191                        , $CONF["shop_name"]                // 配送元 名前
192                        , $CONF["email03"]                  // reply_to
193                        , $CONF["email04"]                  // return_path
194                        , $CONF["email04"]                  //  Errors_to
195                    );
196    // 宛先の設定
197    $name = $data["name01"] . $data["name02"] ." 様";
198    $objMail->setTo($data["email"], $name);
199    $objMail->sendMail();
200}
201
202?>
Note: See TracBrowser for help on using the repository browser.