source: branches/rel/html/install/user_data/include/campaign/default/src/application.php @ 12157

Revision 12157, 6.7 KB checked in by uehara, 17 years ago (diff)
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 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 = ? AND del_flg = 0", 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    $objPage->is_active = true;
53} else {
54    $status = CAMPAIGN_TEMPLATE_END;
55    $objPage->is_active = false;
56}
57
58switch($_POST['mode']) {
59// ¥í¥°¥¤¥ó¥Á¥§¥Ã¥¯
60case 'login':
61    $objLoginFormParam->toLower('login_email');
62    $objPage->arrErr = $objLoginFormParam->checkError();
63    $arrForm =  $objLoginFormParam->getHashArray();
64    // ¥¯¥Ã¥­¡¼ÊݸȽÄê
65    if($arrForm['login_memory'] == "1" && $arrForm['login_email'] != "") {
66        $objCookie->setCookie('login_email', $_POST['login_email']);
67    } else {
68        $objCookie->setCookie('login_email', '');
69    }
70
71    if(count($objPage->arrErr) == 0) {
72        // ¥í¥°¥¤¥óȽÄê
73        if(!$objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'])) {
74            // ²¾ÅÐÏ¿¤ÎȽÄê
75            $objQuery = new SC_Query;
76            $where = "email = ? AND status = 1 AND del_flg = 0";
77            $ret = $objQuery->count("dtb_customer", $where, array($arrForm['login_email']));
78           
79            if($ret > 0) {
80                sfDispSiteError(TEMP_LOGIN_ERROR);
81            } else {
82                sfDispSiteError(SITE_LOGIN_ERROR);
83            }
84        } else {
85            // ½ÅÊ£¿½¹þ¥Á¥§¥Ã¥¯
86            $orverlapping_flg = $objQuery->get("dtb_campaign", "orverlapping_flg", "campaign_id = ?", array($objCampaignSess->getCampaignId()));
87
88            if($orverlapping_flg) {
89                if(lfOverlappingCheck($objCustomer->getValue('customer_id'))) {
90                    $objPage->arrErr['login_email'] = "¢¨ Ê£¿ô²ó¤´±þÊ礹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£";
91                }
92            }
93   
94            if(count($objPage->arrErr) == 0) {
95                // ¿½¹þ¾ðÊó¤òÅÐÏ¿
96                lfRegistCampaignOrder($objCustomer->getValue('customer_id'));
97                // ´°Î»¥Ú¡¼¥¸¤Ø¥ê¥À¥¤¥ì¥¯¥È
98                header("location: ". CAMPAIGN_URL . "$dir_name/complete.php");
99            }
100        }
101    }
102    break;
103default :
104    break;
105}
106// ÆþÎϾðÊó¤òÅϤ¹
107$objPage->arrForm = $_POST;
108$objPage->dir_name = $dir_name;
109$objPage->tpl_dir_name = CAMPAIGN_TEMPLATE_PATH . $dir_name  . "/" . $status;
110
111//----¡¡¥Ú¡¼¥¸É½¼¨
112$objView->assignobj($objPage);
113$objView->display($objPage->tpl_mainpage);
114
115
116//---------------------------------------------------------------------------------------------------------------------------------------------------------
117
118/*
119 * ´Ø¿ô̾¡§lfInitLoginFormParam()
120 * ÀâÌÀ¡¡¡§¥í¥°¥¤¥ó¥Õ¥©¡¼¥à¤ò½é´ü²½
121 * Ìá¤êÃÍ¡§Ìµ¤·
122 */
123function lfInitLoginFormParam() {
124    global $objLoginFormParam;
125    $objLoginFormParam->addParam("µ­²±¤¹¤ë", "login_memory", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
126    $objLoginFormParam->addParam("¥á¡¼¥ë¥¢¥É¥ì¥¹", "login_email", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
127    $objLoginFormParam->addParam("¥Ñ¥¹¥ï¡¼¥É", "login_pass", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
128}
129
130/*
131 * ´Ø¿ô̾¡§lfCheckActive()
132 * °ú¿ô1 ¡§¥Ç¥£¥ì¥¯¥È¥ê̾
133 * ÀâÌÀ¡¡¡§¥­¥ã¥ó¥Ú¡¼¥óÃ椫¥Á¥§¥Ã¥¯
134 * Ìá¤êÃÍ¡§¥­¥ã¥ó¥Ú¡¼¥óÃæ¤Ê¤é true ½ªÎ»¤Ê¤é false
135 */
136function lfCheckActive($directory_name) {
137   
138    global $objQuery;
139    $is_active = false;
140   
141    $col = "limit_count, total_count, start_date, end_date";
142    $arrRet = $objQuery->select($col, "dtb_campaign", "directory_name = ? AND del_flg = 0", array($directory_name));
143
144    // ³«»ÏÆü»þ¡¦Ää»ßÆü»þ¤òÀ®·¿
145    $start_date = (date("YmdHis", strtotime($arrRet[0]['start_date'])));
146    $end_date = (date("YmdHis", strtotime($arrRet[0]['end_date'])));
147    $now_date = (date("YmdHis"));
148
149    // ¥­¥ã¥ó¥Ú¡¼¥ó¤¬³«ºÅ´ü´Ö¤Ç¡¢¤«¤Ä¿½¹þÀ©¸ÂÆâ¤Ç¤¢¤ë
150    if($now_date > $start_date && $now_date < $end_date
151            && ($arrRet[0]['limit_count'] > $arrRet[0]['total_count'] || $arrRet[0]['limit_count'] < 1)) {
152        $is_active = true;
153    }
154       
155    return $is_active;
156}
157
158/*
159 * ´Ø¿ô̾¡§lfRegistCampaignOrder()
160 * ÀâÌÀ¡¡¡§¥­¥ã¥ó¥Ú¡¼¥ó¼õÃí¾ðÊó¤òÊݸ
161 * °ú¿ô1 ¡§¸ÜµÒID
162 * Ìá¤êÃÍ¡§Ìµ¤·
163 */
164function lfRegistCampaignOrder($customer_id) {
165
166    global $objQuery;
167    global $objCampaignSess;
168    $campaign_id = $objCampaignSess->getCampaignId();
169
170    // ¼õÃí¥Ç¡¼¥¿¤ò¼èÆÀ
171    $cols = "
172            customer_id,
173            name01 as order_name01,
174            name02 as order_name02,
175            kana01 as order_kana01,
176            kana02 as order_kana02,
177            zip01 as order_zip01,
178            zip02 as order_zip02,
179            pref as order_pref,
180            addr01 as order_addr01,
181            addr02 as order_addr02,
182            email as order_email,
183            tel01 as order_tel01,
184            tel02 as order_tel02,
185            tel03 as order_tel03,
186            fax01 as order_fax01,
187            fax02 as order_fax02,
188            fax03 as order_fax03,
189            sex as order_sex,
190            job as order_job,
191            birth as order_birth
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/*
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.