function __construct($fid)
 {
     global $dsql;
     $this->FreeID = $fid;
     $this->TypeLink = new TypeLink(0);
     $this->dsql = $dsql;
     $this->maintable = '#@__archives';
     $this->TempletsFile = '';
     $this->FLInfos = $this->dsql->GetOne("Select * From `#@__freelist` where aid='{$fid}' ");
     $liststr = $this->FLInfos['listtag'];
     $this->FLInfos['maxpage'] = empty($this->FLInfos['maxpage']) ? 100 : $this->FLInfos['maxpage'];
     //载入数据里保存的列表属性信息
     $ndtp = new DedeTagParse();
     $ndtp->SetNameSpace("dede", "{", "}");
     $ndtp->LoadString($liststr);
     $this->ListObj = $ndtp->GetTag('list');
     $this->PageSize = $this->ListObj->GetAtt('pagesize');
     if (empty($this->PageSize)) {
         $this->PageSize = 30;
     }
     $channelid = $this->ListObj->GetAtt('channel');
     /*
     if(empty($channelid))
     {
     	showmsg('必须指定频道','-1');exit();
     }
     else
     {
     	$channelid = intval($channelid);
     	$channelinfo = $this->dsql->getone("select maintable from #@__channeltype where id='$channelid'");
     	$this->maintable = $channelinfo['maintable'];
     }
     */
     $channelid = intval($channelid);
     $this->maintable = '#@__archives';
     //全局模板解析器
     $this->dtp = new DedeTagParse();
     $this->dtp->SetNameSpace("dede", "{", "}");
     $this->dtp->SetRefObj($this);
     //设置一些全局参数的值
     $this->Fields['aid'] = $this->FLInfos['aid'];
     $this->Fields['title'] = $this->FLInfos['title'];
     $this->Fields['position'] = $this->FLInfos['title'];
     $this->Fields['keywords'] = $this->FLInfos['keywords'];
     $this->Fields['description'] = $this->FLInfos['description'];
     $channelid = $this->ListObj->GetAtt('channel');
     if (!empty($channelid)) {
         $this->Fields['channeltype'] = $channelid;
         $this->ChannelUnit = new ChannelUnit($channelid);
     } else {
         $this->Fields['channeltype'] = 0;
     }
     foreach ($GLOBALS['PubFields'] as $k => $v) {
         $this->Fields[$k] = $v;
     }
     $this->PartView = new PartView();
     $this->CountRecord();
 }
