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

Revision 11184, 4.0 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}
16
17$objPage = new LC_Page();
18$objView = new SC_SiteView(false);
19$objQuery = new SC_Query();
20$objCustomer = new SC_Customer();
21$objCampaignSess = new SC_CampaignSession();
22// ¥¯¥Ã¥­¡¼´ÉÍý¥¯¥é¥¹
23$objCookie = new SC_Cookie(COOKIE_EXPIRE);
24
25$objLoginFormParam = new SC_FormParam();    // ¥í¥°¥¤¥ó¥Õ¥©¡¼¥àÍÑ
26lfInitLoginFormParam();                     // ½é´üÀßÄê
27$objLoginFormParam->setParam($_POST);       // POSTÃͤμèÆÀ
28
29// ¥Ç¥£¥ì¥¯¥È¥ê̾¤ò¼èÆÀ
30$dir_name = dirname($_SERVER['PHP_SELF']);
31$arrDir = split('/', $dir_name);
32$dir_name = $arrDir[count($arrDir) -1];
33
34/* ¥»¥Ã¥·¥ç¥ó¤Ë¥­¥ã¥ó¥Ú¡¼¥ó¥Ç¡¼¥¿¤ò½ñ¤­¹þ¤à */
35// ¥­¥ã¥ó¥Ú¡¼¥ó¤«¤é¤ÎÁ«°Ü¤È¤¤¤¦¾ðÊó¤òÊÝ»ý
36$objCampaignSess->setIsCampaign();
37// ¥­¥ã¥ó¥Ú¡¼¥óID¤òÊÝ»ý
38$campaign_id = $objQuery->get("dtb_campaign", "campaign_id", "directory_name = ?", array($dir_name));
39$objCampaignSess->setCampaignId($campaign_id);
40// ¥­¥ã¥ó¥Ú¡¼¥ó¥Ç¥£¥ì¥¯¥È¥ê̾¤òÊÝ»ý
41$objCampaignSess->setCampaignDir($dir_name);
42
43// ¥­¥ã¥ó¥Ú¡¼¥ó¤¬³«ºÅÃæ¤«¤ò¥Á¥§¥Ã¥¯
44if(lfCheckActive($dir_name)) {
45    $status = CAMPAIGN_TEMPLATE_ACTIVE;
46} else {
47    $status = CAMPAIGN_TEMPLATE_END;
48}
49
50switch($_POST['mode']) {
51// ¥í¥°¥¤¥ó¥Á¥§¥Ã¥¯
52case 'login':
53    $objLoginFormParam->toLower('login_email');
54    $objPage->arrErr = $objLoginFormParam->checkError();
55    $arrForm =  $objLoginFormParam->getHashArray();
56    // ¥¯¥Ã¥­¡¼ÊݸȽÄê
57    if($arrForm['login_memory'] == "1" && $arrForm['login_email'] != "") {
58        $objCookie->setCookie('login_email', $_POST['login_email']);
59    } else {
60        $objCookie->setCookie('login_email', '');
61    }
62
63    if(count($objPage->arrErr) == 0) {
64        // ¥í¥°¥¤¥óȽÄê
65        if(!$objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'])) {
66            // ²¾ÅÐÏ¿¤ÎȽÄê
67            $objQuery = new SC_Query;
68            $where = "email = ? AND status = 1 AND del_flg = 0";
69            $ret = $objQuery->count("dtb_customer", $where, array($arrForm['login_email']));
70           
71            if($ret > 0) {
72                sfDispSiteError(TEMP_LOGIN_ERROR);
73            } else {
74                sfDispSiteError(SITE_LOGIN_ERROR);
75            }
76        }
77    }
78    break;
79default :
80    break;
81}
82// ÆþÎϾðÊó¤òÅϤ¹
83$objPage->arrForm = $_POST;
84$objPage->tpl_dir_name = CAMPAIGN_TEMPLATE_PATH . $dir_name  . "/" . $status;
85
86//----¡¡¥Ú¡¼¥¸É½¼¨
87$objView->assignobj($objPage);
88$objView->display($objPage->tpl_mainpage);
89
90
91//---------------------------------------------------------------------------------------------------------------------------------------------------------
92
93/*
94 * ´Ø¿ô̾¡§lfInitLoginFormParam()
95 * ÀâÌÀ¡¡¡§¥í¥°¥¤¥ó¥Õ¥©¡¼¥à¤ò½é´ü²½
96 * Ìá¤êÃÍ¡§Ìµ¤·
97 */
98function lfInitLoginFormParam() {
99    global $objLoginFormParam;
100    $objLoginFormParam->addParam("µ­²±¤¹¤ë", "login_memory", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
101    $objLoginFormParam->addParam("¥á¡¼¥ë¥¢¥É¥ì¥¹", "login_email", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
102    $objLoginFormParam->addParam("¥Ñ¥¹¥ï¡¼¥É", "login_pass", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
103}
104
105/*
106 * ´Ø¿ô̾¡§lfCheckActive()
107 * °ú¿ô1 ¡§¥Ç¥£¥ì¥¯¥È¥ê̾
108 * ÀâÌÀ¡¡¡§¥­¥ã¥ó¥Ú¡¼¥óÃæ¤«¥Á¥§¥Ã¥¯
109 * Ìá¤êÃÍ¡§¥­¥ã¥ó¥Ú¡¼¥óÃæ¤Ê¤é true ½ªÎ»¤Ê¤é false
110 */
111function lfCheckActive($directory_name) {
112   
113    global $objQuery;
114    $is_active = false;
115   
116    $col = "limit_count, total_count, start_date, end_date";
117    $arrRet = $objQuery->select($col, "dtb_campaign", "directory_name = ? AND del_flg = 0", array($directory_name));
118
119    // ³«»ÏÆü»þ¡¦Ää»ßÆü»þ¤òÀ®·¿
120    $start_date = (date("YmdHis", strtotime($arrRet[0]['start_date'])));
121    $end_date = (date("YmdHis", strtotime($arrRet[0]['end_date'])));
122    $now_date = (date("YmdHis"));
123
124    // ¥­¥ã¥ó¥Ú¡¼¥ó¤¬³«ºÅ´ü´Ö¤Ç¡¢¤«¤Ä¿½¹þÀ©¸ÂÆâ¤Ç¤¢¤ë
125    if($now_date > $start_date && $now_date < $end_date
126            && $arrRet[0]['limit_count'] > 0 && $arrRet[0]['limit_count'] > $arrRet[0]['total_count']) {
127        $is_active = true;
128    }
129       
130    return $is_active;
131}
132
133?>
Note: See TracBrowser for help on using the repository browser.