[ PHPXref.com ] [ Generated: Sat Aug 9 15:45:03 2008 ] [ FluxBB 1.3 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/admin/ -> reports.php (source)

   1  <?php
   2  /**
   3   * Report management page
   4   *
   5   * Allows administrators and moderators to handle reported posts.
   6   *
   7   * @copyright Copyright (C) 2008 FluxBB.org, based on code copyright (C) 2002-2008 PunBB.org
   8   * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
   9   * @package FluxBB
  10   */
  11  
  12  
  13  if (!defined('FORUM_ROOT'))
  14      define('FORUM_ROOT', '../');
  15  require  FORUM_ROOT.'include/common.php';
  16  require  FORUM_ROOT.'include/common_admin.php';
  17  
  18  ($hook = get_hook('arp_start')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null;
  19  
  20  if (!$forum_user['is_admmod'])
  21      message($lang_common['No permission']);
  22  
  23  // Load the admin.php language file
  24  require FORUM_ROOT.'lang/'.$forum_user['language'].'/admin_common.php';
  25  require FORUM_ROOT.'lang/'.$forum_user['language'].'/admin_reports.php';
  26  
  27  
  28  // Mark reports as read
  29  if (isset($_POST['mark_as_read']))
  30  {
  31      if (empty($_POST['reports']))
  32          message($lang_admin_reports['No reports selected']);
  33  
  34      ($hook = get_hook('arp_mark_as_read_form_submitted')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null;
  35  
  36      $reports_to_mark = array_map('intval', array_keys($_POST['reports']));
  37  
  38      $query = array(
  39          'UPDATE'    => 'reports',
  40          'SET'        => 'zapped='.time().', zapped_by='.$forum_user['id'],
  41          'WHERE'        => 'id IN('.implode(',', $reports_to_mark).') AND zapped IS NULL'
  42      );
  43  
  44      ($hook = get_hook('arp_mark_as_read_qr_mark_reports_as_read')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null;
  45      $forum_db->query_build($query) or error(__FILE__, __LINE__);
  46  
  47      ($hook = get_hook('arp_mark_as_read_pre_redirect')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null;
  48  
  49      redirect(forum_link($forum_url['admin_reports']), $lang_admin_reports['Reports marked read'].' '.$lang_admin_common['Redirect']);
  50  }
  51  
  52  $forum_page['group_count'] = $forum_page['item_count'] = $forum_page['fld_count'] = 0;
  53  
  54  // Setup breadcrumbs
  55  $forum_page['crumbs'] = array(
  56      array($forum_config['o_board_title'], forum_link($forum_url['index'])),
  57      array($lang_admin_common['Forum administration'], forum_link($forum_url['admin_index'])),
  58      $lang_admin_common['Reports']
  59  );
  60  
  61  ($hook = get_hook('arp_pre_header_load')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null;
  62  
  63  define('FORUM_PAGE_SECTION', 'management');
  64  define('FORUM_PAGE', 'admin-reports');
  65  define('FORUM_PAGE_TYPE', 'sectioned');
  66  require  FORUM_ROOT.'header.php';
  67  
  68  // START SUBST - <!-- forum_main -->
  69  ob_start();
  70  
  71  ($hook = get_hook('arp_main_output_start')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null;
  72  
  73  // Fetch any unread reports
  74  $query = array(
  75      'SELECT'    => 'r.id, r.topic_id, r.forum_id, r.reported_by, r.created, r.message, p.id AS pid, t.subject, f.forum_name, u.username AS reporter',
  76      'FROM'        => 'reports AS r',
  77      'JOINS'        => array(
  78          array(
  79              'LEFT JOIN'        => 'posts AS p',
  80              'ON'            => 'r.post_id=p.id'
  81          ),
  82          array(
  83              'LEFT JOIN'        => 'topics AS t',
  84              'ON'            => 'r.topic_id=t.id'
  85          ),
  86          array(
  87              'LEFT JOIN'        => 'forums AS f',
  88              'ON'            => 'r.forum_id=f.id'
  89          ),
  90          array(
  91              'LEFT JOIN'        => 'users AS u',
  92              'ON'            => 'r.reported_by=u.id'
  93          )
  94      ),
  95      'WHERE'        => 'r.zapped IS NULL',
  96      'ORDER BY'    => 'r.created DESC'
  97  );
  98  
  99  ($hook = get_hook('arp_qr_get_new_reports')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null;
 100  
 101  $forum_page['new_reports'] = false;
 102  $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
 103  if ($forum_db->num_rows($result))
 104  {
 105      $forum_page['new_reports'] = true;
 106  
 107  ?>
 108      <div class="main-subhead">
 109          <h2 class="hn"><span><?php echo $lang_admin_reports['New reports heading'] ?></span></h2>
 110      </div>
 111      <div class="main-content main-frm">
 112          <form id="arp-new-report-form" class="frm-form" method="post" accept-charset="utf-8" action="<?php echo forum_link($forum_url['admin_reports']) ?>?action=zap">
 113              <div class="hidden">
 114                  <input type="hidden" name="csrf_token" value="<?php echo generate_form_token(forum_link($forum_url['admin_reports']).'?action=zap') ?>" />
 115              </div>
 116  <?php
 117  
 118      $forum_page['item_num'] = 0;
 119  
 120      while ($cur_report = $forum_db->fetch_assoc($result))
 121      {
 122          $reporter = ($cur_report['reporter'] != '') ? '<a href="'.forum_link($forum_url['user'], $cur_report['reported_by']).'">'.forum_htmlencode($cur_report['reporter']).'</a>' : $lang_admin_reports['Deleted user'];
 123          $forum = ($cur_report['forum_name'] != '') ? '<a href="'.forum_link($forum_url['forum'], array($cur_report['forum_id'], sef_friendly($cur_report['forum_name']))).'">'.forum_htmlencode($cur_report['forum_name']).'</a>' : $lang_admin_reports['Deleted forum'];
 124          $topic = ($cur_report['subject'] != '') ? '<a href="'.forum_link($forum_url['topic'], array($cur_report['topic_id'], sef_friendly($cur_report['subject']))).'">'.forum_htmlencode($cur_report['subject']).'</a>' : $lang_admin_reports['Deleted topic'];
 125          $message = str_replace("\n", '<br />', forum_htmlencode($cur_report['message']));
 126          $post_id = ($cur_report['pid'] != '') ? '<a href="'.forum_link($forum_url['post'], $cur_report['pid']).'">Post #'.$cur_report['pid'].'</a>' : $lang_admin_reports['Deleted post'];
 127  
 128          ($hook = get_hook('arp_new_report_pre_display')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null;
 129  
 130  ?>
 131              <div class="ct-set warn-set report group-item<?php echo ++$forum_page['item_count'] ?>">
 132                  <div class="ct-box warn-box">
 133                      <h3 class="ct-legend hn"><strong><?php echo ++$forum_page['item_num'] ?></strong> <cite class="username"><?php printf($lang_admin_reports['Reported by'], $reporter) ?></cite> <span><?php echo format_time($cur_report['created']) ?></span></h3>
 134                      <h4 class="hn"><?php echo $forum ?> : <?php echo $topic ?> : <?php echo $post_id ?></h4>
 135                      <p><?php echo $message ?></p>
 136                      <p class="item-select"><input type="checkbox" id="fld<?php echo ++$forum_page['fld_count'] ?>" name="reports[<?php echo $cur_report['id'] ?>]" value="1" /> <label for="fld<?php echo $forum_page['fld_count'] ?>"><?php echo $lang_admin_reports['Select report'] ?></label></p>
 137  <?php ($hook = get_hook('arp_new_report_new_block')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; ?>
 138                  </div>
 139              </div>
 140  <?php
 141  
 142      }
 143  
 144  ?>
 145              <div class="frm-buttons">
 146                  <span id="select-all"><a href="#" onclick="return Forum.toggleCheckboxes(document.getElementById('arp-new-report-form'))"><?php echo $lang_admin_common['Select all'] ?></a></span>
 147                  <span class="submit"><input type="submit" name="mark_as_read" value="<?php echo $lang_admin_reports['Mark read'] ?>" /></span>
 148              </div>
 149          </form>
 150      </div>
 151  <?php
 152  
 153  }
 154  
 155  ?>
 156      <div class="main-subhead">
 157          <h2 class="hn"><span><?php echo $lang_admin_reports['Read reports heading'] ?><?php echo ($forum_db->num_rows($result)) ? '' : ' '.$lang_admin_reports['No new reports'] ?></span></h2>
 158      </div>
 159      <div class="main-content main-frm">
 160  <?php
 161  
 162  // Fetch the last 10 reports marked as read
 163  $query = array(
 164      'SELECT'    => 'r.id, r.topic_id, r.forum_id, r.reported_by, r.created, r.message, r.zapped, r.zapped_by AS zapped_by_id, p.id AS pid, t.subject, f.forum_name, u.username AS reporter, u2.username AS zapped_by',
 165      'FROM'        => 'reports AS r',
 166      'JOINS'        => array(
 167          array(
 168              'LEFT JOIN'        => 'posts AS p',
 169              'ON'            => 'r.post_id=p.id'
 170          ),
 171          array(
 172              'LEFT JOIN'        => 'topics AS t',
 173              'ON'            => 'r.topic_id=t.id'
 174          ),
 175          array(
 176              'LEFT JOIN'        => 'forums AS f',
 177              'ON'            => 'r.forum_id=f.id'
 178          ),
 179          array(
 180              'LEFT JOIN'        => 'users AS u',
 181              'ON'            => 'r.reported_by=u.id'
 182          ),
 183          array(
 184              'LEFT JOIN'        => 'users AS u2',
 185              'ON'            => 'r.zapped_by=u2.id'
 186          )
 187      ),
 188      'WHERE'        => 'r.zapped IS NOT NULL',
 189      'ORDER BY'    => 'r.zapped DESC',
 190      'LIMIT'        => '10'
 191  );
 192  
 193  ($hook = get_hook('arp_qr_get_last_zapped_reports')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null;
 194  
 195  $forum_page['old_reports'] = false;
 196  $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
 197  if ($forum_db->num_rows($result))
 198  {
 199      $i = 1;
 200      $forum_page['group_count'] = $forum_page['item_count'] = $forum_page['item_num'] = 0;
 201      $forum_page['old_reports'] = true;
 202  
 203      while ($cur_report = $forum_db->fetch_assoc($result))
 204      {
 205          $reporter = ($cur_report['reporter'] != '') ? '<a href="'.forum_link($forum_url['user'], $cur_report['reported_by']).'">'.forum_htmlencode($cur_report['reporter']).'</a>' : $lang_admin_reports['Deleted user'];
 206          $forum = ($cur_report['forum_name'] != '') ? '<a href="'.forum_link($forum_url['forum'], array($cur_report['forum_id'], sef_friendly($cur_report['forum_name']))).'">'.forum_htmlencode($cur_report['forum_name']).'</a>' : $lang_admin_reports['Deleted forum'];
 207          $topic = ($cur_report['subject'] != '') ? '<a href="'.forum_link($forum_url['topic'], array($cur_report['topic_id'], sef_friendly($cur_report['subject']))).'">'.forum_htmlencode($cur_report['subject']).'</a>' : $lang_admin_reports['Deleted topic'];
 208          $message = str_replace("\n", '<br />', forum_htmlencode($cur_report['message']));
 209          $post_id = ($cur_report['pid'] != '') ? '<a href="'.forum_link($forum_url['post'], $cur_report['pid']).'">Post #'.$cur_report['pid'].'</a>' : $lang_admin_reports['Deleted post'];
 210          $zapped_by = ($cur_report['zapped_by'] != '') ? '<a href="'.forum_link($forum_url['user'], $cur_report['zapped_by_id']).'">'.forum_htmlencode($cur_report['zapped_by']).'</a>' : $lang_admin_reports['Deleted user'];
 211  
 212          ($hook = get_hook('arp_report_pre_display')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null;
 213  
 214  ?>
 215              <div class="ct-set report data-set group-item<?php echo ++$forum_page['item_count'] ?>">
 216                  <div class="ct-box data-box">
 217                      <h3 class="ct-legend hn"><strong><?php echo ++$forum_page['item_num'] ?></strong> <cite class="username"><?php printf($lang_admin_reports['Reported by'], $reporter) ?></cite> <span><?php echo format_time($cur_report['created']) ?></span></h3>
 218                      <h4 class="hn"><?php echo $forum ?> : <?php echo $topic ?> : <?php echo $post_id ?></h4>
 219                      <p><?php echo $message ?> <strong><?php printf($lang_admin_reports['Marked read by'], format_time($cur_report['zapped']), $zapped_by) ?></strong></p>
 220  <?php ($hook = get_hook('arp_report_new_block')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; ?>
 221                  </div>
 222              </div>
 223  <?php
 224  
 225      }
 226  
 227  ?>
 228      </div>
 229  <?php
 230  
 231  }
 232  
 233  if (!$forum_page['new_reports'] && !$forum_page['old_reports'])
 234  {
 235  
 236  ?>
 237      <div class="main-subhead">
 238          <h2 class="hn"><span><?php echo $lang_admin_reports['Empty reports heading'] ?></span></h2>
 239      </div>
 240      <div class="main-content main-frm">
 241          <div class="ct-box">
 242              <p><?php echo $lang_admin_reports['No reports'] ?></p>
 243          </div>
 244      </div>
 245  <?php
 246  
 247  }
 248  
 249  ($hook = get_hook('arp_end')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null;
 250  
 251  $tpl_temp = forum_trim(ob_get_contents());
 252  $tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main);
 253  ob_end_clean();
 254  // END SUBST - <!-- forum_main -->
 255  
 256  require  FORUM_ROOT.'footer.php';


[ Powered by PHPXref - Served by Debian GNU/Linux ]