[ Index ]

PHP Cross Reference of MyBB 1.4.13

title

Body

[close]

/ -> usercp2.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.4
   4   * Copyright © 2008 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://www.mybboard.net
   7   * License: http://www.mybboard.net/about/license
   8   *
   9   * $Id: usercp2.php 4854 2010-04-07 02:44:40Z RyanGordon $
  10   */
  11  
  12  define("IN_MYBB", 1);
  13  define('THIS_SCRIPT', 'usercp2.php');
  14  
  15  $templatelist = 'usercp_nav_messenger,usercp_nav_changename,usercp_nav_profile,usercp_nav_misc,usercp_nav';
  16  
  17  require_once  "./global.php";
  18  require_once  MYBB_ROOT."inc/functions_user.php";
  19  
  20  if($mybb->user['uid'] == 0)
  21  {
  22      error_no_permission();
  23  }
  24  
  25  // Verify incoming POST request
  26  verify_post_check($mybb->input['my_post_key']);
  27  
  28  $lang->load("usercp");
  29  
  30  usercp_menu();
  31  
  32  $server_http_referer = htmlentities($_SERVER['HTTP_REFERER']);
  33  
  34  if($mybb->input['action'] == "do_addsubscription")
  35  {
  36      if($mybb->input['type'] != "forum")
  37      {
  38          $thread = get_thread($mybb->input['tid']);
  39          if(!$thread['tid'])
  40          {
  41              error($lang->error_invalidthread);
  42          }
  43          $forumpermissions = forum_permissions($thread['fid']);
  44          if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0)
  45          {
  46              error_no_permission();
  47          }
  48          add_subscribed_thread($thread['tid'], $mybb->input['notification']);
  49          if($mybb->input['referrer'])
  50          {
  51              $url = htmlspecialchars_uni(addslashes($mybb->input['referrer']));
  52          }
  53          else
  54          {
  55              $url = get_thread_link($thread['tid']);
  56          }
  57          redirect($url, $lang->redirect_subscriptionadded);
  58      }
  59  }
  60  
  61  if($mybb->input['action'] == "addsubscription")
  62  {
  63      if($mybb->input['type'] == "forum")
  64      {
  65          $forum = get_forum($mybb->input['fid']);
  66          if(!$forum['fid'])
  67          {
  68              error($lang->error_invalidforum);
  69          }
  70          $forumpermissions = forum_permissions($forum['fid']);
  71          if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0)
  72          {
  73              error_no_permission();
  74          }
  75          add_subscribed_forum($forum['fid']);
  76          if($server_http_referer)
  77          {
  78              $url = $server_http_referer;
  79          }
  80          else
  81          {
  82              $url = "index.php";
  83          }
  84          redirect($url, $lang->redirect_forumsubscriptionadded);
  85      }
  86      else
  87      {
  88          $thread  = get_thread($mybb->input['tid']);
  89          if(!$thread['tid'])
  90          {
  91              error($lang->error_invalidthread);
  92          }
  93          add_breadcrumb($lang->nav_subthreads, "usercp.php?action=subscriptions");
  94          add_breadcrumb($lang->nav_addsubscription);
  95  
  96          $forumpermissions = forum_permissions($thread['fid']);
  97          if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0)
  98          {
  99              error_no_permission();
 100          }
 101          $referrer = '';
 102          if($server_http_referer)
 103          {
 104              $referrer = $server_http_referer;
 105          }
 106  
 107          require_once  MYBB_ROOT."inc/class_parser.php";
 108          $parser = new postParser;
 109          $thread['subject'] = $parser->parse_badwords($thread['subject']);
 110          $thread['subject'] = htmlspecialchars_uni($thread['subject']);
 111          $lang->subscribe_to_thread = $lang->sprintf($lang->subscribe_to_thread, $thread['subject']);
 112  
 113          if($mybb->user['subscriptionmethod'] == 1 || $mybb->user['subscriptionmethod'] == 0)
 114          {
 115              $notification_none_checked = "checked=\"checked\"";
 116          }
 117          else if($mybb->user['subscriptionmethod'] == 2)
 118          {
 119              $notification_instant_checked = "checked=\"checked\"";
 120          }
 121          eval("\$add_subscription = \"".$templates->get("usercp_addsubscription_thread")."\";");
 122          output_page($add_subscription);
 123      }
 124  }
 125  elseif($mybb->input['action'] == "removesubscription")
 126  {
 127      if($mybb->input['type'] == "forum")
 128      {
 129          $forum = get_forum($mybb->input['fid']);
 130          if(!$forum['fid'])
 131          {
 132              error($lang->error_invalidforum);
 133          }
 134          remove_subscribed_forum($forum['fid']);
 135          if($server_http_referer)
 136          {
 137              $url = $server_http_referer;
 138          }
 139          else
 140          {
 141              $url = "usercp.php?action=forumsubscriptions";
 142          }
 143          redirect($url, $lang->redirect_forumsubscriptionremoved);
 144      }
 145      else
 146      {
 147          $thread = get_thread($mybb->input['tid']);
 148          if(!$thread['tid'])
 149          {
 150              error($lang->error_invalidthread);
 151          }
 152          remove_subscribed_thread($thread['tid']);
 153          if($server_http_referer)
 154          {
 155              $url = $server_http_referer;
 156          }
 157          else
 158          {
 159              $url = "usercp.php?action=subscriptions";
 160          }
 161          redirect($url, $lang->redirect_subscriptionremoved);
 162      }
 163  }
 164  elseif($mybb->input['action'] == "removesubscriptions")
 165  {    
 166      if($mybb->input['type'] == "forum")
 167      {
 168          $db->delete_query("forumsubscriptions", "uid='".$mybb->user['uid']."'");
 169          if($server_http_referer)
 170          {
 171              $url = $server_http_referer;
 172          }
 173          else
 174          {
 175              $url = "usercp.php?action=forumsubscriptions";
 176          }
 177          redirect($url, $lang->redirect_forumsubscriptionsremoved);
 178      }
 179      else
 180      {
 181          $db->delete_query("threadsubscriptions", "uid='".$mybb->user['uid']."'");
 182          if($server_http_referer)
 183          {
 184              $url = $server_http_referer;
 185          }
 186          else
 187          {
 188              $url = "usercp.php?action=subscriptions";
 189          }
 190          redirect($url, $lang->redirect_subscriptionsremoved);
 191      }
 192  }
 193  else
 194  {
 195      error($lang->error_invalidaction);
 196  }
 197  ?>


Generated: Mon Apr 19 19:52:21 2010 Cross-referenced by PHPXref 0.7