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

Revision 11221, 6.6 KB checked in by uehara, 20 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            if($orverlapping_flg) {
86                if(lfOverlappingCheck()) {
87                    $objPage->arrErr['orverlapping'] = true;
88                }
89            }
90           
91            if(count($objPage->arrErr) == 0) {
92                // ¿½¹þ¾ðÊó¤òÅÐÏ¿
93                lfRegistCampaignOrder($objCustomer->getValue('customer_id'));
94                // ´°Î»¥Ú¡¼¥¸¤Ø¥ê¥À¥¤¥ì¥¯¥È
95                header("location: ". URL_DIR . "campaign/$dir_name/complete.php");
96            }
97        }
98    }
99    break;
100default :
101    break;
102}
103// ÆþÎϾðÊó¤òÅϤ¹
104$objPage->arrForm = $_POST;
105$objPage->dir_name = $dir_name;
106$objPage->tpl_dir_name = CAMPAIGN_TEMPLATE_PATH . $dir_name  . "/" . $status;
107
108//----¡¡¥Ú¡¼¥¸É½¼¨
109$objView->assignobj($objPage);
110$objView->display($objPage->tpl_mainpage);
111
112
113//---------------------------------------------------------------------------------------------------------------------------------------------------------
114
115/*
116 * ´Ø¿ô̾¡§lfInitLoginFormParam()
117 * ÀâÌÀ¡¡¡§¥í¥°¥¤¥ó¥Õ¥©¡¼¥à¤ò½é´ü²½
118 * Ìá¤êÃÍ¡§Ìµ¤·
119 */
120function lfInitLoginFormParam() {
121    global $objLoginFormParam;
122    $objLoginFormParam->addParam("µ­²±¤¹¤ë", "login_memory", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
123    $objLoginFormParam->addParam("¥á¡¼¥ë¥¢¥É¥ì¥¹", "login_email", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
124    $objLoginFormParam->addParam("¥Ñ¥¹¥ï¡¼¥É", "login_pass", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
125}
126
127/*
128 * ´Ø¿ô̾¡§lfCheckActive()
129 * °ú¿ô1 ¡§¥Ç¥£¥ì¥¯¥È¥ê̾
130 * ÀâÌÀ¡¡¡§¥­¥ã¥ó¥Ú¡¼¥óÃæ¤«¥Á¥§¥Ã¥¯
131 * Ìá¤êÃÍ¡§¥­¥ã¥ó¥Ú¡¼¥óÃæ¤Ê¤é true ½ªÎ»¤Ê¤é false
132 */
133function lfCheckActive($directory_name) {
134   
135    global $objQuery;
136    $is_active = false;
137   
138    $col = "limit_count, total_count, start_date, end_date";
139    $arrRet = $objQuery->select($col, "dtb_campaign", "directory_name = ? AND del_flg = 0", array($directory_name));
140
141    // ³«»ÏÆü»þ¡¦Ää»ßÆü»þ¤òÀ®·¿
142    $start_date = (date("YmdHis", strtotime($arrRet[0]['start_date'])));
143    $end_date = (date("YmdHis", strtotime($arrRet[0]['end_date'])));
144    $now_date = (date("YmdHis"));
145
146    // ¥­¥ã¥ó¥Ú¡¼¥ó¤¬³«ºÅ´ü´Ö¤Ç¡¢¤«¤Ä¿½¹þÀ©¸ÂÆâ¤Ç¤¢¤ë
147    if($now_date > $start_date && $now_date < $end_date
148            && $arrRet[0]['limit_count'] > 0 && $arrRet[0]['limit_count'] > $arrRet[0]['total_count']) {
149        $is_active = true;
150    }
151       
152    return $is_active;
153}
154
155/*
156 * ´Ø¿ô̾¡§lfRegistCampaignOrder()
157 * ÀâÌÀ¡¡¡§¥­¥ã¥ó¥Ú¡¼¥ó¼õÃí¾ðÊó¤òÊݸ
158 * °ú¿ô1 ¡§¸ÜµÒID
159 * Ìá¤êÃÍ¡§Ìµ¤·
160 */
161function lfRegistCampaignOrder($customer_id) {
162
163    global $objQuery;
164    global $objCampaignSess;
165    $campaign_id = $objCampaignSess->getCampaignId();
166
167    // ¼õÃí¥Ç¡¼¥¿¤ò¼èÆÀ
168    $cols = "
169            customer_id,
170            name01 as order_name01,
171            name02 as order_name02,
172            kana01 as order_kana01,
173            kana02 as order_kana02,
174            zip01 as order_zip01,
175            zip02 as order_zip02,
176            pref as order_pref,
177            addr01 as order_addr01,
178            addr02 as order_addr02,
179            email as order_email,
180            tel01 as order_tel01,
181            tel02 as order_tel02,
182            tel03 as order_tel03,
183            fax01 as order_fax01,
184            fax02 as order_fax02,
185            fax03 as order_fax03,
186            sex as order_sex,
187            job as order_job,
188            birth as order_birth,
189            cell01,
190            cell02,
191            cell03
192            ";
193           
194    $arrCustomer = $objQuery->select($cols, "dtb_customer", "customer_id = ?", array($customer_id));
195
196    $sqlval = $arrCustomer[0];
197    $sqlval['campaign_id'] = $campaign_id;
198    $sqlval['create_date'] = 'now()';
199       
200    // INSERT¤Î¼Â¹Ô
201    $objQuery->insert("dtb_campaign_order", $sqlval);
202   
203    // ¿½¤·¹þ¤ß¿ô¤Î¹¹¿·
204    $total_count = $objQuery->get("dtb_campaign", "total_count", "campaign_id = ?", array($campaign_id));
205    $arrCampaign['total_count'] = $total_count += 1;
206    $objQuery->update("dtb_campaign", $arrCampaign, "campaign_id = ?", array($campaign_id));
207}
208
209/*
210 * ´Ø¿ô̾¡§lfOverlappingCheck()
211 * ÀâÌÀ¡¡¡§½ÅÊ£±þÊç¥Á¥§¥Ã¥¯
212 * °ú¿ô1 ¡§¸ÜµÒID
213 * Ìá¤êÃÍ¡§¥Õ¥é¥° (½ÅÊ£¤¬¤¢¤Ã¤¿¤é true ½ÅÊ£¤¬¤Ê¤«¤Ã¤¿¤é false)
214 */
215function lfOverlappingCheck($customer_id) {
216   
217    global $objQuery;
218   
219    $count = $objQuery->count("dtb_campaign_order", "customer_id = ?", array($customer_id));
220    if($count > 0) {
221        return true;
222    }
223   
224    return false;
225}
226?>
Note: See TracBrowser for help on using the repository browser.