function plus_spacenewart(&$atts, &$refObj, &$fields)
{
    global $dsql, $_vars;
    $attlist = "channel=1,titlelen=30,infolen=200,row=8,imgwidth=120,imgheight=90";
    FillAtts($atts, $attlist);
    FillFields($atts, $fields, $refObj);
    extract($atts, EXTR_OVERWRITE);
    $query = "Select arc.*,mt.mtypename,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,\r\n\t\ttp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\r\n\t\tfrom `#@__archives` arc\r\n\t\tleft join `#@__arctype` tp on arc.typeid=tp.id\r\n\t\tleft join `#@__mtypes` mt on mt.mtypeid=arc.mtype\r\n\t\twhere arc.mid='{$_vars['mid']}' and arc.channel={$channel}\r\n\t\torder by id desc limit 0,{$row}";
    $dsql->SetQuery($query);
    $dsql->Execute("al");
    $artlist = '';
    $rearr = array();
    while ($row = $dsql->GetArray("al")) {
        //处理一些特殊字段
        $row['infos'] = cn_substr($row['description'], $infolen);
        $row['id'] = $row['id'];
        $row['arcurl'] = GetFileUrl($row['id'], $row['typeid'], $row['senddate'], $row['title'], $row['ismake'], $row['arcrank'], $row['namerule'], $row['typedir'], $row['money'], $row['filename'], $row['moresite'], $row['siteurl'], $row['sitepath']);
        $row['typeurl'] = GetTypeUrl($row['typeid'], $row['typedir'], $row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'], $row['moresite'], $row['siteurl'], $row['sitepath']);
        if ($row['litpic'] == '') {
            $row['litpic'] = '/images/defaultpic.gif';
        }
        if (!eregi("^http://", $row['litpic'])) {
            $row['picname'] = $row['litpic'] = $GLOBALS['cfg_cmsurl'] . $row['litpic'];
        } else {
            $row['picname'] = $row['litpic'] = $row['litpic'];
        }
        $row['stime'] = GetDateMK($row['pubdate']);
        $row['typelink'] = "<a href='" . $row['typeurl'] . "'>" . $row['typename'] . "</a>";
        $row['image'] = "<img src='" . $row['picname'] . "' border='0' width='{$imgwidth}' height='{$imgheight}' alt='" . ereg_replace("['><]", "", $row['title']) . "'>";
        $row['imglink'] = "<a href='" . $row['filename'] . "'>" . $row['image'] . "</a>";
        $row['fulltitle'] = $row['title'];
        $row['title'] = cn_substr($row['title'], $titlelen);
        if ($row['color'] != '') {
            $row['title'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
        }
        if (ereg('b', $row['flag'])) {
            $row['title'] = "<strong>" . $row['title'] . "</strong>";
        }
        //$row['title'] = "<b>".$row['title']."</b>";
        $row['textlink'] = "<a href='" . $row['filename'] . "'>" . $row['title'] . "</a>";
        $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
        $row['memberurl'] = $GLOBALS['cfg_memberurl'];
        $row['templeturl'] = $GLOBALS['cfg_templeturl'];
        $rearr[] = $row;
    }
    //loop line
    $dsql->FreeResult("al");
    return $rearr;
}
  function GetList($limitstart,$ismake=1)
  {
    global $cfg_list_son;

		$col = $this->ListObj->GetAtt('col');
    if(empty($col)) $col = 1;
    $titlelen = $this->ListObj->GetAtt('titlelen');
    $infolen = $this->ListObj->GetAtt('infolen');
    $imgwidth = $this->ListObj->GetAtt('imgwidth');
    $imgheight = $this->ListObj->GetAtt('imgheight');
    $titlelen = AttDef($titlelen,60);
    $infolen = AttDef($infolen,250);
    $imgwidth = AttDef($imgwidth,80);
    $imgheight = AttDef($imgheight,80);
    $innertext = trim($this->ListObj->GetInnerText());
		if(empty($innertext)) $innertext = GetSysTemplets("list_fulllist.htm");

		$tablewidth=100;
		if($col=="") $col=1;
		$colWidth = ceil(100/$col);
		$tablewidth = $tablewidth."%";
		$colWidth = $colWidth."%";

		//按不同情况设定SQL条件
		$orwhere = " arc.arcrank > -1 And channel>-1 ";

		$typeid = $this->ListObj->GetAtt('typeid');
 		$subday = $this->ListObj->GetAtt('subday');
 		$listtype = $this->ListObj->GetAtt('type');
 		$att = $this->ListObj->GetAtt('att');
 		$channelid = $this->ListObj->GetAtt('channel');
 		if(empty($channelid)) $channelid = 0;

 		//是否指定栏目条件
 		if(!empty($typeid)){
 		  	if($cfg_list_son=='N') $orwhere .= " And (arc.typeid='$typeid' or arc.typeid2='$typeid') ";
 		    else $orwhere .= " And (".$this->TypeLink->GetSunID($typeid,"arc",$this->Fields['channeltype'])." Or arc.typeid2='$typeid') ";
 		}
 		//自定义属性条件
 		if($att!="") $orwhere .= "And arc.arcatt='$att' ";

		//文档的频道模型
		if($channelid>0 && !eregi("spec",$listtype)) $orwhere .= " And arc.channel = '$channelid' ";

		//推荐文档 带缩略图  专题文档
		if(eregi("commend",$listtype)) $orwhere .= " And arc.iscommend > 10  ";
		if(eregi("image",$listtype)) $orwhere .= " And arc.litpic <> ''  ";
		if(eregi("spec",$listtype) || $channelid==-1) $orwhere .= " And arc.channel = -1  ";

 		if(!empty($subday)){
 		  $starttime = time() - $subday;
 		  $orwhere .= " And arc.senddate > $starttime  ";
 		}

 		$keyword = $this->ListObj->GetAtt('keyword');
 		if(!empty($keyword)) $orwhere .= " And CONCAT(arc.title,arc.keywords) REGEXP '$keyword' ";

		$orderby = $this->ListObj->GetAtt('orderby');
		$orderWay = $this->ListObj->GetAtt('orderway');
		//排序方式
		$ordersql = "";
		if($orderby=="senddate") $ordersql=" order by arc.senddate $orderWay";
		else if($orderby=="pubdate") $ordersql=" order by arc.pubdate $orderWay";
    else if($orderby=="id") $ordersql="  order by arc.ID $orderWay";
    else if($orderby=="hot"||$orderby=="click") $ordersql = " order by arc.click $orderWay";
		else if($orderby=="lastpost") $ordersql = "  order by arc.lastpost $orderWay";
    else if($orderby=="postnum") $ordersql = "  order by arc.postnum $orderWay";
    else if($orderby=="rand") $ordersql = "  order by rand()";
		else $ordersql=" order by arc.sortrank $orderWay";

		//获得附加表的相关信息
		//-----------------------------
		$addField = "";
		$addJoin = "";
		if(is_object($this->ChannelUnit)){
		  $addtable  = $this->ChannelUnit->ChannelInfos['addtable'];
		  if($addtable!=""){
			  $addJoin = " left join $addtable on arc.ID = ".$addtable.".aid ";
			  $addField = "";
			  $fields = explode(",",$this->ChannelUnit->ChannelInfos['listadd']);
			  foreach($fields as $k=>$v){ $nfields[$v] = $k; }
			  foreach($this->ChannelUnit->ChannelFields as $k=>$arr){
				  if(isset($nfields[$k])){
				     if($arr['rename']!="") $addField .= ",".$addtable.".".$k." as ".$arr['rename'];
				     else $addField .= ",".$addtable.".".$k;
				  }
			 }
		  }
		}
		//
		//----------------------------
		$query = "Select arc.ID,arc.title,arc.iscommend,arc.color,
		arc.typeid,arc.ismake,arc.money,arc.description,arc.shorttitle,
		arc.memberid,arc.writer,arc.postnum,arc.lastpost,
		arc.pubdate,arc.senddate,arc.arcrank,arc.click,arc.litpic,
		tp.typedir,tp.typename,tp.isdefault,tp.defaultname,
		tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl
		$addField
		from {$this->maintable} arc
		left join #@__arctype tp on arc.typeid=tp.ID
		$addJoin
		where $orwhere $ordersql limit $limitstart,".$this->PageSize;
		$this->dsql->SetQuery($query);
		$this->dsql->Execute("al");
    $artlist = "";
    if($col>1) $artlist = "<table width='$tablewidth' border='0' cellspacing='0' cellpadding='0'>\r\n";
    $indtp = new DedeTagParse();
 		$indtp->SetNameSpace("field","[","]");
    $indtp->LoadSource($innertext);
    $GLOBALS['autoindex'] = 0;
    for($i=0;$i<$this->PageSize;$i++)
		{
       if($col>1) $artlist .= "<tr>\r\n";
       for($j=0;$j<$col;$j++)
			 {
         if($col>1) $artlist .= "<td width='$colWidth'>\r\n";
         if($row = $this->dsql->GetArray("al"))
         {
           $GLOBALS['autoindex']++;
           //处理一些特殊字段
           $row['id'] =  $row['ID'];
           $row['arcurl'] = $this->GetArcUrl($row['id'],$row['typeid'],$row['senddate'],$row['title'],$row['ismake'],$row['arcrank'],$row['namerule'],$row['typedir'],$row['money']);
           $row['typeurl'] = $this->GetListUrl($row['typeid'],$row['typedir'],$row['isdefault'],$row['defaultname'],$row['ispart'],$row['namerule2'],"abc");

           if($ismake==0 && $GLOBALS['cfg_multi_site']=='Y'){
           	 if($row["siteurl"]=="") $row["siteurl"] = $GLOBALS['cfg_mainsite'];
           	 if(!eregi("^http://",$row['picname'])){
           	 	  $row['litpic'] = $row['siteurl'].$row['litpic'];
           	 	  $row['picname'] = $row['litpic'];
           	 }
           }

           $row['description'] = cnw_left($row['description'],$infolen);
           if($row['litpic']=="") $row['litpic'] = $GLOBALS['cfg_plus_dir']."/img/dfpic.gif";
           $row['picname'] = $row['litpic'];
           $row['info'] = $row['description'];
           $row['filename'] = $row['arcurl'];
           $row['stime'] = GetDateMK($row['pubdate']);
           $row['textlink'] = "<a href='".$row['filename']."' title='".str_replace("'","",$row['title'])."'>".$row['title']."</a>";
           $row['typelink'] = "<a href='".$row['typeurl']."'>[".$row['typename']."]</a>";
           $row['imglink'] = "<a href='".$row['filename']."'><img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".str_replace("'","",$row['title'])."'></a>";
           $row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".str_replace("'","",$row['title'])."'>";
           $row['phpurl'] = $GLOBALS['cfg_plus_dir'];
           $row['plusurl'] = $GLOBALS['cfg_plus_dir'];
 		       $row['templeturl'] = $GLOBALS['cfg_templets_dir'];
 		       $row['memberurl'] = $GLOBALS['cfg_member_dir'];
 		       $row['title'] = cn_substr($row['title'],$titlelen);
           if($row['color']!="") $row['title'] = "<font color='".$row['color']."'>".$row['title']."</font>";
           if($row['iscommend']==5||$row['iscommend']==16) $row['title'] = "<b>".$row['title']."</b>";
           //编译附加表里的数据
           if(is_object($this->ChannelUnit)){
              foreach($row as $k=>$v){
 		  	         if(ereg("[A-Z]",$k)) $row[strtolower($k)] = $v;
 		          }
              foreach($this->ChannelUnit->ChannelFields as $k=>$arr){
 		  	         if(isset($row[$k])) $row[$k] = $this->ChannelUnit->MakeField($k,$row[$k]);
 		  	      }
 		  	   }
           //---------------------------
           //解析单条记录
           //-------------------------
           if(is_array($indtp->CTags)){
       	      foreach($indtp->CTags as $k=>$ctag){
       		 	    $_f = $ctag->GetName();
       		 	    if(isset($row[$_f])) $indtp->Assign($k,$row[$_f]);
       		 	    else $indtp->Assign($k,"");
       	     }
           }
           $artlist .= $indtp->GetResult();
         }//if hasRow
         else{
         	 $artlist .= "";
         }
         if($col>1) $artlist .= "	</td>\r\n";
       }//Loop Col
       if($col>1) $i += $col - 1;
       if($col>1) $artlist .= "	</tr>\r\n";
     }//Loop Line
     if($col>1) $artlist .= "</table>\r\n";
     $this->dsql->FreeResult("al");
     return $artlist;
  }
	function GetArcList($limitstart=0,$row=10,$col=1,$titlelen=30,$infolen=250,
	$imgwidth=120,$imgheight=90,$listtype="all",$orderby="default",$innertext="",$tablewidth="100",$ismake=1,$orderWay='desc')
	{
		global $cfg_list_son;
		$t1 = ExecTime();
		$getrow = ($row=="" ? 10 : $row);
		if($limitstart=="") $limitstart = 0;
		if($titlelen=="") $titlelen = 100;
		if($infolen=="") $infolen = 250;
		if($imgwidth=="") $imgwidth = 120;
		if($imgheight=="") $imgheight = 120;
		if($listtype=="") $listtype = "all";
		if($orderby=="") $orderby="default";
		else $orderby=strtolower($orderby);
		if($orderWay=='') $orderWay = 'desc';
		$tablewidth = str_replace("%","",$tablewidth);
		if($tablewidth=="") $tablewidth=100;
		if($col=="") $col=1;
		$colWidth = ceil(100/$col);
		$tablewidth = $tablewidth."%";
		$colWidth = $colWidth."%";
		$innertext = trim($innertext);
		if($innertext=="") $innertext = GetSysTemplets("list_fulllist.htm");

		$idlists = '';
		$this->dsql->SetQuery("Select aid From #@__tag_list where tid='{$this->TagID}' And arcrank>-1 limit $limitstart,$getrow");
		//echo "Select aid From #@__tag_list where tid='{$this->TagID}' And arcrank>-1 limit $limitstart,$getrow";
		$this->dsql->Execute();
		while($row=$this->dsql->GetArray()){
			$idlists .= ($idlists=='' ? $row['aid'] : ','.$row['aid']);
		}
		if($idlists=='') return '';

		//按不同情况设定SQL条件
		$orwhere = " se.aid in($idlists) ";

		//排序方式
		$ordersql = "";
		if($orderby=="uptime") $ordersql = "  order by se.uptime $orderWay";
		else $ordersql=" order by se.aid $orderWay";

		//----------------------------
		$query = "Select se.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl
			from `#@__full_search` se left join `#@__arctype` tp on se.typeid=tp.ID
			where $orwhere $ordersql
		";

		$this->dsql->SetQuery($query);
		$this->dsql->Execute('al');
		echo $this->dsql->GetError();
		$artlist = "";
		if($col>1) $artlist = "<table width='$tablewidth' border='0' cellspacing='0' cellpadding='0'>\r\n";
		$this->dtp2->LoadSource($innertext);
		if(!is_array($this->dtp2->CTags)) return '';
		$GLOBALS['autoindex'] = 0;
		for($i=0;$i<$getrow;$i++)
		{
				if($col>1) $artlist .= "<tr>\r\n";
				for($j=0;$j<$col;$j++)
				{
					if($col>1) $artlist .= "<td width='$colWidth'>\r\n";
					if($row = $this->dsql->GetArray('al',MYSQL_ASSOC))
					{
						$GLOBALS['autoindex']++;
						//处理一些特殊字段
						$row['id'] =  $row['aid'];
						$row['arcurl'] = $row['url'];
						$row['typeurl'] = $this->GetListUrl($row['typeid'],$row['typedir'],$row['isdefault'],$row['defaultname'],$row['ispart'],$row['namerule2'],"abc");

						if($ismake==0 && $GLOBALS['cfg_multi_site']=='Y')
						{
							if($row['litpic']==''){
								$row['litpic'] = $GLOBALS['cfg_mainsite'].$GLOBALS['cfg_plus_dir']."/img/dfpic.gif";
              }
							else if(!eregi("^http://",$row['picname'])){
								$row['litpic'] = $row['siteurl'].$row['litpic'];
							}
							$row['picname'] = $row['litpic'];
						}else
						{
							if($row['litpic']=='') $row['litpic'] = $GLOBALS['cfg_plus_dir']."/img/dfpic.gif";
						}

						$row['description'] = cnw_left($row['addinfos'],$infolen);
						$row['picname'] = $row['litpic'];
						$row['info'] = $row['description'];
						$row['filename'] = $row['arcurl'];
						$row['uptime'] = GetDateMK($row['uptime']);
						$row['typelink'] = "<a href='".$row['typeurl']."'>[".$row['typename']."]</a>";
						$row['imglink'] = "<a href='".$row['filename']."'><img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".str_replace("'","",$row['title'])."'></a>";
						$row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".str_replace("'","",$row['title'])."'>";
						$row['title'] = cn_substr($row['title'],$titlelen);
						$row['textlink'] = "<a href='".$row['filename']."' title='".str_replace("'","",$row['title'])."'>".$row['title']."</a>";

						foreach($this->dtp2->CTags as $k=>$ctag)
						{
							if(isset($row[$ctag->GetName()])) $this->dtp2->Assign($k,$row[$ctag->GetName()]);
							else $this->dtp2->Assign($k,"");
						}

						$artlist .= $this->dtp2->GetResult();
					//if hasRow
					}else
					{
						$artlist .= "";
					}
					if($col>1) $artlist .= "	</td>\r\n";
				}//Loop Col
				if($col>1) $i += $col - 1;
				if($col>1) $artlist .= "	</tr>\r\n";
		}//Loop Line
		if($col>1) $artlist .= "</table>\r\n";
		$this->dsql->FreeResult("al");
		return $artlist;
	}
function SpGetFullList(&$dsql,$typeid=0,$channelid=0,$row=10,$titlelen=30,$infolen=160,
   $keyword='',$innertext='',$idlist='',$limitv='',$ismember=0,$orderby='',$imgwidth=120,$imgheight=120)
  {
		global $cfg_maxsearch,$cfg_al_cachetime;
		$row = AttDef($row,10);
		$line = $row;
		$titlelen = AttDef($titlelen,30);
		$infolen = AttDef($infolen,160);
    $channelid = AttDef($channelid,0);
    $ismember = AttDef($ismember,0);
    $limitv = AttDef($limitv,'');
		$keyword = trim($keyword);
		$typeid = AttDef($typeid,'');
		$innertext = trim($innertext);
		$imgwidth = AttDef($imgwidth,120);
		$imgheight = AttDef($imgheight,120);
		$orderby = trim($orderby);
		if($innertext=="") $innertext = GetSysTemplets("part_arclist.htm");
		if(empty($idlist)) $idlist = '';
		else $idlist = ereg_replace("[^,0-9]","",$idlist);

    $orwhere = '';
    $mintime = time() - ($cfg_al_cachetime * 3600);
    //指定的文档ID列表,通常是专题和相关文章,使用了idlist将不启用后面任何条件
	  $idlist = trim($idlist);
	  if($idlist!='')
	  {
	  	$orwhere .= " arcf.aid in ($idlist) And arcf.arcrank > -1 ";
	  }
    //没使用idlist才启用这些条件
    else
    {
		  //按不同情况设定SQL条件 排序方式
	    $orwhere .= " arcf.arcrank > -1 ";
		  //文档的频道模型
		  if(!empty($channelid)) $orwhere .= " And arcf.channelid = '$channelid' ";

		  //是否为会员文档
		  if($ismember==1) $orwhere .= " And arcf.memberid>0  ";

		  //指定栏目条件,如果用 "," 分开,可以指定特定类目
		  if(!empty($typeid) && empty($idlist))
		  {
		    $reids = explode(",",$typeid);
		    $ridnum = count($reids);
		    if($ridnum>1){
			    $tpsql = "";
		      for($i=0;$i<$ridnum;$i++)
		      {
				    $sonids = TypeGetSunID($reids[$i],$dsql,'arc',0,true);
				    $tpsql .= ($tpsql=='' ? $sonids : ','.$sonids);
		      }
		      $tpsql = " And arcf.typeid in ($tpsql) ";
		      $orwhere .= $tpsql;
		      unset($tpsql);
		    }else{
			    $sonids = TypeGetSunID($typeid,$dsql,'arc',0,true);
			    if(ereg(',',$sonids)) $orwhere .= " And arcf.typeid in ($sonids) ";
			    else $orwhere .= " And arcf.typeid=$sonids ";
		    }
		    unset($reids);
	    }

		  //指定了关键字条件
		  if($keyword!="")
		  {
		    $keywords = explode(",",$keyword);
		    $ridnum = count($keywords);
		    $rstr = trim($keywords[0]);
		    if($ridnum>4) $ridnum = 4;
		    for($i=1;$i < $ridnum;$i++){
			    $keywords[$i] = trim($keywords[$i]);
			    if($keywords[$i]!="") $rstr .= "|".$keywords[$i];
			  }
		    if($rstr!="") $orwhere .= " And CONCAT(arcf.title,arcf.keywords) REGEXP '$rstr' ";
		    unset($keywords);
	    }
    }//没使用idlist才启用这些条件
    
	 //文档排序的方式
		$ordersql = "";
    if($orderby=='rand') $ordersql = "  order by rand()";
    else if($orderby=='click'||$orderby=='hot') $ordersql = "  order by arcf.click desc";
    else if($orderby=='digg') $ordersql = "  order by arcf.digg desc";
    else if($orderby=='diggtime') $ordersql = "  order by arcf.diggtime desc";
		else $ordersql=" order by arcf.aid desc";

    //返回结果条数
	  if(!empty($limit)) $limitsql = " limit $limitv ";
	  else $limitsql = " limit 0,$line ";

	  //载入底层模板
	  $dtp2 = new DedeTagParse();
    $dtp2->SetNameSpace("field","[","]");
    $dtp2->LoadString($innertext);
    if(!is_array($dtp2->CTags)) return '';

		//执行SQL查询
		$query = "Select arcf.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl
		from `#@__full_search` arcf left join `#@__arctype` tp on arcf.typeid=tp.ID
		where $orwhere $ordersql $limitsql ";
		
		$md5hash = md5($query);
		$artlist = '';
		$ids = '';
		$needup = false;
		if($idlist=='' && $cfg_al_cachetime>0)
		{
		  	$ids = SpGetArclistDateCacheF($dsql,$md5hash);
		  	if($ids=='-1') $needup = true;
		  	else if($ids!='')
		  	{
		         $query = "Select arcf.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl
		                 from `#@__full_search` arcf left join `#@__arctype` tp on arcf.typeid=tp.ID
		                 where arcf.aid in($ids) $ordersql $limitsql ";
		  	}else 
		  	{
		  		return '';
		  	}
		}
		$nids = array();
		$t1 = ExecTime();
		$dsql->SetQuery($query);
		$dsql->Execute("alf");
    
    $GLOBALS['autoindex'] = 0;
    while($row = $dsql->GetArray("alf"))
    {
       //处理一些特殊字段
       $row['description'] = cn_substr($row['addinfos'],$infolen);
       $nids[] = $row['id'] =  $row['aid'];
       if(!isset($row['picname'])) $row['picname'] = '';
       
       if($row['url']=='') $row['url'] = $GLOBALS['cfg_phpurl'].'/view.php?aid='.$row['aid'];
       
       $row['filename'] = $row['arcurl'] = $row['url'];
       $row['typeurl'] = GetTypeUrl($row['typeid'],MfTypedir($row['typedir']),$row['isdefault'],$row['defaultname'],$row['ispart'],$row['namerule2'],$row['siteurl']);
       if($row['litpic']=="") $row['litpic'] = $GLOBALS['PubFields']['templeturl']."/img/default.gif";
       $row['picname'] = $row['litpic'];
       if($GLOBALS['cfg_multi_site']=='Y')
       {
           if($row['siteurl']=="") $row['siteurl'] = $GLOBALS['cfg_mainsite'];
           if(!eregi("^http://",$row['picname'])){
           	 	$row['litpic'] = $row['siteurl'].$row['litpic'];
           	 	$row['picname'] = $row['litpic'];
           }
       }
       $row['stime'] = GetDateMK($row['uptime']);
       $row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
       $row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".ereg_replace("['><]","",$row['title'])."' />";
       $row['imglink'] = "<a href='".$row['arcurl']."'>".$row['image']."</a>";
       $row['fulltitle'] = $row['title'];
       $row['title'] = cn_substr($row['title'],$titlelen);
       $row['textlink'] = "<a href='".$row['arcurl']."'>".$row['title']."</a>";
       foreach($dtp2->CTags as $k=>$ctag)
       {
       		if(isset($row[$ctag->GetName()])){
       			$dtp2->Assign($k,$row[$ctag->GetName()]);
       		}
       		else $dtp2->Assign($k,'');
       }
       $GLOBALS['autoindex']++;
       $artlist .= $dtp2->GetResult();
     }//Loop Line
     $dsql->FreeResult("alf");
     
     if($needup)
     {
     	  $ids = join(',',$nids);
     	  $inquery = "INSERT INTO `#@__arccache_full`(`md5hash`,`uptime`,`cachedata`) VALUES ('".$md5hash."', '".time()."', '$ids'); ";
	      $dsql->ExecuteNoneQuery("Delete From `#@__arccache_full` where md5hash='".$md5hash."' or uptime < $mintime ");
	      $dsql->ExecuteNoneQuery($inquery);
     }
     
     $t2 = ExecTime();
     //echo "<hr>".($t2-$t1)." $query<hr>";
     return $artlist;
}
  function GetArcList($innertext="")
  {
    $typeid=$this->TypeID;
		$innertext = trim($innertext);
		if($innertext=="") $innertext = GetSysTemplets("rss.htm");
		$orwhere = " #@__archives.arcrank > -1 ";
		$orwhere .= " And (".$this->TypeLink->GetSunID($this->TypeID,"#@__archives",$this->TypeFields['channeltype'])." Or #@__archives.typeid2='".$this->TypeID."') ";
		$ordersql=" order by #@__archives.senddate desc";
		//----------------------------
		$query = "Select #@__archives.ID,#@__archives.title,#@__archives.source,#@__archives.writer,#@__archives.typeid,#@__archives.ismake,#@__archives.money,
		#@__archives.description,#@__archives.pubdate,#@__archives.senddate,#@__archives.arcrank,#@__archives.click,
		#@__archives.litpic,#@__arctype.typedir,#@__arctype.typename,#@__arctype.isdefault,
		#@__arctype.defaultname,#@__arctype.namerule,#@__arctype.namerule2,#@__arctype.ispart,
		#@__arctype.siteurl 
		from #@__archives 
		left join #@__arctype on #@__archives.typeid=#@__arctype.ID
		where $orwhere $ordersql limit 0,".$this->MaxRow;
		$this->dsql->SetQuery($query);
		$this->dsql->Execute("al");
    $artlist = "";
    $dtp2 = new DedeTagParse();
 		$dtp2->SetNameSpace("field","[","]");
    $dtp2->LoadSource($innertext);
    while($row = $this->dsql->GetArray("al"))
    {
      //处理一些特殊字段
      if($row["litpic"]=="") $row["litpic"] = $GLOBALS["cfg_plus_dir"]."/img/dfpic.gif";
      $row["picname"] = $row["litpic"];
      $row["arcurl"] = $this->GetArcUrl($row["ID"],$row["typeid"],$row["senddate"],$row["title"],
                        $row["ismake"],$row["arcrank"],$row["namerule"],$row["typedir"],$row["money"]);
      $row["typeurl"] = $this->GetListUrl($row["typeid"],$row["typedir"],$row["isdefault"],$row["defaultname"],$row["ispart"],$row["namerule2"]);
      $row["info"] = $row["description"];
      $row["filename"] = $row["arcurl"];
      $row["stime"] = GetDateMK($row["pubdate"]);
      $row["image"] = "<img src='".$row["picname"]."' border='0'>";
      $row["fullurl"] = $row['siteurl'].$row["arcurl"];
      $row["phpurl"] = $GLOBALS["cfg_plus_dir"];
 		  $row["templeturl"] = $GLOBALS["cfg_templets_dir"];
 		  if($row["source"]=="") $row["source"] = $GLOBALS['cfg_webname'];
 		  if($row["writer"]=="") $row["writer"] = "秩名";
 		  
 		  foreach($row as $k=>$v){
 		  	$row[$k] = htmlspecialchars($v);
 		  }
      //---------------------------
      if(is_array($dtp2->CTags)){
       	foreach($dtp2->CTags as $k=>$ctag){
       		if(isset($row[$ctag->GetName()])) $dtp2->Assign($k,$row[$ctag->GetName()]);
       		else $dtp2->Assign($k,"");
       	}
      }
      $artlist .= $dtp2->GetResult()."\r\n";
     }
     $this->dsql->FreeResult("al");
     return $artlist;
  }
Exemple #6
0
 //处理一些特殊字段
 $row['info'] = $row['infos'] = cn_substr($row['description'], $infolen);
 $row['id'] = $row['id'];
 if ($row['corank'] > 0 && $row['arcrank'] == 0) {
     $row['arcrank'] = $row['corank'];
 }
 $row['filename'] = $row['arcurl'] = GetFileUrl($row['id'], $row['typeid'], $row['senddate'], $row['title'], $row['ismake'], $row['arcrank'], $row['namerule'], $row['typedir'], $row['money'], $row['filename'], $row['moresite'], $row['siteurl'], $row['sitepath']);
 $row['typeurl'] = GetTypeUrl($row['typeid'], $row['typedir'], $row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'], $row['moresite'], $row['siteurl'], $row['sitepath']);
 if ($row['litpic'] == '-' || $row['litpic'] == '') {
     $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
 }
 if (!preg_match("#^http:\\/\\/#", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
     $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
 }
 $row['picname'] = $row['litpic'];
 $row['stime'] = GetDateMK($row['pubdate']);
 $row['typelink'] = "<a href='" . $row['typeurl'] . "'>" . $row['typename'] . "</a>";
 $row['image'] = "<img src='" . $row['picname'] . "' border='0' width='{$imgwidth}' height='{$imgheight}' alt='" . preg_replace("#['><]#", "", $row['title']) . "'>";
 $row['imglink'] = "<a href='" . $row['filename'] . "'>" . $row['image'] . "</a>";
 $row['fulltitle'] = $row['title'];
 $row['title'] = cn_substr($row['title'], $titlelen);
 if ($row['color'] != '') {
     $row['title'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
 }
 if (preg_match('#b#', $row['flag'])) {
     $row['title'] = "<strong>" . $row['title'] . "</strong>";
 }
 //$row['title'] = "<b>".$row['title']."</b>";
 $row['textlink'] = "<a href='" . $row['filename'] . "'>" . $row['title'] . "</a>";
 $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
 $row['memberurl'] = $GLOBALS['cfg_memberurl'];
 /**
  *  获得文档列表
  *
  * @access    public
  * @param     string  $innertext  底层模板
  * @return    string
  */
 function GetArcList($innertext = "")
 {
     $typeid = $this->TypeID;
     $innertext = trim($innertext);
     if ($innertext == "") {
         $innertext = GetSysTemplets("rss.htm");
     }
     $orwhere = " arc.arcrank > -1 ";
     $orwhere .= " AND (arc.typeid in (" . GetSonIds($this->TypeID, $this->TypeFields['channeltype']) . ") ) ";
     $ordersql = " ORDER BY arc.id desc";
     $query = "SELECT arc.*,tp.typedir,tp.typename,tp.isdefault,\r\n        tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\r\n        FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\r\n        WHERE {$orwhere} {$ordersql} LIMIT 0," . $this->MaxRow;
     $this->dsql->SetQuery($query);
     $this->dsql->Execute('al');
     $artlist = '';
     $dtp2 = new DedeTagParse();
     $dtp2->SetNameSpace('field', '[', ']');
     $dtp2->LoadSource($innertext);
     while ($row = $this->dsql->GetArray('al')) {
         //处理一些特殊字段
         if ($row['litpic'] == '-' || $row['litpic'] == '') {
             $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
         }
         if (!preg_match("/^http:\\/\\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
             $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
         }
         $row['picname'] = $row['litpic'];
         $row["arcurl"] = GetFileUrl($row["id"], $row["typeid"], $row["senddate"], $row["title"], $row["ismake"], $row["arcrank"], $row["namerule"], $row["typedir"], $row["money"], $row['filename'], $row["moresite"], $row["siteurl"], $row["sitepath"]);
         $row["typeurl"] = GetTypeUrl($row["typeid"], $row["typedir"], $row["isdefault"], $row["defaultname"], $row["ispart"], $row["namerule2"], $row["moresite"], $row["siteurl"], $row["sitepath"]);
         $row["info"] = $row["description"];
         $row["filename"] = $row["arcurl"];
         $row["stime"] = GetDateMK($row["pubdate"]);
         $row["image"] = "<img src='" . $row["picname"] . "' border='0'>";
         $row["fullurl"] = $GLOBALS["cfg_basehost"] . $row["arcurl"];
         // 2011-6-20 启用多站点RSS输出存在的路径问题(by:织梦的鱼)
         if ($GLOBALS['cfg_multi_site'] == 'Y') {
             $row["fullurl"] = $row["arcurl"];
         }
         $row["phpurl"] = $GLOBALS["cfg_plus_dir"];
         $row["templeturl"] = $GLOBALS["cfg_templets_dir"];
         if ($row["source"] == '') {
             $row["source"] = $GLOBALS['cfg_webname'];
         }
         if ($row["writer"] == '') {
             $row["writer"] = "秩名";
         }
         foreach ($row as $k => $v) {
             $row[$k] = htmlspecialchars($v);
         }
         if (is_array($dtp2->CTags)) {
             foreach ($dtp2->CTags as $k => $ctag) {
                 if ($ctag->GetName() == 'array') {
                     //传递整个数组,在runphp模式中有特殊作用
                     $dtp2->Assign($k, $row);
                 } else {
                     if (isset($row[$ctag->GetName()])) {
                         $dtp2->Assign($k, $row[$ctag->GetName()]);
                     } else {
                         $dtp2->Assign($k, '');
                     }
                 }
             }
         }
         $artlist .= $dtp2->GetResult() . "\r\n";
     }
     $this->dsql->FreeResult('al');
     return $artlist;
 }
 function GetArcList($limitstart = 0, $row = 10, $col = 1, $titlelen = 30, $infolen = 250, $imgwidth = 120, $imgheight = 90, $achanneltype = "all", $orderby = "default", $innertext = "", $tablewidth = "100")
 {
     $typeid = $this->TypeID;
     if ($row == '') {
         $row = 10;
     }
     if ($limitstart == '') {
         $limitstart = 0;
     }
     if ($titlelen == '') {
         $titlelen = 30;
     }
     if ($infolen == '') {
         $infolen = 250;
     }
     if ($imgwidth == '') {
         $imgwidth = 120;
     }
     if ($imgheight = '') {
         $imgheight = 120;
     }
     if ($achanneltype == '') {
         $achanneltype = '0';
     }
     $orderby = $orderby == '' ? 'default' : strtolower($orderby);
     $tablewidth = str_replace("%", "", $tablewidth);
     if ($tablewidth == '') {
         $tablewidth = 100;
     }
     if ($col == '') {
         $col = 1;
     }
     $colWidth = ceil(100 / $col);
     $tablewidth = $tablewidth . "%";
     $colWidth = $colWidth . "%";
     $innertext = trim($innertext);
     if ($innertext == '') {
         $innertext = GetSysTemplets("search_list.htm");
     }
     //排序方式
     $ordersql = '';
     if ($orderby == "senddate") {
         $ordersql = " order by arc.senddate desc";
     } else {
         if ($orderby == "pubdate") {
             $ordersql = " order by arc.pubdate desc";
         } else {
             if ($orderby == "id") {
                 $ordersql = "  order by arc.id desc";
             } else {
                 $ordersql = " order by arc.sortrank desc";
             }
         }
     }
     //搜索
     $query = "Select arc.*,act.typedir,act.typename,act.isdefault,act.defaultname,act.namerule,\r\n\t\tact.namerule2,act.ispart,act.moresite,act.siteurl,act.sitepath\r\n\t\tfrom `#@__archives` arc left join `#@__arctype` act on arc.typeid=act.id\r\n\t\twhere {$this->AddSql} {$ordersql} limit {$limitstart},{$row}";
     $this->dsql->SetQuery($query);
     $this->dsql->Execute("al");
     $artlist = "";
     if ($col > 1) {
         $artlist = "<table width='{$tablewidth}' border='0' cellspacing='0' cellpadding='0'>\r\n";
     }
     $this->dtp2->LoadSource($innertext);
     for ($i = 0; $i < $row; $i++) {
         if ($col > 1) {
             $artlist .= "<tr>\r\n";
         }
         for ($j = 0; $j < $col; $j++) {
             if ($col > 1) {
                 $artlist .= "<td width='{$colWidth}'>\r\n";
             }
             if ($row = $this->dsql->GetArray("al")) {
                 //处理一些特殊字段
                 $row["arcurl"] = GetFileUrl($row["id"], $row["typeid"], $row["senddate"], $row["title"], $row["ismake"], $row["arcrank"], $row["namerule"], $row["typedir"], $row["money"], $row['filename'], $row["moresite"], $row["siteurl"], $row["sitepath"]);
                 $row["description"] = $this->GetRedKeyWord(cn_substr($row["description"], $infolen));
                 $row["title"] = $this->GetRedKeyWord(cn_substr($row["title"], $titlelen));
                 $row["id"] = $row["id"];
                 if ($row['litpic'] == '-' || $row['litpic'] == '') {
                     $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
                 }
                 if (!eregi("^http://", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
                     $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
                 }
                 $row['picname'] = $row['litpic'];
                 $row["typeurl"] = GetTypeUrl($row["typeid"], $row["typedir"], $row["isdefault"], $row["defaultname"], $row["ispart"], $row["namerule2"], $row["moresite"], $row["siteurl"], $row["sitepath"]);
                 $row["info"] = $row["description"];
                 $row["filename"] = $row["arcurl"];
                 $row["stime"] = GetDateMK($row["pubdate"]);
                 $row["textlink"] = "<a href='" . $row["filename"] . "'>" . $row["title"] . "</a>";
                 $row["typelink"] = "[<a href='" . $row["typeurl"] . "'>" . $row["typename"] . "</a>]";
                 $row["imglink"] = "<a href='" . $row["filename"] . "'><img src='" . $row["picname"] . "' border='0' width='{$imgwidth}' height='{$imgheight}'></a>";
                 $row["image"] = "<img src='" . $row["picname"] . "' border='0' width='{$imgwidth}' height='{$imgheight}'>";
                 $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                 $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                 $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                 if (is_array($this->dtp2->CTags)) {
                     foreach ($this->dtp2->CTags as $k => $ctag) {
                         if ($ctag->GetName() == 'array') {
                             //传递整个数组,在runphp模式中有特殊作用
                             $this->dtp2->Assign($k, $row);
                         } else {
                             if (isset($row[$ctag->GetName()])) {
                                 $this->dtp2->Assign($k, $row[$ctag->GetName()]);
                             } else {
                                 $this->dtp2->Assign($k, '');
                             }
                         }
                     }
                 }
                 $artlist .= $this->dtp2->GetResult();
             } else {
                 $artlist .= "";
             }
             if ($col > 1) {
                 $artlist .= "</td>\r\n";
             }
         }
         //Loop Col
         if ($col > 1) {
             $artlist .= "</tr>\r\n";
         }
     }
     //Loop Line
     if ($col > 1) {
         $artlist .= "</table>\r\n";
     }
     $this->dsql->FreeResult("al");
     return $artlist;
 }
Exemple #9
0
 /**
  *  获得一个单列的文档列表
  *
  * @access    public
  * @param     int  $limitstart  限制开始  
  * @param     int  $row  行数 
  * @param     int  $col  列数
  * @param     int  $titlelen  标题长度
  * @param     int  $infolen  描述长度
  * @param     int  $imgwidth  图片宽度
  * @param     int  $imgheight  图片高度
  * @param     string  $listtype  列表类型
  * @param     string  $orderby  排列顺序
  * @param     string  $innertext  底层模板
  * @param     string  $tablewidth  表格宽度
  * @param     string  $ismake  是否编译
  * @param     string  $orderWay  排序方式
  * @return    string
  */
 function GetArcList($limitstart = 0, $row = 10, $col = 1, $titlelen = 30, $listtype = "all", $orderby = "default", $innertext = "", $tablewidth = "100", $ismake = 1, $orderWay = 'desc')
 {
     global $cfg_list_son;
     $typeid = $this->TypeID;
     if ($row == '') {
         $row = 10;
     }
     if ($limitstart == '') {
         $limitstart = 0;
     }
     if ($titlelen == '') {
         $titlelen = 100;
     }
     if ($listtype == '') {
         $listtype = "all";
     }
     if ($orderby == '') {
         $orderby = 'id';
     } else {
         $orderby = strtolower($orderby);
     }
     if ($orderWay == '') {
         $orderWay = 'desc';
     }
     $tablewidth = str_replace("%", "", $tablewidth);
     if ($tablewidth == '') {
         $tablewidth = 100;
     }
     if ($col == '') {
         $col = 1;
     }
     $colWidth = ceil(100 / $col);
     $tablewidth = $tablewidth . "%";
     $colWidth = $colWidth . "%";
     $innertext = trim($innertext);
     if ($innertext == '') {
         $innertext = GetSysTemplets('list_sglist.htm');
     }
     //排序方式
     $ordersql = '';
     if ($orderby == 'senddate' || $orderby == 'id') {
         $ordersql = " ORDER BY arc.aid {$orderWay}";
     } else {
         if ($orderby == 'hot' || $orderby == 'click') {
             $ordersql = " ORDER BY arc.click {$orderWay}";
         } else {
             $ordersql = " ORDER BY arc.aid {$orderWay}";
         }
     }
     $addField = 'arc.' . join(',arc.', $this->ListFields);
     //如果不用默认的sortrank或id排序,使用联合查询(数据量大时非常缓慢)
     if (preg_match('/hot|click/', $orderby) || $this->sAddTable) {
         $query = "SELECT tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,\n            tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,arc.aid,arc.aid AS id,arc.typeid,\n            {$addField}\n            FROM `{$this->AddTable}` arc\n            LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\n            WHERE {$this->addSql} {$ordersql} LIMIT {$limitstart},{$row}";
     } else {
         $t1 = ExecTime();
         $ids = array();
         $nordersql = str_replace('.aid', '.id', $ordersql);
         $query = "SELECT id From `#@__arctiny` arc WHERE {$this->addSql} {$nordersql} LIMIT {$limitstart},{$row} ";
         $this->dsql->SetQuery($query);
         $this->dsql->Execute();
         while ($arr = $this->dsql->GetArray()) {
             $ids[] = $arr['id'];
         }
         $idstr = join(',', $ids);
         if ($idstr == '') {
             return '';
         } else {
             $query = "SELECT tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,\n                tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,arc.aid,arc.aid AS id,arc.typeid,\n                       {$addField}\n                       FROM `{$this->AddTable}` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\n                       WHERE arc.aid IN({$idstr}) AND arc.arcrank >-1 {$ordersql} ";
         }
         $t2 = ExecTime();
         //echo $t2-$t1;
     }
     $this->dsql->SetQuery($query);
     $this->dsql->Execute('al');
     $t2 = ExecTime();
     //echo $t2-$t1;
     $artlist = '';
     $this->dtp2->LoadSource($innertext);
     $GLOBALS['autoindex'] = 0;
     for ($i = 0; $i < $row; $i++) {
         if ($col > 1) {
             $artlist .= "<div>\r\n";
         }
         for ($j = 0; $j < $col; $j++) {
             if ($row = $this->dsql->GetArray("al")) {
                 $GLOBALS['autoindex']++;
                 $ids[$row['aid']] = $row['id'] = $row['aid'];
                 //处理一些特殊字段
                 $row['ismake'] = 1;
                 $row['money'] = 0;
                 $row['arcrank'] = 0;
                 $row['filename'] = '';
                 $row['filename'] = $row['arcurl'] = GetFileUrl($row['id'], $row['typeid'], $row['senddate'], $row['title'], $row['ismake'], $row['arcrank'], $row['namerule'], $row['typedir'], $row['money'], $row['filename'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                 $row['typeurl'] = GetTypeUrl($row['typeid'], MfTypedir($row['typedir']), $row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                 if ($row['litpic'] == '-' || $row['litpic'] == '') {
                     $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
                 }
                 if (!preg_match("/^http:\\/\\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
                     $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
                 }
                 $row['picname'] = $row['litpic'];
                 $row['pubdate'] = $row['senddate'];
                 $row['stime'] = GetDateMK($row['pubdate']);
                 $row['typelink'] = "<a href='" . $row['typeurl'] . "'>" . $row['typename'] . "</a>";
                 $row['fulltitle'] = $row['title'];
                 $row['title'] = cn_substr($row['title'], $titlelen);
                 if (preg_match('/b/', $row['flag'])) {
                     $row['title'] = "<b>" . $row['title'] . "</b>";
                 }
                 $row['textlink'] = "<a href='" . $row['filename'] . "'>" . $row['title'] . "</a>";
                 $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                 $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                 $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                 //编译附加表里的数据
                 foreach ($row as $k => $v) {
                     $row[strtolower($k)] = $v;
                 }
                 foreach ($this->ChannelUnit->ChannelFields as $k => $arr) {
                     if (isset($row[$k])) {
                         $row[$k] = $this->ChannelUnit->MakeField($k, $row[$k]);
                     }
                 }
                 if (is_array($this->dtp2->CTags)) {
                     foreach ($this->dtp2->CTags as $k => $ctag) {
                         if ($ctag->GetName() == 'array') {
                             //传递整个数组,在runphp模式中有特殊作用
                             $this->dtp2->Assign($k, $row);
                         } else {
                             if (isset($row[$ctag->GetName()])) {
                                 $this->dtp2->Assign($k, $row[$ctag->GetName()]);
                             } else {
                                 $this->dtp2->Assign($k, '');
                             }
                         }
                     }
                 }
                 $artlist .= $this->dtp2->GetResult();
             }
             //if hasRow
         }
         //Loop Col
         if ($col > 1) {
             $i += $col - 1;
             $artlist .= "    </div>\r\n";
         }
     }
     //Loop Line
     $t3 = ExecTime();
     //echo ($t3-$t2);
     $this->dsql->FreeResult('al');
     return $artlist;
 }
 function GetArcList($atts, $refObj = '', $fields = array())
 {
     $attlist = "titlelen=30,infolen=200,imgwidth=120,imgheight=90";
     FillAtts($atts, $attlist);
     FillFields($atts, $fields, $refObj);
     extract($atts, EXTR_OVERWRITE);
     $rsArray = array();
     //global $_vars;
     //$t1 = Exectime();
     if (!$this->isQuery) {
         $this->dsql->Execute('mbdl', $this->sourceSql);
     }
     $i = 0;
     while ($row = $this->dsql->GetArray('mbdl')) {
         $i++;
         if (!isset($row['description'])) {
             $row['description'] = '';
         }
         if (!isset($row['color'])) {
             $row['color'] = '';
         }
         if (!isset($row['pubdate'])) {
             $row['pubdate'] = $row['senddate'];
         }
         //处理一些特殊字段
         $row['infos'] = cn_substr($row['description'], $infolen);
         $row['id'] = $row['id'];
         $row['filename'] = $row['arcurl'] = GetFileUrl($row['id'], $row['typeid'], $row['senddate'], $row['title'], $row['ismake'], $row['arcrank'], $row['namerule'], $row['typedir'], $row['money'], $row['filename'], $row['moresite'], $row['siteurl'], $row['sitepath']);
         $row['typeurl'] = GetTypeUrl($row['typeid'], $row['typedir'], $row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'], $row['moresite'], $row['siteurl'], $row['sitepath']);
         if ($row['litpic'] == '-' || $row['litpic'] == '') {
             $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
         }
         if (!eregi("^http://", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
             $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
         }
         $row['picname'] = $row['litpic'];
         $row['stime'] = GetDateMK($row['pubdate']);
         $row['typelink'] = "<a href='" . $row['typeurl'] . "'>" . $row['typename'] . "</a>";
         $row['image'] = "<img src='" . $row['picname'] . "' border='0' width='{$imgwidth}' height='{$imgheight}' alt='" . ereg_replace("['><]", "", $row['title']) . "'>";
         $row['imglink'] = "<a href='" . $row['filename'] . "'>" . $row['image'] . "</a>";
         $row['fulltitle'] = $row['title'];
         $row['title'] = cn_substr($row['title'], $titlelen);
         if ($row['color'] != '') {
             $row['title'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
         }
         if (ereg('b', $row['flag'])) {
             $row['title'] = "<strong>" . $row['title'] . "</strong>";
         }
         //$row['title'] = "<b>".$row['title']."</b>";
         $row['textlink'] = "<a href='" . $row['filename'] . "'>" . $row['title'] . "</a>";
         $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
         $row['memberurl'] = $GLOBALS['cfg_memberurl'];
         $row['templeturl'] = $GLOBALS['cfg_templeturl'];
         $rsArray[$i] = $row;
         if ($i >= $this->pageSize) {
             break;
         }
     }
     $this->dsql->FreeResult();
     //echo "执行时间:".(Exectime() - $t1);
     return $rsArray;
 }
Exemple #11
0
function lib_arclistDone(&$refObj, &$ctag, $typeid = 0, $row = 10, $col = 1, $titlelen = 30, $infolen = 160, $imgwidth = 120, $imgheight = 90, $listtype = 'all', $orderby = 'default', $keyword = '', $innertext = '', $arcid = 0, $idlist = '', $channelid = 0, $limit = '', $att = '', $order = 'desc', $subday = 0, $noflag = '')
{
    global $dsql, $PubFields, $cfg_keyword_like, $cfg_index_cache, $_arclistEnv, $envs, $cfg_cache_type;
    $row = AttDef($row, 10);
    $titlelen = AttDef($titlelen, 30);
    $infolen = AttDef($infolen, 160);
    $imgwidth = AttDef($imgwidth, 120);
    $imgheight = AttDef($imgheight, 120);
    $listtype = AttDef($listtype, 'all');
    $arcid = AttDef($arcid, 0);
    $channelid = AttDef($channelid, 0);
    $orderby = AttDef($orderby, 'default');
    $orderWay = AttDef($order, 'desc');
    $subday = AttDef($subday, 0);
    $line = $row;
    $orderby = strtolower($orderby);
    $keyword = trim($keyword);
    $innertext = trim($innertext);
    $tablewidth = $ctag->GetAtt('tablewidth');
    $writer = $ctag->GetAtt('writer');
    if ($tablewidth == "") {
        $tablewidth = 100;
    }
    if (empty($col)) {
        $col = 1;
    }
    $colWidth = ceil(100 / $col);
    $tablewidth = $tablewidth . "%";
    $colWidth = $colWidth . "%";
    if ($innertext == '') {
        $innertext = GetSysTemplets('part_arclist.htm');
    }
    if (@$ctag->GetAtt('getall') == 1) {
        $getall = 1;
    } else {
        $getall = 0;
    }
    if ($att == '0') {
        $att = '';
    }
    if ($att == '3') {
        $att = 'f';
    }
    if ($att == '1') {
        $att = 'h';
    }
    $orwheres = array();
    $maintable = '#@__archives';
    //按不同情况设定SQL条件 排序方式
    if ($idlist == '') {
        if ($orderby == 'near' && $cfg_keyword_like == 'N') {
            $keyword = '';
        }
        if ($writer == 'this') {
            $wmid = isset($refObj->Fields['mid']) ? $refObj->Fields['mid'] : 0;
            $orwheres[] = " arc.mid = '{$wmid}' ";
        }
        //时间限制(用于调用最近热门文章、热门评论之类),这里的时间只能计算到天,否则缓存功能将无效
        if ($subday > 0) {
            $ntime = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y'));
            $limitday = $ntime - $subday * 24 * 3600;
            $orwheres[] = " arc.senddate > {$limitday} ";
        }
        //关键字条件
        if ($keyword != '') {
            $keyword = str_replace(',', '|', $keyword);
            $orwheres[] = " CONCAT(arc.title,arc.keywords) REGEXP '{$keyword}' ";
        }
        //文档属性
        if (eregi('commend', $listtype)) {
            $orwheres[] = " FIND_IN_SET('c', arc.flag)>0  ";
        }
        if (eregi('image', $listtype)) {
            $orwheres[] = " FIND_IN_SET('p', arc.flag)>0  ";
        }
        if ($att != '') {
            $flags = explode(',', $att);
            for ($i = 0; isset($flags[$i]); $i++) {
                $orwheres[] = " FIND_IN_SET('{$flags[$i]}', arc.flag)>0 ";
            }
        }
        if (!empty($typeid) && $typeid != 'top') {
            //指定了多个栏目时,不再获取子类的id
            if (ereg(',', $typeid)) {
                //指定了getall属性或主页模板例外
                if ($getall == 1 || empty($refObj->Fields['typeid'])) {
                    $typeids = explode(',', $typeid);
                    foreach ($typeids as $ttid) {
                        $typeidss[] = GetSonIds($ttid);
                    }
                    $typeidStr = join(',', $typeidss);
                    $typeidss = explode(',', $typeidStr);
                    $typeidssok = array_unique($typeidss);
                    $typeid = join(',', $typeidssok);
                }
                $orwheres[] = " arc.typeid in ({$typeid}) ";
            } else {
                //处理交叉栏目
                $CrossID = '';
                if ($ctag->GetAtt('cross') == '1') {
                    $arr = $dsql->GetOne("Select `id`,`topid`,`cross`,`crossid`,`ispart`,`typename` From `#@__arctype` where id='{$typeid}' ");
                    if ($arr['cross'] == 0 || $arr['cross'] == 2 && trim($arr['crossid'] == '')) {
                        $orwheres[] = ' arc.typeid in (' . GetSonIds($typeid) . ')';
                    } else {
                        $selquery = '';
                        if ($arr['cross'] == 1) {
                            $selquery = "Select id,topid From `#@__arctype` where typename like '{$arr['typename']}' And id<>'{$typeid}' And topid<>'{$typeid}'  ";
                        } else {
                            $arr['crossid'] = ereg_replace('[^0-9,]', '', trim($arr['crossid']));
                            if ($arr['crossid'] != '') {
                                $selquery = "Select id,topid From `#@__arctype` where id in('{$arr['crossid']}') And id<>'{$typeid}' And topid<>'{$typeid}'  ";
                            }
                        }
                        if ($selquery != '') {
                            $dsql->SetQuery($selquery);
                            $dsql->Execute();
                            while ($arr = $dsql->GetArray()) {
                                $CrossID .= $CrossID == '' ? $arr['id'] : ',' . $arr['id'];
                            }
                        }
                    }
                }
                if ($CrossID == '') {
                    $orwheres[] = ' arc.typeid in (' . GetSonIds($typeid) . ')';
                } else {
                    $orwheres[] = ' arc.typeid in (' . GetSonIds($typeid) . ',' . $CrossID . ')';
                }
            }
        }
        //频道ID
        if (eregi('spec', $listtype)) {
            $channelid == -1;
        }
        if (!empty($channelid)) {
            $orwheres[] = " And arc.channel = '{$channelid}' ";
        }
        if (!empty($noflag)) {
            if (!ereg(',', $noflag)) {
                $orwheres[] = " FIND_IN_SET('{$noflag}', arc.flag)<1 ";
            } else {
                $noflags = explode(',', $noflag);
                foreach ($noflags as $noflag) {
                    if (trim($noflag) == '') {
                        continue;
                    }
                    $orwheres[] = " FIND_IN_SET('{$noflag}', arc.flag)<1 ";
                }
            }
        }
        $orwheres[] = ' arc.arcrank > -1 ';
        //由于这个条件会导致缓存功能失去意义,因此取消
        //if($arcid!=0) $orwheres[] = " arc.id<>'$arcid' ";
    }
    //文档排序的方式
    $ordersql = '';
    if ($orderby == 'hot' || $orderby == 'click') {
        $ordersql = " order by arc.click {$orderWay}";
    } else {
        if ($orderby == 'sortrank' || $orderby == 'pubdate') {
            $ordersql = " order by arc.sortrank {$orderWay}";
        } else {
            if ($orderby == 'id') {
                $ordersql = "  order by arc.id {$orderWay}";
            } else {
                if ($orderby == 'near') {
                    $ordersql = " order by ABS(arc.id - " . $arcid . ")";
                } else {
                    if ($orderby == 'lastpost') {
                        $ordersql = "  order by arc.lastpost {$orderWay}";
                    } else {
                        if ($orderby == 'scores') {
                            $ordersql = "  order by arc.scores {$orderWay}";
                        } else {
                            if ($orderby == 'rand') {
                                $ordersql = "  order by rand()";
                            } else {
                                $ordersql = " order by arc.sortrank {$orderWay}";
                            }
                        }
                    }
                }
            }
        }
    }
    //limit条件
    $limit = trim(eregi_replace('limit', '', $limit));
    if ($limit != '') {
        $limitsql = " limit {$limit} ";
    } else {
        $limitsql = " limit 0,{$line} ";
    }
    $orwhere = '';
    if (isset($orwheres[0])) {
        $orwhere = join(' And ', $orwheres);
        $orwhere = ereg_replace("^ And", '', $orwhere);
        $orwhere = ereg_replace("And[ ]{1,}And", 'And ', $orwhere);
    }
    if ($orwhere != '') {
        $orwhere = " where {$orwhere} ";
    }
    //获取附加表信息
    $addfield = trim($ctag->GetAtt('addfields'));
    $addfieldsSql = '';
    $addfieldsSqlJoin = '';
    if ($addfield != '' && !empty($channelid)) {
        $row = $dsql->GetOne("Select addtable From `#@__channeltype` where id='{$channelid}' ");
        if (isset($row['addtable']) && trim($row['addtable']) != '') {
            $addtable = trim($row['addtable']);
            $addfields = explode(',', $addfield);
            $row['addtable'] = trim($row['addtable']);
            $addfieldsSql = ",addf." . join(',addf.', $addfields);
            $addfieldsSqlJoin = " left join `{$addtable}` addf on addf.aid = arc.id ";
        }
    }
    $query = "Select arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,\r\n\t\ttp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\r\n\t\t{$addfieldsSql}\r\n\t\tfrom `{$maintable}` arc left join `#@__arctype` tp on arc.typeid=tp.id\r\n\t\t{$addfieldsSqlJoin}\r\n\t\t{$orwhere} {$ordersql} {$limitsql}";
    $md5hash = md5($query);
    $stylehash = $cfg_cache_type == 'content' ? md5($innertext) : '';
    $needSaveCache = true;
    if ($idlist != '' || $GLOBALS['_arclistEnv'] == 'index' || $cfg_index_cache == 0) {
        $needSaveCache = false;
    } else {
        $idlist = GetArclistCache($md5hash, $stylehash);
        if ($idlist != '') {
            $needSaveCache = false;
        }
        //如果使用的是内容缓存,直接返回结果
        if ($cfg_cache_type == 'content' && $idlist != '') {
            $idlist = $idlist == 0 ? '' : $idlist;
            return $idlist;
        }
    }
    //指定了id或使用缓存中的id
    if ($idlist != '') {
        $query = "Select arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,\r\n\t\t\ttp.moresite,tp.siteurl,tp.sitepath\r\n\t\t\t{$addfieldsSql}\r\n\t\t\t from `{$maintable}` arc left join `#@__arctype` tp on arc.typeid=tp.id\r\n\t\t\t {$addfieldsSqlJoin}\r\n\t\t  where arc.id in({$idlist}) {$ordersql} ";
    }
    $dsql->SetQuery($query);
    $dsql->Execute('al');
    $artlist = '';
    if ($col > 1) {
        $artlist = "<table width='{$tablewidth}' border='0' cellspacing='0' cellpadding='0'>\r\n";
    }
    $dtp2 = new DedeTagParse();
    $dtp2->SetNameSpace('field', '[', ']');
    $dtp2->LoadString($innertext);
    $GLOBALS['autoindex'] = 0;
    $ids = array();
    for ($i = 0; $i < $line; $i++) {
        if ($col > 1) {
            $artlist .= "<tr>\r\n";
        }
        for ($j = 0; $j < $col; $j++) {
            if ($col > 1) {
                $artlist .= "\t<td width='{$colWidth}'>\r\n";
            }
            if ($row = $dsql->GetArray("al")) {
                $ids[] = $row['id'];
                //处理一些特殊字段
                $row['info'] = $row['infos'] = cn_substr($row['description'], $infolen);
                $row['id'] = $row['id'];
                if ($row['corank'] > 0 && $row['arcrank'] == 0) {
                    $row['arcrank'] = $row['corank'];
                }
                $row['filename'] = $row['arcurl'] = GetFileUrl($row['id'], $row['typeid'], $row['senddate'], $row['title'], $row['ismake'], $row['arcrank'], $row['namerule'], $row['typedir'], $row['money'], $row['filename'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                $row['typeurl'] = GetTypeUrl($row['typeid'], $row['typedir'], $row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                if ($row['litpic'] == '-' || $row['litpic'] == '') {
                    $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
                }
                if (!eregi("^http://", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
                    $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
                }
                $row['picname'] = $row['litpic'];
                $row['stime'] = GetDateMK($row['pubdate']);
                $row['typelink'] = "<a href='" . $row['typeurl'] . "'>" . $row['typename'] . "</a>";
                $row['image'] = "<img src='" . $row['picname'] . "' border='0' width='{$imgwidth}' height='{$imgheight}' alt='" . ereg_replace("['><]", "", $row['title']) . "'>";
                $row['imglink'] = "<a href='" . $row['filename'] . "'>" . $row['image'] . "</a>";
                $row['fulltitle'] = $row['title'];
                $row['title'] = cn_substr($row['title'], $titlelen);
                if ($row['color'] != '') {
                    $row['title'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
                }
                if (ereg('b', $row['flag'])) {
                    $row['title'] = "<strong>" . $row['title'] . "</strong>";
                }
                //$row['title'] = "<b>".$row['title']."</b>";
                $row['textlink'] = "<a href='" . $row['filename'] . "'>" . $row['title'] . "</a>";
                $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                if (is_array($dtp2->CTags)) {
                    foreach ($dtp2->CTags as $k => $ctag) {
                        if ($ctag->GetName() == 'array') {
                            //传递整个数组,在runphp模式中有特殊作用
                            $dtp2->Assign($k, $row);
                        } else {
                            if (isset($row[$ctag->GetName()])) {
                                $dtp2->Assign($k, $row[$ctag->GetName()]);
                            } else {
                                $dtp2->Assign($k, '');
                            }
                        }
                    }
                    $GLOBALS['autoindex']++;
                }
                $artlist .= $dtp2->GetResult() . "\r\n";
            } else {
                $artlist .= '';
            }
            if ($col > 1) {
                $artlist .= "\t</td>\r\n";
            }
        }
        //Loop Col
        if ($col > 1) {
            $i += $col - 1;
        }
        if ($col > 1) {
            $artlist .= "\t</tr>\r\n";
        }
    }
    //loop line
    if ($col > 1) {
        $artlist .= "\t</table>\r\n";
    }
    $dsql->FreeResult("al");
    //保存ID缓存
    $idsstr = join(',', $ids);
    if ($needSaveCache) {
        if ($idsstr == '') {
            $idsstr = '0';
        }
        if ($cfg_cache_type == 'content' && $idsstr != '0') {
            $idsstr = $artlist;
        }
        $inquery = "INSERT INTO `#@__arccache`(`md5hash`,`stylehash`,`uptime`,`cachedata`) VALUES ('" . $md5hash . "','{$stylehash}', '" . time() . "', '{$idsstr}'); ";
        $dsql->ExecuteNoneQuery("Delete From `#@__arccache` where md5hash='" . $md5hash . "' ");
        $dsql->ExecuteNoneQuery($inquery);
    }
    return $artlist;
}
function SpGetArcList($dsql,$typeid=0,$row=10,$col=1,$titlelen=30,$infolen=160,
  $imgwidth=120,$imgheight=90,$listtype="all",$orderby="default",$keyword="",$innertext="",
  $tablewidth="100",$arcid=0,$idlist="",$channelid=0,$limit="",$att=0,$order="desc",$subday=0)
  {
		global $PubFields;
		$row = AttDef($row,10);
		$titlelen = AttDef($titlelen,30);
		$infolen = AttDef($infolen,160);
		$imgwidth = AttDef($imgwidth,120);
		$imgheight = AttDef($imgheight,120);
		$listtype = AttDef($listtype,"all");
    $arcid = AttDef($arcid,0);
    $channelid = AttDef($channelid,0);
    $orderby = AttDef($orderby,"default");
    $orderWay = AttDef($order,"desc");
    $subday = AttDef($subday,0);
    $line = $row;
		$orderby=strtolower($orderby);
		$tablewidth = str_replace("%","",$tablewidth);
		if($tablewidth=="") $tablewidth=100;
		if($col=="") $col = 1;
		$colWidth = ceil(100/$col); 
		$tablewidth = $tablewidth."%";
		$colWidth = $colWidth."%";
		$keyword = trim($keyword);
		$innertext = trim($innertext);
		if($innertext=="") $innertext = GetSysTemplets("part_arclist.htm");
		//按不同情况设定SQL条件 排序方式
		$orwhere = " arc.arcrank > -1 ";
		//时间限制(用于调用最近热门文章、热门评论之类)
		if($subday>0){
			 $limitday = time() - ($oneday * 24 * 3600);
			 $orwhere .= " And arc.senddate > $limitday ";
		}
		//文档的自定义属性
		if($att!="") $orwhere .= "And arcatt='$att' ";
		//文档的频道模型
		if($channelid>0 && !eregi("spec",$listtype)) $orwhere .= " And arc.channel = '$channelid' ";
		//是否为推荐文档
		if(eregi("commend",$listtype)) $orwhere .= " And arc.iscommend > 10  ";
		//是否为带缩略图图片文档
		if(eregi("image",$listtype)) $orwhere .= " And arc.litpic <> ''  ";
		//是否为专题文档
		if(eregi("spec",$listtype) || $channelid==-1) $orwhere .= " And arc.channel = -1  ";
    //是否指定相近ID
		if($arcid!=0) $orwhere .= " And arc.ID<>'$arcid' ";
		
		//文档排序的方式
		$ordersql = "";
		if($orderby=="hot"||$orderby=="click") $ordersql = " order by arc.click $orderWay";
		else if($orderby=="pubdate") $ordersq = " order by arc.pubdate $orderWay";
		else if($orderby=="sortrank") $ordersq = " order by arc.sortrank $orderWay";
    else if($orderby=="id") $ordersql = "  order by arc.ID $orderWay";
    else if($orderby=="near") $ordersql = " order by ABS(arc.ID - ".$arcid.")";
    else if($orderby=="lastpost") $ordersql = "  order by arc.lastpost $orderWay";
    else if($orderby=="postnum") $ordersql = "  order by arc.postnum $orderWay";
		else $ordersql=" order by arc.senddate $orderWay";
		
		//类别ID的条件,如果用 "," 分开,可以指定特定类目
		//------------------------------
		if($typeid!=0)
		{
		  $reids = explode(",",$typeid);
		  $ridnum = count($reids);
		  if($ridnum>1){
			  $tpsql = "";
		    for($i=0;$i<$ridnum;$i++){
				  if($tpsql=="") $tpsql .= " And (".TypeGetSunID($reids[$i],$dsql,'arc');
				  else $tpsql .= " Or ".TypeGetSunID($reids[$i],$dsql,'arc');
		    }
		    $tpsql .= ") ";
		    $orwhere .= $tpsql;
		    unset($tpsql);
		  }
		  else{
			  $orwhere .= " And ".TypeGetSunID($typeid,$dsql,'arc');
		  }
		  unset($reids);
	  }
		//指定的文档ID列表
		//----------------------------------
		if($idlist!="")
		{
			$reids = explode(",",$idlist);
		  $ridnum = count($reids);
		  $idlistSql = "";
		  for($i=0;$i<$ridnum;$i++){
				if($idlistSql=="") $idlistSql .= " And ( arc.ID='".$reids[$i]."' ";
				else $idlistSql .= " Or arc.ID='".$reids[$i]."' ";
		  }
		  $idlistSql .= ") ";
		  $orwhere .= $idlistSql;
		  unset($idlistSql);
		  unset($reids);
		  $row = $ridnum;
		}
		//关键字条件
		if($keyword!="")
		{
		  $keywords = explode(",",$keyword);
		  $ridnum = count($keywords);
		  $orwhere .= " And (arc.keywords like '%".trim($keywords[0])." %' ";
		  for($i=1;$i<$ridnum;$i++){
			  if($keywords[$i]!="") $orwhere .= " Or arc.keywords like '%".trim($keywords[$i])." %' ";
		  }
		  $orwhere .= ")";
		  unset($keywords);
	  }
	  $limit = trim(eregi_replace("limit","",$limit));
	  if($limit!="") $limitsql = " limit $limit ";
	  else $limitsql = " limit 0,$line ";
		//////////////
		$query = "Select arc.ID,arc.title,arc.iscommend,arc.color,arc.typeid,arc.ismake,
		arc.description,arc.pubdate,arc.senddate,arc.arcrank,arc.click,arc.money,
		arc.litpic,tp.typedir,tp.typename,tp.isdefault,
		tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl
		from #@__archives arc left join #@__arctype tp on arc.typeid=tp.ID
		where $orwhere $ordersql $limitsql";
		 
		$dsql->SetQuery($query);
		$dsql->Execute("al");
    $artlist = "";
    if($col>1) $artlist = "<table width='$tablewidth' border='0' cellspacing='0' cellpadding='0'>\r\n";
    $dtp2 = new DedeTagParse();
    $dtp2->SetNameSpace("field","[","]");
    $dtp2->LoadString($innertext);
    $GLOBALS['autoindex'] = 0;
    for($i=0;$i<$line;$i++)
		{
       if($col>1) $artlist .= "<tr>\r\n";
       for($j=0;$j<$col;$j++)
			 {
         if($col>1) $artlist .= "	<td width='$colWidth'>\r\n";
         if($row = $dsql->GetArray("al"))
         {
           //处理一些特殊字段
           $row['description'] = cn_substr($row['description'],$infolen);
           $row['id'] =  $row['ID'];
           file_put_contents("c:/ttt.txt",$row['id']); 
           if($row['litpic']=="") $row['litpic'] = $PubFields['templeturl']."/img/default.gif";
           $row['picname'] = $row['litpic'];
           $row['arcurl'] = GetFileUrl($row['id'],$row['typeid'],$row['senddate'],
                            $row['title'],$row['ismake'],$row['arcrank'],$row['namerule'],
                            $row['typedir'],$row['money'],true,$row['siteurl']);
           $row['typeurl'] = GetTypeUrl($row['typeid'],MfTypedir($row['typedir']),$row['isdefault'],$row['defaultname'],$row['ispart'],$row['namerule2'],$row['siteurl']);

           $row['info'] = $row['description'];
           $row['filename'] = $row['arcurl'];
           $row['stime'] = GetDateMK($row['pubdate']);
           $row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
           $row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".ereg_replace("['><]","",$row['title'])."'>";
           $row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";
           $row['title'] = cn_substr($row['title'],$titlelen);
           $row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
           
           if($row['color']!="") $row['title'] = "<font color='".$row['color']."'>".$row['title']."</font>";
           if($row['iscommend']==5||$row['iscommend']==16) $row['title'] = "<b>".$row['title']."</b>";
           
           $row['phpurl'] = $PubFields['phpurl'];
 		       $row['templeturl'] = $PubFields['templeturl'];
           if(is_array($dtp2->CTags)){
       	      foreach($dtp2->CTags as $k=>$ctag){
       		 	    if(isset($row[$ctag->GetName()])) $dtp2->Assign($k,$row[$ctag->GetName()]);
       		 	    else $dtp2->Assign($k,"");
       	      }
       	      $GLOBALS['autoindex']++;
           }
           $artlist .= $dtp2->GetResult()."\r\n";
         }//if hasRow
         else{
         	 $artlist .= "";
         }
         if($col>1) $artlist .= "	</td>\r\n";
       }//Loop Col
       if($col>1) $i += $col - 1;
       if($col>1) $artlist .= "	</tr>\r\n";
     }//Loop Line
     if($col>1) $artlist .= "	</table>\r\n";
     $dsql->FreeResult("al");
     return $artlist;
}
	function GetArcList($limitstart=0,$row=10,$col=1,$titlelen=30,$infolen=250,
	$imgwidth=120,$imgheight=90,$listtype="all",$orderby="default",$innertext="",$tablewidth="100",$ismake=1,$orderWay='desc')
	{
		global $cfg_list_son;
		$t1 = ExecTime();
		$typeid=$this->TypeID;
		if($row=="") $row = 10;
		if($limitstart=="") $limitstart = 0;
		if($titlelen=="") $titlelen = 100;
		if($infolen=="") $infolen = 250;
		if($imgwidth=="") $imgwidth = 120;
		if($imgheight=="") $imgheight = 120;
		if($listtype=="") $listtype = "all";
		if($orderby=="") $orderby="default";
		else $orderby=strtolower($orderby);
		if($orderWay=='') $orderWay = 'desc';
		$tablewidth = str_replace("%","",$tablewidth);
		if($tablewidth=="") $tablewidth=100;
		if($col=="") $col=1;
		$colWidth = ceil(100/$col);
		$tablewidth = $tablewidth."%";
		$colWidth = $colWidth."%";
		$innertext = trim($innertext);
		if($innertext=="") $innertext = GetSysTemplets("list_digglist.htm");
		//按不同情况设定SQL条件
		$orwhere = " arc.arcrank > -1 ";
    
		//排序方式
		$ordersql = "";
		if($orderby=="digg") $ordersql=" order by arc.digg $orderWay";
		else $ordersql=" order by arc.diggtime $orderWay";

    $this->dtp2->LoadSource($innertext);
		if(!is_array($this->dtp2->CTags)) return '';

		$query = "Select arc.*,
			tp.typedir,tp.typename,tp.isdefault,tp.defaultname,
			tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl
			from `#@__full_search` arc
			left join #@__arctype tp on arc.typeid=tp.ID
			where $orwhere $ordersql limit $limitstart,$row
		";
		$this->dsql->SetQuery($query);
		$this->dsql->Execute("alf");
		//$t2 = ExecTime();
		//echo $query."|";
		//echo ($t2-$t1)."<br>";
		$artlist = "";
		$GLOBALS['autoindex'] = 0;
		while($row = $this->dsql->GetArray("alf"))
    {
       //处理一些特殊字段
       $row['description'] = cn_substr($row['addinfos'],$infolen);
       $row['id'] =  $row['aid'];
       $row['filename'] = $row['arcurl'] = $row['url'];
       $row['typeurl'] = GetTypeUrl($row['typeid'],MfTypedir($row['typedir']),$row['isdefault'],$row['defaultname'],$row['ispart'],$row['namerule2'],$row['siteurl']);
       if($row['litpic']=="") $row['litpic'] = $GLOBALS['PubFields']['templeturl']."/img/default.gif";
       $row['picname'] = $row['litpic'];
       if($GLOBALS['cfg_multi_site']=='Y')
       {
           if($row['siteurl']=="") $row['siteurl'] = $GLOBALS['cfg_mainsite'];
           if(!eregi("^http://",$row['picname'])){
           	 	$row['litpic'] = $row['siteurl'].$row['litpic'];
           	 	$row['picname'] = $row['litpic'];
           }
       }
       $row['stime'] = GetDateMK($row['uptime']);
       $row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
       $row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".ereg_replace("['><]","",$row['title'])."' />";
       $row['imglink'] = "<a href='".$row['arcurl']."'>".$row['image']."</a>";
       $row['fulltitle'] = $row['title'];
       $row['title'] = cn_substr($row['title'],$titlelen);
       $row['textlink'] = "<a href='".$row['arcurl']."'>".$row['title']."</a>";
       foreach($this->dtp2->CTags as $k=>$ctag)
       {
       		if(isset($row[$ctag->GetName()])) $this->dtp2->Assign($k,$row[$ctag->GetName()]);
       		else $this->dtp2->Assign($k,'');
       }
       $GLOBALS['autoindex']++;
       $artlist .= $this->dtp2->GetResult();
     }//Loop Line
		 $this->dsql->FreeResult("alf");
		//$t3 = ExecTime();
		//echo ($t3-$t2)."<br>";
		return $artlist;
	}
	function GetArcList($limitstart=0,$row=10,$col=1,$titlelen=30,$infolen=250,
	$imgwidth=120,$imgheight=90,$listtype="all",$orderby="default",$innertext="",$tablewidth="100",$ismake=1,$orderWay='desc')
	{
		global $cfg_list_son;
		$t1 = ExecTime();
		$typeid=$this->TypeID;
		
		if($row=="") $row = 10;
			if($limitstart=="") $limitstart = 0;
			if($titlelen=="") $titlelen = 100;
			if($infolen=="") $infolen = 250;
			if($imgwidth=="") $imgwidth = 120;
			if($imgheight=="") $imgheight = 120;
			if($listtype=="") $listtype = "all";
			if($orderby=="") $orderby="default";
			else $orderby=strtolower($orderby);
			if($orderWay=='') $orderWay = 'desc';
			$tablewidth = str_replace("%","",$tablewidth);
			if($tablewidth=="") $tablewidth=100;
			if($col=="") $col=1;
			$colWidth = ceil(100/$col);
			$tablewidth = $tablewidth."%";
			$colWidth = $colWidth."%";
			$innertext = trim($innertext);
			if($innertext=="") $innertext = GetSysTemplets("list_fulllist.htm");
			//按不同情况设定SQL条件

			$orwhere = $this->addSql;

			//排序方式
			if($orderby=="senddate") $ordersql=" order by arc.senddate $orderWay";
			elseif($orderby=="pubdate") $ordersql=" order by arc.pubdate $orderWay";
			elseif($orderby=="id") $ordersql="  order by arc.ID $orderWay";
			elseif($orderby=="hot"||$orderby=="click") $ordersql = " order by arc.click $orderWay";
			elseif($orderby=="lastpost") $ordersql = "  order by arc.lastpost $orderWay";
			elseif($orderby=="postnum") $ordersql = "  order by arc.postnum $orderWay";
			elseif($orderby=="digg") $ordersql = "  order by arc.digg $orderWay";
		  elseif($orderby=="diggtime") $ordersql = "  order by arc.diggtime $orderWay";
			else $ordersql=" order by arc.sortrank $orderWay";

			//获得附加表的相关信息
			//-----------------------------
			$addtable  = $this->ChannelUnit->ChannelInfos['addtable'];
			$addfields = trim($this->ChannelUnit->ChannelInfos['listadd']);
			if($addtable!="" && $addfields!="")
			{
				$addJoin = " left join `$addtable` addt on addt.aid = arc.ID ";
				$addField = "";
				$fields = explode(",",$addfields);
				foreach($fields as $k=>$v){
					$addField .= ",addt.{$v}";
				}
			}else
			{
				$addField = "";
				$addJoin = "";
			}

			$query = "Select arc.*,
			tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl
			$addField
			from `{$this->maintable}` arc
			left join #@__arctype tp on arc.typeid=tp.ID
			$addJoin
			where $orwhere $ordersql limit $limitstart,$row";

			$this->dtp2->LoadSource($innertext);
			if(!is_array($this->dtp2->CTags)) return '';
			
			$this->dsql->Execute("al",$query);
			
			$t2 = ExecTime();
			
			$artlist = "";
			if($col>1) $artlist = "<table width='$tablewidth' border='0' cellspacing='0' cellpadding='0'>\r\n";
			
			$GLOBALS['autoindex'] = 0;
			for($i=0;$i<$row;$i++)
			{
				if($col>1) $artlist .= "<tr>\r\n";
				for($j=0;$j<$col;$j++)
				{
					if($col>1) $artlist .= "<td width='$colWidth'>\r\n";
					if($row = $this->dsql->GetArray("al",MYSQL_ASSOC))
					{
						$GLOBALS['autoindex']++;
						//处理一些特殊字段
						//if()
						$row['id'] =  $row['ID'];
						$row['arcurl'] = $this->GetArcUrl($row['id'],$row['typeid'],$row['senddate'],$row['title'],$row['ismake'],$row['arcrank'],$row['namerule'],$row['typedir'],$row['money']);
						$row['typeurl'] = $this->GetListUrl($row['typeid'],$row['typedir'],$row['isdefault'],$row['defaultname'],$row['ispart'],$row['namerule2'],"abc");

						if($ismake==0 && $GLOBALS['cfg_multi_site']=='Y')
						{
							if($row["siteurl"]=="") $row["siteurl"] = $GLOBALS['cfg_mainsite'];
							if(!eregi("^http://",$row['picname'])){
								$row['litpic'] = $row['siteurl'].$row['litpic'];
								$row['picname'] = $row['litpic'];
							}
						}

						$row['description'] = cn_substr($row['description'],$infolen);
						if($row['litpic']=="") $row['litpic'] = $GLOBALS['cfg_plus_dir']."/img/dfpic.gif";
						$row['picname'] = $row['litpic'];
						$row['info'] = $row['description'];
						$row['filename'] = $row['arcurl'];
						$row['stime'] = GetDateMK($row['pubdate']);
						
						if($this->hasDmCache){
						  $row['areaidname'] = $row['areaid2name'] = $row['sectoridname'] = $row['sectorid2name'] =$row['smalltypeidname'] = '';
						  $row['areaidname'] = $this->areas[$row['areaid']];
						  $row['areaid2name'] = $this->areas[$row['areaid2']];
						  $row['sectoridname'] = $this->sectors[$row['sectorid']];
						  $row['sectorid2name'] = $this->sectors[$row['sectorid2']];
						  $row['smalltypeidname'] = $this->smalltypes[$row['smalltypeid']];
						}

						$row['textlink'] = "<a href='".$row['filename']."' title='".str_replace("'","",$row['title'])."'>".$row['title']."</a>";

						if($row['typeid'] != $this->Fields['ID']){
							$row['typelink'] = "<a href='".$row['typeurl']."'>[".$row['typename']."]</a>";
						}else{
							$row['typelink']= '';
						}
						$row['imglink'] = "<a href='".$row['filename']."'><img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".str_replace("'","",$row['title'])."'></a>";
						$row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".str_replace("'","",$row['title'])."'>";
						$row['phpurl'] = $GLOBALS['cfg_plus_dir'];
						$row['plusurl'] = $GLOBALS['cfg_plus_dir'];
						$row['templeturl'] = $GLOBALS['cfg_templets_dir'];
						$row['memberurl'] = $GLOBALS['cfg_member_dir'];
						$row['title'] = cn_substr($row['title'],$titlelen);
						if($row['color']!="") $row['title'] = "<font color='".$row['color']."'>".$row['title']."</font>";
						if($row['iscommend']==5||$row['iscommend']==16) $row['title'] = "<b>".$row['title']."</b>";
						//编译附加表里的数据
						foreach($row as $k=>$v){ $row[strtolower($k)] = $v; }
						foreach($this->ChannelUnit->ChannelFields as $k=>$arr){
							if(isset($row[$k])) $row[$k] = $this->ChannelUnit->MakeField($k,$row[$k]);
						}
						foreach($this->dtp2->CTags as $k=>$ctag){
								@$this->dtp2->Assign($k,$row[$ctag->GetName()]);
						}
						$artlist .= $this->dtp2->GetResult();
					}//if hasRow
					if($col>1) $artlist .= "	</td>\r\n";
				}//Loop Col
				if($col>1) $i += $col - 1;
				if($col>1) $artlist .= "	</tr>\r\n";
		}//Loop Line
		if($col>1) $artlist .= "</table>\r\n";
		$this->dsql->FreeResult("al");
		//$t3 = ExecTime();
		//echo ($t3-$t2)."<br>";
		return $artlist;
	}
Exemple #15
0
/**
 *  arclist解析函数
 *
 * @access    public
 * @param     object  $refObj  引用对象
 * @param     object  $ctag  标签
 * @param     int  $typeid  栏目ID
 * @param     int  $row  调用行数
 * @param     int  $titlelen  字符串长度
 * @param     int  $infolen  描述信息长度
 * @param     int  $imgwidth  图片宽度
 * @param     int  $imgheight  图片高度
 * @param     string  $listtype  列表类型
 * @param     string  $orderby  排列顺序
 * @param     string  $keyword  关键词
 * @param     string  $innertext  底层模板
 * @param     int  $arcid  文档ID
 * @param     string  $idlist  ID列表
 * @param     int  $channelid  频道ID
 * @param     string  $limit  限制
 * @param     string  $att  属性
 * @param     string  $order  排序类型
 * @param     int  $subday  天内
 * @param     string  $noflag  属性标记
 * @param     string  $tagid  标签id
 * @param     string  $pagesize  显示条数
 * @param     string  $isweight  是否需要对检索出来的内容按照weight排序
 * @return    string
 */
function lib_arclistDone(&$refObj, &$ctag, $typeid = 0, $row = 10, $col = 1, $titlelen = 30, $infolen = 160, $imgwidth = 120, $imgheight = 90, $listtype = 'all', $orderby = 'default', $keyword = '', $innertext = '', $arcid = 0, $idlist = '', $channelid = 0, $limit = '', $att = '', $order = 'desc', $subday = 0, $noflag = '', $tagid = '', $pagesize = 0, $isweight = 'N')
{
    global $dsql, $PubFields, $cfg_keyword_like, $cfg_index_cache, $_arclistEnv, $envs, $cfg_cache_type, $cfg_digg_update;
    $row = AttDef($row, 10);
    $titlelen = AttDef($titlelen, 30);
    $infolen = AttDef($infolen, 160);
    $imgwidth = AttDef($imgwidth, 120);
    $imgheight = AttDef($imgheight, 120);
    $listtype = AttDef($listtype, 'all');
    $arcid = AttDef($arcid, 0);
    $channelid = AttDef($channelid, 0);
    $orderby = AttDef($orderby, 'default');
    $orderWay = AttDef($order, 'desc');
    $subday = AttDef($subday, 0);
    $pagesize = AttDef($pagesize, 0);
    $line = $row;
    $orderby = strtolower($orderby);
    $keyword = trim($keyword);
    $innertext = trim($innertext);
    $tablewidth = $ctag->GetAtt('tablewidth');
    $writer = $ctag->GetAtt('writer');
    if ($tablewidth == "") {
        $tablewidth = 100;
    }
    if (empty($col)) {
        $col = 1;
    }
    $colWidth = ceil(100 / $col);
    $tablewidth = $tablewidth . "%";
    $colWidth = $colWidth . "%";
    //记录属性,以便分页样式统一调用
    $attarray = compact("row", "titlelen", 'infolen', 'imgwidth', 'imgheight', 'listtype', 'arcid', 'channelid', 'orderby', 'orderWay', 'subday', 'pagesize', 'orderby', 'keyword', 'tablewidth', 'col', 'colWidth');
    if ($innertext == '') {
        $innertext = GetSysTemplets('part_arclist.htm');
    }
    if (@$ctag->GetAtt('getall') == 1) {
        $getall = 1;
    } else {
        $getall = 0;
    }
    if ($att == '0') {
        $att = '';
    }
    if ($att == '3') {
        $att = 'f';
    }
    if ($att == '1') {
        $att = 'h';
    }
    $orwheres = array();
    $maintable = '#@__archives';
    //按不同情况设定SQL条件 排序方式
    if ($idlist == '') {
        if ($orderby == 'near' && $cfg_keyword_like == 'N') {
            $keyword = '';
        }
        if ($writer == 'this') {
            $wmid = isset($refObj->Fields['mid']) ? $refObj->Fields['mid'] : 0;
            $orwheres[] = " arc.mid = '{$wmid}' ";
        }
        //时间限制(用于调用最近热门文章、热门评论之类),这里的时间只能计算到天,否则缓存功能将无效
        if ($subday > 0) {
            $ntime = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y'));
            $limitday = $ntime - $subday * 24 * 3600;
            $orwheres[] = " arc.senddate > {$limitday} ";
        }
        //关键字条件
        if ($keyword != '') {
            $keyword = str_replace(',', '|', $keyword);
            $orwheres[] = " CONCAT(arc.title,arc.keywords) REGEXP '{$keyword}' ";
        }
        //文档属性
        if (preg_match('/commend/i', $listtype)) {
            $orwheres[] = " FIND_IN_SET('c', arc.flag)>0  ";
        }
        if (preg_match('/image/i', $listtype)) {
            $orwheres[] = " FIND_IN_SET('p', arc.flag)>0  ";
        }
        if ($att != '') {
            $flags = explode(',', $att);
            for ($i = 0; isset($flags[$i]); $i++) {
                $orwheres[] = " FIND_IN_SET('{$flags[$i]}', arc.flag)>0 ";
            }
        }
        if (!empty($typeid) && $typeid != 'top') {
            //指定了多个栏目时,不再获取子类的id
            if (preg_match('#,#', $typeid)) {
                //指定了getall属性或主页模板例外
                if ($getall == 1 || empty($refObj->Fields['typeid'])) {
                    $typeids = explode(',', $typeid);
                    foreach ($typeids as $ttid) {
                        $typeidss[] = GetSonIds($ttid);
                    }
                    $typeidStr = join(',', $typeidss);
                    $typeidss = explode(',', $typeidStr);
                    $typeidssok = array_unique($typeidss);
                    $typeid = join(',', $typeidssok);
                }
                $orwheres[] = " arc.typeid IN ({$typeid}) ";
            } else {
                //处理交叉栏目
                $CrossID = '';
                if ($ctag->GetAtt('cross') == '1') {
                    $arr = $dsql->GetOne("SELECT `id`,`topid`,`cross`,`crossid`,`ispart`,`typename` FROM `#@__arctype` WHERE id='{$typeid}' ");
                    if ($arr['cross'] == 0 || $arr['cross'] == 2 && trim($arr['crossid'] == '')) {
                        $orwheres[] = ' arc.typeid IN (' . GetSonIds($typeid) . ')';
                    } else {
                        $selquery = '';
                        if ($arr['cross'] == 1) {
                            $selquery = "SELECT id,topid FROM `#@__arctype` WHERE typename LIKE '{$arr['typename']}' AND id<>'{$typeid}' AND topid<>'{$typeid}'  ";
                        } else {
                            $arr['crossid'] = preg_replace('#[^0-9,]#', '', trim($arr['crossid']));
                            if ($arr['crossid'] != '') {
                                $selquery = "SELECT id,topid FROM `#@__arctype` WHERE id IN('{$arr['crossid']}') AND id<>'{$typeid}' AND topid<>'{$typeid}'  ";
                            }
                        }
                        if ($selquery != '') {
                            $dsql->SetQuery($selquery);
                            $dsql->Execute();
                            while ($arr = $dsql->GetArray()) {
                                $CrossID .= $CrossID == '' ? $arr['id'] : ',' . $arr['id'];
                            }
                        }
                    }
                }
                if ($CrossID == '') {
                    $orwheres[] = ' arc.typeid IN (' . GetSonIds($typeid) . ')';
                } else {
                    $orwheres[] = ' arc.typeid IN (' . GetSonIds($typeid) . ',' . $CrossID . ')';
                }
            }
        }
        //频道ID
        if (preg_match('#spec#i', $listtype)) {
            $channelid == -1;
        }
        if (!empty($channelid)) {
            $orwheres[] = " And arc.channel = '{$channelid}' ";
        }
        if (!empty($noflag)) {
            if (!preg_match('#,#', $noflag)) {
                $orwheres[] = " FIND_IN_SET('{$noflag}', arc.flag)<1 ";
            } else {
                $noflags = explode(',', $noflag);
                foreach ($noflags as $noflag) {
                    if (trim($noflag) == '') {
                        continue;
                    }
                    $orwheres[] = " FIND_IN_SET('{$noflag}', arc.flag)<1 ";
                }
            }
        }
        $orwheres[] = ' arc.arcrank > -1 ';
        //由于这个条件会导致缓存功能失去意义,因此取消
        //if($arcid!=0) $orwheres[] = " arc.id<>'$arcid' ";
    }
    //文档排序的方式
    $ordersql = '';
    if ($orderby == 'hot' || $orderby == 'click') {
        $ordersql = " ORDER BY arc.click {$orderWay}";
    } else {
        if ($orderby == 'sortrank' || $orderby == 'pubdate') {
            $ordersql = " ORDER BY arc.sortrank {$orderWay}";
        } else {
            if ($orderby == 'id') {
                $ordersql = "  ORDER BY arc.id {$orderWay}";
            } else {
                if ($orderby == 'near') {
                    $ordersql = " ORDER BY ABS(arc.id - " . $arcid . ")";
                } else {
                    if ($orderby == 'lastpost') {
                        $ordersql = "  ORDER BY arc.lastpost {$orderWay}";
                    } else {
                        if ($orderby == 'scores') {
                            $ordersql = "  ORDER BY arc.scores {$orderWay}";
                        } else {
                            if ($orderby == 'goodpost') {
                                $ordersql = " order by arc.goodpost {$orderWay}";
                            } else {
                                if ($orderby == 'badpost') {
                                    $ordersql = " order by arc.badpost {$orderWay}";
                                } else {
                                    if ($orderby == 'rand') {
                                        $ordersql = "  ORDER BY rand()";
                                    } else {
                                        $ordersql = " ORDER BY arc.sortrank {$orderWay}";
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    //limit条件
    $limit = trim(preg_replace('#limit#is', '', $limit));
    if ($limit != '') {
        $limitsql = " LIMIT {$limit} ";
        $limitarr = explode(',', $limit);
        $line = isset($limitarr[1]) ? $limitarr[1] : $line;
    } else {
        $limitsql = " LIMIT 0,{$line} ";
    }
    $orwhere = '';
    if (isset($orwheres[0])) {
        $orwhere = join(' And ', $orwheres);
        $orwhere = preg_replace("#^ And#is", '', $orwhere);
        $orwhere = preg_replace("#And[ ]{1,}And#is", 'And ', $orwhere);
    }
    if ($orwhere != '') {
        $orwhere = " WHERE {$orwhere} ";
    }
    //获取附加表信息
    $addfield = trim($ctag->GetAtt('addfields'));
    $addfieldsSql = '';
    $addfieldsSqlJoin = '';
    if ($addfield != '' && !empty($channelid)) {
        $row = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='{$channelid}' ");
        if (isset($row['addtable']) && trim($row['addtable']) != '') {
            $addtable = trim($row['addtable']);
            $addfields = explode(',', $addfield);
            $row['addtable'] = trim($row['addtable']);
            $addfieldsSql = ",addf." . join(',addf.', $addfields);
            $addfieldsSqlJoin = " LEFT JOIN `{$addtable}` addf ON addf.aid = arc.id ";
        }
    }
    $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,\r\n        tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\r\n        {$addfieldsSql}\r\n        FROM `{$maintable}` arc LEFT JOIN `#@__arctype` tp on arc.typeid=tp.id\r\n        {$addfieldsSqlJoin}\r\n        {$orwhere} {$ordersql} {$limitsql}";
    //统一hash
    $taghash = md5(serialize($ctag) . $typeid);
    $needSaveCache = true;
    //进行tagid的默认处理
    if ($pagesize > 0) {
        $tagid = AttDef($tagid, 'tag' . $taghash);
    }
    if ($idlist != '' || $GLOBALS['_arclistEnv'] == 'index' || $cfg_index_cache == 0) {
        $needSaveCache = false;
    } else {
        $idlist = GetArclistCache($taghash);
        if ($idlist != '') {
            $needSaveCache = false;
        }
        //如果使用的是内容缓存,直接返回结果
        if ($cfg_cache_type == 'content' && $idlist != '') {
            $idlist = $idlist == 0 ? '' : $idlist;
            return $idlist;
        }
    }
    //指定了id或使用缓存中的id
    if ($idlist != '') {
        $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,\r\n            tp.moresite,tp.siteurl,tp.sitepath\r\n            {$addfieldsSql}\r\n             FROM `{$maintable}` arc left join `#@__arctype` tp on arc.typeid=tp.id\r\n             {$addfieldsSqlJoin}\r\n          WHERE arc.id in({$idlist}) {$ordersql} ";
    }
    // 好评差评缓存更新
    if ($cfg_digg_update > 0) {
        if ($orderby == 'goodpost' || $orderby == 'badpost') {
            $t1 = ExecTime();
            $postsql = "SELECT arc.id,arc.goodpost,arc.badpost,arc.scores\r\n\t\t\t\tFROM `{$maintable}` arc\r\n\t\t\t\t{$orwhere} {$ordersql} {$limitsql}";
            if ($idlist != '') {
                $postsql = "SELECT arc.id,arc.goodpost,arc.badpost,arc.scores\r\n\t\t\t\t\t FROM `{$maintable}` arc \r\n\t\t\t\t  WHERE arc.id in({$idlist}) {$ordersql} ";
            }
            $dsql->SetQuery($query);
            $dsql->Execute('lit');
            while ($row = $dsql->GetArray('lit')) {
                $prefix = 'diggCache';
                $key = 'aid-' . $row['id'];
                $cacherow = GetCache($prefix, $key);
                $setsql = array();
                if (!empty($cacherow['scores']) && $cacherow['scores'] != $row['scores']) {
                    $setsql[] = "scores = {$cacherow['scores']}";
                }
                if (!empty($cacherow['goodpost']) && $cacherow['goodpost'] != $row['goodpost']) {
                    $setsql[] = "goodpost = {$cacherow['goodpost']}";
                }
                if (!empty($cacherow['badpost']) && $cacherow['badpost'] != $row['badpost']) {
                    $setsql[] = "badpost = {$cacherow['badpost']}";
                }
                $setsql = implode(',', $setsql);
                $sql = "UPDATE `{$maintable}` SET {$setsql} WHERE id='{$row['id']}'";
                if (!empty($setsql)) {
                    $dsql->ExecuteNoneQuery($sql);
                }
            }
            //echo ExecTime()-$t1;
        }
    }
    $dsql->SetQuery($query);
    $dsql->Execute('al');
    //$row = $dsql->GetArray("al");
    $artlist = '';
    if ($pagesize > 0) {
        $artlist .= "    <div id='{$tagid}'>\r\n";
    }
    if ($col > 1) {
        $artlist = "<table width='{$tablewidth}' border='0' cellspacing='0' cellpadding='0'>\r\n";
    }
    $dtp2 = new DedeTagParse();
    $dtp2->SetNameSpace('field', '[', ']');
    $dtp2->LoadString($innertext);
    $GLOBALS['autoindex'] = 0;
    $ids = array();
    $orderWeight = array();
    for ($i = 0; $i < $line; $i++) {
        if ($col > 1) {
            $artlist .= "<tr>\r\n";
        }
        for ($j = 0; $j < $col; $j++) {
            if ($col > 1) {
                $artlist .= "    <td width='{$colWidth}'>\r\n";
            }
            if ($row = $dsql->GetArray("al")) {
                $ids[] = $row['id'];
                //处理一些特殊字段
                $row['info'] = $row['infos'] = cn_substr($row['description'], $infolen);
                $row['id'] = $row['id'];
                if ($row['corank'] > 0 && $row['arcrank'] == 0) {
                    $row['arcrank'] = $row['corank'];
                }
                $row['filename'] = $row['arcurl'] = GetFileUrl($row['id'], $row['typeid'], $row['senddate'], $row['title'], $row['ismake'], $row['arcrank'], $row['namerule'], $row['typedir'], $row['money'], $row['filename'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                $row['typeurl'] = GetTypeUrl($row['typeid'], $row['typedir'], $row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                if ($row['litpic'] == '-' || $row['litpic'] == '') {
                    $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
                }
                if (!preg_match("#^http:\\/\\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
                    $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
                }
                $row['picname'] = $row['litpic'];
                $row['stime'] = GetDateMK($row['pubdate']);
                $row['typelink'] = "<a href='" . $row['typeurl'] . "'>" . $row['typename'] . "</a>";
                $row['image'] = "<img src='" . $row['picname'] . "' border='0' width='{$imgwidth}' height='{$imgheight}' alt='" . preg_replace("#['><]#", "", $row['title']) . "'>";
                $row['imglink'] = "<a href='" . $row['filename'] . "'>" . $row['image'] . "</a>";
                $row['fulltitle'] = $row['title'];
                $row['title'] = cn_substr($row['title'], $titlelen);
                if ($row['color'] != '') {
                    $row['title'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
                }
                if (preg_match('#b#', $row['flag'])) {
                    $row['title'] = "<strong>" . $row['title'] . "</strong>";
                }
                //$row['title'] = "<b>".$row['title']."</b>";
                $row['textlink'] = "<a href='" . $row['filename'] . "'>" . $row['title'] . "</a>";
                $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                if (is_array($dtp2->CTags)) {
                    foreach ($dtp2->CTags as $k => $ctag) {
                        if ($ctag->GetName() == 'array') {
                            //传递整个数组,在runphp模式中有特殊作用
                            $dtp2->Assign($k, $row);
                        } else {
                            if (isset($row[$ctag->GetName()])) {
                                $dtp2->Assign($k, $row[$ctag->GetName()]);
                            } else {
                                $dtp2->Assign($k, '');
                            }
                        }
                    }
                    $GLOBALS['autoindex']++;
                }
                if ($pagesize > 0) {
                    if ($GLOBALS['autoindex'] <= $pagesize) {
                        $liststr = $dtp2->GetResult();
                        $artlist .= $liststr . "\r\n";
                    } else {
                        $artlist .= "";
                        $orderWeight[] = array('weight' => $row['weight'], 'arclist' => '');
                    }
                } else {
                    $liststr = $dtp2->GetResult();
                    $artlist .= $liststr . "\r\n";
                }
                $orderWeight[] = array('weight' => $row['weight'], 'arclist' => $liststr);
            } else {
                $artlist .= '';
            }
            // 进行判断,如果启用排序则内容输出为重新排序后的内容
            // var_dump($isweight=='y' && count($orderWeight) == $line);
            $isweight = strtolower($isweight);
            if ($isweight == 'y') {
                $artlist = '';
                $orderWeight = list_sort_by($orderWeight, 'weight', 'asc');
                foreach ($orderWeight as $vv) {
                    $artlist .= $vv['arclist'];
                }
            }
            if ($col > 1) {
                $artlist .= "    </td>\r\n";
            }
        }
        //Loop Col
        if ($col > 1) {
            $i += $col - 1;
        }
        if ($col > 1) {
            $artlist .= "    </tr>\r\n";
        }
    }
    //loop line
    if ($col > 1) {
        $artlist .= "    </table>\r\n";
    }
    $dsql->FreeResult("al");
    $idsstr = join(',', $ids);
    //分页特殊处理
    if ($pagesize > 0) {
        $artlist .= "    </div>\r\n";
        $row = $dsql->GetOne("SELECT tagid FROM #@__arcmulti WHERE tagid='{$tagid}'");
        $uptime = time();
        $attstr = addslashes(serialize($attarray));
        $innertext = addslashes($innertext);
        if (!is_array($row)) {
            $query = "\r\n          INSERT INTO #@__arcmulti(tagid,uptime,innertext,pagesize,arcids,ordersql,addfieldsSql,addfieldsSqlJoin,attstr)\r\n          VALUES('{$tagid}','{$uptime}','{$innertext}','{$pagesize}','{$idsstr}','{$ordersql}','{$addfieldsSql}','{$addfieldsSqlJoin}','{$attstr}');\r\n        ";
            $dsql->ExecuteNoneQuery($query);
        } else {
            $query = "UPDATE `#@__arcmulti`\r\n           SET\r\n           uptime='{$uptime}',\r\n           innertext='{$innertext}',\r\n           pagesize='{$pagesize}',\r\n           arcids='{$idsstr}',\r\n           ordersql='{$ordersql}',\r\n           addfieldsSql='{$addfieldsSql}',\r\n           addfieldsSqlJoin='{$addfieldsSqlJoin}',\r\n           attstr='{$attstr}'\r\n           WHERE tagid='{$tagid}'\r\n        ";
            $dsql->ExecuteNoneQuery($query);
        }
    }
    //保存ID缓存
    if ($needSaveCache) {
        if ($idsstr == '') {
            $idsstr = '0';
        }
        if ($cfg_cache_type == 'content' && $idsstr != '0') {
            $idsstr = addslashes($artlist);
        }
        $inquery = "INSERT INTO `#@__arccache`(`md5hash`,`uptime`,`cachedata`) VALUES ('" . $taghash . "','" . time() . "', '{$idsstr}'); ";
        $dsql->ExecuteNoneQuery("DELETE FROM `#@__arccache` WHERE md5hash='" . $taghash . "' ");
        $dsql->ExecuteNoneQuery($inquery);
    }
    return $artlist;
}
Exemple #16
0
function lib_arclistsg(&$ctag, &$refObj)
{
    global $dsql, $PubFields, $cfg_keyword_like, $cfg_index_cache, $_arclistEnv, $envs, $_sys_globals;
    //属性处理
    $attlist = "typeid|0,row|10,col|1,flag|,titlelen|30,sort|default,keyword|,innertext|,arcid|0,idlist|,channelid|0,limit|,orderway|desc,subday|0";
    FillAttsDefault($ctag->CAttribute->Items, $attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $line = $row;
    $orderby = strtolower($sort);
    if ($col == '') {
        $col = 1;
    }
    if (empty($imgwidth)) {
        $imgwidth = "";
    }
    if (empty($imgheight)) {
        $imgheight = "";
    }
    $innertext = trim($ctag->GetInnerText());
    if ($innertext == '') {
        $innertext = GetSysTemplets("part_arclistsg.htm");
    }
    if (empty($channelid) && isset($GLOBALS['envs']['channelid'])) {
        $channelid = $GLOBALS['envs']['channelid'];
    }
    if (empty($typeid) && !empty($envs['typeid'])) {
        $typeid = $envs['typeid'];
    }
    if (empty($typeid) && empty($channelid)) {
        return "No channel info!";
    }
    if (!empty($channelid)) {
        $gquery = "SELECT addtable,listfields FROM `#@__channeltype` WHERE id='{$channelid}' ";
    } else {
        $gquery = "SELECT ch.addtable,listfields FROM `#@__arctype` tp LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype WHERE id='{$typeid}'";
    }
    $row = $dsql->GetOne($gquery);
    $orwheres = array();
    $maintable = trim($row['addtable']);
    if ($maintable == '') {
        return "No addtable info!";
    }
    //列表调用字段
    $listarcs = array('aid', 'typeid');
    if (!empty($row['listfields'])) {
        $listfields = explode(',', $row['listfields']);
        foreach ($listfields as $v) {
            if (!in_array($v, $listarcs)) {
                $listarcs[] = $v;
            }
        }
    }
    $arclistquery = join(',', $listarcs);
    $arclistquery .= ",arc.aid AS id,arc.senddate AS pubdate";
    //按不同情况设定SQL条件 排序方式
    if ($idlist == '') {
        if ($orderby == 'near' && $cfg_keyword_like == 'N') {
            $keyword = '';
        }
        //时间限制(用于调用最近热门文章、热门评论之类)
        if ($subday > 0) {
            //这里的时间只能计算到天,否则缓存功能将无效
            $ntime = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y'));
            $limitday = $ntime - $subday * 24 * 3600;
            $orwheres[] = " arc.senddate > {$limitday} ";
        }
        if ($flag != '') {
            $flags = explode(',', $flag);
            for ($i = 0; isset($flags[$i]); $i++) {
                $orwheres[] = " FIND_IN_SET('{$flags[$i]}',flag)>0 ";
            }
        }
        if (!empty($typeid)) {
            //指定了多个栏目时,不再获取子类的id
            if (preg_match('#,#', $typeid)) {
                $orwheres[] = " typeid IN ({$typeid}) ";
            } else {
                //处理交叉栏目
                $CrossID = '';
                if ((isset($envs['cross']) || $ctag->GetAtt('cross') == '1') && $ctag->GetAtt('nocross') != '1') {
                    $arr = $dsql->GetOne("SELECT `id`,`topid`,`cross`,`crossid`,`ispart`,`typename` FROM `#@__arctype` WHERE id='{$typeid}' ");
                    if ($arr['cross'] == 0 || $arr['cross'] == 2 && trim($arr['crossid'] == '')) {
                        $orwheres[] = ' typeid IN (' . GetSonIds($typeid) . ')';
                    } else {
                        $selquery = '';
                        if ($arr['cross'] == 1) {
                            $selquery = "SELECT id,topid FROM `#@__arctype` WHERE typename like '{$arr['typename']}' AND id<>'{$typeid}' AND topid<>'{$typeid}'  ";
                        } else {
                            $arr['crossid'] = preg_replace('#[^0-9,]#', '', trim($arr['crossid']));
                            if ($arr['crossid'] != '') {
                                $selquery = "SELECT id,topid FROM `#@__arctype` WHERE id IN('{$arr['crossid']}') AND id<>'{$typeid}' AND topid<>'{$typeid}'  ";
                            }
                        }
                        if ($selquery != '') {
                            $dsql->SetQuery($selquery);
                            $dsql->Execute();
                            while ($arr = $dsql->GetArray()) {
                                $CrossID .= $CrossID == '' ? $arr['id'] : ',' . $arr['id'];
                            }
                        }
                    }
                }
                if ($CrossID == '') {
                    $orwheres[] = ' typeid IN (' . GetSonIds($typeid) . ')';
                } else {
                    $orwheres[] = ' typeid IN (' . GetSonIds($typeid) . ',' . $CrossID . ')';
                }
            }
        }
        //频道ID
        if (!empty($channelid)) {
            $orwheres[] = " AND arc.channel = '{$channelid}' ";
        }
        //由于这个条件会导致缓存功能失去意义,因此取消
        //if($arcid!=0) $orwheres[] = " arc.id<>'$arcid' ";
    }
    //文档排序的方式
    $ordersql = '';
    if ($orderby == 'hot' || $orderby == 'click') {
        $ordersql = " ORDER BY arc.click {$orderway}";
    } else {
        if ($orderby == 'id') {
            $ordersql = "  ORDER BY arc.aid {$orderway}";
        } else {
            if ($orderby == 'near') {
                $ordersql = " ORDER BY ABS(arc.id - " . $arcid . ")";
            } else {
                if ($orderby == 'rand') {
                    $ordersql = "  ORDER BY rand()";
                } else {
                    $ordersql = " ORDER BY arc.aid {$orderway}";
                }
            }
        }
    }
    //limit条件
    $limit = trim(preg_replace('#limit#i', '', $limit));
    if ($limit != '') {
        $limitsql = " LIMIT {$limit} ";
    } else {
        $limitsql = " LIMIT 0,{$line} ";
    }
    $orwhere = '';
    if (isset($orwheres[0])) {
        $orwhere = join(' AND ', $orwheres);
        $orwhere = preg_replace("#^ AND#i", '', $orwhere);
        $orwhere = preg_replace("#AND[ ]{1,}AND#i", 'AND ', $orwhere);
    }
    if ($orwhere != '') {
        $orwhere = " WHERE {$orwhere} ";
    }
    $query = "SELECT {$arclistquery},tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,\n        tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\n        FROM `{$maintable}` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\n        {$orwhere} AND arc.arcrank > -1 {$ordersql} {$limitsql}";
    $md5hash = md5($query);
    $needcache = TRUE;
    if ($idlist != '') {
        $needcache = FALSE;
    } else {
        $idlist = GetArclistSgCache($md5hash);
        if ($idlist != '') {
            $needcache = FALSE;
        }
    }
    //指定了id或使用缓存中的id
    if ($idlist != '' && $_arclistEnv != 'index') {
        $query = "SELECT {$arclistquery},tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,\n            tp.moresite,tp.siteurl,tp.sitepath FROM `{$maintable}` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\n          WHERE arc.aid IN({$idlist}) {$ordersql} {$limitsql}";
    }
    $dsql->SetQuery($query);
    $dsql->Execute("al");
    $artlist = "";
    $dtp2 = new DedeTagParse();
    $dtp2->SetNameSpace("field", "[", "]");
    $dtp2->LoadString($innertext);
    $GLOBALS['autoindex'] = 0;
    $ids = array();
    for ($i = 0; $i < $line; $i++) {
        for ($j = 0; $j < $col; $j++) {
            if ($col > 1) {
                $artlist .= "    <div>\r\n";
            }
            if ($row = $dsql->GetArray("al")) {
                $ids[] = $row['aid'];
                $row['filename'] = $row['arcurl'] = GetFileUrl($row['id'], $row['typeid'], $row['senddate'], $row['title'], 1, 0, $row['namerule'], $row['typedir'], 0, '', $row['moresite'], $row['siteurl'], $row['sitepath']);
                $row['typeurl'] = GetTypeUrl($row['typeid'], $row['typedir'], $row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                if ($row['litpic'] == '-' || $row['litpic'] == '') {
                    $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
                }
                if (!preg_match("#^http:\\/\\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
                    $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
                }
                $row['picname'] = $row['litpic'];
                $row['image'] = "<img src='" . $row['picname'] . "' border='0' width='{$imgwidth}' height='{$imgheight}' alt='" . preg_replace("#['><]#", "", $row['title']) . "' />";
                $row['imglink'] = "<a href='" . $row['filename'] . "'>" . $row['image'] . "</a>";
                $row['stime'] = GetDateMK($row['pubdate']);
                $row['typelink'] = "<a href='" . $row['typeurl'] . "'>" . $row['typename'] . "</a>";
                $row['fulltitle'] = $row['title'];
                $row['title'] = cn_substr($row['title'], $titlelen);
                $row['textlink'] = "<a href='" . $row['filename'] . "'>" . $row['title'] . "</a>";
                $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                if (is_array($dtp2->CTags)) {
                    foreach ($dtp2->CTags as $k => $ctag) {
                        if ($ctag->GetName() == 'array') {
                            //传递整个数组,在runphp模式中有特殊作用
                            $dtp2->Assign($k, $row);
                        } else {
                            if (isset($row[$ctag->GetName()])) {
                                $dtp2->Assign($k, $row[$ctag->GetName()]);
                            } else {
                                $dtp2->Assign($k, '');
                            }
                        }
                    }
                    $GLOBALS['autoindex']++;
                }
                $artlist .= $dtp2->GetResult() . "\r\n";
            } else {
                $artlist .= '';
            }
            if ($col > 1) {
                $artlist .= "    </div>\r\n";
            }
        }
        //Loop Col
        if ($col > 1) {
            $i += $col - 1;
        }
    }
    //loop line
    $dsql->FreeResult("al");
    //保存ID缓存
    $idsstr = join(',', $ids);
    if ($idsstr != '' && $needcache && $cfg_index_cache > 0) {
        $mintime = time() - $cfg_index_cache * 3600;
        $inquery = "INSERT INTO `#@__arccache`(`md5hash`,`uptime`,`cachedata`) VALUES ('" . $md5hash . "', '" . time() . "', '{$idsstr}'); ";
        $dsql->ExecuteNoneQuery("DELETE FROM `#@__arccache` WHERE md5hash='" . $md5hash . "' or uptime < {$mintime} ");
        $dsql->ExecuteNoneQuery($inquery);
    }
    return $artlist;
}
Exemple #17
0
function lib_likearticle(&$ctag, &$refObj)
{
    global $dsql;
    //属性处理
    $attlist = "row|12,titlelen|28,infolen|150,col|1,tablewidth|100,mytypeid|0,byabs|0,imgwidth|120,imgheight|90";
    FillAttsDefault($ctag->CAttribute->Items, $attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $revalue = '';
    if (empty($tablewidth)) {
        $tablewidth = 100;
    }
    if (empty($col)) {
        $col = 1;
    }
    $colWidth = ceil(100 / $col);
    $tablewidth = $tablewidth . "%";
    $colWidth = $colWidth . "%";
    $ids = array();
    $tids = array();
    if (!empty($refObj->Fields['tags'])) {
        $keyword = $refObj->Fields['tags'];
    } else {
        $keyword = !empty($refObj->Fields['keywords']) ? $refObj->Fields['keywords'] : '';
    }
    $typeid = !empty($mytypeid) ? $mytypeid : 0;
    if (empty($typeid)) {
        if (!empty($refObj->Typelink->TypeInfos['reid'])) {
            $typeid = $refObj->Typelink->TypeInfos['reid'];
        } else {
            if (!empty($refObj->Fields['typeid'])) {
                $typeid = $refObj->Fields['typeid'];
            }
        }
    }
    if (!empty($typeid) && !preg_match('#,#', $typeid)) {
        $typeid = GetSonIds($typeid);
    }
    $limitRow = $row - count($ids);
    $keyword = '';
    if (!empty($refObj->Fields['keywords'])) {
        $keywords = explode(',', trim($refObj->Fields['keywords']));
        $keyword = '';
        $n = 1;
        foreach ($keywords as $k) {
            if ($n > 3) {
                break;
            }
            if (trim($k) == '') {
                continue;
            } else {
                $k = addslashes($k);
            }
            $keyword .= $keyword == '' ? " CONCAT(arc.keywords,' ',arc.title) LIKE '%{$k}%' " : " OR CONCAT(arc.keywords,' ',arc.title) LIKE '%{$k}%' ";
            $n++;
        }
    }
    $arcid = !empty($refObj->Fields['id']) ? $refObj->Fields['aid'] : 0;
    if (empty($arcid) || $byabs == 0) {
        $orderquery = " ORDER BY arc.id desc ";
    } else {
        $orderquery = " ORDER BY ABS(arc.id - " . $arcid . ") ";
    }
    if ($keyword != '') {
        if (!empty($typeid)) {
            $typeid = " AND arc.typeid IN({$typeid}) AND arc.id<>{$arcid} ";
        }
        $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,\r\n                  tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\r\n                  FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\r\n                  where arc.arcrank>-1 AND ({$keyword})  {$typeid} {$orderquery} limit 0, {$row}";
    } else {
        if (!empty($typeid)) {
            $typeid = " arc.typeid IN({$typeid}) AND arc.id<>{$arcid} ";
        }
        $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,\r\n                  tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\r\n                  FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\r\n                 WHERE arc.arcrank>-1 AND  {$typeid} {$orderquery} limit 0, {$row}";
    }
    $innertext = trim($ctag->GetInnerText());
    if ($innertext == '') {
        $innertext = GetSysTemplets('part_arclist.htm');
    }
    $dsql->SetQuery($query);
    $dsql->Execute('al');
    $artlist = '';
    if ($col > 1) {
        $artlist = "<table width='{$tablewidth}' border='0' cellspacing='0' cellpadding='0'>\r\n";
    }
    $dtp2 = new DedeTagParse();
    $dtp2->SetNameSpace('field', '[', ']');
    $dtp2->LoadString($innertext);
    $GLOBALS['autoindex'] = 0;
    $line = $row;
    for ($i = 0; $i < $line; $i++) {
        if ($col > 1) {
            $artlist .= "<tr>\r\n";
        }
        for ($j = 0; $j < $col; $j++) {
            if ($col > 1) {
                $artlist .= "    <td width='{$colWidth}'>\r\n";
            }
            if ($row = $dsql->GetArray("al")) {
                $ids[] = $row['id'];
                //处理一些特殊字段
                $row['info'] = $row['infos'] = cn_substr($row['description'], $infolen);
                $row['id'] = $row['id'];
                if ($row['corank'] > 0 && $row['arcrank'] == 0) {
                    $row['arcrank'] = $row['corank'];
                }
                $row['filename'] = $row['arcurl'] = GetFileUrl($row['id'], $row['typeid'], $row['senddate'], $row['title'], $row['ismake'], $row['arcrank'], $row['namerule'], $row['typedir'], $row['money'], $row['filename'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                $row['typeurl'] = GetTypeUrl($row['typeid'], $row['typedir'], $row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                if ($row['litpic'] == '-' || $row['litpic'] == '') {
                    $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
                }
                if (!preg_match("#^http:\\/\\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
                    $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
                }
                $row['picname'] = $row['litpic'];
                $row['stime'] = GetDateMK($row['pubdate']);
                $row['typelink'] = "<a href='" . $row['typeurl'] . "'>" . $row['typename'] . "</a>";
                $row['image'] = "<img src='" . $row['picname'] . "' border='0' width='{$imgwidth}' height='{$imgheight}' alt='" . preg_replace("#['><]#", "", $row['title']) . "'>";
                $row['imglink'] = "<a href='" . $row['filename'] . "'>" . $row['image'] . "</a>";
                $row['fulltitle'] = $row['title'];
                $row['title'] = cn_substr($row['title'], $titlelen);
                if ($row['color'] != '') {
                    $row['title'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
                }
                if (preg_match('#b#', $row['flag'])) {
                    $row['title'] = "<strong>" . $row['title'] . "</strong>";
                }
                $row['textlink'] = "<a href='" . $row['filename'] . "'>" . $row['title'] . "</a>";
                $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                if (is_array($dtp2->CTags)) {
                    foreach ($dtp2->CTags as $k => $ctag) {
                        if ($ctag->GetName() == 'array') {
                            $dtp2->Assign($k, $row);
                        } else {
                            if (isset($row[$ctag->GetName()])) {
                                $dtp2->Assign($k, $row[$ctag->GetName()]);
                            } else {
                                $dtp2->Assign($k, '');
                            }
                        }
                    }
                    $GLOBALS['autoindex']++;
                }
                $artlist .= $dtp2->GetResult() . "\r\n";
            } else {
                $artlist .= '';
            }
            if ($col > 1) {
                $artlist .= "    </td>\r\n";
            }
        }
        //Loop Col
        if ($col > 1) {
            $i += $col - 1;
        }
        if ($col > 1) {
            $artlist .= "    </tr>\r\n";
        }
    }
    //loop line
    if ($col > 1) {
        $artlist .= "    </table>\r\n";
    }
    $dsql->FreeResult("al");
    return $artlist;
}
 function GetList($limitstart, $ismake = 1)
 {
     global $cfg_list_son, $cfg_needsontype;
     $col = $this->ListObj->GetAtt('col');
     if (empty($col)) {
         $col = 1;
     }
     $titlelen = $this->ListObj->GetAtt('titlelen');
     $infolen = $this->ListObj->GetAtt('infolen');
     $imgwidth = $this->ListObj->GetAtt('imgwidth');
     $imgheight = $this->ListObj->GetAtt('imgheight');
     $titlelen = AttDef($titlelen, 60);
     $infolen = AttDef($infolen, 250);
     $imgwidth = AttDef($imgwidth, 80);
     $imgheight = AttDef($imgheight, 80);
     $innertext = trim($this->ListObj->GetInnerText());
     if (empty($innertext)) {
         $innertext = GetSysTemplets("list_fulllist.htm");
     }
     $tablewidth = 100;
     if ($col == "") {
         $col = 1;
     }
     $colWidth = ceil(100 / $col);
     $tablewidth = $tablewidth . "%";
     $colWidth = $colWidth . "%";
     //按不同情况设定SQL条件
     $orwhere = " arc.arcrank > -1 And channel>-1 ";
     $typeid = $this->ListObj->GetAtt('typeid');
     $subday = $this->ListObj->GetAtt('subday');
     $listtype = $this->ListObj->GetAtt('type');
     $att = $this->ListObj->GetAtt('att');
     $channelid = $this->ListObj->GetAtt('channel');
     if (empty($channelid)) {
         $channelid = 0;
     }
     //是否指定栏目条件
     if (!empty($typeid)) {
         if ($cfg_list_son == 'N') {
             $orwhere .= " And (arc.typeid='{$typeid}') ";
         } else {
             $orwhere .= " And arc.typeid in (" . GetSonIds($typeid, 0, true) . ") ";
         }
     }
     //自定义属性条件
     if ($att != '') {
         $flags = explode(',', $att);
         for ($i = 0; isset($flags[$i]); $i++) {
             $orwhere .= " AND FIND_IN_SET('{$flags[$i]}',flag)>0 ";
         }
     }
     //文档的频道模型
     if ($channelid > 0 && !eregi("spec", $listtype)) {
         $orwhere .= " And arc.channel = '{$channelid}' ";
     }
     //推荐文档 带缩略图  专题文档
     if (eregi("commend", $listtype)) {
         $orwhere .= " And FIND_IN_SET('c',flag) > 0  ";
     }
     if (eregi("image", $listtype)) {
         $orwhere .= " And arc.litpic <> ''  ";
     }
     if (eregi("spec", $listtype) || $channelid == -1) {
         $orwhere .= " And arc.channel = -1  ";
     }
     if (!empty($subday)) {
         $starttime = time() - $subday * 86400;
         $orwhere .= " And arc.senddate > {$starttime}  ";
     }
     $keyword = $this->ListObj->GetAtt('keyword');
     if (!empty($keyword)) {
         $orwhere .= " And CONCAT(arc.title,arc.keywords) REGEXP '{$keyword}' ";
     }
     $orderby = $this->ListObj->GetAtt('orderby');
     $orderWay = $this->ListObj->GetAtt('orderway');
     //排序方式
     $ordersql = "";
     if ($orderby == "senddate") {
         $ordersql = " order by arc.senddate {$orderWay}";
     } else {
         if ($orderby == "pubdate") {
             $ordersql = " order by arc.pubdate {$orderWay}";
         } else {
             if ($orderby == "id") {
                 $ordersql = "  order by arc.id {$orderWay}";
             } else {
                 if ($orderby == "hot" || $orderby == "click") {
                     $ordersql = " order by arc.click {$orderWay}";
                 } else {
                     if ($orderby == "lastpost") {
                         $ordersql = "  order by arc.lastpost {$orderWay}";
                     } else {
                         if ($orderby == "scores") {
                             $ordersql = "  order by arc.scores {$orderWay}";
                         } else {
                             if ($orderby == "rand") {
                                 $ordersql = "  order by rand()";
                             } else {
                                 $ordersql = " order by arc.sortrank {$orderWay}";
                             }
                         }
                     }
                 }
             }
         }
     }
     //获得附加表的相关信息
     $addField = "";
     $addJoin = "";
     if (is_object($this->ChannelUnit)) {
         $addtable = $this->ChannelUnit->ChannelInfos['addtable'];
         if ($addtable != "") {
             $addJoin = " left join {$addtable} on arc.id = " . $addtable . ".aid ";
             $addField = "";
             $fields = explode(",", $this->ChannelUnit->ChannelInfos['listfields']);
             foreach ($fields as $k => $v) {
                 $nfields[$v] = $k;
             }
             foreach ($this->ChannelUnit->ChannelFields as $k => $arr) {
                 if (isset($nfields[$k])) {
                     if (!empty($arr['rename'])) {
                         $addField .= "," . $addtable . "." . $k . " as " . $arr['rename'];
                     } else {
                         $addField .= "," . $addtable . "." . $k;
                     }
                 }
             }
         }
     }
     $query = "Select arc.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,\r\n\t\ttp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\r\n\t\t{$addField}\r\n\t\tfrom {$this->maintable} arc\r\n\t\tleft join #@__arctype tp on arc.typeid=tp.id\r\n\t\t{$addJoin}\r\n\t\twhere {$orwhere} {$ordersql} limit {$limitstart}," . $this->PageSize;
     $this->dsql->SetQuery($query);
     $this->dsql->Execute("al");
     $artlist = "";
     if ($col > 1) {
         $artlist = "<table width='{$tablewidth}' border='0' cellspacing='0' cellpadding='0'>\r\n";
     }
     $indtp = new DedeTagParse();
     $indtp->SetNameSpace("field", "[", "]");
     $indtp->LoadSource($innertext);
     $GLOBALS['autoindex'] = 0;
     for ($i = 0; $i < $this->PageSize; $i++) {
         if ($col > 1) {
             $artlist .= "<tr>\r\n";
         }
         for ($j = 0; $j < $col; $j++) {
             if ($col > 1) {
                 $artlist .= "<td width='{$colWidth}'>\r\n";
             }
             if ($row = $this->dsql->GetArray("al")) {
                 $GLOBALS['autoindex']++;
                 //处理一些特殊字段
                 $row['id'] = $row['id'];
                 $row['arcurl'] = $this->GetArcUrl($row['id'], $row['typeid'], $row['senddate'], $row['title'], $row['ismake'], $row['arcrank'], $row['namerule'], $row['typedir'], $row['money'], $row['filename'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                 $row['typeurl'] = GetTypeUrl($row['typeid'], $row['typedir'], $row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'], $row['siteurl'], $row['sitepath']);
                 if ($ismake == 0 && $GLOBALS['cfg_multi_site'] == 'Y') {
                     if ($row["siteurl"] == "") {
                         $row["siteurl"] = $GLOBALS['cfg_mainsite'];
                     }
                 }
                 $row['description'] = cn_substr($row['description'], $infolen);
                 if ($row['litpic'] == '-' || $row['litpic'] == '') {
                     $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
                 }
                 if (!eregi("^http://", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
                     $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
                 }
                 $row['picname'] = $row['litpic'];
                 $row['info'] = $row['description'];
                 $row['filename'] = $row['arcurl'];
                 $row['stime'] = GetDateMK($row['pubdate']);
                 $row['textlink'] = "<a href='" . $row['filename'] . "' title='" . str_replace("'", "", $row['title']) . "'>" . $row['title'] . "</a>";
                 $row['typelink'] = "<a href='" . $row['typeurl'] . "'>[" . $row['typename'] . "]</a>";
                 $row['imglink'] = "<a href='" . $row['filename'] . "'><img src='" . $row['picname'] . "' border='0' width='{$imgwidth}' height='{$imgheight}' alt='" . str_replace("'", "", $row['title']) . "'></a>";
                 $row['image'] = "<img src='" . $row['picname'] . "' border='0' width='{$imgwidth}' height='{$imgheight}' alt='" . str_replace("'", "", $row['title']) . "'>";
                 $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                 $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                 $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                 $row['title'] = cn_substr($row['title'], $titlelen);
                 if ($row['color'] != "") {
                     $row['title'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
                 }
                 if (ereg('c', $row['flag'])) {
                     $row['title'] = "<b>" . $row['title'] . "</b>";
                 }
                 //编译附加表里的数据
                 if (is_object($this->ChannelUnit)) {
                     foreach ($row as $k => $v) {
                         if (ereg("[A-Z]", $k)) {
                             $row[strtolower($k)] = $v;
                         }
                     }
                     foreach ($this->ChannelUnit->ChannelFields as $k => $arr) {
                         if (isset($row[$k])) {
                             $row[$k] = $this->ChannelUnit->MakeField($k, $row[$k]);
                         }
                     }
                 }
                 //解析单条记录
                 if (is_array($indtp->CTags)) {
                     foreach ($indtp->CTags as $k => $ctag) {
                         $_f = $ctag->GetName();
                         if ($_f == 'array') {
                             //传递整个数组,在runphp模式中有特殊作用
                             $indtp->Assign($k, $row);
                         } else {
                             if (isset($row[$_f])) {
                                 $indtp->Assign($k, $row[$_f]);
                             } else {
                                 $indtp->Assign($k, "");
                             }
                         }
                     }
                 }
                 $artlist .= $indtp->GetResult();
             } else {
                 $artlist .= "";
             }
             if ($col > 1) {
                 $artlist .= "\t</td>\r\n";
             }
         }
         //Loop Col
         if ($col > 1) {
             $i += $col - 1;
         }
         if ($col > 1) {
             $artlist .= "\t</tr>\r\n";
         }
     }
     //Loop Line
     if ($col > 1) {
         $artlist .= "</table>\r\n";
     }
     $this->dsql->FreeResult("al");
     return $artlist;
 }
  function GetArcList($limitstart=0,$perpage=10,$col=1,$titlelen=30,$infolen=250,
  $imgwidth=120,$imgheight=90,$achanneltype="all",$orderby=" aid desc ",$innertext="",$tablewidth="100")
  {

	    $typeid=$this->TypeID;
    	if($perpage=="") $perpage = 10;
		if($limitstart=="") $limitstart = 0;
		if($titlelen=="") $titlelen = 30;
		if($infolen=="") $infolen = 250;
	    if($achanneltype=="") $achanneltype = "0";
		$innertext = trim($innertext);
		if($innertext=="") $innertext = GetSysTemplets("search_list.htm");
		$ordersql = "order by ".$this->OrderBy;

		$query = "select * from #@__full_search left join #@__arctype on #@__arctype.ID=#@__full_search.typeid
				where aid in ($this->result) $ordersql limit $limitstart,$perpage ";

		$this->dsql->SetQuery($query);
		$this->dsql->Execute("al");
	    $artlist = "";
	    $this->dtp2->LoadSource($innertext);
		$tt = 0;
	    for($i=0;$i<$perpage;$i++)
		{
         if($row = $this->dsql->GetArray("al"))
         {
           //处理一些特殊字段
           $row["arcurl"] = $row["url"];
           $row["description"] = $this->GetRedKeyWord(cn_substr($row["addinfos"],$infolen));
           $row["title"] = $this->GetRedKeyWord(cn_substr($row["title"],$titlelen));
           $row["id"] =  $row["aid"];
           if($row["litpic"]=="") $row["litpic"] = $GLOBALS["cfg_plus_dir"]."/img/dfpic.gif";
           $row["picname"] = $row["litpic"];
           $row["typeurl"] = $this->GetListUrl($row["typeid"],$row["typedir"],$row["isdefault"],$row["defaultname"],$row["ispart"],$row["namerule2"],$row["siteurl"]);
           $row["info"] = $row["description"];
           $row["filename"] = $row["arcurl"];
           $row["stime"] = GetDateMK($row["uptime"]);
           $row["textlink"] = "<a href='".$row["filename"]."'>".$row["title"]."</a>";
           $row["typelink"] = "[<a href='".$row["typeurl"]."'>".$row["typename"]."</a>]";
           $row["imglink"] = "<a href='".$row["filename"]."'><img src='".$row["picname"]."' border='0' width='$imgwidth' height='$imgheight'></a>";
           $row["image"] = "<img src='".$row["picname"]."' border='0' width='$imgwidth' height='$imgheight'>";
           $row["phpurl"] = $GLOBALS["cfg_plus_dir"];
 		   $row["templeturl"] = $GLOBALS["cfg_templets_dir"];
 		   $row["memberurl"] = $GLOBALS["cfg_member_dir"];
           //---------------------------
           if(is_array($this->dtp2->CTags)){
       	     foreach($this->dtp2->CTags as $k=>$ctag){
       		 	   if(isset($row[$ctag->GetName()])) $this->dtp2->Assign($k,$row[$ctag->GetName()]);
       		 	   else $this->dtp2->Assign($k,"");
       	    }
           }
           $artlist .= $this->dtp2->GetResult();
           $tt = 1;
         }//if hasRow
         else{
         	if($tt == 0 && $this->KType == 1){
						$sp1 = new SearchView($this->TypeID,$this->Keyword,$this->ChannelType,$this->SearchType,0,$this->cacheid);
						$sp1->Display();
						$sp1->Close();
						exit;
	        }else{
	        	$artlist .= '';
	        }
         }
     }//Loop Line
     $this->dsql->FreeResult("al");
     return $artlist;
  }
Exemple #20
0
 /**
  *  获得一个单列的文档列表
  *
  * @access    public
  * @param     int  $limitstart  限制开始  
  * @param     int  $row  行数 
  * @param     int  $col  列数
  * @param     int  $titlelen  标题长度
  * @param     int  $infolen  描述长度
  * @param     int  $imgwidth  图片宽度
  * @param     int  $imgheight  图片高度
  * @param     string  $listtype  列表类型
  * @param     string  $orderby  排列顺序
  * @param     string  $innertext  底层模板
  * @param     string  $tablewidth  表格宽度
  * @param     string  $ismake  是否编译
  * @param     string  $orderWay  排序方式
  * @return    string
  */
 function GetArcList($limitstart = 0, $row = 10, $col = 1, $titlelen = 30, $infolen = 250, $imgwidth = 120, $imgheight = 90, $listtype = "all", $orderby = "default", $innertext = "", $tablewidth = "100", $ismake = 1, $orderWay = 'desc')
 {
     $getrow = $row == '' ? 10 : $row;
     if ($limitstart == '') {
         $limitstart = 0;
     }
     if ($titlelen == '') {
         $titlelen = 100;
     }
     if ($infolen == '') {
         $infolen = 250;
     }
     if ($imgwidth == '') {
         $imgwidth = 120;
     }
     if ($imgheight == '') {
         $imgheight = 120;
     }
     if ($listtype == '') {
         $listtype = 'all';
     }
     $orderby = $orderby == '' ? 'default' : strtolower($orderby);
     if ($orderWay == '') {
         $orderWay = 'desc';
     }
     $tablewidth = str_replace("%", "", $tablewidth);
     if ($tablewidth == '') {
         $tablewidth = 100;
     }
     if ($col == '') {
         $col = 1;
     }
     $colWidth = ceil(100 / $col);
     $tablewidth = $tablewidth . "%";
     $colWidth = $colWidth . "%";
     $innertext = trim($innertext);
     if ($innertext == '') {
         $innertext = GetSysTemplets("list_fulllist.htm");
     }
     $idlists = $ordersql = '';
     $this->dsql->SetQuery("SELECT aid FROM `#@__taglist` WHERE tid = '{$this->TagInfos['id']}' AND arcrank>-1 LIMIT {$limitstart},{$getrow}");
     $this->dsql->Execute();
     while ($row = $this->dsql->GetArray()) {
         $idlists .= $idlists == '' ? $row['aid'] : ',' . $row['aid'];
     }
     if ($idlists == '') {
         return '';
     }
     //按不同情况设定SQL条件
     $orwhere = " se.id IN({$idlists}) ";
     //排序方式
     if ($orderby == "sortrank") {
         $ordersql = "  ORDER BY se.sortrank {$orderWay}";
     } else {
         $ordersql = " ORDER BY se.id {$orderWay}";
     }
     $query = "SELECT se.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\n            FROM `#@__archives` se LEFT JOIN `#@__arctype` tp ON se.typeid=tp.id WHERE {$orwhere} {$ordersql} ";
     $this->dsql->SetQuery($query);
     $this->dsql->Execute('al');
     $row = $this->PageSize / $col;
     $artlist = '';
     $this->dtp2->LoadSource($innertext);
     $GLOBALS['autoindex'] = 0;
     for ($i = 0; $i < $row; $i++) {
         if ($col > 1) {
             $artlist .= "<div>\r\n";
         }
         for ($j = 0; $j < $col; $j++) {
             if ($row = $this->dsql->GetArray("al")) {
                 $GLOBALS['autoindex']++;
                 $ids[$row['id']] = $row['id'];
                 //处理一些特殊字段
                 $row['infos'] = cn_substr($row['description'], $infolen);
                 $row['id'] = $row['id'];
                 $row['arcurl'] = GetFileUrl($row['id'], $row['typeid'], $row['senddate'], $row['title'], $row['ismake'], $row['arcrank'], $row['namerule'], $row['typedir'], $row['money'], $row['filename'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                 $row['typeurl'] = GetTypeUrl($row['typeid'], MfTypedir($row['typedir']), $row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                 if ($row['litpic'] == '-' || $row['litpic'] == '') {
                     $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
                 }
                 if (!preg_match("/^http:\\/\\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
                     $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
                 }
                 $row['picname'] = $row['litpic'];
                 $row['stime'] = GetDateMK($row['pubdate']);
                 $row['typelink'] = "<a href='" . $row['typeurl'] . "'>" . $row['typename'] . "</a>";
                 $row['image'] = "<img src='" . $row['picname'] . "' border='0' width='{$imgwidth}' height='{$imgheight}' alt='" . preg_replace("/['><]/", "", $row['title']) . "'>";
                 $row['imglink'] = "<a href='" . $row['filename'] . "'>" . $row['image'] . "</a>";
                 $row['fulltitle'] = $row['title'];
                 $row['title'] = cn_substr($row['title'], $titlelen);
                 if ($row['color'] != '') {
                     $row['title'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
                 }
                 if (preg_match('/c/', $row['flag'])) {
                     $row['title'] = "<b>" . $row['title'] . "</b>";
                 }
                 $row['textlink'] = "<a href='" . $row['filename'] . "'>" . $row['title'] . "</a>";
                 $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                 $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                 $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                 if (is_array($this->dtp2->CTags)) {
                     foreach ($this->dtp2->CTags as $k => $ctag) {
                         if ($ctag->GetName() == 'array') {
                             //传递整个数组,在runphp模式中有特殊作用
                             $this->dtp2->Assign($k, $row);
                         } else {
                             if (isset($row[$ctag->GetName()])) {
                                 $this->dtp2->Assign($k, $row[$ctag->GetName()]);
                             } else {
                                 $this->dtp2->Assign($k, '');
                             }
                         }
                     }
                 }
                 $artlist .= $this->dtp2->GetResult();
             }
             //if hasRow
         }
         //Loop Col
         if ($col > 1) {
             $i += $col - 1;
             $artlist .= "    </div>\r\n";
         }
     }
     //Loop Line
     $this->dsql->FreeResult('al');
     return $artlist;
 }
 /**
  *  获得文档列表
  *
  * @access    public
  * @param     int  $limitstart  限制开始  
  * @param     int  $row  行数 
  * @param     int  $col  列数
  * @param     int  $titlelen  标题长度
  * @param     int  $infolen  描述长度
  * @param     int  $imgwidth  图片宽度
  * @param     int  $imgheight  图片高度
  * @param     string  $achanneltype  列表类型
  * @param     string  $orderby  排列顺序
  * @param     string  $innertext  底层模板
  * @param     string  $tablewidth  表格宽度
  * @return    string
  */
 function GetArcList($limitstart = 0, $row = 10, $col = 1, $titlelen = 30, $infolen = 250, $imgwidth = 120, $imgheight = 90, $achanneltype = "all", $orderby = "default", $innertext = "", $tablewidth = "100")
 {
     global $cfg_sphinx_article;
     $typeid = $this->TypeID;
     if ($row == '') {
         $row = 10;
     }
     if ($limitstart == '') {
         $limitstart = 0;
     }
     if ($titlelen == '') {
         $titlelen = 30;
     }
     if ($infolen == '') {
         $infolen = 250;
     }
     if ($imgwidth == '') {
         $imgwidth = 120;
     }
     if ($imgheight = '') {
         $imgheight = 120;
     }
     if ($achanneltype == '') {
         $achanneltype = '0';
     }
     $orderby = $orderby == '' ? 'default' : strtolower($orderby);
     $tablewidth = str_replace("%", "", $tablewidth);
     if ($tablewidth == '') {
         $tablewidth = 100;
     }
     if ($col == '') {
         $col = 1;
     }
     $colWidth = ceil(100 / $col);
     $tablewidth = $tablewidth . "%";
     $colWidth = $colWidth . "%";
     $innertext = trim($innertext);
     if ($innertext == '') {
         $innertext = GetSysTemplets("search_list.htm");
     }
     if ($cfg_sphinx_article == 'Y') {
         $ordersql = '';
         if ($this->ChannelType < 0 || $this->ChannelTypeid < 0) {
             if ($orderby == "id") {
                 $ordersql = "@id desc";
             } else {
                 $ordersql = "@senddate desc";
             }
         } else {
             if ($orderby == "senddate") {
                 $ordersql = "@senddate desc";
             } else {
                 if ($orderby == "pubdate") {
                     $ordersql = "@pubdate desc";
                 } else {
                     if ($orderby == "id") {
                         $ordersql = "@id desc";
                     } else {
                         $ordersql = "@sortrank desc";
                     }
                 }
             }
         }
         $this->sphinx->SetLimits($limitstart, (int) $row, $row > 1000 ? $row : 1000);
         $res = array();
         $res = AutoCharset($this->sphinx->Query($this->Keywords, 'mysql, delta'), 'utf-8', 'gbk');
         foreach ($res['words'] as $k => $v) {
             $this->Keywords .= " {$k}";
         }
         foreach ($res['matches'] as $_v) {
             $aids[] = $_v['id'];
         }
         $aids = @implode(',', $aids);
         //搜索
         $query = "SELECT arc.*,act.typedir,act.typename,act.isdefault,act.defaultname,act.namerule,\n            act.namerule2,act.ispart,act.moresite,act.siteurl,act.sitepath\n            FROM `#@__archives` arc LEFT JOIN `#@__arctype` act ON arc.typeid=act.id\n            WHERE arc.id IN ({$aids})";
     } else {
         //排序方式
         $ordersql = '';
         if ($this->ChannelType < 0 || $this->ChannelTypeid < 0) {
             if ($orderby == "id") {
                 $ordersql = "ORDER BY arc.aid desc";
             } else {
                 $ordersql = "ORDER BY arc.senddate desc";
             }
         } else {
             if ($orderby == "senddate") {
                 $ordersql = " ORDER BY arc.senddate desc";
             } else {
                 if ($orderby == "pubdate") {
                     $ordersql = " ORDER BY arc.pubdate desc";
                 } else {
                     if ($orderby == "id") {
                         $ordersql = "  ORDER BY arc.id desc";
                     } else {
                         $ordersql = " ORDER BY arc.sortrank desc";
                     }
                 }
             }
         }
         //搜索
         $query = "SELECT arc.*,act.typedir,act.typename,act.isdefault,act.defaultname,act.namerule,\n            act.namerule2,act.ispart,act.moresite,act.siteurl,act.sitepath\n            FROM `{$this->AddTable}` arc LEFT JOIN `#@__arctype` act ON arc.typeid=act.id\n            WHERE {$this->AddSql} {$ordersql} LIMIT {$limitstart},{$row}";
     }
     $this->dsql->SetQuery($query);
     $this->dsql->Execute("al");
     $artlist = "";
     if ($col > 1) {
         $artlist = "<table width='{$tablewidth}' border='0' cellspacing='0' cellpadding='0'>\r\n";
     }
     $this->dtp2->LoadSource($innertext);
     for ($i = 0; $i < $row; $i++) {
         if ($col > 1) {
             $artlist .= "<tr>\r\n";
         }
         for ($j = 0; $j < $col; $j++) {
             if ($col > 1) {
                 $artlist .= "<td width='{$colWidth}'>\r\n";
             }
             if ($row = $this->dsql->GetArray("al")) {
                 if ($this->ChannelType < 0 || $this->ChannelTypeid < 0) {
                     $row["id"] = $row["aid"];
                     $row["ismake"] = empty($row["ismake"]) ? "" : $row["ismake"];
                     $row["filename"] = empty($row["filename"]) ? "" : $row["filename"];
                     $row["money"] = empty($row["money"]) ? "" : $row["money"];
                     $row["description"] = empty($row["description "]) ? "" : $row["description"];
                     $row["pubdate"] = empty($row["pubdate  "]) ? $row["senddate"] : $row["pubdate"];
                 }
                 //处理一些特殊字段
                 $row["arcurl"] = GetFileUrl($row["id"], $row["typeid"], $row["senddate"], $row["title"], $row["ismake"], $row["arcrank"], $row["namerule"], $row["typedir"], $row["money"], $row['filename'], $row["moresite"], $row["siteurl"], $row["sitepath"]);
                 $row["description"] = $this->GetRedKeyWord(cn_substr($row["description"], $infolen));
                 $row["title"] = $this->GetRedKeyWord(cn_substr($row["title"], $titlelen));
                 $row["id"] = $row["id"];
                 if ($row['litpic'] == '-' || $row['litpic'] == '') {
                     $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
                 }
                 if (!preg_match("/^http:\\/\\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
                     $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
                 }
                 $row['picname'] = $row['litpic'];
                 $row["typeurl"] = GetTypeUrl($row["typeid"], $row["typedir"], $row["isdefault"], $row["defaultname"], $row["ispart"], $row["namerule2"], $row["moresite"], $row["siteurl"], $row["sitepath"]);
                 $row["info"] = $row["description"];
                 $row["filename"] = $row["arcurl"];
                 $row["stime"] = GetDateMK($row["pubdate"]);
                 $row["textlink"] = "<a href='" . $row["filename"] . "'>" . $row["title"] . "</a>";
                 $row["typelink"] = "[<a href='" . $row["typeurl"] . "'>" . $row["typename"] . "</a>]";
                 $row["imglink"] = "<a href='" . $row["filename"] . "'><img src='" . $row["picname"] . "' border='0' width='{$imgwidth}' height='{$imgheight}'></a>";
                 $row["image"] = "<img src='" . $row["picname"] . "' border='0' width='{$imgwidth}' height='{$imgheight}'>";
                 $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                 $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                 $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                 if (is_array($this->dtp2->CTags)) {
                     foreach ($this->dtp2->CTags as $k => $ctag) {
                         if ($ctag->GetName() == 'array') {
                             //传递整个数组,在runphp模式中有特殊作用
                             $this->dtp2->Assign($k, $row);
                         } else {
                             if (isset($row[$ctag->GetName()])) {
                                 $this->dtp2->Assign($k, $row[$ctag->GetName()]);
                             } else {
                                 $this->dtp2->Assign($k, '');
                             }
                         }
                     }
                 }
                 $artlist .= $this->dtp2->GetResult();
             } else {
                 $artlist .= "";
             }
             if ($col > 1) {
                 $artlist .= "</td>\r\n";
             }
         }
         //Loop Col
         if ($col > 1) {
             $artlist .= "</tr>\r\n";
         }
     }
     //Loop Line
     if ($col > 1) {
         $artlist .= "</table>\r\n";
     }
     $this->dsql->FreeResult("al");
     return $artlist;
 }
Exemple #22
0
 /**
  *  获取内容列表
  *
  * @access    public
  * @param     int  $limitstart  限制开始  
  * @param     int  $row  行数 
  * @param     int  $col  列数
  * @param     int  $titlelen  标题长度
  * @param     int  $infolen  描述长度
  * @param     int  $imgwidth  图片宽度
  * @param     int  $imgheight  图片高度
  * @param     string  $listtype  列表类型
  * @param     string  $orderby  排列顺序
  * @param     string  $innertext  底层模板
  * @param     string  $tablewidth  表格宽度
  * @return    string
  */
 function GetArcList($limitstart = 0, $row = 10, $col = 1, $titlelen = 30, $infolen = 250, $imgwidth = 120, $imgheight = 90, $listtype = "all", $orderby = "default", $innertext = "", $tablewidth = "100")
 {
     $typeid = $this->TypeID;
     if ($row == "") {
         $row = 10;
     }
     if ($limitstart == "") {
         $limitstart = 0;
     }
     if ($titlelen == "") {
         $titlelen = 30;
     }
     if ($infolen == "") {
         $infolen = 250;
     }
     if ($imgwidth == "") {
         $imgwidth = 120;
     }
     if ($imgheight == "") {
         $imgheight = 120;
     }
     if ($listtype == "") {
         $listtype = "all";
     }
     if ($orderby == "") {
         $orderby = "default";
     } else {
         $orderby = strtolower($orderby);
     }
     $tablewidth = str_replace("%", "", $tablewidth);
     if ($tablewidth == "") {
         $tablewidth = 100;
     }
     if ($col == "") {
         $col = 1;
     }
     $colWidth = ceil(100 / $col);
     $tablewidth = $tablewidth . "%";
     $colWidth = $colWidth . "%";
     $innertext = trim($innertext);
     if ($innertext == "") {
         $innertext = GetSysTemplets("spec_list.htm");
     }
     //按不同情况设定SQL条件
     $orwhere = " arc.arcrank > -1 AND arc.channel = -1 ";
     if ($this->StartTime > 0) {
         $orwhere .= " AND arc.senddate>'" . $this->StartTime . "'";
     }
     //排序方式
     $ordersql = '';
     if ($orderby == 'senddate') {
         $ordersql = " ORDER BY arc.senddate desc";
     } else {
         if ($orderby == 'pubdate') {
             $ordersql = " ORDER BY arc.pubdate desc";
         } else {
             if ($orderby == 'id') {
                 $ordersql = "  ORDER BY arc.id desc";
             } else {
                 $ordersql = " ORDER BY arc.sortrank desc";
             }
         }
     }
     $query = "SELECT arc.*,tp.typedir,tp.typename,tp.isdefault,arc.money,\r\n            tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\r\n            FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\r\n            WHERE {$orwhere} {$ordersql} LIMIT {$limitstart},{$row} ";
     $this->dsql->SetQuery($query);
     $this->dsql->Execute('al');
     $artlist = '';
     if ($col > 1) {
         $artlist = "<table width='{$tablewidth}' border='0' cellspacing='0' cellpadding='0'>\r\n";
     }
     $this->dtp2->LoadSource($innertext);
     for ($i = 0; $i < $row; $i++) {
         if ($col > 1) {
             $artlist .= "<tr>\r\n";
         }
         for ($j = 0; $j < $col; $j++) {
             if ($col > 1) {
                 $artlist .= "<td width='{$colWidth}'>\r\n";
             }
             if ($row = $this->dsql->GetArray("al")) {
                 //处理一些特殊字段
                 $row["description"] = cn_substr($row["description"], $infolen);
                 $row["title"] = cn_substr($row["title"], $titlelen);
                 $row["id"] = $row["id"];
                 if ($row['litpic'] == '-' || $row['litpic'] == '') {
                     $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
                 }
                 if (!preg_match("/^http:\\/\\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
                     $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
                 }
                 $row['picname'] = $row['litpic'];
                 $row["arcurl"] = GetFileUrl($row["id"], $row["typeid"], $row["senddate"], $row["title"], $row["ismake"], $row["arcrank"], $row["namerule"], $row["typedir"], $row["money"], $row['filename'], $row["moresite"], $row["siteurl"], $row["sitepath"]);
                 $row["typeurl"] = GetTypeUrl($row["typeid"], $row["typedir"], $row["isdefault"], $row["defaultname"], $row["ispart"], $row["namerule2"], $row["moresite"], $row["siteurl"], $row["sitepath"]);
                 $row["info"] = $row["description"];
                 $row["filename"] = $row["arcurl"];
                 $row["stime"] = GetDateMK($row["pubdate"]);
                 $row["textlink"] = "<a href='" . $row["filename"] . "'>" . $row["title"] . "</a>";
                 $row["typelink"] = "[<a href='" . $row["typeurl"] . "'>" . $row["typename"] . "</a>]";
                 $row["imglink"] = "<a href='" . $row["filename"] . "'><img src='" . $row["picname"] . "' border='0' width='{$imgwidth}' height='{$imgheight}'></a>";
                 $row["image"] = "<img src='" . $row["picname"] . "' border='0' width='{$imgwidth}' height='{$imgheight}'>";
                 $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                 $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                 $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                 //编译附加表里的数据
                 foreach ($this->ChannelUnit->ChannelFields as $k => $arr) {
                     if (isset($row[$k])) {
                         $row[$k] = $this->ChannelUnit->MakeField($k, $row[$k]);
                     }
                 }
                 if (is_array($this->dtp2->CTags)) {
                     foreach ($this->dtp2->CTags as $k => $ctag) {
                         if ($ctag->GetName() == 'array') {
                             //传递整个数组,在runphp模式中有特殊作用
                             $this->dtp2->Assign($k, $row);
                         } else {
                             if (isset($row[$ctag->GetName()])) {
                                 $this->dtp2->Assign($k, $row[$ctag->GetName()]);
                             } else {
                                 $this->dtp2->Assign($k, '');
                             }
                         }
                     }
                 }
                 $artlist .= $this->dtp2->GetResult();
             } else {
                 $artlist .= "";
             }
             if ($col > 1) {
                 $artlist .= "</td>\r\n";
             }
         }
         //Loop Col
         if ($col > 1) {
             $artlist .= "</tr>\r\n";
         }
     }
     //Loop Line
     if ($col > 1) {
         $artlist .= "</table>\r\n";
     }
     $this->dsql->FreeResult("al");
     return $artlist;
 }
  function GetArcList($limitstart=0,$row=10,$col=1,$titlelen=30,$infolen=250,
  $imgwidth=120,$imgheight=90,$listtype="all",$orderby="default",$innertext="",$tablewidth="100")
  {
    $typeid=$this->TypeID;
		if($row=="") $row = 10;
		if($limitstart=="") $limitstart = 0;
		if($titlelen=="") $titlelen = 30;
		if($infolen=="") $infolen = 250;
    if($imgwidth=="") $imgwidth = 120;
    if($imgheight=="") $imgheight = 120;
    if($listtype=="") $listtype = "all";
		if($orderby=="") $orderby="default";
		else $orderby=strtolower($orderby);
		$tablewidth = str_replace("%","",$tablewidth);
		if($tablewidth=="") $tablewidth=100;
		if($col=="") $col=1;
		$colWidth = ceil(100/$col); 
		$tablewidth = $tablewidth."%";
		$colWidth = $colWidth."%";
		$innertext = trim($innertext);
		if($innertext=="") $innertext = GetSysTemplets("spec_list.htm");
		//按不同情况设定SQL条件
		$orwhere = " arcs.arcrank > -1 And arcs.channel = -1 ";
		if($this->StartTime>0) $orwhere .= " And arcs.senddate>'".$this->StartTime."'";
		
		//排序方式
		$ordersql = "";
		if($orderby=="senddate") $ordersql=" order by arcs.senddate desc";
		else if($orderby=="pubdate") $ordersql=" order by arcs.pubdate desc";
    else if($orderby=="id") $ordersql="  order by arcs.ID desc";
		else $ordersql=" order by arcs.sortrank desc";
		//
		//----------------------------
		$query = "Select arcs.ID,arcs.title,arcs.typeid,arcs.ismake,
		arcs.description,arcs.pubdate,arcs.senddate,arcs.arcrank,
		arcs.click,arcs.postnum,arcs.lastpost,arcs.money,arcs.litpic,t.typedir,t.typename,t.isdefault,
		t.defaultname,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl
		from `#@__archivesspec` arcs 
		left join #@__arctype t on arcs.typeid=t.ID
		where $orwhere $ordersql limit $limitstart,$row";
		$this->dsql->SetQuery($query);
		$this->dsql->Execute("al");
    $artlist = "";
    if($col>1) $artlist = "<table width='$tablewidth' border='0' cellspacing='0' cellpadding='0'>\r\n";
    $this->dtp2->LoadSource($innertext);
    for($i=0;$i<$row;$i++)
		{
       if($col>1) $artlist .= "<tr>\r\n";
       for($j=0;$j<$col;$j++)
			 {
         if($col>1) $artlist .= "<td width='$colWidth'>\r\n";
         if($row = $this->dsql->GetArray("al"))
         {
           //处理一些特殊字段
           $row["description"] = cnw_left($row["description"],$infolen);
           $row["title"] = cnw_left($row["title"],$titlelen);
           $row["id"] =  $row["ID"];
           if($row["litpic"]=="") $row["litpic"] = $GLOBALS["cfg_plus_dir"]."/img/dfpic.gif";
           $row["picname"] = $row["litpic"];
           $row["arcurl"] = GetFileUrl($row["ID"],$row["typeid"],$row["senddate"],$row["title"],
                        $row["ismake"],$row["arcrank"],$row["namerule"],$row["typedir"],$row["money"],true,$row["siteurl"]);
           $row["typeurl"] = $this->GetListUrl($row["typeid"],$row["typedir"],$row["isdefault"],$row["defaultname"],$row["ispart"],$row["namerule2"],$row["siteurl"]);
           $row["info"] = $row["description"];
           $row["filename"] = $row["arcurl"];
           $row["stime"] = GetDateMK($row["pubdate"]);
           $row["textlink"] = "<a href='".$row["filename"]."'>".$row["title"]."</a>";
           $row["typelink"] = "[<a href='".$row["typeurl"]."'>".$row["typename"]."</a>]"; 
           $row["imglink"] = "<a href='".$row["filename"]."'><img src='".$row["picname"]."' border='0' width='$imgwidth' height='$imgheight'></a>";
           $row["image"] = "<img src='".$row["picname"]."' border='0' width='$imgwidth' height='$imgheight'>";
           $row["phpurl"] = $GLOBALS["cfg_plus_dir"];
 		       $row["templeturl"] = $GLOBALS["cfg_templets_dir"];
 		       $row["memberurl"] = $GLOBALS["cfg_member_dir"];
           //编译附加表里的数据
           foreach($this->ChannelUnit->ChannelFields as $k=>$arr){
 		  	      if(isset($row[$k])) $row[$k] = $this->ChannelUnit->MakeField($k,$row[$k]);
 		  	   }
           //---------------------------
           if(is_array($this->dtp2->CTags)){
       	     foreach($this->dtp2->CTags as $k=>$ctag){
       		 	   if(isset($row[$ctag->GetName()])) $this->dtp2->Assign($k,$row[$ctag->GetName()]);
       		 	   else $this->dtp2->Assign($k,"");
       	    }
           }
           $artlist .= $this->dtp2->GetResult();
         }//if hasRow
         else{
         	 $artlist .= "";
         }
         if($col>1) $artlist .= "</td>\r\n";
       }//Loop Col
       if($col>1) $artlist .= "</tr>\r\n";
     }//Loop Line
     if($col>1) $artlist .= "</table>\r\n";
     $this->dsql->FreeResult("al");
     return $artlist;
  }
Exemple #24
0
 /**
  *  获得一个单列的文档列表
  *
  * @access    public
  * @param     int  $limitstart  限制开始  
  * @param     int  $row  行数 
  * @param     int  $col  列数
  * @param     int  $titlelen  标题长度
  * @param     int  $infolen  描述长度
  * @param     int  $imgwidth  图片宽度
  * @param     int  $imgheight  图片高度
  * @param     string  $listtype  列表类型
  * @param     string  $orderby  排列顺序
  * @param     string  $innertext  底层模板
  * @param     string  $tablewidth  表格宽度
  * @param     string  $ismake  是否编译
  * @param     string  $orderWay  排序方式
  * @return    string
  */
 function GetArcList($limitstart = 0, $row = 10, $col = 1, $titlelen = 30, $infolen = 250, $imgwidth = 120, $imgheight = 90, $listtype = "all", $orderby = "default", $innertext = "", $tablewidth = "100", $ismake = 1, $orderWay = 'desc')
 {
     global $cfg_list_son, $cfg_digg_update;
     $typeid = $this->TypeID;
     if ($row == '') {
         $row = 10;
     }
     if ($limitstart == '') {
         $limitstart = 0;
     }
     if ($titlelen == '') {
         $titlelen = 100;
     }
     if ($infolen == '') {
         $infolen = 250;
     }
     if ($imgwidth == '') {
         $imgwidth = 120;
     }
     if ($imgheight == '') {
         $imgheight = 120;
     }
     if ($listtype == '') {
         $listtype = 'all';
     }
     if ($orderWay == '') {
         $orderWay = 'desc';
     }
     if ($orderby == '') {
         $orderby = 'default';
     } else {
         $orderby = strtolower($orderby);
     }
     $tablewidth = str_replace('%', '', $tablewidth);
     if ($tablewidth == '') {
         $tablewidth = 100;
     }
     if ($col == '') {
         $col = 1;
     }
     $colWidth = ceil(100 / $col);
     $tablewidth = $tablewidth . '%';
     $colWidth = $colWidth . '%';
     $innertext = trim($innertext);
     if ($innertext == '') {
         $innertext = GetSysTemplets('list_fulllist.htm');
     }
     //排序方式
     $ordersql = '';
     if ($orderby == "senddate" || $orderby == "id") {
         $ordersql = " ORDER BY arc.id {$orderWay}";
     } else {
         if ($orderby == "hot" || $orderby == "click") {
             $ordersql = " ORDER BY arc.click {$orderWay}";
         } else {
             if ($orderby == "lastpost") {
                 $ordersql = "  ORDER BY arc.lastpost {$orderWay}";
             } else {
                 $ordersql = " ORDER BY arc.sortrank {$orderWay}";
             }
         }
     }
     //获得附加表的相关信息
     $addtable = $this->ChannelUnit->ChannelInfos['addtable'];
     if ($addtable != "") {
         $addJoin = " LEFT JOIN `{$addtable}` ON arc.id = " . $addtable . '.aid ';
         $addField = '';
         $fields = explode(',', $this->ChannelUnit->ChannelInfos['listfields']);
         foreach ($fields as $k => $v) {
             $nfields[$v] = $k;
         }
         if (is_array($this->ChannelUnit->ChannelFields) && !empty($this->ChannelUnit->ChannelFields)) {
             foreach ($this->ChannelUnit->ChannelFields as $k => $arr) {
                 if (isset($nfields[$k])) {
                     if (!empty($arr['rename'])) {
                         $addField .= ',' . $addtable . '.' . $k . ' as ' . $arr['rename'];
                     } else {
                         $addField .= ',' . $addtable . '.' . $k;
                     }
                 }
             }
         }
     } else {
         $addField = '';
         $addJoin = '';
     }
     //如果不用默认的sortrank或id排序,使用联合查询(数据量大时非常缓慢)
     if (preg_match('/hot|click|lastpost/', $orderby)) {
         $query = "SELECT arc.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,\n           tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\n           {$addField}\n           FROM `#@__archives` arc\n           LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\n           {$addJoin}\n           WHERE {$this->addSql} {$ordersql} LIMIT {$limitstart},{$row}";
     } else {
         $t1 = ExecTime();
         $ids = array();
         $query = "SELECT id FROM `#@__arctiny` arc WHERE {$this->addSql} {$ordersql} LIMIT {$limitstart},{$row} ";
         $this->dsql->SetQuery($query);
         $this->dsql->Execute();
         while ($arr = $this->dsql->GetArray()) {
             $ids[] = $arr['id'];
         }
         $idstr = join(',', $ids);
         if ($idstr == '') {
             return '';
         } else {
             $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,\n                       tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\n                       {$addField}\n                       FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\n                       {$addJoin}\n                       WHERE arc.id in({$idstr}) {$ordersql} ";
         }
         $t2 = ExecTime();
         //echo $t2-$t1;
     }
     $this->dsql->SetQuery($query);
     $this->dsql->Execute('al');
     $t2 = ExecTime();
     //echo $t2-$t1;
     $artlist = '';
     $this->dtp2->LoadSource($innertext);
     $GLOBALS['autoindex'] = 0;
     for ($i = 0; $i < $row; $i++) {
         if ($col > 1) {
             $artlist .= "<div>\r\n";
         }
         for ($j = 0; $j < $col; $j++) {
             if ($row = $this->dsql->GetArray("al")) {
                 $GLOBALS['autoindex']++;
                 $ids[$row['id']] = $row['id'];
                 //处理一些特殊字段
                 $row['infos'] = cn_substr($row['description'], $infolen);
                 $row['id'] = $row['id'];
                 if ($cfg_digg_update > 0) {
                     $prefix = 'diggCache';
                     $key = 'aid-' . $row['id'];
                     $cacherow = GetCache($prefix, $key);
                     $row['goodpost'] = $cacherow['goodpost'];
                     $row['badpost'] = $cacherow['badpost'];
                     $row['scores'] = $cacherow['scores'];
                 }
                 if ($row['corank'] > 0 && $row['arcrank'] == 0) {
                     $row['arcrank'] = $row['corank'];
                 }
                 $row['filename'] = $row['arcurl'] = GetFileUrl($row['id'], $row['typeid'], $row['senddate'], $row['title'], $row['ismake'], $row['arcrank'], $row['namerule'], $row['typedir'], $row['money'], $row['filename'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                 $row['typeurl'] = GetTypeUrl($row['typeid'], MfTypedir($row['typedir']), $row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                 if ($row['litpic'] == '-' || $row['litpic'] == '') {
                     $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
                 }
                 if (!preg_match("/^http:\\/\\//i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
                     $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
                 }
                 $row['picname'] = $row['litpic'];
                 $row['stime'] = GetDateMK($row['pubdate']);
                 $row['typelink'] = "<a href='" . $row['typeurl'] . "'>" . $row['typename'] . "</a>";
                 $row['image'] = "<img src='" . $row['picname'] . "' border='0' width='{$imgwidth}' height='{$imgheight}' alt='" . preg_replace("/['><]/", "", $row['title']) . "'>";
                 $row['imglink'] = "<a href='" . $row['filename'] . "'>" . $row['image'] . "</a>";
                 $row['fulltitle'] = $row['title'];
                 $row['title'] = cn_substr($row['title'], $titlelen);
                 if ($row['color'] != '') {
                     $row['title'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
                 }
                 if (preg_match('/c/', $row['flag'])) {
                     $row['title'] = "<b>" . $row['title'] . "</b>";
                 }
                 $row['textlink'] = "<a href='" . $row['filename'] . "'>" . $row['title'] . "</a>";
                 $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                 $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                 $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                 //编译附加表里的数据
                 foreach ($row as $k => $v) {
                     $row[strtolower($k)] = $v;
                 }
                 foreach ($this->ChannelUnit->ChannelFields as $k => $arr) {
                     if (isset($row[$k])) {
                         $row[$k] = $this->ChannelUnit->MakeField($k, $row[$k]);
                     }
                 }
                 if (is_array($this->dtp2->CTags)) {
                     foreach ($this->dtp2->CTags as $k => $ctag) {
                         if ($ctag->GetName() == 'array') {
                             //传递整个数组,在runphp模式中有特殊作用
                             $this->dtp2->Assign($k, $row);
                         } else {
                             if (isset($row[$ctag->GetName()])) {
                                 $this->dtp2->Assign($k, $row[$ctag->GetName()]);
                             } else {
                                 $this->dtp2->Assign($k, '');
                             }
                         }
                     }
                 }
                 $artlist .= $this->dtp2->GetResult();
             }
             //if hasRow
         }
         //Loop Col
         if ($col > 1) {
             $i += $col - 1;
             $artlist .= "    </div>\r\n";
         }
     }
     //Loop Line
     $t3 = ExecTime();
     //echo ($t3-$t2);
     $this->dsql->FreeResult('al');
     return $artlist;
 }
function SpGetArcList(&$dsql,$templets,$typeid=0,$row=10,$col=1,$titlelen=30,$infolen=160,
  $imgwidth=120,$imgheight=90,$listtype="all",$orderby="default",$keyword="",$innertext="",
  $tablewidth="100",$arcid=0,$idlist="",$channelid=0,$limitv="",$att="",$order="desc",
  $subday=0,$ismember=0,$maintable='#@__archives',$ctag='',$isUpCache=true)
  {
		global $PubFields,$cfg_keyword_like,$cfg_arc_all,$cfg_needsontype,$cfg_maxsearch,$cfg_al_cachetime;

		$row = AttDef($row,10);
		$titlelen = AttDef($titlelen,30);
		$infolen = AttDef($infolen,160);
		$imgwidth = AttDef($imgwidth,120);
		$imgheight = AttDef($imgheight,120);
		$listtype = AttDef($listtype,"all");
    $arcid = AttDef($arcid,0);
    //$att = AttDef($att,0);
    $channelid = AttDef($channelid,0);
    $ismember = AttDef($ismember,0);
    $orderby = AttDef($orderby,"default");
    $orderWay = AttDef($order,"desc");
    $maintable = AttDef($maintable,"#@__archives");
    $subday = AttDef($subday,0);
    $line = $row;
		$orderby=strtolower($orderby);
		$tablewidth = str_replace("%","",$tablewidth);
		if($tablewidth=="") $tablewidth=100;
		if($col=="") $col = 1;
		$colWidth = ceil(100/$col);
		$tablewidth = $tablewidth."%";
		$colWidth = $colWidth."%";
		$keyword = trim($keyword);
		$innertext = trim($innertext);
		if($innertext=="") $innertext = GetSysTemplets("part_arclist.htm");
		if(!empty($idlist) && ereg("[^0-9,]",$idlist)) $idlist = '';
		
		$mintime = time() - ($cfg_al_cachetime * 3600);

		$orwhere = '';

  //对于文章列表等地方的调用,限定为最新文档
  $idlist = ereg_replace("[^,0-9]","",$idlist);
	if($idlist!='') $orwhere .= " arc.ID in ($idlist) And ";
    

  $t1 = ExecTime();
	
	//按不同情况设定SQL条件 排序方式
	$orwhere .= " arc.arcrank > -1 ";

  $addField = "";
  $addJoin = "";
  $channelinfos = '';

  //获取主表
  if(eregi('spec',$listtype)) $channelid = -1;
  if(!empty($typeid)) $reids = explode(',',$typeid);
  if(!empty($channelid))
  {
  	$channelinfos = $dsql->GetOne("Select ID,maintable,addtable,listadd From `#@__channeltype` where ID='$channelid' ");
  	$maintable = $channelinfos['maintable'];
  }else if(!empty($typeid))
  {
		$channelinfos = $dsql->GetOne("select c.ID,c.maintable,c.addtable,c.listadd from `#@__arctype` a left join #@__channeltype c on c.ID=a.channeltype where a.ID='".$reids[0]."' ");
		if(is_array($channelinfos)) {			
			$maintable = $channelinfos['maintable'];
			$channelid = $channelinfos['ID'];
		}
  }

  if(trim($maintable)=='') $maintable = "#@__archives";

   //时间限制(用于调用最近热门文章、热门评论之类)
		if($subday>0){
			 $limitvday = time() - ($subday * 24 * 3600);
			 $orwhere .= " And arc.senddate > $limitvday ";
		}
		//文档的自定义属性
		if($att!="") $orwhere .= " And arc.arcatt='$att' ";
		//文档的频道模型
		if(!empty($channelid) && !eregi("spec",$listtype)) $orwhere .= " And arc.channel = '$channelid' ";
		//echo $orwhere.$channelid ;
		//是否为推荐文档
		if(eregi("commend",$listtype)) $orwhere .= " And arc.iscommend > 10  ";
		//是否为带缩略图图片文档
		if(eregi("image",$listtype)) $orwhere .= " And arc.litpic <> ''  ";
		//是否为专题文档
		if(eregi("spec",$listtype) || $channelid==-1) $orwhere .= " And arc.channel = -1  ";
    //是否指定相近ID
		if($arcid!=0) $orwhere .= " And arc.ID<>'$arcid' ";

		//是否为会员文档
		if($ismember==1) $orwhere .= " And arc.memberid>0  ";

		if($cfg_keyword_like=='N'){ $keyword=""; }

	//类别ID的条件,如果用 "," 分开,可以指定特定类目
	//------------------------------
	if(!empty($typeid))
	{
		  $ridnum = count($reids);
		  if($ridnum>1)
		  {
			  $sonids = '';
		    for($i=0;$i<$ridnum;$i++){
				  $sonids .= ($sonids=='' ? TypeGetSunID($reids[$i],$dsql,'arc',0,true) : ','.TypeGetSunID($reids[$i],$dsql,'arc',0,true));
		    }
		   $orwhere .= " And arc.typeid in ($sonids)  ";
		  }else{
			  $sonids = TypeGetSunID($typeid,$dsql,'arc',0,true);
			  $orwhere .= " And arc.typeid in ($sonids) ";
		  }
		  unset($reids);
	}

	//关键字条件
  if($keyword!='')
  {
		  $keywords = explode(",",$keyword);
		  $ridnum = count($keywords);
		  $rstr = trim($keywords[0]);
		  if($ridnum>4) $ridnum = 4;
		  for($i=0;$i<$ridnum;$i++){
			  $keywords[$i] = trim($keywords[$i]);
			  if($keywords[$i]!="") $rstr .= "|".$keywords[$i];
			}
		  if($rstr!="") $orwhere .= " And CONCAT(arc.title,arc.keywords) REGEXP '$rstr' ";
		  unset($keywords);
	}

	//获得附加表的相关信息
	//-----------------------------
	if(is_array($channelinfos))
	{
			$channelinfos['listadd'] = trim($channelinfos['listadd']);
			if($cfg_arc_all=='Y' && is_array($channelinfos) && $channelinfos['listadd']!='')
			{
				  $addField = '';
				  $fields = explode(',',$channelinfos['listadd']);
				  foreach($fields as $v) $addField .= ",addt.{$v}";
				  if($addField!='') $addJoin = " left join `{$channelinfos['addtable']}` addt on addt.aid = arc.ID ";
			}
	}


	//文档排序的方式
		$ordersql = "";
		if($orderby=='hot'||$orderby=='click') $ordersql = " order by arc.click $orderWay";
		else if($orderby=='pubdate') $ordersql = " order by arc.pubdate $orderWay";
		else if($orderby=='sortrank') $ordersql = " order by arc.sortrank $orderWay";
    else if($orderby=='id') $ordersql = "  order by arc.ID $orderWay";
    else if($orderby=='near') $ordersql = " order by ABS(arc.ID - ".$arcid.")";
    else if($orderby=='lastpost') $ordersql = "  order by arc.lastpost $orderWay";
    else if($orderby=='postnum') $ordersql = "  order by arc.postnum $orderWay";
    else if($orderby=='digg') $ordersql = "  order by arc.digg $orderWay";
    else if($orderby=='diggtime') $ordersql = "  order by arc.diggtime $orderWay";
    else if($orderby=='rand') $ordersql = "  order by rand()";
		else $ordersql=" order by arc.ID $orderWay";

	  if(!empty($limitv)) $limitvsql = " limit $limitv ";
	  else $limitvsql = " limit 0,$line ";
		//////////////
		$query = "Select arc.ID,arc.title,arc.iscommend,arc.color,arc.typeid,arc.channel,
		    arc.ismake,arc.description,arc.pubdate,arc.senddate,arc.arcrank,arc.click,arc.digg,arc.diggtime,
		    arc.money,arc.litpic,arc.writer,arc.shorttitle,arc.memberid,arc.postnum,arc.lastpost,
		    tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,
		    tp.namerule2,tp.ispart,tp.moresite,tp.siteurl{$addField}
		    from `$maintable` arc left join `#@__arctype` tp on arc.typeid=tp.ID $addJoin
		    where $orwhere $ordersql $limitvsql
		";
		
		//echo $query;
		//exit();
		
		$md5hash = md5($query);
		
		$ids = '';
		$needup = false;
		if($idlist=='' && $isUpCache && $cfg_al_cachetime>0)
		{
		  	$ids = SpGetArclistDateCache($dsql,$md5hash);
		  	if($ids=='-1') $needup = true;
		  	else if($ids!='')
		  	{
		  		  $query = "Select arc.ID,arc.title,arc.iscommend,arc.color,arc.typeid,arc.channel,
		          arc.ismake,arc.description,arc.pubdate,arc.senddate,arc.arcrank,arc.click,arc.digg,arc.diggtime,
		          arc.money,arc.litpic,arc.writer,arc.shorttitle,arc.memberid,arc.postnum,arc.lastpost,
		          tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,
		          tp.namerule2,tp.ispart,tp.moresite,tp.siteurl{$addField}
		          from `$maintable` arc left join `#@__arctype` tp on arc.typeid=tp.ID $addJoin
		         where arc.ID in($ids) $ordersql ";
		  	}else
		  	{
		  		return '';
		  	}
		}
		
    $artlist = "";
    $dsql->SetQuery($query);
		$dsql->Execute("al");
    
    $dtp2 = new DedeTagParse();
    $dtp2->SetNameSpace("field","[","]");
    $dtp2->LoadString($innertext);
    
    $nids = array();
    
    if($col>1) $artlist = "<table width='$tablewidth' border='0' cellspacing='0' cellpadding='0'>\r\n";
    $GLOBALS['autoindex'] = 0;
    for($i=0;$i<$line;$i++)
		{
       if($col>1) $artlist .= "<tr>\r\n";
       for($j=0;$j<$col;$j++)
			 {
         if($col>1) $artlist .= "	<td width='$colWidth'>\r\n";
         if($row = $dsql->GetArray("al",MYSQL_ASSOC))
         {
           //处理一些特殊字段
           $row['description'] = cn_substr($row['description'],$infolen);
           $nids[] = $row['id'] =  $row['ID'];

			$row['arcurl'] = GetFileUrl($row['id'],$row['typeid'],$row['senddate'],
		                $row['title'],$row['ismake'],$row['arcrank'],$row['namerule'],
		                $row['typedir'],$row['money'],true,$row['siteurl']);
			$row['typeurl'] = GetTypeUrl($row['typeid'],MfTypedir($row['typedir']),$row['isdefault'],$row['defaultname'],$row['ispart'],$row['namerule2'],$row['siteurl']);

			
           

           if($row['litpic']=="") $row['litpic'] = $PubFields['templeturl']."/img/default.gif";
           $row['picname'] = $row['litpic'];
           if($GLOBALS['cfg_multi_site']=='Y'){
           	 if($row['siteurl']=="") $row['siteurl'] = $GLOBALS['cfg_mainsite'];
           	 if(!eregi("^http://",$row['picname'])){
           	 	  $row['litpic'] = $row['siteurl'].$row['litpic'];
           	 	  $row['picname'] = $row['litpic'];
           	 }
           }
           $row['info'] = $row['description'];
           $row['filename'] = $row['arcurl'];
           $row['stime'] = GetDateMK($row['pubdate']);
           $row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
           $row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".ereg_replace("['><]","",$row['title'])."'>";
           $row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";
           $row['title'] = cn_substr($row['title'],$titlelen);
           $row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
           if($row['color']!="") $row['title'] = "<font color='".$row['color']."'>".$row['title']."</font>";
           if($row['iscommend']==5||$row['iscommend']==16) $row['title'] = "<b>".$row['title']."</b>";
           $row['phpurl'] = $PubFields['phpurl'];
 		       $row['templeturl'] = $PubFields['templeturl'];

       	   foreach($dtp2->CTags as $k=>$ctag){ @$dtp2->Assign($k,$row[$ctag->GetName()]); }
       	   $GLOBALS['autoindex']++;

           $artlist .= $dtp2->GetResult();
         }//if hasRow
         else{
         	 $artlist .= '';
         }
         if($col>1) $artlist .= "	</td>\r\n";
       }//Loop Col
       if($col>1) $i += $col - 1;
       if($col>1) $artlist .= "	</tr>\r\n";
     }//Loop Line
     if($col>1) $artlist .= "	</table>\r\n";
     $dsql->FreeResult("al");

     if($needup)
     {
     	  $ids = join(',',$nids);
     	  $inquery = "INSERT INTO `#@__arccache`(`md5hash`,`uptime`,`cachedata`) VALUES ('".$md5hash."', '".time()."', '$ids'); ";
	      $dsql->ExecuteNoneQuery("Delete From `#@__arccache` where md5hash='".$md5hash."' or uptime < $mintime ");
	      $dsql->ExecuteNoneQuery($inquery);
     }
     
     
     $t2 = ExecTime();
     //echo ($t2-$t1).$query;
     //$debug = trim($artlist).'<li>'.($t2-$t1)."  $query</li>";
     
     return trim($artlist);
}