Beispiel #2
0
function lib_flinktype(&$ctag, &$refObj)
{
    global $dsql;
    $attlist = "row|24,titlelen|24";
    FillAttsDefault($ctag->CAttribute->Items, $attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $totalrow = $row;
    $revalue = '';
    $equery = "SELECT * FROM #@__flinktype order by id asc limit 0,{$totalrow}";
    if (trim($ctag->GetInnerText()) == '') {
        $innertext = "<li>[field:typename /]</li>";
    } else {
        $innertext = $ctag->GetInnerText();
    }
    if (!isset($type)) {
        $type = '';
    }
    $dtp = new DedeTagParse();
    $dtp->SetNameSpace("dede", "{", "}");
    $dtp->LoadString($innertext);
    $dsql->SetQuery($equery);
    $dsql->Execute();
    $rs = '';
    $row = array();
    while ($dbrow = $dsql->GetObject()) {
        $row[] = $dbrow;
    }
    $dedecms = false;
    $dedecms->id = 999;
    $dedecms->typename = '织梦链';
    if ($type == 'dedecms') {
        $row[] = $dedecms;
    }
    foreach ($row as $key => $value) {
        if (is_array($dtp->CTags)) {
            $GLOBALS['envs']['flinkid'] = $value->id;
            foreach ($dtp->CTags as $tagid => $ctag) {
                $tagname = $ctag->GetName();
                if ($tagname == "flink") {
                    $dtp->Assign($tagid, lib_flink($ctag, $refObj));
                }
            }
        }
        $rs = $dtp->GetResult();
        $rs = preg_replace("/\\[field:id([\\/\\s]{0,})\\]/isU", $value->id, $rs);
        $rs = preg_replace("/\\[field:typename([\\/\\s]{0,})\\]/isU", $value->typename, $rs);
        $revalue .= $rs;
    }
    return $revalue;
}
Beispiel #3
0
function lib_booklist(&$ctag, &$refObj, $getcontent = 0)
{
    global $dsql, $envs, $cfg_dbprefix, $cfg_cmsurl;
    //属性处理
    $attlist = "row|12,booktype|-1,titlelen|30,orderby|lastpost,author|,keyword|";
    FillAttsDefault($ctag->CAttribute->Items, $attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    if (!$dsql->IsTable("{$cfg_dbprefix}story_books")) {
        return '没安装连载模块';
    }
    $addquery = '';
    if (empty($innertext)) {
        if ($getcontent == 0) {
            $innertext = GetSysTemplets('booklist.htm');
        } else {
            $innertext = GetSysTemplets('bookcontentlist.htm');
        }
    }
    //图书类型
    if ($booktype != -1) {
        $addquery .= " And b.booktype='{$booktype}' ";
    }
    //推荐
    if ($orderby == 'commend') {
        $addquery .= " And b.iscommend=1 ";
        $orderby = 'lastpost';
    }
    //作者条件
    if (!empty($author)) {
        $addquery .= " And b.author like '{$author}' ";
    }
    //关键字条件
    if (!empty($keyword)) {
        $keywords = explode(',', $keyword);
        $keywords = array_unique($keywords);
        if (count($keywords) > 0) {
            $addquery .= " And (";
        }
        foreach ($keywords as $v) {
            $addquery .= " CONCAT(b.author,b.bookname,b.keywords) like '%{$v}%' OR";
        }
        $addquery = ereg_replace(" OR\$", "", $addquery);
        $addquery .= ")";
    }
    $clist = '';
    $query = "Select b.id,b.catid,b.ischeck,b.booktype,b.iscommend,b.click,b.bookname,b.lastpost,\r\n \t\tb.author,b.mid,b.litpic,b.pubdate,b.weekcc,b.monthcc,b.description,c.classname,c.classname as typename,c.booktype as catalogtype\r\n \t\tFrom `#@__story_books` b left join `#@__story_catalog` c on c.id=b.catid\r\n \t\twhere b.postnum>0 And b.ischeck>0 {$addquery} order by b.{$orderby} desc limit 0, {$row}";
    $dsql->SetQuery($query);
    $dsql->Execute();
    $ndtp = new DedeTagParse();
    $ndtp->SetNameSpace('field', '[', ']');
    $GLOBALS['autoindex'] = 0;
    while ($row = $dsql->GetArray()) {
        $GLOBALS['autoindex']++;
        $row['title'] = $row['bookname'];
        $ndtp->LoadString($innertext);
        //获得图书最新的一个更新章节
        $row['contenttitle'] = '';
        $row['contentid'] = '';
        if ($getcontent == 1) {
            $nrow = $dsql->GetOne("Select id,title,chapterid From `#@__story_content` where bookid='{$row['id']}' order by id desc ");
            $row['contenttitle'] = $nrow['title'];
            $row['contentid'] = $nrow['id'];
        }
        if ($row['booktype'] == 1) {
            $row['contenturl'] = $cfg_cmspath . '/book/show-photo.php?id=' . $row['contentid'];
        } else {
            $row['contenturl'] = $cfg_cmspath . '/book/story.php?id=' . $row['contentid'];
        }
        //动态网址
        $row['dmbookurl'] = $cfg_cmspath . '/book/book.php?id=' . $row['id'];
        //静态网址
        $row['bookurl'] = $row['url'] = GetBookUrl($row['id'], $row['bookname']);
        $row['catalogurl'] = $cfg_cmspath . '/book/list.php?id=' . $row['catid'];
        $row['cataloglink'] = "<a href='{$row['catalogurl']}'>{$row['classname']}</a>";
        $row['booklink'] = "<a href='{$row['bookurl']}'>{$row['bookname']}</a>";
        $row['contentlink'] = "<a href='{$row['contenturl']}'>{$row['contenttitle']}</a>";
        $row['imglink'] = "<a href='{$row['bookurl']}'><img src='{$row['litpic']}' width='{$imgwidth}' height='{$imgheight}' border='0' /></a>";
        if ($row['ischeck'] == 2) {
            $row['ischeck'] = '已完成连载';
        } else {
            $row['ischeck'] = '连载中...';
        }
        if ($row['booktype'] == 0) {
            $row['booktypename'] = '小说';
        } else {
            $row['booktypename'] = '漫画';
        }
        if (is_array($ndtp->CTags)) {
            foreach ($ndtp->CTags as $tagid => $ctag) {
                $tagname = $ctag->GetTagName();
                if (isset($row[$tagname])) {
                    $ndtp->Assign($tagid, $row[$tagname]);
                } else {
                    $ndtp->Assign($tagid, '');
                }
            }
        }
        $clist .= $ndtp->GetResult();
    }
    return $clist;
}
Beispiel #4
0
}
$usemore = $arr['usemore'];
$notename = $arr['notename'];
$notes = array();
$dsql->FreeResult();
$dtp = new DedeTagParse();
$dtp2 = new DedeTagParse();
$dtp->LoadString($arr['listconfig'] . $arr['itemconfig']);
$channelid = $arr['channelid'];
$notes['keywordtrim'] = '';
$notes['descriptiontrim'] = '';
foreach ($dtp->CTags as $tid => $ctag) {
    if ($ctag->GetName() == 'item') {
        $f = $ctag->GetAtt('field');
        $notes[$f]['item'] = $ctag;
        $dtp2->LoadString($ctag->GetInnerText());
        $notes[$f]['trim'] = '';
        foreach ($dtp2->CTags as $ctag2) {
            if ($ctag2->GetName() == 'trim') {
                $notes[$f]['trim'] .= "{dede:trim replace=\"" . $ctag2->GetAtt('replace') . "\"}" . $ctag2->GetInnerText() . "{/dede:trim}\r\n";
            } else {
                if ($ctag2->GetName() == 'match') {
                    $notes[$f]['match'] = $ctag2->GetInnerText() . "\r\n";
                } else {
                    if ($ctag2->GetName() == 'function') {
                        $notes[$f]['function'] = $ctag2->GetInnerText() . "\r\n";
                    }
                }
            }
        }
    } else {
$row = $dsql->GetOne("Select ex.*,n.arcsource From `#@__conote` n left join `#@__co_exrule` ex on ex.aid=n.typeid where nid='$nid'");
if(!is_array($row)){
	ShowMsg('找不到导入规则,无法完成操作!','javascript:;');
	$dsql->Close();
	exit();
}
$channelid = $row['channelid'];
$etype = $row['etype'];
$arcsource = $row['arcsource'];
$senddate = time();

$typeinfos = $dsql->GetOne("Select * From `#@__arctype` where ID='$typeid'",MYSQL_ASSOC);
//分析规则,并生成临时的SQL语句
//-------------------------------------
$dtp = new DedeTagParse();
$dtp->LoadString($row['ruleset']);
$noteinfo = $dtp->GetTagByName('note');
$tablenames = explode(",",$noteinfo->GetAtt('tablename'));
$autofield = $noteinfo->GetAtt('autofield');
$synfield = $noteinfo->GetAtt('synfield');
$tablename1 = str_replace('#@__',$cfg_dbprefix,$tablenames[0]);
$tb1SqlKey = "Insert Into `$tablename1`($autofield";
$tb1SqlValue = " Values('@$autofield@'";
if(count($tablenames)>=2){
	$tablename2 = str_replace('#@__',$cfg_dbprefix,$tablenames[1]);
	$tb2SqlKey = "Insert Into `$tablename2`(";
  $tb2SqlValue = " Values(";
  if($synfield!=''){
		$tb2SqlKey .= $synfield;
		$tb2SqlValue .= "'@$synfield@'";
  }
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;
}
	   $dsql = new DedeSql(false);
	   $row = $dsql->GetOne("Select * From #@__conote where nid='$nid' ");
	   $dsql->Close();
	   $win->AddMsgItem("<textarea name='notes' style='width:100%;height:500px' rows='20'>{$row['noteinfo']}</textarea>");
	   $winform = $win->GetWindow("ok");
	   $win->Display();
     exit();
}
else
{
   	  CheckPurview('co_EditNote');
   	  require_once(dirname(__FILE__)."/../include/pub_dedetag.php");
   	  $dtp = new DedeTagParse();
   	  $dbnotes = $notes;
   	  $notes = stripslashes($notes);
      $dtp->LoadString($notes);
   	  if(!is_array($dtp->CTags)){
	      ShowMsg("该规则不合法,无法保存!","-1");
	      $dsql->Close();
	      exit();
      }
      $ctag = $dtp->GetTagByName("item");
	    $query = "
	      Update #@__conote 
	        set typeid='".$ctag->GetAtt('typeid')."',
	        gathername='".$ctag->GetAtt('name')."',
	        language='".$ctag->GetAtt('language')."',
	        lasttime=0,
	        savetime='".time()."',
	        noteinfo='".$dbnotes."'
	      where nid = $nid;
Beispiel #8
0
     }
 }
 //符合需执行条件的任务
 if ($isplay) {
     $dourl = trim($arr['dourl']);
     if (!file_exists("task/{$dourl}")) {
         echo $client == 'js' ? '' : 'notask';
         exit;
     } else {
         $getConfigStr = trim($arr['parameter']);
         $getString = '';
         if (ereg('t:', $getConfigStr)) {
             $getStrings = array();
             $dtp = new DedeTagParse();
             $dtp->SetNameSpace('t', '<', '>');
             $dtp->LoadString($getConfigStr);
             if (is_array($dtp->CTags)) {
                 foreach ($dtp->CTags as $k => $ctag) {
                     $getString .= ($getString == '' ? '' : '&') . $ctag->GetAtt('key') . '=' . urlencode($ctag->GetAtt('value'));
                 }
             }
         }
         $dsql->ExecuteNoneQuery("Update `#@__sys_task` set lastrun='" . time() . "', sta='运行' where id='{$arr['id']}' ");
         if ($getString != '') {
             $dourl .= '?' . $getString;
         }
         if ($client == 'js') {
             header("location:{$cfg_phpurl}/task/{$dourl}");
         } else {
             echo "{$cfg_phpurl}/task/{$dourl}";
         }
Beispiel #9
0
    ShowMsg("成功保存一条记录!", $backurl);
    exit;
}
$dsql->SetSql("SELECT * FROM `#@__co_htmls` WHERE aid='{$aid}'");
$dsql->Execute();
$row = $dsql->GetObject();
$isdown = $row->isdown;
$nid = $row->nid;
$url = $row->url;
$dtime = $row->dtime;
$body = $row->result;
$litpic = $row->litpic;
$fields = array();
if ($isdown == 0) {
    $co = new DedeCollection();
    $co->LoadNote($nid);
    $co->DownUrl($aid, $url, $litpic);
    $co->dsql->SetSql("SELECT * FROM `#@__co_htmls` WHERE aid='{$aid}'");
    $co->dsql->Execute();
    $row = $co->dsql->GetObject();
    $isdown = $row->isdown;
    $nid = $row->nid;
    $url = $row->url;
    $dtime = $row->dtime;
    $body = $row->result;
    $litpic = $row->litpic;
}
$dtp = new DedeTagParse();
$dtp->SetNameSpace("dede", "{", "}");
$dtp->LoadString($body);
include DedeInclude('templets/co_view.htm');
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;
}
Beispiel #11
0
 /**
  * caijixia for dedecms
  * @version        $Id: cjx.class.php 112 2013-05-28 01:22:57Z qinjinpeng $
  * @copyright Copyright (c) 2011,caijixia for dedecms,caijixia.com.
  * @license   This is NOT a freeware, use is subject to license terms
  *
  * @param     NULL
  * @return    NULL
 */
 function ac_gettask()
 {
     AjaxHead();
     $typeid = $this->gv('typeid');
     $rs = cjxdb('kwkeyword')->where("typeid={$typeid}")->Fields('`type`,`keyword`')->select();
     $keyword = $rss = $dx = $dxs = '';
     require_once DEDEINC . "/dedetag.class.php";
     $dtp = new DedeTagParse();
     foreach ($rs as $r) {
         if ($r['type'] == 0) {
             $keyword .= empty($keyword) ? $r['keyword'] : "\r\n" . $r['keyword'];
         } else {
             if ($r['type'] == 1) {
                 $rss .= empty($rss) ? $r['keyword'] : "\r\n" . $r['keyword'];
             } else {
                 if ($r['type'] == 2) {
                     $dx .= empty($dx) ? $r['keyword'] : "``" . $r['keyword'];
                     $dtp->LoadString($r['keyword']);
                     $dxt = $dtp->GetTagByName('list') ? $dtp->GetTagByName('list')->GetInnerText() : '';
                     $dxs .= "<span><a href='javascript:void(0);' style='float:right' onclick='delpage(this);'>删除</a><a href='javascript:void(0);' style='float:right' onclick='editpage(this);'>编辑&nbsp;</a>" . $dxt . "</span>";
                 } else {
                 }
             }
         }
     }
     $note = cjxdb('co_note')->Fields('nid,notename')->where('channelid=1')->select();
     foreach ($note as $k => $v) {
         $ck = cjxdb('kwkeyword')->where("`keyword`={$v['nid']} AND `type`=3")->find();
         if ($ck) {
             if ($ck['typeid'] == $typeid) {
                 $note[$k]['btype'] = true;
             } else {
                 $note[$k]['btype'] = $ck['typeid'];
             }
         }
         $note[$k]['channelname'] = '普通文章';
     }
     $this->assign('typeid', $typeid);
     $this->assign('keyword', $keyword);
     $this->assign('rss', $rss);
     $this->assign('dx', $dx);
     $this->assign('dxs', $dxs);
     $this->assign('notelist', $note);
     $this->display();
 }
Beispiel #12
0
	 }
	 $row['channelid'] = $channelid;
	 $row['rulename'] = "{$cinfos['typename']}模型";
	 $row['etype'] = "当前系统";
	 $row['dtime'] = $ntime;
	}
}
if(empty($exrule)) $exrule = $row['aid'];
if(empty($exrule)){
	ClearAllLink();
  ShowMsg("读取规则错误,无法继续操作!","javascript:;");
	exit();
}
$ruleset = $row['ruleset'];
$dtp = new DedeTagParse();
$dtp->LoadString($ruleset);
$noteid = 0;
if(is_array($dtp->CTags))
{
	foreach($dtp->CTags as $ctag){
		if($ctag->GetName()=='field') $noteid++;
		if($ctag->GetName()=='note') $noteinfos = $ctag;
	}
}
else
{
	ShowMsg("该规则不合法,无法进行生成采集配置!","-1");
	$dsql->Close();
	exit();
}
require_once(dirname(__FILE__)."/templets/co_add.htm");
Beispiel #13
0
		$language = $ctag->GetAtt("language");
		$matchtype = $ctag->GetAtt("matchtype");
		$refurl = $ctag->GetAtt("refurl");
		$isref = $ctag->GetAtt("isref");
		$exptime = $ctag->GetAtt("exptime");
	}
	else if($ctag->GetName()=="list")
	{
		$sunnote = $ctag->GetInnerText();
		$dtp2->LoadString($sunnote);
		$source = $ctag->GetAtt('source');
		$sourcetype = $ctag->GetAtt('sourcetype');
		$varstart = $ctag->GetAtt('varstart');
		$varend = $ctag->GetAtt('varend');
		$urlTag = $dtp2->GetTagByName('url');
		$needTag = $dtp2->GetTagByName('need');
		$cannotTag = $dtp2->GetTagByName('cannot');
		$linkareaTag = $dtp2->GetTagByName('linkarea');
	}
	else if($ctag->GetName()=="art")
	{
		$sunnote = $ctag->GetInnerText();
		$dtp3->LoadString($sunnote);
		$sppageTag = $dtp3->GetTagByName('sppage');
  }
}

