国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

657 lines
25KB

  1. <?php if (!defined('DEDEINC')) exit('Request Error!');
  2. /**
  3. * 文章列表调用标记
  4. *
  5. * 9:19 2010年7月13日:修正对isweight属性的支持
  6. *
  7. * @version $Id: arclist.lib.php 3 9:19 2010年7月13日Z tianya $
  8. * @package DedeBIZ.Taglib
  9. * @copyright Copyright (c) 2021, DedeBIZ.COM
  10. * @license https://www.dedebiz.com/license
  11. * @link https://www.dedebiz.com
  12. */
  13. /**
  14. * arclist解析标签
  15. *
  16. * @access public
  17. * @param object $ctag 解析标签
  18. * @param object $refObj 引用对象
  19. * @return string 成功后返回解析后的标签内容
  20. */
  21. function lib_arclist(&$ctag, &$refObj)
  22. {
  23. global $envs;
  24. $autopartid = 0;
  25. $tagid = '';
  26. $tagname = $ctag->GetTagName();
  27. $channelid = $ctag->GetAtt('channelid');
  28. //增加对分页内容的处理
  29. $pagesize = $ctag->GetAtt('pagesize');
  30. if ($pagesize == '') {
  31. $multi = 0;
  32. } else {
  33. $tagid = $ctag->GetAtt('tagid');
  34. }
  35. // arclist是否需要weight排序,默认为"N",如果需要排序则设置为"Y"
  36. $isweight = $ctag->GetAtt('isweight');
  37. if ($tagname == 'imglist' || $tagname == 'imginfolist') {
  38. $listtype = 'image';
  39. } else if ($tagname == 'specart') {
  40. $channelid = -1;
  41. $listtype = '';
  42. } else if ($tagname == 'coolart') {
  43. $listtype = 'commend';
  44. } else if ($tagname == 'autolist') {
  45. $autopartid = $ctag->GetAtt('partsort');
  46. } else {
  47. $listtype = $ctag->GetAtt('type');
  48. }
  49. //排序
  50. if ($ctag->GetAtt('sort') != '') $orderby = $ctag->GetAtt('sort');
  51. else if ($tagname == 'hotart') $orderby = 'click';
  52. else $orderby = $ctag->GetAtt('orderby');
  53. //对相应的标记使用不同的默认innertext
  54. if (trim($ctag->GetInnerText()) != '') $innertext = $ctag->GetInnerText();
  55. else if ($tagname == 'imglist') $innertext = GetSysTemplets('part_imglist.htm');
  56. else if ($tagname == 'imginfolist') $innertext = GetSysTemplets('part_imginfolist.htm');
  57. else $innertext = GetSysTemplets("part_arclist.htm");
  58. //兼容titlelength
  59. if ($ctag->GetAtt('titlelength') != '') $titlelen = $ctag->GetAtt('titlelength');
  60. else $titlelen = $ctag->GetAtt('titlelen');
  61. //兼容infolength
  62. if ($ctag->GetAtt('infolength') != '') $infolen = $ctag->GetAtt('infolength');
  63. else $infolen = $ctag->GetAtt('infolen');
  64. $typeid = trim($ctag->GetAtt('typeid'));
  65. if (empty($typeid)) {
  66. $typeid = (isset($refObj->Fields['typeid']) ? $refObj->Fields['typeid'] : $envs['typeid']);
  67. }
  68. if ($listtype == 'autolist') {
  69. $typeid = lib_GetAutoChannelID($ctag->GetAtt('partsort'), $typeid);
  70. }
  71. if ($ctag->GetAtt('att') == '') {
  72. $flag = $ctag->GetAtt('flag');
  73. } else {
  74. $flag = $ctag->GetAtt('att');
  75. }
  76. return lib_arclistDone(
  77. $refObj,
  78. $ctag,
  79. $typeid,
  80. $ctag->GetAtt('row'),
  81. $ctag->GetAtt('col'),
  82. $titlelen,
  83. $infolen,
  84. $ctag->GetAtt('imgwidth'),
  85. $ctag->GetAtt('imgheight'),
  86. $listtype,
  87. $orderby,
  88. $ctag->GetAtt('keyword'),
  89. $innertext,
  90. $envs['aid'],
  91. $ctag->GetAtt('idlist'),
  92. $channelid,
  93. $ctag->GetAtt('limit'),
  94. $flag,
  95. $ctag->GetAtt('orderway'),
  96. $ctag->GetAtt('subday'),
  97. $ctag->GetAtt('noflag'),
  98. $tagid,
  99. $pagesize,
  100. $isweight
  101. );
  102. }
  103. /**
  104. * arclist解析函数
  105. *
  106. * @access public
  107. * @param object $refObj 引用对象
  108. * @param object $ctag 标签
  109. * @param int $typeid 栏目ID
  110. * @param int $row 调用行数
  111. * @param int $titlelen 字符串长度
  112. * @param int $infolen 描述信息长度
  113. * @param int $imgwidth 图片宽度
  114. * @param int $imgheight 图片高度
  115. * @param string $listtype 列表类型
  116. * @param string $orderby 排列顺序
  117. * @param string $keyword 关键词
  118. * @param string $innertext 底层模板
  119. * @param int $arcid 文档ID
  120. * @param string $idlist ID列表
  121. * @param int $channelid 频道ID
  122. * @param string $limit 限制
  123. * @param string $att 属性
  124. * @param string $order 排序类型
  125. * @param int $subday 天内
  126. * @param string $noflag 属性标记
  127. * @param string $tagid 标签id
  128. * @param string $pagesize 显示条数
  129. * @param string $isweight 是否需要对检索出来的内容按照weight排序
  130. * @return string
  131. */
  132. function lib_arclistDone(
  133. &$refObj,
  134. &$ctag,
  135. $typeid = 0,
  136. $row = 10,
  137. $col = 1,
  138. $titlelen = 30,
  139. $infolen = 160,
  140. $imgwidth = 120,
  141. $imgheight = 90,
  142. $listtype = 'all',
  143. $orderby = 'default',
  144. $keyword = '',
  145. $innertext = '',
  146. $arcid = 0,
  147. $idlist = '',
  148. $channelid = 0,
  149. $limit = '',
  150. $att = '',
  151. $order = 'desc',
  152. $subday = 0,
  153. $noflag = '',
  154. $tagid = '',
  155. $pagesize = 0,
  156. $isweight = 'N'
  157. ) {
  158. global $dsql, $PubFields, $cfg_keyword_like, $cfg_index_cache, $_arclistEnv, $envs, $cfg_cache_type, $cfg_digg_update;
  159. $row = AttDef($row, 10);
  160. $titlelen = AttDef($titlelen, 30);
  161. $infolen = AttDef($infolen, 160);
  162. $imgwidth = AttDef($imgwidth, 120);
  163. $imgheight = AttDef($imgheight, 120);
  164. $listtype = AttDef($listtype, 'all');
  165. $arcid = AttDef($arcid, 0);
  166. $channelid = AttDef($channelid, 0);
  167. $orderby = AttDef($orderby, 'default');
  168. $orderWay = AttDef($order, 'desc');
  169. $subday = AttDef($subday, 0);
  170. $pagesize = AttDef($pagesize, 0);
  171. $line = $row;
  172. $orderby = strtolower($orderby);
  173. $keyword = trim($keyword);
  174. $innertext = trim($innertext);
  175. $tablewidth = $ctag->GetAtt('tablewidth');
  176. $writer = $ctag->GetAtt('writer');
  177. if ($tablewidth == "") $tablewidth = 100;
  178. if (empty($col)) $col = 1;
  179. $colWidth = ceil(100 / $col);
  180. $tablewidth = $tablewidth . "%";
  181. $colWidth = $colWidth . "%";
  182. //记录属性,以便分页样式统一调用
  183. $attarray = compact(
  184. "row",
  185. "titlelen",
  186. 'infolen',
  187. 'imgwidth',
  188. 'imgheight',
  189. 'listtype',
  190. 'arcid',
  191. 'channelid',
  192. 'orderby',
  193. 'orderWay',
  194. 'subday',
  195. 'pagesize',
  196. 'orderby',
  197. 'keyword',
  198. 'tablewidth',
  199. 'col',
  200. 'colWidth'
  201. );
  202. if ($innertext == '') $innertext = GetSysTemplets('part_arclist.htm');
  203. if (@$ctag->GetAtt('getall') == 1) $getall = 1;
  204. else $getall = 0;
  205. if ($att == '0') $att = '';
  206. if ($att == '3') $att = 'f';
  207. if ($att == '1') $att = 'h';
  208. $orwheres = array();
  209. $maintable = '#@__archives';
  210. //按不同情况设定SQL条件 排序方式
  211. if ($idlist == '') {
  212. if ($orderby == 'near' && $cfg_keyword_like == 'N') {
  213. $keyword = '';
  214. }
  215. if ($writer == 'this') {
  216. $wmid = isset($refObj->Fields['mid']) ? $refObj->Fields['mid'] : 0;
  217. $orwheres[] = " arc.mid = '$wmid' ";
  218. }
  219. //时间限制(用于调用最近热门文章、热门评论之类),这里的时间只能计算到天,否则缓存功能将无效
  220. if ($subday > 0) {
  221. $ntime = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y'));
  222. $limitday = $ntime - ($subday * 24 * 3600);
  223. $orwheres[] = " arc.senddate > $limitday ";
  224. }
  225. //关键字条件
  226. if ($keyword != '') {
  227. $keyword = str_replace(',', '|', $keyword);
  228. $orwheres[] = " CONCAT(arc.title,arc.keywords) REGEXP '$keyword' ";
  229. }
  230. //文档属性
  231. if (preg_match('/commend/i', $listtype)) $orwheres[] = " FIND_IN_SET('c', arc.flag)>0 ";
  232. if (preg_match('/image/i', $listtype)) $orwheres[] = " FIND_IN_SET('p', arc.flag)>0 ";
  233. if ($att != '') {
  234. $flags = explode(',', $att);
  235. for ($i = 0; isset($flags[$i]); $i++) $orwheres[] = " FIND_IN_SET('{$flags[$i]}', arc.flag)>0 ";
  236. }
  237. if (!empty($typeid) && $typeid != 'top') {
  238. //指定了多个栏目时,不再获取子类的id
  239. if (preg_match('#,#', $typeid)) {
  240. //指定了getall属性或主页模板例外
  241. if ($getall == 1 || empty($refObj->Fields['typeid'])) {
  242. $typeids = explode(',', $typeid);
  243. foreach ($typeids as $ttid) {
  244. $typeidss[] = GetSonIds($ttid);
  245. }
  246. $typeidStr = join(',', $typeidss);
  247. $typeidss = explode(',', $typeidStr);
  248. $typeidssok = array_unique($typeidss);
  249. $typeid = join(',', $typeidssok);
  250. }
  251. $orwheres[] = " arc.typeid IN ($typeid) ";
  252. } else {
  253. //处理交叉栏目
  254. $CrossID = '';
  255. if ($ctag->GetAtt('cross') == '1') {
  256. $arr = $dsql->GetOne("SELECT `id`,`topid`,`cross`,`crossid`,`ispart`,`typename` FROM `#@__arctype` WHERE id='$typeid' ");
  257. if ($arr['cross'] == 0 || ($arr['cross'] == 2 && trim($arr['crossid'] == ''))) {
  258. $orwheres[] = ' arc.typeid IN (' . GetSonIds($typeid) . ')';
  259. } else {
  260. $selquery = '';
  261. if ($arr['cross'] == 1) {
  262. $selquery = "SELECT id,topid FROM `#@__arctype` WHERE typename LIKE '{$arr['typename']}' AND id<>'{$typeid}' AND topid<>'{$typeid}' ";
  263. } else {
  264. $arr['crossid'] = preg_replace('#[^0-9,]#', '', trim($arr['crossid']));
  265. if ($arr['crossid'] != '') $selquery = "SELECT id,topid FROM `#@__arctype` WHERE id IN('{$arr['crossid']}') AND id<>'{$typeid}' AND topid<>'{$typeid}' ";
  266. }
  267. if ($selquery != '') {
  268. $dsql->SetQuery($selquery);
  269. $dsql->Execute();
  270. while ($arr = $dsql->GetArray()) {
  271. $CrossID .= ($CrossID == '' ? $arr['id'] : ',' . $arr['id']);
  272. }
  273. }
  274. }
  275. }
  276. if ($CrossID == '') $orwheres[] = ' arc.typeid IN (' . GetSonIds($typeid) . ')';
  277. else $orwheres[] = ' arc.typeid IN (' . GetSonIds($typeid) . ',' . $CrossID . ')';
  278. }
  279. }
  280. //频道ID
  281. if (preg_match('#spec#i', $listtype)) $channelid == -1;
  282. if (!empty($channelid)) $orwheres[] = " And arc.channel = '$channelid' ";
  283. if (!empty($noflag)) {
  284. if (!preg_match('#,#', $noflag)) {
  285. $orwheres[] = " FIND_IN_SET('$noflag', arc.flag)<1 ";
  286. } else {
  287. $noflags = explode(',', $noflag);
  288. foreach ($noflags as $noflag) {
  289. if (trim($noflag) == '') continue;
  290. $orwheres[] = " FIND_IN_SET('$noflag', arc.flag)<1 ";
  291. }
  292. }
  293. }
  294. $orwheres[] = ' arc.arcrank > -1 ';
  295. //由于这个条件会导致缓存功能失去意义,因此取消
  296. //if($arcid!=0) $orwheres[] = " arc.id<>'$arcid' ";
  297. }
  298. //文档排序的方式
  299. $ordersql = '';
  300. if ($orderby == 'hot' || $orderby == 'click') $ordersql = " ORDER BY arc.click $orderWay";
  301. else if ($orderby == 'sortrank' || $orderby == 'pubdate') $ordersql = " ORDER BY arc.sortrank $orderWay";
  302. else if ($orderby == 'id') $ordersql = " ORDER BY arc.id $orderWay";
  303. else if ($orderby == 'near') $ordersql = " ORDER BY ABS(arc.id - " . $arcid . ")";
  304. else if ($orderby == 'lastpost') $ordersql = " ORDER BY arc.lastpost $orderWay";
  305. else if ($orderby == 'scores') $ordersql = " ORDER BY arc.scores $orderWay";
  306. //功能:增加按好评数和差评数调用
  307. else if ($orderby == 'goodpost') $ordersql = " order by arc.goodpost $orderWay";
  308. else if ($orderby == 'badpost') $ordersql = " order by arc.badpost $orderWay";
  309. else if ($orderby == 'rand') $ordersql = " ORDER BY rand()";
  310. else $ordersql = " ORDER BY arc.sortrank $orderWay";
  311. //limit条件
  312. $limit = trim(preg_replace('#limit#is', '', $limit));
  313. if ($limit != '') {
  314. $limitsql = " LIMIT $limit ";
  315. $limitarr = explode(',', $limit);
  316. $line = isset($limitarr[1]) ? $limitarr[1] : $line;
  317. } else $limitsql = " LIMIT 0,$line ";
  318. $orwhere = '';
  319. if (isset($orwheres[0])) {
  320. $orwhere = join(' And ', $orwheres);
  321. $orwhere = preg_replace("#^ And#is", '', $orwhere);
  322. $orwhere = preg_replace("#And[ ]{1,}And#is", 'And ', $orwhere);
  323. }
  324. if ($orwhere != '') $orwhere = " WHERE $orwhere ";
  325. //获取附加表信息
  326. $addfield = trim($ctag->GetAtt('addfields'));
  327. $addfieldsSql = '';
  328. $addfieldsSqlJoin = '';
  329. if ($addfield != '' && !empty($channelid)) {
  330. $row = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  331. if (isset($row['addtable']) && trim($row['addtable']) != '') {
  332. $addtable = trim($row['addtable']);
  333. $addfields = explode(',', $addfield);
  334. $row['addtable'] = trim($row['addtable']);
  335. $addfieldsSql = ",addf." . join(',addf.', $addfields);
  336. $addfieldsSqlJoin = " LEFT JOIN `$addtable` addf ON addf.aid = arc.id ";
  337. }
  338. }
  339. $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,
  340. tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
  341. $addfieldsSql
  342. FROM `$maintable` arc LEFT JOIN `#@__arctype` tp on arc.typeid=tp.id
  343. $addfieldsSqlJoin
  344. $orwhere $ordersql $limitsql";
  345. //统一hash
  346. $taghash = md5(serialize($ctag) . $typeid);
  347. $needSaveCache = true;
  348. //进行tagid的默认处理
  349. if ($pagesize > 0) $tagid = AttDef($tagid, 'tag' . $taghash);
  350. if ($idlist != '' || $GLOBALS['_arclistEnv'] == 'index' || $cfg_index_cache == 0) {
  351. $needSaveCache = false;
  352. } else {
  353. $idlist = GetArclistCache($taghash);
  354. if ($idlist != '') {
  355. $needSaveCache = false;
  356. }
  357. //如果使用的是内容缓存,直接返回结果
  358. if ($cfg_cache_type == 'content' && $idlist != '') {
  359. $idlist = ($idlist == 0 ? '' : $idlist);
  360. return $idlist;
  361. }
  362. }
  363. //指定了id或使用缓存中的id
  364. if ($idlist != '') {
  365. $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,
  366. tp.moresite,tp.siteurl,tp.sitepath
  367. $addfieldsSql
  368. FROM `$maintable` arc left join `#@__arctype` tp on arc.typeid=tp.id
  369. $addfieldsSqlJoin
  370. WHERE arc.id in($idlist) $ordersql ";
  371. }
  372. $dsql->SetQuery($query);
  373. $dsql->Execute('al');
  374. //$row = $dsql->GetArray("al");
  375. $artlist = '';
  376. if ($pagesize > 0) $artlist .= " <div id='{$tagid}'>\r\n";
  377. if ($col > 1) $artlist = "<table width='$tablewidth' border='0' cellspacing='0' cellpadding='0'>\r\n";
  378. $dtp2 = new DedeTagParse();
  379. $dtp2->SetNameSpace('field', '[', ']');
  380. $dtp2->LoadString($innertext);
  381. $GLOBALS['autoindex'] = 0;
  382. $ids = array();
  383. $orderWeight = array();
  384. for ($i = 0; $i < $line; $i++) {
  385. if ($col > 1) $artlist .= "<tr>\r\n";
  386. for ($j = 0; $j < $col; $j++) {
  387. if ($col > 1) $artlist .= " <td width='$colWidth'>\r\n";
  388. if ($row = $dsql->GetArray("al")) {
  389. $ids[] = $row['id'];
  390. //处理一些特殊字段
  391. $row['info'] = $row['infos'] = cn_substr($row['description'], $infolen);
  392. $row['id'] = $row['id'];
  393. if ($row['corank'] > 0 && $row['arcrank'] == 0) {
  394. $row['arcrank'] = $row['corank'];
  395. }
  396. $row['filename'] = $row['arcurl'] = GetFileUrl(
  397. $row['id'],
  398. $row['typeid'],
  399. $row['senddate'],
  400. $row['title'],
  401. $row['ismake'],
  402. $row['arcrank'],
  403. $row['namerule'],
  404. $row['typedir'],
  405. $row['money'],
  406. $row['filename'],
  407. $row['moresite'],
  408. $row['siteurl'],
  409. $row['sitepath']
  410. );
  411. $row['typeurl'] = GetTypeUrl(
  412. $row['typeid'],
  413. $row['typedir'],
  414. $row['isdefault'],
  415. $row['defaultname'],
  416. $row['ispart'],
  417. $row['namerule2'],
  418. $row['moresite'],
  419. $row['siteurl'],
  420. $row['sitepath']
  421. );
  422. if ($row['litpic'] == '-' || $row['litpic'] == '') {
  423. $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/static/defaultpic.gif';
  424. }
  425. if (!preg_match("#^http:\/\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
  426. $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
  427. }
  428. $row['picname'] = $row['litpic'];
  429. $row['stime'] = GetDateMK($row['pubdate']);
  430. $row['typelink'] = "<a href='" . $row['typeurl'] . "'>" . $row['typename'] . "</a>";
  431. $row['image'] = "<img src='" . $row['picname'] . "' border='0' width='$imgwidth' height='$imgheight' alt='" . preg_replace("#['><]#", "", $row['title']) . "'>";
  432. $row['imglink'] = "<a href='" . $row['filename'] . "'>" . $row['image'] . "</a>";
  433. $row['fulltitle'] = $row['title'];
  434. $row['title'] = cn_substr($row['title'], $titlelen);
  435. if ($row['color'] != '') $row['title'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
  436. if (preg_match('#b#', $row['flag'])) $row['title'] = "<strong>" . $row['title'] . "</strong>";
  437. //$row['title'] = "<b>".$row['title']."</b>";
  438. $row['textlink'] = "<a href='" . $row['filename'] . "'>" . $row['title'] . "</a>";
  439. $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
  440. $row['memberurl'] = $GLOBALS['cfg_memberurl'];
  441. $row['templeturl'] = $GLOBALS['cfg_templeturl'];
  442. if (is_array($dtp2->CTags)) {
  443. foreach ($dtp2->CTags as $k => $ctag) {
  444. if ($ctag->GetName() == 'array') {
  445. //传递整个数组,在runphp模式中有特殊作用
  446. $dtp2->Assign($k, $row);
  447. } else {
  448. if (isset($row[$ctag->GetName()])) $dtp2->Assign($k, $row[$ctag->GetName()]);
  449. else $dtp2->Assign($k, '');
  450. }
  451. }
  452. $GLOBALS['autoindex']++;
  453. }
  454. if ($pagesize > 0) {
  455. if ($GLOBALS['autoindex'] <= $pagesize) {
  456. $liststr = $dtp2->GetResult();
  457. $artlist .= $liststr . "\r\n";
  458. } else {
  459. $artlist .= "";
  460. $orderWeight[] = array(
  461. 'weight' => $row['weight'],
  462. 'arclist' => ''
  463. );
  464. }
  465. } else {
  466. $liststr = $dtp2->GetResult();
  467. $artlist .= $liststr . "\r\n";
  468. }
  469. $orderWeight[] = array(
  470. 'weight' => $row['weight'],
  471. 'arclist' => $liststr
  472. );
  473. } //if hasRow
  474. else {
  475. $artlist .= '';
  476. }
  477. // 进行判断,如果启用排序则内容输出为重新排序后的内容
  478. // var_dump($isweight=='y' && count($orderWeight) == $line);
  479. $isweight = strtolower($isweight);
  480. if ($isweight == 'y') {
  481. $artlist = '';
  482. $orderWeight = list_sort_by($orderWeight, 'weight', 'asc');
  483. foreach ($orderWeight as $vv) {
  484. $artlist .= $vv['arclist'];
  485. }
  486. }
  487. if ($col > 1) $artlist .= " </td>\r\n";
  488. } //Loop Col
  489. if ($col > 1) $i += $col - 1;
  490. if ($col > 1) $artlist .= " </tr>\r\n";
  491. } //loop line
  492. if ($col > 1) $artlist .= " </table>\r\n";
  493. $dsql->FreeResult("al");
  494. $idsstr = join(',', $ids);
  495. //分页特殊处理
  496. if ($pagesize > 0) {
  497. $artlist .= " </div>\r\n";
  498. $row = $dsql->GetOne("SELECT tagid FROM `#@__arcmulti` WHERE tagid='$tagid'");
  499. $uptime = time();
  500. $attstr = addslashes(serialize($attarray));
  501. $innertext = addslashes($innertext);
  502. if (!is_array($row)) {
  503. $query = "INSERT INTO `#@__arcmulti`(tagid,uptime,innertext,pagesize,arcids,ordersql,addfieldsSql,addfieldsSqlJoin,attstr)
  504. VALUES('$tagid','$uptime','$innertext','$pagesize','$idsstr','$ordersql','$addfieldsSql','$addfieldsSqlJoin','$attstr');
  505. ";
  506. $dsql->ExecuteNoneQuery($query);
  507. } else {
  508. $query = "UPDATE `#@__arcmulti`
  509. SET
  510. uptime='$uptime',
  511. innertext='$innertext',
  512. pagesize='$pagesize',
  513. arcids='$idsstr',
  514. ordersql='$ordersql',
  515. addfieldsSql='$addfieldsSql',
  516. addfieldsSqlJoin='$addfieldsSqlJoin',
  517. attstr='$attstr'
  518. WHERE tagid='$tagid'
  519. ";
  520. $dsql->ExecuteNoneQuery($query);
  521. }
  522. }
  523. //保存ID缓存
  524. if ($needSaveCache) {
  525. if ($idsstr == '') $idsstr = '0';
  526. if ($cfg_cache_type == 'content' && $idsstr != '0') {
  527. $idsstr = addslashes($artlist);
  528. }
  529. $inquery = "INSERT INTO `#@__arccache`(`md5hash`,`uptime`,`cachedata`) VALUES ('" . $taghash . "','" . time() . "', '$idsstr'); ";
  530. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arccache` WHERE md5hash='" . $taghash . "' ");
  531. $dsql->ExecuteNoneQuery($inquery);
  532. }
  533. return $artlist;
  534. }
  535. /**
  536. * 查询缓存
  537. *
  538. * @access public
  539. * @param string $md5hash 唯一识别hash
  540. * @return string
  541. */
  542. function GetArclistCache($md5hash)
  543. {
  544. global $dsql, $envs, $cfg_makesign_cache, $cfg_index_cache, $cfg_cache_type;
  545. if ($cfg_index_cache <= 0) return '';
  546. if (isset($envs['makesign']) && $cfg_makesign_cache == 'N') return '';
  547. $mintime = time() - $cfg_index_cache;
  548. $arr = $dsql->GetOne("SELECT cachedata,uptime FROM `#@__arccache` WHERE md5hash = '$md5hash' ");
  549. if (!is_array($arr)) {
  550. return '';
  551. } else if ($arr['uptime'] < $mintime) {
  552. return '';
  553. } else {
  554. return $arr['cachedata'];
  555. }
  556. }
  557. /**
  558. * 获取自动频道ID
  559. *
  560. * @access public
  561. * @param string $sortid
  562. * @param string $topid
  563. * @return string
  564. */
  565. function lib_GetAutoChannelID($sortid, $topid)
  566. {
  567. global $dsql;
  568. if (empty($sortid)) $sortid = 1;
  569. $getstart = $sortid - 1;
  570. $row = $dsql->GetOne("SELECT id,typename FROM `#@__arctype` WHERE reid='{$topid}' And ispart<2 And ishidden<>'1' ORDER BY sortrank asc limit $getstart,1");
  571. if (!is_array($row)) return 0;
  572. else return $row['id'];
  573. }
  574. /**
  575. * 对查询结果集进行排序
  576. *
  577. * @access public
  578. * @param array $list 查询结果
  579. * @param string $field 排序的字段名
  580. * @param array $sortby 排序类型
  581. * asc正向排序 desc逆向排序 nat自然排序
  582. * @return array
  583. */
  584. function list_sort_by($list, $field, $sortby = 'asc')
  585. {
  586. if (is_array($list)) {
  587. $refer = $resultSet = array();
  588. foreach ($list as $i => $data)
  589. $refer[$i] = &$data[$field];
  590. switch ($sortby) {
  591. case 'asc': // 正向排序
  592. asort($refer);
  593. break;
  594. case 'desc': // 逆向排序
  595. arsort($refer);
  596. break;
  597. case 'nat': // 自然排序
  598. natcasesort($refer);
  599. break;
  600. }
  601. foreach ($refer as $key => $val)
  602. $resultSet[] = &$list[$key];
  603. return $resultSet;
  604. }
  605. return false;
  606. }