<?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 } ?>";
|
}
|
}
|