[ Index ]

PHP Cross Reference of MyBB 1.8.12

title

Body

[close]

/ -> usercp2.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', 'usercp2.php');
  13  define("ALLOWABLE_PAGE", "removesubscription,removesubscriptions");
  14  
  15  $templatelist = "usercp_nav_messenger,usercp_nav_profile,usercp_nav,usercp_addsubscription_thread,usercp_nav_messenger_tracking,usercp_nav_messenger_folder";
  16  $templatelist .= ",usercp_nav_home,usercp_nav_editsignature,usercp_nav_attachments,usercp_nav_changename,usercp_nav_messenger_compose,usercp_nav_misc";
  17  
  18  require_once  "./global.php";
  19  require_once  MYBB_ROOT."inc/functions_user.php";
  20  
  21  if($mybb->user['uid'] == 0)
  22  {
  23      error_no_permission();
  24  }
  25  
  26  // Verify incoming POST request
  27  verify_post_check($mybb->get_input('my_post_key'));
  28  
  29  $lang->load("usercp");
  30  
  31  usercp_menu();
  32  
  33  $server_http_referer = htmlentities($_SERVER['HTTP_REFERER']);
  34  
  35  $plugins->run_hooks("usercp2_start");
  36  
  37  if($mybb->get_input('action') == "do_addsubscription" && $mybb->get_input('type') != "forum")
  38  {
  39      $thread = get_thread($mybb->get_input('tid'));
  40      if(!$thread)
  41      {
  42          error($lang->error_invalidthread);
  43      }
  44  
  45      // Is the currently logged in user a moderator of this forum?
  46      $ismod = is_moderator($thread['fid']);
  47  
  48      // Make sure we are looking at a real thread here.
  49      if(($thread['visible'] != 1 && $ismod == false) || ($thread['visible'] > 1 && $ismod == true))
  50      {
  51          error($lang->error_invalidthread);
  52      }
  53  
  54      $forumpermissions = forum_permissions($thread['fid']);
  55      if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0 || (isset($forumpermissions['canonlyviewownthreads']) && $forumpermissions['canonlyviewownthreads'] != 0 && $thread['uid'] != $mybb->user['uid']))
  56      {
  57          error_no_permission();
  58      }
  59  
  60      $plugins->run_hooks("usercp2_do_addsubscription");
  61  
  62      add_subscribed_thread($thread['tid'], $mybb->get_input('notification', MyBB::INPUT_INT));
  63  
  64      if($mybb->get_input('referrer'))
  65      {
  66          $url = htmlspecialchars_uni($mybb->get_input('referrer'));
  67      }
  68      else
  69      {
  70          $url = get_thread_link($thread['tid']);
  71      }
  72      redirect($url, $lang->redirect_subscriptionadded);
  73  }
  74  elseif($mybb->get_input('action') == "addsubscription")
  75  {
  76      if($mybb->get_input('type') == "forum")
  77      {
  78          $forum = get_forum($mybb->get_input('fid', MyBB::INPUT_INT));
  79          if(!$forum)
  80          {
  81              error($lang->error_invalidforum);
  82          }
  83          $forumpermissions = forum_permissions($forum['fid']);
  84          if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0)
  85          {
  86              error_no_permission();
  87          }
  88  
  89          $plugins->run_hooks("usercp2_addsubscription_forum");
  90  
  91          add_subscribed_forum($forum['fid']);
  92          if($server_http_referer)
  93          {
  94              $url = $server_http_referer;
  95          }
  96          else
  97          {
  98              $url = "index.php";
  99          }
 100          redirect($url, $lang->redirect_forumsubscriptionadded);
 101      }
 102      else
 103      {
 104          $thread  = get_thread($mybb->get_input('tid', MyBB::INPUT_INT));
 105          if(!$thread)
 106          {
 107              error($lang->error_invalidthread);
 108          }
 109  
 110          // Is the currently logged in user a moderator of this forum?
 111          $ismod = is_moderator($thread['fid']);
 112  
 113          // Make sure we are looking at a real thread here.
 114          if(($thread['visible'] != 1 && $ismod == false) || ($thread['visible'] > 1 && $ismod == true))
 115          {
 116              error($lang->error_invalidthread);
 117          }
 118  
 119          add_breadcrumb($lang->nav_subthreads, "usercp.php?action=subscriptions");
 120          add_breadcrumb($lang->nav_addsubscription);
 121  
 122          $forumpermissions = forum_permissions($thread['fid']);
 123          if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0 || (isset($forumpermissions['canonlyviewownthreads']) && $forumpermissions['canonlyviewownthreads'] != 0 && $thread['uid'] != $mybb->user['uid']))
 124          {
 125              error_no_permission();
 126          }
 127          $referrer = '';
 128          if($server_http_referer)
 129          {
 130              $referrer = $server_http_referer;
 131          }
 132  
 133          require_once  MYBB_ROOT."inc/class_parser.php";
 134          $parser = new postParser;
 135          $thread['subject'] = $parser->parse_badwords($thread['subject']);
 136          $thread['subject'] = htmlspecialchars_uni($thread['subject']);
 137          $lang->subscribe_to_thread = $lang->sprintf($lang->subscribe_to_thread, $thread['subject']);
 138  
 139          $notification_none_checked = $notification_email_checked = $notification_pm_checked = '';
 140          if($mybb->user['subscriptionmethod'] == 1 || $mybb->user['subscriptionmethod'] == 0)
 141          {
 142              $notification_none_checked = "checked=\"checked\"";
 143          }
 144          else if($mybb->user['subscriptionmethod'] == 2)
 145          {
 146              $notification_email_checked = "checked=\"checked\"";
 147          }
 148          else if($mybb->user['subscriptionmethod'] == 3)
 149          {
 150              $notification_pm_checked = "checked=\"checked\"";
 151          }
 152  
 153          $plugins->run_hooks("usercp2_addsubscription_thread");
 154  
 155          eval("\$add_subscription = \"".$templates->get("usercp_addsubscription_thread")."\";");
 156          output_page($add_subscription);
 157          exit;
 158      }
 159  }
 160  elseif($mybb->get_input('action') == "removesubscription")
 161  {
 162      if($mybb->get_input('type') == "forum")
 163      {
 164          $forum = get_forum($mybb->get_input('fid', MyBB::INPUT_INT));
 165          if(!$forum)
 166          {
 167              error($lang->error_invalidforum);
 168          }
 169  
 170          $plugins->run_hooks("usercp2_removesubscription_forum");
 171  
 172          remove_subscribed_forum($forum['fid']);
 173          if($server_http_referer)
 174          {
 175              $url = $server_http_referer;
 176          }
 177          else
 178          {
 179              $url = "usercp.php?action=forumsubscriptions";
 180          }
 181          redirect($url, $lang->redirect_forumsubscriptionremoved);
 182      }
 183      else
 184      {
 185          $thread = get_thread($mybb->get_input('tid', MyBB::INPUT_INT));
 186          if(!$thread)
 187          {
 188              error($lang->error_invalidthread);
 189          }
 190  
 191          // Is the currently logged in user a moderator of this forum?
 192          $ismod = is_moderator($thread['fid']);
 193  
 194          // Make sure we are looking at a real thread here.
 195          if(($thread['visible'] != 1 && $ismod == false) || ($thread['visible'] > 1 && $ismod == true))
 196          {
 197              error($lang->error_invalidthread);
 198          }
 199  
 200          $plugins->run_hooks("usercp2_removesubscription_thread");
 201  
 202          remove_subscribed_thread($thread['tid']);
 203          if($server_http_referer)
 204          {
 205              $url = $server_http_referer;
 206          }
 207          else
 208          {
 209              $url = "usercp.php?action=subscriptions";
 210          }
 211          redirect($url, $lang->redirect_subscriptionremoved);
 212      }
 213  }
 214  elseif($mybb->get_input('action') == "removesubscriptions")
 215  {
 216      if($mybb->get_input('type') == "forum")
 217      {
 218          $plugins->run_hooks("usercp2_removesubscriptions_forum");
 219  
 220          $db->delete_query("forumsubscriptions", "uid='".$mybb->user['uid']."'");
 221          if($server_http_referer)
 222          {
 223              $url = $server_http_referer;
 224          }
 225          else
 226          {
 227              $url = "usercp.php?action=forumsubscriptions";
 228          }
 229          redirect($url, $lang->redirect_forumsubscriptionsremoved);
 230      }
 231      else
 232      {
 233          $plugins->run_hooks("usercp2_removesubscriptions_thread");
 234  
 235          $db->delete_query("threadsubscriptions", "uid='".$mybb->user['uid']."'");
 236          if($server_http_referer)
 237          {
 238              $url = $server_http_referer;
 239          }
 240          else
 241          {
 242              $url = "usercp.php?action=subscriptions";
 243          }
 244          redirect($url, $lang->redirect_subscriptionsremoved);
 245      }
 246  }
 247  else
 248  {
 249      error($lang->error_invalidaction);
 250  }
 251  


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