PageRenderTime 39ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/source/include/modcp/modcp_recyclebin.php

https://github.com/kuaileshike/upload
PHP | 210 lines | 155 code | 49 blank | 6 comment | 50 complexity | 490d290d34580b632f1bffb29fe9cc62 MD5 | raw file
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: modcp_recyclebin.php 27222 2012-01-11 08:01:39Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
  9. exit('Access Denied');
  10. }
  11. $op = !in_array($op , array('list', 'delete', 'search', 'restore')) ? 'list' : $op;
  12. $do = !empty($_GET['do']) ? dhtmlspecialchars($_GET['do']) : '';
  13. $tidarray = array();
  14. $action = $_GET['action'];
  15. $result = array();
  16. foreach (array('threadoption', 'viewsless', 'viewsmore', 'repliesless', 'repliesmore', 'noreplydays', 'typeid') as $key) {
  17. $$key = isset($_GET[''.$key]) && is_numeric($_GET[''.$key]) ? intval($_GET[''.$key]) : '';
  18. $result[$key] = $$key;
  19. }
  20. foreach (array('starttime', 'endtime', 'keywords', 'users') as $key) {
  21. $$key = isset($_GET[''.$key]) ? trim($_GET[''.$key]) : '';
  22. $result[$key] = isset($_GET[''.$key]) ? dhtmlspecialchars($_GET[''.$key]) : '';
  23. }
  24. $threadoptionselect = array('','','','','','', '', '', '', '', 999=>'', 888=>'');
  25. $threadoptionselect[$threadoption] = 'selected';
  26. $postlist = array();
  27. $total = $multipage = '';
  28. $cachekey = 'srchresult_recycle_thread'.$_G['fid'];
  29. if($_G['fid'] && $_G['forum']['ismoderator'] && $modforums['recyclebins'][$_G['fid']]) {
  30. $srchupdate = false;
  31. if(in_array($_G['adminid'], array(1, 2, 3)) && ($op == 'delete' || $op == 'restore') && submitcheck('dosubmit')) {
  32. if(!empty($_GET['moderate'])) {
  33. foreach(C::t('forum_thread')->fetch_all_by_tid_displayorder($_GET['moderate'], -1, '=', $_G['fid']) as $tid) {
  34. $tidarray[] = $tid['tid'];
  35. }
  36. if($tidarray) {
  37. if($op == 'delete' && $_G['group']['allowclearrecycle']) {
  38. require_once libfile('function/delete');
  39. deletethread($tidarray);
  40. }
  41. if($op == 'restore') {
  42. require_once libfile('function/post');
  43. undeletethreads($tidarray);
  44. }
  45. if($_GET['oldop'] == 'search') {
  46. $srchupdate = true;
  47. }
  48. }
  49. }
  50. $op = dhtmlspecialchars($_GET['oldop']);
  51. showmessage('modcp_recyclebin_'.$op.'_succeed', '', array(), array('break' => 1));
  52. }
  53. if($op == 'search' && submitcheck('searchsubmit')) {
  54. $conditions = array();
  55. if($threadoption > 0 && $threadoption < 255) {
  56. $conditions['specialthread'] = 1;
  57. $conditions['special'] = $threadoption;
  58. } elseif($threadoption == 999) {
  59. $conditions['digest'] = array(1,2,3);
  60. } elseif($threadoption == 888) {
  61. $conditions['sticky'] = 1;
  62. }
  63. $viewsless !== ''? $conditions['viewsless'] = $viewsless : '';
  64. $viewsmore !== ''? $conditions['viewsmore'] = $viewsmore : '';
  65. $repliesless !== ''? $conditions['repliesless'] = $repliesless : '';
  66. $repliesmore !== ''? $conditions['repliesmore'] = $repliesmore : '';
  67. $noreplydays !== ''? $conditions['noreplydays'] = $noreplydays : '';
  68. $starttime != '' ? $conditions['starttime'] = $starttime : '';
  69. $endtime != '' ? $conditions['endtime'] = $endtime : '';
  70. if(trim($keywords)) {
  71. $conditions['keywords'] = $keywords;
  72. }
  73. if(trim($users)) {
  74. $conditions['users'] = trim($users);
  75. }
  76. if($_GET['typeid']) {
  77. $conditions['intype'] = $_GET['typeid'];
  78. }
  79. if(!empty($conditions)) {
  80. $tids = $comma = '';
  81. $count = 0;
  82. $conditions['fid'] = $_G['fid'];
  83. $conditions['sticky'] = 3;
  84. foreach(C::t('forum_thread')->fetch_all_search($conditions, 0, 0, 1000, 'lastpost') as $thread) {
  85. $tids .= $comma.$thread['tid'];
  86. $comma = ',';
  87. $count ++;
  88. }
  89. $result['tids'] = $tids;
  90. $result['count'] = $count;
  91. $result['fid'] = $_G['fid'];
  92. $modsession->set($cachekey, $result, true);
  93. unset($result, $tids);
  94. $page = 1;
  95. } else {
  96. $op = 'list';
  97. }
  98. }
  99. $page = max(1, intval($_G['page']));
  100. $total = 0;
  101. $query = $multipage = '';
  102. if($op == 'list') {
  103. $total = C::t('forum_thread')->count_by_fid_typeid_displayorder($_G['fid'], $_GET['typeid'], -1);
  104. $tpage = ceil($total / $_G['tpp']);
  105. $page = min($tpage, $page);
  106. $multipage = multi($total, $_G['tpp'], $page, "$cpscript?mod=modcp&action=$action&op=$op&fid=$_G[fid]&do=$do");
  107. if($total) {
  108. $start = ($page - 1) * $_G['tpp'];
  109. $threads = C::t('forum_thread')->fetch_all_by_fid_typeid_displayorder($_G['fid'], $_GET['typeid'], -1, '=', $start, $_G['tpp']);
  110. }
  111. }
  112. if($op == 'search') {
  113. $result = $modsession->get($cachekey);
  114. if($result) {
  115. if($srchupdate && $result['count'] && $tidarray) {
  116. $td = explode(',', $result['tids']);
  117. $newtids = $comma = $newcount = '';
  118. if(is_array($td)) {
  119. foreach ($td as $v) {
  120. $v = intval($v);
  121. if(!in_array($v, $tidarray)) {
  122. $newcount ++;
  123. $newtids .= $comma.$v;
  124. $comma = ',';
  125. }
  126. }
  127. $result['count'] = $newcount;
  128. $result['tids'] = $newtids;
  129. $modsession->set($cachekey, $result, true);
  130. }
  131. }
  132. $threadoptionselect[$result['threadoption']] = 'selected';
  133. $total = $result['count'];
  134. $tpage = ceil($total / $_G['tpp']);
  135. $page = min($tpage, $page);
  136. $multipage = multi($total, $_G['tpp'], $page, "$cpscript?mod=modcp&action=$action&op=$op&fid=$_G[fid]&do=$do");
  137. if($total) {
  138. $start = ($page - 1) * $_G['tpp'];
  139. $threads = C::t('forum_thread')->fetch_all_by_tid_fid_displayorder(explode(',', $result['tids']), $_G['fid'], -1, 'lastpost', $start, $_G['tpp']);
  140. }
  141. }
  142. }
  143. $postlist = array();
  144. if($threads) {
  145. require_once libfile('function/misc');
  146. foreach($threads as $thread) {
  147. $post = procthread($thread);
  148. $post['modthreadkey'] = modauthkey($post['tid']);
  149. $postlist[$post['tid']] = $post;
  150. }
  151. if($postlist) {
  152. $tids = array_keys($postlist);
  153. foreach(C::t('forum_threadmod')->fetch_all_by_tid($tids) as $row) {
  154. if(empty($postlist[$row['tid']]['reason'])) {
  155. $postlist[$row['tid']]['reason'] = $row['reason'];
  156. }
  157. }
  158. }
  159. }
  160. }
  161. ?>