source: temp/trunk/html/regist/index.php @ 1328

Revision 1328, 5.7 KB checked in by naka, 20 years ago (diff)

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2
3require_once("../require.php");
4
5//---- ¥Ú¡¼¥¸É½¼¨¥¯¥é¥¹
6class LC_Page {
7   
8    var $arrSession;
9    var $tpl_mainpage;
10    var $arrPref;
11
12    function LC_Page() {
13        $this->tpl_css = '/css/layout/regist/index.css';    // ¥á¥¤¥óCSS¥Ñ¥¹
14    }
15}
16
17$objConn = new SC_DBConn();
18$objPage = new LC_Page();
19$objView = new SC_SiteView();
20$objSiteInfo = new SC_SiteInfo();
21$objCustomer = new SC_Customer();
22$CONF = sf_getBasisData();
23$arrInfo = $objSiteInfo->data;
24
25//--¡¡ËÜÅÐÏ¿´°Î»¤Î¤¿¤á¤Ë¥á¡¼¥ë¤«¤éÀܳ¤·¤¿¾ì¹ç
26if ($_GET["mode"] == "regist") {
27   
28    //-- ÆþÎÏ¥Á¥§¥Ã¥¯
29    $objPage->arrErr = lfErrorCheck($_GET);
30    if ($objPage->arrErr) {
31        $objPage->tpl_mainpage = 'regist/error.tpl';
32        $objPage->tpl_css = "/css/layout/regist/error.css";
33        $objPage->tpl_title = '¥¨¥é¡¼';
34
35    } else {
36        //$objPage->tpl_mainpage = 'regist/complete.tpl';
37        //$objPage->tpl_title = ' ²ñ°÷ÅÐÏ¿(´°Î»¥Ú¡¼¥¸)';
38        $registSecretKey = lfRegistData($_GET);         //Ëܲñ°÷ÅÐÏ¿¡Ê¥Õ¥é¥°Êѹ¹¡Ë
39        lfSendRegistMail($registSecretKey);             //Ëܲñ°÷ÅÐÏ¿´°Î»¥á¡¼¥ëÁ÷¿®
40
41        // ¥í¥°¥¤¥óºÑ¤ß¤Î¾õÂ֤ˤ¹¤ë¡£
42        $objQuery = new SC_Query();
43        $email = $objQuery->get("dtb_customer", "email", "secret_key = ?", array($registSecretKey));
44        $objCustomer->setLogin($email);
45        header("Location: ./complete.php");
46        exit;
47    }
48
49//--¡¡¤½¤ì°Ê³°¤Î¥¢¥¯¥»¥¹¤Ï̵¸ú¤È¤¹¤ë
50} else {
51    $objPage->arrErr["id"] = "̵¸ú¤Ê¥¢¥¯¥»¥¹¤Ç¤¹¡£";
52    $objPage->tpl_mainpage = 'regist/error.tpl';
53    $objPage->tpl_css = "/css/layout/regist/error.css";
54    $objPage->tpl_title = '¥¨¥é¡¼';
55
56}
57
58//----¡¡¥Ú¡¼¥¸É½¼¨
59$objView->assignobj($objPage);
60$objView->display(SITE_FRAME);
61
62//---- ÅÐÏ¿
63function lfRegistData($array) {
64    global $objConn;
65    global $arrInfo;
66   
67    do {
68        $secret = sfGetUniqRandomId("r");
69    } while( ($result = $objConn->getOne("SELECT COUNT(*) FROM dtb_customer WHERE secret_key = ?", array($secret)) ) != 0);
70
71    $sql = "SELECT email FROM dtb_customer WHERE secret_key = ? AND status = 1";
72    $email = $objConn->getOne($sql, array($array["id"]));
73
74    $objConn->query("BEGIN");
75    $arrRegist["secret_key"] = $secret; //¡¡ËÜÅÐÏ¿IDȯ¹Ô
76    $arrRegist["status"] = 2;
77    $arrRegist["update_date"] = "NOW()";
78   
79    $objQuery = new SC_Query();
80    $where = "secret_key = ? AND status = 1";
81   
82    $arrRet = $objQuery->select("point", "dtb_customer", $where, array($array["id"]));
83    // ²ñ°÷ÅÐÏ¿»þ¤Î²Ã»»¥Ý¥¤¥ó¥È(¹ØÆþ»þ²ñ°÷ÅÐÏ¿¤Î¾ì¹ç¤Ï¡¢¥Ý¥¤¥ó¥È²Ã»»¡Ë
84    $arrRegist['point'] = $arrRet[0]['point'] + addslashes($arrInfo['welcome_point']);
85   
86    $objQuery->update("dtb_customer", $arrRegist, $where, array($array["id"]));
87   
88    $ret = $objQuery->getLastQuery(false);
89   
90    /* ¹ØÆþ»þÅÐÏ¿¤Î¾ì¹ç¡¢¤½¤Î²ó¤Î¹ØÆþ¤ò²ñ°÷¹ØÆþ¤È¤ß¤Ê¤¹¡£ */
91    // ²ñ°÷¾ðÊó¤ÎÆÉ¤ß¹þ¤ß
92    $where1 = "secret_key = ? AND status = 2";
93    $customer = $objQuery->select("*", "dtb_customer", $where1, array($secret));
94    // ½é²ó¹ØÆþ¾ðÊó¤ÎÆÉ¤ß¹þ¤ß
95//  $where2 = "member_check = 1 AND order_email = ? AND password = ?";
96//  $order_temp_id = $objQuery->get("dtb_order_temp", "order_temp_id", $where2, array($customer[0]['email'], $customer[0]['password']));
97    $order_temp_id = $objQuery->get("dtb_order_temp", "order_temp_id");
98    // ¹ØÆþ¾ðÊó¤Î¹¹¿·
99    if ($order_temp_id != null) {
100        $arrCustomer['customer_id'] = $customer[0]['customer_id'];
101        $where3 = "order_temp_id = ?";
102        $objQuery->update("dtb_order_temp", $arrCustomer, $where3, array($order_temp_id));
103        $objQuery->update("dtb_order", $arrCustomer, $where3, array($order_temp_id));
104    }
105
106    $sql = "SELECT mail_flag FROM dtb_customer_mail WHERE email = ?";
107    $result = $objConn->getOne($sql, array($email));
108   
109    switch($result) {
110    // ²¾HTML
111    case '4':
112        $arrRegistMail["mail_flag"] = 1;
113        break;
114    // ²¾TEXT
115    case '5':
116        $arrRegistMail["mail_flag"] = 2;
117        break;
118    // ²¾¤Ê¤·
119    case '6':
120        $arrRegistMail["mail_flag"] = 3;
121        break;
122    default:
123        $arrRegistMail["mail_flag"] = $result;
124        break;
125    }
126
127    $objConn->autoExecute("dtb_customer_mail", $arrRegistMail, "email = '" .addslashes($email). "'");
128    $objConn->query("COMMIT");
129       
130    return $secret;     // ËÜÅÐÏ¿ID¤òÊÖ¤¹
131}
132
133//---- ÆþÎÏ¥¨¥é¡¼¥Á¥§¥Ã¥¯
134function lfErrorCheck($array) {
135
136    global $objConn;
137    $objErr = new SC_CheckError($array);
138
139    $objErr->doFunc(array("²¾ÅÐÏ¿ID", 'id'), array("EXIST_CHECK"));
140    if (! EregI("^[[:alnum:]]+$",$array["id"] )) {
141        $objErr->arrErr["id"] = "̵¸ú¤ÊURL¤Ç¤¹¡£¥á¡¼¥ë¤Ëµ­ºÜ¤µ¤ì¤Æ¤¤¤ëËܲñ°÷ÅÐÏ¿ÍÑURL¤òºÆÅÙ¤´³Îǧ¤¯¤À¤µ¤¤¡£";
142    }
143    if (! $objErr->arrErr["id"]) {
144
145        $sql = "SELECT customer_id FROM dtb_customer WHERE secret_key = ? AND status = 1 AND delete = 0";
146        $result = $objConn->getOne($sql, array($array["id"]));
147
148        if (! is_numeric($result)) {
149            $objErr->arrErr["id"] .= "¢¨ ´û¤Ë²ñ°÷ÅÐÏ¿¤¬´°Î»¤·¤Æ¤¤¤ë¤«¡¢Ìµ¸ú¤ÊURL¤Ç¤¹¡£<br>";
150            return $objErr->arrErr;
151
152        }
153    }
154
155    return $objErr->arrErr;
156}
157
158//---- Àµ²ñ°÷ÅÐÏ¿´°Î»¥á¡¼¥ëÁ÷¿®
159function lfSendRegistMail($registSecretKey) {
160    global $objConn;
161    global $CONF;
162
163    //-- À«Ì¾¤ò¼èÆÀ
164    $sql = "SELECT email, name01, name02 FROM dtb_customer WHERE secret_key = ?";
165    $result = $objConn->getAll($sql, array($registSecretKey));
166    $data = $result[0];
167   
168    //--¡¡¥á¡¼¥ëÁ÷¿®
169    $objMailText = new SC_SiteView();
170    $objMailText->assign("CONF", $CONF);
171    $objMailText->assign("name01", $data["name01"]);
172    $objMailText->assign("name02", $data["name02"]);
173    $toCustomerMail = $objMailText->fetch("mail_templates/customer_regist_mail.tpl");
174    $subject = sfMakeSubject('Ëܲñ°÷ÅÐÏ¿¤¬´°Î»¤·¤Þ¤·¤¿¡£');
175    $objMail = new GC_SendMail();
176
177    $objMail->setItem(
178                          ''                                //¡¡°¸Àè
179                        , $subject//"¡Ú" .$CONF["shop_name"]. "¡Û".ENTRY_CUSTOMER_REGIST_SUBJECT        //¡¡¥µ¥Ö¥¸¥§¥¯¥È
180                        , $toCustomerMail                   //¡¡ËÜʸ
181                        , $CONF["email03"]                  //¡¡ÇÛÁ÷¸µ¥¢¥É¥ì¥¹
182                        , $CONF["shop_name"]                //¡¡ÇÛÁ÷¸µ¡¡Ì¾Á°
183                        , $CONF["email03"]                  //¡¡reply_to
184                        , $CONF["email04"]                  //¡¡return_path
185                        , $CONF["email04"]                  //  Errors_to
186                    );
187    // °¸Àè¤ÎÀßÄê
188    $name = $data["name01"] . $data["name02"] ." ÍÍ";
189    $objMail->setTo($data["email"], $name);
190    $objMail->sendMail();
191}
192
193?>
Note: See TracBrowser for help on using the repository browser.