function lib_mytag(&$ctag, &$refObj) { $attlist = "typeid|0,name|,ismake|no"; FillAttsDefault($ctag->CAttribute->Items, $attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); if (trim($ismake) == '') { $ismake = 'no'; } $body = lib_GetMyTagT($refObj, $typeid, $name, '#@__mytag'); //编译 if ($ismake == 'yes') { require_once DEDEINC . '/arc.partview.class.php'; $pvCopy = new PartView($typeid); $pvCopy->SetTemplet($body, "string"); $body = $pvCopy->GetResult(); } return $body; }
/** * php5构造函数 * * @access public * @param int $aid 内容ID * @return string */ function __construct($aid) { global $cfg_basedir, $cfg_templets_dir, $cfg_df_style, $envs; $this->dsql = $GLOBALS['dsql']; $this->dtp = new DedeTagParse(); $this->dtp->refObj = $this; $this->dtp->SetNameSpace("dede", "{", "}"); $this->Fields = $this->dsql->GetOne("SELECT * FROM `#@__sgpage` WHERE aid='{$aid}' "); $envs['aid'] = $this->Fields['aid']; //设置一些全局参数的值 foreach ($GLOBALS['PubFields'] as $k => $v) { $this->Fields[$k] = $v; } if ($this->Fields['ismake'] == 1) { $pv = new PartView(); $pv->SetTemplet($this->Fields['body'], 'string'); $this->Fields['body'] = $pv->GetResult(); } $tplfile = $cfg_basedir . str_replace('{style}', $cfg_templets_dir . '/' . $cfg_df_style, $this->Fields['template']); $this->dtp->LoadTemplate($tplfile); $this->ParseTemplet(); }
$pv = new PartView(); $row = $pv->dsql->GetOne(" SELECT * FROM `#@__mytag` WHERE aid='{$aid}' "); if (!is_array($row)) { $myvalues = "<!--\r\ndocument.write('Not found input!');\r\n-->"; } else { $tagbody = ''; if ($row['timeset'] == 0) { $tagbody = $row['normbody']; } else { $ntime = time(); if ($ntime > $row['endtime'] || $ntime < $row['starttime']) { $tagbody = $row['expbody']; } else { $tagbody = $row['normbody']; } } $pv->SetTemplet($tagbody, 'string'); $myvalues = $pv->GetResult(); $myvalues = str_replace('"', '\\"', $myvalues); $myvalues = str_replace("\r", "\\r", $myvalues); $myvalues = str_replace("\n", "\\n", $myvalues); $myvalues = "<!--\r\ndocument.write(\"{$myvalues}\");\r\n-->\r\n"; file_put_contents($cacheFile, $myvalues); /* 使用 file_put_contents替换下列代码提高执行效率 $fp = fopen($cacheFile, 'w'); fwrite($fp, $myvalues); fclose($fp); */ } } include $cacheFile;
function lib_channelartlist(&$ctag, &$refObj) { global $dsql, $envs, $_sys_globals, $cfg_tui; //处理标记属性、innertext $attlist = 'typeid|0,row|20,showhide|no,cacheid|'; FillAttsDefault($ctag->CAttribute->Items, $attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); $innertext = trim($ctag->GetInnerText()); $showhideArr = array('yes' => 0, 'no' => 1, 'both' => -1); $hideflag = $showhideArr[$showhide]; $artlist = ''; //读取固定的缓存块 $cacheid = trim($cacheid); if ($cacheid != '') { $artlist = GetCacheBlock($cacheid); if ($artlist != '') { return $artlist; } } if (empty($typeid)) { $typeid = !empty($refObj->TypeLink->TypeInfos['id']) ? $refObj->TypeLink->TypeInfos['id'] : 0; } if ($innertext == '') { $innertext = GetSysTemplets('part_channelartlist.htm'); } $totalnum = $row; if (empty($totalnum)) { $totalnum = 20; } //获得类别ID总数的信息 $typeids = array(); if ($typeid == 0) { $tpsql = " reid<>0 AND ispart<>2 AND ishidden<>{$hideflag} AND channeltype>0 "; } else { if ($typeid == '-1') { $tpsql = " reid=0 and ishidden<>{$hideflag} AND channeltype>0 "; } else { if ($typeid == '-9999999') { $tpsql = " id={$cfg_tui} AND ispart<>2 AND ishidden<>{$hideflag} "; } else { if (!preg_match('#,#', $typeid) && $typeid > 0) { $tpsql = " reid='{$typeid}' AND ispart<>2 AND ishidden<>{$hideflag} "; } else { if ($typeid < 0) { $typeid = 0 - $typeid; $tpsql = " id={$typeid} AND ispart<>2 AND ishidden<>{$hideflag} "; } else { $tpsql = " reid IN({$typeid}) AND ispart<>2 AND ishidden<>{$hideflag} "; } } } } } if ($orderby == '') { $orderbysql = "ORDER BY id"; } else { $orderbysql = "ORDER BY {$orderby}"; } if ($orderway == '') { $orderwaysql = "desc"; } else { $orderwaysql = "{$orderway}"; } $dsql->SetQuery("SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath \r\n FROM `#@__arctype` WHERE {$tpsql} {$orderbysql} {$orderwaysql} LIMIT {$totalnum}"); $dsql->Execute(); while ($row = $dsql->GetArray()) { $typeids[] = $row; } if (!isset($typeids[0])) { return ''; } $GLOBALS['itemindex'] = 0; $GLOBALS['itemparity'] = 1; for ($i = 0; isset($typeids[$i]); $i++) { $GLOBALS['itemindex']++; $pv = new PartView($typeids[$i]['id']); $pv->Fields['typeurl'] = GetOneTypeUrlA($typeids[$i]); $pv->SetTemplet($innertext, 'string'); $artlist .= $pv->GetResult(); $GLOBALS['itemparity'] = $GLOBALS['itemparity'] == 1 ? 2 : 1; } //注销环境变量,以防止后续调用中被使用 $GLOBALS['envs']['typeid'] = $_sys_globals['typeid']; $GLOBALS['envs']['reid'] = ''; if ($cacheid != '') { WriteCacheBlock($cacheid, $artlist); } return $artlist; }
function IncludeFile($filename,$ismake='no') { global $cfg_df_style; $restr = ""; if(file_exists($filename)){ $okfile = $filename; } else if( file_exists(dirname(__FILE__)."/".$filename) ){ $okfile = dirname(__FILE__)."/".$filename; } else if( file_exists(dirname(__FILE__)."/../".$filename) ){ $okfile = dirname(__FILE__)."/../".$filename; } else if( file_exists(dirname(__FILE__)."/../templets/".$filename) ){ $okfile = dirname(__FILE__)."/../templets/".$filename; } else if( file_exists(dirname(__FILE__)."/../templets/".$cfg_df_style."/".$filename) ){ $okfile = dirname(__FILE__)."/../templets/".$cfg_df_style."/".$filename; } else{ return "无法在这个位置找到: $filename"; } //编译 if($ismake=="yes"){ require_once(dirname(__FILE__)."/inc_arcpart_view.php"); $pvCopy = new PartView(); $pvCopy->SetTemplet($okfile,"file"); $restr = $pvCopy->GetResult(); }else{ $fp = @fopen($okfile,"r"); while($line=fgets($fp,1024)) $restr.=$line; fclose($fp); } return $restr; }
function lib_channelartlist(&$ctag, &$refObj) { global $dsql, $envs, $_sys_globals; //处理标记属性、innertext $attlist = 'typeid|0,row|20,cacheid|'; FillAttsDefault($ctag->CAttribute->Items, $attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); $innertext = trim($ctag->GetInnerText()); $artlist = ''; //读取固定的缓存块 $cacheid = trim($cacheid); if ($cacheid != '') { $artlist = GetCacheBlock($cacheid); if ($artlist != '') { return $artlist; } } if (empty($typeid)) { $typeid = !empty($refObj->TypeLink->TypeInfos['id']) ? $refObj->TypeLink->TypeInfos['id'] : 0; } if ($innertext == '') { $innertext = GetSysTemplets('part_channelartlist.htm'); } $totalnum = $row; if (empty($totalnum)) { $totalnum = 20; } //获得类别ID总数的信息 $typeids = array(); if ($typeid == 0 || $typeid == 'top') { $tpsql = " reid=0 AND ispart<>2 AND ishidden<>1 AND channeltype>0 "; } else { if (!preg_match('#,#', $typeid)) { $tpsql = " reid='{$typeid}' AND ispart<>2 AND ishidden<>1 "; } else { $tpsql = " id IN({$typeid}) AND ispart<>2 AND ishidden<>1 "; } } $dsql->SetQuery("SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath \n FROM `#@__arctype` WHERE {$tpsql} ORDER BY substring_index( '{$typeid}',id,1) limit {$totalnum}"); $dsql->Execute(); while ($row = $dsql->GetArray()) { $typeids[] = $row; } if (!isset($typeids[0])) { return ''; } $GLOBALS['itemindex'] = 0; $GLOBALS['itemparity'] = 1; for ($i = 0; isset($typeids[$i]); $i++) { $GLOBALS['itemindex']++; $pv = new PartView($typeids[$i]['id']); $pv->Fields['typeurl'] = GetOneTypeUrlA($typeids[$i]); if ($typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['id'] || $typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['topid']) { $pv->Fields['currentstyle'] = $currentstyle ? $currentstyle : 'current'; } else { $pv->Fields['currentstyle'] = ''; } $pv->SetTemplet($innertext, 'string'); $artlist .= $pv->GetResult(); $GLOBALS['itemparity'] = $GLOBALS['itemparity'] == 1 ? 2 : 1; } //注销环境变量,以防止后续调用中被使用 $GLOBALS['envs']['typeid'] = $_sys_globals['typeid']; $GLOBALS['envs']['reid'] = ''; if ($cacheid != '') { WriteCacheBlock($cacheid, $artlist); } return $artlist; }