[ Index ]

PHP Cross Reference of MyBB 1.6.5

title

Body

[close]

/ -> misc.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: misc.php 5641 2011-10-26 09:36:44Z Tomm $
  10   */
  11  
  12  define("IN_MYBB", 1);
  13  define('THIS_SCRIPT', 'misc.php');
  14  
  15  $templatelist = "redirect_markallread,redirect_markforumread";
  16  $templatelist .= ",misc_buddypopup,misc_buddypopup_user_online,misc_buddypopup_user_offline,misc_buddypopup_user_sendpm";
  17  $templatelist .= ",misc_smilies,misc_smilies_smilie,misc_help_section_bit,misc_help_section,misc_help";
  18  require_once  "./global.php";
  19  require_once  MYBB_ROOT."inc/functions_post.php";
  20  
  21  // Load global language phrases
  22  $lang->load("misc");
  23  
  24  $plugins->run_hooks("misc_start");
  25  
  26  if($mybb->input['action'] == "dstswitch" && $mybb->request_method == "post" && $mybb->user['uid'] > 0)
  27  {
  28      if($mybb->user['dstcorrection'] == 2)
  29      {
  30          if($mybb->user['dst'] == 1)
  31          {
  32              $update_array = array("dst" => 0);
  33          }
  34          else
  35          {
  36              $update_array = array("dst" => 1);
  37          }
  38      }
  39      $db->update_query("users", $update_array, "uid='{$mybb->user['uid']}'");
  40      if(!$mybb->input['ajax'])
  41      {
  42          redirect("index.php", $lang->dst_settings_updated);
  43      }
  44      else
  45      {
  46          echo "done";
  47          exit;
  48      }
  49  }
  50  if($mybb->input['action'] == "markread")
  51  {
  52      if($mybb->user['uid'] && verify_post_check($mybb->input['my_post_key'], true) !== true)
  53      {
  54          // Protect our user's unread forums from CSRF
  55          error($lang->invalid_post_code);
  56      }
  57  
  58      if($mybb->input['fid'])
  59      {
  60          $mybb->input['fid'] = intval($mybb->input['fid']);
  61          $validforum = get_forum($mybb->input['fid']);
  62          if(!$validforum)
  63          {
  64              if(!$mybb->input['ajax'])
  65              {
  66                  error($lang->error_invalidforum);
  67              }
  68              else
  69              {
  70                  echo 0;
  71                  exit;
  72              }
  73          }
  74  
  75          require_once  MYBB_ROOT."/inc/functions_indicators.php";
  76          mark_forum_read($mybb->input['fid']);
  77  
  78          $plugins->run_hooks("misc_markread_forum");
  79  
  80          if(!$mybb->input['ajax'])
  81          {
  82              redirect(get_forum_link($mybb->input['fid']), $lang->redirect_markforumread);
  83          }
  84          else
  85          {
  86              echo 1;
  87              exit;
  88          }
  89      }
  90      else
  91      {
  92  
  93          $plugins->run_hooks("misc_markread_end");
  94          require_once  MYBB_ROOT."/inc/functions_indicators.php";
  95          mark_all_forums_read();
  96          redirect("index.php", $lang->redirect_markforumsread);
  97      }
  98  }
  99  elseif($mybb->input['action'] == "clearpass")
 100  {
 101      $plugins->run_hooks("misc_clearpass");
 102  
 103      if($mybb->input['fid'])
 104      {
 105          my_unsetcookie("forumpass[".intval($mybb->input['fid'])."]");
 106          redirect("index.php", $lang->redirect_forumpasscleared);
 107      }
 108  }
 109  elseif($mybb->input['action'] == "rules")
 110  {
 111      if($mybb->input['fid'])
 112      {
 113          $plugins->run_hooks("misc_rules_start");
 114  
 115          $query = $db->simple_select("forums", "*", "fid='".intval($mybb->input['fid'])."' AND active!=0");
 116          $forum = $db->fetch_array($query);
 117  
 118          $forumpermissions = forum_permissions($forum['fid']);
 119  
 120          if($forum['type'] != "f" || $forum['rules'] == '')
 121          {
 122              error($lang->error_invalidforum);
 123          }
 124          if($forumpermissions['canview'] != 1)
 125          {
 126              error_no_permission();
 127          }
 128          if(!$forum['rulestitle'])
 129          {
 130              $forum['rulestitle'] = $lang->sprintf($lang->forum_rules, $forum['name']);
 131          }
 132  
 133          require_once  MYBB_ROOT."inc/class_parser.php";
 134          $parser = new postParser();
 135          $parser_options = array(
 136              "allow_html" => 1,
 137              "allow_mycode" => 1,
 138              "allow_smilies" => 1,
 139              "allow_imgcode" => 1,
 140              "filter_badwords" => 1
 141          );
 142  
 143          $forum['rules'] = $parser->parse_message($forum['rules'], $parser_options);
 144  
 145          // Make navigation
 146          build_forum_breadcrumb($mybb->input['fid']);
 147          add_breadcrumb($forum['rulestitle']);
 148  
 149          $plugins->run_hooks("misc_rules_end");
 150  
 151          eval("\$rules = \"".$templates->get("misc_rules_forum")."\";");
 152          output_page($rules);
 153      }
 154  
 155  }
 156  elseif($mybb->input['action'] == "help")
 157  {
 158      $lang->load("helpdocs");
 159      $lang->load("helpsections");
 160      $lang->load("customhelpdocs");
 161      $lang->load("customhelpsections");
 162  
 163      add_breadcrumb($lang->nav_helpdocs, "misc.php?action=help");
 164  
 165      $query = $db->query("
 166          SELECT h.*, s.enabled AS section
 167          FROM ".TABLE_PREFIX."helpdocs h
 168          LEFT JOIN ".TABLE_PREFIX."helpsections s ON (s.sid=h.sid)
 169          WHERE h.hid='".intval($mybb->input['hid'])."'
 170      ");
 171      $helpdoc = $db->fetch_array($query);
 172      if($helpdoc['hid'])
 173      {
 174          if($helpdoc['section'] != 0 && $helpdoc['enabled'] != 0)
 175          {
 176              $plugins->run_hooks("misc_help_helpdoc_start");
 177  
 178              if($helpdoc['usetranslation'] == 1)
 179              {
 180                  $langnamevar = "d".$helpdoc['hid']."_name";
 181                  $langdescvar = "d".$helpdoc['hid']."_desc";
 182                  $langdocvar = "d".$helpdoc['hid']."_document";
 183                  if($lang->$langnamevar)
 184                  {
 185                      $helpdoc['name'] = $lang->$langnamevar;
 186                  }
 187                  if($lang->$langdescvar)
 188                  {
 189                      $helpdoc['description'] = $lang->$langdescvar;
 190                  }
 191                  if($lang->$langdocvar)
 192                  {
 193                      $helpdoc['document'] = $lang->$langdocvar;
 194                      
 195                      if($langdocvar == "d3_document")
 196                      {
 197                          $helpdoc['document'] = $lang->sprintf($helpdoc['document'], $mybb->user['logoutkey']);
 198                      }
 199                  }
 200              }
 201              add_breadcrumb($helpdoc['name']);
 202  
 203              $plugins->run_hooks("misc_help_helpdoc_end");
 204  
 205              eval("\$helppage = \"".$templates->get("misc_help_helpdoc")."\";");
 206              output_page($helppage);
 207          }
 208          else
 209          {
 210              error($lang->error_invalidhelpdoc);
 211          }
 212      }
 213      else
 214      {
 215          $plugins->run_hooks("misc_help_section_start");
 216  
 217          $query = $db->simple_select("helpdocs", "*", "", array('order_by' => 'sid, disporder'));
 218          while($helpdoc = $db->fetch_array($query))
 219          {
 220              $helpdocs[$helpdoc['sid']][$helpdoc['disporder']][$helpdoc['hid']] = $helpdoc;
 221          }
 222          unset($helpdoc);
 223          $sections = '';
 224          $query = $db->simple_select("helpsections", "*", "enabled != 0", array('order_by' => 'disporder'));
 225          while($section = $db->fetch_array($query))
 226          {
 227              if($section['usetranslation'] == 1)
 228              {
 229                  $langnamevar = "s".$section['sid']."_name";
 230                  $langdescvar = "s".$section['sid']."_desc";
 231                  if($lang->$langnamevar)
 232                  {
 233                      $section['name'] = $lang->$langnamevar;
 234                  }
 235                  if($lang->$langdescvar)
 236                  {
 237                      $section['description'] = $lang->$langdescvar;
 238                  }
 239              }
 240              if(is_array($helpdocs[$section['sid']]))
 241              {
 242                  $helpbits = '';
 243                  // Expand (or Collapse) forums
 244                  if($mybb->input['action'] == "expand")
 245                  {
 246                      my_setcookie("fcollapse[{$section['sid']}]", '');
 247                      $scollapse[$section['sid']] = '';
 248                  }
 249                  elseif($mybb->input['action'] == "collapse")
 250                  {
 251                      my_setcookie("fcollapse[{$section['sid']}]", "y");
 252                      $scollapse[$section['sid']] = "y";
 253                  }
 254                  foreach($helpdocs[$section['sid']] as $key => $bit)
 255                  {
 256                      foreach($bit as $key => $helpdoc)
 257                      {
 258                          if($helpdoc['enabled'] != 0)
 259                          {
 260                              if($helpdoc['usetranslation'] == 1)
 261                              {
 262                                  $langnamevar = "d".$helpdoc['hid'].'_name';
 263                                  $langdescvar = "d".$helpdoc['hid'].'_desc';
 264                                  if($lang->$langnamevar)
 265                                  {
 266                                      $helpdoc['name'] = $lang->$langnamevar;
 267                                  }
 268                                  if($lang->$langdescvar)
 269                                  {
 270                                      $helpdoc['description'] = $lang->$langdescvar;
 271                                  }
 272                              }
 273                              $altbg = alt_trow();
 274                              eval("\$helpbits .= \"".$templates->get("misc_help_section_bit")."\";");
 275                          }
 276                      }
 277                      $expdisplay = '';
 278                      $sname = "sid_".$section['sid']."_c";
 279                      if($collapsed[$sname] == "display: show;")
 280                      {
 281                          $expcolimage = "collapse_collapsed.gif";
 282                          $expdisplay = "display: none;";
 283                      }
 284                      else
 285                      {
 286                          $expcolimage = "collapse.gif";
 287                      }
 288                  }
 289                  eval("\$sections .= \"".$templates->get("misc_help_section")."\";");
 290              }
 291          }
 292  
 293          $plugins->run_hooks("misc_help_section_end");
 294  
 295          eval("\$help = \"".$templates->get("misc_help")."\";");
 296          output_page($help);
 297      }
 298  }
 299  elseif($mybb->input['action'] == "buddypopup")
 300  {
 301      $plugins->run_hooks("misc_buddypopup_start");
 302  
 303      if($mybb->user['uid'] == 0)
 304      {
 305          error_no_permission();
 306      }
 307      if($mybb->input['removebuddy'])
 308      {
 309          $buddies = $mybb->user['buddylist'];
 310          $namesarray = explode(",",$buddies);
 311          if(is_array($namesarray))
 312          {
 313              foreach($namesarray as $key => $buddyid)
 314              {
 315                  if($buddyid == $mybb->input['removebuddy'])
 316                  {
 317                      unset($namesarray[$key]);
 318                  }
 319              }
 320              $buddylist = implode(',', $namesarray);
 321              $db->update_query("users", array('buddylist' => $buddylist), "uid='".$mybb->user['uid']."'");
 322              $mybb->user['buddylist'] = $buddylist;
 323          }
 324      }
 325      // Load Buddies
 326      if($mybb->user['buddylist'] != "")
 327      {
 328          $timecut = TIME_NOW - $mybb->settings['wolcutoff'];
 329          $query = $db->simple_select("users", "*", "uid IN ({$mybb->user['buddylist']})", array('order_by' => 'lastactive'));
 330  
 331          while($buddy = $db->fetch_array($query))
 332          {
 333              $buddy_name = format_name($buddy['username'], $buddy['usergroup'], $buddy['displaygroup']);
 334              $profile_link = build_profile_link($buddy_name, $buddy['uid'], '_blank', 'if(window.opener) { window.opener.location = this.href; return false; }');
 335  
 336              if($mybb->user['receivepms'] != 0 && $buddy['receivepms'] != 0 && $groupscache[$buddy['usergroup']]['canusepms'] != 0)
 337              {
 338                  eval("\$send_pm = \"".$templates->get("misc_buddypopup_user_sendpm")."\";");
 339              }
 340              else
 341              {
 342                  $send_pm = '';
 343              }
 344              if($buddy['lastactive'])
 345              {
 346                  $last_active = $lang->sprintf($lang->last_active, my_date($mybb->settings['dateformat'], $buddy['lastactive']).", ".my_date($mybb->settings['timeformat'], $buddy['lastactive']));
 347              }
 348              else
 349              {
 350                  $last_active = $lang->sprintf($lang->last_active, $lang->never);
 351              }
 352  
 353              if($buddy['avatar'])
 354              {
 355                  $buddy['avatar'] = htmlspecialchars_uni($buddy['avatar']);
 356                  if($buddy['avatardimensions'])
 357                  {
 358                      require_once  MYBB_ROOT."inc/functions_image.php";
 359                      list($width, $height) = explode("|", $buddy['avatardimensions']);
 360                      $scaled_dimensions = scale_image($width, $height, 44, 44);
 361                  }
 362                  else
 363                  {
 364                      $scaled_dimensions = array(
 365                          "width" => 44,
 366                          "height" => 44
 367                      );
 368                  }
 369              }
 370              else
 371              {
 372                  $buddy['avatar'] = $theme['imgdir'] . "/default_avatar.gif";
 373                  $scaled_dimensions = array(
 374                      "width" => 44,
 375                      "height" => 44
 376                  );
 377              }
 378              $margin_top = ceil((50-$scaled_dimensions['height'])/2);
 379              if($buddy['lastactive'] > $timecut && ($buddy['invisible'] == 0 || $mybb->user['usergroup'] == 4) && $buddy['lastvisit'] != $buddy['lastactive'])
 380              {
 381                  eval("\$buddys['online'] .= \"".$templates->get("misc_buddypopup_user_online")."\";");
 382              }
 383              else
 384              {
 385                  eval("\$buddys['offline'] .= \"".$templates->get("misc_buddypopup_user_offline")."\";");
 386              }
 387          }
 388      }
 389      else
 390      {
 391          // No buddies? :(
 392          $buddys['offline'] = $lang->no_buddies;
 393      }
 394  
 395      $plugins->run_hooks("misc_buddypopup_end");
 396  
 397      eval("\$buddylist = \"".$templates->get("misc_buddypopup")."\";");
 398      output_page($buddylist);
 399  }
 400  elseif($mybb->input['action'] == "whoposted")
 401  {
 402      $numposts = 0;
 403      $altbg = alt_trow();
 404      $whoposted = '';
 405      $tid = intval($mybb->input['tid']);
 406      $thread = get_thread($tid);
 407      
 408      if(is_moderator($thread['fid']))
 409      {
 410          $ismod = true;
 411          $show_posts = "(p.visible = '1' OR p.visible = '0')";
 412      }
 413      else
 414      {
 415          $ismod = false;
 416          $show_posts = "p.visible = '1'";
 417      }
 418      
 419      // Make sure we are looking at a real thread here.
 420      if(!$thread['tid'] || ($thread['visible'] == 0 && $ismod == false) || ($thread['visible'] > 1 && $ismod == true))
 421      {
 422          error($lang->error_invalidthread);
 423      }
 424      // Does the thread belong to a valid forum?
 425      $forum = get_forum($thread['fid']);
 426      if(!$forum || $forum['type'] != "f")
 427      {
 428          error($lang->error_invalidforum);
 429      }
 430      
 431      // Does the user have permission to view this thread?
 432      $forumpermissions = forum_permissions($forum['fid']);
 433      
 434      if($forumpermissions['canview'] != 1 || $forumpermissions['canviewthreads'] != 1)
 435      {
 436          error_no_permission();
 437      }
 438      
 439      // Check if this forum is password protected and we have a valid password
 440      check_forum_password($forum['fid']);
 441      
 442      if($mybb->input['sort'] != 'username')
 443      {
 444          $sortsql = ' ORDER BY posts DESC';
 445      }
 446      else
 447      {
 448          $sortsql = ' ORDER BY p.username ASC';
 449      }
 450      $query = $db->query("
 451          SELECT COUNT(p.pid) AS posts, p.username AS postusername, u.uid, u.username, u.usergroup, u.displaygroup
 452          FROM ".TABLE_PREFIX."posts p
 453          LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
 454          WHERE tid='".$tid."' AND $show_posts
 455          GROUP BY u.uid, p.username, u.uid, u.username, u.usergroup, u.displaygroup
 456          ".$sortsql."
 457      ");
 458      while($poster = $db->fetch_array($query))
 459      {
 460          if($poster['username'] == '')
 461          {
 462              $poster['username'] = $poster['postusername'];
 463          }
 464          $poster_name = format_name($poster['username'], $poster['usergroup'], $poster['displaygroup']);
 465          if($poster['uid'])
 466          {
 467              $onclick = "opener.location.href='".get_profile_link($poster['uid'])."'; return false;";
 468          }
 469          $profile_link = build_profile_link($poster_name, $poster['uid'], '_blank', $onclick);
 470          $numposts += $poster['posts'];
 471          eval("\$whoposted .= \"".$templates->get("misc_whoposted_poster")."\";");
 472          $altbg = alt_trow();
 473      }
 474      $numposts = my_number_format($numposts);
 475      eval("\$whop = \"".$templates->get("misc_whoposted")."\";");
 476      output_page($whop);
 477  }
 478  elseif($mybb->input['action'] == "smilies")
 479  {
 480      $smilies = '';
 481      if($mybb->input['popup'])
 482      { // make small popup list of smilies
 483          $editor = addslashes(htmlentities($mybb->input['editor']));
 484          $e = 1;
 485          $class = "trow1";
 486          $smilies = "<tr>";
 487          $query = $db->simple_select("smilies", "*", "", array('order_by' => 'disporder'));
 488          while($smilie = $db->fetch_array($query))
 489          {
 490              $smilie['insert'] = addslashes($smilie['find']);
 491              $smilie['find'] = htmlspecialchars_uni($smilie['find']);
 492              eval("\$smilies .= \"".$templates->get("misc_smilies_popup_smilie")."\";");
 493              if($e == 2)
 494              {
 495                  $smilies .= "</tr><tr>";
 496                  $e = 1;
 497                  $class = alt_trow();
 498              }
 499              else
 500              {
 501                  $e = 2;
 502              }
 503          }
 504          if($e == 2)
 505          {
 506              $smilies .= "<td colspan=\"2\" class=\"$class\">&nbsp;</td>";
 507          }
 508          eval("\$smiliespage = \"".$templates->get("misc_smilies_popup")."\";");
 509          output_page($smiliespage);
 510      }
 511      else
 512      {
 513          add_breadcrumb($lang->nav_smilies);
 514          $class = "trow1";
 515          $query = $db->simple_select("smilies", "*", "", array('order_by' => 'disporder'));
 516          while($smilie = $db->fetch_array($query))
 517          {
 518              $smilie['find'] = htmlspecialchars_uni($smilie['find']);
 519              eval("\$smilies .= \"".$templates->get("misc_smilies_smilie")."\";");
 520              $class = alt_trow();
 521          }
 522          eval("\$smiliespage = \"".$templates->get("misc_smilies")."\";");
 523          output_page($smiliespage);
 524      }
 525  }
 526  elseif($mybb->input['action'] == "imcenter")
 527  {
 528      if($mybb->input['imtype'] != "aim" && $mybb->input['imtype'] != "msn" && $mybb->input['imtype'] != "yahoo")
 529      {
 530          error($lang->error_invalidimtype);
 531      }
 532      $uid = $mybb->input['uid'];
 533      $user = get_user($uid);
 534  
 535      if(!$user['username'])
 536      {
 537          error($lang->error_invaliduser);
 538      }
 539      if(!$user[$mybb->input['imtype']])
 540      {
 541          error($lang->error_invalidimtype);
 542      }
 543  
 544      // build im navigation bar
 545      $navigationbar = $navsep = '';
 546      if($user['aim'])
 547      {
 548          $navigationbar .= "<a href=\"misc.php?action=imcenter&amp;imtype=aim&amp;uid=$uid\">$lang->aol_im</a>";
 549          $navsep = ' - ';
 550      }
 551      if($user['msn'])
 552      {
 553          $navigationbar .= "$navsep<a href=\"misc.php?action=imcenter&amp;imtype=msn&amp;uid=$uid\">$lang->msn</a>";
 554          $navsep = ' - ';
 555      }
 556      if($user['yahoo'])
 557      {
 558          $navigationbar .= "$navsep<a href=\"misc.php?action=imcenter&amp;imtype=yahoo&amp;uid=$uid\">$lang->yahoo_im</a>";
 559      }
 560      $lang->msn_address_is = $lang->sprintf($lang->msn_address_is, $user['username']);
 561      $lang->send_y_message = $lang->sprintf($lang->send_y_message, $user['username']);
 562      $lang->view_y_profile = $lang->sprintf($lang->view_y_profile, $user['username']);
 563      
 564      $imtemplate = "misc_imcenter_".$mybb->input['imtype'];
 565      eval("\$imcenter = \"".$templates->get($imtemplate)."\";");
 566      output_page($imcenter);
 567  }
 568  elseif($mybb->input['action'] == "syndication")
 569  {
 570      $plugins->run_hooks("misc_syndication_start");
 571  
 572      $fid = $mybb->input['fid'];
 573      $version = $mybb->input['version'];
 574      $limit = $mybb->input['limit'];
 575      $forums = $mybb->input['forums'];
 576  
 577      add_breadcrumb($lang->nav_syndication);
 578      $unviewable = get_unviewable_forums();
 579      if(is_array($forums))
 580      {
 581          $unexp = explode(",", $unviewable);
 582          foreach($unexp as $fid)
 583          {
 584              $unview[$fid] = 1;
 585          }
 586          $syndicate = '';
 587          $comma = '';
 588          foreach($forums as $fid)
 589          {
 590              if($fid == "all")
 591              {
 592                  $all = 1;
 593                  break;
 594              }
 595              elseif(is_numeric($fid))
 596              {
 597                  if(!$unview[$fid])
 598                  {
 599                      $syndicate .= $comma.$fid;
 600                      $comma = ",";
 601                      $flist[$fid] = 1;
 602                  }
 603              }
 604          }
 605          $url = $mybb->settings['bburl']."/syndication.php";
 606          if(!$all)
 607          {
 608              $url .= "?fid=$syndicate";
 609              $add = 1;
 610          }
 611  
 612          // If the version is not RSS2.0, set the type to Atom1.0.
 613          if($version != "rss2.0")
 614          {
 615              if(!$add)
 616              {
 617                  $url .= "?";
 618              }
 619              else
 620              {
 621                  $url .= "&";
 622              }
 623              $url .= "type=atom1.0";
 624              $add = 1;
 625          }
 626          if(intval($limit) > 0)
 627          {
 628              if($limit > 100)
 629              {
 630                  $limit = 100;
 631              }
 632              if(!$add)
 633              {
 634                  $url .= "?";
 635              }
 636              else
 637              {
 638                  $url .= "&";
 639              }
 640              if(is_numeric($limit))
 641              {
 642                  $url .= "limit=$limit";
 643              }
 644          }
 645          $limit = intval($_POST['limit']);
 646          eval("\$feedurl = \"".$templates->get("misc_syndication_feedurl")."\";");
 647      }
 648      unset($GLOBALS['forumcache']);
 649      if(!$limit || !is_numeric($limit))
 650      {
 651          $limit = 15;
 652      }
 653  
 654      // If there is no version in the input, check the default (RSS2.0).
 655      if($version == "atom1.0")
 656      {
 657          $atom1check = "checked=\"checked\"";
 658          $rss2check = '';
 659      }
 660      else
 661      {
 662          $atom1check = '';
 663          $rss2check = "checked=\"checked\"";
 664      }
 665      $forumselect = makesyndicateforums("", $blah);
 666  
 667      $plugins->run_hooks("misc_syndication_end");
 668  
 669      eval("\$syndication = \"".$templates->get("misc_syndication")."\";");
 670      output_page($syndication);
 671  }
 672  
 673  
 674  if($mybb->input['action'] == "clearcookies")
 675  {
 676      $plugins->run_hooks("misc_clearcookies");
 677      
 678      if($mybb->input['key'] != $mybb->user['logoutkey'])
 679      {
 680          error($lang->error_invalidkey);
 681      }
 682  
 683      $remove_cookies = array('mybb', 'mybbuser', 'mybb[password]', 'mybb[lastvisit]', 'mybb[lastactive]', 'collapsed', 'mybb[forumread]', 'mybb[threadsread]', 'mybbadmin');
 684  
 685      if($mybb->settings['cookiedomain'])
 686      {
 687          foreach($remove_cookies as $name)
 688          {
 689              @my_setcookie($name, '', TIME_NOW-1, $mybb->settings['cookiepath'], $mybb->settings['cookiedomain']);
 690          }
 691      }
 692      else
 693      {
 694          foreach($remove_cookies as $name)
 695          {
 696              @my_setcookie($name, '', TIME_NOW-1, $mybb->settings['cookiepath']);
 697          }
 698      }
 699      redirect("index.php", $lang->redirect_cookiescleared);
 700  }
 701  
 702  function makesyndicateforums($pid="0", $selitem="", $addselect="1", $depth="", $permissions="")
 703  {
 704      global $db, $forumcache, $permissioncache, $mybb, $selecteddone, $forumlist, $forumlistbits, $theme, $templates, $flist, $lang, $unviewable;
 705      static $unviewableforums;
 706  
 707      $pid = intval($pid);
 708      if(!$permissions)
 709      {
 710          $permissions = $mybb->usergroup;
 711      }
 712  
 713      if(!is_array($forumcache))
 714      {
 715          // Get Forums
 716          $query = $db->simple_select("forums", "*", "linkto = '' AND active!=0", array('order_by' => 'pid, disporder'));
 717          while($forum = $db->fetch_array($query))
 718          {
 719              $forumcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
 720          }
 721      }
 722  
 723      if(!is_array($permissioncache))
 724      {
 725          $permissioncache = forum_permissions();
 726      }
 727  
 728      if(!$unviewableforums)
 729      {
 730          // Save our unviewable forums in an array
 731          $unviewableforums = explode(",", str_replace("'", "", $unviewable));
 732      }
 733  
 734      if(is_array($forumcache[$pid]))
 735      {
 736          foreach($forumcache[$pid] as $key => $main)
 737          {
 738              foreach($main as $key => $forum)
 739              {
 740                  $perms = $permissioncache[$forum['fid']];
 741                  if($perms['canview'] == 1 || $mybb->settings['hideprivateforums'] == 0)
 742                  {
 743                      if($flist[$forum['fid']])
 744                      {
 745                          $optionselected = "selected=\"selected\"";
 746                          $selecteddone = "1";
 747                      }
 748                      else
 749                      {
 750                          $optionselected = '';
 751                      }
 752  
 753                      if($forum['password'] == '' && !in_array($forum['fid'], $unviewableforums) || $forum['password'] && $mybb->cookies['forumpass'][$forum['fid']] == md5($mybb->user['uid'].$forum['password']))
 754                      {
 755                          $forumlistbits .= "<option value=\"{$forum['fid']}\" $optionselected>$depth {$forum['name']}</option>\n";
 756                      }
 757  
 758                      if($forumcache[$forum['fid']])
 759                      {
 760                          $newdepth = $depth."&nbsp;&nbsp;&nbsp;&nbsp;";
 761                          $forumlistbits .= makesyndicateforums($forum['fid'], $selitem, 0, $newdepth, $perms);
 762                      }
 763                  }
 764              }
 765          }
 766      }
 767      if($addselect)
 768      {
 769          if(!$selecteddone)
 770          {
 771              $addsel = " selected=\"selected\"";
 772          }
 773          $forumlist = "<select name=\"forums[]\" size=\"10\" multiple=\"multiple\">\n<option value=\"all\" $addsel>$lang->syndicate_all_forums</option>\n<option value=\"all\">----------------------</option>\n$forumlistbits\n</select>";
 774      }
 775      return $forumlist;
 776  }
 777  
 778  ?>


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