source: temp/branches/mobile/html/mobile/magazine/confirm.php @ 11418

Revision 11418, 5.1 KB checked in by rebelt, 17 years ago (diff)

以下のモバイルサイト用ページ・機能を作成いたしました。

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