Example #1
0
 function ac_txt()
 {
     global $cfg_basehost, $cfg_basedir, $cfg_cmspath, $cfg_multi_site, $dsql;
     $str = $cfg_basehost . "\r\n";
     $murl = $cfg_basedir . $cfg_cmspath . "/sitemap.txt";
     $dsql->Execute('me', "SELECT * FROM #@__arctype");
     while ($arcRow = $dsql->GetArray()) {
         $typeurl = GetTypeUrl($arcRow['id'], $arcRow['typedir'], $arcRow['isdefault'], $arcRow['defaultname'], $arcRow['ispart'], $arcRow['namerule2'], $arcRow['moresite'], $arcRow['siteurl'], $arcRow['sitepath']);
         if ($cfg_multi_site == 'N' && $arcRow['ispart'] != 2) {
             $str .= $cfg_basehost . $typeurl . "\r\n";
         } else {
             $str .= $typeurl . "\r\n";
         }
     }
     $query = "Select arc.id,arc.title,arc.shorttitle,arc.typeid,arc.ismake,arc.senddate,arc.arcrank,arc.money,arc.filename,arc.litpic,\n                            t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath\n                            from `#@__archives` arc left join #@__arctype t on arc.typeid=t.id  WHERE arc.ismake > 0 ";
     $dsql->Execute('a1', $query);
     while ($aRow = $dsql->GetArray('a1')) {
         $arcurl = GetFileUrl($aRow['id'], $aRow['typeid'], $aRow['senddate'], $aRow['title'], $aRow['ismake'], $aRow['arcrank'], $aRow['namerule'], $aRow['typedir'], $aRow['money'], $aRow['filename'], $aRow['moresite'], $aRow['siteurl'], $aRow['sitepath']);
         if ($cfg_multi_site == 'N') {
             $str .= $cfg_basehost . $arcurl . "\r\n";
         } else {
             $str .= $arcurl . "\r\n";
         }
     }
     file_put_contents($murl, $str);
     echo "<a href='/sitemap.txt' target='_blank'>成功更新文件: /sitemap.txt 浏览...</a>";
     exit;
 }
