source: branches/dev/data/include/module.inc @ 15040

Revision 15040, 5.1 KB checked in by adati, 17 years ago (diff)

#エビスタグ付加モジュール(thanksページで顧客情報をタグ埋め込み・CSVダウンロード機能)

Line 
1<?php
2
3// ¥¨¥Ó¥¹¥¿¥°½ÐÎÏÍÑ¥¯¥é¥¹
4class LC_EbisPage {
5    function LC_EbisPage() {
6        $this->tpl_mainpage = MODULE_PATH . "ebis_tag_text.tpl";
7    }
8}
9
10// ¥¨¥Ó¥¹¥¿¥°¤Îȯ¹Ô
11function sfPrintEbisTag($pid = "") {
12    $objQuery = new SC_Query();
13    $arrRet   = $objQuery->select("sub_data", "dtb_module", "module_id = ?", array(EBIS_TAG_MID));
14    $arrSubData = unserialize($arrRet[0]['sub_data']);
15   
16    if ( empty($arrSubData['cid']) ) return;
17   
18    $arrEbis = array(
19        'cid'       => $arrSubData['cid'],
20        'login_url' => $arrSubData['login_url'],
21    );
22   
23    if(!is_array($pid) && $pid != "") {
24        if(!ereg(".tpl$", $pid)) {
25            // ¥Ú¡¼¥¸ID¤ò¾å½ñ¤­¤¹¤ë
26            $arrEbis['pid'] = $pid;
27        } else {
28            // ¥Æ¥ó¥×¥ì¡¼¥È¤Î¥Ñ¥¹¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤ë¾ì¹ç
29            $temp_id = str_replace(USER_TEMPLATE_PATH, '', $pid);
30            $temp_id = str_replace(HTML_PATH,   '',  $temp_id);
31            $temp_id = preg_replace('|^/+|',    '',  $temp_id);
32            $temp_id = preg_replace('|\.tpl$|', '',  $temp_id);
33            $temp_id = preg_replace('|[\./]|',  '_', $temp_id);
34            $arrEbis['pid'] = $temp_id;
35        }
36    }   
37   
38    // ¾¦ÉÊ°ìÍ÷¥Ú¡¼¥¸¤Ï¡¢ÆüìID¤òȯ¹Ô
39    if(ereg("/products/list.php\?category_id=[0-9]+$", $_SERVER["REQUEST_URI"])) {
40        $filename = basename($_SERVER["REQUEST_URI"]);
41        $arrEbis['pid'] = ereg_replace("list.php\?category_id=", "list-c", $filename);
42    }
43   
44    // ¾¦Éʾܺ٥ڡ¼¥¸¤Ï¡¢ÆüìID¤òȯ¹Ô
45    if(ereg("/products/detail.php\?product_id=[0-9]+$", $_SERVER["REQUEST_URI"])) {
46        $filename = basename($_SERVER["REQUEST_URI"]);
47        $arrEbis['pid'] = ereg_replace("detail.php\?product_id=", "detail-p", $filename);
48    }
49
50    // ¹ØÆþ´°Î»¥Ú¡¼¥¸(thanks¥Ú¡¼¥¸)¤ÏÆüìID¤òȯ¹Ô
51    if(preg_match("|/shopping/complete.php$|", $_SERVER["REQUEST_URI"])) {
52        global $arrEBiSTagAttrKeys;
53        global $arrEBiSTagAttrTagName;
54        global $arrJob;
55        global $arrSex;
56       
57        $arrEbis['pid']  = 'thanks'; // ¥Ú¡¼¥¸ID¤ò¥»¥Ã¥È
58        $customerInfo    = $_SESSION['customer'];
59       
60        /**
61         * $arrSubData == Array (
62         *      [user] => username
63         *      [pass] => password
64         *      [login_url] => http://login_url/
65         *      [cid] => ebis_parameter
66         *      [m1id] => 1
67         *      [a1id] => 2
68         *      [o1id] => 3
69         *      [o2id] => 4
70         *      [o3id] => 0
71         *      [o4id] => 0
72         *      [o5id] => 0
73         * )
74         **/
75       
76        foreach ($arrSubData as $key => $value) {
77            if (!in_array($key , $arrEBiSTagAttrTagName)) continue;
78            if (empty($arrEBiSTagAttrKeys[$value])) continue;
79           
80            // °À­¾ðÊó¤ò¥»¥Ã¥È
81            switch ($value) {
82            case EBiS_TAG_ATTR_CUSTOMER_ID:
83            case EBiS_TAG_ATTR_PAYMENT:
84                $tmp_key       = $arrEBiSTagAttrKeys[$value];
85                $arrEbis[$key] = $customerInfo[$tmp_key];
86                break;
87            case EBiS_TAG_ATTR_JOB:
88                $tmp_key       = $arrEBiSTagAttrKeys[$value];
89                $arrEbis[$key] = $arrJob[$customerInfo[$tmp_key]];
90                break;
91            case EBiS_TAG_ATTR_SEX:
92                $tmp_key       = $arrEBiSTagAttrKeys[$value];
93                $arrEbis[$key] = $arrSex[$customerInfo[$tmp_key]];
94                break;
95            default:
96            }
97        }
98    }
99   
100    // ID³ä¤êÅö¤Æ¤µ¤ì¤Æ¤¤¤Ê¤¤¥Ú¡¼¥¸¤Ï¡¢¼«Æ°Åª¤ËÀ¸À®¤¹¤ë¡£
101    if($arrEbis['pid'] == "") {             
102        $temp_id = ereg_replace("^[/]+","",$_SERVER['PHP_SELF']);
103        $temp_id = ereg_replace(".php$","",$temp_id);
104        $temp_id = ereg_replace("[\./]","_",$temp_id);
105        $arrEbis['pid'] = $temp_id;
106    }
107
108    // ¥Ú¡¼¥¸ID¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Î¤ß¥¿¥°¤ò½ÐÎϤ¹¤ë¡£
109    if($arrEbis['pid'] != "") {
110        $objSubPage = new LC_EbisPage();
111        $objSubPage->arrEbis = $arrEbis;
112        $objSubView = new SC_SiteView();
113        $objSubView->assignobj($objSubPage);
114        $objSubView->display($objSubPage->tpl_mainpage);
115    }
116}
117
118// ¥³¥ó¥Ð¡¼¥¸¥ç¥ó¥¿¥°¤Îȯ¹Ô
119function sfPrintAffTag($conv_page, $option) {
120    if(is_numeric($conv_page)) {
121        // sub_data¤è¤ê¥¿¥°¾ðÊó¤òÆɤ߹þ¤à
122        $objQuery = new SC_Query();
123        $arrRet = $objQuery->select("sub_data", "dtb_module", "module_id = ?", array(AFF_TAG_MID));
124        $arrSubData = unserialize($arrRet[0]['sub_data']);
125        $aff_tag = $arrSubData[$conv_page];
126       
127        $array = split("\|", $option);
128       
129        // ÆÃÄêʸ»ú¤ÎÃÖ¤­´¹¤¨
130        foreach($array as $each) {
131            list($key, $value) = split("=", $each);
132            $aff_tag = ereg_replace("\[\[" . $key . "\]\]", $value, $aff_tag);
133        }
134        print($aff_tag);       
135    }
136}
137
138// dtb_payment¤ËÈÆÍѹàÌܤ¬Â¸ºß¤·¤Æ¤¤¤Ê¤±¤ì¤ÐÄɲ乤ë
139function sfAlterMemo(){
140    $objQuery = new SC_Query();
141   
142    // ÈÆÍѹàÌܤθºß¥Á¥§¥Ã¥¯
143    if(!sfColumnExists("dtb_payment", "memo01")){
144       
145        // ¥â¥¸¥å¡¼¥ëID¤òÄɲÃ
146        $objQuery->query("alter table dtb_payment add module_id int4;");
147       
148        // ¥â¥¸¥å¡¼¥ë¥Ñ¥¹¤òÄɲÃ
149        $objQuery->query("alter table dtb_payment add module_path text;");
150       
151        // ÈÆÍѹàÌܤò10¸ÄÄɲÃ
152        for($i=1; $i<=9; $i++){
153            $objQuery->query("alter table dtb_payment add memo0".$i." text;");
154        }
155        $objQuery->query("alter table dtb_payment add memo10 text;");
156    }
157}
158
159?>
Note: See TracBrowser for help on using the repository browser.