source: branches/comu/html/mobile/magazine/confirm.php @ 12039

Revision 12039, 5.6 KB checked in by nanasess, 17 years ago (diff)

header("Location: 〜") で相対パスが使用されていたのを絶対パスに変更.
data/lib/slib.php に sfGetCurrentUri(boolean) と sfGetCurrentSchema() を追加

  • Property svn:eol-style set to native
Line 
1<?php
2/**
3 *
4 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
5 *
6 * http://www.lockon.co.jp/
7 *
8 *
9 * ¥á¥ë¥Þ¥¬³Îǧ
10 */
11
12require_once('../require.php');
13
14class LC_Page {
15    function LC_Page() {
16        /** ɬ¤ºÊѹ¹¤¹¤ë **/
17        $this->tpl_mainpage = 'magazine/confirm.tpl';
18        $this->tpl_title .= '¥á¥ë¥Þ¥¬³Îǧ';
19    }
20}
21
22$objPage = new LC_Page();
23$objConn = new SC_DbConn();
24$objPage->arrForm = $_POST;
25
26// ÅÐÏ¿
27if (isset($_REQUEST['btnRegist'])) {
28    $objPage->arrErr = lfMailErrorCheck($objPage->arrForm, "regist");
29
30    // ¥¨¥é¡¼¤¬¤Ê¤±¤ì¤Ð
31    if (count($objPage->arrErr) == 0) {
32        // ³Îǧ
33        $objPage->arrForm['kind'] = '¥á¥ë¥Þ¥¬ÅÐÏ¿';
34        $objPage->arrForm['type'] = 'regist';
35        $objPage->arrForm['mail'] = $objPage->arrForm['regist'];
36    } else {
37        $objPage->tpl_mainpage = 'magazine/index.tpl';
38        $objPage->tpl_title = '¥á¥ë¥Þ¥¬ÅÐÏ¿¡¦²ò½ü';
39    }
40// ²ò½ü
41} elseif (isset($_REQUEST['btnCancel'])) {
42    $objPage->arrErr = lfMailErrorCheck($objPage->arrForm, "cancel");
43
44    // ¥¨¥é¡¼¤¬¤Ê¤±¤ì¤Ð
45    if (count($objPage->arrErr) == 0) {
46        // ³Îǧ
47        $objPage->arrForm['kind'] = '¥á¥ë¥Þ¥¬²ò½ü';
48        $objPage->arrForm['type'] = 'cancel';
49        $objPage->arrForm['mail'] = $objPage->arrForm['cancel'];
50    } else {
51        $objPage->tpl_mainpage = 'magazine/index.tpl';
52        $objPage->tpl_title = '¥á¥ë¥Þ¥¬ÅÐÏ¿¡¦²ò½ü';
53    }
54// ´°Î»
55} elseif ($_REQUEST['mode'] == 'regist' or $_REQUEST['mode'] == 'cancel') {
56
57    //¡¡ÅÐÏ¿
58    if ($_REQUEST['mode'] == 'regist') {
59        $uniqId = lfRegistData($_POST["email"]);
60        $subject = sfMakesubject('¥á¥ë¥Þ¥¬ÅÐÏ¿¤Î¤´³Îǧ');
61    //¡¡²ò½ü
62    } elseif ($_REQUEST['mode'] == 'cancel') {
63        $uniqId = lfGetSecretKey($_POST["email"]);
64        $subject = sfMakesubject('¥á¥ë¥Þ¥¬²ò½ü¤Î¤´³Îǧ');
65    }
66    $CONF = sf_getBasisData();
67    $objPage->CONF = $CONF;
68    $objPage->tpl_url = gfAddSessionId(MOBILE_SSL_URL . "magazine/" . $_REQUEST['mode'] . ".php?id=" . $uniqId);
69   
70    $objMailText = new SC_MobileView();
71    $objMailText->assignobj($objPage);
72    $toCustomerMail = $objMailText->fetch("mail_templates/mailmagazine_" . $_REQUEST['mode'] . ".tpl");
73    $objMail = new GC_SendMail();
74    $objMail->setItem(
75                        ''                                  //¡¡°¸Àè
76                        , $subject                          //¡¡¥µ¥Ö¥¸¥§¥¯¥È
77                        , $toCustomerMail                   //¡¡ËÜʸ
78                        , $CONF["email03"]                  //¡¡ÇÛÁ÷¸µ¥¢¥É¥ì¥¹
79                        , $CONF["shop_name"]                //¡¡ÇÛÁ÷¸µ¡¡Ì¾Á°
80                        , $CONF["email03"]                  //¡¡reply_to
81                        , $CONF["email04"]                  //¡¡return_path
82                        , $CONF["email04"]                  //  Errors_to
83                        , $CONF["email01"]                  //  Bcc
84                                                        );
85    // °¸Àè¤ÎÀßÄê
86    $objMail->setTo($_POST["email"], $_POST["email"]);
87    $objMail->sendMail();
88
89    // ´°Î»¥Ú¡¼¥¸¤Ë°ÜÆ°¤µ¤»¤ë¡£
90    header("Location:" . gfAddSessionId(sfGetCurrentUri() . "/complete.php"));
91    exit;
92} else {
93    sfDispSiteError(CUSTOMER_ERROR, "", false, "", true);
94}
95
96// ¥ì¥¤¥¢¥¦¥È¥Ç¥¶¥¤¥ó¤ò¼èÆÀ
97$objPage = sfGetPageLayout($objPage, false, DEF_LAYOUT);
98
99$objView = new SC_MobileView();
100$objView->assignobj($objPage);
101$objView->display(SITE_FRAME);
102
103//-----------------------------------------------------------------------------------------------------------------------------------
104
105
106//---- ÆþÎÏ¥¨¥é¡¼¥Á¥§¥Ã¥¯
107function lfMailErrorCheck($array, $dataName) {
108    $objErr = new SC_CheckError($array);
109    $objErr->doFunc(
110                array('¥á¡¼¥ë¥¢¥É¥ì¥¹', $dataName, MTEXT_LEN) ,
111                array("NO_SPTAB", "EXIST_CHECK", "EMAIL_CHECK",
112                    "SPTAB_CHECK" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK", "MOBILE_EMAIL_CHECK"));
113
114    // ÆþÎÏ¥¨¥é¡¼¤¬¤Ê¤±¤ì¤Ð
115    if (count($objErr->arrErr) == 0) {
116        // ¥á¥ë¥Þ¥¬¤ÎÅÐϿ̵ͭ
117        $flg = lfIsRegistData($array[$dataName]);
118
119        // ÅÐÏ¿¤Î»þ
120        if ($dataName == 'regist' and $flg == true) {
121            $objErr->arrErr[$dataName] = "´û¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤¹¡£<br>";
122        // ²ò½ü¤Î»þ
123        } elseif ($dataName == 'cancel' and $flg == false) {
124            $objErr->arrErr[$dataName] = "¥á¥ë¥Þ¥¬ÅÐÏ¿¤¬¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£<br>";
125        }
126    }
127
128    return $objErr->arrErr;
129}
130
131
132//---- ¥á¥ë¥Þ¥¬ÅÐÏ¿
133function lfRegistData ($email) {
134    global $objConn;
135
136    $count = 1;
137    while ($count != 0) {
138        $uniqid = sfGetUniqRandomId("t");
139        $count = $objConn->getOne("SELECT COUNT(*) FROM dtb_customer_mail WHERE secret_key = ?", array($uniqid));
140    }
141   
142    $arrRegist["email"] = $email;           // ¥á¡¼¥ë¥¢¥É¥ì¥¹
143    $arrRegist["mail_flag"] = 5;            // ÅÐÏ¿¾õÂÖ
144    $arrRegist["secret_key"] = $uniqid;     // IDȯ¹Ô
145    $arrRegist["create_date"] = "now()";    // ºîÀ®Æü
146    $arrRegist["update_date"] = "now()";    // ¹¹¿·Æü
147
148    //-- ²¾ÅÐÏ¿¼Â¹Ô
149    $objConn->query("BEGIN");
150
151    $objQuery = new SC_Query();
152
153    //--¡¡´û¤Ë¥á¥ë¥Þ¥¬ÅÐÏ¿¤·¤Æ¤¤¤ë¤«¤ÎȽÄê
154    $sql = "SELECT count(*) FROM dtb_customer_mail WHERE email = ?";
155    $mailResult = $objConn->getOne($sql, array($arrRegist["email"]));
156
157    if ($mailResult == 1) {     
158        $objQuery->update("dtb_customer_mail", $arrRegist, "email = '" .addslashes($arrRegist["email"]). "'");         
159    } else {
160        $objQuery->insert("dtb_customer_mail", $arrRegist);     
161    }
162    $objConn->query("COMMIT");
163
164    return $uniqid;
165}
166
167// ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¥­¡¼¤Î¼èÆÀ
168function lfGetSecretKey ($email) {
169    global $objConn;
170
171    $sql = "SELECT secret_key FROM dtb_customer_mail WHERE email = ?";
172    $uniqid = $objConn->getOne($sql, array($email));
173
174    if ($uniqid == '') {
175        $count = 1;
176        while ($count != 0) {
177            $uniqid = sfGetUniqRandomId("t");
178            $count = $objConn->getOne("SELECT COUNT(*) FROM dtb_customer_mail WHERE secret_key = ?", array($uniqid));
179        }
180
181        $objQuery = new SC_Query();
182        $objQuery->update("dtb_customer_mail", array('secret_key' => $uniqid), "email = '" .addslashes($email). "'");
183    }
184
185    return $uniqid;
186}
187
188// ´û¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«
189function lfIsRegistData ($email) {
190    global $objConn;
191
192    $sql = "SELECT email, mail_flag FROM dtb_customer_mail WHERE email = ?";
193    $mailResult = $objConn->getRow($sql, array($email));
194
195    // NULL¤â¹ØÆɤȤߤʤ¹
196    if (count($mailResult) == 0 or ($mailResult[1] != null and $mailResult[1] != 2 )) {
197        return false;
198    } else {
199        return true;
200    }
201}
202
203
204?>
Note: See TracBrowser for help on using the repository browser.