function DelArc($aid,$onlyfile=false,$channelid=0)
{
	  global $dsql;
	  if(!is_object($dsql)) $dsql = new DedeSql(false);
	  $tables = GetChannelTable($dsql,$aid,'arc');
    //读取文档信息
    $arctitle = "";
    $arcurl = "";
    $arcQuery = "
    Select a.ID,a.title,a.typeid,
    a.ismake,a.senddate,a.arcrank,c.addtable,
 		a.money,t.typedir,t.typename,a.adminID,
 		t.namerule,t.namerule2,t.ispart,
 		t.moresite,t.siteurl,t.siterefer,t.sitepath 
		from `{$tables['maintable']}` a 
		left join `#@__arctype` t on a.typeid=t.ID
		left join `#@__channeltype` c on c.ID=a.channel
    where a.ID='$aid'
    ";
    $arcRow = $dsql->GetOne($arcQuery);
    if(!is_array($arcRow)) return false;
    //删除数据库的内容
    $rs = $dsql->ExecuteNoneQuery("Delete From `{$tables['maintable']}` where ID='$aid'");
    if($rs){
       $dsql->ExecuteNoneQuery("Delete From `#@__full_search` where aid='$aid'");
       if($arcRow['addtable']!=""){
         $dsql->ExecuteNoneQuery("Delete From `{$tables['addtable']}` where aid='$aid'");
       }
       $dsql->ExecuteNoneQuery("Delete From `#@__feedback` where aid='$aid'");
       $dsql->ExecuteNoneQuery("Delete From `#@__memberstow` where arcid='$aid'");
    }
    //删除HTML
    if($arcRow['ismake']==-1||$arcRow['arcrank']!=0
    ||$arcRow['typeid']==0||$arcRow['money']>0){
  		return true;
  	}
  	$arcurl = GetFileUrl($arcRow['ID'],$arcRow['typeid'],$arcRow['senddate'],$arcRow['title'],$arcRow['ismake'],
           $arcRow['arcrank'],$arcRow['namerule'],$arcRow['typedir'],$arcRow['money'],false,'');
    if(!ereg("\?",$arcurl)){
    	 $truedir = GetTruePath($arcRow['siterefer'],$arcRow['sitepath']);
    	 $htmlfile = $truedir.$arcurl;
    	 if(file_exists($htmlfile) && !is_dir($htmlfile)) unlink($htmlfile);
    	 $arcurls = explode(".",$arcurl);
    	 $sname = $arcurls[count($arcurls)-1];
    	 $fname = ereg_replace("(\.$sname)$","",$arcurl);
    	 for($i=2;$i<=100;$i++){
    		 $htmlfile = $truedir.$fname."_$i".".".$sname;
    		 if(file_exists($htmlfile) && !is_dir($htmlfile)) unlink($htmlfile);
    		 else break;
    	 }
    }
    //删除文本文件
    $ipath = $GLOBALS['cfg_cmspath']."/data/textdata/".(ceil($aid/5000))."/";
		$filename = $GLOBALS['cfg_basedir'].$ipath."{$aid}.txt";
		if(is_file($filename)) unlink($filename);
    return true;
}
Example #3
0
function plus_spacenewart(&$atts, &$refObj, &$fields)
{
    global $dsql, $_vars;
    $attlist = "channel=1,titlelen=30,infolen=200,row=8,imgwidth=120,imgheight=90";
    FillAtts($atts, $attlist);
    FillFields($atts, $fields, $refObj);
    extract($atts, EXTR_OVERWRITE);
    $query = "Select arc.*,mt.mtypename,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,\r\n\t\ttp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\r\n\t\tfrom `#@__archives` arc\r\n\t\tleft join `#@__arctype` tp on arc.typeid=tp.id\r\n\t\tleft join `#@__mtypes` mt on mt.mtypeid=arc.mtype\r\n\t\twhere arc.mid='{$_vars['mid']}' and arc.channel={$channel}\r\n\t\torder by id desc limit 0,{$row}";
    $dsql->SetQuery($query);
    $dsql->Execute("al");
    $artlist = '';
    $rearr = array();
    while ($row = $dsql->GetArray("al")) {
        //处理一些特殊字段
        $row['infos'] = cn_substr($row['description'], $infolen);
        $row['id'] = $row['id'];
        $row['arcurl'] = GetFileUrl($row['id'], $row['typeid'], $row['senddate'], $row['title'], $row['ismake'], $row['arcrank'], $row['namerule'], $row['typedir'], $row['money'], $row['filename'], $row['moresite'], $row['siteurl'], $row['sitepath']);
        $row['typeurl'] = GetTypeUrl($row['typeid'], $row['typedir'], $row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'], $row['moresite'], $row['siteurl'], $row['sitepath']);
        if ($row['litpic'] == '') {
            $row['litpic'] = '/images/defaultpic.gif';
        }
        if (!eregi("^http://", $row['litpic'])) {
            $row['picname'] = $row['litpic'] = $GLOBALS['cfg_cmsurl'] . $row['litpic'];
        } else {
            $row['picname'] = $row['litpic'] = $row['litpic'];
        }
        $row['stime'] = GetDateMK($row['pubdate']);
        $row['typelink'] = "<a href='" . $row['typeurl'] . "'>" . $row['typename'] . "</a>";
        $row['image'] = "<img src='" . $row['picname'] . "' border='0' width='{$imgwidth}' height='{$imgheight}' alt='" . ereg_replace("['><]", "", $row['title']) . "'>";
        $row['imglink'] = "<a href='" . $row['filename'] . "'>" . $row['image'] . "</a>";
        $row['fulltitle'] = $row['title'];
        $row['title'] = cn_substr($row['title'], $titlelen);
        if ($row['color'] != '') {
            $row['title'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
        }
        if (ereg('b', $row['flag'])) {
            $row['title'] = "<strong>" . $row['title'] . "</strong>";
        }
        //$row['title'] = "<b>".$row['title']."</b>";
        $row['textlink'] = "<a href='" . $row['filename'] . "'>" . $row['title'] . "</a>";
        $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
        $row['memberurl'] = $GLOBALS['cfg_memberurl'];
        $row['templeturl'] = $GLOBALS['cfg_templeturl'];
        $rearr[] = $row;
    }
    //loop line
    $dsql->FreeResult("al");
    return $rearr;
}
Example #4
0
function DisplayWidgetIcon()
{
    $id = $_GET["id"];
    $pac = $_GET["pac"];
    $data = GetPageData($pac, false);
    if ($data == null) {
        return;
    }
    if ($data['error'] != null && $data['error'] != "") {
        SetSortValue($id, -3);
        $src = GetFeedwebUrl() . "IMG/Remove.png";
        if ($data['error'] == "Bad PAC") {
            $title = __("The widget data is invalid and cannot be used.", "FWTD");
            echo "<script>function OnInvalidPAC() { if (window.confirm ('" . __("Remove Invalid Widget?", "FWTD") . "') == true) " . "window.location.href='" . plugin_dir_url(__FILE__) . "/widget_commit.php?feedweb_cmd=REM&wp_post_id=" . $id . "'; } " . "</script><a href='#' onclick='OnInvalidPAC()'><img title='{$title}' src='{$src}' style='padding-left: 4px;'/></a>";
            return;
        }
        $title = __("Unknown error.", "FWTD") . __("\nPlease contact Feedweb (contact@feedweb.net)", "FWTD");
        echo "<img title='{$title}' src='{$src}' style='padding-left: 4px;'/>";
        return;
    }
    $src = GetFeedwebUrl() . "IMG/Edit.png";
    $votes = $data['votes'];
    $score = $data['score'];
    if ($score != "") {
        SetSortValue($id, intval($votes));
        $format = __("Edit / Remove Rating Widget\n(%s Votes. Average Score: %s)", "FWTD");
        $title = sprintf($format, $votes, $score);
        if ($data['image'] != "") {
            $src = GetFileUrl($data['image']);
        }
    } else {
        SetSortValue($id, 0);
        $title = __("Edit / Remove Rating Widget\n(No votes yet)", "FWTD");
    }
    $width = 675;
    $height = 360;
    $url = plugin_dir_url(__FILE__) . "widget_dialog.php?wp_post_id=" . $id . "&mode=edit&KeepThis=true&TB_iframe=true&height={$height}&width={$width}";
    $div_class = GetStatusImageClass();
    $image_id = $div_class . "_" . $id;
    echo "<div class='{$div_class}' style='display: inline;' onmouseover='ShowFeedwebStats({$id})' onmouseout='HideFeedwebStats()'>";
    $answers = $data['answers'];
    if ($answers != null) {
        for ($index = 0; $index < count($answers); $index++) {
            $text = str_replace("'", "’", $answers[$index]);
            echo "<input type='hidden' class='FeedwebPostAnswerData' value='{$text}'/>";
        }
    }
    echo "<input alt='{$url}' class='thickbox' id='{$image_id}' title='{$title}' type='image' src='{$src}'/></div>";
}
Example #5
0
 function GetOneArchive($aid)
 {
     global $dsql;
     include_once DEDEINC . "/channelunit.func.php";
     $aid = trim(preg_replace('/[^0-9]/', '', $aid));
     $reArr = array();
     $chRow = $dsql->GetOne("SELECT arc.*,ch.maintable,ch.addtable,ch.issystem FROM `#@__arctiny` arc LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel WHERE arc.id='{$aid}' ");
     if (!is_array($chRow)) {
         return $reArr;
     } else {
         if (empty($chRow['maintable'])) {
             $chRow['maintable'] = '#@__archives';
         }
     }
     if ($chRow['issystem'] != -1) {
         $nquery = " SELECT arc.*,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath\n                        FROM `{$chRow['maintable']}` arc LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid\n                        WHERE arc.id='{$aid}' ";
     } else {
         $nquery = " SELECT arc.*,1 AS ismake,0 AS money,'' AS filename,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath\n                        FROM `{$chRow['addtable']}` arc LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid\n                        WHERE arc.aid='{$aid}' ";
     }
     $arcRow = $dsql->GetOne($nquery);
     if (!is_array($arcRow)) {
         return $reArr;
     }
     if (!isset($arcRow['description'])) {
         $arcRow['description'] = '';
     }
     if (empty($arcRow['description']) && isset($arcRow['body'])) {
         $arcRow['description'] = cn_substr(html2text($arcRow['body']), 250);
     }
     if (!isset($arcRow['pubdate'])) {
         $arcRow['pubdate'] = $arcRow['senddate'];
     }
     if (!isset($arcRow['notpost'])) {
         $arcRow['notpost'] = 0;
     }
     $reArr = $arcRow;
     $reArr['aid'] = $aid;
     $reArr['topid'] = $arcRow['topid'];
     $reArr['arctitle'] = $arcRow['title'];
     $reArr['arcurl'] = GetFileUrl($aid, $arcRow['typeid'], $arcRow['senddate'], $reArr['title'], $arcRow['ismake'], $arcRow['arcrank'], $arcRow['namerule'], $arcRow['typedir'], $arcRow['money'], $arcRow['filename'], $arcRow['moresite'], $arcRow['siteurl'], $arcRow['sitepath']);
     return $reArr;
 }
		from `{$tables['maintable']}` arc
		left join #@__arctype t on t.ID = arc.typeid
		left join #@__channeltype c on c.ID = arc.channel
		where arc.ID='$aid'
  ";
  $arcRow = $dsql->GetOne($arcQuery);
	if($arcRow['ismake']==-1||$arcRow['arcrank']!=0
    ||$arcRow['typeid']==0||$arcRow['money']>0||$arcRow['channel']<-1)
  {
    	$dsql->Close();
    	echo "<script language='javascript'>location.href='{$cfg_plus_dir}/view.php?aid={$aid}';</script>";
    	exit();
  }
  $arcurl = GetFileUrl($arcRow['ID'],$arcRow['typeid'],$arcRow['senddate'],$arcRow['title'],$arcRow['ismake'],
           $arcRow['arcrank'],$arcRow['namerule'],$arcRow['typedir'],$arcRow['money'],true,$arcRow['siteurl']);
  $arcfile = GetFileUrl($arcRow['ID'],$arcRow['typeid'],$arcRow['senddate'],$arcRow['title'],$arcRow['ismake'],
           $arcRow['arcrank'],$arcRow['namerule'],$arcRow['typedir'],$arcRow['money'],false,'');
	$truefile = GetTruePath($arcRow['siterefer'],$arcRow['sitepath']).$arcfile;
  MakeArt($aid,true,true);
  $dsql->Close();
  echo "<script language='javascript'>location.href='$arcurl"."?".time()."';</script>";
	exit();
}
/*--------------------------
//推荐文档
function commendArchives();
---------------------------*/
else if($dopost=="commendArchives")
{
	CheckPurview('a_Commend,sys_ArcBatch');
	$dsql = new DedeSql(false);
	if( $aid!="" && !ereg("(".$aid."`|`".$aid.")",$qstr) ) $qstr .= "`".$aid;
 	function GetArcUrl($aid,$typeid,$timetag,$title,$ismake=0,$rank=0,$namerule="",$artdir="",$money=0)
  {
  	return GetFileUrl($aid,$typeid,$timetag,$title,$ismake,$rank,$namerule,$artdir,$money);
  }
Example #8
0
 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:\\/\\/#", $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'] != '') {
    function toXml()
    {
        global $dsql, $cfg_webname, $cfg_basehost, $cfg_soft_lang;
        $addonQuery = $limitQuery = "";
        if (!empty($this->Typeid)) {
            $addonQuery .= "AND arc.typeid=" . intval($this->Typeid);
            $typeinfos = $this->getType($this->Typeid);
        }
        if ($this->SitemapType == 2) {
            $setupmaxaid = baidu_get_setting('setupmaxaid');
            $addonQuery .= "AND arc.id>" . intval($setupmaxaid);
        }
        $this->Start = intval($this->Start);
        //var_dump($typeinfos);exit();
        if (!empty($this->Row)) {
            $limitQuery = "LIMIT  {$this->Start}," . intval($this->Row);
        }
        $query = "SELECT arc.*,arc.senddate AS pubdate,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,\n\t\t\ttp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,at.body\n\t\t\tFROM `{$this->MainTable}` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\n            LEFT JOIN `#@__addonarticle` at ON arc.id=at.aid\n\t\t\tWHERE arc.arcrank=0 AND arc.arcrank > -1 AND arc.channel=1 {$addonQuery} ORDER BY arc.senddate DESC {$limitQuery}";
        //var_dump($query);
        $dsql->SetQuery($query);
        $dsql->Execute('dd');
        $xmlstr = '<?xml version="1.0" encoding="UTF-8"?>
<urlset>';
        $setupmaxaid = 0;
        while ($row = $dsql->GetArray('dd')) {
            $row['id'] = isset($row['aid']) ? $row['aid'] : $row['id'];
            $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['showdate'] = Mydate('Y-m-d', $row['pubdate']);
            $row['priority'] = 0;
            $row['body'] = isset($row['body']) ? Html2Text($row['body']) : '';
            $row['body'] = empty($row['body']) ? $row['description'] : $row['body'];
            //var_dump($row);exit;
            if (preg_match("#c#", $row['flag'])) {
                $row['priority'] = '1.0';
            }
            if (!isset($typeinfos)) {
                $typeinfos = $this->getType($row['typeid']);
            }
            //var_dump($typeinfo);exit();
            //var_dump($row);
            $row['source'] = trim(Html2Text($row['source']));
            $row['title'] = baidu_strip_invalid_xml($row['title']);
            $row['body'] = baidu_strip_invalid_xml($row['body']);
            $addstr = $copyrightstr = $yearstr = "";
            $copyrightstr = !empty($row['source']) ? "\r\n\t\t\t\t\t<copyrightHolder><name><![CDATA[{$row['source']}]]></name></copyrightHolder>" : '';
            $addstr .= empty($row['litpic']) ? "" : "\r\n\t\t\t\t\t<image><![CDATA[{$row['litpic']}]]></image>";
            $yearstr = Mydate('Y', $row['pubdate']);
            $rowxmlstr = <<<EOT
\t
\t<url>
\t\t\t<loc><![CDATA[{$cfg_basehost}{$row['filename']}]]></loc>
\t\t\t<lastmod>{$row['showdate']}</lastmod>
\t\t\t<changefreq>always</changefreq>
\t\t\t<priority>{$row['priority']}</priority>
\t\t\t<data>
\t\t\t\t<Webpage>
\t\t\t\t\t<name><![CDATA[{$row['title']}]]></name>
\t\t\t\t\t<url><![CDATA[{$cfg_basehost}{$row['filename']}]]></url>
\t\t\t\t\t<provider>
\t\t\t\t\t\t<name><![CDATA[{$cfg_webname}]]></name>
\t\t\t\t\t\t<url><![CDATA[{$cfg_basehost}]]></url>
\t\t\t\t\t</provider>
\t\t\t\t\t<description><![CDATA[{$row['description']}]]></description>
                    <text><![CDATA[{$row['body']}]]></text>
                    <keywords><![CDATA[{$row['keywords']}]]></keywords>
\t\t\t\t\t<breadcrumb><![CDATA[{$typeinfos['position']}]]></breadcrumb>
\t\t\t\t\t{$addstr}
                    <isPartOf>
\t\t\t\t\t\t<name><![CDATA[{$typeinfos['typename']}]]></name>
\t\t\t\t\t\t<url><![CDATA[{$cfg_basehost}{$typeinfos['typelink']}]]></url>
\t\t\t\t\t</isPartOf>
                    {$copyrightstr}
\t\t\t\t\t<copyrightYear>{$yearstr}</copyrightYear>
\t\t\t\t</Webpage>
\t\t\t</data>
\t\t</url>
EOT;
            if ($cfg_soft_lang == 'gb2312') {
                $rowxmlstr = gb2utf8($rowxmlstr);
            }
            //var_dump($rowxmlstr);exit;
            $xmlstr .= $rowxmlstr;
        }
        //exit($xmlstr);
        $xmlstr .= "\r\n</urlset>";
        //$xmldata['content'] = $xmlstr;
        return $xmlstr;
    }
	function GetFileUrl($aid,$typeid,$timetag,$title,$ismake=0,$rank=0,$namerule="",$artdir="",$money=0,$siterefer="",$sitepath=""){
		$articleRule = "";
		$articleDir = "";
		if($namerule!="") $articleRule = $namerule;
		else if(is_array($this->TypeInfos)) $articleRule = $this->TypeInfos['namerule'];
		if($artdir!="") $articleDir = $artdir;
		else if(is_array($this->TypeInfos)) $articleDir = $this->GetTypeDir();
		return GetFileUrl($aid,$typeid,$timetag,$title,$ismake,$rank,$articleRule,$articleDir,$money,$siterefer,$sitepath);
	}
Example #11
0
 /**
  *  获得文档列表
  *
  * @access    public
  * @param     int  $limitstart  限制开始  
  * @param     int  $row  行数 
  * @param     int  $col  列数
  * @param     int  $titlelen  标题长度
  * @param     int  $infolen  描述长度
  * @param     int  $imgwidth  图片宽度
  * @param     int  $imgheight  图片高度
  * @param     string  $achanneltype  列表类型
  * @param     string  $orderby  排列顺序
  * @param     string  $innertext  底层模板
  * @param     string  $tablewidth  表格宽度
  * @return    string
  */
 function GetArcList($limitstart = 0, $row = 10, $col = 1, $titlelen = 30, $infolen = 250, $imgwidth = 120, $imgheight = 90, $achanneltype = "all", $orderby = "default", $innertext = "", $tablewidth = "100")
 {
     global $cfg_sphinx_article;
     $typeid = $this->TypeID;
     if ($row == '') {
         $row = 10;
     }
     if ($limitstart == '') {
         $limitstart = 0;
     }
     if ($titlelen == '') {
         $titlelen = 30;
     }
     if ($infolen == '') {
         $infolen = 250;
     }
     if ($imgwidth == '') {
         $imgwidth = 120;
     }
     if ($imgheight = '') {
         $imgheight = 120;
     }
     if ($achanneltype == '') {
         $achanneltype = '0';
     }
     $orderby = $orderby == '' ? 'default' : strtolower($orderby);
     $tablewidth = str_replace("%", "", $tablewidth);
     if ($tablewidth == '') {
         $tablewidth = 100;
     }
     if ($col == '') {
         $col = 1;
     }
     $colWidth = ceil(100 / $col);
     $tablewidth = $tablewidth . "%";
     $colWidth = $colWidth . "%";
     $innertext = trim($innertext);
     if ($innertext == '') {
         $innertext = GetSysTemplets("search_list.htm");
     }
     if ($cfg_sphinx_article == 'Y') {
         $ordersql = '';
         if ($this->ChannelType < 0 || $this->ChannelTypeid < 0) {
             if ($orderby == "id") {
                 $ordersql = "@id desc";
             } else {
                 $ordersql = "@senddate desc";
             }
         } else {
             if ($orderby == "senddate") {
                 $ordersql = "@senddate desc";
             } else {
                 if ($orderby == "pubdate") {
                     $ordersql = "@pubdate desc";
                 } else {
                     if ($orderby == "id") {
                         $ordersql = "@id desc";
                     } else {
                         $ordersql = "@sortrank desc";
                     }
                 }
             }
         }
         $this->sphinx->SetLimits($limitstart, (int) $row, $row > 1000 ? $row : 1000);
         $res = array();
         $res = AutoCharset($this->sphinx->Query($this->Keywords, 'mysql, delta'), 'utf-8', 'gbk');
         foreach ($res['words'] as $k => $v) {
             $this->Keywords .= " {$k}";
         }
         foreach ($res['matches'] as $_v) {
             $aids[] = $_v['id'];
         }
         $aids = @implode(',', $aids);
         //搜索
         $query = "SELECT arc.*,act.typedir,act.typename,act.isdefault,act.defaultname,act.namerule,\n            act.namerule2,act.ispart,act.moresite,act.siteurl,act.sitepath\n            FROM `#@__archives` arc LEFT JOIN `#@__arctype` act ON arc.typeid=act.id\n            WHERE arc.id IN ({$aids})";
     } else {
         //排序方式
         $ordersql = '';
         if ($this->ChannelType < 0 || $this->ChannelTypeid < 0) {
             if ($orderby == "id") {
                 $ordersql = "ORDER BY arc.aid desc";
             } else {
                 $ordersql = "ORDER BY arc.senddate desc";
             }
         } else {
             if ($orderby == "senddate") {
                 $ordersql = " ORDER BY arc.senddate desc";
             } else {
                 if ($orderby == "pubdate") {
                     $ordersql = " ORDER BY arc.pubdate desc";
                 } else {
                     if ($orderby == "id") {
                         $ordersql = "  ORDER BY arc.id desc";
                     } else {
                         $ordersql = " ORDER BY arc.sortrank desc";
                     }
                 }
             }
         }
         //搜索
         $query = "SELECT arc.*,act.typedir,act.typename,act.isdefault,act.defaultname,act.namerule,\n            act.namerule2,act.ispart,act.moresite,act.siteurl,act.sitepath\n            FROM `{$this->AddTable}` arc LEFT JOIN `#@__arctype` act ON arc.typeid=act.id\n            WHERE {$this->AddSql} {$ordersql} LIMIT {$limitstart},{$row}";
     }
     $this->dsql->SetQuery($query);
     $this->dsql->Execute("al");
     $artlist = "";
     if ($col > 1) {
         $artlist = "<table width='{$tablewidth}' border='0' cellspacing='0' cellpadding='0'>\r\n";
     }
     $this->dtp2->LoadSource($innertext);
     for ($i = 0; $i < $row; $i++) {
         if ($col > 1) {
             $artlist .= "<tr>\r\n";
         }
         for ($j = 0; $j < $col; $j++) {
             if ($col > 1) {
                 $artlist .= "<td width='{$colWidth}'>\r\n";
             }
             if ($row = $this->dsql->GetArray("al")) {
                 if ($this->ChannelType < 0 || $this->ChannelTypeid < 0) {
                     $row["id"] = $row["aid"];
                     $row["ismake"] = empty($row["ismake"]) ? "" : $row["ismake"];
                     $row["filename"] = empty($row["filename"]) ? "" : $row["filename"];
                     $row["money"] = empty($row["money"]) ? "" : $row["money"];
                     $row["description"] = empty($row["description "]) ? "" : $row["description"];
                     $row["pubdate"] = empty($row["pubdate  "]) ? $row["senddate"] : $row["pubdate"];
                 }
                 //处理一些特殊字段
                 $row["arcurl"] = GetFileUrl($row["id"], $row["typeid"], $row["senddate"], $row["title"], $row["ismake"], $row["arcrank"], $row["namerule"], $row["typedir"], $row["money"], $row['filename'], $row["moresite"], $row["siteurl"], $row["sitepath"]);
                 $row["description"] = $this->GetRedKeyWord(cn_substr($row["description"], $infolen));
                 $row["title"] = $this->GetRedKeyWord(cn_substr($row["title"], $titlelen));
                 $row["id"] = $row["id"];
                 if ($row['litpic'] == '-' || $row['litpic'] == '') {
                     $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
                 }
                 if (!preg_match("/^http:\\/\\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
                     $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
                 }
                 $row['picname'] = $row['litpic'];
                 $row["typeurl"] = GetTypeUrl($row["typeid"], $row["typedir"], $row["isdefault"], $row["defaultname"], $row["ispart"], $row["namerule2"], $row["moresite"], $row["siteurl"], $row["sitepath"]);
                 $row["info"] = $row["description"];
                 $row["filename"] = $row["arcurl"];
                 $row["stime"] = GetDateMK($row["pubdate"]);
                 $row["textlink"] = "<a href='" . $row["filename"] . "'>" . $row["title"] . "</a>";
                 $row["typelink"] = "[<a href='" . $row["typeurl"] . "'>" . $row["typename"] . "</a>]";
                 $row["imglink"] = "<a href='" . $row["filename"] . "'><img src='" . $row["picname"] . "' border='0' width='{$imgwidth}' height='{$imgheight}'></a>";
                 $row["image"] = "<img src='" . $row["picname"] . "' border='0' width='{$imgwidth}' height='{$imgheight}'>";
                 $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                 $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                 $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                 if (is_array($this->dtp2->CTags)) {
                     foreach ($this->dtp2->CTags as $k => $ctag) {
                         if ($ctag->GetName() == 'array') {
                             //传递整个数组,在runphp模式中有特殊作用
                             $this->dtp2->Assign($k, $row);
                         } else {
                             if (isset($row[$ctag->GetName()])) {
                                 $this->dtp2->Assign($k, $row[$ctag->GetName()]);
                             } else {
                                 $this->dtp2->Assign($k, '');
                             }
                         }
                     }
                 }
                 $artlist .= $this->dtp2->GetResult();
             } else {
                 $artlist .= "";
             }
             if ($col > 1) {
                 $artlist .= "</td>\r\n";
             }
         }
         //Loop Col
         if ($col > 1) {
             $artlist .= "</tr>\r\n";
         }
     }
     //Loop Line
     if ($col > 1) {
         $artlist .= "</table>\r\n";
     }
     $this->dsql->FreeResult("al");
     return $artlist;
 }
Example #12
0
             $row['senddate'] = $addTableRow['senddate'];
             $row['channel'] = $addTableRow['channel'];
             $row['arcrank'] = $addTableRow['arcrank'];
             $row['senddate'] = $addTableRow['senddate'];
             $row['typedir'] = $addTableRow['typedir'];
             $row['isdefault'] = $addTableRow['isdefault'];
             $row['defaultname'] = $addTableRow['defaultname'];
             $row['ispart'] = $addTableRow['ispart'];
             $row['namerule2'] = $addTableRow['namerule2'];
             $row['moresite'] = $addTableRow['moresite'];
             $row['siteurl'] = $addTableRow['siteurl'];
             $row['sitepath'] = $addTableRow['sitepath'];
         }
     }
 }
 $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['title'] = changyan_autoCharset($row['title']);
 $feedArr['title'] = $row['title'];
 $feedArr['url'] = $cfg_basehost . $row['arcurl'];
 $feedArr['ttime'] = date('Y-m-d h:m:s', $row['senddate']);
 $feedArr['sourceid'] = $arr['aid'];
 $feedArr['parentid'] = 0;
 $feedArr['categoryid'] = $row['typeid'];
 $feedArr['ownerid'] = $row['mid'];
 $feedArr['metadata'] = '';
 $dsql->SetQuery("SELECT feedback_id FROM `#@__plus_changyan_importids` WHERE aid={$arr['aid']}");
 $dsql->Execute('dd');
 $feedback_ids = array();
 while ($farr = $dsql->GetArray('dd')) {
     $feedback_ids[] = $farr['feedback_id'];
 }
