$title = '';
 if (!empty($_GET['title'])) {
     $title = str_replace(array('_', '%'), array('\\_', '\\%'), $_GET['title']);
 }
 if (!empty($dateline) && $dateline != 'all') {
     $srcdate = TIMESTAMP - $dateline;
 }
 $fids = $modfid && $modfid != -1 ? $modfid : 0;
 $isgroup = $modfid == -1 ? 1 : -1;
 $modcount = 0;
 $moderates = C::t('common_moderate')->fetch_all_by_idtype('tid', $moderatestatus, $srcdate);
 if (!empty($moderates)) {
     $modcount = C::t('forum_thread')->count_by_tid_fid(array_keys($moderates), $fids, $isgroup, $_GET['username'], $title);
 }
 if ($modcount != count($moderates) && !$srcdate && !$fids && !$_GET['username'] && !$title) {
     moderateswipe('tid', array_keys($moderates));
 }
 $start_limit = ($page - 1) * $tpp;
 if ($modcount) {
     $threadlist = C::t('forum_thread')->fetch_all_by_tid_fid(array_keys($moderates), $fids, $isgroup, $_GET['username'], $title, $start_limit, $tpp);
     $tids = C::t('forum_thread')->get_posttableid();
     if ($tids) {
         foreach ($tids as $posttableid => $tid) {
             foreach (C::t('forum_post')->fetch_all_by_tid($posttableid, $tid, true, '', 0, 0, 1) as $post) {
                 $threadlist[$post['tid']] = array_merge($threadlist[$post['tid']], $post);
             }
         }
     }
     $multipage = multi($modcount, $tpp, $page, ADMINSCRIPT . "?action=moderate&operation=threads&filter={$filter}&modfid={$modfid}&dateline={$_GET['dateline']}&username={$_GET['username']}&title={$_GET['title']}&tpp={$tpp}&showcensor={$showcensor}");
 }
 echo '<p class="margintop marginbot"><a href="javascript:;" onclick="expandall();">' . cplang('moderate_all_expand') . '</a> &nbsp;<a href="javascript:;" onclick="foldall();">' . cplang('moderate_all_fold') . '</a><p>';
 }
 $modcount = C::t('common_moderate')->count_by_search_for_post(getposttable($posttable), $moderatestatus, 0, $modfid > 0 ? $modfid : 0, $_GET['username'], $dateline && $dateline != 'all' ? TIMESTAMP - $dateline : null, $_GET['title']);
 $start_limit = ($page - 1) * $ppp;
 $postarr = C::t('common_moderate')->fetch_all_by_search_for_post(getposttable($posttable), $moderatestatus, 0, $modfid > 0 ? $modfid : 0, $_GET['username'], $dateline && $dateline != 'all' ? TIMESTAMP - $dateline : null, $_GET['title'], $start_limit, $ppp);
 if ($postarr) {
     $_tids = $_fids = array();
     foreach ($postarr as $_post) {
         $_fids[$_post['fid']] = $_post['fid'];
         $_tids[$_post['tid']] = $_post['tid'];
     }
     $_forums = C::t('forum_forum')->fetch_all($_fids);
     $_threads = C::t('forum_thread')->fetch_all($_tids);
 }
 $checklength = C::t('common_moderate')->fetch_all_by_idtype('pid', $moderatestatus, null);
 if ($modcount != $checklength && !$srcdate && !$modfid && !$_GET['username'] && !$_GET['title'] && !$posttable) {
     moderateswipe('pid', array_keys($checklength));
 }
 $multipage = multi($modcount, $ppp, $page, ADMINSCRIPT . "?action=moderate&operation=replies&filter={$filter}&modfid={$modfid}&dateline={$_GET['dateline']}&username={$_GET['username']}&title={$_GET['title']}&ppp={$ppp}&showcensor={$showcensor}&posttableid={$posttable}");
 echo '<p class="margintop marginbot"><a href="javascript:;" onclick="expandall();">' . cplang('moderate_all_expand') . '</a> <a href="javascript:;" onclick="foldall();">' . cplang('moderate_all_fold') . '</a><p>';
 $censor =& discuz_censor::instance();
 $censor->highlight = '#FF0000';
 require_once libfile('function/misc');
 foreach ($postarr as &$post) {
     $_forum = $_forums[$post['fid']];
     $_arr = array('forumname' => $_forum['name'], 'allowsmilies' => $_forum['allowsmilies'], 'allowhtml' => $_forum['allowhtml'], 'allowbbcode' => $_forum['allowbbcode'], 'allowimgcode' => $_forum['allowimgcode']);
     $post = array_merge($post, $_arr);
     if (getstatus($post['status'], 5)) {
         $post['authorid'] = 0;
         $post['author'] = cplang('moderate_t_comment');
     }
     $post['dateline'] = dgmdate($post['dateline']);