[ Index ]

PHP Cross Reference of phpBB 3.0 Beta 3

title

Body

[close]

/ -> report.php (source)

   1  <?php
   2  /** 
   3  *
   4  * @package phpBB3
   5  * @version $Id: report.php,v 1.34 2006/11/12 14:29:31 naderman Exp $
   6  * @copyright (c) 2005 phpBB Group 
   7  * @license http://opensource.org/licenses/gpl-license.php GNU Public License 
   8  *
   9  */
  10  
  11  /**
  12  * @ignore
  13  */
  14  define('IN_PHPBB', true);
  15  $phpbb_root_path = './';
  16  $phpEx = substr(strrchr(__FILE__, '.'), 1);
  17  include($phpbb_root_path . 'common.' . $phpEx);
  18  include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
  19  
  20  // Start session management
  21  $user->session_begin();
  22  $auth->acl($user->data);
  23  $user->setup('mcp');
  24  
  25  $forum_id        = request_var('f', 0);
  26  $post_id        = request_var('p', 0);
  27  $reason_id        = request_var('reason_id', 0);
  28  $report_text    = request_var('report_text', '', true);
  29  
  30  utf8_normalize_nfc(&$report_text);
  31  
  32  $user_notify = (isset($_POST['notify']) && $user->data['is_registered']) ? true : false;
  33  $submit = (isset($_POST['submit'])) ? true : false;
  34  
  35  if (!$post_id)
  36  {
  37      trigger_error('NO_POST_SELECTED');
  38  }
  39  
  40  $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;p=$post_id") . "#p$post_id";
  41  
  42  // Has the report been cancelled?
  43  if (isset($_POST['cancel']))
  44  {
  45      redirect($redirect_url);
  46  }
  47  
  48  // Grab all relevant data
  49  $sql = 'SELECT t.*, p.*
  50      FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
  51      WHERE p.post_id = $post_id
  52          AND p.topic_id = t.topic_id";
  53  $result = $db->sql_query($sql);
  54  $report_data = $db->sql_fetchrow($result);
  55  $db->sql_freeresult($result);
  56  
  57  if (!$report_data)
  58  {
  59      trigger_error('POST_NOT_EXIST');
  60  }
  61  
  62  $forum_id = (int) ($report_data['forum_id']) ? $report_data['forum_id'] : $forum_id;
  63  $topic_id = (int) $report_data['topic_id'];
  64  
  65  $sql = 'SELECT *
  66      FROM ' . FORUMS_TABLE . '
  67      WHERE forum_id = ' . $forum_id;
  68  $result = $db->sql_query($sql);
  69  $forum_data = $db->sql_fetchrow($result);
  70  $db->sql_freeresult($result);
  71  
  72  if (!$forum_data)
  73  {
  74      trigger_error('FORUM_NOT_EXIST');
  75  }
  76  
  77  // Check required permissions
  78  $acl_check_ary = array('f_list' => 'POST_NOT_EXIST', 'f_read' => 'USER_CANNOT_READ', 'f_report' => 'USER_CANNOT_REPORT');
  79  
  80  foreach ($acl_check_ary as $acl => $error)
  81  {
  82      if (!$auth->acl_get($acl, $forum_id))
  83      {
  84          trigger_error($error);
  85      }
  86  }
  87  unset($acl_check_ary);
  88  
  89  if ($report_data['post_reported'])
  90  {
  91      $message = $user->lang['ALREADY_REPORTED'];
  92      $message .= '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');
  93      trigger_error($message);
  94  }
  95  
  96  // Submit report?
  97  if ($submit && $reason_id)
  98  {
  99      $sql = 'SELECT *
 100          FROM ' . REPORTS_REASONS_TABLE . "
 101          WHERE reason_id = $reason_id";
 102      $result = $db->sql_query($sql);
 103      $row = $db->sql_fetchrow($result);
 104      $db->sql_freeresult($result);
 105  
 106      if (!$row || (!$report_text && strtolower($row['reason_title']) == 'other'))
 107      {
 108          trigger_error('EMPTY_REPORT');
 109      }
 110  
 111      $sql_ary = array(
 112          'reason_id'        => (int) $reason_id,
 113          'post_id'        => $post_id,
 114          'user_id'        => (int) $user->data['user_id'],
 115          'user_notify'    => (int) $user_notify,
 116          'report_closed'    => 0,
 117          'report_time'    => (int) time(),
 118          'report_text'    => (string) $report_text
 119      );
 120  
 121      $sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
 122      $db->sql_query($sql);
 123      $report_id = $db->sql_nextid();
 124  
 125      if (!$report_data['post_reported'])
 126      {
 127          $sql = 'UPDATE ' . POSTS_TABLE . '
 128              SET post_reported = 1
 129              WHERE post_id = ' . $post_id;
 130          $db->sql_query($sql);
 131      }
 132  
 133      if (!$report_data['topic_reported'])
 134      {
 135          $sql = 'UPDATE ' . TOPICS_TABLE . '
 136              SET topic_reported = 1
 137              WHERE topic_id = ' . $report_data['topic_id'];
 138          $db->sql_query($sql);
 139      }
 140  
 141      meta_refresh(3, $redirect_url);
 142  
 143      $message = $user->lang['POST_REPORTED_SUCCESS'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');
 144      trigger_error($message);
 145  }
 146  
 147  // Generate the reasons
 148  display_reasons($reason_id);
 149  
 150  $template->assign_vars(array(
 151      'REPORT_TEXT'        => $report_text,
 152      'S_REPORT_ACTION'    => append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&amp;p=' . $post_id),
 153  
 154      'S_NOTIFY'            => $user_notify,
 155      'S_CAN_NOTIFY'        => ($user->data['is_registered']) ? true : false)
 156  );
 157  
 158  generate_forum_nav($forum_data);
 159  
 160  // Start output of page
 161  page_header($user->lang['REPORT_POST']);
 162  
 163  $template->set_filenames(array(
 164      'body' => 'report_body.html')
 165  );
 166  
 167  page_footer();
 168  
 169  ?>


Generated: Wed Nov 22 00:35:05 2006 Cross-referenced by PHPXref 0.6