<?php
//
// Copyright (C) 2003-2004 Two Shoes Module Factory
// All rights reserved.
//
// This program uses parts of the original Simpleboard Application
// 0.7.0b written by Josh Levine; http://www.joshlevine.net
//
// This source file is part of the SimpleBoard Component, a Mambo 4.5
// custom Component By Jan de Graaff - http://tsmf.jigsnet.com
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// Please note that the GPL states that any headers in files and
// Copyright notices as well as credits in headers, source files
// and output (screens, prints, etc.) can not be removed.
// You can extend them with your own credits, though...
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
// The "GNU General Public License" (GPL) is available at
// http://www.gnu.org/copyleft/gpl.html.
//
// Dont allow direct linking
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );


require_once($sbp.'/sb_auth.php');

//global $catid; //should not be needed and is a bit dangerous..
//Security basics begin
	//Securing passed form elements:
	$catid=(int)$catid;
	$Itemid=(int)$Itemid;
	//resetting some things:
	$moderatedForum=0;
	$lockedForum=0;
	$lockedTopic=0;
	$topicSticky=0;
	$is_Mod=0;
//Security Basics end
if (!$is_admin)
{
   $database->setQuery("SELECT userid FROM #__sb_moderation WHERE catid='$catid' and userid='$my->id'");
   if ($database->loadResult() ) {$is_Mod=1;}
}else{ $is_Mod=1;} //superadmins always are

unset($allow_forum);
$allow_forum=array();
//get the db data with allowed forums and turn it into an array
if ($sbSession->allowed != "na" && ! $new_sb_user)  {
   $allow_forum=explode(',',$sbSession->allowed);
}
else {
   //get only the public accessible forums..
   $database->setQuery( "SELECT id FROM #__sb_categories WHERE published='1' AND pub_access='0'");
   $allowed_forums=$database->loadObjectList();
   $i=0;
   foreach ($allowed_forums as $af){
      if (count ($allow_forum) == 0 ){
         $allow_forum[0]=$af->id;
      }
      else {
         $allow_forum[$i]=$af->id;
         $i++;
      }
   } 
}

if (!$is_Mod){
   //check Access Level Restrictions but don't bother for Moderators
   //get all the info on this forum:
   $database->setQuery("SELECT id,pub_access,pub_recurse,admin_access,admin_recurse FROM #__sb_categories where id='$catid'");
   $row=$database->loadObjectList();
   //Do user identification based upon the ACL
   $letPass=0;
   $letPass=sb_auth::validate_user($row[0], $allow_forum, $aro_group->group_id, $acl);
}

