国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

238 行
6.7KB

  1. <?php
  2. /**
  3. * 内容列表
  4. * content_s_list.php、content_i_list.php、content_select_list.php
  5. * 均使用本文件作为实际处理代码,只是使用的模板不同,如有相关变动,只需改本文件及相关模板即可
  6. *
  7. * @version $Id: content_list.php 1 14:31 2010年7月12日Z tianya $
  8. * @package DedeCMS.Administrator
  9. * @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
  10. * @license http://help.dedecms.com/usersguide/license.html
  11. * @link http://www.dedecms.com
  12. */
  13. require_once(dirname(__FILE__).'/config.php');
  14. require_once(DEDEINC.'/typelink.class.php');
  15. require_once(DEDEINC.'/datalistcp.class.php');
  16. require_once(DEDEADMIN.'/inc/inc_list_functions.php');
  17. $cid = isset($cid) ? intval($cid) : 0;
  18. $channelid = isset($channelid) ? intval($channelid) : 0;
  19. $mid = isset($mid) ? intval($mid) : 0;
  20. if(!isset($keyword)) $keyword = '';
  21. if(!isset($flag)) $flag = '';
  22. if(!isset($arcrank)) $arcrank = '';
  23. if(!isset($dopost)) $dopost = '';
  24. $arcrank = RemoveXSS($arcrank);
  25. //检查权限许可,总权限
  26. CheckPurview('a_List,a_AccList,a_MyList');
  27. //栏目浏览许可
  28. $userCatalogSql = '';
  29. if(TestPurview('a_List'))
  30. {
  31. ;
  32. }
  33. else if(TestPurview('a_AccList'))
  34. {
  35. if($cid==0 && $cfg_admin_channel == 'array')
  36. {
  37. $admin_catalog = join(',', $admin_catalogs);
  38. $userCatalogSql = " arc.typeid IN($admin_catalog) ";
  39. }
  40. else
  41. {
  42. CheckCatalog($cid, '你无权浏览非指定栏目的内容!');
  43. }
  44. if(TestPurview('a_MyList')) $mid = $cuserLogin->getUserID();
  45. }
  46. $adminid = $cuserLogin->getUserID();
  47. $maintable = '#@__archives';
  48. setcookie('ENV_GOBACK_URL', $dedeNowurl, time()+3600, '/');
  49. $tl = new TypeLink($cid);
  50. //----------------------------------------
  51. //在不指定排序条件和关键字的情况下直接统计微表
  52. //----------------------------------------
  53. if(empty($totalresult) && empty($keyword) && empty($orderby) && empty($flag))
  54. {
  55. $tinyQuerys = array();
  56. if(!empty($userCatalogSql))
  57. {
  58. $tinyQuerys[] = str_replace('arc.', '', $userCatalogSql);
  59. }
  60. if(!empty($channelid) && empty($cid))
  61. {
  62. $tinyQuerys[] = " channel = '$channelid' ";
  63. }
  64. else
  65. {
  66. $tinyQuerys[] = " channel>0 ";
  67. }
  68. if(!empty($arcrank))
  69. {
  70. $tinyQuerys[] = " arcrank='$arcrank' ";
  71. }
  72. else
  73. {
  74. $tinyQuerys[] = " arcrank > -2 ";
  75. }
  76. if(!empty($mid))
  77. {
  78. $tinyQuerys[] = " mid='$mid' ";
  79. }
  80. if(!empty($cid))
  81. {
  82. $tinyQuerys[] = " typeid in(".GetSonIds($cid).") ";
  83. }
  84. if(count($tinyQuerys)>0)
  85. {
  86. $tinyQuery = "WHERE ".join(' AND ',$tinyQuerys);
  87. }
  88. // 缓存处理
  89. $sql = "SELECT COUNT(*) AS dd FROM `#@__arctiny` $tinyQuery ";
  90. $arr = $dsql->GetOne($sql);
  91. $totalresult = $arr['dd'];
  92. }
  93. if($cid==0)
  94. {
  95. if($channelid==0)
  96. {
  97. $positionname = '所有栏目&gt;';
  98. }
  99. else
  100. {
  101. $row = $tl->dsql->GetOne("SELECT id,typename,maintable FROM `#@__channeltype` WHERE id='$channelid'");
  102. $positionname = $row['typename']." &gt; ";
  103. $maintable = $row['maintable'];
  104. $channelid = $row['id'];
  105. }
  106. }
  107. else
  108. {
  109. $positionname = str_replace($cfg_list_symbol," &gt; ",$tl->GetPositionName())." &gt; ";
  110. }
  111. //当选择的是单表模型栏目时,直接跳转到单表模型管理区
  112. if(empty($channelid)
  113. && isset($tl->TypeInfos['channeltype']))
  114. {
  115. $channelid = $tl->TypeInfos['channeltype'];
  116. }
  117. if($channelid < -1 )
  118. {
  119. header("location:content_sg_list.php?cid=$cid&channelid=$channelid&keyword=$keyword");
  120. exit();
  121. }
  122. // 栏目大于800则需要缓存数据
  123. $optHash = md5($cid. serialize($admin_catalogs).$channelid);
  124. $optCache = DEDEDATA."/tplcache/inc_option_$optHash.inc";
  125. $typeCount = 0;
  126. if (file_exists($cache1)) require_once($cache1);
  127. else $cfg_Cs = array();
  128. $typeCount = count($cfg_Cs);
  129. if ( $typeCount > 800)
  130. {
  131. if (file_exists($optCache))
  132. {
  133. $optionarr = file_get_contents($optCache);
  134. } else {
  135. $optionarr = $tl->GetOptionArray($cid, $admin_catalogs, $channelid);
  136. file_put_contents($optCache, $optionarr);
  137. }
  138. } else {
  139. $optionarr = $tl->GetOptionArray($cid, $admin_catalogs, $channelid);
  140. }
  141. $whereSql = empty($channelid) ? " WHERE arc.channel > 0 AND arc.arcrank > -2 " : " WHERE arc.channel = '$channelid' AND arc.arcrank > -2 ";
  142. $flagsArr = '';
  143. $dsql->Execute('f', 'SELECT * FROM `#@__arcatt` ORDER BY sortid ASC');
  144. while($frow = $dsql->GetArray('f'))
  145. {
  146. $flagsArr .= ($frow['att']==$flag ? "<option value='{$frow['att']}' selected>{$frow['attname']}</option>\r\n" : "<option value='{$frow['att']}'>{$frow['attname']}</option>\r\n");
  147. }
  148. if(!empty($userCatalogSql))
  149. {
  150. $whereSql .= " AND ".$userCatalogSql;
  151. }
  152. if(!empty($mid))
  153. {
  154. $whereSql .= " AND arc.mid = '$mid' ";
  155. }
  156. if($keyword != '')
  157. {
  158. $whereSql .= " AND ( CONCAT(arc.title,arc.writer) LIKE '%$keyword%') ";
  159. }
  160. if($flag != '')
  161. {
  162. $whereSql .= " AND FIND_IN_SET('$flag', arc.flag) ";
  163. }
  164. if($cid != 0)
  165. {
  166. $whereSql .= ' AND arc.typeid IN ('.GetSonIds($cid).')';
  167. }
  168. if($arcrank != '')
  169. {
  170. $whereSql .= " AND arc.arcrank = '$arcrank' ";
  171. $CheckUserSend = "<button type='button' class='btn btn-secondary btn-sm' onClick=\"location='catalog_do.php?cid=".$cid."&dopost=listArchives&gurl=content_list.php';\">所有文档</button>";
  172. }
  173. else
  174. {
  175. $CheckUserSend = "<button type='button' class='btn btn-secondary btn-sm' onClick=\"location='catalog_do.php?cid=".$cid."&dopost=listArchives&arcrank=-1&gurl=content_list.php';\">稿件审核</button>";
  176. }
  177. $orderby = empty($orderby) ? 'id' : preg_replace("#[^a-z0-9]#", "", $orderby);
  178. $orderbyField = 'arc.'.$orderby;
  179. $query = "SELECT arc.id,arc.typeid,arc.senddate,arc.flag,arc.ismake,
  180. arc.channel,arc.arcrank,arc.click,arc.title,arc.color,arc.litpic,arc.pubdate,arc.mid
  181. FROM `$maintable` arc
  182. $whereSql
  183. ORDER BY $orderbyField DESC";
  184. if(empty($f) || !preg_match("#form#", $f)) $f = 'form1.arcid1';
  185. //初始化
  186. $dlist = new DataListCP();
  187. $dlist->pageSize = 30;
  188. //GET参数
  189. $dlist->SetParameter('dopost', 'listArchives');
  190. $dlist->SetParameter('keyword', $keyword);
  191. if(!empty($mid)) $dlist->SetParameter('mid', $mid);
  192. $dlist->SetParameter('cid', $cid);
  193. $dlist->SetParameter('flag', $flag);
  194. $dlist->SetParameter('orderby', $orderby);
  195. $dlist->SetParameter('arcrank', $arcrank);
  196. $dlist->SetParameter('channelid', $channelid);
  197. $dlist->SetParameter('f', $f);
  198. //模板
  199. if(empty($s_tmplets)) $s_tmplets = 'templets/content_list.htm';
  200. $dlist->SetTemplate(DEDEADMIN.'/'.$s_tmplets);
  201. //查询
  202. $dlist->SetSource($query);
  203. //显示
  204. $dlist->Display();
  205. // echo $dlist->queryTime;
  206. $dlist->Close();