⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inc_channel_unit.php

📁 强大的PHP内容管理系统尽量不要让站长把时间都花费在为您修正说明上。压缩包解压
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php 
require_once(DEDEINC."/pub_dedetag.php");
require_once(DEDEINC."/inc_channel_unit_functions.php");
$GLOBALS['cfg_softinfos'] = '';
/*----------------------------------
表示特定频道的附加数据结构信息
function C____ChannelUnit();
-----------------------------------*/
class ChannelUnit
{
	var $ChannelInfos;
	var $ChannelFields;
	var $AllFieldNames;
	var $ChannelID;
	var $ArcID;
	var $dsql;
	var $SplitPageField;
	//-------------
	//php5构造函数
	//-------------
	function __construct($cid,$aid=0)
 	{
 		$this->ChannelInfos = "";
 		$this->ChannelFields = "";
 		$this->AllFieldNames = "";
 		$this->SplitPageField = "";
 		$this->ChannelID = $cid;
 		$this->ArcID = $aid;
 		$this->dsql = new DedeSql(false);
 		$this->ChannelInfos = $this->dsql->GetOne("Select * from #@__channeltype where ID='$cid'");
 		if(!is_array($this->ChannelInfos)){
 			echo "<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>\r\n";
 			echo "<div style='font-size:14px;line-height:150%;margin-left:20px'>";
 			echo "读取频道 {$cid} 信息失败,无法进行后续操作!<br/>\r\n";
 			echo "你可以尝试先对错误文档进行清理,然后再刷新本页。<br/>\r\n";
 			echo "请选择操作: <a href='javascript:location.reload();'>[重试]</a> <a href='archives_clear.php' target='_blank'>[清理错误文档]</a> ";
 			echo "</div>";
 			exit();
 		}
 		$dtp = new DedeTagParse();
 		$dtp->SetNameSpace("field","<",">");
    $dtp->LoadSource($this->ChannelInfos["fieldset"]);
    if(is_array($dtp->CTags))
    {
    	$tnames = Array();
    	foreach($dtp->CTags as $ctag){
    		$tname = $ctag->GetName();
    		if(isset($tnames[$tname]))
    		{ return; }
    		$tnames[$tname] = 1;
    		if($this->AllFieldNames!="") $this->AllFieldNames .= ",".$tname;
    		else $this->AllFieldNames .= $tname;
    		$this->ChannelFields[$tname]["innertext"] = $ctag->GetInnerText();
    		$this->ChannelFields[$tname]["type"] = $ctag->GetAtt("type");
    		$this->ChannelFields[$tname]["default"] = $ctag->GetAtt("default");
    		$this->ChannelFields[$tname]["rename"] = $ctag->GetAtt("rename");
    		$this->ChannelFields[$tname]["function"] = $ctag->GetAtt("function");
    		$this->ChannelFields[$tname]["value"] = "";
    		//----------------------------------------------------------------
    		$this->ChannelFields[$tname]["itemname"] = $ctag->GetAtt("itemname");
    		if($this->ChannelFields[$tname]["itemname"]=="")
    		{ $this->ChannelFields[$tname]["itemname"]=$tname; }
    		$this->ChannelFields[$tname]["isnull"] = $ctag->GetAtt("isnull");
    		$this->ChannelFields[$tname]["maxlength"] = $ctag->GetAtt("maxlength");
    		if($ctag->GetAtt("page")=="split") $this->SplitPageField = $tname;
      }
    }
    $dtp->Clear();
  }
  function ChannelUnit($cid,$aid=0)
	{
		$this->__construct($cid,$aid);
	}
	
	//设置档案ID
	//-----------------------
	function SetArcID($aid)
	{
		$this->ArcID = $aid;
	}
	
