[ Index ]

PHP Cross Reference of MyBB 1.8.12

title

Body

[close]

/ -> moderation.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.8
   4   * Copyright 2014 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://www.mybb.com
   7   * License: http://www.mybb.com/about/license
   8   *
   9   */
  10  
  11  define("IN_MYBB", 1);
  12  define('THIS_SCRIPT', 'moderation.php');
  13  
  14  $templatelist = "changeuserbox,loginbox,moderation_delayedmoderation_custommodtool,moderation_delayedmodaction_notes,moderation_delayedmoderation_merge,moderation_delayedmoderation_move";
  15  $templatelist .= ",moderation_delayedmoderation,moderation_deletethread,moderation_deletepoll,moderation_mergeposts_post,moderation_viewthreadnotes,moderation_confirmation,moderation_purgespammer";
  16  $templatelist .= ",moderation_move,moderation_threadnotes_modaction,moderation_threadnotes_delayedmodaction,moderation_threadnotes,moderation_getip_modoptions,moderation_getip,moderation_getpmip";
  17  $templatelist .= ",moderation_split_post,moderation_inline_deletethreads,moderation_inline_movethreads,moderation_inline_deleteposts,moderation_inline_mergeposts,moderation_threadnotes_modaction_error";
  18  $templatelist .= ",moderation_inline_splitposts,forumjump_special,forumjump_advanced,forumdisplay_password_wrongpass,forumdisplay_password,moderation_inline_moveposts,moderation_delayedmodaction_error";
  19  $templatelist .= ",moderation_delayedmodaction_notes_thread_single,moderation_delayedmodaction_notes_thread_multiple,moderation_delayedmodaction_notes_forum,moderation_delayedmodaction_notes_new_forum";
  20  $templatelist .= ",moderation_delayedmodaction_notes_redirect,moderation_delayedmodaction_notes_merge,moderation_delayedmoderation_thread,moderation_threadnotes_modaction_thread,forumjump_bit";
  21  $templatelist .= ",moderation_delayedmoderation_date_day,moderation_delayedmoderation_date_month,moderation_threadnotes_modaction_post,moderation_merge,moderation_split,moderation_threadnotes_modaction_forum";
  22  
  23  require_once  "./global.php";
  24  require_once  MYBB_ROOT."inc/functions_post.php";
  25  require_once  MYBB_ROOT."inc/functions_upload.php";
  26  require_once  MYBB_ROOT."inc/class_parser.php";
  27  $parser = new postParser;
  28  require_once  MYBB_ROOT."inc/class_moderation.php";
  29  $moderation = new Moderation;
  30  
  31  // Load global language phrases
  32  $lang->load("moderation");
  33  
  34  $plugins->run_hooks("moderation_start");
  35  
  36  $tid = $mybb->get_input('tid', MyBB::INPUT_INT);
  37  $pid = $mybb->get_input('pid', MyBB::INPUT_INT);
  38  $fid = $mybb->get_input('fid', MyBB::INPUT_INT);
  39  $pmid = $mybb->get_input('pmid', MyBB::INPUT_INT);
  40  
  41  if($pid)
  42  {
  43      $post = get_post($pid);
  44      if(!$post)
  45      {
  46          error($lang->error_invalidpost);
  47      }
  48      $tid = $post['tid'];
  49  }
  50  
  51  if($tid)
  52  {
  53      $thread = get_thread($tid);
  54      if(!$thread)
  55      {
  56          error($lang->error_invalidthread);
  57      }
  58      $fid = $thread['fid'];
  59  }
  60  
  61  if($fid)
  62  {
  63      $modlogdata['fid'] = $fid;
  64      $forum = get_forum($fid);
  65  
  66      // Make navigation
  67      build_forum_breadcrumb($fid);
  68  
  69      // Get our permissions all nice and setup
  70      $permissions = forum_permissions($fid);
  71  }
  72  
  73  if($pmid > 0)
  74  {
  75      $query = $db->simple_select('privatemessages', 'uid, subject, ipaddress, fromid', "pmid = $pmid");
  76  
  77      $pm = $db->fetch_array($query);
  78  
  79      if(!$pm)
  80      {
  81          error($lang->error_invalidpm);
  82      }
  83  }
  84  
  85  // Get some navigation if we need it
  86  $mybb->input['action'] = $mybb->get_input('action');
  87  switch($mybb->input['action'])
  88  {
  89      case "reports":
  90          add_breadcrumb($lang->reported_posts);
  91          break;
  92      case "allreports":
  93          add_breadcrumb($lang->all_reported_posts);
  94          break;
  95  
  96  }
  97  
  98  if(isset($thread))
  99  {
 100      $thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
 101      add_breadcrumb($thread['subject'], get_thread_link($thread['tid']));
 102      $modlogdata['tid'] = $thread['tid'];
 103  }
 104  
 105  if(isset($forum))
 106  {
 107      // Check if this forum is password protected and we have a valid password
 108      check_forum_password($forum['fid']);
 109  }
 110  
 111  $mybb->user['username'] = htmlspecialchars_uni($mybb->user['username']);
 112  eval("\$loginbox = \"".$templates->get("changeuserbox")."\";");
 113  
 114  $allowable_moderation_actions = array("getip", "getpmip", "cancel_delayedmoderation", "delayedmoderation", "threadnotes", "purgespammer", "viewthreadnotes");
 115  
 116  if($mybb->request_method != "post" && !in_array($mybb->input['action'], $allowable_moderation_actions))
 117  {
 118      error_no_permission();
 119  }
 120  
 121  // Begin!
 122  switch($mybb->input['action'])
 123  {
 124      // Delayed Moderation
 125      case "cancel_delayedmoderation":
 126          // Verify incoming POST request
 127          verify_post_check($mybb->get_input('my_post_key'));
 128  
 129          add_breadcrumb($lang->delayed_moderation);
 130          if(!is_moderator($fid, "canmanagethreads"))
 131          {
 132              error_no_permission();
 133          }
 134  
 135          $plugins->run_hooks('moderation_cancel_delayedmoderation');
 136  
 137          $db->delete_query("delayedmoderation", "did='".$mybb->get_input('did', MyBB::INPUT_INT)."'");
 138  
 139          if($tid == 0)
 140          {
 141              moderation_redirect(get_forum_link($fid), $lang->redirect_delayed_moderation_cancelled);
 142          }
 143          else
 144          {
 145              moderation_redirect("moderation.php?action=delayedmoderation&amp;tid={$tid}&amp;my_post_key={$mybb->post_code}", $lang->redirect_delayed_moderation_cancelled);
 146          }
 147          break;
 148      case "do_delayedmoderation":
 149      case "delayedmoderation":
 150          // Verify incoming POST request
 151          verify_post_check($mybb->get_input('my_post_key'));
 152          
 153          $localized_time_offset = $mybb->user['timezone']*3600 + $mybb->user['dst']*3600;
 154  
 155          if(!$mybb->get_input('date_day', MyBB::INPUT_INT))
 156          {
 157              $mybb->input['date_day'] = gmdate('d', TIME_NOW + $localized_time_offset);
 158          }
 159          if(!$mybb->get_input('date_month', MyBB::INPUT_INT))
 160          {
 161              $mybb->input['date_month'] = gmdate('m', TIME_NOW + $localized_time_offset);
 162          }
 163  
 164          // Assume in-line moderation if TID is not set
 165          if(!empty($mybb->input['tid']))
 166          {
 167              $mybb->input['tids'] = $tid;
 168          }
 169          else
 170          {
 171              if($mybb->get_input('inlinetype') == 'search')
 172              {
 173                  $tids = getids($mybb->get_input('searchid'), 'search');
 174              }
 175              else
 176              {
 177                  $fid = $mybb->get_input('fid', MyBB::INPUT_INT);
 178                  $tids = getids($fid, "forum");
 179              }
 180              if(count($tids) < 1)
 181              {
 182                  error($lang->error_inline_nothreadsselected);
 183              }
 184  
 185              $mybb->input['tids'] = $tids;
 186          }
 187  
 188          add_breadcrumb($lang->delayed_moderation);
 189  
 190          if(!is_moderator($fid, "canmanagethreads"))
 191          {
 192              error_no_permission();
 193          }
 194  
 195          $errors = array();
 196          $customthreadtools = "";
 197  
 198          $allowed_types = array('openclosethread', 'softdeleterestorethread', 'deletethread', 'move', 'stick', 'merge', 'removeredirects', 'removesubscriptions', 'approveunapprovethread');
 199  
 200          $mybb->input['type'] = $mybb->get_input('type');
 201  
 202          switch($db->type)
 203          {
 204              case "pgsql":
 205              case "sqlite":
 206                  $query = $db->simple_select("modtools", 'tid, name', "(','||forums||',' LIKE '%,$fid,%' OR ','||forums||',' LIKE '%,-1,%' OR forums='') AND type = 't'");
 207                  break;
 208              default:
 209                  $query = $db->simple_select("modtools", 'tid, name', "(CONCAT(',',forums,',') LIKE '%,$fid,%' OR CONCAT(',',forums,',') LIKE '%,-1,%' OR forums='') AND type = 't'");
 210          }
 211          while($tool = $db->fetch_array($query))
 212          {
 213              $allowed_types[] = "modtool_".$tool['tid'];
 214  
 215              $tool['name'] = htmlspecialchars_uni($tool['name']);
 216  
 217              $checked = "";
 218              if($mybb->input['type'] == "modtool_".$tool['tid'])
 219              {
 220                  $checked = "checked=\"checked\"";
 221              }
 222  
 223              eval("\$customthreadtools .= \"".$templates->get("moderation_delayedmoderation_custommodtool")."\";");
 224          }
 225  
 226          $mybb->input['delayedmoderation'] = $mybb->get_input('delayedmoderation', MyBB::INPUT_ARRAY);
 227  
 228          if($mybb->input['action'] == "do_delayedmoderation" && $mybb->request_method == "post")
 229          {
 230              if(!in_array($mybb->input['type'], $allowed_types))
 231              {
 232                  $mybb->input['type'] = '';
 233                  $errors[] = $lang->error_delayedmoderation_unsupported_type;
 234              }
 235  
 236              if($mybb->input['type'] == 'move' && (!isset($mybb->input['delayedmoderation']['method']) || !in_array($mybb->input['delayedmoderation']['method'], array('move', 'redirect', 'copy'))))
 237              {
 238                  $mybb->input['delayedmoderation']['method'] = '';
 239                  $errors[] = $lang->error_delayedmoderation_unsupported_method;
 240              }
 241  
 242              if($mybb->input['type'] == 'move')
 243              {
 244                  $newforum = get_forum($fid);
 245                  if(!$newforum || $newforum['type'] != "f" || $newforum['type'] == "f" && $newforum['linkto'] != '')
 246                  {
 247                      $errors[] = $lang->error_invalidforum;
 248                  }
 249              }
 250  
 251              if($mybb->input['date_day'] > 31 || $mybb->input['date_day'] < 1)
 252              {
 253                  $errors[] = $lang->error_delayedmoderation_invalid_date_day;
 254              }
 255  
 256              if($mybb->input['date_month'] > 12 || $mybb->input['date_month'] < 1)
 257              {
 258                  $errors[] = $lang->error_delayedmoderation_invalid_date_month;
 259              }
 260  
 261              if($mybb->input['date_year'] < gmdate('Y', TIME_NOW + $localized_time_offset))
 262              {
 263                  $errors[] = $lang->error_delayedmoderation_invalid_date_year;
 264              }
 265  
 266              $date_time = explode(' ', $mybb->get_input('date_time'));
 267              $date_time = explode(':', (string)$date_time[0]);
 268  
 269              if(stristr($mybb->input['date_time'], 'pm'))
 270              {
 271                  $date_time[0] = 12+$date_time[0];
 272                  if($date_time[0] >= 24)
 273                  {
 274                      $date_time[0] = '00';
 275                  }
 276              }
 277  
 278              $rundate = gmmktime((int)$date_time[0], (int)$date_time[1], date('s', TIME_NOW), $mybb->get_input('date_month', MyBB::INPUT_INT), $mybb->get_input('date_day', MyBB::INPUT_INT), $mybb->get_input('date_year', MyBB::INPUT_INT)) - $localized_time_offset;
 279  
 280              if(!$errors)
 281              {
 282                  if(is_array($mybb->input['tids']))
 283                  {
 284                      $mybb->input['tids'] = implode(',' , $mybb->input['tids']);
 285                  }
 286  
 287                  $did = $db->insert_query("delayedmoderation", array(
 288                      'type' => $db->escape_string($mybb->input['type']),
 289                      'delaydateline' => (int)$rundate,
 290                      'uid' => $mybb->user['uid'],
 291                      'tids' => $db->escape_string($mybb->input['tids']),
 292                      'fid' => $fid,
 293                      'dateline' => TIME_NOW,
 294                      'inputs' => $db->escape_string(my_serialize($mybb->input['delayedmoderation']))
 295                  ));
 296  
 297                  $plugins->run_hooks('moderation_do_delayedmoderation');
 298  
 299                  $rundate_format = my_date('relative', $rundate, '', 2);
 300                  $lang->redirect_delayed_moderation_thread = $lang->sprintf($lang->redirect_delayed_moderation_thread, $rundate_format);
 301  
 302                  if(!empty($mybb->input['tid']))
 303                  {
 304                      moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_delayed_moderation_thread);
 305                  }
 306                  else
 307                  {
 308                      if($mybb->get_input('inlinetype') == 'search')
 309                      {
 310                          moderation_redirect(get_forum_link($fid), $lang->sprintf($lang->redirect_delayed_moderation_search, $rundate_format));
 311                      }
 312                      else
 313                      {
 314                          moderation_redirect(get_forum_link($fid), $lang->sprintf($lang->redirect_delayed_moderation_forum, $rundate_format));
 315                      }
 316                  }
 317              }
 318              else
 319              {
 320                  $type_selected = array();
 321                  foreach($allowed_types as $type)
 322                  {
 323                      $type_selected[$type] = '';
 324                  }
 325                  $type_selected[$mybb->get_input('type')] = "checked=\"checked\"";
 326                  $method_selected = array('move' => '', 'redirect' => '', 'copy' => '');
 327                  if(isset($mybb->input['delayedmoderation']['method']))
 328                  {
 329                      $method_selected[$mybb->input['delayedmoderation']['method']] = "checked=\"checked\"";
 330                  }
 331  
 332                  foreach(array('redirect_expire', 'new_forum', 'subject', 'threadurl') as $value)
 333                  {
 334                      if(!isset($mybb->input['delayedmoderation'][$value]))
 335                      {
 336                          $mybb->input['delayedmoderation'][$value] = '';
 337                      }
 338                  }
 339                  $mybb->input['delayedmoderation']['redirect_expire'] = (int)$mybb->input['delayedmoderation']['redirect_expire'];
 340                  $mybb->input['delayedmoderation']['new_forum'] = (int)$mybb->input['delayedmoderation']['new_forum'];
 341                  $mybb->input['delayedmoderation']['subject'] = htmlspecialchars_uni($mybb->input['delayedmoderation']['subject']);
 342                  $mybb->input['delayedmoderation']['threadurl'] = htmlspecialchars_uni($mybb->input['delayedmoderation']['threadurl']);
 343  
 344                  $forumselect = build_forum_jump("", $mybb->input['delayedmoderation']['new_forum'], 1, '', 0, true, '', "delayedmoderation[new_forum]");
 345              }
 346          }
 347          else
 348          {
 349              $type_selected = array();
 350              foreach($allowed_types as $type)
 351              {
 352                  $type_selected[$type] = '';
 353              }
 354              $type_selected['openclosethread'] = "checked=\"checked\"";
 355              $method_selected = array('move' => 'checked="checked"', 'redirect' => '', 'copy' => '');
 356  
 357              $mybb->input['delayedmoderation']['redirect_expire'] = '';
 358              $mybb->input['delayedmoderation']['subject'] = $thread['subject'];
 359              $mybb->input['delayedmoderation']['threadurl'] = '';
 360  
 361              $forumselect = build_forum_jump("", $fid, 1, '', 0, true, '', "delayedmoderation[new_forum]");
 362          }
 363  
 364          if(isset($errors) && count($errors) > 0)
 365          {
 366              $display_errors = inline_error($errors);
 367          }
 368          else
 369          {
 370              $display_errors = '';
 371          }
 372  
 373          $forum_cache = $cache->read("forums");
 374  
 375          $actions = array(
 376              'openclosethread' => $lang->open_close_thread,
 377              'softdeleterestorethread' => $lang->softdelete_restore_thread,
 378              'deletethread' => $lang->delete_thread,
 379              'move' => $lang->move_copy_thread,
 380              'stick' => $lang->stick_unstick_thread,
 381              'merge' => $lang->merge_threads,
 382              'removeredirects' => $lang->remove_redirects,
 383              'removesubscriptions' => $lang->remove_subscriptions,
 384              'approveunapprovethread' => $lang->approve_unapprove_thread
 385          );
 386  
 387          switch($db->type)
 388          {
 389              case "pgsql":
 390              case "sqlite":
 391                  $query = $db->simple_select("modtools", 'tid, name', "(','||forums||',' LIKE '%,$fid,%' OR ','||forums||',' LIKE '%,-1,%' OR forums='') AND type = 't'");
 392                  break;
 393              default:
 394                  $query = $db->simple_select("modtools", 'tid, name', "(CONCAT(',',forums,',') LIKE '%,$fid,%' OR CONCAT(',',forums,',') LIKE '%,-1,%' OR forums='') AND type = 't'");
 395          }
 396          while($tool = $db->fetch_array($query))
 397          {
 398              $actions['modtool_'.$tool['tid']] = htmlspecialchars_uni($tool['name']);
 399          }
 400  
 401          $delayedmods = '';
 402          $trow = alt_trow(1);
 403          if($tid == 0)
 404          {
 405              // Inline thread moderation is used
 406              if($mybb->get_input('inlinetype') == 'search')
 407              {
 408                  $tids = getids($mybb->get_input('searchid'), 'search');
 409              }
 410              else
 411              {
 412                  $tids = getids($fid, "forum");
 413              }
 414              $where_array = array();
 415              switch($db->type)
 416              {
 417                  case "pgsql":
 418                  case "sqlite":
 419                      foreach($tids as $like)
 420                      {
 421                          $where_array[] = "','||d.tids||',' LIKE '%,".$db->escape_string($like).",%'";
 422                      }
 423                      $where_statement = implode(" OR ", $where_array);
 424                      break;
 425                  default:
 426                      foreach($tids as $like)
 427                      {
 428                          $where_array[] = "CONCAT(',',d.tids,',') LIKE  '%,".$db->escape_string($like).",%'";
 429                      }
 430                      $where_statement = implode(" OR ", $where_array);
 431              }
 432              $query = $db->query("
 433                  SELECT d.*, u.username, f.name AS fname
 434                  FROM ".TABLE_PREFIX."delayedmoderation d
 435                  LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=d.uid)
 436                  LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=d.fid)
 437                  WHERE ".$where_statement."
 438                  ORDER BY d.dateline DESC
 439                  LIMIT  0, 20
 440              ");
 441          }
 442          else
 443          {
 444              switch($db->type)
 445              {
 446                  case "pgsql":
 447                  case "sqlite":
 448                      $query = $db->query("
 449                          SELECT d.*, u.username, f.name AS fname
 450                          FROM ".TABLE_PREFIX."delayedmoderation d
 451                          LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=d.uid)
 452                          LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=d.fid)
 453                          WHERE ','||d.tids||',' LIKE '%,{$tid},%'
 454                          ORDER BY d.dateline DESC
 455                          LIMIT  0, 20
 456                      ");
 457                      break;
 458                  default:
 459                      $query = $db->query("
 460                          SELECT d.*, u.username, f.name AS fname
 461                          FROM ".TABLE_PREFIX."delayedmoderation d
 462                          LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=d.uid)
 463                          LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=d.fid)
 464                          WHERE CONCAT(',',d.tids,',') LIKE '%,{$tid},%'
 465                          ORDER BY d.dateline DESC
 466                          LIMIT  0, 20
 467                      ");
 468              }
 469          }
 470          
 471          while($delayedmod = $db->fetch_array($query))
 472          {
 473              $delayedmod['dateline'] = my_date("jS M Y, {$mybb->settings['timeformat']}", $delayedmod['delaydateline']);
 474              $delayedmod['username'] = htmlspecialchars_uni($delayedmod['username']);
 475              $delayedmod['profilelink'] = build_profile_link($delayedmod['username'], $delayedmod['uid']);
 476              $delayedmod['action'] = $actions[$delayedmod['type']];
 477              $info = '';
 478              if(strpos($delayedmod['tids'], ',') === false)
 479              {
 480                  $delayed_thread = get_thread($delayedmod['tids']);
 481                  $delayed_thread['link'] = get_thread_link($delayed_thread['tid']);
 482                  $delayed_thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($delayed_thread['subject']));
 483                  eval("\$info .= \"".$templates->get("moderation_delayedmodaction_notes_thread_single")."\";");
 484              }
 485              else
 486              {
 487                  eval("\$info .= \"".$templates->get("moderation_delayedmodaction_notes_thread_multiple")."\";");
 488              }
 489  
 490              if($delayedmod['fname'])
 491              {
 492                  $delayedmod['link'] = get_forum_link($delayedmod['fid']);
 493                  $delayedmod['fname'] = htmlspecialchars_uni($delayedmod['fname']);
 494                  eval("\$info .= \"".$templates->get("moderation_delayedmodaction_notes_forum")."\";");
 495              }
 496              $delayedmod['inputs'] = my_unserialize($delayedmod['inputs']);
 497  
 498              if($delayedmod['type'] == 'move')
 499              {
 500                  $delayedmod['link'] = get_forum_link($delayedmod['inputs']['new_forum']);
 501                  $delayedmod['name'] = htmlspecialchars_uni($forum_cache[$delayedmod['inputs']['new_forum']]['name']);
 502                  eval("\$info .= \"".$templates->get("moderation_delayedmodaction_notes_new_forum")."\";");
 503  
 504                  if($delayedmod['inputs']['method'] == "redirect")
 505                  {
 506                      if((int)$delayedmod['inputs']['redirect_expire'] == 0)
 507                      {
 508                          $redirect_expire_bit = $lang->redirect_forever;
 509                      }
 510                      else
 511                      {
 512                          $redirect_expire_bit = (int)$delayedmod['inputs']['redirect_expire']." {$lang->days}";
 513                      }
 514  
 515                      eval("\$info .= \"".$templates->get("moderation_delayedmodaction_notes_redirect")."\";");
 516                  }
 517              }
 518              else if($delayedmod['type'] == 'merge')
 519              {
 520                  $delayedmod['subject'] = htmlspecialchars_uni($delayedmod['inputs']['subject']);
 521                  $delayedmod['threadurl'] = htmlspecialchars_uni($delayedmod['inputs']['threadurl']);
 522                  eval("\$info .= \"".$templates->get("moderation_delayedmodaction_notes_merge")."\";");
 523              }
 524  
 525              eval("\$delayedmods .= \"".$templates->get("moderation_delayedmodaction_notes")."\";");
 526              $trow = alt_trow();
 527          }
 528          if(!$delayedmods)
 529          {
 530              $cols = 5;
 531              eval("\$delayedmods = \"".$templates->get("moderation_delayedmodaction_error")."\";");
 532          }
 533  
 534          $url = '';
 535          if($mybb->get_input('tid', MyBB::INPUT_INT))
 536          {
 537              $lang->threads = $lang->thread;
 538              $thread['link'] = get_thread_link($tid);
 539              eval("\$threads = \"".$templates->get("moderation_delayedmoderation_thread")."\";");
 540              eval("\$moderation_delayedmoderation_merge = \"".$templates->get("moderation_delayedmoderation_merge")."\";");
 541          }
 542          else
 543          {
 544              if($mybb->get_input('inlinetype') == 'search')
 545              {
 546                  $tids = getids($mybb->get_input('searchid'), 'search');
 547                  $url = htmlspecialchars_uni($mybb->get_input('url'));
 548              }
 549              else
 550              {
 551                  $tids = getids($fid, "forum");
 552              }
 553              if(count($tids) < 1)
 554              {
 555                  error($lang->error_inline_nothreadsselected);
 556              }
 557  
 558              $threads = $lang->sprintf($lang->threads_selected, count($tids));
 559              $moderation_delayedmoderation_merge = '';
 560          }
 561          $mybb->input['redirect_expire'] = $mybb->get_input('redirect_expire');
 562          eval("\$moderation_delayedmoderation_move = \"".$templates->get("moderation_delayedmoderation_move")."\";");
 563  
 564          // Generate form elements for date form
 565          $dateday = '';
 566          for($day = 1; $day <= 31; ++$day)
 567          {
 568              $selected = '';
 569              if($mybb->get_input('date_day', MyBB::INPUT_INT) == $day)
 570              {
 571                  $selected = ' selected="selected"';
 572              }
 573              eval('$dateday .= "'.$templates->get('moderation_delayedmoderation_date_day').'";');
 574          }
 575  
 576          $datemonth = array();
 577          foreach(array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12') as $month)
 578          {
 579              $datemonth[$month] = '';
 580              if($mybb->get_input('date_month', MyBB::INPUT_INT) == (int)$month)
 581              {
 582                  $datemonth[$month] = ' selected="selected"';
 583              }
 584          }
 585          
 586  
 587          eval('$datemonth = "'.$templates->get('moderation_delayedmoderation_date_month').'";');
 588  
 589          $dateyear = gmdate('Y', TIME_NOW  + $localized_time_offset);
 590          $datetime = gmdate($mybb->settings['timeformat'], TIME_NOW + $localized_time_offset);
 591  
 592          $plugins->run_hooks("moderation_delayedmoderation");
 593  
 594          eval("\$delayedmoderation = \"".$templates->get("moderation_delayedmoderation")."\";");
 595          output_page($delayedmoderation);
 596          break;
 597      // Open or close a thread
 598      case "openclosethread":
 599          // Verify incoming POST request
 600          verify_post_check($mybb->get_input('my_post_key'));
 601  
 602          if(!is_moderator($fid, "canopenclosethreads"))
 603          {
 604              error_no_permission();
 605          }
 606  
 607          if($thread['closed'] == 1)
 608          {
 609              $openclose = $lang->opened;
 610              $redirect = $lang->redirect_openthread;
 611              $moderation->open_threads($tid);
 612          }
 613          else
 614          {
 615              $openclose = $lang->closed;
 616              $redirect = $lang->redirect_closethread;
 617              $moderation->close_threads($tid);
 618          }
 619  
 620          $lang->mod_process = $lang->sprintf($lang->mod_process, $openclose);
 621  
 622          log_moderator_action($modlogdata, $lang->mod_process);
 623  
 624          moderation_redirect(get_thread_link($thread['tid']), $redirect);
 625          break;
 626  
 627      // Stick or unstick that post to the top bab!
 628      case "stick":
 629          // Verify incoming POST request
 630          verify_post_check($mybb->get_input('my_post_key'));
 631  
 632          if(!is_moderator($fid, "canstickunstickthreads"))
 633          {
 634              error_no_permission();
 635          }
 636  
 637          $plugins->run_hooks("moderation_stick");
 638  
 639          if($thread['sticky'] == 1)
 640          {
 641              $stuckunstuck = $lang->unstuck;
 642              $redirect = $lang->redirect_unstickthread;
 643              $moderation->unstick_threads($tid);
 644          }
 645          else
 646          {
 647              $stuckunstuck = $lang->stuck;
 648              $redirect = $lang->redirect_stickthread;
 649              $moderation->stick_threads($tid);
 650          }
 651  
 652          $lang->mod_process = $lang->sprintf($lang->mod_process, $stuckunstuck);
 653  
 654          log_moderator_action($modlogdata, $lang->mod_process);
 655  
 656          moderation_redirect(get_thread_link($thread['tid']), $redirect);
 657          break;
 658  
 659      // Remove redirects to a specific thread
 660      case "removeredirects":
 661  
 662          // Verify incoming POST request
 663          verify_post_check($mybb->get_input('my_post_key'));
 664  
 665          if(!is_moderator($fid, "canmanagethreads"))
 666          {
 667              error_no_permission();
 668          }
 669  
 670          $plugins->run_hooks("moderation_removeredirects");
 671  
 672          $moderation->remove_redirects($tid);
 673  
 674          log_moderator_action($modlogdata, $lang->redirects_removed);
 675          moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_redirectsremoved);
 676          break;
 677  
 678      // Delete thread confirmation page
 679      case "deletethread":
 680  
 681          add_breadcrumb($lang->nav_deletethread);
 682  
 683          if(!is_moderator($fid, "candeletethreads"))
 684          {
 685              if($permissions['candeletethreads'] != 1 || $mybb->user['uid'] != $thread['uid'])
 686              {
 687                  error_no_permission();
 688              }
 689          }
 690  
 691          $plugins->run_hooks("moderation_deletethread");
 692  
 693          eval("\$deletethread = \"".$templates->get("moderation_deletethread")."\";");
 694          output_page($deletethread);
 695          break;
 696  
 697      // Delete the actual thread here
 698      case "do_deletethread":
 699  
 700          // Verify incoming POST request
 701          verify_post_check($mybb->get_input('my_post_key'));
 702  
 703          if(!is_moderator($fid, "candeletethreads"))
 704          {
 705              if($permissions['candeletethreads'] != 1 || $mybb->user['uid'] != $thread['uid'])
 706              {
 707                  error_no_permission();
 708              }
 709          }
 710  
 711          $plugins->run_hooks("moderation_do_deletethread");
 712  
 713          // Log the subject of the deleted thread
 714          $modlogdata['thread_subject'] = $thread['subject'];
 715  
 716          $thread['subject'] = $db->escape_string($thread['subject']);
 717          $lang->thread_deleted = $lang->sprintf($lang->thread_deleted, $thread['subject']);
 718          log_moderator_action($modlogdata, $lang->thread_deleted);
 719  
 720          $moderation->delete_thread($tid);
 721  
 722          mark_reports($tid, "thread");
 723          moderation_redirect(get_forum_link($fid), $lang->redirect_threaddeleted);
 724          break;
 725  
 726      // Delete the poll from a thread confirmation page
 727      case "deletepoll":
 728          add_breadcrumb($lang->nav_deletepoll);
 729  
 730          if(!is_moderator($fid, "canmanagepolls"))
 731          {
 732              if($permissions['candeletethreads'] != 1 || $mybb->user['uid'] != $thread['uid'])
 733              {
 734                  error_no_permission();
 735              }
 736          }
 737  
 738          $plugins->run_hooks("moderation_deletepoll");
 739  
 740          $query = $db->simple_select("polls", "pid", "tid='$tid'");
 741          $poll = $db->fetch_array($query);
 742          if(!$poll)
 743          {
 744              error($lang->error_invalidpoll);
 745          }
 746  
 747          eval("\$deletepoll = \"".$templates->get("moderation_deletepoll")."\";");
 748          output_page($deletepoll);
 749          break;
 750  
 751      // Delete the actual poll here!
 752      case "do_deletepoll":
 753  
 754          // Verify incoming POST request
 755          verify_post_check($mybb->get_input('my_post_key'));
 756  
 757          if(!isset($mybb->input['delete']))
 758          {
 759              error($lang->redirect_pollnotdeleted);
 760          }
 761          if(!is_moderator($fid, "canmanagepolls"))
 762          {
 763              if($permissions['candeletethreads'] != 1 || $mybb->user['uid'] != $thread['uid'])
 764              {
 765                  error_no_permission();
 766              }
 767          }
 768          $query = $db->simple_select("polls", "pid", "tid = $tid");
 769          $poll = $db->fetch_array($query);
 770          if(!$poll)
 771          {
 772              error($lang->error_invalidpoll);
 773          }
 774  
 775          $plugins->run_hooks("moderation_do_deletepoll");
 776  
 777          $lang->poll_deleted = $lang->sprintf($lang->poll_deleted, $thread['subject']);
 778          log_moderator_action($modlogdata, $lang->poll_deleted);
 779  
 780          $moderation->delete_poll($poll['pid']);
 781  
 782          moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_polldeleted);
 783          break;
 784  
 785      // Approve a thread
 786      case "approvethread":
 787  
 788          // Verify incoming POST request
 789          verify_post_check($mybb->get_input('my_post_key'));
 790  
 791          if(!is_moderator($fid, "canapproveunapprovethreads"))
 792          {
 793              error_no_permission();
 794          }
 795          $thread = get_thread($tid);
 796  
 797          $plugins->run_hooks("moderation_approvethread");
 798  
 799          $lang->thread_approved = $lang->sprintf($lang->thread_approved, $thread['subject']);
 800          log_moderator_action($modlogdata, $lang->thread_approved);
 801  
 802          $moderation->approve_threads($tid, $fid);
 803  
 804          moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_threadapproved);
 805          break;
 806  
 807      // Unapprove a thread
 808      case "unapprovethread":
 809  
 810          // Verify incoming POST request
 811          verify_post_check($mybb->get_input('my_post_key'));
 812  
 813          if(!is_moderator($fid, "canapproveunapprovethreads"))
 814          {
 815              error_no_permission();
 816          }
 817          $thread = get_thread($tid);
 818  
 819          $plugins->run_hooks("moderation_unapprovethread");
 820  
 821          $lang->thread_unapproved = $lang->sprintf($lang->thread_unapproved, $thread['subject']);
 822          log_moderator_action($modlogdata, $lang->thread_unapproved);
 823  
 824          $moderation->unapprove_threads($tid);
 825  
 826          moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_threadunapproved);
 827          break;
 828  
 829      // Restore a thread
 830      case "restorethread":
 831  
 832          // Verify incoming POST request
 833          verify_post_check($mybb->get_input('my_post_key'));
 834  
 835          if(!is_moderator($fid, "canrestorethreads"))
 836          {
 837              error_no_permission();
 838          }
 839          $thread = get_thread($tid);
 840  
 841          $plugins->run_hooks("moderation_restorethread");
 842  
 843          $lang->thread_restored = $lang->sprintf($lang->thread_restored, $thread['subject']);
 844          log_moderator_action($modlogdata, $lang->thread_restored);
 845  
 846          $moderation->restore_threads($tid);
 847  
 848          moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_threadrestored);
 849          break;
 850  
 851      // Soft delete a thread
 852      case "softdeletethread":
 853  
 854          // Verify incoming POST request
 855          verify_post_check($mybb->get_input('my_post_key'));
 856  
 857          if(!is_moderator($fid, "cansoftdeletethreads"))
 858          {
 859              error_no_permission();
 860          }
 861          $thread = get_thread($tid);
 862  
 863          $plugins->run_hooks("moderation_softdeletethread");
 864  
 865          $lang->thread_soft_deleted = $lang->sprintf($lang->thread_soft_deleted, $thread['subject']);
 866          log_moderator_action($modlogdata, $lang->thread_soft_deleted);
 867  
 868          $moderation->soft_delete_threads($tid);
 869  
 870          moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_threadsoftdeleted);
 871          break;
 872  
 873      // Move a thread
 874      case "move":
 875          add_breadcrumb($lang->nav_move);
 876          if(!is_moderator($fid, "canmanagethreads"))
 877          {
 878              error_no_permission();
 879          }
 880  
 881          $plugins->run_hooks("moderation_move");
 882  
 883          $forumselect = build_forum_jump("", '', 1, '', 0, true, '', "moveto");
 884          eval("\$movethread = \"".$templates->get("moderation_move")."\";");
 885          output_page($movethread);
 886          break;
 887  
 888      // Let's get this thing moving!
 889      case "do_move":
 890  
 891          // Verify incoming POST request
 892          verify_post_check($mybb->get_input('my_post_key'));
 893  
 894          $moveto = $mybb->get_input('moveto', MyBB::INPUT_INT);
 895          $method = $mybb->get_input('method');
 896  
 897          if(!is_moderator($fid, "canmanagethreads"))
 898          {
 899              error_no_permission();
 900          }
 901          // Check if user has moderator permission to move to destination
 902          if(!is_moderator($moveto, "canmanagethreads") && !is_moderator($fid, "canmovetononmodforum"))
 903          {
 904              error_no_permission();
 905          }
 906          $newperms = forum_permissions($moveto);
 907          if($newperms['canview'] == 0 && !is_moderator($fid, "canmovetononmodforum"))
 908          {
 909              error_no_permission();
 910          }
 911  
 912          $newforum = get_forum($moveto);
 913          if(!$newforum || $newforum['type'] != "f" || $newforum['type'] == "f" && $newforum['linkto'] != '')
 914          {
 915              error($lang->error_invalidforum);
 916          }
 917          if($method != "copy" && $thread['fid'] == $moveto)
 918          {
 919              error($lang->error_movetosameforum);
 920          }
 921  
 922          $plugins->run_hooks('moderation_do_move');
 923  
 924          $expire = 0;
 925          if($mybb->get_input('redirect_expire', MyBB::INPUT_INT) > 0)
 926          {
 927              $expire = TIME_NOW + ($mybb->get_input('redirect_expire', MyBB::INPUT_INT) * 86400);
 928          }
 929  
 930          $the_thread = $tid;
 931  
 932          $newtid = $moderation->move_thread($tid, $moveto, $method, $expire);
 933  
 934          switch($method)
 935          {
 936              case "copy":
 937                  log_moderator_action($modlogdata, $lang->thread_copied);
 938                  break;
 939              default:
 940              case "move":
 941              case "redirect":
 942                  log_moderator_action($modlogdata, $lang->thread_moved);
 943                  break;
 944          }
 945  
 946          moderation_redirect(get_thread_link($newtid), $lang->redirect_threadmoved);
 947          break;
 948  
 949      // Viewing thread notes
 950      case "viewthreadnotes":
 951          if(!is_moderator($fid))
 952          {
 953              error_no_permission();
 954          }
 955  
 956          // Make sure we are looking at a real thread here.
 957          if(!$thread)
 958          {
 959              error($lang->error_nomember);
 960          }
 961  
 962          $plugins->run_hooks('moderation_viewthreadnotes');
 963  
 964          $lang->view_notes_for = $lang->sprintf($lang->view_notes_for, $thread['subject']);
 965  
 966          $thread['notes'] = nl2br(htmlspecialchars_uni($thread['notes']));
 967  
 968          eval("\$viewthreadnotes = \"".$templates->get("moderation_viewthreadnotes", 1, 0)."\";");
 969          echo $viewthreadnotes;
 970          break;
 971  
 972      // Thread notes editor
 973      case "threadnotes":
 974          add_breadcrumb($lang->nav_threadnotes);
 975          if(!is_moderator($fid, "canmanagethreads"))
 976          {
 977              error_no_permission();
 978          }
 979          $thread['notes'] = htmlspecialchars_uni($parser->parse_badwords($thread['notes']));
 980          $trow = alt_trow(1);
 981  
 982          if(is_moderator($fid, "canviewmodlog"))
 983          {
 984              $query = $db->query("
 985                  SELECT l.*, u.username, t.subject AS tsubject, f.name AS fname, p.subject AS psubject
 986                  FROM ".TABLE_PREFIX."moderatorlog l
 987                  LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=l.uid)
 988                  LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=l.tid)
 989                  LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=l.fid)
 990                  LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=l.pid)
 991                  WHERE t.tid='$tid'
 992                  ORDER BY l.dateline DESC
 993                  LIMIT  0, 20
 994              ");
 995              $modactions = '';
 996              while($modaction = $db->fetch_array($query))
 997              {
 998                  $modaction['dateline'] = my_date("jS M Y, G:i", $modaction['dateline']);
 999                  $modaction['username'] = htmlspecialchars_uni($modaction['username']);
1000                  $modaction['profilelink'] = build_profile_link($modaction['username'], $modaction['uid']);
1001                  $modaction['action'] = htmlspecialchars_uni($modaction['action']);
1002                  $info = '';
1003                  if($modaction['tsubject'])
1004                  {
1005                      $modaction['tsubject'] = htmlspecialchars_uni($parser->parse_badwords($modaction['tsubject']));
1006                      $modaction['threadlink'] = get_thread_link($modaction['tid']);
1007                      eval("\$info .= \"".$templates->get("moderation_threadnotes_modaction_thread")."\";");
1008                  }
1009                  if($modaction['fname'])
1010                  {
1011                      $modaction['fname'] = htmlspecialchars_uni($modaction['fname']);
1012                      $modaction['forumlink'] = get_forum_link($modaction['fid']);
1013                      eval("\$info .= \"".$templates->get("moderation_threadnotes_modaction_forum")."\";");
1014                  }
1015                  if($modaction['psubject'])
1016                  {
1017  
1018                      $modaction['psubject'] = htmlspecialchars_uni($parser->parse_badwords($modaction['psubject']));
1019                      $modaction['postlink'] = get_post_link($modaction['pid']);
1020                      eval("\$info .= \"".$templates->get("moderation_threadnotes_modaction_post")."\";");
1021                  }
1022  
1023                  eval("\$modactions .= \"".$templates->get("moderation_threadnotes_modaction")."\";");
1024                  $trow = alt_trow();
1025              }
1026              if(!$modactions)
1027              {
1028                  eval("\$modactions = \"".$templates->get("moderation_threadnotes_modaction_error")."\";");
1029              }
1030          }
1031  
1032          $actions = array(
1033              'openclosethread' => $lang->open_close_thread,
1034              'deletethread' => $lang->delete_thread,
1035              'move' => $lang->move_copy_thread,
1036              'stick' => $lang->stick_unstick_thread,
1037              'merge' => $lang->merge_threads,
1038              'removeredirects' => $lang->remove_redirects,
1039              'removesubscriptions' => $lang->remove_subscriptions,
1040              'approveunapprovethread' => $lang->approve_unapprove_thread
1041          );
1042  
1043          switch($db->type)
1044          {
1045              case "pgsql":
1046              case "sqlite":
1047                  $query = $db->simple_select("modtools", 'tid, name', "(','||forums||',' LIKE '%,$fid,%' OR ','||forums||',' LIKE '%,-1,%' OR forums='') AND type = 't'");
1048                  break;
1049              default:
1050                  $query = $db->simple_select("modtools", 'tid, name', "(CONCAT(',',forums,',') LIKE '%,$fid,%' OR CONCAT(',',forums,',') LIKE '%,-1,%' OR forums='') AND type = 't'");
1051          }
1052          while($tool = $db->fetch_array($query))
1053          {
1054              $actions['modtool_'.$tool['tid']] = htmlspecialchars_uni($tool['name']);
1055          }
1056  
1057          $forum_cache = $cache->read("forums");
1058  
1059          $trow = alt_trow(1);
1060          switch($db->type)
1061          {
1062              case "pgsql":
1063              case "sqlite":
1064                  $query = $db->query("
1065                      SELECT d.*, u.username, f.name AS fname
1066                      FROM ".TABLE_PREFIX."delayedmoderation d
1067                      LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=d.uid)
1068                      LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=d.fid)
1069                      WHERE ','||d.tids||',' LIKE '%,{$tid},%'
1070                      ORDER BY d.dateline DESC
1071                      LIMIT  0, 20
1072                  ");
1073                  break;
1074              default:
1075                  $query = $db->query("
1076                      SELECT d.*, u.username, f.name AS fname
1077                      FROM ".TABLE_PREFIX."delayedmoderation d
1078                      LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=d.uid)
1079                      LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=d.fid)
1080                      WHERE CONCAT(',',d.tids,',') LIKE '%,{$tid},%'
1081                      ORDER BY d.dateline DESC
1082                      LIMIT  0, 20
1083                  ");
1084          }
1085          $delayedmods = '';
1086          while($delayedmod = $db->fetch_array($query))
1087          {
1088              $delayedmod['dateline'] = my_date("jS M Y, G:i", $delayedmod['delaydateline']);
1089              $delayedmod['username'] = htmlspecialchars_uni($delayedmod['username']);
1090              $delayedmod['profilelink'] = build_profile_link($delayedmod['username'], $delayedmod['uid']);
1091              $delayedmod['action'] = $actions[$delayedmod['type']];
1092              $info = '';
1093              if(strpos($delayedmod['tids'], ',') === false)
1094              {
1095                  $delayed_thread['link'] = get_thread_link($delayedmod['tids']);
1096                  $delayed_thread['subject'] = htmlspecialchars_uni($thread['subject']);
1097                  eval("\$info .= \"".$templates->get("moderation_delayedmodaction_notes_thread_single")."\";");
1098              }
1099              else
1100              {
1101                  eval("\$info .= \"".$templates->get("moderation_delayedmodaction_notes_thread_multiple")."\";");
1102              }
1103  
1104              if($delayedmod['fname'])
1105              {
1106                  $delayedmod['link'] = get_forum_link($delayedmod['fid']);
1107                  $delayedmod['fname'] = htmlspecialchars_uni($delayedmod['fname']);
1108                  eval("\$info .= \"".$templates->get("moderation_delayedmodaction_notes_forum")."\";");
1109              }
1110              $delayedmod['inputs'] = my_unserialize($delayedmod['inputs']);
1111  
1112              if($delayedmod['type'] == 'move')
1113              {
1114                  $delayedmod['link'] = get_forum_link($delayedmod['inputs']['new_forum']);
1115                  $delayedmod['name'] = htmlspecialchars_uni($forum_cache[$delayedmod['inputs']['new_forum']]['name']);
1116                  eval("\$info .= \"".$templates->get("moderation_delayedmodaction_notes_new_forum")."\";");
1117  
1118                  if($delayedmod['inputs']['method'] == "redirect")
1119                  {
1120                      if((int)$delayedmod['inputs']['redirect_expire'] == 0)
1121                      {
1122                          $redirect_expire_bit = $lang->redirect_forever;
1123                      }
1124                      else
1125                      {
1126                          $redirect_expire_bit = (int)$delayedmod['inputs']['redirect_expire']." {$lang->days}";
1127                      }
1128  
1129                      eval("\$info .= \"".$templates->get("moderation_delayedmodaction_notes_redirect")."\";");
1130                  }
1131              }
1132              else if($delayedmod['type'] == 'merge')
1133              {
1134                  $delayedmod['subject'] = htmlspecialchars_uni($delayedmod['inputs']['subject']);
1135                  $delayedmod['threadurl'] = htmlspecialchars_uni($delayedmod['inputs']['threadurl']);
1136                  eval("\$info .= \"".$templates->get("moderation_delayedmodaction_notes_merge")."\";");
1137              }
1138  
1139              eval("\$delayedmods .= \"".$templates->get("moderation_threadnotes_delayedmodaction")."\";");
1140              $trow = alt_trow();
1141          }
1142          if(!$delayedmods)
1143          {
1144              $cols = 4;
1145              eval("\$delayedmods = \"".$templates->get("moderation_delayedmodaction_error")."\";");
1146          }
1147  
1148          $plugins->run_hooks("moderation_threadnotes");
1149  
1150          eval("\$threadnotes = \"".$templates->get("moderation_threadnotes")."\";");
1151          output_page($threadnotes);
1152          break;
1153  
1154      // Update the thread notes!
1155      case "do_threadnotes":
1156  
1157          // Verify incoming POST request
1158          verify_post_check($mybb->get_input('my_post_key'));
1159  
1160          if(!is_moderator($fid, "canmanagethreads"))
1161          {
1162              error_no_permission();
1163          }
1164  
1165          $plugins->run_hooks("moderation_do_threadnotes");
1166  
1167          log_moderator_action($modlogdata, $lang->thread_notes_edited);
1168          $sqlarray = array(
1169              "notes" => $db->escape_string($mybb->get_input('threadnotes')),
1170          );
1171          $db->update_query("threads", $sqlarray, "tid='$tid'");
1172          moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_threadnotesupdated);
1173          break;
1174  
1175      // Let's look up the ip address of a post
1176      case "getip":
1177          add_breadcrumb($lang->nav_getip);
1178          if(!is_moderator($fid, "canviewips"))
1179          {
1180              error_no_permission();
1181          }
1182  
1183          $post['ipaddress'] = my_inet_ntop($db->unescape_binary($post['ipaddress']));
1184          $hostname = @gethostbyaddr($post['ipaddress']);
1185          if(!$hostname || $hostname == $post['ipaddress'])
1186          {
1187              $hostname = $lang->resolve_fail;
1188          }
1189  
1190          $post['username'] = htmlspecialchars_uni($post['username']);
1191          $username = build_profile_link($post['username'], $post['uid']);
1192  
1193          // Moderator options
1194          $modoptions = "";
1195          if($mybb->usergroup['canmodcp'] == 1 && $mybb->usergroup['canuseipsearch'] == 1)
1196          {
1197              $ipaddress = $post['ipaddress'];
1198              eval("\$modoptions = \"".$templates->get("moderation_getip_modoptions")."\";");
1199          }
1200  
1201          $plugins->run_hooks('moderation_getip');
1202  
1203          eval("\$getip = \"".$templates->get("moderation_getip")."\";");
1204          output_page($getip);
1205          break;
1206  
1207      // Let's look up the ip address of a PM
1208      case "getpmip":
1209          if($pmid <= 0)
1210          {
1211              error($lang->error_invalidpm);
1212          }
1213          add_breadcrumb($lang->nav_pms, "private.php");
1214          $pm['subject'] = htmlspecialchars_uni($parser->parse_badwords($pm['subject']));
1215          add_breadcrumb($pm['subject'], "private.php?action=read&amp;pmid={$pmid}");
1216          add_breadcrumb($lang->nav_getpmip);
1217          if(!$mybb->usergroup['issupermod'])
1218          {
1219              error_no_permission();
1220          }
1221  
1222          $pm['ipaddress'] = my_inet_ntop($db->unescape_binary($pm['ipaddress']));
1223          $hostname = @gethostbyaddr($pm['ipaddress']);
1224          if(!$hostname || $hostname == $pm['ipaddress'])
1225          {
1226              $hostname = $lang->resolve_fail;
1227          }
1228  
1229          $name = $db->fetch_field($db->simple_select('users', 'username', "uid = {$pm['fromid']}"), 'username');
1230          $username = build_profile_link($name, $pm['fromid']);
1231  
1232          // Moderator options
1233          $modoptions = "";
1234          if($mybb->usergroup['canmodcp'] == 1 && $mybb->usergroup['canuseipsearch'] == 1)
1235          {
1236              $ipaddress = $pm['ipaddress'];
1237              eval("\$modoptions = \"".$templates->get("moderation_getip_modoptions")."\";");
1238          }
1239  
1240          $plugins->run_hooks('moderation_getpmip');
1241  
1242          eval("\$getpmip = \"".$templates->get("moderation_getpmip")."\";");
1243          output_page($getpmip);
1244          break;
1245  
1246      // Merge threads
1247      case "merge":
1248          add_breadcrumb($lang->nav_merge);
1249          if(!is_moderator($fid, "canmanagethreads"))
1250          {
1251              error_no_permission();
1252          }
1253  
1254          $plugins->run_hooks("moderation_merge");
1255  
1256          eval("\$merge = \"".$templates->get("moderation_merge")."\";");
1257          output_page($merge);
1258          break;
1259  
1260      // Let's get those threads together baby! (Merge threads)
1261      case "do_merge":
1262  
1263          // Verify incoming POST request
1264          verify_post_check($mybb->get_input('my_post_key'));
1265  
1266          if(!is_moderator($fid, "canmanagethreads"))
1267          {
1268              error_no_permission();
1269          }
1270  
1271          $plugins->run_hooks("moderation_do_merge");
1272  
1273          // explode at # sign in a url (indicates a name reference) and reassign to the url
1274          $realurl = explode("#", $mybb->get_input('threadurl'));
1275          $mybb->input['threadurl'] = $realurl[0];
1276  
1277          // Are we using an SEO URL?
1278          if(substr($mybb->input['threadurl'], -4) == "html")
1279          {
1280              // Get thread to merge's tid the SEO way
1281              preg_match("#thread-([0-9]+)?#i", $mybb->input['threadurl'], $threadmatch);
1282              preg_match("#post-([0-9]+)?#i", $mybb->input['threadurl'], $postmatch);
1283  
1284              if($threadmatch[1])
1285              {
1286                  $parameters['tid'] = $threadmatch[1];
1287              }
1288  
1289              if($postmatch[1])
1290              {
1291                  $parameters['pid'] = $postmatch[1];
1292              }
1293          }
1294          else
1295          {
1296              // Get thread to merge's tid the normal way
1297              $splitloc = explode(".php", $mybb->input['threadurl']);
1298              $temp = explode("&", my_substr($splitloc[1], 1));
1299  
1300              if(!empty($temp))
1301              {
1302                  for($i = 0; $i < count($temp); $i++)
1303                  {
1304                      $temp2 = explode("=", $temp[$i], 2);
1305                      $parameters[$temp2[0]] = $temp2[1];
1306                  }
1307              }
1308              else
1309              {
1310                  $temp2 = explode("=", $splitloc[1], 2);
1311                  $parameters[$temp2[0]] = $temp2[1];
1312              }
1313          }
1314  
1315          if(!empty($parameters['pid']) && empty($parameters['tid']))
1316          {
1317              $post = get_post($parameters['pid']);
1318              $mergetid = (int)$post['tid'];
1319          }
1320          elseif(!empty($parameters['tid']))
1321          {
1322              $mergetid = (int)$parameters['tid'];
1323          }
1324          else
1325          {
1326              $mergetid = 0;
1327          }
1328          $mergethread = get_thread($mergetid);
1329          if(!$mergethread)
1330          {
1331              error($lang->error_badmergeurl);
1332          }
1333          if($mergetid == $tid)
1334          { // sanity check
1335              error($lang->error_mergewithself);
1336          }
1337          if(!is_moderator($mergethread['fid'], "canmanagethreads"))
1338          {
1339              error_no_permission();
1340          }
1341          if(isset($mybb->input['subject']))
1342          {
1343              $subject = $mybb->get_input('subject');
1344          }
1345          else
1346          {
1347              $subject = $thread['subject'];
1348          }
1349  
1350          $moderation->merge_threads($mergetid, $tid, $subject);
1351  
1352          log_moderator_action($modlogdata, $lang->thread_merged);
1353  
1354          moderation_redirect(get_thread_link($tid), $lang->redirect_threadsmerged);
1355          break;
1356  
1357      // Divorce the posts in this thread (Split!)
1358      case "split":
1359          add_breadcrumb($lang->nav_split);
1360          if(!is_moderator($fid, "canmanagethreads"))
1361          {
1362              error_no_permission();
1363          }
1364          $query = $db->query("
1365              SELECT p.*, u.*
1366              FROM ".TABLE_PREFIX."posts p
1367              LEFT JOIN ".TABLE_PREFIX."users u ON (p.uid=u.uid)
1368              WHERE tid='$tid'
1369              ORDER BY dateline ASC
1370          ");
1371          $numposts = $db->num_rows($query);
1372          if($numposts <= 1)
1373          {
1374              error($lang->error_cantsplitonepost);
1375          }
1376  
1377          $altbg = "trow1";
1378          $posts = '';
1379          while($post = $db->fetch_array($query))
1380          {
1381              $postdate = my_date('relative', $post['dateline']);
1382              $post['username'] = htmlspecialchars_uni($post['username']);
1383  
1384              $parser_options = array(
1385                  "allow_html" => $forum['allowhtml'],
1386                  "allow_mycode" => $forum['allowmycode'],
1387                  "allow_smilies" => $forum['allowsmilies'],
1388                  "allow_imgcode" => $forum['allowimgcode'],
1389                  "allow_videocode" => $forum['allowvideocode'],
1390                  "filter_badwords" => 1
1391              );
1392              if($post['smilieoff'] == 1)
1393              {
1394                  $parser_options['allow_smilies'] = 0;
1395              }
1396  
1397              $message = $parser->parse_message($post['message'], $parser_options);
1398              eval("\$posts .= \"".$templates->get("moderation_split_post")."\";");
1399              $altbg = alt_trow();
1400          }
1401          $forumselect = build_forum_jump("", $fid, 1, '', 0, true, '', "moveto");
1402  
1403          $plugins->run_hooks("moderation_split");
1404  
1405          eval("\$split = \"".$templates->get("moderation_split")."\";");
1406          output_page($split);
1407          break;
1408  
1409      // Let's break them up buddy! (Do the split)
1410      case "do_split":
1411  
1412          // Verify incoming POST request
1413          verify_post_check($mybb->get_input('my_post_key'));
1414  
1415          if(!is_moderator($fid, "canmanagethreads"))
1416          {
1417              error_no_permission();
1418          }
1419  
1420          $plugins->run_hooks("moderation_do_split");
1421  
1422          $mybb->input['splitpost'] = $mybb->get_input('splitpost', MyBB::INPUT_ARRAY);
1423          if(empty($mybb->input['splitpost']))
1424          {
1425              error($lang->error_nosplitposts);
1426          }
1427          $query = $db->simple_select("posts", "COUNT(*) AS totalposts", "tid='{$tid}'");
1428          $count = $db->fetch_array($query);
1429  
1430          if($count['totalposts'] == 1)
1431          {
1432              error($lang->error_cantsplitonepost);
1433          }
1434  
1435          if($count['totalposts'] == count($mybb->input['splitpost']))
1436          {
1437              error($lang->error_cantsplitall);
1438          }
1439  
1440          if(!empty($mybb->input['moveto']))
1441          {
1442              $moveto = $mybb->get_input('moveto', MyBB::INPUT_INT);
1443          }
1444          else
1445          {
1446              $moveto = $fid;
1447          }
1448  
1449          $newforum = get_forum($moveto);
1450          if(!$newforum || $newforum['type'] != "f" || $newforum['type'] == "f" && $newforum['linkto'] != '')
1451          {
1452              error($lang->error_invalidforum);
1453          }
1454  
1455          $pids = array();
1456  
1457          // move the selected posts over
1458          $query = $db->simple_select("posts", "pid", "tid='$tid'");
1459          while($post = $db->fetch_array($query))
1460          {
1461              if(isset($mybb->input['splitpost'][$post['pid']]) && $mybb->input['splitpost'][$post['pid']] == 1)
1462              {
1463                  $pids[] = $post['pid'];
1464              }
1465              mark_reports($post['pid'], "post");
1466          }
1467  
1468          $newtid = $moderation->split_posts($pids, $tid, $moveto, $mybb->get_input('newsubject'));
1469  
1470          log_moderator_action($modlogdata, $lang->thread_split);
1471  
1472          moderation_redirect(get_thread_link($newtid), $lang->redirect_threadsplit);
1473          break;
1474  
1475      // Delete Thread Subscriptions
1476      case "removesubscriptions":
1477  
1478          // Verify incoming POST request
1479          verify_post_check($mybb->get_input('my_post_key'));
1480  
1481          if(!is_moderator($fid, "canmanagethreads"))
1482          {
1483              error_no_permission();
1484          }
1485  
1486          $plugins->run_hooks("moderation_removesubscriptions");
1487  
1488          $moderation->remove_thread_subscriptions($tid, true);
1489  
1490          log_moderator_action($modlogdata, $lang->removed_subscriptions);
1491  
1492          moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_removed_subscriptions);
1493          break;
1494  
1495      // Delete Threads - Inline moderation
1496      case "multideletethreads":
1497          add_breadcrumb($lang->nav_multi_deletethreads);
1498  
1499          if(!empty($mybb->input['searchid']))
1500          {
1501              // From search page
1502              $threads = getids($mybb->get_input('searchid'), 'search');
1503              if(!is_moderator_by_tids($threads, 'candeletethreads'))
1504              {
1505                  error_no_permission();
1506              }
1507          }
1508          else
1509          {
1510              $threads = getids($fid, 'forum');
1511              if(!is_moderator($fid, 'candeletethreads'))
1512              {
1513                  error_no_permission();
1514              }
1515          }
1516          if(count($threads) < 1)
1517          {
1518              error($lang->error_inline_nothreadsselected);
1519          }
1520  
1521          $inlineids = implode("|", $threads);
1522          if($mybb->get_input('inlinetype') == 'search')
1523          {
1524              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
1525          }
1526          else
1527          {
1528              clearinline($fid, 'forum');
1529          }
1530          $return_url = htmlspecialchars_uni($mybb->get_input('url'));
1531          eval("\$multidelete = \"".$templates->get("moderation_inline_deletethreads")."\";");
1532          output_page($multidelete);
1533          break;
1534  
1535      // Actually delete the threads - Inline moderation
1536      case "do_multideletethreads":
1537  
1538          // Verify incoming POST request
1539          verify_post_check($mybb->get_input('my_post_key'));
1540  
1541          $threadlist = explode("|", $mybb->get_input('threads'));
1542          if(!is_moderator_by_tids($threadlist, "candeletethreads"))
1543          {
1544              error_no_permission();
1545          }
1546          foreach($threadlist as $tid)
1547          {
1548              $tid = (int)$tid;
1549              $moderation->delete_thread($tid);
1550              $tlist[] = $tid;
1551          }
1552          log_moderator_action($modlogdata, $lang->multi_deleted_threads);
1553          if($mybb->get_input('inlinetype') == 'search')
1554          {
1555              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
1556          }
1557          else
1558          {
1559              clearinline($fid, 'forum');
1560          }
1561          mark_reports($tlist, "threads");
1562          moderation_redirect(get_forum_link($fid), $lang->redirect_inline_threadsdeleted);
1563          break;
1564  
1565      // Open threads - Inline moderation
1566      case "multiopenthreads":
1567  
1568          // Verify incoming POST request
1569          verify_post_check($mybb->get_input('my_post_key'));
1570  
1571          if(!empty($mybb->input['searchid']))
1572          {
1573              // From search page
1574              $threads = getids($mybb->get_input('searchid'), 'search');
1575              if(!is_moderator_by_tids($threads, 'canopenclosethreads'))
1576              {
1577                  error_no_permission();
1578              }
1579          }
1580          else
1581          {
1582              $threads = getids($fid, 'forum');
1583              if(!is_moderator($fid, 'canopenclosethreads'))
1584              {
1585                  error_no_permission();
1586              }
1587          }
1588  
1589          if(count($threads) < 1)
1590          {
1591              error($lang->error_inline_nothreadsselected);
1592          }
1593  
1594          $moderation->open_threads($threads);
1595  
1596          log_moderator_action($modlogdata, $lang->multi_opened_threads);
1597          if($mybb->get_input('inlinetype') == 'search')
1598          {
1599              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
1600          }
1601          else
1602          {
1603              clearinline($fid, 'forum');
1604          }
1605          moderation_redirect(get_forum_link($fid), $lang->redirect_inline_threadsopened);
1606          break;
1607  
1608      // Close threads - Inline moderation
1609      case "multiclosethreads":
1610  
1611          // Verify incoming POST request
1612          verify_post_check($mybb->get_input('my_post_key'));
1613  
1614          if(!empty($mybb->input['searchid']))
1615          {
1616              // From search page
1617              $threads = getids($mybb->get_input('searchid'), 'search');
1618              if(!is_moderator_by_tids($threads, 'canopenclosethreads'))
1619              {
1620                  error_no_permission();
1621              }
1622          }
1623          else
1624          {
1625              $threads = getids($fid, 'forum');
1626              if(!is_moderator($fid, 'canopenclosethreads'))
1627              {
1628                  error_no_permission();
1629              }
1630          }
1631          if(count($threads) < 1)
1632          {
1633              error($lang->error_inline_nothreadsselected);
1634          }
1635  
1636          $moderation->close_threads($threads);
1637  
1638          log_moderator_action($modlogdata, $lang->multi_closed_threads);
1639          if($mybb->get_input('inlinetype') == 'search')
1640          {
1641              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
1642          }
1643          else
1644          {
1645              clearinline($fid, 'forum');
1646          }
1647          moderation_redirect(get_forum_link($fid), $lang->redirect_inline_threadsclosed);
1648          break;
1649  
1650      // Approve threads - Inline moderation
1651      case "multiapprovethreads":
1652  
1653          // Verify incoming POST request
1654          verify_post_check($mybb->get_input('my_post_key'));
1655  
1656          if(!empty($mybb->input['searchid']))
1657          {
1658              // From search page
1659              $threads = getids($mybb->get_input('searchid'), 'search');
1660              if(!is_moderator_by_tids($threads, 'canapproveunapprovethreads'))
1661              {
1662                  error_no_permission();
1663              }
1664          }
1665          else
1666          {
1667              $threads = getids($fid, 'forum');
1668              if(!is_moderator($fid, 'canapproveunapprovethreads'))
1669              {
1670                  error_no_permission();
1671              }
1672          }
1673          if(count($threads) < 1)
1674          {
1675              error($lang->error_inline_nothreadsselected);
1676          }
1677  
1678          $moderation->approve_threads($threads, $fid);
1679  
1680          log_moderator_action($modlogdata, $lang->multi_approved_threads);
1681          if($mybb->get_input('inlinetype') == 'search')
1682          {
1683              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
1684          }
1685          else
1686          {
1687              clearinline($fid, 'forum');
1688          }
1689          $cache->update_stats();
1690          moderation_redirect(get_forum_link($fid), $lang->redirect_inline_threadsapproved);
1691          break;
1692  
1693      // Unapprove threads - Inline moderation
1694      case "multiunapprovethreads":
1695  
1696          // Verify incoming POST request
1697          verify_post_check($mybb->get_input('my_post_key'));
1698  
1699          if(!empty($mybb->input['searchid']))
1700          {
1701              // From search page
1702              $threads = getids($mybb->get_input('searchid'), 'search');
1703              if(!is_moderator_by_tids($threads, 'canapproveunapprovethreads'))
1704              {
1705                  error_no_permission();
1706              }
1707          }
1708          else
1709          {
1710              $threads = getids($fid, 'forum');
1711              if(!is_moderator($fid, 'canapproveunapprovethreads'))
1712              {
1713                  error_no_permission();
1714              }
1715          }
1716          if(count($threads) < 1)
1717          {
1718              error($lang->error_inline_nothreadsselected);
1719          }
1720  
1721          $moderation->unapprove_threads($threads, $fid);
1722  
1723          log_moderator_action($modlogdata, $lang->multi_unapproved_threads);
1724          if($mybb->get_input('inlinetype') == 'search')
1725          {
1726              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
1727          }
1728          else
1729          {
1730              clearinline($fid, 'forum');
1731          }
1732          $cache->update_stats();
1733          moderation_redirect(get_forum_link($fid), $lang->redirect_inline_threadsunapproved);
1734          break;
1735  
1736      // Restore threads - Inline moderation
1737      case "multirestorethreads":
1738  
1739          // Verify incoming POST request
1740          verify_post_check($mybb->get_input('my_post_key'));
1741  
1742          if(!empty($mybb->input['searchid']))
1743          {
1744              // From search page
1745              $threads = getids($mybb->get_input('searchid'), 'search');
1746              if(!is_moderator_by_tids($threads, 'canrestorethreads'))
1747              {
1748                  error_no_permission();
1749              }
1750          }
1751          else
1752          {
1753              $threads = getids($fid, 'forum');
1754              if(!is_moderator($fid, 'canrestorethreads'))
1755              {
1756                  error_no_permission();
1757              }
1758          }
1759          if(count($threads) < 1)
1760          {
1761              error($lang->error_inline_nothreadsselected);
1762          }
1763  
1764          $moderation->restore_threads($threads);
1765  
1766          log_moderator_action($modlogdata, $lang->multi_restored_threads);
1767          if($mybb->get_input('inlinetype') == 'search')
1768          {
1769              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
1770          }
1771          else
1772          {
1773              clearinline($fid, 'forum');
1774          }
1775          $cache->update_stats();
1776          moderation_redirect(get_forum_link($fid), $lang->redirect_inline_threadsrestored);
1777          break;
1778  
1779      // Soft delete threads - Inline moderation
1780      case "multisoftdeletethreads":
1781  
1782          // Verify incoming POST request
1783          verify_post_check($mybb->get_input('my_post_key'));
1784  
1785          if(!empty($mybb->input['searchid']))
1786          {
1787              // From search page
1788              $threads = getids($mybb->get_input('searchid'), 'search');
1789              if(!is_moderator_by_tids($threads, 'cansoftdeletethreads'))
1790              {
1791                  error_no_permission();
1792              }
1793          }
1794          else
1795          {
1796              $threads = getids($fid, 'forum');
1797              if(!is_moderator($fid, 'cansoftdeletethreads'))
1798              {
1799                  error_no_permission();
1800              }
1801          }
1802          if(count($threads) < 1)
1803          {
1804              error($lang->error_inline_nothreadsselected);
1805          }
1806  
1807          $moderation->soft_delete_threads($threads);
1808  
1809          log_moderator_action($modlogdata, $lang->multi_soft_deleted_threads);
1810          if($mybb->get_input('inlinetype') == 'search')
1811          {
1812              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
1813          }
1814          else
1815          {
1816              clearinline($fid, 'forum');
1817          }
1818          $cache->update_stats();
1819          moderation_redirect(get_forum_link($fid), $lang->redirect_inline_threadssoftdeleted);
1820          break;
1821  
1822      // Stick threads - Inline moderation
1823      case "multistickthreads":
1824  
1825          // Verify incoming POST request
1826          verify_post_check($mybb->get_input('my_post_key'));
1827  
1828          if(!empty($mybb->input['searchid']))
1829          {
1830              // From search page
1831              $threads = getids($mybb->get_input('searchid'), 'search');
1832              if(!is_moderator_by_tids($threads, 'canstickunstickthreads'))
1833              {
1834                  error_no_permission();
1835              }
1836          }
1837          else
1838          {
1839              $threads = getids($fid, 'forum');
1840              if(!is_moderator($fid, 'canstickunstickthreads'))
1841              {
1842                  error_no_permission();
1843              }
1844          }
1845          if(count($threads) < 1)
1846          {
1847              error($lang->error_inline_nothreadsselected);
1848          }
1849  
1850          $moderation->stick_threads($threads);
1851  
1852          log_moderator_action($modlogdata, $lang->multi_stuck_threads);
1853          if($mybb->get_input('inlinetype') == 'search')
1854          {
1855              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
1856          }
1857          else
1858          {
1859              clearinline($fid, 'forum');
1860          }
1861          moderation_redirect(get_forum_link($fid), $lang->redirect_inline_threadsstuck);
1862          break;
1863  
1864      // Unstick threads - Inline moderaton
1865      case "multiunstickthreads":
1866  
1867          // Verify incoming POST request
1868          verify_post_check($mybb->get_input('my_post_key'));
1869  
1870          if(!empty($mybb->input['searchid']))
1871          {
1872              // From search page
1873              $threads = getids($mybb->get_input('searchid'), 'search');
1874              if(!is_moderator_by_tids($threads, 'canstickunstickthreads'))
1875              {
1876                  error_no_permission();
1877              }
1878          }
1879          else
1880          {
1881              $threads = getids($fid, 'forum');
1882              if(!is_moderator($fid, 'canstickunstickthreads'))
1883              {
1884                  error_no_permission();
1885              }
1886          }
1887          if(count($threads) < 1)
1888          {
1889              error($lang->error_inline_nothreadsselected);
1890          }
1891  
1892          $moderation->unstick_threads($threads);
1893  
1894          log_moderator_action($modlogdata, $lang->multi_unstuck_threads);
1895          if($mybb->get_input('inlinetype') == 'search')
1896          {
1897              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
1898          }
1899          else
1900          {
1901              clearinline($fid, 'forum');
1902          }
1903          moderation_redirect(get_forum_link($fid), $lang->redirect_inline_threadsunstuck);
1904          break;
1905  
1906      // Move threads - Inline moderation
1907      case "multimovethreads":
1908          add_breadcrumb($lang->nav_multi_movethreads);
1909  
1910          if(!empty($mybb->input['searchid']))
1911          {
1912              // From search page
1913              $threads = getids($mybb->get_input('searchid'), 'search');
1914              if(!is_moderator_by_tids($threads, 'canmanagethreads'))
1915              {
1916                  error_no_permission();
1917              }
1918          }
1919          else
1920          {
1921              $threads = getids($fid, 'forum');
1922              if(!is_moderator($fid, 'canmanagethreads'))
1923              {
1924                  error_no_permission();
1925              }
1926          }
1927  
1928          if(count($threads) < 1)
1929          {
1930              error($lang->error_inline_nothreadsselected);
1931          }
1932          $inlineids = implode("|", $threads);
1933          if($mybb->get_input('inlinetype') == 'search')
1934          {
1935              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
1936          }
1937          else
1938          {
1939              clearinline($fid, 'forum');
1940          }
1941          $forumselect = build_forum_jump("", '', 1, '', 0, true, '', "moveto");
1942          $return_url = htmlspecialchars_uni($mybb->get_input('url'));
1943          eval("\$movethread = \"".$templates->get("moderation_inline_movethreads")."\";");
1944          output_page($movethread);
1945          break;
1946  
1947      // Actually move the threads in Inline moderation
1948      case "do_multimovethreads":
1949  
1950          // Verify incoming POST request
1951          verify_post_check($mybb->get_input('my_post_key'));
1952  
1953          $moveto = $mybb->get_input('moveto', MyBB::INPUT_INT);
1954          $threadlist = explode("|", $mybb->get_input('threads'));
1955          if(!is_moderator_by_tids($threadlist, 'canmanagethreads'))
1956          {
1957              error_no_permission();
1958          }
1959          foreach($threadlist as $tid)
1960          {
1961              $tids[] = (int)$tid;
1962          }
1963          // Make sure moderator has permission to move to the new forum
1964          $newperms = forum_permissions($moveto);
1965          if(($newperms['canview'] == 0 || !is_moderator($moveto, 'canmanagethreads')) && !is_moderator_by_tids($tids, 'canmovetononmodforum'))
1966          {
1967              error_no_permission();
1968          }
1969  
1970          $newforum = get_forum($moveto);
1971          if(!$newforum || $newforum['type'] != "f" || $newforum['type'] == "f" && $newforum['linkto'] != '')
1972          {
1973              error($lang->error_invalidforum);
1974          }
1975  
1976          $moderation->move_threads($tids, $moveto);
1977  
1978          log_moderator_action($modlogdata, $lang->multi_moved_threads);
1979  
1980          moderation_redirect(get_forum_link($moveto), $lang->redirect_inline_threadsmoved);
1981          break;
1982  
1983      // Delete posts - Inline moderation
1984      case "multideleteposts":
1985          add_breadcrumb($lang->nav_multi_deleteposts);
1986  
1987          if($mybb->get_input('inlinetype') == 'search')
1988          {
1989              $posts = getids($mybb->get_input('searchid'), 'search');
1990          }
1991          else
1992          {
1993              $posts = getids($tid, 'thread');
1994          }
1995  
1996          if(count($posts) < 1)
1997          {
1998              error($lang->error_inline_nopostsselected);
1999          }
2000          if(!is_moderator_by_pids($posts, "candeleteposts"))
2001          {
2002              error_no_permission();
2003          }
2004          $inlineids = implode("|", $posts);
2005          if($mybb->get_input('inlinetype') == 'search')
2006          {
2007              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
2008          }
2009          else
2010          {
2011              clearinline($tid, 'thread');
2012          }
2013  
2014          $return_url = htmlspecialchars_uni($mybb->get_input('url'));
2015  
2016          eval("\$multidelete = \"".$templates->get("moderation_inline_deleteposts")."\";");
2017          output_page($multidelete);
2018          break;
2019  
2020      // Actually delete the posts in inline moderation
2021      case "do_multideleteposts":
2022  
2023          // Verify incoming POST request
2024          verify_post_check($mybb->get_input('my_post_key'));
2025  
2026          $postlist = explode("|", $mybb->get_input('posts'));
2027          if(!is_moderator_by_pids($postlist, "candeleteposts"))
2028          {
2029              error_no_permission();
2030          }
2031          $postlist = array_map('intval', $postlist);
2032          $pids = implode(',', $postlist);
2033  
2034          $tids = array();
2035          if($pids)
2036          {
2037              $query = $db->simple_select("threads", "tid", "firstpost IN({$pids})");
2038              while($threadid = $db->fetch_field($query, "tid"))
2039              {
2040                  $tids[] = $threadid;
2041              }
2042          }
2043  
2044          $deletecount = 0;
2045          foreach($postlist as $pid)
2046          {
2047              $pid = (int)$pid;
2048              $moderation->delete_post($pid);
2049              $plist[] = $pid;
2050              $deletecount++;
2051          }
2052  
2053          // If we have multiple threads, we must be coming from the search
2054          if(!empty($tids))
2055          {
2056              foreach($tids as $tid)
2057              {
2058                  $moderation->delete_thread($tid);
2059                  mark_reports($tid, "thread");
2060                  $url = get_forum_link($fid);
2061              }
2062          }
2063          // Otherwise we're just deleting from showthread.php
2064          else
2065          {
2066              $query = $db->simple_select("posts", "pid", "tid = $tid");
2067              $numposts = $db->num_rows($query);
2068              if(!$numposts)
2069              {
2070                  $moderation->delete_thread($tid);
2071                  mark_reports($tid, "thread");
2072                  $url = get_forum_link($fid);
2073              }
2074              else
2075              {
2076                  mark_reports($plist, "posts");
2077                  $url = get_thread_link($thread['tid']);
2078              }
2079          }
2080  
2081          $lang->deleted_selective_posts = $lang->sprintf($lang->deleted_selective_posts, $deletecount);
2082          log_moderator_action($modlogdata, $lang->deleted_selective_posts);
2083          moderation_redirect($url, $lang->redirect_postsdeleted);
2084          break;
2085  
2086      // Merge posts - Inline moderation
2087      case "multimergeposts":
2088          add_breadcrumb($lang->nav_multi_mergeposts);
2089  
2090          if($mybb->get_input('inlinetype') == 'search')
2091          {
2092              $posts = getids($mybb->get_input('searchid'), 'search');
2093          }
2094          else
2095          {
2096              $posts = getids($tid, 'thread');
2097          }
2098  
2099          // Add the selected posts from other threads
2100          foreach($mybb->cookies as $key => $value)
2101          {
2102              if(strpos($key, "inlinemod_thread") !== false && $key != "inlinemod_thread$tid")
2103              {
2104                  $inlinepostlist = explode("|", $mybb->cookies[$key]);
2105                  foreach($inlinepostlist as $p)
2106                  {
2107                      $p = (int)$p;
2108  
2109                      if(!empty($p))
2110                      {
2111                          $posts[] = (int)$p;
2112                      }
2113                  }
2114                  // Remove the cookie once its data is retrieved
2115                  my_unsetcookie($key);
2116              }
2117          }
2118  
2119          if(empty($posts))
2120          {
2121              error($lang->error_inline_nopostsselected);
2122          }
2123  
2124          if(!is_moderator_by_pids($posts, "canmanagethreads"))
2125          {
2126              error_no_permission();
2127          }
2128  
2129          $postlist = "";
2130          $query = $db->query("
2131              SELECT p.*, u.*
2132              FROM ".TABLE_PREFIX."posts p
2133              LEFT JOIN ".TABLE_PREFIX."users u ON (p.uid=u.uid)
2134              WHERE pid IN (".implode($posts, ",").")
2135              ORDER BY dateline ASC
2136          ");
2137          $altbg = "trow1";
2138          while($post = $db->fetch_array($query))
2139          {
2140              $postdate = my_date('relative', $post['dateline']);
2141  
2142              $parser_options = array(
2143                  "allow_html" => $forum['allowhtml'],
2144                  "allow_mycode" => $forum['allowmycode'],
2145                  "allow_smilies" => $forum['allowsmilies'],
2146                  "allow_imgcode" => $forum['allowimgcode'],
2147                  "allow_videocode" => $forum['allowvideocode'],
2148                  "filter_badwords" => 1
2149              );
2150              if($post['smilieoff'] == 1)
2151              {
2152                  $parser_options['allow_smilies'] = 0;
2153              }
2154  
2155              $message = $parser->parse_message($post['message'], $parser_options);
2156              eval("\$postlist .= \"".$templates->get("moderation_mergeposts_post")."\";");
2157              $altbg = alt_trow();
2158          }
2159  
2160          $inlineids = implode("|", $posts);
2161          if($mybb->get_input('inlinetype') == 'search')
2162          {
2163              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
2164          }
2165          else
2166          {
2167              clearinline($tid, 'thread');
2168          }
2169  
2170          $return_url = htmlspecialchars_uni($mybb->get_input('url'));
2171  
2172          eval("\$multimerge = \"".$templates->get("moderation_inline_mergeposts")."\";");
2173          output_page($multimerge);
2174          break;
2175  
2176      // Actually merge the posts - Inline moderation
2177      case "do_multimergeposts":
2178  
2179          // Verify incoming POST request
2180          verify_post_check($mybb->get_input('my_post_key'));
2181  
2182          $mergepost = $mybb->get_input('mergepost', MyBB::INPUT_ARRAY);
2183          if(count($mergepost) <= 1)
2184          {
2185              error($lang->error_nomergeposts);
2186          }
2187  
2188          foreach($mergepost as $pid => $yes)
2189          {
2190              $postlist[] = (int)$pid;
2191          }
2192  
2193          if(!is_moderator_by_pids($postlist, "canmanagethreads"))
2194          {
2195              error_no_permission();
2196          }
2197  
2198          $masterpid = $moderation->merge_posts($postlist, $tid, $mybb->input['sep']);
2199  
2200          mark_reports($postlist, "posts");
2201          log_moderator_action($modlogdata, $lang->merged_selective_posts);
2202          moderation_redirect(get_post_link($masterpid)."#pid$masterpid", $lang->redirect_inline_postsmerged);
2203          break;
2204  
2205      // Split posts - Inline moderation
2206      case "multisplitposts":
2207          add_breadcrumb($lang->nav_multi_splitposts);
2208  
2209          if($mybb->get_input('inlinetype') == 'search')
2210          {
2211              $posts = getids($mybb->get_input('searchid'), 'search');
2212          }
2213          else
2214          {
2215              $posts = getids($tid, 'thread');
2216          }
2217  
2218          if(count($posts) < 1)
2219          {
2220              error($lang->error_inline_nopostsselected);
2221          }
2222  
2223          if(!is_moderator_by_pids($posts, "canmanagethreads"))
2224          {
2225              error_no_permission();
2226          }
2227          $posts = array_map('intval', $posts);
2228          $pidin = implode(',', $posts);
2229  
2230          // Make sure that we are not splitting a thread with one post
2231          // Select number of posts in each thread that the splitted post is in
2232          $query = $db->query("
2233              SELECT DISTINCT p.tid, COUNT(q.pid) as count
2234              FROM ".TABLE_PREFIX."posts p
2235              LEFT JOIN ".TABLE_PREFIX."posts q ON (p.tid=q.tid)
2236              WHERE p.pid IN ($pidin)
2237              GROUP BY p.tid, p.pid
2238          ");
2239          $threads = $pcheck = array();
2240          while($tcheck = $db->fetch_array($query))
2241          {
2242              if((int)$tcheck['count'] <= 1)
2243              {
2244                  error($lang->error_cantsplitonepost);
2245              }
2246              $threads[] = $pcheck[] = $tcheck['tid']; // Save tids for below
2247          }
2248  
2249          // Make sure that we are not splitting all posts in the thread
2250          // The query does not return a row when the count is 0, so find if some threads are missing (i.e. 0 posts after removal)
2251          $query = $db->query("
2252              SELECT DISTINCT p.tid, COUNT(q.pid) as count
2253              FROM ".TABLE_PREFIX."posts p
2254              LEFT JOIN ".TABLE_PREFIX."posts q ON (p.tid=q.tid)
2255              WHERE p.pid IN ($pidin) AND q.pid NOT IN ($pidin)
2256              GROUP BY p.tid, p.pid
2257          ");
2258          $pcheck2 = array();
2259          while($tcheck = $db->fetch_array($query))
2260          {
2261              if($tcheck['count'] > 0)
2262              {
2263                  $pcheck2[] = $tcheck['tid'];
2264              }
2265          }
2266          if(count($pcheck2) != count($pcheck))
2267          {
2268              // One or more threads do not have posts after splitting
2269              error($lang->error_cantsplitall);
2270          }
2271  
2272          $inlineids = implode("|", $posts);
2273          if($mybb->get_input('inlinetype') == 'search')
2274          {
2275              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
2276          }
2277          else
2278          {
2279              clearinline($tid, 'thread');
2280          }
2281          $forumselect = build_forum_jump("", $fid, 1, '', 0, true, '', "moveto");
2282  
2283          $return_url = htmlspecialchars_uni($mybb->get_input('url'));
2284  
2285          eval("\$splitposts = \"".$templates->get("moderation_inline_splitposts")."\";");
2286          output_page($splitposts);
2287          break;
2288  
2289      // Actually split the posts - Inline moderation
2290      case "do_multisplitposts":
2291  
2292          // Verify incoming POST request
2293          verify_post_check($mybb->get_input('my_post_key'));
2294  
2295          $plist = array();
2296          $postlist = explode("|", $mybb->get_input('posts'));
2297          foreach($postlist as $pid)
2298          {
2299              $pid = (int)$pid;
2300              $plist[] = $pid;
2301          }
2302  
2303          if(!is_moderator_by_pids($plist, "canmanagethreads"))
2304          {
2305              error_no_permission();
2306          }
2307  
2308          // Ensure all posts exist
2309          $posts = array();
2310          if(!empty($plist))
2311          {
2312              $query = $db->simple_select('posts', 'pid', 'pid IN ('.implode(',', $plist).')');
2313              while($pid = $db->fetch_field($query, 'pid'))
2314              {
2315                  $posts[] = $pid;
2316              }
2317          }
2318  
2319          if(empty($posts))
2320          {
2321              error($lang->error_inline_nopostsselected);
2322          }
2323  
2324          $pidin = implode(',', $posts);
2325  
2326          // Make sure that we are not splitting a thread with one post
2327          // Select number of posts in each thread that the splitted post is in
2328          $query = $db->query("
2329              SELECT DISTINCT p.tid, COUNT(q.pid) as count
2330              FROM ".TABLE_PREFIX."posts p
2331              LEFT JOIN ".TABLE_PREFIX."posts q ON (p.tid=q.tid)
2332              WHERE p.pid IN ($pidin)
2333              GROUP BY p.tid, p.pid
2334          ");
2335          $pcheck = array();
2336          while($tcheck = $db->fetch_array($query))
2337          {
2338              if((int)$tcheck['count'] <= 1)
2339              {
2340                  error($lang->error_cantsplitonepost);
2341              }
2342              $pcheck[] = $tcheck['tid']; // Save tids for below
2343          }
2344  
2345          // Make sure that we are not splitting all posts in the thread
2346          // The query does not return a row when the count is 0, so find if some threads are missing (i.e. 0 posts after removal)
2347          $query = $db->query("
2348              SELECT DISTINCT p.tid, COUNT(q.pid) as count
2349              FROM ".TABLE_PREFIX."posts p
2350              LEFT JOIN ".TABLE_PREFIX."posts q ON (p.tid=q.tid)
2351              WHERE p.pid IN ($pidin) AND q.pid NOT IN ($pidin)
2352              GROUP BY p.tid, p.pid
2353          ");
2354          $pcheck2 = array();
2355          while($tcheck = $db->fetch_array($query))
2356          {
2357              if($tcheck['count'] > 0)
2358              {
2359                  $pcheck2[] = $tcheck['tid'];
2360              }
2361          }
2362          if(count($pcheck2) != count($pcheck))
2363          {
2364              // One or more threads do not have posts after splitting
2365              error($lang->error_cantsplitall);
2366          }
2367  
2368          if(isset($mybb->input['moveto']))
2369          {
2370              $moveto = $mybb->get_input('moveto', MyBB::INPUT_INT);
2371          }
2372          else
2373          {
2374              $moveto = $fid;
2375          }
2376  
2377          $newforum = get_forum($moveto);
2378          if(!$newforum || $newforum['type'] != "f" || $newforum['type'] == "f" && $newforum['linkto'] != '')
2379          {
2380              error($lang->error_invalidforum);
2381          }
2382  
2383          $newsubject = $mybb->get_input('newsubject');
2384          $newtid = $moderation->split_posts($posts, $tid, $moveto, $newsubject);
2385  
2386          $pid_list = implode(', ', $posts);
2387          $lang->split_selective_posts = $lang->sprintf($lang->split_selective_posts, $pid_list, $newtid);
2388          log_moderator_action($modlogdata, $lang->split_selective_posts);
2389  
2390          moderation_redirect(get_thread_link($newtid), $lang->redirect_threadsplit);
2391          break;
2392  
2393      // Move posts - Inline moderation
2394      case "multimoveposts":
2395          add_breadcrumb($lang->nav_multi_moveposts);
2396  
2397          if($mybb->get_input('inlinetype') == 'search')
2398          {
2399              $posts = getids($mybb->get_input('searchid'), 'search');
2400          }
2401          else
2402          {
2403              $posts = getids($tid, 'thread');
2404          }
2405  
2406          if(count($posts) < 1)
2407          {
2408              error($lang->error_inline_nopostsselected);
2409          }
2410  
2411          if(!is_moderator_by_pids($posts, "canmanagethreads"))
2412          {
2413              error_no_permission();
2414          }
2415          $posts = array_map('intval', $posts);
2416          $pidin = implode(',', $posts);
2417  
2418          // Make sure that we are not moving posts in a thread with one post
2419          // Select number of posts in each thread that the moved post is in
2420          $query = $db->query("
2421              SELECT DISTINCT p.tid, COUNT(q.pid) as count
2422              FROM ".TABLE_PREFIX."posts p
2423              LEFT JOIN ".TABLE_PREFIX."posts q ON (p.tid=q.tid)
2424              WHERE p.pid IN ($pidin)
2425              GROUP BY p.tid, p.pid
2426          ");
2427          $threads = $pcheck = array();
2428          while($tcheck = $db->fetch_array($query))
2429          {
2430              if((int)$tcheck['count'] <= 1)
2431              {
2432                  error($lang->error_cantsplitonepost);
2433              }
2434              $threads[] = $pcheck[] = $tcheck['tid']; // Save tids for below
2435          }
2436  
2437          // Make sure that we are not moving all posts in the thread
2438          // The query does not return a row when the count is 0, so find if some threads are missing (i.e. 0 posts after removal)
2439          $query = $db->query("
2440              SELECT DISTINCT p.tid, COUNT(q.pid) as count
2441              FROM ".TABLE_PREFIX."posts p
2442              LEFT JOIN ".TABLE_PREFIX."posts q ON (p.tid=q.tid)
2443              WHERE p.pid IN ($pidin) AND q.pid NOT IN ($pidin)
2444              GROUP BY p.tid, p.pid
2445          ");
2446          $pcheck2 = array();
2447          while($tcheck = $db->fetch_array($query))
2448          {
2449              if($tcheck['count'] > 0)
2450              {
2451                  $pcheck2[] = $tcheck['tid'];
2452              }
2453          }
2454          if(count($pcheck2) != count($pcheck))
2455          {
2456              // One or more threads do not have posts after splitting
2457              error($lang->error_cantmoveall);
2458          }
2459  
2460          $inlineids = implode("|", $posts);
2461          if($mybb->get_input('inlinetype') == 'search')
2462          {
2463              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
2464          }
2465          else
2466          {
2467              clearinline($tid, 'thread');
2468          }
2469          $forumselect = build_forum_jump("", $fid, 1, '', 0, true, '', "moveto");
2470          eval("\$moveposts = \"".$templates->get("moderation_inline_moveposts")."\";");
2471          output_page($moveposts);
2472          break;
2473  
2474      // Actually split the posts - Inline moderation
2475      case "do_multimoveposts":
2476  
2477          // Verify incoming POST request
2478          verify_post_check($mybb->get_input('my_post_key'));
2479  
2480          $plugins->run_hooks("moderation_do_multimoveposts");
2481  
2482          // explode at # sign in a url (indicates a name reference) and reassign to the url
2483          $realurl = explode("#", $mybb->get_input('threadurl'));
2484          $mybb->input['threadurl'] = $realurl[0];
2485  
2486          // Are we using an SEO URL?
2487          if(substr($mybb->input['threadurl'], -4) == "html")
2488          {
2489              // Get thread to merge's tid the SEO way
2490              preg_match("#thread-([0-9]+)?#i", $mybb->input['threadurl'], $threadmatch);
2491              preg_match("#post-([0-9]+)?#i", $mybb->input['threadurl'], $postmatch);
2492  
2493              if($threadmatch[1])
2494              {
2495                  $parameters['tid'] = $threadmatch[1];
2496              }
2497  
2498              if($postmatch[1])
2499              {
2500                  $parameters['pid'] = $postmatch[1];
2501              }
2502          }
2503          else
2504          {
2505              // Get thread to merge's tid the normal way
2506              $splitloc = explode(".php", $mybb->input['threadurl']);
2507              $temp = explode("&", my_substr($splitloc[1], 1));
2508  
2509              if(!empty($temp))
2510              {
2511                  for($i = 0; $i < count($temp); $i++)
2512                  {
2513                      $temp2 = explode("=", $temp[$i], 2);
2514                      $parameters[$temp2[0]] = $temp2[1];
2515                  }
2516              }
2517              else
2518              {
2519                  $temp2 = explode("=", $splitloc[1], 2);
2520                  $parameters[$temp2[0]] = $temp2[1];
2521              }
2522          }
2523  
2524          if(!empty($parameters['pid']) && empty($parameters['tid']))
2525          {
2526              $query = $db->simple_select("posts", "tid", "pid='".(int)$parameters['pid']."'");
2527              $post = $db->fetch_array($query);
2528              $newtid = $post['tid'];
2529          }
2530          elseif(!empty($parameters['tid']))
2531          {
2532              $newtid = $parameters['tid'];
2533          }
2534          else
2535          {
2536              $newtid = 0;
2537          }
2538          $newtid = (int)$newtid;
2539          $newthread = get_thread($newtid);
2540          if(!$newthread)
2541          {
2542              error($lang->error_badmovepostsurl);
2543          }
2544          if($newtid == $tid)
2545          { // sanity check
2546              error($lang->error_movetoself);
2547          }
2548  
2549          $postlist = explode("|", $mybb->get_input('posts'));
2550          $plist = array();
2551          foreach($postlist as $pid)
2552          {
2553              $pid = (int)$pid;
2554              $plist[] = $pid;
2555          }
2556  
2557          if(!is_moderator_by_pids($plist, "canmanagethreads"))
2558          {
2559              error_no_permission();
2560          }
2561  
2562          // Ensure all posts exist
2563          $posts = array();
2564          if(!empty($plist))
2565          {
2566              $query = $db->simple_select('posts', 'pid', 'pid IN ('.implode(',', $plist).')');
2567              while($pid = $db->fetch_field($query, 'pid'))
2568              {
2569                  $posts[] = $pid;
2570              }
2571          }
2572  
2573          if(empty($posts))
2574          {
2575              error($lang->error_inline_nopostsselected);
2576          }
2577  
2578          $pidin = implode(',', $posts);
2579  
2580          // Make sure that we are not moving posts in a thread with one post
2581          // Select number of posts in each thread that the moved post is in
2582          $query = $db->query("
2583              SELECT DISTINCT p.tid, COUNT(q.pid) as count
2584              FROM ".TABLE_PREFIX."posts p
2585              LEFT JOIN ".TABLE_PREFIX."posts q ON (p.tid=q.tid)
2586              WHERE p.pid IN ($pidin)
2587              GROUP BY p.tid, p.pid
2588          ");
2589          $threads = $pcheck = array();
2590          while($tcheck = $db->fetch_array($query))
2591          {
2592              if((int)$tcheck['count'] <= 1)
2593              {
2594                  error($lang->error_cantsplitonepost);
2595              }
2596              $threads[] = $pcheck[] = $tcheck['tid']; // Save tids for below
2597          }
2598  
2599          // Make sure that we are not moving all posts in the thread
2600          // The query does not return a row when the count is 0, so find if some threads are missing (i.e. 0 posts after removal)
2601          $query = $db->query("
2602              SELECT DISTINCT p.tid, COUNT(q.pid) as count
2603              FROM ".TABLE_PREFIX."posts p
2604              LEFT JOIN ".TABLE_PREFIX."posts q ON (p.tid=q.tid)
2605              WHERE p.pid IN ($pidin) AND q.pid NOT IN ($pidin)
2606              GROUP BY p.tid, p.pid
2607          ");
2608          $pcheck2 = array();
2609          while($tcheck = $db->fetch_array($query))
2610          {
2611              if($tcheck['count'] > 0)
2612              {
2613                  $pcheck2[] = $tcheck['tid'];
2614              }
2615          }
2616          if(count($pcheck2) != count($pcheck))
2617          {
2618              // One or more threads do not have posts after splitting
2619              error($lang->error_cantmoveall);
2620          }
2621  
2622          $newtid = $moderation->split_posts($posts, $tid, $newthread['fid'], $db->escape_string($newthread['subject']), $newtid);
2623  
2624          $pid_list = implode(', ', $posts);
2625          $lang->move_selective_posts = $lang->sprintf($lang->move_selective_posts, $pid_list, $newtid);
2626          log_moderator_action($modlogdata, $lang->move_selective_posts);
2627  
2628          moderation_redirect(get_thread_link($newtid), $lang->redirect_moveposts);
2629          break;
2630  
2631      // Approve posts - Inline moderation
2632      case "multiapproveposts":
2633  
2634          // Verify incoming POST request
2635          verify_post_check($mybb->get_input('my_post_key'));
2636  
2637          if($mybb->get_input('inlinetype') == 'search')
2638          {
2639              $posts = getids($mybb->get_input('searchid'), 'search');
2640          }
2641          else
2642          {
2643              $posts = getids($tid, 'thread');
2644          }
2645          if(count($posts) < 1)
2646          {
2647              error($lang->error_inline_nopostsselected);
2648          }
2649  
2650          if(!is_moderator_by_pids($posts, "canapproveunapproveposts"))
2651          {
2652              error_no_permission();
2653          }
2654  
2655          $pids = array();
2656          foreach($posts as $pid)
2657          {
2658              $pids[] = (int)$pid;
2659          }
2660  
2661          $moderation->approve_posts($pids);
2662  
2663          log_moderator_action($modlogdata, $lang->multi_approve_posts);
2664          if($mybb->get_input('inlinetype') == 'search')
2665          {
2666              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
2667          }
2668          else
2669          {
2670              clearinline($tid, 'thread');
2671          }
2672          moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_inline_postsapproved);
2673          break;
2674  
2675      // Unapprove posts - Inline moderation
2676      case "multiunapproveposts":
2677  
2678          // Verify incoming POST request
2679          verify_post_check($mybb->get_input('my_post_key'));
2680  
2681          if($mybb->get_input('inlinetype') == 'search')
2682          {
2683              $posts = getids($mybb->get_input('searchid'), 'search');
2684          }
2685          else
2686          {
2687              $posts = getids($tid, 'thread');
2688          }
2689  
2690          if(count($posts) < 1)
2691          {
2692              error($lang->error_inline_nopostsselected);
2693          }
2694          $pids = array();
2695  
2696          if(!is_moderator_by_pids($posts, "canapproveunapproveposts"))
2697          {
2698              error_no_permission();
2699          }
2700          foreach($posts as $pid)
2701          {
2702              $pids[] = (int)$pid;
2703          }
2704  
2705          $moderation->unapprove_posts($pids);
2706  
2707          log_moderator_action($modlogdata, $lang->multi_unapprove_posts);
2708          if($mybb->get_input('inlinetype') == 'search')
2709          {
2710              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
2711          }
2712          else
2713          {
2714              clearinline($tid, 'thread');
2715          }
2716          moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_inline_postsunapproved);
2717          break;
2718  
2719      // Restore posts - Inline moderation
2720      case "multirestoreposts":
2721  
2722          // Verify incoming POST request
2723          verify_post_check($mybb->get_input('my_post_key'));
2724  
2725          if($mybb->get_input('inlinetype') == 'search')
2726          {
2727              $posts = getids($mybb->get_input('searchid'), 'search');
2728          }
2729          else
2730          {
2731              $posts = getids($tid, 'thread');
2732          }
2733          if(count($posts) < 1)
2734          {
2735              error($lang->error_inline_nopostsselected);
2736          }
2737  
2738          if(!is_moderator_by_pids($posts, "canrestoreposts"))
2739          {
2740              error_no_permission();
2741          }
2742  
2743          $pids = array();
2744          foreach($posts as $pid)
2745          {
2746              $pids[] = (int)$pid;
2747          }
2748  
2749          $moderation->restore_posts($pids);
2750  
2751          log_moderator_action($modlogdata, $lang->multi_restore_posts);
2752          if($mybb->get_input('inlinetype') == 'search')
2753          {
2754              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
2755          }
2756          else
2757          {
2758              clearinline($tid, 'thread');
2759          }
2760          moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_inline_postsrestored);
2761          break;
2762  
2763      // Soft delete posts - Inline moderation
2764      case "multisoftdeleteposts":
2765          // Verify incoming POST request
2766          verify_post_check($mybb->get_input('my_post_key'));
2767  
2768          if($mybb->get_input('inlinetype') == 'search')
2769          {
2770              $posts = getids($mybb->get_input('searchid'), 'search');
2771          }
2772          else
2773          {
2774              $posts = getids($tid, 'thread');
2775          }
2776  
2777          if(count($posts) < 1)
2778          {
2779              error($lang->error_inline_nopostsselected);
2780          }
2781          $pids = array();
2782  
2783          if(!is_moderator_by_pids($posts, "cansoftdeleteposts"))
2784          {
2785              error_no_permission();
2786          }
2787          foreach($posts as $pid)
2788          {
2789              $pids[] = (int)$pid;
2790          }
2791  
2792          $moderation->soft_delete_posts($pids);
2793          log_moderator_action($modlogdata, $lang->multi_soft_delete_posts);
2794  
2795          if($mybb->get_input('inlinetype') == 'search')
2796          {
2797              clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
2798          }
2799          else
2800          {
2801              clearinline($tid, 'thread');
2802          }
2803          moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_inline_postssoftdeleted);
2804          break;
2805      case "do_purgespammer":
2806      case "purgespammer":
2807          require_once  MYBB_ROOT."inc/functions_user.php";
2808  
2809          $groups = explode(",", $mybb->settings['purgespammergroups']);
2810          if(!in_array($mybb->user['usergroup'], $groups))
2811          {
2812              error_no_permission();
2813          }
2814  
2815          $uid = $mybb->input['uid'];
2816          $user = get_user($uid);
2817          if(!$user['uid'] || !purgespammer_show($user['postnum'], $user['usergroup'], $user['uid']))
2818          {
2819              error($lang->purgespammer_invalid_user);
2820          }
2821  
2822          if($mybb->input['action'] == "do_purgespammer")
2823          {
2824              verify_post_check($mybb->get_input('my_post_key'));
2825  
2826              $user_deleted = false;
2827  
2828              // Run the hooks first to avoid any issues when we delete the user
2829              $plugins->run_hooks("moderation_purgespammer_purge");
2830  
2831              require_once  MYBB_ROOT.'inc/datahandlers/user.php';
2832              $userhandler = new UserDataHandler('delete');
2833  
2834              if($mybb->settings['purgespammerbandelete'] == "ban")
2835              {
2836                  // First delete everything
2837                  $userhandler->delete_content($uid);
2838                  $userhandler->delete_posts($uid);
2839                  
2840                  // Next ban him (or update the banned reason, shouldn't happen)
2841                  $query = $db->simple_select("banned", "uid", "uid = '{$uid}'");
2842                  if($db->num_rows($query) > 0)
2843                  {
2844                      $banupdate = array(
2845                          "reason" => $db->escape_string($mybb->settings['purgespammerbanreason'])
2846                      );
2847                      $db->update_query('banned', $banupdate, "uid = '{$uid}'");
2848                  }
2849                  else
2850                  {
2851                      $insert = array(
2852                          "uid" => $uid,
2853                          "gid" => (int)$mybb->settings['purgespammerbangroup'],
2854                          "oldgroup" => 2,
2855                          "oldadditionalgroups" => "",
2856                          "olddisplaygroup" => 0,
2857                          "admin" => (int)$mybb->user['uid'],
2858                          "dateline" => TIME_NOW,
2859                          "bantime" => "---",
2860                          "lifted" => 0,
2861                          "reason" => $db->escape_string($mybb->settings['purgespammerbanreason'])
2862                      );
2863                      $db->insert_query('banned', $insert);
2864                  }
2865  
2866                  // Add the IP's to the banfilters
2867                  foreach(array($user['regip'], $user['lastip']) as $ip)
2868                  {
2869                      $ip = my_inet_ntop($db->unescape_binary($ip));
2870                      $query = $db->simple_select("banfilters", "type", "type = 1 AND filter = '".$db->escape_string($ip)."'");
2871                      if($db->num_rows($query) == 0)
2872                      {
2873                          $insert = array(
2874                              "filter" => $db->escape_string($ip),
2875                              "type" => 1,
2876                              "dateline" => TIME_NOW
2877                          );
2878                          $db->insert_query("banfilters", $insert);
2879                      }
2880                  }
2881  
2882                  // Clear the profile
2883                  $userhandler->clear_profile($uid, $mybb->settings['purgespammerbangroup']);
2884  
2885                  $cache->update_banned();
2886                  $cache->update_bannedips();
2887                  $cache->update_awaitingactivation();
2888  
2889                  // Update reports cache
2890                  $cache->update_reportedcontent();
2891              }
2892              elseif($mybb->settings['purgespammerbandelete'] == "delete")
2893              {
2894                  $user_deleted = $userhandler->delete_user($uid, 1);
2895              }
2896  
2897              // Submit the user to stop forum spam
2898              if(!empty($mybb->settings['purgespammerapikey']))
2899              {
2900                  $sfs = @fetch_remote_file("http://stopforumspam.com/add.php?username=" . urlencode($user['username']) . "&ip_addr=" . urlencode(my_inet_ntop($db->unescape_binary($user['lastip']))) . "&email=" . urlencode($user['email']) . "&api_key=" . urlencode($mybb->settings['purgespammerapikey']));
2901              }
2902  
2903              log_moderator_action(array('uid' => $uid, 'username' => $user['username']), $lang->purgespammer_modlog);
2904  
2905              if($user_deleted)
2906              {
2907                  redirect($mybb->settings['bburl'], $lang->purgespammer_success);
2908              }
2909              else
2910              {
2911                  redirect(get_profile_link($uid), $lang->purgespammer_success);
2912              }
2913          }
2914          else if($mybb->input['action'] == "purgespammer")
2915          {
2916              $plugins->run_hooks("moderation_purgespammer_show");
2917  
2918              add_breadcrumb($lang->purgespammer);
2919              $lang->purgespammer_purge = $lang->sprintf($lang->purgespammer_purge, htmlspecialchars_uni($user['username']));
2920              if($mybb->settings['purgespammerbandelete'] == "ban")
2921              {
2922                  $lang->purgespammer_purge_desc = $lang->sprintf($lang->purgespammer_purge_desc, $lang->purgespammer_ban);
2923              }
2924              else
2925              {
2926                  $lang->purgespammer_purge_desc = $lang->sprintf($lang->purgespammer_purge_desc, $lang->purgespammer_delete);                
2927              }
2928              eval("\$purgespammer = \"".$templates->get('moderation_purgespammer')."\";");
2929              output_page($purgespammer);
2930          }
2931          break;
2932      default:
2933          require_once  MYBB_ROOT."inc/class_custommoderation.php";
2934          $custommod = new CustomModeration;
2935          $tool = $custommod->tool_info($mybb->get_input('action', MyBB::INPUT_INT));
2936          if($tool !== false)
2937          {
2938              // Verify incoming POST request
2939              verify_post_check($mybb->get_input('my_post_key'));
2940  
2941              $options = my_unserialize($tool['threadoptions']);
2942  
2943              if(!is_member($tool['groups']))
2944              {
2945                  error_no_permission();
2946              }
2947  
2948              if(!empty($options['confirmation']) && empty($mybb->input['confirm']))
2949              {
2950                  add_breadcrumb($lang->confirm_execute_tool);
2951  
2952                  $lang->confirm_execute_tool_desc = $lang->sprintf($lang->confirm_execute_tool_desc, htmlspecialchars_uni($tool['name']));
2953  
2954                  $modtype = $mybb->get_input('modtype');
2955                  $inlinetype = $mybb->get_input('inlinetype');
2956                  $searchid = $mybb->get_input('searchid');
2957                  $url = htmlspecialchars_uni($mybb->get_input('url'));
2958                  $plugins->run_hooks('moderation_confirmation');
2959  
2960                  eval('$page = "'.$templates->get('moderation_confirmation').'";');
2961  
2962                  output_page($page);
2963                  exit;
2964              }
2965  
2966              if($tool['type'] == 't' && $mybb->get_input('modtype') == 'inlinethread')
2967              {
2968                  if($mybb->get_input('inlinetype') == 'search')
2969                  {
2970                      $tids = getids($mybb->get_input('searchid'), 'search');
2971                  }
2972                  else
2973                  {
2974                      $tids = getids($fid, "forum");
2975                  }
2976                  if(count($tids) < 1)
2977                  {
2978                      error($lang->error_inline_nopostsselected);
2979                  }
2980                  if(!is_moderator_by_tids($tids, "canusecustomtools"))
2981                  {
2982                      error_no_permission();
2983                  }
2984  
2985                  $thread_options = my_unserialize($tool['threadoptions']);
2986                  if($thread_options['movethread'] && $forum_cache[$thread_options['movethread']]['type'] != "f")
2987                  {
2988                      error($lang->error_movetocategory);
2989                  }
2990  
2991                  $custommod->execute($mybb->get_input('action', MyBB::INPUT_INT), $tids);
2992                   $lang->custom_tool = $lang->sprintf($lang->custom_tool, $tool['name']);
2993                  log_moderator_action($modlogdata, $lang->custom_tool);
2994                  if($mybb->get_input('inlinetype') == 'search')
2995                  {
2996                      clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
2997                      $lang->redirect_customtool_search = $lang->sprintf($lang->redirect_customtool_search, $tool['name']);
2998                      $return_url = htmlspecialchars_uni($mybb->get_input('url'));
2999                      redirect($return_url, $lang->redirect_customtool_search);
3000                  }
3001                  else
3002                  {
3003                      clearinline($fid, "forum");
3004                      $lang->redirect_customtool_forum = $lang->sprintf($lang->redirect_customtool_forum, $tool['name']);
3005                      redirect(get_forum_link($fid), $lang->redirect_customtool_forum);
3006                  }
3007                  break;
3008              }
3009              elseif($tool['type'] == 't' && $mybb->get_input('modtype') == 'thread')
3010              {
3011                  if(!is_moderator_by_tids($tid, "canusecustomtools"))
3012                  {
3013                      error_no_permission();
3014                  }
3015  
3016                  $thread_options = my_unserialize($tool['threadoptions']);
3017                  if($thread_options['movethread'] && $forum_cache[$thread_options['movethread']]['type'] != "f")
3018                  {
3019                      error($lang->error_movetocategory);
3020                  }
3021  
3022                  $ret = $custommod->execute($mybb->get_input('action', MyBB::INPUT_INT), $tid);
3023                   $lang->custom_tool = $lang->sprintf($lang->custom_tool, $tool['name']);
3024                  log_moderator_action($modlogdata, $lang->custom_tool);
3025                  if($ret == 'forum')
3026                  {
3027                      $lang->redirect_customtool_forum = $lang->sprintf($lang->redirect_customtool_forum, $tool['name']);
3028                      moderation_redirect(get_forum_link($fid), $lang->redirect_customtool_forum);
3029                  }
3030                  else
3031                  {
3032                      $lang->redirect_customtool_thread = $lang->sprintf($lang->redirect_customtool_thread, $tool['name']);
3033                      moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_customtool_thread);
3034                  }
3035                  break;
3036              }
3037              elseif($tool['type'] == 'p' && $mybb->get_input('modtype') == 'inlinepost')
3038              {
3039                  if($mybb->get_input('inlinetype') == 'search')
3040                  {
3041                      $pids = getids($mybb->get_input('searchid'), 'search');
3042                  }
3043                  else
3044                  {
3045                      $pids = getids($tid, 'thread');
3046                  }
3047  
3048                  if(count($pids) < 1)
3049                  {
3050                      error($lang->error_inline_nopostsselected);
3051                  }
3052                  if(!is_moderator_by_pids($pids, "canusecustomtools"))
3053                  {
3054                      error_no_permission();
3055                  }
3056  
3057                  // Get threads which are associated with the posts
3058                  $tids = array();
3059                  $options = array(
3060                      'order_by' => 'dateline',
3061                      'order_dir' => 'asc'
3062                  );
3063                  $query = $db->simple_select("posts", "DISTINCT tid, dateline", "pid IN (".implode(',',$pids).")", $options);
3064                  while($row = $db->fetch_array($query))
3065                  {
3066                      $tids[] = $row['tid'];
3067                  }
3068  
3069                  $ret = $custommod->execute($mybb->get_input('action', MyBB::INPUT_INT), $tids, $pids);
3070                   $lang->custom_tool = $lang->sprintf($lang->custom_tool, $tool['name']);
3071                  log_moderator_action($modlogdata, $lang->custom_tool);
3072                  if($mybb->get_input('inlinetype') == 'search')
3073                  {
3074                      clearinline($mybb->get_input('searchid', MyBB::INPUT_INT), 'search');
3075                      $lang->redirect_customtool_search = $lang->sprintf($lang->redirect_customtool_search, $tool['name']);
3076                      $return_url = htmlspecialchars_uni($mybb->get_input('url'));
3077                      redirect($return_url, $lang->redirect_customtool_search);
3078                  }
3079                  else
3080                  {
3081                      clearinline($tid, 'thread');
3082                      if($ret == 'forum')
3083                      {
3084                          $lang->redirect_customtool_forum = $lang->sprintf($lang->redirect_customtool_forum, $tool['name']);
3085                          moderation_redirect(get_forum_link($fid), $lang->redirect_customtool_forum);
3086                      }
3087                      else
3088                      {
3089                          $lang->redirect_customtool_thread = $lang->sprintf($lang->redirect_customtool_thread, $tool['name']);
3090                          moderation_redirect(get_thread_link($tid), $lang->redirect_customtool_thread);
3091                      }
3092                  }
3093  
3094                  break;
3095              }
3096          }
3097          error_no_permission();
3098          break;
3099  }
3100  
3101  /**
3102   * Some little handy functions for our inline moderation
3103   *
3104   * @param int $id
3105   * @param string $type
3106   *
3107   * @return array
3108   */
3109  function getids($id, $type)
3110  {
3111      global $mybb;
3112  
3113      $newids = array();
3114      $cookie = "inlinemod_".$type.$id;
3115      if(isset($mybb->cookies[$cookie]))
3116      {
3117          $cookie_ids = explode("|", $mybb->cookies[$cookie]);
3118  
3119          foreach($cookie_ids as $cookie_id)
3120          {
3121              if(empty($cookie_id))
3122              {
3123                  continue;
3124              }
3125  
3126              if($cookie_id == 'ALL')
3127              {
3128                  $newids += getallids($id, $type);
3129              }
3130              else
3131              {
3132                  $newids[] = (int)$cookie_id;
3133              }
3134          }
3135      }
3136  
3137      return $newids;
3138  }
3139  
3140  /**
3141   * @param int $id
3142   * @param string $type
3143   *
3144   * @return array
3145   */
3146  function getallids($id, $type)
3147  {
3148      global $db, $mybb;
3149  
3150      $ids = array();
3151  
3152      // Get any removed threads (after our user hit 'all')
3153      $removed_ids = array();
3154      $cookie = "inlinemod_".$type.$id."_removed";
3155      if(isset($mybb->cookies[$cookie]))
3156      {
3157          $removed_ids = explode("|", $mybb->cookies[$cookie]);
3158  
3159          if(!is_array($removed_ids))
3160          {
3161              $removed_ids = array();
3162          }
3163      }
3164  
3165      // "Select all Threads in this forum" only supported by forumdisplay and search
3166      if($type == 'forum')
3167      {
3168          $query = $db->simple_select("threads", "tid", "fid='".(int)$id."'");
3169          while($tid = $db->fetch_field($query, "tid"))
3170          {
3171              if(in_array($tid, $removed_ids))
3172              {
3173                  continue;
3174              }
3175  
3176              $ids[] = $tid;
3177          }
3178      }
3179      else if($type == 'search')
3180      {
3181          $query = $db->simple_select("searchlog", "resulttype, posts, threads", "sid='".$db->escape_string($id)."' AND uid='{$mybb->user['uid']}'", 1);
3182          $searchlog = $db->fetch_array($query);
3183          if($searchlog['resulttype'] == 'posts')
3184          {
3185              $ids = explode(',', $searchlog['posts']);
3186          }
3187          else
3188          {
3189              $ids = explode(',', $searchlog['threads']);
3190          }
3191  
3192          if(is_array($ids))
3193          {
3194              foreach($ids as $key => $tid)
3195              {
3196                  if(in_array($tid, $removed_ids))
3197                  {
3198                      unset($ids[$key]);
3199                  }
3200              }
3201          }
3202      }
3203  
3204      return $ids;
3205  }
3206  
3207  /**
3208   * @param int $id
3209   * @param string $type
3210   */
3211  function clearinline($id, $type)
3212  {
3213      my_unsetcookie("inlinemod_".$type.$id);
3214      my_unsetcookie("inlinemod_{$type}{$id}_removed");
3215  }
3216  
3217  /**
3218   * @param int $id
3219   * @param string $type
3220   */
3221  function extendinline($id, $type)
3222  {
3223      my_setcookie("inlinemod_{$type}{$id}", '', TIME_NOW+3600);
3224      my_setcookie("inlinemod_{$type}{$id}_removed", '', TIME_NOW+3600);
3225  }
3226  
3227  /**
3228   * Checks if the current user is a moderator of all the posts specified
3229   *
3230   * Note: If no posts are specified, this function will return true.  It is the
3231   * responsibility of the calling script to error-check this case if necessary.
3232   *
3233   * @param array $posts Array of post IDs
3234   * @param string $permission Permission to check
3235   * @return bool True if moderator of all; false otherwise
3236   */
3237  function is_moderator_by_pids($posts, $permission='')
3238  {
3239      global $db, $mybb;
3240  
3241      // Speedy determination for supermods/admins and guests
3242      if($mybb->usergroup['issupermod'])
3243      {
3244          return true;
3245      }
3246      elseif(!$mybb->user['uid'])
3247      {
3248          return false;
3249      }
3250      // Make an array of threads if not an array
3251      if(!is_array($posts))
3252      {
3253          $posts = array($posts);
3254      }
3255      // Validate input
3256      $posts = array_map('intval', $posts);
3257      $posts[] = 0;
3258      // Get forums
3259      $posts_string = implode(',', $posts);
3260      $query = $db->simple_select("posts", "DISTINCT fid", "pid IN ($posts_string)");
3261      while($forum = $db->fetch_array($query))
3262      {
3263          if(!is_moderator($forum['fid'], $permission))
3264          {
3265              return false;
3266          }
3267      }
3268      return true;
3269  }
3270  
3271  /**
3272   * Checks if the current user is a moderator of all the threads specified
3273   *
3274   * Note: If no threads are specified, this function will return true.  It is the
3275   * responsibility of the calling script to error-check this case if necessary.
3276   *
3277   * @param array $threads Array of thread IDs
3278   * @param string $permission Permission to check
3279   * @return bool True if moderator of all; false otherwise
3280   */
3281  function is_moderator_by_tids($threads, $permission='')
3282  {
3283      global $db, $mybb;
3284  
3285      // Speedy determination for supermods/admins and guests
3286      if($mybb->usergroup['issupermod'])
3287      {
3288          return true;
3289      }
3290      elseif(!$mybb->user['uid'])
3291      {
3292          return false;
3293      }
3294      // Make an array of threads if not an array
3295      if(!is_array($threads))
3296      {
3297          $threads = array($threads);
3298      }
3299      // Validate input
3300      $threads = array_map('intval', $threads);
3301      $threads[] = 0;
3302      // Get forums
3303      $threads_string = implode(',', $threads);
3304      $query = $db->simple_select("threads", "DISTINCT fid", "tid IN ($threads_string)");
3305      while($forum = $db->fetch_array($query))
3306      {
3307          if(!is_moderator($forum['fid'], $permission))
3308          {
3309              return false;
3310          }
3311      }
3312      return true;
3313  }
3314  
3315  /**
3316   * Special redirect that takes a return URL into account
3317   * @param string $url URL
3318   * @param string $message Message
3319   * @param string $title Title
3320   */
3321  function moderation_redirect($url, $message="", $title="")
3322  {
3323      global $mybb;
3324      if(!empty($mybb->input['url']))
3325      {
3326          redirect(htmlentities($mybb->input['url']), $message, $title);
3327      }
3328      redirect($url, $message, $title);
3329  }


2005 - 2016 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref 0.7.1