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

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