source: temp/branches/ec-cube-beta/html/campaign/default/application.php @ 11227

Revision 11227, 6.6 KB checked in by uehara, 19 years ago (diff)
Line 
1<?php
2/*
3 * Copyright(c) 2000-2006 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7require_once("../../require.php");
8
9//---- ¥Ú¡¼¥¸É½¼¨¥¯¥é¥¹
10class LC_Page {
11   
12    function LC_Page() {
13        $this->tpl_mainpage = TEMPLATE_DIR . '/campaign/application.tpl';
14        /*
15         session_start»þ¤Îno-cache¥Ø¥Ã¥À¡¼¤òÍÞÀ©¤¹¤ë¤³¤È¤Ç
16         ¡ÖÌá¤ë¡×¥Ü¥¿¥ó»ÈÍÑ»þ¤ÎÍ­¸ú´ü¸ÂÀÚ¤ìɽ¼¨¤òÍÞÀ©¤¹¤ë¡£
17         private-no-expire:¥¯¥é¥¤¥¢¥ó¥È¤Î¥­¥ã¥Ã¥·¥å¤òµö²Ä¤¹¤ë¡£
18        */
19        session_cache_limiter('private-no-expire');
20    }
21}
22
23$objPage = new LC_Page();
24$objView = new SC_SiteView(false);
25$objQuery = new SC_Query();
26$objCustomer = new SC_Customer();
27$objCampaignSess = new SC_CampaignSession();
28// ¥¯¥Ã¥­¡¼´ÉÍý¥¯¥é¥¹
29$objCookie = new SC_Cookie(COOKIE_EXPIRE);
30
31$objLoginFormParam = new SC_FormParam();    // ¥í¥°¥¤¥ó¥Õ¥©¡¼¥àÍÑ
32lfInitLoginFormParam();                     // ½é´üÀßÄê
33$objLoginFormParam->setParam($_POST);       // POSTÃͤμèÆÀ
34
35// ¥Ç¥£¥ì¥¯¥È¥ê̾¤ò¼èÆÀ
36$dir_name = dirname($_SERVER['PHP_SELF']);
37$arrDir = split('/', $dir_name);
38$dir_name = $arrDir[count($arrDir) -1];
39
40/* ¥»¥Ã¥·¥ç¥ó¤Ë¥­¥ã¥ó¥Ú¡¼¥ó¥Ç¡¼¥¿¤ò½ñ¤­¹þ¤à */
41// ¥­¥ã¥ó¥Ú¡¼¥ó¤«¤é¤ÎÁ«°Ü¤È¤¤¤¦¾ðÊó¤òÊÝ»ý
42$objCampaignSess->setIsCampaign();
43// ¥­¥ã¥ó¥Ú¡¼¥óID¤òÊÝ»ý
44$campaign_id = $objQuery->get("dtb_campaign", "campaign_id", "directory_name = ?", array($dir_name));
45$objCampaignSess->setCampaignId($campaign_id);
46// ¥­¥ã¥ó¥Ú¡¼¥ó¥Ç¥£¥ì¥¯¥È¥ê̾¤òÊÝ»ý
47$objCampaignSess->setCampaignDir($dir_name);
48
49// ¥­¥ã¥ó¥Ú¡¼¥ó¤¬³«ºÅÃæ¤«¤ò¥Á¥§¥Ã¥¯
50if(lfCheckActive($dir_name)) {
51    $status = CAMPAIGN_TEMPLATE_ACTIVE;
52} else {
53    $status = CAMPAIGN_TEMPLATE_END;
54}
55
56switch($_POST['mode']) {
57// ¥í¥°¥¤¥ó¥Á¥§¥Ã¥¯
58case 'login':
59    $objLoginFormParam->toLower('login_email');
60    $objPage->arrErr = $objLoginFormParam->checkError();
61    $arrForm =  $objLoginFormParam->getHashArray();
62    // ¥¯¥Ã¥­¡¼ÊݸȽÄê
63    if($arrForm['login_memory'] == "1" && $arrForm['login_email'] != "") {
64        $objCookie->setCookie('login_email', $_POST['login_email']);
65    } else {
66        $objCookie->setCookie('login_email', '');
67    }
68
69    if(count($objPage->arrErr) == 0) {
70        // ¥í¥°¥¤¥óȽÄê
71        if(!$objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'])) {
72            // ²¾ÅÐÏ¿¤ÎȽÄê
73            $objQuery = new SC_Query;
74            $where = "email = ? AND status = 1 AND del_flg = 0";
75            $ret = $objQuery->count("dtb_customer", $where, array($arrForm['login_email']));
76           
77            if($ret > 0) {
78                sfDispSiteError(TEMP_LOGIN_ERROR);
79            } else {
80                sfDispSiteError(SITE_LOGIN_ERROR);
81            }
82        } else {
83            // ½ÅÊ£¿½¹þ¥Á¥§¥Ã¥¯
84            $orverlapping_flg = $objQuery->get("dtb_campaign", "orverlapping_flg", "campaign_id = ?", array($objCampaignSess->getCampaignId()));
85
86            if($orverlapping_flg) {
87                if(lfOverlappingCheck($objCustomer->getValue('customer_id'))) {
88                    $objPage->arrErr['email'] = "¢¨ Ê£¿ô²ó¤´±þÊ礹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£";
89                }
90            }
91   
92            if(count($objPage->arrErr) == 0) {
93                // ¿½¹þ¾ðÊó¤òÅÐÏ¿
94                lfRegistCampaignOrder($objCustomer->getValue('customer_id'));
95                // ´°Î»¥Ú¡¼¥¸¤Ø¥ê¥À¥¤¥ì¥¯¥È
96                header("location: ". URL_DIR . "campaign/$dir_name/complete.php");
97            }
98        }
99    }
100    break;
101default :
102    break;
103}
104// ÆþÎϾðÊó¤òÅϤ¹
105$objPage->arrForm = $_POST;
106$objPage->dir_name = $dir_name;
107$objPage->tpl_dir_name = CAMPAIGN_TEMPLATE_PATH . $dir_name  . "/" . $status;
108
109//----¡¡¥Ú¡¼¥¸É½¼¨
110$objView->assignobj($objPage);
111$objView->display($objPage->tpl_mainpage);
112
113
114//---------------------------------------------------------------------------------------------------------------------------------------------------------
115
116/*
117 * ´Ø¿ô̾¡§lfInitLoginFormParam()
118 * ÀâÌÀ¡¡¡§¥í¥°¥¤¥ó¥Õ¥©¡¼¥à¤ò½é´ü²½
119 * Ìá¤êÃÍ¡§Ìµ¤·
120 */
121function lfInitLoginFormParam() {
122    global $objLoginFormParam;
123    $objLoginFormParam->addParam("µ­²±¤¹¤ë", "login_memory", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
124    $objLoginFormParam->addParam("¥á¡¼¥ë¥¢¥É¥ì¥¹", "login_email", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
125    $objLoginFormParam->addParam("¥Ñ¥¹¥ï¡¼¥É", "login_pass", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
126}
127
128/*
129 * ´Ø¿ô̾¡§lfCheckActive()
130 * °ú¿ô1 ¡§¥Ç¥£¥ì¥¯¥È¥ê̾
131 * ÀâÌÀ¡¡¡§¥­¥ã¥ó¥Ú¡¼¥óÃæ¤«¥Á¥§¥Ã¥¯
132 * Ìá¤êÃÍ¡§¥­¥ã¥ó¥Ú¡¼¥óÃæ¤Ê¤é true ½ªÎ»¤Ê¤é false
133 */
134function lfCheckActive($directory_name) {
135   
136    global $objQuery;
137    $is_active = false;
138   
139    $col = "limit_count, total_count, start_date, end_date";
140    $arrRet = $objQuery->select($col, "dtb_campaign", "directory_name = ? AND del_flg = 0", array($directory_name));
141
142    // ³«»ÏÆü»þ¡¦Ää»ßÆü»þ¤òÀ®·¿
143    $start_date = (date("YmdHis", strtotime($arrRet[0]['start_date'])));
144    $end_date = (date("YmdHis", strtotime($arrRet[0]['end_date'])));
145    $now_date = (date("YmdHis"));
146
147    // ¥­¥ã¥ó¥Ú¡¼¥ó¤¬³«ºÅ´ü´Ö¤Ç¡¢¤«¤Ä¿½¹þÀ©¸ÂÆâ¤Ç¤¢¤ë
148    if($now_date > $start_date && $now_date < $end_date
149            && $arrRet[0]['limit_count'] > 0 && $arrRet[0]['limit_count'] > $arrRet[0]['total_count']) {
150        $is_active = true;
151    }
152       
153    return $is_active;
154}
155
156/*
157 * ´Ø¿ô̾¡§lfRegistCampaignOrder()
158 * ÀâÌÀ¡¡¡§¥­¥ã¥ó¥Ú¡¼¥ó¼õÃí¾ðÊó¤òÊݸ
159 * °ú¿ô1 ¡§¸ÜµÒID
160 * Ìá¤êÃÍ¡§Ìµ¤·
161 */
162function lfRegistCampaignOrder($customer_id) {
163
164    global $objQuery;
165    global $objCampaignSess;
166    $campaign_id = $objCampaignSess->getCampaignId();
167
168    // ¼õÃí¥Ç¡¼¥¿¤ò¼èÆÀ
169    $cols = "
170            customer_id,
171            name01 as order_name01,
172            name02 as order_name02,
173            kana01 as order_kana01,
174            kana02 as order_kana02,
175            zip01 as order_zip01,
176            zip02 as order_zip02,
177            pref as order_pref,
178            addr01 as order_addr01,
179            addr02 as order_addr02,
180            email as order_email,
181            tel01 as order_tel01,
182            tel02 as order_tel02,
183            tel03 as order_tel03,
184            fax01 as order_fax01,
185            fax02 as order_fax02,
186            fax03 as order_fax03,
187            sex as order_sex,
188            job as order_job,
189            birth as order_birth,
190            cell01,
191            cell02,
192            cell03
193            ";
194           
195    $arrCustomer = $objQuery->select($cols, "dtb_customer", "customer_id = ?", array($customer_id));
196
197    $sqlval = $arrCustomer[0];
198    $sqlval['campaign_id'] = $campaign_id;
199    $sqlval['create_date'] = 'now()';
200       
201    // INSERT¤Î¼Â¹Ô
202    $objQuery->insert("dtb_campaign_order", $sqlval);
203   
204    // ¿½¤·¹þ¤ß¿ô¤Î¹¹¿·
205    $total_count = $objQuery->get("dtb_campaign", "total_count", "campaign_id = ?", array($campaign_id));
206    $arrCampaign['total_count'] = $total_count += 1;
207    $objQuery->update("dtb_campaign", $arrCampaign, "campaign_id = ?", array($campaign_id));
208}
209
210/*
211 * ´Ø¿ô̾¡§lfOverlappingCheck()
212 * ÀâÌÀ¡¡¡§½ÅÊ£±þÊç¥Á¥§¥Ã¥¯
213 * °ú¿ô1 ¡§¸ÜµÒID
214 * Ìá¤êÃÍ¡§¥Õ¥é¥° (½ÅÊ£¤¬¤¢¤Ã¤¿¤é true ½ÅÊ£¤¬¤Ê¤«¤Ã¤¿¤é false)
215 */
216function lfOverlappingCheck($customer_id) {
217   
218    global $objQuery;
219   
220    $count = $objQuery->count("dtb_campaign_order", "customer_id = ?", array($customer_id));
221    if($count > 0) {
222        return true;
223    }
224   
225    return false;
226}
227?>
Note: See TracBrowser for help on using the repository browser.