PageRenderTime 38ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/source/include/modcp/modcp_recyclebinpost.php

https://github.com/kuaileshike/upload
PHP | 164 lines | 121 code | 37 blank | 6 comment | 45 complexity | f3df4fba8ad799d0276d396ed41686dc 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_recyclebinpost.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. $pidarray = array();
  14. $action = $_GET['action'];
  15. $result = array();
  16. foreach (array('starttime', 'endtime', 'keywords', 'users') as $key) {
  17. $$key = isset($_GET[''.$key]) ? trim($_GET[''.$key]) : '';
  18. $result[$key] = isset($_GET[''.$key]) ? dhtmlspecialchars($_GET[''.$key]) : '';
  19. }
  20. $postlist = array();
  21. $total = $multipage = '';
  22. $posttableid = intval($_GET['posttableid']);
  23. $posttableselect = getposttableselect();
  24. $cachekey = 'srchresult_recycle_post_'.$posttableid.'_'.$_G['fid'];
  25. if($_G['fid'] && $_G['forum']['ismoderator'] && $modforums['recyclebins'][$_G['fid']]) {
  26. $srchupdate = false;
  27. if(in_array($_G['adminid'], array(1, 2, 3)) && ($op == 'delete' || $op == 'restore') && submitcheck('dosubmit')) {
  28. if($ids = dimplode($_GET['moderate'])) {
  29. $pidarray = array();
  30. foreach(C::t('forum_post')->fetch_all($posttableid, $_GET['moderate'], false) as $post) {
  31. if($post['fid'] != $_G['fid'] || $post['invisible'] != '-5') {
  32. continue;
  33. }
  34. $pidarray[] = $post['pid'];
  35. }
  36. if($pidarray) {
  37. require_once libfile('function/misc');
  38. if ($op == 'delete' && $_G['group']['allowclearrecycle']){
  39. recyclebinpostdelete($pidarray, $posttableid);
  40. }
  41. if ($op == 'restore') {
  42. recyclebinpostundelete($pidarray, $posttableid);
  43. }
  44. if($_GET['oldop'] == 'search') {
  45. $srchupdate = true;
  46. }
  47. }
  48. }
  49. $op = dhtmlspecialchars($_GET['oldop']);
  50. showmessage('modcp_recyclebinpost_'.$op.'_succeed', '', array(), array('break' => 1));
  51. }
  52. if($op == 'search' && submitcheck('searchsubmit')) {
  53. if($starttime || $endtime || trim($keywords) || trim($users)) {
  54. $pids = array();
  55. foreach(C::t('forum_post')->fetch_all_by_search($posttableid, null, $keywords, -5, null, null, ($users ? explode(',', str_replace(' ', '', trim($users))) : null), strtotime($starttime), strtotime($endtime), null, null, 0, 1000) as $value) {
  56. $postlist[] = $value;
  57. $pids[] = $value['pid'];
  58. }
  59. $result['pids'] = implode(',', $pids);
  60. $result['count'] = count($pids);
  61. $result['fid'] = $_G['fid'];
  62. $result['posttableid'] = $posttableid;
  63. $modsession->set($cachekey, $result, true);
  64. unset($result, $pids);
  65. $page = 1;
  66. } else {
  67. $op = 'list';
  68. }
  69. }
  70. $page = max(1, intval($_G['page']));
  71. $total = 0;
  72. $query = $multipage = '';
  73. $fields = 'message, useip, attachment, htmlon, smileyoff, bbcodeoff, pid, tid, fid, author, dateline, subject, authorid, anonymous';
  74. if($op == 'list') {
  75. $total = C::t('forum_post')->count_by_fid_invisible($posttableid, $_G['fid'], '-5');
  76. $tpage = ceil($total / $_G['tpp']);
  77. $page = min($tpage, $page);
  78. $multipage = multi($total, $_G['tpp'], $page, "$cpscript?mod=modcp&action=$action&amp;op=$op&amp;fid=$_G[fid]&amp;do=$do");
  79. if($total) {
  80. $start = ($page - 1) * $_G['tpp'];
  81. foreach(C::t('forum_post')->fetch_all_by_fid($posttableid, $_G['fid'], true, 'DESC', $start, $_G['tpp'], null, '-5') as $value) {
  82. $postlist[] = $value;
  83. }
  84. }
  85. }
  86. if($op == 'search') {
  87. $result = $modsession->get($cachekey);
  88. if($result) {
  89. if($srchupdate && $result['count'] && $pidarray) {
  90. $pd = explode(',', $result['pids']);
  91. $newpids = $comma = $newcount = '';
  92. if(is_array($pd)) {
  93. foreach ($pd as $v) {
  94. $v = intval($v);
  95. if(!in_array($v, $pidarray)) {
  96. $newcount ++;
  97. $newpids .= $comma.$v; $comma = ',';
  98. }
  99. }
  100. $result['count'] = $newcount;
  101. $result['pids'] = $newpids;
  102. $modsession->set($cachekey, $result, true);
  103. }
  104. }
  105. $total = $result['count'];
  106. $tpage = ceil($total / $_G['tpp']);
  107. $page = min($tpage, $page);
  108. $multipage = multi($total, $_G['tpp'], $page, "$cpscript?mod=modcp&action=$action&amp;op=$op&amp;fid=$_G[fid]&amp;do=$do");
  109. if($total) {
  110. $start = ($page - 1) * $_G['tpp'];
  111. $postlist = C::t('forum_post')->fetch_all_by_pid($posttableid, explode(',', $result['pids']), true, 'DESC', $start, $_G['tpp'], $_G['fid'], -5);
  112. }
  113. }
  114. }
  115. if($postlist) {
  116. require_once libfile('function/misc');
  117. require_once libfile('function/post');
  118. require_once libfile('function/discuzcode');
  119. foreach($postlist as $key => $post) {
  120. $post['modthreadkey'] = modauthkey($post['tid']);
  121. $post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], sprintf('%00b', $post['htmlon']), $_G['forum']['allowsmilies'], $_G['forum']['allowbbcode'], $_G['forum']['allowimgcode'], $_G['forum']['allowhtml']);
  122. $post['dateline'] = dgmdate($post['dateline'], 'Y-m-d H:i:s');
  123. $postlist[$key] = $post;
  124. }
  125. }
  126. }
  127. ?>