require_once(dirname(__FILE__)."/templets/co_edit.htm");

ClearAllLink();
?>
	function LoadConfig($configString)
	{
		$dtp = new DedeTagParse();
		$dtp->SetNameSpace("dede","{","}");
		$dtp2 = new DedeTagParse();
		$dtp2->SetNameSpace("dede","{","}");
		$dtp3 = new DedeTagParse();
		$dtp3->SetNameSpace("dede","{","}");
		$dtp->LoadString($configString);
		for($i=0;$i<=$dtp->Count;$i++)
		{
			$ctag = $dtp->CTags[$i];
			//item 配置
			//节点基本信息
			if($ctag->GetName()=="item")
			{
				$this->Item["name"] = $ctag->GetAtt("name");
				$this->Item["typeid"] = $ctag->GetAtt("typeid");
				$this->Item["imgurl"] = $ctag->GetAtt("imgurl");
				$this->Item["imgdir"] = $ctag->GetAtt("imgdir");
				$this->Item["language"] = $ctag->GetAtt("language");
				$this->Item["matchtype"] = $ctag->GetAtt("matchtype");
				$this->Item["isref"] = $ctag->GetAtt("isref");
				$this->Item["refurl"] = $ctag->GetAtt("refurl");
				$this->Item["exptime"] = $ctag->GetAtt("exptime"); 
				if($this->Item["matchtype"]=="") $this->Item["matchtype"]="string";
				//创建图片保存目录
				$updir = dirname(__FILE__)."/".$this->Item["imgdir"]."/";
				$updir = str_replace("\\","/",$updir);
				$updir = preg_replace("/\/{1,}/","/",$updir);
				if(!is_dir($updir)) MkdirAll($updir,$GLOBALS['cfg_dir_purview']);
			}
			//list 配置
			//要采集的列表页的信息
			else if($ctag->GetName()=="list")
			{
				$this->List["varstart"]= $ctag->GetAtt("varstart");
				$this->List["varend"] = $ctag->GetAtt("varend");
				$this->List["source"] = $ctag->GetAtt("source");
				$this->List["sourcetype"] = $ctag->GetAtt("sourcetype");
				$dtp2->LoadString($ctag->GetInnerText());
				for($j=0;$j<=$dtp2->Count;$j++)
				{
					$ctag2 = $dtp2->CTags[$j];
					$tname = $ctag2->GetName();
					if($tname=="need"){
						$this->List["need"] = trim($ctag2->GetInnerText());
					}else if($tname=="cannot"){
						$this->List["cannot"] = trim($ctag2->GetInnerText());
					}
					else if($tname=="linkarea"){
						$this->List["linkarea"] = trim($ctag2->GetInnerText());
				  }else if($tname=="url")
					{
						$gurl = trim($ctag2->GetAtt("value"));
						//手工指定列表网址
						if($this->List["source"]=="app")
						{
							$turl = trim($ctag2->GetInnerText());
							$turls = explode("\n",$turl);
							$l_tj = 0;
							foreach($turls as $turl){
								$turl = trim($turl);
								if($turl=="") continue;
								if(!eregi("^http://",$turl)) $turl = "http://".$turl;
								$this->List["url"][$l_tj] = $turl;
								$l_tj++;
							}
						}
						//用分页变量产生的网址
						else
						{	
							if(eregi("var:分页",trim($ctag2->GetAtt("value")))){
								if($this->List["varstart"]=="") $this->List["varstart"]=1;
								if($this->List["varend"]=="") $this->List["varend"]=10;
								$l_tj = 0;
								for($l_em = $this->List["varstart"];$l_em<=$this->List["varend"];$l_em++){
										$this->List["url"][$l_tj] = str_replace("[var:分页]",$l_em,$gurl);
										$l_tj++;
								}
							}//if set var
							else{
								$this->List["url"][0] = $gurl;
							}
						}
					}
				}//End inner Loop1
			}
			//art 配置
			//要采集的文章页的信息
			else if($ctag->GetName()=="art")
			{
				$dtp2->LoadString($ctag->GetInnerText());
				for($j=0;$j<=$dtp2->Count;$j++)
				{
					$ctag2 = $dtp2->CTags[$j];
					//文章要采集的字段的信息及处理方式
					if($ctag2->GetName()=="note"){
						$field = $ctag2->GetAtt('field');
						if($field == "") continue;
						$this->ArtNote[$field]["value"] = $ctag2->GetAtt('value');
						$this->ArtNote[$field]["isunit"] = $ctag2->GetAtt('isunit');
						$this->ArtNote[$field]["isdown"] = $ctag2->GetAtt('isdown');
						$dtp3->LoadString($ctag2->GetInnerText());
						for($k=0;$k<=$dtp3->Count;$k++)
						{
							$ctag3 = $dtp3->CTags[$k];
							if($ctag3->GetName()=="trim"){
								$this->ArtNote[$field]["trim"][] = $ctag3->GetInnerText();
							}
							else if($ctag3->GetName()=="match"){
								$this->ArtNote[$field]["match"] = $ctag3->GetInnerText();
							}
							else if($ctag3->GetName()=="function"){
								$this->ArtNote[$field]["function"] = $ctag3->GetInnerText();
							}
						}
					}
					else if($ctag2->GetName()=="sppage"){
						$this->ArtNote["sppage"] = $ctag2->GetInnerText();
						$this->ArtNote["sptype"] = $ctag2->GetAtt('sptype');
					}
				}//End inner Loop2
			}
		}//End Loop
		$dtp->Clear();
		$dtp2->Clear();
	}
