source: branches/feature-module-paygent/data/include/module.inc @ 15120

Revision 15120, 5.8 KB checked in by adati, 17 years ago (diff)

1.4.2betaのマージ

Line 
1<?php
2
3// ¥¨¥Ó¥¹¥¿¥°½ÐÎÏÍÑ¥¯¥é¥¹
4class LC_EbisPage {
5    function LC_EbisPage() {
6        $this->tpl_mainpage = MODULE_PATH . "mdl_ebis_tag/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    lfSetThanksPegeTag($arrEbis, $arrSubData);
52
53    // ID³ä¤êÅö¤Æ¤µ¤ì¤Æ¤¤¤Ê¤¤¥Ú¡¼¥¸¤Ï¡¢¼«Æ°Åª¤ËÀ¸À®¤¹¤ë¡£
54    if($arrEbis['pid'] == "") {             
55        $temp_id = ereg_replace("^[/]+","",$_SERVER['PHP_SELF']);
56        $temp_id = ereg_replace(".php$","",$temp_id);
57        $temp_id = ereg_replace("[\./]","_",$temp_id);
58        $arrEbis['pid'] = $temp_id;
59    }
60
61    // ¥Ú¡¼¥¸ID¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Î¤ß¥¿¥°¤ò½ÐÎϤ¹¤ë¡£
62    if($arrEbis['pid'] != "") {
63        $objSubPage = new LC_EbisPage();
64        $objSubPage->arrEbis = $arrEbis;
65        $objSubView = new SC_SiteView();
66        $objSubView->assignobj($objSubPage);
67        $objSubView->display($objSubPage->tpl_mainpage);
68    }
69}
70
71// ¹ØÆþ´°Î»²èÌ̤Υ¨¥Ó¥¹¥¿¥°¤òÀßÄê
72function lfSetThanksPegeTag(&$arrEbis, $arrSubData){
73    $pattern = "|/shopping/complete.php$|";
74    $target  = $_SERVER["REQUEST_URI"];
75    if( !preg_match($pattern, $target) ) return;
76   
77    global $arrEBiSTagAttrTagName;
78    global $arrJobEN;
79    global $arrSexEN;
80    global $order_id;
81   
82    $objQuery = new SC_Query();
83    $arrRet   = $objQuery->select('*', 'dtb_order', 'order_id = ?', array($order_id));
84    $arrCustomerInfo = $arrRet[0];
85    $arrEbis['pid']  = 'thanks'; // ¥Ú¡¼¥¸ID¤ò¥»¥Ã¥È
86   
87    /**
88     * $arrSubData == Array (
89     *      [user] => username
90     *      [pass] => password
91     *      [login_url] => http://login_url/
92     *      [cid] => ebis_parameter
93     *      [m1id] => 1
94     *      [a1id] => 2
95     *      [o1id] => 3
96     *      [o2id] => 4
97     *      [o3id] => 0
98     *      [o4id] => 0
99     *      [o5id] => 0
100     * )
101     * $arrEBiSTagAttrTagName == Array(
102     *      'm1id', 'a1id', 'o1id', 'o2id'
103     *      'o3id', 'o4id', 'o5id'
104     * )
105     **/
106   
107    foreach ($arrEBiSTagAttrTagName as $tagname) {
108        if ( empty($arrSubData[$tagname]) ) continue;
109       
110        $value = $arrSubData[$tagname];
111       
112        // °À­¾ðÊó¤ò¥»¥Ã¥È
113        switch ($value) {
114        case EBiS_TAG_ATTR_CUSTOMER_ID:
115            $arrEbis[$tagname] = $arrCustomerInfo['customer_id'];
116            break;
117        case EBiS_TAG_ATTR_PAYMENT:
118            $arrEbis[$tagname] = $arrCustomerInfo['payment_total'];
119            break;
120        case EBiS_TAG_ATTR_JOB:
121            if ( empty($arrCustomerInfo['order_job']) ) break;
122            $arrEbis[$tagname] = $arrJobEN[$arrCustomerInfo['order_job']];
123            break;
124        case EBiS_TAG_ATTR_SEX:
125            $arrEbis[$tagname] = $arrSexEN[$arrCustomerInfo['order_sex']];
126            break;
127        case EBiS_TAG_ATTR_AGE:
128            if ( empty($arrCustomerInfo['order_birth']) ) break;
129            $arrEbis[$tagname] = gfGetAge($arrCustomerInfo['order_birth']);
130            break;
131        case EBiS_TAG_ATTR_IS_CUSTOMER:
132            if ( $arrCustomerInfo['customer_id'] == '0' ) {
133                $arrEbis[$tagname] = '0';
134            } else {
135                $arrEbis[$tagname] = '1';
136            }
137            break;
138        default:
139        }
140    }
141}
142
143// ¥³¥ó¥Ð¡¼¥¸¥ç¥ó¥¿¥°¤Îȯ¹Ô
144function sfPrintAffTag($conv_page, $option) {
145    if(is_numeric($conv_page)) {
146        // sub_data¤è¤ê¥¿¥°¾ðÊó¤òÆɤ߹þ¤à
147        $objQuery = new SC_Query();
148        $arrRet = $objQuery->select("sub_data", "dtb_module", "module_id = ?", array(AFF_TAG_MID));
149        $arrSubData = unserialize($arrRet[0]['sub_data']);
150        $aff_tag = $arrSubData[$conv_page];
151       
152        $array = split("\|", $option);
153       
154        // ÆÃÄêʸ»ú¤ÎÃÖ¤­´¹¤¨
155        foreach($array as $each) {
156            list($key, $value) = split("=", $each);
157            $aff_tag = ereg_replace("\[\[" . $key . "\]\]", $value, $aff_tag);
158        }
159        print($aff_tag);       
160    }
161}
162
163// dtb_payment¤ËÈÆÍѹàÌܤ¬Â¸ºß¤·¤Æ¤¤¤Ê¤±¤ì¤ÐÄɲ乤ë
164function sfAlterMemo(){
165    $objQuery = new SC_Query();
166   
167    // ÈÆÍѹàÌܤθºß¥Á¥§¥Ã¥¯
168    if(!sfColumnExists("dtb_payment", "memo01")){
169       
170        // ¥â¥¸¥å¡¼¥ëID¤òÄɲÃ
171        $objQuery->query("alter table dtb_payment add module_id int4;");
172       
173        // ¥â¥¸¥å¡¼¥ë¥Ñ¥¹¤òÄɲÃ
174        $objQuery->query("alter table dtb_payment add module_path text;");
175       
176        // ÈÆÍѹàÌܤò10¸ÄÄɲÃ
177        for($i=1; $i<=9; $i++){
178            $objQuery->query("alter table dtb_payment add memo0".$i." text;");
179        }
180        $objQuery->query("alter table dtb_payment add memo10 text;");
181    }
182}
183
184?>
Note: See TracBrowser for help on using the repository browser.