Example #13
0
/**
 *  删除不带主表内容模型的数据
 *
 * @access    public
 * @param     int  $aid  文档ID
 * @return    string
 */
function DelArcSg($aid)
{
    global $dsql, $cfg_cookie_encode, $cfg_ml, $cfg_upload_switch, $cfg_medias_dir;
    $aid = intval($aid);
    //读取文档信息
    $arctitle = '';
    $arcurl = '';
    $arcQuery = "Select arc.id,arc.typeid,arc.senddate,arc.arcrank,ch.addtable,ch.nid,\n        tp.typedir,tp.typename,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\n          from `#@__arctiny` arc\n          left join `#@__arctype` tp on tp.id=arc.typeid\n          left join `#@__channeltype` ch on ch.id=arc.channel\n        where arc.id='{$aid}' ";
    $arcRow = $dsql->GetOne($arcQuery);
    if (!is_array($arcRow)) {
        return FALSE;
    }
    //删除数据库的内容
    $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` where id='{$aid}' ");
    $dsql->ExecuteNoneQuery("DELETE FROM `" . $arcRow['addtable'] . "` where aid='{$aid}' ");
    $dsql->ExecuteNoneQuery("DELETE FROM `#@__feedback` where aid='{$aid}'");
    $dsql->ExecuteNoneQuery("DELETE FROM `#@__member_stow` where aid='{$aid}'");
    $dsql->ExecuteNoneQuery("DELETE FROM `#@__taglist ` where aid='{$aid}'");
    //删除HTML
    if ($arcRow['arcrank'] != 0 || $arcRow['typeid'] == 0) {
        return TRUE;
    }
    $arcurl = GetFileUrl($arcRow['id'], $arcRow['typeid'], $arcRow['senddate'], '', 1, $arcRow['arcrank'], $arcRow['namerule'], $arcRow['typedir'], 0, '');
    if (!preg_match("#\\?#", $arcurl)) {
        $htmlfile = GetTruePath() . str_replace($GLOBALS['cfg_basehost'], '', $arcurl);
        if (file_exists($htmlfile) && !is_dir($htmlfile)) {
            @unlink($htmlfile);
            $arcurls = explode(".", $htmlfile);
            $sname = $arcurls[count($arcurls) - 1];
            $fname = preg_replace("#(\\.{$sname})\$#", "", $htmlfile);
            for ($i = 2; $i <= 100; $i++) {
                $htmlfile = $fname . "_{$i}" . "." . $sname;
                if (file_exists($htmlfile) && !is_dir($htmlfile)) {
                    @unlink($htmlfile);
                } else {
                    break;
                }
            }
        }
    }
    //删除文本文件
    $filenameh = DEDEDATA . "/textdata/" . ceil($aid / 5000) . "/{$aid}-" . substr(md5($cfg_cookie_encode), 0, 16) . ".txt";
    return TRUE;
}
Example #14
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;
}
Example #15
0
 function GetPreNext($gtype = '')
 {
     $rs = '';
     if (count($this->PreNext) < 2) {
         $aid = $this->ArcID;
         $preR = $this->dsql->GetOne("Select id From `#@__arctiny` where id<{$aid} And arcrank>-1 And typeid='{$this->Fields['typeid']}' order by id desc");
         $nextR = $this->dsql->GetOne("Select id From `#@__arctiny` where id>{$aid} And arcrank>-1 And typeid='{$this->Fields['typeid']}' order by id asc");
         $next = is_array($nextR) ? " where arc.id={$nextR['id']} " : ' where 1>2 ';
         $pre = is_array($preR) ? " where arc.id={$preR['id']} " : ' where 1>2 ';
         $query = "Select arc.id,arc.title,arc.shorttitle,arc.typeid,arc.ismake,arc.senddate,arc.arcrank,arc.money,arc.filename,\r\n\t\t\t\t\t\tt.typedir,t.typename,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath\r\n\t\t\t\t\t\tfrom `#@__archives` arc left join #@__arctype t on arc.typeid=t.id  ";
         $nextRow = $this->dsql->GetOne($query . $next);
         $preRow = $this->dsql->GetOne($query . $pre);
         if (is_array($preRow)) {
             $mlink = GetFileUrl($preRow['id'], $preRow['typeid'], $preRow['senddate'], $preRow['title'], $preRow['ismake'], $preRow['arcrank'], $preRow['namerule'], $preRow['typedir'], $preRow['money'], $preRow['filename'], $preRow['moresite'], $preRow['siteurl'], $preRow['sitepath']);
             $this->PreNext['pre'] = "上一篇:<a href='{$mlink}'>{$preRow['title']}</a> ";
         } else {
             $this->PreNext['pre'] = "上一篇:没有了 ";
         }
         if (is_array($nextRow)) {
             $mlink = GetFileUrl($nextRow['id'], $nextRow['typeid'], $nextRow['senddate'], $nextRow['title'], $nextRow['ismake'], $nextRow['arcrank'], $nextRow['namerule'], $nextRow['typedir'], $nextRow['money'], $nextRow['filename'], $nextRow['moresite'], $nextRow['siteurl'], $nextRow['sitepath']);
             $this->PreNext['next'] = "下一篇:<a href='{$mlink}'>{$nextRow['title']}</a> ";
         } else {
             $this->PreNext['next'] = "下一篇:没有了 ";
         }
     }
     if ($gtype == 'pre') {
         $rs = $this->PreNext['pre'];
     } else {
         if ($gtype == 'next') {
             $rs = $this->PreNext['next'];
         } else {
             $rs = $this->PreNext['pre'] . " &nbsp; " . $this->PreNext['next'];
         }
     }
     return $rs;
 }
