source: branches/dev/html/regist/index.php @ 8

Revision 8, 5.7 KB checked in by root, 17 years ago (diff)

new import

Line 
1<?php
2/*
3 * Copyright(c) 2000-2006 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.