Beispiel #15
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;
}
Beispiel #16
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;
}
 /**
  *  分析采集文章页的字段的设置
  *
  * @access    public
  * @param     string  $configString  配置字符串
  * @return    void
  */
 function LoadItemConfig($configString)
 {
     $dtp = new DedeTagParse();
     $dtp2 = new DedeTagParse();
     $dtp->LoadString($configString);
     for ($i = 0; $i <= $dtp->Count; $i++) {
         $ctag = $dtp->CTags[$i];
         if ($ctag->GetName() == 'sppage') {
             $this->artNotes['sppage'] = $ctag->GetInnerText();
             $this->artNotes['sptype'] = $ctag->GetAtt('sptype');
             $this->spNotes['srul'] = $ctag->GetAtt('srul');
             $this->spNotes['erul'] = $ctag->GetAtt('erul');
         } else {
             if ($ctag->GetName() == 'previewurl') {
                 $this->artNotes['previewurl'] = $ctag->GetInnerText();
             } else {
                 if ($ctag->GetName() == 'keywordtrim') {
                     $this->artNotes['keywordtrim'] = $ctag->GetInnerText();
                 } else {
                     if ($ctag->GetName() == 'descriptiontrim') {
                         $this->artNotes['descriptiontrim'] = $ctag->GetInnerText();
                     } else {
                         if ($ctag->GetName() == 'item') {
                             $field = $ctag->GetAtt('field');
                             if ($field == '') {
                                 continue;
                             }
                             $this->artNotes[$field]['value'] = $ctag->GetAtt('value');
                             $this->artNotes[$field]['isunit'] = $ctag->GetAtt('isunit');
                             $this->artNotes[$field]['isdown'] = $ctag->GetAtt('isdown');
                             $this->artNotes[$field]['trim'] = array();
                             $this->artNotes[$field]['match'] = '';
                             $this->artNotes[$field]['function'] = '';
                             $t = 0;
                             $dtp2->LoadString($ctag->GetInnerText());
                             for ($k = 0; $k <= $dtp2->Count; $k++) {
                                 $ctag2 = $dtp2->CTags[$k];
                                 if ($ctag2->GetName() == 'trim') {
                                     $this->artNotes[$field]['trim'][$t][0] = str_replace('#n#', '&nbsp;', $ctag2->GetInnerText());
                                     $this->artNotes[$field]['trim'][$t][1] = $ctag2->GetAtt('replace');
                                     $t++;
                                 } else {
                                     if ($ctag2->GetName() == 'match') {
                                         $this->artNotes[$field]['match'] = str_replace('#n#', '&nbsp;', $ctag2->GetInnerText());
                                     } else {
                                         if ($ctag2->GetName() == 'function') {
                                             $this->artNotes[$field]['function'] = $ctag2->GetInnerText();
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     //End Loop
     $dtp->Clear();
     $dtp2->Clear();
 }
Beispiel #18
0
 function GetCatalogList($pid, $innertext)
 {
     global $cfg_cmspath;
     $clist = '';
     $this->dsql->SetQuery("Select id,pid,classname From #@__story_catalog where pid='{$pid}' order by rank asc ");
     $this->dsql->Execute();
     $ndtp = new DedeTagParse();
     $ndtp->SetNameSpace("in", "{", "}");
     $ch = 0;
     if (trim($innertext) == "") {
         if ($pid == 0) {
             $innertext = GetSysTemplets('book_catalog.htm');
         } else {
             $innertext = GetSysTemplets('book_catalog_son.htm');
         }
     }
     while ($row = $this->dsql->GetArray()) {
         $ch++;
         $ndtp->LoadString($innertext);
         $row['url'] = $cfg_cmspath . '/book/list.php?id=' . $row['id'];
         if (is_array($ndtp->CTags)) {
             foreach ($ndtp->CTags as $tagid => $ctag) {
                 $tagname = $ctag->GetTagName();
                 //field类型
                 if ($tagname == 'field') {
                     if (isset($row[$ctag->GetAtt('name')])) {
                         $ndtp->Assign($tagid, $row[$ctag->GetAtt('name')]);
                     } else {
                         $ndtp->Assign($tagid, '');
                     }
                 } else {
                     if ($tagname == 'sonlist') {
                         $this->dsql->SetQuery("Select id,pid,classname From #@__story_catalog where pid='{$row['id']}' order by rank asc");
                         $this->dsql->Execute('ch');
                         $ct = 0;
                         $nlist = '';
                         while ($rowch = $this->dsql->GetArray('ch')) {
                             $ct++;
                             $rowch['url'] = $cfg_cmspath . '/book/list.php?id=' . $rowch['id'];
                             $rbtext = preg_replace("/\\[field:url([\\s]{0,})\\/\\]/isU", $rowch['url'], $ctag->GetInnerText());
                             $rbtext = preg_replace("/\\[field:id([\\s]{0,})\\/\\]/isU", $rowch['id'], $rbtext);
                             $rbtext = preg_replace("/\\[field:classname([\\s]{0,})\\/\\]/isU", $rowch['classname'], $rbtext);
                             $nlist .= $rbtext;
                         }
                         $ndtp->Assign($tagid, $nlist);
                     }
                 }
             }
             //End foreach
             $clist .= $ndtp->GetResult();
         }
     }
     return $clist;
 }
Beispiel #19
0
 require_once DEDEINC . "/dedetag.class.php";
 $notes = trim($notes);
 //对Base64格式的规则进行解码
 if (ereg('^BASE64:', $notes)) {
     if (!ereg(':END$', $notes)) {
         ShowMsg('该规则不合法,Base64格式的采集规则为:BASE64:base64编码后的配置:END !', '-1');
         exit;
     }
     $notess = explode(':', $notes);
     $notes = $notess[1];
     $notes = base64_decode(ereg_replace("[\r\n\t ]", '', $notes)) or die('配置字符串有错误!');
 } else {
     $notes = stripslashes($notes);
 }
 $dtp = new DedeTagParse();
 $dtp->LoadString($notes);
 if (!is_array($dtp->CTags)) {
     ShowMsg('该规则不合法,无法导入!', '-1');
     exit;
 }
 $ctag1 = $dtp->GetTagByName('listconfig');
 $ctag2 = $dtp->GetTagByName('itemconfig');
 $listconfig = $ctag1->GetInnerText();
 $itemconfig = addslashes($ctag2->GetInnerText());
 $dtp->LoadString($listconfig);
 $listconfig = addslashes($listconfig);
 $noteinfo = $dtp->GetTagByName('noteinfo');
 if (!is_object($noteinfo)) {
     ShowMsg("该规则不合法,无法导入!", "-1");
     exit;
 }
Beispiel #20
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;
}
Beispiel #21
0
 $totalnum = $line = count($ids);
 //取出属性并解析为变量
 $attarray = unserialize($row['attstr']);
 extract($attarray, EXTR_SKIP);
 $artlist = '';
 //通过页面及总数解析当前页面数据范围
 $strnum = ($pnum - 1) * $row['pagesize'];
 $limitsql = " LIMIT {$strnum},{$row['pagesize']} ";
 if ($mtype == 0) {
     //处理列表内容项
     $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            {$row['addfieldsSql']}\r\n             FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\r\n             {$row['addfieldsSqlJoin']}\r\n          WHERE arc.id IN({$row['arcids']}) {$row['ordersql']} {$limitsql}";
     $dsql->SetQuery($query);
     $dsql->Execute('al');
     $dtp2 = new DedeTagParse();
     $dtp2->SetNameSpace('field', '[', ']');
     $dtp2->LoadString($row['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 .= "    <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'];
Beispiel #22
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;
}
Beispiel #23
0
 if (!empty($nid)) {
     $dsql->SetQuery("SELECT * FROM `#@__co_htmls` WHERE nid='{$nid}' AND isdown='1' ORDER BY aid {$orderway} LIMIT {$startdd},{$pagesize}");
 } else {
     $dsql->SetQuery("SELECT * FROM `#@__co_htmls` WHERE isdown='1' ORDER BY aid {$orderway} LIMIT {$startdd},{$pagesize}");
 }
 $dsql->Execute();
 while ($row = $dsql->GetObject()) {
     if (trim($row->result == '')) {
         continue;
     }
     //$addSqlTemplate,$mainSqlTemplate,$indexSqlTemplate
     $ntypeid = $autotype == 1 && $row->typeid != 0 ? $row->typeid : $typeid;
     $indexSql = str_replace('@typeid@', $ntypeid, $indexSqlTemplate);
     $mainSql = str_replace('@typeid@', $ntypeid, $mainSqlTemplate);
     $addSql = str_replace('@typeid@', $ntypeid, $addSqlTemplate);
     $dtp->LoadString($row->result);
     $exid = $row->aid;
     if (!is_array($dtp->CTags)) {
         continue;
     }
     //获取时间和标题
     $pubdate = $sortrank = time();
     $title = $row->title;
     $litpic = '';
     foreach ($dtp->CTags as $ctag) {
         $itemName = $ctag->GetAtt('name');
         if ($itemName == 'title' && $usetitle == 0) {
             $title = trim($ctag->GetInnerText());
             if ($title == '') {
                 $title = $row->title;
             }
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);
}