if ($letPass || $is_Mod)
{
   $threads_per_page=$sbConfig['threads_per_page'];
   if ($catid <= 0 )
   {
      //make sure we got a valid category id
      $catid=1;
   }


   $view=$view==""?$settings[current_view]:$view;
   setcookie("sboard_settings[current_view]",$view,time()+31536000,'/');


   /*//////////////// Start selecting messages, prepare them for threading, etc... /////////////////*/
   $page = (int)$page;
   $page = $page<1?1:$page;
   $offset = ($page-1)*$threads_per_page;
   $row_count=$page*$threads_per_page;
   $database->setQuery("Select count(*) FROM #__sb_messages WHERE parent = '0' AND catid= '$catid' AND hold = '0' ");
   $total=(int)$database->loadResult();
   $database->setQuery("SELECT a. * , MAX( b.time )  AS lastpost FROM  #__sb_messages  AS a LEFT  JOIN #__sb_messages  AS b ON b.thread = a.thread WHERE a.parent =  '0' AND a.catid =  $catid AND a.hold =  '0' GROUP  BY id ORDER  BY ordering DESC , lastpost DESC  LIMIT $offset,$row_count");
 
   foreach ($database->loadObjectList() as $message) {
		$threadids[]=$message->id;
		$messages[$message->parent][]=$message;
		$last_reply[$message->id] = $message;
		$hits[$message->id]=$message->hits;
   }

    if (count($threadids) > 0) {
      $idstr = @join("','",$threadids);
	  $database->setQuery("SELECT id,parent,thread,catid,subject,name,time,topic_emoticon,locked,ordering, moved FROM #__sb_messages WHERE thread IN ('$idstr') AND id NOT IN ('$idstr') and hold=0");
	foreach ($database->loadObjectList() as $message)
      {
         $messages[$message->parent][]=$message;
         $thread_counts[$message->thread]++;
         $last_reply[$message->thread]=$last_reply[$message->thread]->time<$message->time?$message:$last_reply[$message->thread];
      }
   }
   //get number of pending messages
   $database->setQuery("select count(*) from #__sb_messages where catid='$catid' and hold=1");
   $numPending=$database->loadResult();


   //@rsort($messages[0]);
?>

<link rel="stylesheet" href="components/com_simpleboard/template/<?php echo $sbConfig['template']; ?>/forum.css" type="text/css" />

<table border="0" cellspacing="0" cellpadding="0" width="100%" class="sb_contentpane">
   <tr>
     <td align="center">
       <table border="0" width="100%">
         <!--<?php include ($sbp.'/searchbox.php');?>-->
         <tr>
           <td align="center">
             <b><font size="2"><?php echo $board_title;?></font></b>
             <?php echo $sbConfig['board_offline'] ? '<br /><font color="red">' ._FORUM_IS_OFFLINE.'</font>' : '&nbsp;' ;?>
           </td>
         </tr>
       </table>
<br />
<div align="center">
      <a href="<?php echo sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid);?>">
         <?php echo $sbIcons['home'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['home'].'" border="0" alt="'._HOME.'" title="'._HOME.'" />' : _HOME; ?>
      </a>

   <?php
   if ($my_id != 0)
    {//Userprofile
      echo $sbIcons['profile'] ?'':'| ';?><a href="<?php if ($sbConfig['cb_profile']) { echo sefRelToAbs('index.php?option=com_comprofiler&amp;Itemid='.$cbitemid); } else { echo sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=userprofile&amp;do=show'); }?>">
         <?php echo $sbIcons['profile'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['profile'].'" border="0" alt="'._GEN_MYPROFILE.'" title="'._GEN_MYPROFILE.'"/>' : _GEN_MYPROFILE; ?>
      </a>
      <?php
    }
          if ($view=="flat")
          {
            echo $sbIcons['threadedview'] ?'':'| '; echo '<a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=showcat&amp;view=threaded&amp;id='.$id.'&amp;catid='.$catid).'">';
            echo $sbIcons['threadedview'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['threadedview'].'" border="0" alt="'._GEN_THREADED_VIEW.'" title="'._GEN_THREADED_VIEW.'"/>' : _GEN_THREADED_VIEW;
            echo '</a>';
          }
          else
          {
            echo $sbIcons['flatview'] ?'':'| '; echo '<a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=showcat&amp;id='.$id.'&amp;view=flat&amp;catid='.$catid).'">';
            echo $sbIcons['flatview'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['flatview'].'" border="0" alt="'._GEN_FLAT_VIEW.'" title="'._GEN_FLAT_VIEW.'"/>' : _GEN_FLAT_VIEW;
            echo "</a>";
          }

    if ($is_moderator || $is_admin){
      if ($numPending>0)
      {
         $numcolor='<font color="red">';
         echo $sbIcons['pendingmessages'] ?'':' | '; echo ' <a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=review&action=list&amp;catid='.$catid).'">';
         echo $sbIcons['pendingmessages'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['pendingmessages'].'" border="0" alt="'.$numPending.' '._SHOWCAT_PENDING.'" />' : $numcolor.''.$numPending.'</font> '._SHOWCAT_PENDING;
         echo '</a>';
       }else{
          echo $sbIcons['nopendingmsgs'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['nopendingmsgs'].'" border="0" alt="'._SHOWCAT_NOPENDING.'" title="'._SHOWCAT_NOPENDING.'" />' : ' | '._SHOWCAT_NOPENDING;
       }
    }
	 /* RODAX SOFTWARE
      echo $sbIcons['help'] ?'':' | '; echo '<a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=faq').'">';
      echo $sbIcons['help'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['help'].'" border="0" alt="'._GEN_HELP.'" title="'._GEN_HELP.'"/>' : _GEN_HELP;
      echo '</a>';
	*/
	  // add lines for new rules menu item
      if ( $sbConfig['enableRulesPage'] ) {
		  echo $sbIcons['rules'] ?'':' | '; 
		  echo '<a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=rules').'">';
	      echo $sbIcons['rules'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['rules'].'" border="0" alt="'._GEN_RULES.'" title="'._GEN_RULES.'"/>' : _GEN_RULES;
    	  echo '</a>';
	  }
	  echo '</div>';	  

   //post new topic
   echo "</td></tr><tr><td class='buttonheading'>";
   if ((($sbConfig['pubwrite']==0 && $my_id != 0)||$sbConfig['pubwrite']==1) && ($topicLock==0 || ($topicLock==1 && $is_moderator))) {
	//this user is allowed to post a new topic:
	   if ($sbIcons['new_topic']){
    	  echo '<a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=post&amp;do=reply&amp;catid='.$catid).'"><img src="modules/mod_sbicons/'.$sbIcons['new_topic'].'" alt="'._GEN_POST_NEW_TOPIC.'" title="'._GEN_POST_NEW_TOPIC.'" border="0"></a>';
	   }
	   else{
	      echo '<a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=post&amp;do=reply&amp;catid='.$catid).'">'._GEN_POST_NEW_TOPIC.'</a>';
	   }
	}
   echo '</td></tr><tr><td align="right">';
   //pagination 1
   if (count($messages[0]) > 0) {
      echo _PAGE;
      if (($page-2) > 1) {
         echo '<a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=showcat&amp;catid='.$catid.'&amp;page=1').'">1</a>&nbsp;';
         echo "...&nbsp;";
      }
      for ($i=($page-2)<=0?1:($page-2); $i<= $page+2 && $i<= ceil($total/$threads_per_page); $i++) {
            if ($page == $i) {
                  echo "<strong>[$i]</strong>&nbsp;";
            }
            else {
               echo '<a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=showcat&amp;catid='.$catid.'&amp;page='.$i).'">'.$i.'</a>&nbsp;';
            }
       }
      if ($page+2 < ceil($total/$threads_per_page)) {
         echo "...&nbsp;";
         echo '<a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=showcat&amp;catid='.$catid.'&amp;page='.ceil($total/$threads_per_page)).'">'.ceil($total/$threads_per_page).'</a>';
      }
   }

      echo "      </td>";
      echo "   </tr>";


      //Get the category name for breadcrumb
      $database->setQuery("SELECT name,locked,review, parent from #__sb_categories where id='$catid'");
     $database->loadObject($objCatInfo);
     //Get the Category's parent category name for breadcrumb
     $database->setQuery("SELECT name,id FROM #__sb_categories WHERE id='$objCatInfo->parent'");
     $database->loadObject($objCatParentInfo);
     if ( $bPageTitle ) { $mainframe->setPageTitle( $objCatParentInfo->name.' - '.$objCatInfo->name.' - '.$sbConfig['board_title'] ); }
      //check if this forum is locked
      $forumLocked=$objCatInfo->locked;
      //check if this forum is subject to review
      $forumReviewed=$objCatInfo->review;
      echo "<tr>";

		/* RODAX SOFTWARE
      echo '<td><div class="pathway">'._GEN_PATHWAY;
      echo '<a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid).'" class="pathway">';
      echo $sbIcons['forumlist'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['forumlist'].'" border="0" alt="'._GEN_FORUMLIST.'" > > ' : _GEN_FORUMLIST;
      echo '</a> <img src="'.$mls.'/images/M_images/arrow.png" alt="" /><a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=listcat&amp;catid='.$objCatParentInfo->id).'" class="pathway">'.$objCatParentInfo->name.'</a> <img src="'.$mls.'/images/M_images/arrow.png" alt="" />  <strong> '.$objCatInfo->name.'</strong>  ';
		*/
      if ($forumLocked)
      {
         echo $sbIcons['forumlocked'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['forumlocked'].'" border="0" alt="'._GEN_LOCKED_FORUM.'" title="'._GEN_LOCKED_FORUM.'"/>' : '  <img src="'.$sbs.'/emoticons/lock.gif"  border="0"  width="15" height="15" alt="'._GEN_LOCKED_FORUM.'" title="'._GEN_LOCKED_FORUM.'">';
         $lockedForum=1;
      }else{echo "";}
      if ($forumReviewed)
      {
         echo $sbIcons['forummoderated'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['forummoderated'].'" border="0" alt="'._GEN_MODERATED.'" title="'._GEN_MODERATED.'"/>' : '  <img src="'.$sbs.'/emoticons/review.gif" border="0"  width="15" height="15" alt="'._GEN_MODERATED.'" title="'._GEN_MODERATED.'">';
         $moderatedForum=1;
      }else{echo "";}
      echo "</div></td></tr>";
      echo "   <tr>";
      echo "      <td>";
      
      //get time of last visit
      if ($settings[prevvisit]==0 && $previousVisit !=0)
      { $prevCheck= $previousVisit;}else{$prevCheck=$settings[prevvisit];}
        
      //get all readTopics in an array
      $readTopics="";
      $database->setQuery("SELECT readtopics FROM #__sb_sessions WHERE userid=$my->id");
      $readTopics=$database->loadResult();
	  if ( count ($readTopics) == 0 ) { $readTopics = "0"; } //make sure at least something is in there..
      //make it into an array
      $read_topics=explode(',',$readTopics);

      if (count($messages) > 0)
      {
      if ($view=="flat")
         include_once($sbp.'/flat.php');
      else
         include_once($sbp.'/thread.php');
      }
      else
      {
         echo "<p align=\"center\">";
         echo '<br /><br />'._SHOWCAT_NO_TOPICS;
         echo "</p>";
      }?>
            </td>
         </tr>
         <tr><td colspan="8" align="right">
         <?php
            //pagination 2
            if (count($messages[0]) > 0)
            {
               echo _PAGE;
               if (($page-2) > 1)
               {
                  echo '<a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=showcat&amp;catid='.$catid.'&amp;page=1').'">1</a>&nbsp;';
                  echo "...&nbsp;";
               }
               for ($i=($page-2)<=0?1:($page-2); $i<= $page+2 && $i<= ceil($total/$threads_per_page); $i++)
                  {
                     if ($page == $i)
                        {
                           echo "<strong>[$i]</strong>&nbsp;";
                        }
                        else
                        {
                           echo '<a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=showcat&amp;catid='.$catid.'&amp;page='.$i).'">'.$i.'</a>&nbsp;';
                        }
                  }


               if ($page+2 < ceil($total/$threads_per_page))
                  {
                     echo "...&nbsp;";
                     echo '<a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=showcat&amp;catid='.$catid.'&amp;page='.ceil($total/$threads_per_page)).'">'.ceil($total/$threads_per_page).'</a>';
                  }

             }         ?>
             <br />&nbsp;
            </td>
         </tr>
         <?php 
         if ($sbConfig['enableForumJump']){ ?>
               <tr>
               <td>
         		<form id="jumpto" name="jumpto" method="post" target="_self" action="<?php echo sefRelToAbs('index.php?option=com_simpleboard&Itemid='.$Itemid.'&func=showcat');?>" onsubmit="if(document.jumpto.catid.value < 2){return false;}">
         		<div style="width: 100%" align="right">
         		<input type="submit" name="Go" value="Go" class="button" />
         		<select name="catid" onchange="if(this.options[this.selectedIndex].value > 0){ forms['jumpto'].submit() }" class="button">
               <option value="" SELECTED><?php echo _GEN_FORUM_JUMP;?></option>
         		<?php

               
            	showChildren(0, "", $allow_forum);
         ?>
         </select>
         </div>
         </form>
         </td>
         </tr>
         <?php } ?>
         <tr>
            <?php
			if ((($sbConfig['pubwrite']==0 && $my_id != 0)||$sbConfig['pubwrite']==1) && ($topicLock==0 || ($topicLock==1 && $is_moderator))) {
	            if ($sbIcons['new_topic']){
    	           echo '<td align="right"><a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=post&amp;do=reply&amp;catid='.$catid).'"><img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['new_topic'].'" alt="'._GEN_POST_NEW_TOPIC.'" title="'._GEN_POST_NEW_TOPIC.'" border="0"></a></td>';
        	    }else{
            	   echo '<td align="right"><a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=post&amp;do=reply&amp;catid='.$catid).'">'._GEN_POST_NEW_TOPIC.'</a></td>';
	            }
			}?>	
         </tr>
      <?php
        if ($my->id != 0){
           echo '<tr><td colspan="6" align="left"><a href="'.sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=markThisRead&amp;catid='.$catid).'">';
           echo $sbIcons['markThisForumRead'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['markThisForumRead'].'" border="0" alt="'._GEN_MARK_THIS_FORUM_READ.'" title="'._GEN_MARK_THIS_FORUM_READ.'"/> - ' : _GEN_MARK_THIS_FORUM_READ;
           echo '</a></td></tr>';
           echo '<tr><td colspan="6">';
              echo '<span class="sb_new">';
              echo $sbIcons['unreadmessage'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['unreadmessage'].'" border="0" alt="'._GEN_UNREAD.'" title="'._GEN_UNREAD.'"/>' : $sbConfig['newChar'];
              echo '</span><small> - '._GEN_UNREAD.'</small><br /><span class="sb_notnew">';
              echo $sbIcons['readmessage'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['readmessage'].'" border="0" alt="'._GEN_NOUNREAD.'" title="'._GEN_NOUNREAD.'"/>' : $sbConfig['newChar'];
              echo '</span><small> - '._GEN_NOUNREAD.'</small></td></tr>';
        }      
      ?>
         
     <tr>
         <td colspan="5">
         <?php
         if ($topicLocked)
         {
            echo $sbIcons['topiclocked'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['topiclocked'].'" border="0" alt="'._GEN_LOCKED_TOPIC.'" title="'._GEN_LOCKED_TOPIC.'"><small> - '._GEN_LOCKED_TOPIC.'</small><br />': '<img src="'.$sbs.'/emoticons/lock.gif" width=15 height=15 alt="'._GEN_LOCKED_TOPIC.'" title="'._GEN_LOCKED_TOPIC.'"><small> - '._GEN_LOCKED_TOPIC.'</small><br />';
         }
         if ($topicSticky)
         {
            echo $sbIcons['topicsticky'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['topicsticky'].'" border="0" alt="'._GEN_ISSTICKY.'" title="'._GEN_ISSTICKY.'"><small> - '._GEN_ISSTICKY.'</small>' : '<img src="'.$sbs.'/emoticons/pushpin.gif" width=15 height=15 alt="'._GEN_ISSTICKY.'" title="'._GEN_ISSTICKY.'"><small> - '._GEN_ISSTICKY.'</small>';
         }
         ?>
         </td>
     </tr>
    
     <?php
      //get the Moderator list for display
      $database->setQuery("select * from #__sb_moderation left join #__users on #__users.id=#__sb_moderation.userid where #__sb_moderation.catid=$catid");
      $modslist=$database->loadObjectList();
?>
     <tr>
         <td colspan="5">

         <?php
            if ($lockedForum==1)
            {
               echo $sbIcons['forumlocked'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['forumlocked'].'" border="0" alt="'._GEN_LOCKED_FORUM.'" /><small> - '._GEN_LOCKED_FORUM.'</small><br />' : '  <img src="'.$sbs.'/emoticons/lock.gif" border="0"  width="15" height="15" alt="'._GEN_LOCKED_FORUM.'"><small> - '._GEN_LOCKED_FORUM.'</small><br />';
            }else{echo "";}
            if ($moderatedForum==1)
            {
               echo $sbIcons['forummoderated'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['forummoderated'].'" border="0" alt="'._GEN_MODERATED.'" /><small> - '._GEN_MODERATED.'</small>' : '  <img src="'.$sbs.'/emoticons/review.gif" border="0" width="15" height="15" alt="'._GEN_MODERATED.'"><small> - '._GEN_MODERATED.'</small>';
            }else{echo "";}
         ?>
            <?php if (count($modslist)>0)
            {
               echo '<br />'._GEN_MODERATORS.": ";
               foreach ($modslist as $mod)
               {
                  echo "&nbsp;<small><u>$mod->username</u></small>&nbsp;";
                }
            } ?>
         </td>
      </tr>
   </table>
   <?php
}
else{
   echo "You do not have access to this Forum"; 
   if ($sbConfig['enableForumJump']){ ?>
	<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tr><td width="100%" valign="top" align="right">
	<form id="jumpto" name="jumpto" method="post" target="_self" action="index.php" onsubmit="if(document.jumpto.catid.value < 2){return false;}">
	<div style="width: 100%" align="right">
	<input type="hidden" name="Itemid" value="<?php echo $Itemid;?>" />
	<input type="hidden" name="option" value="com_simpleboard" />
	<input type="hidden" name="func" value="showcat" />
	<input type="submit" name="Go" value="Go" />
   <select name="catid" onchange="if(this.options[this.selectedIndex].value > 0){ forms['jumpto'].submit() }">
   <option name="" SELECTED><?php echo _GEN_FORUM_JUMP;?></option>
	<?php
	showChildren(0, "", $allow_forum);
	?>
	</select>
	</div>
	</form>
	</td></tr>
	</table>
	
	<?php
   }
}

function showChildren($category,$prefix="", &$allow_forum) {
   global $database;
               
   $database->setQuery( "SELECT id, name, parent FROM #__sb_categories WHERE parent='$category'  and published='1' order by ordering");
   $forums = $database->loadObjectList();
   foreach ($forums as $forum)
   {
      if (in_array($forum->id, $allow_forum)) {
         echo ("<option value=\"{$forum->id}\">$prefix{$forum->name}</option>");
      }
   showChildren($forum->id,$prefix."&nbsp;&nbsp;", $allow_forum);
   }
}
?>