chengkun
2025-04-18 1bb985f32f2efe0f9dd69f3cf29a1c809b1cf96d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
class Smarty_Internal_Compile_Adlist extends Smarty_Internal_CompileBase{
    public $required_attributes = array('item');
    public $optional_attributes = array('name', 'key', 'classid','adid', 'limit','laysrc', 'random');
    public $shorttag_order = array('from', 'item', 'key', 'name');
    public function compile($args, $compiler, $parameter){
 
        $_attr = $this->getAttributes($compiler, $args);
 
        $from = $_attr['from'];
        $item = $_attr['item'];
        $name = $_attr['item'];
        $name=str_replace('\'','',$name);
        $name=$name?$name:'list';$name='$'.$name;
        if (!strncmp("\$_smarty_tpl->tpl_vars[$item]", $from, strlen($item) + 24)) {
            $compiler->trigger_template_error("item variable {$item} may not be the same variable as at 'from'", $compiler->lex->taglineno);
        }
        $class_id = $_attr['classid'];
        $adid = $_attr['adid'];
        $limit = $_attr['limit'];$limit=is_numeric($limit)?$limit:0;
        $length = $_attr['length'];$length=is_numeric($length)?$length:0;
        if(isset($adid)){
            $OutputStr='global $db,$db_config,$config;
            $paramer='.ArrayToString($_attr,true).';'.$name.'=array();
            $AdArr=array();
            include(PLUS_PATH.\'/pimg_cache.php\');  if(!empty($ad_label[$paramer[classid]][\'ad_\'.$paramer[adid]])&&($ad_label[$paramer[classid]][\'ad_\'.$paramer[adid]][\'did\']==$_SESSION[\'did\']||$ad_label[$paramer[classid]][\'ad_\'.$paramer[adid]][\'did\']==\'0\')&&$ad_label[$paramer[classid]][\'ad_\'.$paramer[adid]][\'start\']<time()&&$ad_label[$paramer[classid]][\'ad_\'.$paramer[adid]][\'end\']>time()){
                $AdArr[] = $ad_label[$paramer[classid]][\'ad_\'.$paramer[adid]];
            }';
 
        }else{
            $OutputStr='global $db,$db_config,$config;$AdArr=array();$paramer=array();$attr='.ArrayToString($_attr,true).';
            include(PLUS_PATH.\'pimg_cache.php\');$add_arr = $ad_label['.$class_id.'];if(is_array($add_arr) && !empty($add_arr)){
                $i=0;$limit = '.$limit.';$length = '.$length.';
                foreach($add_arr as $key=>$value){
                    if($config[\'did\']){
                        if(($value[\'did\']==$config[\'did\']|| $value[\'did\']==-1)&&$value[\'start\']<time()&&$value[\'end\']>time()){
                            if($i>0 && $limit==$i){
                                break;
                            }
                            if($length>0){
                                $value[\'name\'] = mb_substr($value[\'name\'],0,$length);
                            }
                            if($paramer[\'type\']!=""){
                                if($paramer[\'type\'] == $value[\'type\']){
                                    $AdArr[] = $value;
                                }
                            }else{
                                $AdArr[] = $value;
                            }
                            $i++;
                        }
                        
                    }else{
                        if(($value[\'did\']==-1 || !$value[\'did\']) && $value[\'start\']<time()&&$value[\'end\']>time()){
                            if($i>0 && $limit==$i){
                                break;
                            }
                            if($length>0){
                                $value[\'name\'] = mb_substr($value[\'name\'],0,$length);
                            }
                            if($paramer[\'type\']!=""){
                                if($paramer[\'type\'] == $value[\'type\']){
                                    $AdArr[] = $value;
                                }
                            }else{
                                $AdArr[] = $value;
                            }
                            $i++;
                        }
                        
                    }
                }
                if (isset($attr[\'random\']) && $attr[\'random\'] && count($AdArr) > $attr[\'random\']) {
                    $temp = [];
                    $random_keys = array_rand($AdArr, $attr[\'random\']);
 
                    if($attr[\'random\'] == 1) {
                        $temp[] = $AdArr[$attr[\'random\']];
                    } else {
                        foreach ($AdArr as $key => $value) {
                            if (in_array($key, $random_keys)) {
                                $temp[$key] = $value;
                            }
                        }
                    }
                    $AdArr = $temp;
                }
            }';
        }
 
        return SmartyOutputStr($this,$compiler,$_attr,'adlist','$AdArr',$OutputStr,'$AdArr');
    }
}
class Smarty_Internal_Compile_Adlistelse extends Smarty_Internal_CompileBase{
    public function compile($args, $compiler, $parameter){
        $_attr = $this->getAttributes($compiler, $args);
 
        list($openTag, $nocache, $item, $key) = $this->closeTag($compiler, array('adlist'));
        $this->openTag($compiler, 'adlistelse', array('adlistelse', $nocache, $item, $key));
 
        return "<?php }\nif (!\$_smarty_tpl->tpl_vars[$item]->_loop) {\n?>";
    }
}
class Smarty_Internal_Compile_Adlistclose extends Smarty_Internal_CompileBase{
    public function compile($args, $compiler, $parameter){
        $_attr = $this->getAttributes($compiler, $args);
        if ($compiler->nocache) {
            $compiler->tag_nocache = true;
        }
 
        list($openTag, $compiler->nocache, $item, $key) = $this->closeTag($compiler, array('adlist', 'adlistelse'));
 
        return "<?php } ?>";
    }
}