MyBB PHP Cross Reference Discussion Forums

Source: /misc.php - 784 lines - 20401 bytes - Summary - Text - Print

Description: MyBB 1.6 Copyright 2010 MyBB Group, All Rights Reserved

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

title

Description

title

Description

title

Description

title

title

Body