[ Index ]

PHP Cross Reference of MyBB 1.4.13

title

Body

[close]

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


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