예제 #1
0
function lib_changyan(&$ctag, &$refObj)
{
    global $dsql, $envs;
    //属性处理
    $attlist = "type|code,config|,class|_DEDECY,style|";
    FillAttsDefault($ctag->CAttribute->Items, $attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $reval = "";
    if (!$dsql->IsTable("#@__plus_changyan_setting")) {
        return '没安装畅言模块';
    }
    $client_id = changyan_get_setting('appid');
    if (empty($client_id)) {
        return '尚未注册畅言帐号,请到后台注册';
    }
    if ($type == 'code' or $type == 'code2') {
        $reval .= "<div class='{$class}' style='{$style}'>";
        $prefix = 'changyan';
        $key = 'code';
        $row = GetCache($prefix, $key);
        if (!is_array($row)) {
            $appid = changyan_get_setting('appid');
            $user = changyan_get_setting('user');
            $sign = changyan_gen_sign($user);
            $result = changyan_getcode(CHANGYAN_CLIENT_ID, $user, false, $sign, $appid);
            $row['reval'] = htmlspecialchars($result['code']);
            SetCache($prefix, $key, $row, 60 * 60 * 1);
        }
        if (!empty($config)) {
            $config_arr = array();
            $configs = explode(',', $config);
            if (count($configs) > 0) {
                foreach ($configs as $c) {
                    $item = explode(':', $c);
                    $config_arr[$item[0]] = $item[1];
                }
            }
            $config_str = json_encode($config_arr);
            $reval .= <<<EOT
<script>
    var_config={$config_str};
</script>
EOT;
        }
        $reval .= htmlspecialchars_decode($row['reval']);
        $reval = str_replace("id='SOHUCS'", "id='SOHUCS' sid='{$refObj->ArcID}'", $reval);
        if ($type == 'code2') {
            $reval = preg_replace("#window.SCS_NO_IFRAME[ ]?=[ ]?true;#i", "", $reval);
        }
        $reval = str_replace("<script>", "</div><script>", $reval);
    } elseif ($type == 'count') {
        if (!$GLOBALS['changyan_count_js']) {
            $reval .= "<script type=\"text/javascript\" src=\"http://assets.changyan.sohu.com/upload/plugins/plugins.count.js\"></script>";
        }
        $reval .= "<a href=\"#SOHUCS\" id=\"changyan_count_unit\"></a>";
        $GLOBALS['changyan_count_js'] = TRUE;
    }
    return $reval;
}
예제 #2
0
 * @package        DedeCMS.Plus
 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
 * @license        http://help.dedecms.com/usersguide/license.html
 * @link           http://www.dedecms.com
 */
require_once dirname(__FILE__) . "/../include/common.inc.php";
$action = isset($action) ? trim($action) : '';
$id = empty($id) ? 0 : intval(preg_replace("/[^\\d]/", '', $id));
helper('cache');
if ($id < 1) {
    exit;
}
$maintable = '#@__archives';
$prefix = 'diggCache';
$key = 'aid-' . $id;
$row = GetCache($prefix, $key);
if (!is_array($row) || $cfg_digg_update == 0) {
    $row = $dsql->GetOne("SELECT goodpost,badpost,scores FROM `{$maintable}` WHERE id='{$id}' ");
    if ($cfg_digg_update == 0) {
        if ($action == 'good') {
            $row['goodpost'] = $row['goodpost'] + 1;
            $dsql->ExecuteNoneQuery("UPDATE `{$maintable}` SET scores = scores + {$cfg_caicai_add},goodpost=goodpost+1,lastpost=" . time() . " WHERE id='{$id}'");
        } else {
            if ($action == 'bad') {
                $row['badpost'] = $row['badpost'] + 1;
                $dsql->ExecuteNoneQuery("UPDATE `{$maintable}` SET scores = scores - {$cfg_caicai_sub},badpost=badpost+1,lastpost=" . time() . " WHERE id='{$id}'");
            }
        }
        DelCache($prefix, $key);
    }
    SetCache($prefix, $key, $row, 0);
예제 #3
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;
 }
예제 #4
0
파일: config.php 프로젝트: cwcw/cms
 function GetMemberName($mid = 0)
 {
     global $dsql;
     $rs = GetCache('memberlogin', $mid);
     if (empty($rs)) {
         $rs = $dsql->GetOne("SELECT * FROM `#@__member` WHERE mid='{$mid}' ");
         SetCache('memberlogin', $mid, $rs, 1800);
     }
     return $rs['uname'];
 }
예제 #5
0
파일: hotel.php 프로젝트: holin/sstour
<?php

if ($actionhtml = GetCache($action)) {
    include_once $actionhtml;
    include_once Getincludefun("html");
    $smarty->assign('cache_config', $cache_config);
}
if ($option == 'index') {
    $smarty->assign('config', array('title' => "{$cache_config['subject']}", 'keywords' => $config['keywords'] . "_{$cache_config['subject']}", 'description' => $config['description'] . "_{$cache_config['subject']}"));
    $nCount = $cache_config['numser'] ? $cache_config['numser'] : "20";
    $cParameter = "action={$action}&option={$option}&id={$id}&Industry={$Industry}&Keyword={$Keyword}";
    include_once Getincludefun("page");
    if ($Keyword) {
        fgetposttoupdatd($Keyword, $ODBC['charset']);
        $where = "`hot_subject` LIKE '%{$Keyword}%' AND `hot_pass`='1'";
    } else {
        $where = "`hot_pass`='1'";
    }
    $nNums = $GETSQL->fNumrows("SELECT hot_id FROM `{$ODBC['tablepre']}hotel` WHERE {$where}");
    if ($nNums > 0) {
        $sql_hotel = $GETSQL->fSql("hot_id,hot_subject,hot_logo,hot_info", "`{$ODBC['tablepre']}hotel`", "{$where}", "ORDER BY `hot_sp` DESC,`hot_date` DESC,`hot_id` DESC", $nPage * $nCount, $nCount);
        foreach ($sql_hotel as $key => $value) {
            $sql_hotel[$key]['hot_info'] = fconurt($value['hot_info']);
        }
        if ($nNums > $nCount) {
            $fpageup = fPages($nNums, $nPage, $nCount, $cParameter, 1);
            $smarty->assign('fpageup', $fpageup);
        }
    }
    $smarty->assign('sql_hotel', $sql_hotel);
    $smarty->assign('rentime', fmicrotime());
예제 #6
0
<?php

/***********************************************
DAVE PHP API
https://github.com/evantahler/PHP-DAVE-API
Evan Tahler | 2011

I am a way to test that cahce functions are working
I'll store and return a user provided variable
***********************************************/
// I'll use HASH as the variable to log by IP address;
if ($ERROR == 100) {
    if ($CONFIG['CacheType'] == "") {
        $ERROR = "The cache is not configured on this server";
    }
}
if ($ERROR == 100) {
    if (strlen($PARAMS["Hash"]) == 0) {
        $ERROR = "You need to provide a Hash";
    } else {
        $CacheKey = $IP . "_CacheTest";
        SetCache($CacheKey, $PARAMS["Hash"]);
        $result = GetCache($CacheKey);
        $OUTPUT['CacheKey'] = $CacheKey;
        $OUTPUT['CachedResult'] = $result;
    }
}
예제 #7
0
 function __construct($kptime = -1, $cache = FALSE)
 {
     global $dsql;
     if ($kptime == -1) {
         $this->M_KeepTime = 3600 * 24 * 7;
     } else {
         $this->M_KeepTime = $kptime;
     }
     $formcache = FALSE;
     $this->M_ID = $this->GetNum(GetCookie("DedeUserID"));
     $this->M_LoginTime = GetCookie("DedeLoginTime");
     $this->fields = array();
     $this->isAdmin = FALSE;
     if (empty($this->M_ID)) {
         $this->ResetUser();
     } else {
         $this->M_ID = intval($this->M_ID);
         if ($cache) {
             $this->fields = GetCache($this->memberCache, $this->M_ID);
             if (empty($this->fields)) {
                 $this->fields = $dsql->GetOne("Select * From `#@__member` where mid='{$this->M_ID}' ");
             } else {
                 $formcache = TRUE;
             }
         } else {
             $this->fields = $dsql->GetOne("Select * From `#@__member` where mid='{$this->M_ID}' ");
         }
         if (is_array($this->fields)) {
             #api{{
             if (defined('UC_API') && @(include_once DEDEROOT . '/uc_client/client.php')) {
                 if ($data = uc_get_user($this->fields['userid'])) {
                     if (uc_check_avatar($data[0]) && !strstr($this->fields['face'], UC_API)) {
                         $this->fields['face'] = UC_API . '/avatar.php?uid=' . $data[0] . '&size=middle';
                         $dsql->ExecuteNoneQuery("UPDATE `#@__member` SET `face`='" . $this->fields['face'] . "' WHERE `mid`='{$this->M_ID}'");
                     }
                 }
             }
             #/aip}}
             //间隔一小时更新一次用户登录时间
             if (time() - $this->M_LoginTime > 3600) {
                 $dsql->ExecuteNoneQuery("update `#@__member` set logintime='" . time() . "',loginip='" . GetIP() . "' where mid='" . $this->fields['mid'] . "';");
                 PutCookie("DedeLoginTime", time(), $this->M_KeepTime);
             }
             $this->M_LoginID = $this->fields['userid'];
             $this->M_MbType = $this->fields['mtype'];
             $this->M_Money = $this->fields['money'];
             $this->M_UserName = FormatUsername($this->fields['uname']);
             $this->M_Scores = $this->fields['scores'];
             $this->M_Face = $this->fields['face'];
             $this->M_Rank = $this->fields['rank'];
             $this->M_Spacesta = $this->fields['spacesta'];
             $sql = "Select titles From #@__scores where integral<={$this->fields['scores']} order by integral desc";
             $scrow = $dsql->GetOne($sql);
             $this->fields['honor'] = $scrow['titles'];
             $this->M_Honor = $this->fields['honor'];
             if ($this->fields['matt'] == 10) {
                 $this->isAdmin = TRUE;
             }
             $this->M_UpTime = $this->fields['uptime'];
             $this->M_ExpTime = $this->fields['exptime'];
             $this->M_JoinTime = MyDate('Y-m-d', $this->fields['jointime']);
             if ($this->M_Rank > 10 && $this->M_UpTime > 0) {
                 $this->M_HasDay = $this->Judgemember();
             }
             if (!$formcache) {
                 SetCache($this->memberCache, $this->M_ID, $this->fields, 1800);
             }
         } else {
             $this->ResetUser();
         }
     }
 }
예제 #8
0
}
unset($SquidNuditScanParams);
$filter = new ImageFilter();
$GLOBALS["HELPER"] = new externhelper();
while (!feof(STDIN)) {
    $url = trim(fgets(STDIN));
    if ($url == null) {
        continue;
    }
    $array = $GLOBALS["HELPER"]->parseURL($url);
    if ($GLOBALS["DEBUG_LEVEL"] > 1) {
        $GLOBALS["HELPER"]->WLOG($url . " str:" . strlen($url) . " LOGIN:{$array["LOGIN"]},IPADDR:{$array["IPADDR"]} MAC:{$array["MAC"]} HOST:{$array["HOST"]} URI:{$array["URI"]}");
    }
    $szMac = $array["MAC"];
    $szUrl = $array["URI"];
    $iScore = GetCache($szUrl);
    if ($iScore > 0) {
        if ($GLOBALS["DEBUG_LEVEL"] > 0) {
            $GLOBALS["HELPER"]->WLOG("Cached: {$iScore}% " . basename($szUrl));
        }
        if ($iScore > $iPicScanVal) {
            print "OK\n";
            continue;
        } else {
            print "ERR\n";
            continue;
        }
    }
    if (strlen($szUrl) < 3) {
        if ($GLOBALS["DEBUG_LEVEL"] > 1) {
            $GLOBALS["HELPER"]->WLOG("-> STOP no uri...");
예제 #9
0
파일: member.php 프로젝트: holin/sstour
            $_POST['blog_tags'] = implode(",", $gametag);
            $sql_gametag = $GETSQL->fSql("tag_id,tag_subject", "`{$ODBC['tablepre']}travelyoutag`", "`tag_subject` IN ({$gametags})");
            foreach ($sql_gametag as $value) {
                foreach ($gametag as $key => $ver) {
                    if ($ver == $value['tag_subject']) {
                        unset($gametag[$key]);
                    }
                }
            }
            $GETSQL->fUpdate("`{$ODBC['tablepre']}travelyoutag`", "`tag_num`=`tag_num`+1", "`tag_subject` IN ({$gametags})");
            foreach ($gametag as $value) {
                $cQuery = array("`tag_subject`");
                $cData = array($value);
                $GETSQL->fInsert("`{$ODBC['tablepre']}travelyoutag`", $cQuery, $cData);
            }
        }
        $cQuery = array("`thr_id`", "`thr_hid`", "`thr_subject`", "`thr_tages`", "`thr_content`", "`thr_date`");
        $cData = array($nowtime, $id, $_POST['blog_title'], $_POST['blog_tags'], $_POST['blog_body'], fgetdate());
        $GETSQL->fInsert("`{$ODBC['tablepre']}travelyou`", $cQuery, $cData);
        if ($actionhtml = GetCache('travel')) {
            include_once $actionhtml;
            if ($cache_config['cache'] == '1') {
                P_unlink(R_P . "html/travel/travelyou_I_{$id}.htm");
                ffile("{$boardurl}index.php?action=travel&option=travelyou&id={$id}", '', "r");
            }
        }
        header("Location: update.php?action=add&title=" . urlencode("发表成功") . "&a=travel&p=travelyouthread&id={$id}&in={$nowtime}");
        exit;
    }
    $smarty->display("travelyouedit.htm");
}
예제 #10
0
/**
 *  arclist解析函数
 *
 * @access    public
 * @param     object  $refObj  引用对象
 * @param     object  $ctag  标签
 * @param     int  $typeid  栏目ID
 * @param     int  $row  调用行数
 * @param     int  $titlelen  字符串长度
 * @param     int  $infolen  描述信息长度
 * @param     int  $imgwidth  图片宽度
 * @param     int  $imgheight  图片高度
 * @param     string  $listtype  列表类型
 * @param     string  $orderby  排列顺序
 * @param     string  $keyword  关键词
 * @param     string  $innertext  底层模板
 * @param     int  $arcid  文档ID
 * @param     string  $idlist  ID列表
 * @param     int  $channelid  频道ID
 * @param     string  $limit  限制
 * @param     string  $att  属性
 * @param     string  $order  排序类型
 * @param     int  $subday  天内
 * @param     string  $noflag  属性标记
 * @param     string  $tagid  标签id
 * @param     string  $pagesize  显示条数
 * @param     string  $isweight  是否需要对检索出来的内容按照weight排序
 * @return    string
 */
function lib_arclistDone(&$refObj, &$ctag, $typeid = 0, $row = 10, $col = 1, $titlelen = 30, $infolen = 160, $imgwidth = 120, $imgheight = 90, $listtype = 'all', $orderby = 'default', $keyword = '', $innertext = '', $arcid = 0, $idlist = '', $channelid = 0, $limit = '', $att = '', $order = 'desc', $subday = 0, $noflag = '', $tagid = '', $pagesize = 0, $isweight = 'N')
{
    global $dsql, $PubFields, $cfg_keyword_like, $cfg_index_cache, $_arclistEnv, $envs, $cfg_cache_type, $cfg_digg_update;
    $row = AttDef($row, 10);
    $titlelen = AttDef($titlelen, 30);
    $infolen = AttDef($infolen, 160);
    $imgwidth = AttDef($imgwidth, 120);
    $imgheight = AttDef($imgheight, 120);
    $listtype = AttDef($listtype, 'all');
    $arcid = AttDef($arcid, 0);
    $channelid = AttDef($channelid, 0);
    $orderby = AttDef($orderby, 'default');
    $orderWay = AttDef($order, 'desc');
    $subday = AttDef($subday, 0);
    $pagesize = AttDef($pagesize, 0);
    $line = $row;
    $orderby = strtolower($orderby);
    $keyword = trim($keyword);
    $innertext = trim($innertext);
    $tablewidth = $ctag->GetAtt('tablewidth');
    $writer = $ctag->GetAtt('writer');
    if ($tablewidth == "") {
        $tablewidth = 100;
    }
    if (empty($col)) {
        $col = 1;
    }
    $colWidth = ceil(100 / $col);
    $tablewidth = $tablewidth . "%";
    $colWidth = $colWidth . "%";
    //记录属性,以便分页样式统一调用
    $attarray = compact("row", "titlelen", 'infolen', 'imgwidth', 'imgheight', 'listtype', 'arcid', 'channelid', 'orderby', 'orderWay', 'subday', 'pagesize', 'orderby', 'keyword', 'tablewidth', 'col', 'colWidth');
    if ($innertext == '') {
        $innertext = GetSysTemplets('part_arclist.htm');
    }
    if (@$ctag->GetAtt('getall') == 1) {
        $getall = 1;
    } else {
        $getall = 0;
    }
    if ($att == '0') {
        $att = '';
    }
    if ($att == '3') {
        $att = 'f';
    }
    if ($att == '1') {
        $att = 'h';
    }
    $orwheres = array();
    $maintable = '#@__archives';
    //按不同情况设定SQL条件 排序方式
    if ($idlist == '') {
        if ($orderby == 'near' && $cfg_keyword_like == 'N') {
            $keyword = '';
        }
        if ($writer == 'this') {
            $wmid = isset($refObj->Fields['mid']) ? $refObj->Fields['mid'] : 0;
            $orwheres[] = " arc.mid = '{$wmid}' ";
        }
        //时间限制(用于调用最近热门文章、热门评论之类),这里的时间只能计算到天,否则缓存功能将无效
        if ($subday > 0) {
            $ntime = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y'));
            $limitday = $ntime - $subday * 24 * 3600;
            $orwheres[] = " arc.senddate > {$limitday} ";
        }
        //关键字条件
        if ($keyword != '') {
            $keyword = str_replace(',', '|', $keyword);
            $orwheres[] = " CONCAT(arc.title,arc.keywords) REGEXP '{$keyword}' ";
        }
        //文档属性
        if (preg_match('/commend/i', $listtype)) {
            $orwheres[] = " FIND_IN_SET('c', arc.flag)>0  ";
        }
        if (preg_match('/image/i', $listtype)) {
            $orwheres[] = " FIND_IN_SET('p', arc.flag)>0  ";
        }
        if ($att != '') {
            $flags = explode(',', $att);
            for ($i = 0; isset($flags[$i]); $i++) {
                $orwheres[] = " FIND_IN_SET('{$flags[$i]}', arc.flag)>0 ";
            }
        }
        if (!empty($typeid) && $typeid != 'top') {
            //指定了多个栏目时,不再获取子类的id
            if (preg_match('#,#', $typeid)) {
                //指定了getall属性或主页模板例外
                if ($getall == 1 || empty($refObj->Fields['typeid'])) {
                    $typeids = explode(',', $typeid);
                    foreach ($typeids as $ttid) {
                        $typeidss[] = GetSonIds($ttid);
                    }
                    $typeidStr = join(',', $typeidss);
                    $typeidss = explode(',', $typeidStr);
                    $typeidssok = array_unique($typeidss);
                    $typeid = join(',', $typeidssok);
                }
                $orwheres[] = " arc.typeid IN ({$typeid}) ";
            } else {
                //处理交叉栏目
                $CrossID = '';
                if ($ctag->GetAtt('cross') == '1') {
                    $arr = $dsql->GetOne("SELECT `id`,`topid`,`cross`,`crossid`,`ispart`,`typename` FROM `#@__arctype` WHERE id='{$typeid}' ");
                    if ($arr['cross'] == 0 || $arr['cross'] == 2 && trim($arr['crossid'] == '')) {
                        $orwheres[] = ' arc.typeid IN (' . GetSonIds($typeid) . ')';
                    } else {
                        $selquery = '';
                        if ($arr['cross'] == 1) {
                            $selquery = "SELECT id,topid FROM `#@__arctype` WHERE typename LIKE '{$arr['typename']}' AND id<>'{$typeid}' AND topid<>'{$typeid}'  ";
                        } else {
                            $arr['crossid'] = preg_replace('#[^0-9,]#', '', trim($arr['crossid']));
                            if ($arr['crossid'] != '') {
                                $selquery = "SELECT id,topid FROM `#@__arctype` WHERE id IN('{$arr['crossid']}') AND id<>'{$typeid}' AND topid<>'{$typeid}'  ";
                            }
                        }
                        if ($selquery != '') {
                            $dsql->SetQuery($selquery);
                            $dsql->Execute();
                            while ($arr = $dsql->GetArray()) {
                                $CrossID .= $CrossID == '' ? $arr['id'] : ',' . $arr['id'];
                            }
                        }
                    }
                }
                if ($CrossID == '') {
                    $orwheres[] = ' arc.typeid IN (' . GetSonIds($typeid) . ')';
                } else {
                    $orwheres[] = ' arc.typeid IN (' . GetSonIds($typeid) . ',' . $CrossID . ')';
                }
            }
        }
        //频道ID
        if (preg_match('#spec#i', $listtype)) {
            $channelid == -1;
        }
        if (!empty($channelid)) {
            $orwheres[] = " And arc.channel = '{$channelid}' ";
        }
        if (!empty($noflag)) {
            if (!preg_match('#,#', $noflag)) {
                $orwheres[] = " FIND_IN_SET('{$noflag}', arc.flag)<1 ";
            } else {
                $noflags = explode(',', $noflag);
                foreach ($noflags as $noflag) {
                    if (trim($noflag) == '') {
                        continue;
                    }
                    $orwheres[] = " FIND_IN_SET('{$noflag}', arc.flag)<1 ";
                }
            }
        }
        $orwheres[] = ' arc.arcrank > -1 ';
        //由于这个条件会导致缓存功能失去意义,因此取消
        //if($arcid!=0) $orwheres[] = " arc.id<>'$arcid' ";
    }
    //文档排序的方式
    $ordersql = '';
    if ($orderby == 'hot' || $orderby == 'click') {
        $ordersql = " ORDER BY arc.click {$orderWay}";
    } else {
        if ($orderby == 'sortrank' || $orderby == 'pubdate') {
            $ordersql = " ORDER BY arc.sortrank {$orderWay}";
        } else {
            if ($orderby == 'id') {
                $ordersql = "  ORDER BY arc.id {$orderWay}";
            } else {
                if ($orderby == 'near') {
                    $ordersql = " ORDER BY ABS(arc.id - " . $arcid . ")";
                } else {
                    if ($orderby == 'lastpost') {
                        $ordersql = "  ORDER BY arc.lastpost {$orderWay}";
                    } else {
                        if ($orderby == 'scores') {
                            $ordersql = "  ORDER BY arc.scores {$orderWay}";
                        } else {
                            if ($orderby == 'goodpost') {
                                $ordersql = " order by arc.goodpost {$orderWay}";
                            } else {
                                if ($orderby == 'badpost') {
                                    $ordersql = " order by arc.badpost {$orderWay}";
                                } else {
                                    if ($orderby == 'rand') {
                                        $ordersql = "  ORDER BY rand()";
                                    } else {
                                        $ordersql = " ORDER BY arc.sortrank {$orderWay}";
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    //limit条件
    $limit = trim(preg_replace('#limit#is', '', $limit));
    if ($limit != '') {
        $limitsql = " LIMIT {$limit} ";
        $limitarr = explode(',', $limit);
        $line = isset($limitarr[1]) ? $limitarr[1] : $line;
    } else {
        $limitsql = " LIMIT 0,{$line} ";
    }
    $orwhere = '';
    if (isset($orwheres[0])) {
        $orwhere = join(' And ', $orwheres);
        $orwhere = preg_replace("#^ And#is", '', $orwhere);
        $orwhere = preg_replace("#And[ ]{1,}And#is", 'And ', $orwhere);
    }
    if ($orwhere != '') {
        $orwhere = " WHERE {$orwhere} ";
    }
    //获取附加表信息
    $addfield = trim($ctag->GetAtt('addfields'));
    $addfieldsSql = '';
    $addfieldsSqlJoin = '';
    if ($addfield != '' && !empty($channelid)) {
        $row = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='{$channelid}' ");
        if (isset($row['addtable']) && trim($row['addtable']) != '') {
            $addtable = trim($row['addtable']);
            $addfields = explode(',', $addfield);
            $row['addtable'] = trim($row['addtable']);
            $addfieldsSql = ",addf." . join(',addf.', $addfields);
            $addfieldsSqlJoin = " LEFT JOIN `{$addtable}` addf ON addf.aid = arc.id ";
        }
    }
    $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,\r\n        tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\r\n        {$addfieldsSql}\r\n        FROM `{$maintable}` arc LEFT JOIN `#@__arctype` tp on arc.typeid=tp.id\r\n        {$addfieldsSqlJoin}\r\n        {$orwhere} {$ordersql} {$limitsql}";
    //统一hash
    $taghash = md5(serialize($ctag) . $typeid);
    $needSaveCache = true;
    //进行tagid的默认处理
    if ($pagesize > 0) {
        $tagid = AttDef($tagid, 'tag' . $taghash);
    }
    if ($idlist != '' || $GLOBALS['_arclistEnv'] == 'index' || $cfg_index_cache == 0) {
        $needSaveCache = false;
    } else {
        $idlist = GetArclistCache($taghash);
        if ($idlist != '') {
            $needSaveCache = false;
        }
        //如果使用的是内容缓存,直接返回结果
        if ($cfg_cache_type == 'content' && $idlist != '') {
            $idlist = $idlist == 0 ? '' : $idlist;
            return $idlist;
        }
    }
    //指定了id或使用缓存中的id
    if ($idlist != '') {
        $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,\r\n            tp.moresite,tp.siteurl,tp.sitepath\r\n            {$addfieldsSql}\r\n             FROM `{$maintable}` arc left join `#@__arctype` tp on arc.typeid=tp.id\r\n             {$addfieldsSqlJoin}\r\n          WHERE arc.id in({$idlist}) {$ordersql} ";
    }
    // 好评差评缓存更新
    if ($cfg_digg_update > 0) {
        if ($orderby == 'goodpost' || $orderby == 'badpost') {
            $t1 = ExecTime();
            $postsql = "SELECT arc.id,arc.goodpost,arc.badpost,arc.scores\r\n\t\t\t\tFROM `{$maintable}` arc\r\n\t\t\t\t{$orwhere} {$ordersql} {$limitsql}";
            if ($idlist != '') {
                $postsql = "SELECT arc.id,arc.goodpost,arc.badpost,arc.scores\r\n\t\t\t\t\t FROM `{$maintable}` arc \r\n\t\t\t\t  WHERE arc.id in({$idlist}) {$ordersql} ";
            }
            $dsql->SetQuery($query);
            $dsql->Execute('lit');
            while ($row = $dsql->GetArray('lit')) {
                $prefix = 'diggCache';
                $key = 'aid-' . $row['id'];
                $cacherow = GetCache($prefix, $key);
                $setsql = array();
                if (!empty($cacherow['scores']) && $cacherow['scores'] != $row['scores']) {
                    $setsql[] = "scores = {$cacherow['scores']}";
                }
                if (!empty($cacherow['goodpost']) && $cacherow['goodpost'] != $row['goodpost']) {
                    $setsql[] = "goodpost = {$cacherow['goodpost']}";
                }
                if (!empty($cacherow['badpost']) && $cacherow['badpost'] != $row['badpost']) {
                    $setsql[] = "badpost = {$cacherow['badpost']}";
                }
                $setsql = implode(',', $setsql);
                $sql = "UPDATE `{$maintable}` SET {$setsql} WHERE id='{$row['id']}'";
                if (!empty($setsql)) {
                    $dsql->ExecuteNoneQuery($sql);
                }
            }
            //echo ExecTime()-$t1;
        }
    }
    $dsql->SetQuery($query);
    $dsql->Execute('al');
    //$row = $dsql->GetArray("al");
    $artlist = '';
    if ($pagesize > 0) {
        $artlist .= "    <div id='{$tagid}'>\r\n";
    }
    if ($col > 1) {
        $artlist = "<table width='{$tablewidth}' border='0' cellspacing='0' cellpadding='0'>\r\n";
    }
    $dtp2 = new DedeTagParse();
    $dtp2->SetNameSpace('field', '[', ']');
    $dtp2->LoadString($innertext);
    $GLOBALS['autoindex'] = 0;
    $ids = array();
    $orderWeight = array();
    for ($i = 0; $i < $line; $i++) {
        if ($col > 1) {
            $artlist .= "<tr>\r\n";
        }
        for ($j = 0; $j < $col; $j++) {
            if ($col > 1) {
                $artlist .= "    <td width='{$colWidth}'>\r\n";
            }
            if ($row = $dsql->GetArray("al")) {
                $ids[] = $row['id'];
                //处理一些特殊字段
                $row['info'] = $row['infos'] = cn_substr($row['description'], $infolen);
                $row['id'] = $row['id'];
                if ($row['corank'] > 0 && $row['arcrank'] == 0) {
                    $row['arcrank'] = $row['corank'];
                }
                $row['filename'] = $row['arcurl'] = GetFileUrl($row['id'], $row['typeid'], $row['senddate'], $row['title'], $row['ismake'], $row['arcrank'], $row['namerule'], $row['typedir'], $row['money'], $row['filename'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                $row['typeurl'] = GetTypeUrl($row['typeid'], $row['typedir'], $row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'], $row['moresite'], $row['siteurl'], $row['sitepath']);
                if ($row['litpic'] == '-' || $row['litpic'] == '') {
                    $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
                }
                if (!preg_match("#^http:\\/\\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
                    $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
                }
                $row['picname'] = $row['litpic'];
                $row['stime'] = GetDateMK($row['pubdate']);
                $row['typelink'] = "<a href='" . $row['typeurl'] . "'>" . $row['typename'] . "</a>";
                $row['image'] = "<img src='" . $row['picname'] . "' border='0' width='{$imgwidth}' height='{$imgheight}' alt='" . preg_replace("#['><]#", "", $row['title']) . "'>";
                $row['imglink'] = "<a href='" . $row['filename'] . "'>" . $row['image'] . "</a>";
                $row['fulltitle'] = $row['title'];
                $row['title'] = cn_substr($row['title'], $titlelen);
                if ($row['color'] != '') {
                    $row['title'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
                }
                if (preg_match('#b#', $row['flag'])) {
                    $row['title'] = "<strong>" . $row['title'] . "</strong>";
                }
                //$row['title'] = "<b>".$row['title']."</b>";
                $row['textlink'] = "<a href='" . $row['filename'] . "'>" . $row['title'] . "</a>";
                $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                if (is_array($dtp2->CTags)) {
                    foreach ($dtp2->CTags as $k => $ctag) {
                        if ($ctag->GetName() == 'array') {
                            //传递整个数组,在runphp模式中有特殊作用
                            $dtp2->Assign($k, $row);
                        } else {
                            if (isset($row[$ctag->GetName()])) {
                                $dtp2->Assign($k, $row[$ctag->GetName()]);
                            } else {
                                $dtp2->Assign($k, '');
                            }
                        }
                    }
                    $GLOBALS['autoindex']++;
                }
                if ($pagesize > 0) {
                    if ($GLOBALS['autoindex'] <= $pagesize) {
                        $liststr = $dtp2->GetResult();
                        $artlist .= $liststr . "\r\n";
                    } else {
                        $artlist .= "";
                        $orderWeight[] = array('weight' => $row['weight'], 'arclist' => '');
                    }
                } else {
                    $liststr = $dtp2->GetResult();
                    $artlist .= $liststr . "\r\n";
                }
                $orderWeight[] = array('weight' => $row['weight'], 'arclist' => $liststr);
            } else {
                $artlist .= '';
            }
            // 进行判断,如果启用排序则内容输出为重新排序后的内容
            // var_dump($isweight=='y' && count($orderWeight) == $line);
            $isweight = strtolower($isweight);
            if ($isweight == 'y') {
                $artlist = '';
                $orderWeight = list_sort_by($orderWeight, 'weight', 'asc');
                foreach ($orderWeight as $vv) {
                    $artlist .= $vv['arclist'];
                }
            }
            if ($col > 1) {
                $artlist .= "    </td>\r\n";
            }
        }
        //Loop Col
        if ($col > 1) {
            $i += $col - 1;
        }
        if ($col > 1) {
            $artlist .= "    </tr>\r\n";
        }
    }
    //loop line
    if ($col > 1) {
        $artlist .= "    </table>\r\n";
    }
    $dsql->FreeResult("al");
    $idsstr = join(',', $ids);
    //分页特殊处理
    if ($pagesize > 0) {
        $artlist .= "    </div>\r\n";
        $row = $dsql->GetOne("SELECT tagid FROM #@__arcmulti WHERE tagid='{$tagid}'");
        $uptime = time();
        $attstr = addslashes(serialize($attarray));
        $innertext = addslashes($innertext);
        if (!is_array($row)) {
            $query = "\r\n          INSERT INTO #@__arcmulti(tagid,uptime,innertext,pagesize,arcids,ordersql,addfieldsSql,addfieldsSqlJoin,attstr)\r\n          VALUES('{$tagid}','{$uptime}','{$innertext}','{$pagesize}','{$idsstr}','{$ordersql}','{$addfieldsSql}','{$addfieldsSqlJoin}','{$attstr}');\r\n        ";
            $dsql->ExecuteNoneQuery($query);
        } else {
            $query = "UPDATE `#@__arcmulti`\r\n           SET\r\n           uptime='{$uptime}',\r\n           innertext='{$innertext}',\r\n           pagesize='{$pagesize}',\r\n           arcids='{$idsstr}',\r\n           ordersql='{$ordersql}',\r\n           addfieldsSql='{$addfieldsSql}',\r\n           addfieldsSqlJoin='{$addfieldsSqlJoin}',\r\n           attstr='{$attstr}'\r\n           WHERE tagid='{$tagid}'\r\n        ";
            $dsql->ExecuteNoneQuery($query);
        }
    }
    //保存ID缓存
    if ($needSaveCache) {
        if ($idsstr == '') {
            $idsstr = '0';
        }
        if ($cfg_cache_type == 'content' && $idsstr != '0') {
            $idsstr = addslashes($artlist);
        }
        $inquery = "INSERT INTO `#@__arccache`(`md5hash`,`uptime`,`cachedata`) VALUES ('" . $taghash . "','" . time() . "', '{$idsstr}'); ";
        $dsql->ExecuteNoneQuery("DELETE FROM `#@__arccache` WHERE md5hash='" . $taghash . "' ");
        $dsql->ExecuteNoneQuery($inquery);
    }
    return $artlist;
}
예제 #11
0
파일: flink.lib.php 프로젝트: healen/dsCMS
function lib_flink(&$ctag, &$refObj)
{
    global $dsql, $cfg_soft_lang;
    $attlist = "type|textall,row|24,titlelen|24,linktype|1,typeid|0";
    FillAttsDefault($ctag->CAttribute->Items, $attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $totalrow = $row;
    $revalue = '';
    if (isset($GLOBALS['envs']['flinkid'])) {
        $typeid = $GLOBALS['envs']['flinkid'];
    }
    $wsql = " where ischeck >= '{$linktype}' ";
    if ($typeid == 0) {
        $wsql .= '';
    } else {
        if ($typeid == 999) {
            $prefix = 'flink';
            $key = '999';
            $row = GetCache($prefix, $key);
            if (!is_array($row)) {
                require DEDEDATA . '/admin/config_update.php';
                if (!class_exists('DedeHttpDown', false)) {
                    require_once DEDEINC . '/dedehttpdown.class.php';
                }
                $del = new DedeHttpDown();
                $del->OpenUrl($linkHost);
                $linkUrl = $del->GetHtml() . "flink.php?lang={$cfg_soft_lang}&site={$_SERVER['SERVER_NAME']}";
                $del->OpenUrl($linkUrl);
                $linkInfo = $del->GetHtml();
                if (!empty($linkInfo)) {
                    $dedelink = explode("\t", $linkInfo);
                    for ($i = 0; $i < count($dedelink); $i++) {
                        if ($i % 5 == 0 && $i != count($dedelink)) {
                            $revalue .= "<li><a href='http://" . @$dedelink[$i + 1] . "' target='_blank' title='" . @$dedelink[$i + 4] . "'>" . @$dedelink[$i] . "</a></li>";
                        }
                    }
                } else {
                    $revalue = <<<EOT
<li><a href='http://ad.dedecms.com' target='_blank' title='DedeCMS广告'>DedeCMS广告</a></li><li><a href='http://service.dedecms.com' target='_blank' title='织梦客户服务中心'>
织梦客户服务中心</a></li><li><a href='http://ask.dedecms.com' target='_blank' title='织梦问答'>
织梦问答</a></li><li><a href='http://tools.dedecms.com' target='_blank' title='站长工具'>
站长工具</a></li><li><a href='http://site.desdev.cn' target='_blank' title='DedeCMS建站中心'>
DedeCMS建站中心</a></li><li><a href='http://help.dedecms.com' target='_blank' title='织梦CMS帮助中心'>
织梦CMS帮助中心</a></li><li><a href='http://' target='_blank' title=''>
</a></li>
EOT;
                }
                $row['reval'] = $revalue;
                SetCache($prefix, $key, $row, 60 * 60 * 1);
            }
            return $row['reval'];
        } else {
            $wsql .= "And typeid = '{$typeid}'";
        }
    }
    if ($type == 'image') {
        $wsql .= " And logo<>'' ";
    } else {
        if ($type == 'text') {
            $wsql .= " And logo='' ";
        }
    }
    $equery = "SELECT * FROM #@__flink {$wsql} order by sortrank asc limit 0,{$totalrow}";
    if (trim($ctag->GetInnerText()) == '') {
        $innertext = "<li>[field:link /]</li>";
    } else {
        $innertext = $ctag->GetInnerText();
    }
    $dsql->SetQuery($equery);
    $dsql->Execute();
    while ($dbrow = $dsql->GetObject()) {
        if ($type == 'text' || $type == 'textall') {
            $link = "<a href='" . $dbrow->url . "' target='_blank'>" . cn_substr($dbrow->webname, $titlelen) . "</a> ";
        } else {
            if ($type == 'image') {
                $link = "<a href='" . $dbrow->url . "' target='_blank'><img src='" . $dbrow->logo . "' width='248' height='180' border='0'></a> ";
            } else {
                if ($dbrow->logo == '') {
                    $link = "<a href='" . $dbrow->url . "' target='_blank'>" . cn_substr($dbrow->webname, $titlelen) . "</a> ";
                } else {
                    $link = "<a href='" . $dbrow->url . "' target='_blank'><img src='" . $dbrow->logo . "' width='248' height='180' border='0'></a> ";
                }
            }
        }
        $rbtext = preg_replace("/\\[field:url([\\/\\s]{0,})\\]/isU", $row['url'], $innertext);
        $rbtext = preg_replace("/\\[field:webname([\\/\\s]{0,})\\]/isU", $row['webname'], $rbtext);
        $rbtext = preg_replace("/\\[field:logo([\\/\\s]{0,})\\]/isU", $row['logo'], $rbtext);
        $rbtext = preg_replace("/\\[field:link([\\/\\s]{0,})\\]/isU", $link, $rbtext);
        $revalue .= $rbtext;
    }
    return $revalue;
}
예제 #12
0
        $tinyQuerys[] = " arcrank > -2 ";
    }
    if (!empty($mid)) {
        $tinyQuerys[] = " mid='{$mid}' ";
    }
    if (!empty($cid)) {
        $tinyQuerys[] = " typeid in(" . GetSonIds($cid) . ") ";
    }
    if (count($tinyQuerys) > 0) {
        $tinyQuery = "WHERE " . join(' AND ', $tinyQuerys);
    }
    $tinyQuery = "WHERE mid={$adminid}";
    // 缓存处理
    $sql = "SELECT COUNT(*) AS dd FROM `#@__archives` {$tinyQuery} ";
    $cachekey = md5($sql);
    $arr = GetCache('listcache', $cachekey);
    if (empty($arr)) {
        $arr = $dsql->GetOne($sql);
        SetCache('listcache', $cachekey, $arr);
    }
    $totalresult = $arr['dd'];
}
if ($cid == 0) {
    if ($channelid == 0) {
        $positionname = '所有栏目&gt;';
    } else {
        $row = $tl->dsql->GetOne("SELECT id,typename,maintable FROM `#@__channeltype` WHERE id='{$channelid}'");
        $positionname = $row['typename'] . " &gt; ";
        $maintable = $row['maintable'];
        $channelid = $row['id'];
    }
예제 #13
0
파일: link.php 프로젝트: holin/sstour
<?php

if ($actionhtml = GetCache($action) && $_POST['update'] != 'update') {
    include_once $actionhtml;
    include_once Getincludefun("html");
    $smarty->assign('cache_config', $cache_config);
}
if ($option == 'index') {
    $smarty->assign('config', array('title' => "{$cache_config['subject']}", 'keywords' => $config['keywords'] . "_{$cache_config['subject']}", 'description' => $config['description'] . "_{$cache_config['subject']}"));
    if ($_POST['update'] == 'update') {
        fgetposttoupdatd($_POST, $ODBC['charset']);
        if ($_POST['addsubject'] != '' && $_POST['addurl'] != '') {
            $cQuery = array("`link_id`", "`link_subject`", "`link_url`", "`link_info`", "`link_logo`");
            $cData = array($nowtime, $_POST['addsubject'], $_POST['addurl'], $_POST['addinfo'], $_POST['addlogo']);
            $GETSQL->fInsert("`{$ODBC['tablepre']}link`", $cQuery, $cData);
            die(gb2utf8("友情连接申请成功等待管理员通过"));
        }
        die(gb2utf8("友情连接申请失败"));
    }
    $nCount = $cache_config['numser'] ? $cache_config['numser'] : "20";
    $cParameter = "action={$action}&option={$option}";
    $nNums = $GETSQL->fNumrows("SELECT link_id FROM `{$ODBC['tablepre']}link` WHERE `link_pass`>0");
    if ($nNums > 0) {
        $sql_link = $GETSQL->fSql("*", "`{$ODBC['tablepre']}link`", "`link_pass`>0", "ORDER BY `link_pass` DESC,`link_sp` DESC,`link_id` DESC", $nPage * $nCount, $nCount);
        if ($nNums > $nCount) {
            $fpageup = fPages($nNums, $nPage, $nCount, $cParameter, 1);
            $smarty->assign('fpageup', $fpageup);
        }
    }
    $smarty->assign('sql_link', $sql_link);
    $smarty->assign('rentime', fmicrotime());