Example #16
0
 /**
  *  获得文档列表
  *
  * @access    public
  * @param     string  $innertext  底层模板
  * @return    string
  */
 function GetArcList($innertext = "")
 {
     $typeid = $this->TypeID;
     $innertext = trim($innertext);
     if ($innertext == "") {
         $innertext = GetSysTemplets("rss.htm");
     }
     $orwhere = " arc.arcrank > -1 ";
     $orwhere .= " AND (arc.typeid in (" . GetSonIds($this->TypeID, $this->TypeFields['channeltype']) . ") ) ";
     $ordersql = " ORDER BY arc.id desc";
     $query = "SELECT arc.*,tp.typedir,tp.typename,tp.isdefault,\r\n        tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\r\n        FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\r\n        WHERE {$orwhere} {$ordersql} LIMIT 0," . $this->MaxRow;
     $this->dsql->SetQuery($query);
     $this->dsql->Execute('al');
     $artlist = '';
     $dtp2 = new DedeTagParse();
     $dtp2->SetNameSpace('field', '[', ']');
     $dtp2->LoadSource($innertext);
     while ($row = $this->dsql->GetArray('al')) {
         //处理一些特殊字段
         if ($row['litpic'] == '-' || $row['litpic'] == '') {
             $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
         }
         if (!preg_match("/^http:\\/\\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
             $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
         }
         $row['picname'] = $row['litpic'];
         $row["arcurl"] = GetFileUrl($row["id"], $row["typeid"], $row["senddate"], $row["title"], $row["ismake"], $row["arcrank"], $row["namerule"], $row["typedir"], $row["money"], $row['filename'], $row["moresite"], $row["siteurl"], $row["sitepath"]);
         $row["typeurl"] = GetTypeUrl($row["typeid"], $row["typedir"], $row["isdefault"], $row["defaultname"], $row["ispart"], $row["namerule2"], $row["moresite"], $row["siteurl"], $row["sitepath"]);
         $row["info"] = $row["description"];
         $row["filename"] = $row["arcurl"];
         $row["stime"] = GetDateMK($row["pubdate"]);
         $row["image"] = "<img src='" . $row["picname"] . "' border='0'>";
         $row["fullurl"] = $GLOBALS["cfg_basehost"] . $row["arcurl"];
         // 2011-6-20 启用多站点RSS输出存在的路径问题(by:织梦的鱼)
         if ($GLOBALS['cfg_multi_site'] == 'Y') {
             $row["fullurl"] = $row["arcurl"];
         }
         $row["phpurl"] = $GLOBALS["cfg_plus_dir"];
         $row["templeturl"] = $GLOBALS["cfg_templets_dir"];
         if ($row["source"] == '') {
             $row["source"] = $GLOBALS['cfg_webname'];
         }
         if ($row["writer"] == '') {
             $row["writer"] = "秩名";
         }
         foreach ($row as $k => $v) {
             $row[$k] = htmlspecialchars($v);
         }
         if (is_array($dtp2->CTags)) {
             foreach ($dtp2->CTags as $k => $ctag) {
                 if ($ctag->GetName() == 'array') {
                     //传递整个数组,在runphp模式中有特殊作用
                     $dtp2->Assign($k, $row);
                 } else {
                     if (isset($row[$ctag->GetName()])) {
                         $dtp2->Assign($k, $row[$ctag->GetName()]);
                     } else {
                         $dtp2->Assign($k, '');
                     }
                 }
             }
         }
         $artlist .= $dtp2->GetResult() . "\r\n";
     }
     $this->dsql->FreeResult('al');
     return $artlist;
 }
Example #17
0
 /**
  *  获取上一篇,下一篇链接
  *
  * @access    public
  * @param     string  $gtype  获取类型  
  *                    pre:上一篇  preimg:上一篇图片  next:下一篇  nextimg:下一篇图片
  * @return    string
  */
 function GetPreNext($gtype = '')
 {
     global $cfg_indexurl;
     $rs = '';
     if (count($this->PreNext) < 2) {
         $aid = $this->ArcID;
         $chapR = $this->dsql->GetOne("SELECT chapter_no FROM dede_archives WHERE id={$aid}");
         $chapter_no = is_array($chapR) ? $chapR['chapter_no'] : '0';
         $prli = $chapter_no === '0' ? "id<{$aid}" : "chapter_no<{$chapter_no}";
         $neli = $chapter_no === '0' ? "id>{$aid}" : "chapter_no>{$chapter_no}";
         $preR = $this->dsql->GetOne("Select id From `#@__archives` where {$prli} And arcrank>-1 And typeid='{$this->Fields['typeid']}' order by chapter_no desc,id desc");
         $nextR = $this->dsql->GetOne("Select id From `#@__archives` where {$neli} And arcrank>-1 And typeid='{$this->Fields['typeid']}' order by chapter_no asc,id asc");
         $next = is_array($nextR) ? " where arc.id={$nextR['id']} " : ' where 1>2 ';
         $pre = is_array($preR) ? " where arc.id={$preR['id']} " : ' where 1>2 ';
         $query = "Select arc.id,arc.title,arc.shorttitle,arc.typeid,arc.ismake,arc.senddate,arc.arcrank,arc.money,arc.filename,arc.litpic,\r\n                        t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath\r\n                        from `#@__archives` arc left join #@__arctype t on arc.typeid=t.id  ";
         $nextRow = $this->dsql->GetOne($query . $next);
         $preRow = $this->dsql->GetOne($query . $pre);
         if (is_array($preRow)) {
             $mlink = GetFileUrl($preRow['id'], $preRow['typeid'], $preRow['senddate'], $preRow['title'], $preRow['ismake'], $preRow['arcrank'], $preRow['namerule'], $preRow['typedir'], $preRow['money'], $preRow['filename'], $preRow['moresite'], $preRow['siteurl'], $preRow['sitepath']);
             //BbYOu.net修改
             $this->PreNext['pre'] = "{$cfg_indexurl}" . ltrim($mlink, '/');
             $this->PreNext['preimg'] = "<a href='{$mlink}'><img src=\"{$preRow['litpic']}\" alt=\"{$preRow['title']}\"/></a> ";
         } else {
             $this->PreNext['pre'] = "javascript:window.alert('上一篇:没有了'); ";
             $this->PreNext['preimg'] = "<img src=\"/templets/default/images/nophoto.jpg\" alt=\"对不起,没有上一图集了!\"/>";
         }
         if (is_array($nextRow)) {
             $mlink = GetFileUrl($nextRow['id'], $nextRow['typeid'], $nextRow['senddate'], $nextRow['title'], $nextRow['ismake'], $nextRow['arcrank'], $nextRow['namerule'], $nextRow['typedir'], $nextRow['money'], $nextRow['filename'], $nextRow['moresite'], $nextRow['siteurl'], $nextRow['sitepath']);
             //BbYoU.net修改
             $this->PreNext['next'] = "{$cfg_indexurl}" . ltrim($mlink, '/');
             $this->PreNext['nextimg'] = "<a href='{$mlink}'><img src=\"{$nextRow['litpic']}\" alt=\"{$nextRow['title']}\"/></a> ";
         } else {
             $this->PreNext['next'] = "javascript:window.alert('下一篇:没有了'); ";
             $this->PreNext['nextimg'] = "<a href='javascript:void(0)' alt=\"\"><img src=\"/templets/default/images/nophoto.jpg\" alt=\"对不起,没有下一图集了!\"/></a>";
         }
     }
     if ($gtype == 'pre') {
         $rs = $this->PreNext['pre'];
     } else {
         if ($gtype == 'preimg') {
             $rs = $this->PreNext['preimg'];
         } else {
             if ($gtype == 'next') {
                 $rs = $this->PreNext['next'];
             } else {
                 if ($gtype == 'nextimg') {
                     $rs = $this->PreNext['nextimg'];
                 } else {
                     $rs = $this->PreNext['pre'] . " &nbsp; " . $this->PreNext['next'];
                 }
             }
         }
     }
     return $rs;
 }
  function GetArcList($limitstart=0,$row=10,$col=1,$titlelen=30,$infolen=250,
  $imgwidth=120,$imgheight=90,$listtype="all",$orderby="default",$innertext="",$tablewidth="100")
  {
    $typeid=$this->TypeID;
		if($row=="") $row = 10;
		if($limitstart=="") $limitstart = 0;
		if($titlelen=="") $titlelen = 30;
		if($infolen=="") $infolen = 250;
    if($imgwidth=="") $imgwidth = 120;
    if($imgheight=="") $imgheight = 120;
    if($listtype=="") $listtype = "all";
		if($orderby=="") $orderby="default";
		else $orderby=strtolower($orderby);
		$tablewidth = str_replace("%","",$tablewidth);
		if($tablewidth=="") $tablewidth=100;
		if($col=="") $col=1;
		$colWidth = ceil(100/$col); 
		$tablewidth = $tablewidth."%";
		$colWidth = $colWidth."%";
		$innertext = trim($innertext);
		if($innertext=="") $innertext = GetSysTemplets("spec_list.htm");
		//按不同情况设定SQL条件
		$orwhere = " arcs.arcrank > -1 And arcs.channel = -1 ";
		if($this->StartTime>0) $orwhere .= " And arcs.senddate>'".$this->StartTime."'";
		
		//排序方式
		$ordersql = "";
		if($orderby=="senddate") $ordersql=" order by arcs.senddate desc";
		else if($orderby=="pubdate") $ordersql=" order by arcs.pubdate desc";
    else if($orderby=="id") $ordersql="  order by arcs.ID desc";
		else $ordersql=" order by arcs.sortrank desc";
		//
		//----------------------------
		$query = "Select arcs.ID,arcs.title,arcs.typeid,arcs.ismake,
		arcs.description,arcs.pubdate,arcs.senddate,arcs.arcrank,
		arcs.click,arcs.postnum,arcs.lastpost,arcs.money,arcs.litpic,t.typedir,t.typename,t.isdefault,
		t.defaultname,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl
		from `#@__archivesspec` arcs 
		left join #@__arctype t on arcs.typeid=t.ID
		where $orwhere $ordersql limit $limitstart,$row";
		$this->dsql->SetQuery($query);
		$this->dsql->Execute("al");
    $artlist = "";
    if($col>1) $artlist = "<table width='$tablewidth' border='0' cellspacing='0' cellpadding='0'>\r\n";
    $this->dtp2->LoadSource($innertext);
    for($i=0;$i<$row;$i++)
		{
       if($col>1) $artlist .= "<tr>\r\n";
       for($j=0;$j<$col;$j++)
			 {
         if($col>1) $artlist .= "<td width='$colWidth'>\r\n";
         if($row = $this->dsql->GetArray("al"))
         {
           //处理一些特殊字段
           $row["description"] = cnw_left($row["description"],$infolen);
           $row["title"] = cnw_left($row["title"],$titlelen);
           $row["id"] =  $row["ID"];
           if($row["litpic"]=="") $row["litpic"] = $GLOBALS["cfg_plus_dir"]."/img/dfpic.gif";
           $row["picname"] = $row["litpic"];
           $row["arcurl"] = GetFileUrl($row["ID"],$row["typeid"],$row["senddate"],$row["title"],
                        $row["ismake"],$row["arcrank"],$row["namerule"],$row["typedir"],$row["money"],true,$row["siteurl"]);
           $row["typeurl"] = $this->GetListUrl($row["typeid"],$row["typedir"],$row["isdefault"],$row["defaultname"],$row["ispart"],$row["namerule2"],$row["siteurl"]);
           $row["info"] = $row["description"];
           $row["filename"] = $row["arcurl"];
           $row["stime"] = GetDateMK($row["pubdate"]);
           $row["textlink"] = "<a href='".$row["filename"]."'>".$row["title"]."</a>";
           $row["typelink"] = "[<a href='".$row["typeurl"]."'>".$row["typename"]."</a>]"; 
           $row["imglink"] = "<a href='".$row["filename"]."'><img src='".$row["picname"]."' border='0' width='$imgwidth' height='$imgheight'></a>";
           $row["image"] = "<img src='".$row["picname"]."' border='0' width='$imgwidth' height='$imgheight'>";
           $row["phpurl"] = $GLOBALS["cfg_plus_dir"];
 		       $row["templeturl"] = $GLOBALS["cfg_templets_dir"];
 		       $row["memberurl"] = $GLOBALS["cfg_member_dir"];
           //编译附加表里的数据
           foreach($this->ChannelUnit->ChannelFields as $k=>$arr){
 		  	      if(isset($row[$k])) $row[$k] = $this->ChannelUnit->MakeField($k,$row[$k]);
 		  	   }
           //---------------------------
           if(is_array($this->dtp2->CTags)){
       	     foreach($this->dtp2->CTags as $k=>$ctag){
       		 	   if(isset($row[$ctag->GetName()])) $this->dtp2->Assign($k,$row[$ctag->GetName()]);
       		 	   else $this->dtp2->Assign($k,"");
       	    }
           }
           $artlist .= $this->dtp2->GetResult();
         }//if hasRow
         else{
         	 $artlist .= "";
         }
         if($col>1) $artlist .= "</td>\r\n";
       }//Loop Col
       if($col>1) $artlist .= "</tr>\r\n";
     }//Loop Line
     if($col>1) $artlist .= "</table>\r\n";
     $this->dsql->FreeResult("al");
     return $artlist;
  }
 /**
  *  获取上一篇,下一篇链接
  *
  * @access    public
  * @param     string  $gtype  获取类型  
  *                    pre:上一篇  preimg:上一篇图片  next:下一篇  nextimg:下一篇图片
  * @return    string
  */
 function GetPreNext($gtype = '')
 {
     $rs = '';
     if (count($this->PreNext) < 2) {
         $aid = $this->ArcID;
         $preR = $this->dsql->GetOne("Select id From `#@__arctiny` where id<{$aid} And arcrank>-1 And typeid='{$this->Fields['typeid']}' order by id desc");
         $nextR = $this->dsql->GetOne("Select id From `#@__arctiny` where id>{$aid} And arcrank>-1 And typeid='{$this->Fields['typeid']}' order by id asc");
         $next = is_array($nextR) ? " where arc.id={$nextR['id']} " : ' where 1>2 ';
         $pre = is_array($preR) ? " where arc.id={$preR['id']} " : ' where 1>2 ';
         $query = "Select arc.id,arc.title,arc.shorttitle,arc.typeid,arc.ismake,arc.senddate,arc.arcrank,arc.money,arc.filename,arc.litpic,\n                        t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath\n                        from `#@__archives` arc left join #@__arctype t on arc.typeid=t.id  ";
         $nextRow = $this->dsql->GetOne($query . $next);
         $preRow = $this->dsql->GetOne($query . $pre);
         if (is_array($preRow)) {
             $mlink = GetFileUrl($preRow['id'], $preRow['typeid'], $preRow['senddate'], $preRow['title'], $preRow['ismake'], $preRow['arcrank'], $preRow['namerule'], $preRow['typedir'], $preRow['money'], $preRow['filename'], $preRow['moresite'], $preRow['siteurl'], $preRow['sitepath']);
             $this->PreNext['pre'] = "<a href='{$mlink}'>{$preRow['title']}</a> ";
             $this->PreNext['preimg'] = "<a href='{$mlink}'><img src=\"{$preRow['litpic']}\" alt=\"{$preRow['title']}\"/></a> ";
         } else {
             $this->PreNext['pre'] = "<a href=''>没有了</a>";
             $this->PreNext['preimg'] = "<img src=\"/templets/default/images/nophoto.jpg\" alt=\"对不起,没有上一图集了!\"/>";
         }
         if (is_array($nextRow)) {
             $mlink = GetFileUrl($nextRow['id'], $nextRow['typeid'], $nextRow['senddate'], $nextRow['title'], $nextRow['ismake'], $nextRow['arcrank'], $nextRow['namerule'], $nextRow['typedir'], $nextRow['money'], $nextRow['filename'], $nextRow['moresite'], $nextRow['siteurl'], $nextRow['sitepath']);
             $this->PreNext['next'] = "<a href='{$mlink}'>{$nextRow['title']}</a> ";
             $this->PreNext['nextimg'] = "<a href='{$mlink}'><img src=\"{$nextRow['litpic']}\" alt=\"{$nextRow['title']}\"/></a> ";
         } else {
             $this->PreNext['next'] = "<a href=''>没有了</a>";
             $this->PreNext['nextimg'] = "<a href='javascript:void(0)' alt=\"\"><img src=\"/templets/default/images/nophoto.jpg\" alt=\"对不起,没有下一图集了!\"/></a>";
         }
     }
     if ($gtype == 'pre') {
         $rs = $this->PreNext['pre'];
     } else {
         if ($gtype == 'preimg') {
             $rs = $this->PreNext['preimg'];
         } else {
             if ($gtype == 'next') {
                 $rs = $this->PreNext['next'];
             } else {
                 if ($gtype == 'nextimg') {
                     $rs = $this->PreNext['nextimg'];
                 } else {
                     $rs = $this->PreNext['pre'] . " &nbsp; " . $this->PreNext['next'];
                 }
             }
         }
     }
     return $rs;
 }
Example #20
0
 function gettag($get, $post)
 {
     $name = $get['id'];
     if (!API_GETTAG) {
         return API_RETURN_FORBIDDEN;
     }
     //note 获取标签 API 接口
     $name = trim($name);
     if (empty($name) || !preg_match('/^([\\x7f-\\xff_-]|\\w|\\s)+$/', $name) || strlen($name) > 20) {
         return API_RETURN_FAILED;
     }
     $row = $this->db->GetOne("SELECT `total`,`id` FROM `#@__tagindex` WHERE `tag`='{$name}'");
     if (!is_array($row)) {
         return API_RETURN_FAILED;
     }
     $tpp = $row['total'] > 10 ? 10 : $row['total'];
     $ids = array();
     $this->db->SetQuery("SELECT aid FROM `#@__taglist` WHERE `tid`='{$row['id']}' AND arcrank>-1");
     $this->db->Execute();
     while ($row = $this->db->GetArray()) {
         $ids[] = $row['aid'];
     }
     if (empty($ids)) {
         return API_RETURN_FAILED;
     }
     $aids = implode(",", $ids);
     include_once DEDEINC . '/channelunit.func.php';
     $archives_list = array();
     $this->db->SetQuery("SELECT arc.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath \r\n\tFROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id WHERE arc.id IN({$aids}) ORDER BY id DESC LIMIT {$tpp}");
     $this->db->Execute();
     while ($row = $this->db->GetArray()) {
         $row['url'] = 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['url'] = !ereg('http:', $row['url']) ? $GLOBALS['cfg_basehost'] . $row['url'] : $row['url'];
         if (!empty($row['url'])) {
             $archives_list[] = array('title' => $row['title'], 'writer' => $row['writer'], 'pubdate' => $row['pubdate'], 'url' => $row['url']);
         }
     }
     $return = array($name, $archives_list);
     return $this->_serialize($return, 1);
 }
Example #21
0
function GetOneArchive($aid)
{
    global $dsql;
    include_once DEDEINC . "/channelunit.func.php";
    $aid = trim(ereg_replace('[^0-9]', '', $aid));
    $reArr = array();
    $chRow = $dsql->GetOne("Select arc.*,ch.maintable,ch.addtable,ch.issystem From `#@__arctiny` arc left join `#@__channeltype` ch on ch.id=arc.channel where arc.id='{$aid}' ");
    if (!is_array($chRow)) {
        return $reArr;
    } else {
        if (empty($chRow['maintable'])) {
            $chRow['maintable'] = '#@__archives';
        }
    }
    if ($chRow['issystem'] != -1) {
        $nquery = " Select arc.*,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath\r\n\t\t            From `{$chRow['maintable']}` arc left join `#@__arctype` tp on tp.id=arc.typeid\r\n\t\t            where arc.id='{$aid}' ";
    } else {
        $nquery = " Select arc.*,1 as ismake,0 as money,'' as filename,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath\r\n\t\t            From `{$chRow['addtable']}` arc left join `#@__arctype` tp on tp.id=arc.typeid\r\n\t\t            where arc.aid='{$aid}' ";
    }
    $arcRow = $dsql->GetOne($nquery);
    if (!is_array($arcRow)) {
        return $reArr;
    }
    if (!isset($arcRow['description'])) {
        $arcRow['description'] = '';
    }
    if (empty($arcRow['description']) && isset($arcRow['body'])) {
        $arcRow['description'] = cn_substr(html2text($arcRow['body']), 250);
    }
    if (!isset($arcRow['pubdate'])) {
        $arcRow['pubdate'] = $arcRow['senddate'];
    }
    if (!isset($arcRow['notpost'])) {
        $arcRow['notpost'] = 0;
    }
    $reArr = $arcRow;
    $reArr['aid'] = $aid;
    $reArr['topid'] = $arcRow['topid'];
    $reArr['arctitle'] = $arcRow['title'];
    $reArr['arcurl'] = GetFileUrl($aid, $arcRow['typeid'], $arcRow['senddate'], $reArr['title'], $arcRow['ismake'], $arcRow['arcrank'], $arcRow['namerule'], $arcRow['typedir'], $arcRow['money'], $arcRow['filename'], $arcRow['moresite'], $arcRow['siteurl'], $arcRow['sitepath']);
    return $reArr;
}
		}
		$truevalue = $ctag->GetInnerText();
		$tmpSql1 = str_replace('@#'.$tvalue.'#@',addslashes(trim($truevalue)),$tmpSql1);
		if($tablename2!=''){
    	$tmpSql2 = str_replace('@#'.$tvalue.'#@',addslashes(trim($truevalue)),$tmpSql2);
    }
	}
	if($isbreak) continue;
	if($pubdate==0) $pubdate = $senddate;
	$tmpSql1 = ereg_replace('@#(.*)#@','',$tmpSql1);
	$tmpSql2 = ereg_replace('@#(.*)#@','',$tmpSql2);
	
	//这里的规则仅针对当前系统,如果其它系统,需修改这里的逻辑
	$arcid = GetIndexKey($dsql,$typeid,$channelid);
	if($smakeid==0) $smakeid = $arcid;
	$fileurl = GetFileUrl($arcid,$typeid,$senddate,$title,1,0,$typeinfos['namerule'],$typeinfos['typedir'],0,true,$typeinfos['siteurl']);
	$dsql->ExecuteNoneQuery("Update `#@__full_search` set url='".addslashes($fileurl)."',uptime='$senddate',pubdate='$pubdate' where aid='$arcid' ");
	
	$tmpSql1 = str_replace("@$autofield@",$arcid,$tmpSql1);
	$rs = $dsql->ExecuteNoneQuery($tmpSql1);
	
	if($rs){
		if($tablename2!=""){
			  $tmpSql2 = str_replace("@$synfield@",$arcid,$tmpSql2);
			  $rs = $dsql->ExecuteNoneQuery($tmpSql2);
			  if(!$rs){
				  $dsql->ExecuteNoneQuery("Delete From `#@__full_search` where aid='$arcid' ");
				  $dsql->ExecuteNoneQuery("Delete From `$tablename1` where $autofield='$arcid'");
			  }else{
			  	$dsql->ExecuteNoneQuery("update `#@__courl` set isex=1 where aid='$aid'");
			  }
Example #23
0
 /**
  *  获取内容列表
  *
  * @access    public
  * @param     int  $limitstart  限制开始  
  * @param     int  $row  行数 
  * @param     int  $col  列数
  * @param     int  $titlelen  标题长度
  * @param     int  $infolen  描述长度
  * @param     int  $imgwidth  图片宽度
  * @param     int  $imgheight  图片高度
  * @param     string  $listtype  列表类型
  * @param     string  $orderby  排列顺序
  * @param     string  $innertext  底层模板
  * @param     string  $tablewidth  表格宽度
  * @return    string
  */
 function GetArcList($limitstart = 0, $row = 10, $col = 1, $titlelen = 30, $infolen = 250, $imgwidth = 120, $imgheight = 90, $listtype = "all", $orderby = "default", $innertext = "", $tablewidth = "100")
 {
     $typeid = $this->TypeID;
     if ($row == "") {
         $row = 10;
     }
     if ($limitstart == "") {
         $limitstart = 0;
     }
     if ($titlelen == "") {
         $titlelen = 30;
     }
     if ($infolen == "") {
         $infolen = 250;
     }
     if ($imgwidth == "") {
         $imgwidth = 120;
     }
     if ($imgheight == "") {
         $imgheight = 120;
     }
     if ($listtype == "") {
         $listtype = "all";
     }
     if ($orderby == "") {
         $orderby = "default";
     } else {
         $orderby = strtolower($orderby);
     }
     $tablewidth = str_replace("%", "", $tablewidth);
     if ($tablewidth == "") {
         $tablewidth = 100;
     }
     if ($col == "") {
         $col = 1;
     }
     $colWidth = ceil(100 / $col);
     $tablewidth = $tablewidth . "%";
     $colWidth = $colWidth . "%";
     $innertext = trim($innertext);
     if ($innertext == "") {
         $innertext = GetSysTemplets("spec_list.htm");
     }
     //按不同情况设定SQL条件
     $orwhere = " arc.arcrank > -1 AND arc.channel = -1 ";
     if ($this->StartTime > 0) {
         $orwhere .= " AND arc.senddate>'" . $this->StartTime . "'";
     }
     //排序方式
     $ordersql = '';
     if ($orderby == 'senddate') {
         $ordersql = " ORDER BY arc.senddate desc";
     } else {
         if ($orderby == 'pubdate') {
             $ordersql = " ORDER BY arc.pubdate desc";
         } else {
             if ($orderby == 'id') {
                 $ordersql = "  ORDER BY arc.id desc";
             } else {
                 $ordersql = " ORDER BY arc.sortrank desc";
             }
         }
     }
     $query = "SELECT arc.*,tp.typedir,tp.typename,tp.isdefault,arc.money,\r\n            tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\r\n            FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\r\n            WHERE {$orwhere} {$ordersql} LIMIT {$limitstart},{$row} ";
     $this->dsql->SetQuery($query);
     $this->dsql->Execute('al');
     $artlist = '';
     if ($col > 1) {
         $artlist = "<table width='{$tablewidth}' border='0' cellspacing='0' cellpadding='0'>\r\n";
     }
     $this->dtp2->LoadSource($innertext);
     for ($i = 0; $i < $row; $i++) {
         if ($col > 1) {
             $artlist .= "<tr>\r\n";
         }
         for ($j = 0; $j < $col; $j++) {
             if ($col > 1) {
                 $artlist .= "<td width='{$colWidth}'>\r\n";
             }
             if ($row = $this->dsql->GetArray("al")) {
                 //处理一些特殊字段
                 $row["description"] = cn_substr($row["description"], $infolen);
                 $row["title"] = cn_substr($row["title"], $titlelen);
                 $row["id"] = $row["id"];
                 if ($row['litpic'] == '-' || $row['litpic'] == '') {
                     $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
                 }
                 if (!preg_match("/^http:\\/\\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
                     $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
                 }
                 $row['picname'] = $row['litpic'];
                 $row["arcurl"] = GetFileUrl($row["id"], $row["typeid"], $row["senddate"], $row["title"], $row["ismake"], $row["arcrank"], $row["namerule"], $row["typedir"], $row["money"], $row['filename'], $row["moresite"], $row["siteurl"], $row["sitepath"]);
                 $row["typeurl"] = GetTypeUrl($row["typeid"], $row["typedir"], $row["isdefault"], $row["defaultname"], $row["ispart"], $row["namerule2"], $row["moresite"], $row["siteurl"], $row["sitepath"]);
                 $row["info"] = $row["description"];
                 $row["filename"] = $row["arcurl"];
                 $row["stime"] = GetDateMK($row["pubdate"]);
                 $row["textlink"] = "<a href='" . $row["filename"] . "'>" . $row["title"] . "</a>";
                 $row["typelink"] = "[<a href='" . $row["typeurl"] . "'>" . $row["typename"] . "</a>]";
                 $row["imglink"] = "<a href='" . $row["filename"] . "'><img src='" . $row["picname"] . "' border='0' width='{$imgwidth}' height='{$imgheight}'></a>";
                 $row["image"] = "<img src='" . $row["picname"] . "' border='0' width='{$imgwidth}' height='{$imgheight}'>";
                 $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                 $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                 $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                 //编译附加表里的数据
                 foreach ($this->ChannelUnit->ChannelFields as $k => $arr) {
                     if (isset($row[$k])) {
                         $row[$k] = $this->ChannelUnit->MakeField($k, $row[$k]);
                     }
                 }
                 if (is_array($this->dtp2->CTags)) {
                     foreach ($this->dtp2->CTags as $k => $ctag) {
                         if ($ctag->GetName() == 'array') {
                             //传递整个数组,在runphp模式中有特殊作用
                             $this->dtp2->Assign($k, $row);
                         } else {
                             if (isset($row[$ctag->GetName()])) {
                                 $this->dtp2->Assign($k, $row[$ctag->GetName()]);
                             } else {
                                 $this->dtp2->Assign($k, '');
                             }
                         }
                     }
                 }
                 $artlist .= $this->dtp2->GetResult();
             } else {
                 $artlist .= "";
             }
             if ($col > 1) {
                 $artlist .= "</td>\r\n";
             }
         }
         //Loop Col
         if ($col > 1) {
             $artlist .= "</tr>\r\n";
         }
     }
     //Loop Line
     if ($col > 1) {
         $artlist .= "</table>\r\n";
     }
     $this->dsql->FreeResult("al");
     return $artlist;
 }
Example #24
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;
}
Example #25
0
 /**
  *  获得一个单列的文档列表
  *
  * @access    public
  * @param     int  $limitstart  限制开始  
  * @param     int  $row  行数 
  * @param     int  $col  列数
  * @param     int  $titlelen  标题长度
  * @param     int  $infolen  描述长度
  * @param     int  $imgwidth  图片宽度
  * @param     int  $imgheight  图片高度
  * @param     string  $listtype  列表类型
  * @param     string  $orderby  排列顺序
  * @param     string  $innertext  底层模板
  * @param     string  $tablewidth  表格宽度
  * @param     string  $ismake  是否编译
  * @param     string  $orderWay  排序方式
  * @return    string
  */
 function GetArcList($limitstart = 0, $row = 10, $col = 1, $titlelen = 30, $infolen = 250, $imgwidth = 120, $imgheight = 90, $listtype = "all", $orderby = "default", $innertext = "", $tablewidth = "100", $ismake = 1, $orderWay = 'desc')
 {
     global $cfg_list_son, $cfg_digg_update;
     $typeid = $this->TypeID;
     if ($row == '') {
         $row = 10;
     }
     if ($limitstart == '') {
         $limitstart = 0;
     }
     if ($titlelen == '') {
         $titlelen = 100;
     }
     if ($infolen == '') {
         $infolen = 250;
     }
     if ($imgwidth == '') {
         $imgwidth = 120;
     }
     if ($imgheight == '') {
         $imgheight = 120;
     }
     if ($listtype == '') {
         $listtype = 'all';
     }
     if ($orderWay == '') {
         $orderWay = 'desc';
     }
     if ($orderby == '') {
         $orderby = 'default';
     } else {
         $orderby = strtolower($orderby);
     }
     $tablewidth = str_replace('%', '', $tablewidth);
     if ($tablewidth == '') {
         $tablewidth = 100;
     }
     if ($col == '') {
         $col = 1;
     }
     $colWidth = ceil(100 / $col);
     $tablewidth = $tablewidth . '%';
     $colWidth = $colWidth . '%';
     $innertext = trim($innertext);
     if ($innertext == '') {
         $innertext = GetSysTemplets('list_fulllist.htm');
     }
     //排序方式
     $ordersql = '';
     if ($orderby == "senddate" || $orderby == "id") {
         $ordersql = " ORDER BY arc.id {$orderWay}";
     } else {
         if ($orderby == "hot" || $orderby == "click") {
             $ordersql = " ORDER BY arc.click {$orderWay}";
         } else {
             if ($orderby == "lastpost") {
                 $ordersql = "  ORDER BY arc.lastpost {$orderWay}";
             } else {
                 $ordersql = " ORDER BY arc.sortrank {$orderWay}";
             }
         }
     }
     //获得附加表的相关信息
     $addtable = $this->ChannelUnit->ChannelInfos['addtable'];
     if ($addtable != "") {
         $addJoin = " LEFT JOIN `{$addtable}` ON arc.id = " . $addtable . '.aid ';
         $addField = '';
         $fields = explode(',', $this->ChannelUnit->ChannelInfos['listfields']);
         foreach ($fields as $k => $v) {
             $nfields[$v] = $k;
         }
         if (is_array($this->ChannelUnit->ChannelFields) && !empty($this->ChannelUnit->ChannelFields)) {
             foreach ($this->ChannelUnit->ChannelFields as $k => $arr) {
                 if (isset($nfields[$k])) {
                     if (!empty($arr['rename'])) {
                         $addField .= ',' . $addtable . '.' . $k . ' as ' . $arr['rename'];
                     } else {
                         $addField .= ',' . $addtable . '.' . $k;
                     }
                 }
             }
         }
     } else {
         $addField = '';
         $addJoin = '';
     }
     //如果不用默认的sortrank或id排序,使用联合查询(数据量大时非常缓慢)
     if (preg_match('/hot|click|lastpost/', $orderby)) {
         $query = "SELECT arc.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,\n           tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\n           {$addField}\n           FROM `#@__archives` arc\n           LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\n           {$addJoin}\n           WHERE {$this->addSql} {$ordersql} LIMIT {$limitstart},{$row}";
     } else {
         $t1 = ExecTime();
         $ids = array();
         $query = "SELECT id FROM `#@__arctiny` arc WHERE {$this->addSql} {$ordersql} LIMIT {$limitstart},{$row} ";
         $this->dsql->SetQuery($query);
         $this->dsql->Execute();
         while ($arr = $this->dsql->GetArray()) {
             $ids[] = $arr['id'];
         }
         $idstr = join(',', $ids);
         if ($idstr == '') {
             return '';
         } else {
             $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,\n                       tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\n                       {$addField}\n                       FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\n                       {$addJoin}\n                       WHERE arc.id in({$idstr}) {$ordersql} ";
         }
         $t2 = ExecTime();
         //echo $t2-$t1;
     }
     $this->dsql->SetQuery($query);
     $this->dsql->Execute('al');
     $t2 = ExecTime();
     //echo $t2-$t1;
     $artlist = '';
     $this->dtp2->LoadSource($innertext);
     $GLOBALS['autoindex'] = 0;
     for ($i = 0; $i < $row; $i++) {
         if ($col > 1) {
             $artlist .= "<div>\r\n";
         }
         for ($j = 0; $j < $col; $j++) {
             if ($row = $this->dsql->GetArray("al")) {
                 $GLOBALS['autoindex']++;
                 $ids[$row['id']] = $row['id'];
                 //处理一些特殊字段
                 $row['infos'] = cn_substr($row['description'], $infolen);
                 $row['id'] = $row['id'];
                 if ($cfg_digg_update > 0) {
                     $prefix = 'diggCache';
                     $key = 'aid-' . $row['id'];
                     $cacherow = GetCache($prefix, $key);
                     $row['goodpost'] = $cacherow['goodpost'];
                     $row['badpost'] = $cacherow['badpost'];
                     $row['scores'] = $cacherow['scores'];
                 }
                 if ($row['corank'] > 0 && $row['arcrank'] == 0) {
                     $row['arcrank'] = $row['corank'];
                 }
                 $row['filename'] = $row['arcurl'] = GetFileUrl($row['id'], $row['typeid'], $row['senddate'], $row['title'], $row['ismake'], $row['arcrank'], $row['namerule'], $row['typedir'], $row['money'], $row['filename'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                 $row['typeurl'] = GetTypeUrl($row['typeid'], MfTypedir($row['typedir']), $row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                 if ($row['litpic'] == '-' || $row['litpic'] == '') {
                     $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
                 }
                 if (!preg_match("/^http:\\/\\//i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
                     $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
                 }
                 $row['picname'] = $row['litpic'];
                 $row['stime'] = GetDateMK($row['pubdate']);
                 $row['typelink'] = "<a href='" . $row['typeurl'] . "'>" . $row['typename'] . "</a>";
                 $row['image'] = "<img src='" . $row['picname'] . "' border='0' width='{$imgwidth}' height='{$imgheight}' alt='" . preg_replace("/['><]/", "", $row['title']) . "'>";
                 $row['imglink'] = "<a href='" . $row['filename'] . "'>" . $row['image'] . "</a>";
                 $row['fulltitle'] = $row['title'];
                 $row['title'] = cn_substr($row['title'], $titlelen);
                 if ($row['color'] != '') {
                     $row['title'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
                 }
                 if (preg_match('/c/', $row['flag'])) {
                     $row['title'] = "<b>" . $row['title'] . "</b>";
                 }
                 $row['textlink'] = "<a href='" . $row['filename'] . "'>" . $row['title'] . "</a>";
                 $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                 $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                 $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                 //编译附加表里的数据
                 foreach ($row as $k => $v) {
                     $row[strtolower($k)] = $v;
                 }
                 foreach ($this->ChannelUnit->ChannelFields as $k => $arr) {
                     if (isset($row[$k])) {
                         $row[$k] = $this->ChannelUnit->MakeField($k, $row[$k]);
                     }
                 }
                 if (is_array($this->dtp2->CTags)) {
                     foreach ($this->dtp2->CTags as $k => $ctag) {
                         if ($ctag->GetName() == 'array') {
                             //传递整个数组,在runphp模式中有特殊作用
                             $this->dtp2->Assign($k, $row);
                         } else {
                             if (isset($row[$ctag->GetName()])) {
                                 $this->dtp2->Assign($k, $row[$ctag->GetName()]);
                             } else {
                                 $this->dtp2->Assign($k, '');
                             }
                         }
                     }
                 }
                 $artlist .= $this->dtp2->GetResult();
             }
             //if hasRow
         }
         //Loop Col
         if ($col > 1) {
             $i += $col - 1;
             $artlist .= "    </div>\r\n";
         }
     }
     //Loop Line
     $t3 = ExecTime();
     //echo ($t3-$t2);
     $this->dsql->FreeResult('al');
     return $artlist;
 }
 function GetArcList($limitstart = 0, $row = 10, $col = 1, $titlelen = 30, $infolen = 250, $imgwidth = 120, $imgheight = 90, $achanneltype = "all", $orderby = "default", $innertext = "", $tablewidth = "100")
 {
     $typeid = $this->TypeID;
     if ($row == '') {
         $row = 10;
     }
     if ($limitstart == '') {
         $limitstart = 0;
     }
     if ($titlelen == '') {
         $titlelen = 30;
     }
     if ($infolen == '') {
         $infolen = 250;
     }
     if ($imgwidth == '') {
         $imgwidth = 120;
     }
     if ($imgheight = '') {
         $imgheight = 120;
     }
     if ($achanneltype == '') {
         $achanneltype = '0';
     }
     $orderby = $orderby == '' ? 'default' : strtolower($orderby);
     $tablewidth = str_replace("%", "", $tablewidth);
     if ($tablewidth == '') {
         $tablewidth = 100;
     }
     if ($col == '') {
         $col = 1;
     }
     $colWidth = ceil(100 / $col);
     $tablewidth = $tablewidth . "%";
     $colWidth = $colWidth . "%";
     $innertext = trim($innertext);
     if ($innertext == '') {
         $innertext = GetSysTemplets("search_list.htm");
     }
     //排序方式
     $ordersql = '';
     if ($orderby == "senddate") {
         $ordersql = " order by arc.senddate desc";
     } else {
         if ($orderby == "pubdate") {
             $ordersql = " order by arc.pubdate desc";
         } else {
             if ($orderby == "id") {
                 $ordersql = "  order by arc.id desc";
             } else {
                 $ordersql = " order by arc.sortrank desc";
             }
         }
     }
     //搜索
     $query = "Select arc.*,act.typedir,act.typename,act.isdefault,act.defaultname,act.namerule,\r\n\t\tact.namerule2,act.ispart,act.moresite,act.siteurl,act.sitepath\r\n\t\tfrom `#@__archives` arc left join `#@__arctype` act on arc.typeid=act.id\r\n\t\twhere {$this->AddSql} {$ordersql} limit {$limitstart},{$row}";
     $this->dsql->SetQuery($query);
     $this->dsql->Execute("al");
     $artlist = "";
     if ($col > 1) {
         $artlist = "<table width='{$tablewidth}' border='0' cellspacing='0' cellpadding='0'>\r\n";
     }
     $this->dtp2->LoadSource($innertext);
     for ($i = 0; $i < $row; $i++) {
         if ($col > 1) {
             $artlist .= "<tr>\r\n";
         }
         for ($j = 0; $j < $col; $j++) {
             if ($col > 1) {
                 $artlist .= "<td width='{$colWidth}'>\r\n";
             }
             if ($row = $this->dsql->GetArray("al")) {
                 //处理一些特殊字段
                 $row["arcurl"] = GetFileUrl($row["id"], $row["typeid"], $row["senddate"], $row["title"], $row["ismake"], $row["arcrank"], $row["namerule"], $row["typedir"], $row["money"], $row['filename'], $row["moresite"], $row["siteurl"], $row["sitepath"]);
                 $row["description"] = $this->GetRedKeyWord(cn_substr($row["description"], $infolen));
                 $row["title"] = $this->GetRedKeyWord(cn_substr($row["title"], $titlelen));
                 $row["id"] = $row["id"];
                 if ($row['litpic'] == '-' || $row['litpic'] == '') {
                     $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
                 }
                 if (!eregi("^http://", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
                     $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
                 }
                 $row['picname'] = $row['litpic'];
                 $row["typeurl"] = GetTypeUrl($row["typeid"], $row["typedir"], $row["isdefault"], $row["defaultname"], $row["ispart"], $row["namerule2"], $row["moresite"], $row["siteurl"], $row["sitepath"]);
                 $row["info"] = $row["description"];
                 $row["filename"] = $row["arcurl"];
                 $row["stime"] = GetDateMK($row["pubdate"]);
                 $row["textlink"] = "<a href='" . $row["filename"] . "'>" . $row["title"] . "</a>";
                 $row["typelink"] = "[<a href='" . $row["typeurl"] . "'>" . $row["typename"] . "</a>]";
                 $row["imglink"] = "<a href='" . $row["filename"] . "'><img src='" . $row["picname"] . "' border='0' width='{$imgwidth}' height='{$imgheight}'></a>";
                 $row["image"] = "<img src='" . $row["picname"] . "' border='0' width='{$imgwidth}' height='{$imgheight}'>";
                 $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                 $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                 $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                 if (is_array($this->dtp2->CTags)) {
                     foreach ($this->dtp2->CTags as $k => $ctag) {
                         if ($ctag->GetName() == 'array') {
                             //传递整个数组,在runphp模式中有特殊作用
                             $this->dtp2->Assign($k, $row);
                         } else {
                             if (isset($row[$ctag->GetName()])) {
                                 $this->dtp2->Assign($k, $row[$ctag->GetName()]);
                             } else {
                                 $this->dtp2->Assign($k, '');
                             }
                         }
                     }
                 }
                 $artlist .= $this->dtp2->GetResult();
             } else {
                 $artlist .= "";
             }
             if ($col > 1) {
                 $artlist .= "</td>\r\n";
             }
         }
         //Loop Col
         if ($col > 1) {
             $artlist .= "</tr>\r\n";
         }
     }
     //Loop Line
     if ($col > 1) {
         $artlist .= "</table>\r\n";
     }
     $this->dsql->FreeResult("al");
     return $artlist;
 }
         $arcRow['id'] = $aid;
         $arcRow['typeid'] = $trow['typeid'];
         $arcRow['senddate'] = $trow['senddate'];
         $arcRow['title'] = '';
         $arcRow['ismake'] = 1;
         $arcRow['arcrank'] = $trow['corank'];
         $arcRow['namerule'] = $trow['namerule'];
         $arcRow['typedir'] = $trow['typedir'];
         $arcRow['money'] = 0;
         $arcRow['filename'] = '';
         $arcRow['moresite'] = $trow['moresite'];
         $arcRow['siteurl'] = $trow['siteurl'];
         $arcRow['sitepath'] = $trow['sitepath'];
     }
     $arcurl = GetFileUrl($arcRow['id'], $arcRow['typeid'], $arcRow['senddate'], $arcRow['title'], $arcRow['ismake'], $arcRow['arcrank'], $arcRow['namerule'], $arcRow['typedir'], $arcRow['money'], $arcRow['filename'], $arcRow['moresite'], $arcRow['siteurl'], $arcRow['sitepath']);
     $arcfile = GetFileUrl($arcRow['id'], $arcRow['typeid'], $arcRow['senddate'], $arcRow['title'], $arcRow['ismake'], $arcRow['arcrank'], $arcRow['namerule'], $arcRow['typedir'], $arcRow['money'], $arcRow['filename']);
     if (preg_match("#^http:#", $arcfile)) {
         $arcfile = preg_replace("#^http:\\/\\/([^\\/]*)\\/#i", '/', $arcfile);
     }
     $truefile = GetTruePath() . $arcfile;
     if (!file_exists($truefile)) {
         MakeArt($aid, TRUE);
     }
     echo "<script language='javascript'>location.href='{$arcurl}" . "?" . time() . "';</script>";
     exit;
 } else {
     if ($dopost == "uploadLitpic") {
         $upfile = AdminUpload('litpic', 'imagelit', 0, false);
         if ($upfile == '-1') {
             $msg = "<script language='javascript'>\n                parent.document.getElementById('uploadwait').style.display = 'none';\n                alert('你没指定要上传的文件或文件大小超过限制!');\n            </script>";
         } else {
Example #28
0
 function GetArcUrl($aid, $typeid, $timetag, $title, $ismake = 0, $rank = 0, $namerule = '', $artdir = '', $money = 0, $filename = '', $moresite = '', $siteurl = '', $sitepath = '')
 {
     return GetFileUrl($aid, $typeid, $timetag, $title, $ismake, $rank, $namerule, $artdir, $money, $filename, $moresite, $siteurl, $sitepath);
 }
Example #29
0
if (isset($arcID)) {
    $aid = $arcID;
}
$arcID = $aid = isset($aid) && is_numeric($aid) ? $aid : 0;
if ($aid == 0) {
    die(" Request Error! ");
}
//读取文档信息
$arctitle = '';
$arcurl = '';
$topid = 0;
$arcRow = $dsql->GetOne("SELECT arc.title,arc.senddate,arc.arcrank,arc.ismake,arc.money,arc.typeid,tp.topid,tp.typedir,tp.namerule,\r\n                 tp.moresite,tp.siteurl,tp.sitepath FROM `#@__archives` arc  LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid WHERE arc.id='{$aid}'");
if (is_array($arcRow)) {
    $arctitle = $arcRow['title'];
    $topid = $arcRow['topid'];
    $arcurl = @GetFileUrl($aid, $arcRow['typeid'], $arcRow['senddate'], $arctitle, $arcRow['ismake'], $arcRow['arcrank'], $arcRow['namerule'], $arcRow['typedir'], $arcRow['money'], $arcRow['filename'], $arcRow['moresite'], $arcRow['siteurl'], $arcRow['sitepath']);
} else {
    ShowMsg('无法浏览未知文档!', '-1');
    exit;
}
if (empty($mx)) {
    $mx = $cfg_album_width;
}
$pageGuide = "";
//获取上下幅图片链接
$row = $dsql->GetOne("SELECT imgurls FROM `#@__addonimages` WHERE aid='{$aid}'");
$i = 0;
$nextSrc = '';
$preSrc = '';
$dtp = new DedeTagParse();
$dtp->LoadSource($row['imgurls']);
Example #30
0
 /**
  * 获得最差或最好的踩踩文章
  *
  * @param array $atts
  * @param object $refObj
  * @param array $fields
  * @return array
  */
 function GetSortArc($atts, $refObj = '', $fields = array())
 {
     $arcrow = empty($atts['row']) ? 12 : $atts['row'];
     $order = empty($atts['order']) ? 'scores' : $atts['order'];
     $orderway = empty($atts['orderway']) ? 'desc' : $atts['orderway'];
     if (empty($arcrow)) {
         $arcrow = 12;
     }
     $query = "SELECT arc.*,tp.typedir,tp.typename,\n              tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\n          FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON tp.id = arc.typeid\n          WHERE arc.arcrank>-1 ORDER BY arc.{$order} {$orderway} LIMIT 0,{$arcrow} ";
     $rsArray = array();
     $cacheFile = DEDEDATA . '/cache/caicai_' . md5($query) . '.inc';
     $needCache = false;
     if (file_exists($cacheFile) && filemtime($cacheFile) - time() < $this->arcCacheTime) {
         $fp = fopen($cacheFile, 'r');
         $ids = fread($fp, filesize($cacheFile));
         fclose($fp);
         $ids = trim($ids);
         if (!empty($ids)) {
             $query = "SELECT arc.*,tp.typedir,tp.typename,\n              tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\n          FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid\n          WHERE arc.id in({$ids}) ORDER BY arc.{$order} {$orderway} ";
         }
     } else {
         $needCache = true;
     }
     $ids = array();
     $i = 0;
     $this->dsql->Execute('cai', $query);
     while ($arr = $this->dsql->GetArray('cai')) {
         $i++;
         $ids[] = $arr['id'];
         $arr['filename'] = $arr['arcurl'] = GetFileUrl($arr['id'], $arr['typeid'], $arr['senddate'], $arr['title'], $arr['ismake'], $arr['arcrank'], $arr['namerule'], $arr['typedir'], $arr['money'], $arr['filename'], $arr['moresite'], $arr['siteurl'], $arr['sitepath']);
         $arr['typeurl'] = GetTypeUrl($arr['typeid'], MfTypedir($arr['typedir']), $arr['isdefault'], $arr['defaultname'], $arr['ispart'], $arr['namerule2'], $arr['moresite'], $arr['siteurl'], $arr['sitepath']);
         if ($arr['litpic'] == '') {
             $arr['litpic'] = '/images/defaultpic.gif';
         }
         if (!preg_match("#^http:\\/\\/#", $arr['litpic'])) {
             $arr['picname'] = $arr['litpic'] = $GLOBALS['cfg_cmsurl'] . $arr['litpic'];
         } else {
             $arr['picname'] = $arr['litpic'] = $arr['litpic'];
         }
         $rsArray[$i] = $arr;
     }
     $this->dsql->FreeResult('cai');
     //写入缓存
     if ($needCache && count($ids) > 0) {
         $idsstr = join(',', $ids);
         file_put_contents($cacheFile, $idsstr);
         // $fp = fopen($cacheFile, 'w');
         // fwrite($fp, $idsstr);
         // fclose($fp);
     }
     return $rsArray;
 }