	//处理某个字段的值
	//----------------------
	function MakeField($fname,$fvalue,$addvalue="")
	{

		if($fvalue==""){ $fvalue = $this->ChannelFields[$fname]["default"]; }
		$ftype = $this->ChannelFields[$fname]["type"];

		//执行函数
		if($this->ChannelFields[$fname]["function"]!=""){
			$fvalue = $this->EvalFunc($fvalue,$this->ChannelFields[$fname]["function"]);
		}
		//处理各种数据类型
		
		if($ftype=="text"||$ftype=="textchar"){
			$fvalue = ClearHtml($fvalue);
		}
		else if($ftype=="multitext"){
			$fvalue = ClearHtml($fvalue);
			$fvalue = Text2Html($fvalue);
		}
		else if($ftype=="img"){
			$fvalue = $this->GetImgLinks($fvalue);
		}
		else if($ftype=="textdata"){
			if(!is_file($GLOBALS['cfg_basedir'].$fvalue)) return "";
			$fp = fopen($GLOBALS['cfg_basedir'].$fvalue,'r');
			$fvalue = "";
			while(!feof($fp)){ $fvalue .= fgets($fp,1024); }
			fclose($fp);
		}
		else if($ftype=="addon"){
			$foldvalue = $fvalue;
			$tempStr = GetSysTemplets("channel/channel_addon.htm");
			$tempStr = str_replace('~phppath~',$GLOBALS['cfg_plus_dir'],$tempStr);
			$tempStr = str_replace('~link~',$foldvalue,$tempStr);
			$fvalue = $tempStr;
		}
		else if($ftype=="softlinks"){
			$fvalue = $this->GetAddLinkPage($fvalue);
		}
		else if($ftype=="specialtopic"){
			
			$fvalue = $this->GetSpecList($fname,$fvalue,$addvalue);
			
		}
		return $fvalue;
	}
	//获得专题文章的列表
	//--------------------------------
	function GetSpecList($fname,$noteinfo,$noteid="")
	{
		if(!isset($GLOBALS['__SpGetFullList'])) require_once(dirname(__FILE__)."/inc/inc_fun_SpFullList.php");
		if($noteinfo=="") return "";
		$rvalue = "";
		$tempStr = GetSysTemplets("channel/channel_spec_note.htm");
		$dtp = new DedeTagParse();
		$dtp->LoadSource($noteinfo);
		if(is_array($dtp->CTags))
		{
			foreach($dtp->CTags as $k=>$ctag){
				$notename = $ctag->GetAtt("name");
				if($noteid!="" && $ctag->GetAtt("noteid")!=$noteid){ continue; } //指定名称的专题节点
				$isauto = $ctag->GetAtt("isauto");
				$idlist = trim($ctag->GetAtt("idlist"));
				$rownum = trim($ctag->GetAtt("rownum"));
				if(empty($rownum)) $rownum = 40;
				$keywords = "";
				$stypeid = 0;
				
				if($isauto==1){
				  $idlist = "";
				  $keywords = trim($ctag->GetAtt("keywords"));
				  $stypeid = $ctag->GetAtt("typeid");
			  }
				if(trim($ctag->GetInnerText())!="") $listTemplet = $ctag->GetInnerText();
				else $listTemplet = GetSysTemplets("spec_arclist.htm");
				$idvalue = SpGetFullList($this->dsql,$stypeid,0,$rownum,$ctag->GetAtt("titlelen"),$ctag->GetAtt("infolen"),
   $keywords,$listTemplet,$idlist,'',0,'',$ctag->GetAtt("imgwidth"),$ctag->GetAtt("imgheight"));
				$notestr = str_replace("~notename~",$notename,$tempStr);
				$notestr = str_replace("~spec_arclist~",$idvalue,$notestr);
				$rvalue .= $notestr;
				if($noteid!="" && $ctag->GetAtt("noteid")==$noteid){ break; }
			}
		}

		$dtp->Clear();
		return $rvalue;
	}
	
	//获得进入附件下载页面的链接
	//---------------------------------
	function GetAddLinkPage($fvalue)
	{
		$row = $this->dsql->GetOne("Select downtype From #@__softconfig");
		$phppath = $GLOBALS["cfg_plus_dir"];
		$downlinkpage = "";
		if($row['downtype']=='0'){
		   return $this->GetAddLinks($fvalue,$this->ArcID,$this->ChannelID);
	  }else{
	  	 $tempStr = GetSysTemplets("channel/channel_downlinkpage.htm");
		   $links = $phppath."/download.php?open=0&aid=".$this->ArcID."&cid=".$this->ChannelID;
		   $downlinkpage = str_replace("~link~",$links,$tempStr);
		   return $downlinkpage;
	  }
	}
	
	//获得附件的下载所有链接地址
	//-----------------------------------
	function GetAddLinks($fvalue,$aid,$cid)
	{
		global $cfg_softinfos;
		if(!is_array($cfg_softinfos)){
			$cfg_softinfos = $this->dsql->GetOne("Select ismoresite,sites,gotojump,showlocal From #@__softconfig");
	  }
		$phppath = $GLOBALS['cfg_phpurl'];
		$downlinks = "";
		$dtp = new DedeTagParse();
    $dtp->LoadSource($fvalue);
    if(!is_array($dtp->CTags)){
    	$dtp->Clear();
    	return "无链接信息!";
    }
    $tempStr = GetSysTemplets("channel/channel_downlinks.htm");
    foreach($dtp->CTags as $ctag)
    {
    	if($ctag->GetName()=="link")
    	{
    	  $links = trim($ctag->GetInnerText());
    	  $serverName = trim($ctag->GetAtt("text"));
    	  if(!isset($firstLink)){ $firstLink = $links; }
    	  if($cfg_softinfos['showlocal']==0 || $cfg_softinfos['ismoresite']!=1)
    	  {
    	     if($cfg_softinfos['gotojump']==1) $links = $phppath."/download.php?open=1&aid=$aid&cid=$cid&link=".urlencode(base64_encode($links));
    	     $temp = str_replace("~link~",$links,$tempStr);
    	     $temp = str_replace("~server~",$serverName,$temp);
    	     $downlinks .= $temp;
    	  }
      }
    }
    $dtp->Clear();
    //启用镜像功能的情况
    if($cfg_softinfos['ismoresite']==1 && !empty($cfg_softinfos['sites']) && isset($firstLink))
    {
    	if(!empty($GLOBALS['cfg_basehost'])) $firstLink = eregi_replace($GLOBALS['cfg_basehost'],"",$firstLink);
    	
    	$cfg_softinfos['sites'] = ereg_replace("\n{1,}","\n",str_replace("\r","\n",$cfg_softinfos['sites']));
    	$sites = explode("\n",trim($cfg_softinfos['sites']));
    	foreach($sites as $site)
    	{
    		if(trim($site)=='') continue;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -