[ Index ]

PHP Cross Reference of MyBB 1.6.5

title

Body

[close]

/ -> global.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.6
   4   * Copyright 2010 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://mybb.com
   7   * License: http://mybb.com/about/license
   8   *
   9   * $Id: global.php 5640 2011-10-26 09:22:59Z Tomm $
  10   */
  11  
  12  $working_dir = dirname(__FILE__);
  13  if(!$working_dir)
  14  {
  15      $working_dir = '.';
  16  }
  17  
  18  // Load main MyBB core file which begins all of the magic
  19  require_once $working_dir."/inc/init.php";
  20  
  21  $shutdown_queries = array();
  22  
  23  // Read the usergroups cache as well as the moderators cache
  24  $groupscache = $cache->read("usergroups");
  25  
  26  // If the groups cache doesn't exist, update it and re-read it
  27  if(!is_array($groupscache))
  28  {
  29      $cache->update_usergroups();
  30      $groupscache = $cache->read("usergroups");
  31  }
  32  
  33  if(!defined('THIS_SCRIPT'))
  34  {
  35      define('THIS_SCRIPT', '');
  36  }
  37  
  38  $current_page = my_strtolower(basename(THIS_SCRIPT));
  39  
  40  // Send page headers - don't send no-cache headers for attachment.php
  41  if($current_page != "attachment.php")
  42  {
  43      send_page_headers();
  44  }
  45  
  46  // Do not use session system for defined pages
  47  if((@isset($mybb->input['action']) && @isset($nosession[$mybb->input['action']])) || (@isset($mybb->input['thumbnail']) && $current_page == 'attachment.php'))
  48  {
  49      define("NO_ONLINE", 1);
  50  }
  51  
  52  // Create session for this user
  53  require_once  MYBB_ROOT."inc/class_session.php";
  54  $session = new session;
  55  $session->init();
  56  $mybb->session = &$session;
  57  
  58  $mybb->user['ismoderator'] = is_moderator("", "", $mybb->user['uid']);
  59  
  60  // Set our POST validation code here
  61  $mybb->post_code = generate_post_check();
  62  
  63  // Set and load the language
  64  if($mybb->input['language'] && $lang->language_exists($mybb->input['language']) && verify_post_check($mybb->input['my_post_key'], true))
  65  {
  66      $mybb->settings['bblanguage'] = $mybb->input['language'];
  67      // If user is logged in, update their language selection with the new one
  68      if($mybb->user['uid'])
  69      {
  70          if($mybb->cookies['mybblang'])
  71          {
  72              my_unsetcookie("mybblang");
  73          }
  74  
  75          $db->update_query("users", array("language" => $db->escape_string($mybb->settings['bblanguage'])), "uid='{$mybb->user['uid']}'");
  76      }
  77      // Guest = cookie
  78      else
  79      {
  80          my_setcookie("mybblang", $mybb->settings['bblanguage']);
  81      }
  82      $mybb->user['language'] = $mybb->settings['bblanguage'];
  83  }
  84  // Cookied language!
  85  else if(!$mybb->user['uid'] && $mybb->cookies['mybblang'] && $lang->language_exists($mybb->cookies['mybblang']))
  86  {
  87      $mybb->settings['bblanguage'] = $mybb->cookies['mybblang'];
  88  }
  89  else if(!isset($mybb->settings['bblanguage']))
  90  {
  91      $mybb->settings['bblanguage'] = "english";
  92  }
  93  
  94  // Load language
  95  $lang->set_language($mybb->settings['bblanguage']);
  96  $lang->load("global");
  97  $lang->load("messages");
  98  
  99  // Run global_start plugin hook now that the basics are set up
 100  $plugins->run_hooks("global_start");
 101  
 102  if(function_exists('mb_internal_encoding') && !empty($lang->settings['charset']))
 103  {
 104      @mb_internal_encoding($lang->settings['charset']);
 105  }
 106  
 107  // Select the board theme to use.
 108  $loadstyle = '';
 109  $load_from_forum = 0;
 110  $style = array();
 111  
 112  // This user has a custom theme set in their profile
 113  if(isset($mybb->user['style']) && intval($mybb->user['style']) != 0)
 114  {
 115      $loadstyle = "tid='".$mybb->user['style']."'";
 116  }
 117  
 118  $valid = array(
 119      "showthread.php", 
 120      "forumdisplay.php",
 121      "newthread.php",
 122      "newreply.php",
 123      "ratethread.php",
 124      "editpost.php",
 125      "polls.php",
 126      "sendthread.php",
 127      "printthread.php",
 128      "moderation.php"
 129  );
 130  
 131  if(in_array($current_page, $valid))
 132  {
 133      cache_forums();
 134  
 135      // If we're accessing a post, fetch the forum theme for it and if we're overriding it
 136      if($mybb->input['pid'])
 137      {
 138          $query = $db->simple_select("posts", "fid", "pid = '".intval($mybb->input['pid'])."'", array("limit" => 1));
 139          $fid = $db->fetch_field($query, "fid");
 140  
 141          if($fid)
 142          {
 143              $style = $forum_cache[$fid];
 144              $load_from_forum = 1;
 145          }
 146      }
 147  
 148      // We have a thread id and a forum id, we can easily fetch the theme for this forum
 149      else if($mybb->input['tid'])
 150      {
 151          $query = $db->simple_select("threads", "fid", "tid = '".intval($mybb->input['tid'])."'", array("limit" => 1));
 152          $fid = $db->fetch_field($query, "fid");
 153  
 154          if($fid)
 155          {
 156              $style = $forum_cache[$fid];
 157              $load_from_forum = 1;
 158          }
 159      }
 160  
 161      // We have a forum id - simply load the theme from it
 162      else if($mybb->input['fid'])
 163      {
 164          $style = $forum_cache[intval($mybb->input['fid'])];
 165          $load_from_forum = 1;
 166      }
 167  }
 168  unset($valid);
 169  
 170  // From all of the above, a theme was found
 171  if(isset($style['style']) && $style['style'] > 0)
 172  {
 173      // This theme is forced upon the user, overriding their selection
 174      if($style['overridestyle'] == 1 || !isset($mybb->user['style']))
 175      {
 176          $loadstyle = "tid='".intval($style['style'])."'";
 177      }
 178  }
 179  
 180  // After all of that no theme? Load the board default
 181  if(empty($loadstyle))
 182  {
 183      $loadstyle = "def='1'";
 184  }
 185  
 186  // Fetch the theme to load from the database
 187  $query = $db->simple_select("themes", "name, tid, properties, stylesheets", $loadstyle, array('limit' => 1));
 188  $theme = $db->fetch_array($query);
 189  
 190  // No theme was found - we attempt to load the master or any other theme
 191  if(!$theme['tid'])
 192  {
 193      // Missing theme was from a forum, run a query to set any forums using the theme to the default
 194      if($load_from_forum == 1)
 195      {
 196          $db->update_query("forums", array("style" => 0), "style='{$style['style']}'");
 197      }
 198      // Missing theme was from a user, run a query to set any users using the theme to the default
 199      else if($load_from_user == 1)
 200      {
 201          $db->update_query("users", array("style" => 0), "style='{$style['style']}'");
 202      }
 203      // Attempt to load the master or any other theme if the master is not available
 204      $query = $db->simple_select("themes", "name, tid, properties, stylesheets", "", array("order_by" => "tid", "limit" => 1));
 205      $theme = $db->fetch_array($query);
 206  }
 207  $theme = @array_merge($theme, unserialize($theme['properties']));
 208  
 209  // Fetch all necessary stylesheets
 210  $theme['stylesheets'] = unserialize($theme['stylesheets']);
 211  $stylesheet_scripts = array("global", basename($_SERVER['PHP_SELF']));
 212  foreach($stylesheet_scripts as $stylesheet_script)
 213  {
 214      $stylesheet_actions = array("global");
 215      if($mybb->input['action'])
 216      {
 217          $stylesheet_actions[] = $mybb->input['action'];
 218      }
 219      // Load stylesheets for global actions and the current action
 220      foreach($stylesheet_actions as $stylesheet_action)
 221      {
 222          if(!$stylesheet_action)
 223          {
 224              continue;
 225          }
 226          
 227          if($theme['stylesheets'][$stylesheet_script][$stylesheet_action])
 228          {
 229              // Actually add the stylesheets to the list
 230              foreach($theme['stylesheets'][$stylesheet_script][$stylesheet_action] as $page_stylesheet)
 231              {
 232                  if($already_loaded[$page_stylesheet])
 233                  {
 234                      continue;
 235                  }
 236                  $stylesheets .= "<link type=\"text/css\" rel=\"stylesheet\" href=\"{$mybb->settings['bburl']}/{$page_stylesheet}\" />\n";
 237                  $already_loaded[$page_stylesheet] = 1;
 238              }
 239          }
 240      }
 241  }
 242  
 243  // Are we linking to a remote theme server?
 244  if(substr($theme['imgdir'], 0, 7) == "http://")
 245  {
 246      // If a language directory for the current language exists within the theme - we use it
 247      if(!empty($mybb->user['language']))
 248      {
 249          $theme['imglangdir'] = $theme['imgdir'].'/'.$mybb->user['language'];
 250      }
 251      else
 252      {
 253          // Check if a custom language directory exists for this theme
 254          if(!empty($mybb->settings['bblanguage']))
 255          {
 256              $theme['imglangdir'] = $theme['imgdir'].'/'.$mybb->settings['bblanguage'];
 257          }
 258          // Otherwise, the image language directory is the same as the language directory for the theme
 259          else
 260          {
 261              $theme['imglangdir'] = $theme['imgdir'];
 262          }
 263      }
 264  }
 265  else
 266  {
 267      if(!@is_dir($theme['imgdir']))
 268      {
 269          $theme['imgdir'] = "images";
 270      }
 271  
 272      // If a language directory for the current language exists within the theme - we use it
 273      if(!empty($mybb->user['language']) && is_dir($theme['imgdir'].'/'.$mybb->user['language']))
 274      {
 275          $theme['imglangdir'] = $theme['imgdir'].'/'.$mybb->user['language'];
 276      }
 277      else
 278      {
 279          // Check if a custom language directory exists for this theme
 280          if(is_dir($theme['imgdir'].'/'.$mybb->settings['bblanguage']))
 281          {
 282              $theme['imglangdir'] = $theme['imgdir'].'/'.$mybb->settings['bblanguage'];
 283          }
 284          // Otherwise, the image language directory is the same as the language directory for the theme
 285          else
 286          {
 287              $theme['imglangdir'] = $theme['imgdir'];
 288          }
 289      }
 290  }
 291  
 292  // Theme logo - is it a relative URL to the forum root? Append bburl
 293  if(!preg_match("#^(\.\.?(/|$)|([a-z0-9]+)://)#i", $theme['logo']) && substr($theme['logo'], 0, 1) != "/")
 294  {
 295      $theme['logo'] = $mybb->settings['bburl']."/".$theme['logo'];
 296  }
 297  
 298  // Load Main Templates and Cached Templates
 299  if(isset($templatelist))
 300  {
 301      $templatelist .= ',';
 302  }
 303  $templatelist .= "css,headerinclude,header,footer,gobutton,htmldoctype,header_welcomeblock_member,header_welcomeblock_guest,header_welcomeblock_member_admin,global_pm_alert,global_unreadreports,";
 304  $templatelist .= ",global_pending_joinrequests,nav,nav_sep,nav_bit,nav_sep_active,nav_bit_active,footer_languageselect,header_welcomeblock_member_moderator,redirect,error";
 305  $templates->cache($db->escape_string($templatelist));
 306  
 307  // Set the current date and time now
 308  $datenow = my_date($mybb->settings['dateformat'], TIME_NOW, '', false);
 309  $timenow = my_date($mybb->settings['timeformat'], TIME_NOW);
 310  $lang->welcome_current_time = $lang->sprintf($lang->welcome_current_time, $datenow.', '.$timenow);
 311  
 312  // Format the last visit date of this user appropriately
 313  if(isset($mybb->user['lastvisit']))
 314  {
 315      $lastvisit = my_date($mybb->settings['dateformat'], $mybb->user['lastvisit']) . ', ' . my_date($mybb->settings['timeformat'], $mybb->user['lastvisit']);
 316  }
 317  
 318  // Otherwise, they've never visited before
 319  else
 320  {
 321      $lastvisit = $lang->lastvisit_never;
 322  }
 323  
 324  // If the board is closed and we have an Administrator, show board closed warning
 325  $bbclosedwarning = '';
 326  if($mybb->settings['boardclosed'] == 1 && $mybb->usergroup['cancp'] == 1)
 327  {
 328      eval("\$bbclosedwarning = \"".$templates->get("global_boardclosed_warning")."\";");
 329  }
 330  
 331  // Prepare the main templates for use
 332  unset($admincplink);
 333  
 334  // Load appropriate welcome block for the current logged in user
 335  if($mybb->user['uid'] != 0)
 336  {
 337      // User can access the admin cp and we're not hiding admin cp links, fetch it
 338      if($mybb->usergroup['cancp'] == 1 && $mybb->config['hide_admin_links'] != 1)
 339      {
 340          $admin_dir = $config['admin_dir'];
 341          eval("\$admincplink = \"".$templates->get("header_welcomeblock_member_admin")."\";");
 342      }
 343      
 344      if($mybb->usergroup['canmodcp'] == 1)
 345      {
 346          eval("\$modcplink = \"".$templates->get("header_welcomeblock_member_moderator")."\";");
 347      }
 348      
 349      // Format the welcome back message
 350      $lang->welcome_back = $lang->sprintf($lang->welcome_back, build_profile_link($mybb->user['username'], $mybb->user['uid']), $lastvisit);
 351  
 352      // Tell the user their PM usage
 353      $lang->welcome_pms_usage = $lang->sprintf($lang->welcome_pms_usage, my_number_format($mybb->user['pms_unread']), my_number_format($mybb->user['pms_total']));
 354      eval("\$welcomeblock = \"".$templates->get("header_welcomeblock_member")."\";");
 355  }
 356  // Otherwise, we have a guest
 357  else
 358  {
 359      eval("\$welcomeblock = \"".$templates->get("header_welcomeblock_guest")."\";");
 360  }
 361  
 362  $pending_joinrequests = '';
 363  
 364  // Read the group leaders cache
 365  $groupleaders = $cache->read("groupleaders");
 366  if($mybb->user['uid'] != 0 && is_array($groupleaders) && array_key_exists($mybb->user['uid'], $groupleaders))
 367  {
 368      $groupleader = $groupleaders[$mybb->user['uid']];
 369      
 370      $gids = "";
 371      foreach($groupleader as $user)
 372      {
 373          if($user['canmanagerequests'] != 1)
 374          {
 375              continue;
 376          }
 377          
 378          $gids .= ",{$user['gid']}";
 379      }
 380      
 381      $query = $db->simple_select("joinrequests", "COUNT(uid) as total", "gid IN (0{$gids})");
 382      $total_joinrequests = $db->fetch_field($query, "total");
 383      
 384      $pending_joinrequests = "";
 385      if($total_joinrequests > 0)
 386      {
 387          if($total_joinrequests == 1)
 388          {
 389              $lang->pending_joinrequests = $lang->pending_joinrequest;
 390          }
 391          else
 392          {
 393              $lang->pending_joinrequests = $lang->sprintf($lang->pending_joinrequests, $total_joinrequests);
 394          }
 395          eval("\$pending_joinrequests = \"".$templates->get("global_pending_joinrequests")."\";");
 396      }
 397  }
 398  
 399  $unreadreports = '';
 400  // This user is a moderator, super moderator or administrator
 401  if($mybb->usergroup['cancp'] == 1 || $mybb->user['ismoderator'] && $mybb->usergroup['canmodcp'])
 402  {
 403      // Read the reported posts cache
 404      $reported = $cache->read("reportedposts");
 405  
 406      // 0 or more reported posts currently exist
 407      if($reported['unread'] > 0)
 408      {
 409          if($reported['unread'] == 1)
 410          {
 411              $lang->unread_reports = $lang->unread_report;
 412          }
 413          else
 414          {
 415              $lang->unread_reports = $lang->sprintf($lang->unread_reports, $reported['unread']);
 416          }
 417          eval("\$unreadreports = \"".$templates->get("global_unreadreports")."\";");
 418      }
 419  }
 420  
 421  // Got a character set?
 422  if($lang->settings['charset'])
 423  {
 424      $charset = $lang->settings['charset'];
 425  }
 426  // If not, revert to UTF-8
 427  else
 428  {
 429      $charset = "UTF-8";
 430  }
 431  
 432  // Is this user apart of a banned group?
 433  $bannedwarning = '';
 434  if($mybb->usergroup['isbannedgroup'] == 1)
 435  {
 436      // Fetch details on their ban
 437      $query = $db->simple_select("banned", "*", "uid='{$mybb->user['uid']}'", array('limit' => 1));
 438      $ban = $db->fetch_array($query);
 439      if($ban['uid'])
 440      {
 441          // Format their ban lift date and reason appropriately
 442          if($ban['lifted'] > 0)
 443          {
 444              $banlift = my_date($mybb->settings['dateformat'], $ban['lifted']) . ", " . my_date($mybb->settings['timeformat'], $ban['lifted']);
 445          }
 446          else 
 447          {
 448              $banlift = $lang->banned_lifted_never;
 449          }
 450          $reason = htmlspecialchars_uni($ban['reason']);
 451      }
 452      if(empty($reason))
 453      {
 454          $reason = $lang->unknown;
 455      }
 456      if(empty($banlift))
 457      {
 458          $banlift = $lang->unknown;
 459      }
 460      // Display a nice warning to the user
 461      eval("\$bannedwarning = \"".$templates->get("global_bannedwarning")."\";");
 462  }
 463  
 464  $lang->ajax_loading = str_replace("'", "\\'", $lang->ajax_loading);
 465  
 466  // Check if this user has a new private message.
 467  if($mybb->user['pmnotice'] == 2 && $mybb->user['pms_unread'] > 0 && $mybb->settings['enablepms'] != 0 && $mybb->usergroup['canusepms'] != 0 && $mybb->usergroup['canview'] != 0 && ($current_page != "private.php" || $mybb->input['action'] != "read"))
 468  {
 469      $query = $db->query("
 470          SELECT pm.subject, pm.pmid, fu.username AS fromusername, fu.uid AS fromuid
 471          FROM ".TABLE_PREFIX."privatemessages pm
 472          LEFT JOIN ".TABLE_PREFIX."users fu ON (fu.uid=pm.fromid)
 473          WHERE pm.folder='1' AND pm.uid='{$mybb->user['uid']}' AND pm.status='0'
 474          ORDER BY pm.dateline DESC
 475          LIMIT 1
 476      ");
 477      $pm = $db->fetch_array($query);
 478      
 479      if($pm['fromuid'] == 0)
 480      {
 481          $pm['fromusername'] = $lang->mybb_engine;
 482          $user_text = $pm['fromusername'];
 483      }
 484      else
 485      {
 486          $user_text = build_profile_link($pm['fromusername'], $pm['fromuid']);
 487      }
 488  
 489      if($mybb->user['pms_unread'] == 1)
 490      {
 491          $privatemessage_text = $lang->sprintf($lang->newpm_notice_one, $user_text, $pm['pmid'], htmlspecialchars_uni($pm['subject']));
 492      }
 493      else
 494      {
 495          $privatemessage_text = $lang->sprintf($lang->newpm_notice_multiple, $mybb->user['pms_unread'], $user_text, $pm['pmid'], htmlspecialchars_uni($pm['subject']));
 496      }
 497      eval("\$pm_notice = \"".$templates->get("global_pm_alert")."\";");
 498  }
 499  
 500  // Set up some of the default templates
 501  eval("\$headerinclude = \"".$templates->get("headerinclude")."\";");
 502  eval("\$gobutton = \"".$templates->get("gobutton")."\";");
 503  eval("\$htmldoctype = \"".$templates->get("htmldoctype", 1, 0)."\";");
 504  eval("\$header = \"".$templates->get("header")."\";");
 505  
 506  $copy_year = my_date("Y", TIME_NOW);
 507  
 508  // Are we showing version numbers in the footer?
 509  if($mybb->settings['showvernum'] == 1)
 510  {
 511      $mybbversion = ' '.$mybb->version;
 512  }
 513  else
 514  {
 515      $mybbversion = '';
 516  }
 517  
 518  // Check to see if we have any tasks to run
 519  $task_cache = $cache->read("tasks");
 520  if(!$task_cache['nextrun'])
 521  {
 522      $task_cache['nextrun'] = TIME_NOW;
 523  }
 524  if($task_cache['nextrun'] <= TIME_NOW)
 525  {
 526      $task_image = "<img src=\"{$mybb->settings['bburl']}/task.php\" border=\"0\" width=\"1\" height=\"1\" alt=\"\" />";
 527  }
 528  else
 529  {
 530      $task_image = '';
 531  }
 532  
 533  // Are we showing the quick language selection box?
 534  $lang_select = '';
 535  if($mybb->settings['showlanguageselect'] != 0)
 536  {
 537      $languages = $lang->get_languages();
 538      foreach($languages as $key => $language)
 539      {
 540          $language = htmlspecialchars_uni($language);
 541          // Current language matches
 542          if($lang->language == $key)
 543          {
 544              $lang_options .= "<option value=\"{$key}\" selected=\"selected\">&nbsp;&nbsp;&nbsp;{$language}</option>\n";
 545          }
 546          else
 547          {
 548              $lang_options .= "<option value=\"{$key}\">&nbsp;&nbsp;&nbsp;{$language}</option>\n";
 549          }
 550      }
 551      
 552      $lang_redirect_url = get_current_location(true, 'language');
 553      
 554      eval("\$lang_select = \"".$templates->get("footer_languageselect")."\";");
 555  }
 556  
 557  // DST Auto detection enabled?
 558  if($mybb->user['uid'] > 0 && $mybb->user['dstcorrection'] == 2)
 559  {
 560      $auto_dst_detection = "<script type=\"text/javascript\">if(MyBB) { Event.observe(window, 'load', function() { MyBB.detectDSTChange('".($mybb->user['timezone']+$mybb->user['dst'])."'); }); }</script>\n";
 561  }
 562  
 563  eval("\$footer = \"".$templates->get("footer")."\";");
 564  
 565  // Add our main parts to the navigation
 566  $navbits = array();
 567  $navbits[0]['name'] = $mybb->settings['bbname_orig'];
 568  $navbits[0]['url'] = $mybb->settings['bburl']."/index.php";
 569  
 570  // Set the link to the archive.
 571  $archive_url = $mybb->settings['bburl']."/archive/index.php";
 572  
 573  // Check banned ip addresses
 574  if(is_banned_ip($session->ipaddress, true))
 575  {
 576      if ($mybb->user['uid'])
 577      {
 578          $db->delete_query("sessions", "ip='".$db->escape_string($session->ipaddress)."' OR uid='{$mybb->user['uid']}'");
 579      }
 580      else
 581      {
 582          $db->delete_query("sessions", "ip='".$db->escape_string($session->ipaddress)."'");
 583      }
 584      error($lang->error_banned);
 585  }
 586  
 587  $closed_bypass = array(
 588      "member.php" => array(
 589          "login",
 590          "do_login",
 591          "logout",
 592      ),
 593      "captcha.php",
 594  );
 595  
 596  // If the board is closed, the user is not an administrator and they're not trying to login, show the board closed message
 597  if($mybb->settings['boardclosed'] == 1 && $mybb->usergroup['cancp'] != 1 && !in_array($current_page, $closed_bypass) && (!is_array($closed_bypass[$current_page]) || !in_array($mybb->input['action'], $closed_bypass[$current_page])))
 598  {
 599      // Show error
 600      $lang->error_boardclosed .= "<blockquote>{$mybb->settings['boardclosed_reason']}</blockquote>";
 601      error($lang->error_boardclosed);
 602      exit;
 603  }
 604  
 605  // Load Limiting
 606  if($mybb->usergroup['cancp'] != 1 && $mybb->settings['load'] > 0 && ($load = get_server_load()) && $load != $lang->unknown && $load > $mybb->settings['load'])
 607  {
 608      // User is not an administrator and the load limit is higher than the limit, show an error
 609      error($lang->error_loadlimit);
 610  }
 611  
 612  // If there is a valid referrer in the URL, cookie it
 613  if(!$mybb->user['uid'] && $mybb->settings['usereferrals'] == 1 && (isset($mybb->input['referrer']) || isset($mybb->input['referrername'])))
 614  {
 615      if(isset($mybb->input['referrername']))
 616      {
 617          $condition = "username='".$db->escape_string($mybb->input['referrername'])."'";
 618      }
 619      else
 620      {
 621          $condition = "uid='".intval($mybb->input['referrer'])."'";
 622      }
 623      $query = $db->simple_select("users", "uid", $condition, array('limit' => 1));
 624      $referrer = $db->fetch_array($query);
 625      if($referrer['uid'])
 626      {
 627          my_setcookie("mybb[referrer]", $referrer['uid']);
 628      }
 629  }
 630  
 631  if($mybb->usergroup['canview'] != 1)
 632  {
 633      // Check pages allowable even when not allowed to view board
 634      if(defined("ALLOWABLE_PAGE"))
 635      {
 636          if(is_string(ALLOWABLE_PAGE))
 637          {
 638              $allowable_actions = explode(',', ALLOWABLE_PAGE);
 639              
 640              if(!in_array($mybb->input['action'], $allowable_actions))
 641              {
 642                  error_no_permission();
 643              }
 644              
 645              unset($allowable_actions);
 646          }
 647          else if(ALLOWABLE_PAGE !== 1)
 648          {
 649              error_no_permission();
 650          }
 651      }
 652      else
 653      {
 654          error_no_permission();
 655      }
 656  }
 657  
 658  // Find out if this user of ours is using a banned email address.
 659  // If they are, redirect them to change it
 660  if($mybb->user['uid'] && is_banned_email($mybb->user['email']) && $mybb->settings['emailkeep'] != 1)
 661  {
 662      if(THIS_SCRIPT != "usercp.php" || THIS_SCRIPT == "usercp.php" && $mybb->input['action'] != "email" && $mybb->input['action'] != "do_email")
 663      {
 664          redirect("usercp.php?action=email");
 665      }
 666      else if($mybb->request_method != "post")
 667      {
 668          $banned_email_error = inline_error(array($lang->banned_email_warning));
 669      }
 670  }
 671  
 672  // work out which items the user has collapsed
 673  $colcookie = $mybb->cookies['collapsed'];
 674  
 675  // set up collapsable items (to automatically show them us expanded)
 676  if($colcookie)
 677  {
 678      $col = explode("|", $colcookie);
 679      if(!is_array($col))
 680      {
 681          $col[0] = $colcookie; // only one item
 682      }
 683      unset($collapsed);
 684      foreach($col as $key => $val)
 685      {
 686          $ex = $val."_e";
 687          $co = $val."_c";
 688          $collapsed[$co] = "display: show;";
 689          $collapsed[$ex] = "display: none;";
 690          $collapsedimg[$val] = "_collapsed";
 691      }
 692  }
 693  
 694  // Run hooks for end of global.php
 695  $plugins->run_hooks("global_end");
 696  
 697  $globaltime = $maintimer->getTime();
 698  ?>


Generated: Sun Dec 11 14:16:27 2011 Cross-referenced by PHPXref 0.7.1