[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/ -> report.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.6
   4   * Copyright 2010 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://mybb.com
   7   * License: http://mybb.com/about/license
   8   *
   9   * $Id$
  10   */
  11  
  12  define("IN_MYBB", 1);
  13  define('THIS_SCRIPT', 'report.php');
  14  
  15  $templatelist = "report,report_thanks,report_error,report_noreason,forumdisplay_password_wrongpass,forumdisplay_password";
  16  require_once  "./global.php";
  17  
  18  // Load global language phrases
  19  $lang->load("report");
  20  
  21  if($mybb->usergroup['canview'] == 0 || !$mybb->user['uid'])
  22  {
  23      error_no_permission();
  24  }
  25  
  26  if($mybb->input['action'] != "do_report")
  27  {
  28      $mybb->input['action'] = "report";
  29  }
  30  
  31  $post = get_post($mybb->input['pid']);
  32  
  33  if(!$post['pid'])
  34  {
  35      $error = $lang->error_invalidpost;
  36      eval("\$report_error = \"".$templates->get("report_error")."\";");
  37      output_page($report_error);
  38      exit;
  39  }
  40  
  41  
  42  $forum = get_forum($post['fid']);
  43  if(!$forum)
  44  {
  45      $error = $lang->error_invalidforum;
  46      eval("\$report_error = \"".$templates->get("report_error")."\";");
  47      output_page($report_error);
  48      exit;
  49  }
  50  
  51  // Password protected forums ......... yhummmmy!
  52  check_forum_password($forum['parentlist']);
  53  
  54  $thread = get_thread($post['tid']);
  55  
  56  if($mybb->input['action'] == "report")
  57  {
  58      $plugins->run_hooks("report_start");
  59      $pid = $mybb->input['pid'];
  60  
  61      $plugins->run_hooks("report_end");
  62  
  63      eval("\$report = \"".$templates->get("report")."\";");
  64      output_page($report);
  65  }
  66  elseif($mybb->input['action'] == "do_report" && $mybb->request_method == "post")
  67  {
  68      // Verify incoming POST request
  69      verify_post_check($mybb->input['my_post_key']);
  70  
  71      $plugins->run_hooks("report_do_report_start");
  72      if(!trim($mybb->input['reason']))
  73      {
  74          eval("\$report = \"".$templates->get("report_noreason")."\";");
  75          output_page($report);
  76          exit;
  77      }
  78  
  79      if($mybb->settings['reportmethod'] == "email" || $mybb->settings['reportmethod'] == "pms")
  80      {
  81          $query = $db->query("
  82              SELECT DISTINCT u.username, u.email, u.receivepms, u.uid
  83              FROM ".TABLE_PREFIX."moderators m
  84              LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=m.id)
  85              WHERE m.fid IN (".$forum['parentlist'].") AND m.isgroup = '0'
  86          ");
  87          $nummods = $db->num_rows($query);
  88          if(!$nummods)
  89          {
  90              unset($query);
  91              switch($db->type)
  92              {
  93                  case "pgsql":
  94                  case "sqlite":
  95                      $query = $db->query("
  96                          SELECT u.username, u.email, u.receivepms, u.uid
  97                          FROM ".TABLE_PREFIX."users u
  98                          LEFT JOIN ".TABLE_PREFIX."usergroups g ON (((','|| u.additionalgroups|| ',' LIKE '%,'|| g.gid|| ',%') OR u.usergroup = g.gid))
  99                          WHERE (g.cancp=1 OR g.issupermod=1)
 100                      ");
 101                      break;
 102                  default:
 103                      $query = $db->query("
 104                          SELECT u.username, u.email, u.receivepms, u.uid
 105                          FROM ".TABLE_PREFIX."users u
 106                          LEFT JOIN ".TABLE_PREFIX."usergroups g ON (((CONCAT(',', u.additionalgroups, ',') LIKE CONCAT('%,', g.gid, ',%')) OR u.usergroup = g.gid))
 107                          WHERE (g.cancp=1 OR g.issupermod=1)
 108                      ");
 109              }
 110          }
 111  
 112          while($mod = $db->fetch_array($query))
 113          {
 114              $emailsubject = $lang->sprintf($lang->emailsubject_reportpost, $mybb->settings['bbname']);
 115              $emailmessage = $lang->sprintf($lang->email_reportpost, $mybb->user['username'], $mybb->settings['bbname'], $post['subject'], $mybb->settings['bburl'], str_replace('&amp;', '&', get_post_link($post['pid'], $thread['tid'])."#pid".$post['pid']), $thread['subject'], $mybb->input['reason']);
 116  
 117              if($mybb->settings['reportmethod'] == "pms" && $mod['receivepms'] != 0 && $mybb->settings['enablepms'] != 0)
 118              {
 119                  $pm_recipients[] = $mod['uid'];
 120              }
 121              else
 122              {
 123                  my_mail($mod['email'], $emailsubject, $emailmessage);
 124              }
 125          }
 126  
 127          if(count($pm_recipients) > 0)
 128          {
 129              $emailsubject = $lang->sprintf($lang->emailsubject_reportpost, $mybb->settings['bbname']);
 130              $emailmessage = $lang->sprintf($lang->email_reportpost, $mybb->user['username'], $mybb->settings['bbname'], $post['subject'], $mybb->settings['bburl'], str_replace('&amp;', '&', get_post_link($post['pid'], $thread['tid'])."#pid".$post['pid']), $thread['subject'], $mybb->input['reason']);
 131  
 132              require_once  MYBB_ROOT."inc/datahandlers/pm.php";
 133              $pmhandler = new PMDataHandler();
 134  
 135              $pm = array(
 136                  "subject" => $emailsubject,
 137                  "message" => $emailmessage,
 138                  "icon" => 0,
 139                  "fromid" => $mybb->user['uid'],
 140                  "toid" => $pm_recipients
 141              );
 142  
 143              $pmhandler->admin_override = true;
 144              $pmhandler->set_data($pm);
 145  
 146              // Now let the pm handler do all the hard work.
 147              if(!$pmhandler->validate_pm())
 148              {
 149                  // Force it to valid to just get it out of here
 150                  $pmhandler->is_validated = true;
 151                  $pmhandler->errors = array();
 152              }
 153              $pminfo = $pmhandler->insert_pm();
 154          }
 155      }
 156      else
 157      {
 158          $mybb->input['reason'] = utf8_handle_4byte_string($mybb->input['reason']);
 159  
 160          $reportedpost = array(
 161              "pid" => intval($mybb->input['pid']),
 162              "tid" => $thread['tid'],
 163              "fid" => $thread['fid'],
 164              "uid" => $mybb->user['uid'],
 165              "dateline" => TIME_NOW,
 166              "reportstatus" => 0,
 167              "reason" => $db->escape_string(htmlspecialchars_uni($mybb->input['reason']))
 168          );
 169          $db->insert_query("reportedposts", $reportedpost);
 170          $cache->update_reportedposts();
 171      }
 172  
 173      $plugins->run_hooks("report_do_report_end");
 174  
 175      eval("\$report = \"".$templates->get("report_thanks")."\";");
 176      output_page($report);
 177  }
 178  ?>


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1