<?php
/*
Updates By FlareZone.com
*/
//? &#187;
//? &#171;
include("config.php");
include("core.php");
include("xhtmlfunctions.php");
header("Content-type: text/html; charset=ISO-8859-1");
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";

?>

<?php

$bcon = connectdb();
if (!$bcon)
{
    $pstyle = gettheme1("1");
    echo xhtmlhead("FlareZone (ERROR!)",$pstyle);
    echo "<p align=\"center\">";
    echo "<img src=\"images/exit.gif\" alt=\"*\"/><br/>";
    echo "ERROR! cannot connect to database<br/><br/>";
    echo "This error happens usually when backing up the database, please be patient, The site will be up any minute<br/><br/>";
    echo "<b>THANK YOU VERY MUCH</b>";
    echo "</p>";
  echo xhtmlfoot();
      exit();
}
$brws = explode("/",$_SERVER['HTTP_USER_AGENT']);
$ubr = $brws[0];
$uip = getip();
$action = $_GET["action"];
$sid = $_GET["sid"];
$page = $_GET["page"];
$who = $_GET["who"];

$uid = getuid_sid($sid);

cleardata();
if(isipbanned($uip,$ubr))
    {
      if(!isshield(getuid_sid($sid)))
      {
      $pstyle = gettheme1("1");
      echo xhtmlhead("FlareZone",$pstyle);
      echo "<p align=\"center\">";
      echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";
      echo "This IP address is blocked<br/>";
      echo "<br/>";
      echo "How ever we grant a shield against IP-Ban for our great users, you can try to see if you are shielded by trying to log-in, if you kept coming to this page that means you are not shielded, so come back when the ip-ban period is over<br/><br/>";
      $banto = mysql_fetch_array(mysql_query("SELECT  timeto FROM ibwf_penalties WHERE  penalty='2' AND ipadd='".$uip."' AND browserm='".$ubr."' LIMIT 1 "));
      //echo mysql_error();
      $remain =  $banto[0] - time() ;
      $rmsg = gettimemsg($remain);
      echo "Time to unblock the IP: $rmsg<br/><br/>";
      
      echo "</p>";
      echo "<p>";
  echo "<form action=\"login.php\" method=\"get\">";
  echo "Username:<br/> <input name=\"loguid\" format=\"*x\" size=\"8\" maxlength=\"30\"/><br/>";
  echo "Password:<br/> <input type=\"password\" name=\"logpwd\" size=\"8\" maxlength=\"30\"/><br/>";
echo "<input type=\"submit\" value=\"Login\"/>";
echo "</form>"; 
  echo "</p>";
  echo xhtmlfoot();
      exit();
      }
    }
if(($action != "") && ($action!="terms"))
{
    $uid = getuid_sid($sid);
    if((islogged($sid)==false)||($uid==0))
    {
      $pstyle = gettheme($sid);
      echo xhtmlhead("FlareZone",$pstyle);
      echo "<p align=\"center\">";
      echo "You are not logged in<br/>";
      echo "Or Your session has been expired<br/><br/>";
      echo "<a href=\"index.php\">Login</a>";
      echo "</p>";
  echo xhtmlfoot();
      exit();
    }
    
    
    
}
//echo isbanned($uid);
if(isbanned($uid))
    {
      $pstyle = gettheme($sid);
      echo xhtmlhead("FlareZone",$pstyle);
      echo "<p align=\"center\">";
      echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";
      echo "You are <b>Banned</b><br/>";
      $banto = mysql_fetch_array(mysql_query("SELECT timeto FROM ibwf_penalties WHERE uid='".$uid."' AND penalty='1'"));
	  $banres = mysql_fetch_array(mysql_query("SELECT lastpnreas FROM ibwf_users WHERE id='".$uid."'"));
	  
      $remain = $banto[0]- time() ;
      $rmsg = gettimemsg($remain);
      echo "Time to finish your penalty: $rmsg<br/><br/>";
	  echo "Ban Reason: $banres[0]";
      //echo "<a href=\"index.php\">Login</a>";
      echo "</p>";
  echo xhtmlfoot();
      exit();
    }
$res = mysql_query("UPDATE ibwf_users SET browserm='".$ubr."', ipadd='".$uip."' WHERE id='".getuid_sid($sid)."'");

////////////////////////////////////////MAIN PAGE
if($action=="main")
{

  $showicons = mysql_fetch_array(mysql_query("SELECT showicon FROM ibwf_users WHERE id='".$uid."'"));
  $showtime = mysql_fetch_array(mysql_query("SELECT showtime FROM ibwf_users WHERE id='".$uid."'"));
  $showshout = mysql_fetch_array(mysql_query("SELECT showshout FROM ibwf_users WHERE id='".$uid."'"));
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
  $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));
  if($showicons[0]=="1"){
  addvisitor();
  addonline(getuid_sid($sid),"Main Page - xHTML","index.php?action=$action");
  //saveuinfo($sid);
  $pstyle = gettheme($sid);
  echo xhtmlhead("FlareZone",$pstyle);
  echo "<p align=\"center\">";
  if($showtime[0]=="1"){
  echo "<small><a href=\"time.php?sid=$sid\">".date("D d M y - H:i",time() )."</a></small><br/>";
  }
  
$TimeZone="0"; ////Change the TimeZone accordingly!
$New_Time = time() + ($TimeZone * 60 * 60);

$show_date=date("D dS F, Y",$New_Time); 
$show_time=date("H:i",$New_Time); 
$Hour=date("G",$New_Time);


  echo "<img src=\"images/logo.gif\" alt=\"FlareZone\"/><br/>";
  echo "</p>";
  $nick = getnick_sid($sid);
if ($Hour <= 4) { echo "<h5 align=\"center\">Hello $nick you night owl!</h5><br/>"; } 

else if ($Hour <= 11) { echo "<h5 align=\"center\">Good morning $nick!</h5><br/>"; } 

else if ($Hour <= 12) { echo "<h5 align=\"center\">Enjoy your lunch $nick!</h5><br/>"; }

else if ($Hour <= 17) { echo "<h5 align=\"center\">Good afternoon $nick!</h5><br/>"; } 

else if ($Hour <= 24) { echo "<h5 align=\"center\">Good Evening $nick!</h5><br/>"; }

  echo "<p align=\"center\"><small>";
  $fmsg = htmlspecialchars(getfmsg());
  echo "<b><u><font color=\"0000FF\">Site Announcement</font></u></b><br/>";
  echo "<marquee><font color=\"3366FF\">$fmsg</font></marquee><br/>";
  echo "<font color=\"0000FF\">+++++++++++++++++</font><br/>";
  include("popups.php");
  echo "<br/><a href=\"index.php?action=main&amp;sid=$sid\"><i>REFRESH</i></a><br/>";
  echo "</small></p>";
  echo "<div class=\"mblock1\">";
  echo "<h5 align=\"center\">Menu</h5><br/>";
  echo "<small>";
  
 /////inbox data
  $new_gm = getnewgml(getuid_sid($sid));
  if($new_gm>0)
  {
  echo "<a href=\"rwgmail.php?sid=$sid\">&#187;G-Mail(".$new_gm.")</a><br/>";
  }   
  
  $tmsg = getpmcount(getuid_sid($sid));
  $umsg = getunreadpm(getuid_sid($sid));
  
  
  if($umsg==1)
  {
  echo "1. <a accesskey=\"1\" href=\"inbox.php?action=folderunread&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/inbox2.gif\" alt=\"*\"/>Inbox</a>($umsg New Message)<br/>";
  }
  if($umsg>1)
  {
  echo "1. <a accesskey=\"1\" href=\"inbox.php?action=folderunread&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/inbox2.gif\" alt=\"*\"/>Inbox</a>($umsg New Messages)<br/>";
  }  
  if($umsg==0)
  {
  echo "1. <a accesskey=\"1\" href=\"inbox.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/inbox1.gif\" alt=\"*\"/>Inbox</a>($tmsg)<br/>";
  } 
  $uid = getuid_sid($sid);
  $mybuds = getnbuds($uid);
  $onbuds = getonbuds($uid);
  echo "2. <a accesskey=\"2\" href=\"lists.php?action=buds&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/buddies.gif\" alt=\"*\"/>Buddies</a>($onbuds|$mybuds)";
  $reqs = getnreqs($uid);
  if($reqs>0)
  {
    echo ": <a href=\"lists.php?action=reqs&amp;sid=$sid\">$reqs</a>";
  }
  $chs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_chonline"));
  echo "<br/>3. <a accesskey=\"3\" href=\"index.php?action=chat&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/chat.gif\" alt=\"*\"/>Chatrooms</a>($chs[0])<br/>";
  echo "4. <a accesskey=\"4\" href=\"index.php?action=formmenu&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/forum.gif\" alt=\"*\"/>Forums</a><br/>";
  $chs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubs"));
  echo "5. <a accesskey=\"5\" href=\"index.php?action=clmenu&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/clubs.gif\" alt=\"*\"/>Clubs</a>($chs[0])<br/>";
  echo "6. <a accesskey=\"6\" href=\"index.php?action=funm&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/games.gif\" alt=\"*\"/>Fun/Games</a><br/>";
  echo "7. <a accesskey=\"7\" href=\"mshop.php?action=main&amp;sid=$sid\"><img src=\"images/shop.gif\" alt=\"*\"/>FlareZone Shop</a><br/>";
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_vault"));
  echo "8. <a accesskey=\"8\" href=\"lists.php?action=vault&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/downloads.gif\" alt=\"*\"/>Downloads</a>($noi[0])<br/>";
    $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_usergallery"));
  echo "9. <a accesskey=\"9\" href=\"usergallery.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/usergallery.gif\" alt=\"*\"/>User Gallery</a>($noi[0])<br/>";
  echo "10. <a href=\"index.php?action=cpanel&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/cpanel.gif\" alt=\"*\"/>CPanel</a><br/>";
  echo "11. <a href=\"index.php?action=stats&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/stats.gif\" alt=\"*\"/>Site Stats</a><br/>";
  echo "12. <a href=\"index.php?action=partners&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/partners.gif\" alt=\"*\"/>Partners</a><br/>";
  echo "</small>";
  echo "</div>";
  if($showshout[0]=="1"){
  echo "<br/>";
  echo "<br/>";
  echo "<div class=\"mblock2\">";
  echo "<h5 align=\"center\">ShoutBox</h5><br/>";
  echo "<small>";
  echo getshoutbox($sid);
  echo "</small>";
  echo "</div>";
  }
  echo "<br/>";
  echo "<br/>";
  echo "<div class=\"mblock2\">";
  echo "<h5 align=\"center\">Online Stats</h5><br/>";
  echo "<small>";
  $memberonline = "<u>0.Members:</u> <a accesskey=\"0\" href=\"index.php?action=online&amp;sid=$sid\">".getnumonline()."</a>";
  echo "$memberonline";
  $timeout = time()  - 180;
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE perm>'0' AND lastact>'".$timeout."'"));
  echo "<u>*.Staff:</u> <a accesskey=\"*\" href=\"index.php?action=stfol&amp;sid=$sid\">".$noi[0]."</a>";
  $timeout = time()  - 180;
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE specialid>'0' AND lastact>'".$timeout."'"));
  echo "<u>#.V.I.P's:</u> <a accesskey=\"#\" href=\"index.php?action=vipol&amp;sid=$sid\">".$noi[0]."</a>";
  echo "</small>";
  echo "</div>";
  echo "<br/>";
  echo "<br/>";  
  echo "<p><small>";
  if (isowner(getuid_sid($sid)))
  {
  echo "<div class=\"mblock2\">";
  echo "<h5 align=\"center\">Owner/Admins/Mods</h5><br/>";
  echo "<a href=\"index.php?action=ownercp&amp;sid=$sid\">&#187;Owner CP</a><br/>";
  }
  if (isadmin(getuid_sid($sid)))
  {
  echo "<a href=\"index.php?action=admincp&amp;sid=$sid\">&#187;Admin CP</a><br/>";
  }
  if(ismod($uid))
  {
  echo "<a href=\"modcp.php?action=main&amp;sid=$sid\">&#187;Mod R/L</a><br/>";
  echo "<h5 align=\"center\">I Would Apreciate It If Only Staff Click These Links</h5><br/>";
  echo "</div>";
  }
  echo "</small></p>";
  echo "<br/>";
  echo "<br/>";
  echo "<p align=\"center\"><small>";
  echo "<a href=\"copyrights.php\">&#169;FlareZone 2007 - 2023</a><br/>";
  echo "<font color=\"0000FF\">=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=</font><br/>";
  echo "<font color=\"3366FF\">Original Script By Irishblaze(lavalair.net)</font><br/>";
  echo "<font color=\"0000FF\">=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=</font><br/>";
  echo "<font color=\"3366FF\">Script Updates By FlareBoy</font><br/>";
  echo "<font color=\"0000FF\">=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=</font><br/>";
  echo "<a href=\"index.php?action=compact&amp;sid=$sid\">Switch To Compact Mode</a><br/>";
  echo "</small></p>";
  echo xhtmlfoot();
  
 }else
  if($showicons[0]=="0"){
  addvisitor();
  addonline(getuid_sid($sid),"Main Page - xHTML","index.php?action=$action");
  //saveuinfo($sid);
  $pstyle = gettheme($sid);
  echo xhtmlhead("FlareZone",$pstyle);
  echo "<p align=\"center\">";
  if($showtime[0]=="1"){
  echo "<small><a href=\"time.php?sid=$sid\">".date("D d M y - H:i",time() )."</a></small><br/>";
  }
  
$TimeZone="0"; ////Change the TimeZone accordingly!
$New_Time = time() + ($TimeZone * 60 * 60);

$show_date=date("D dS F, Y",$New_Time); 
$show_time=date("H:i",$New_Time); 
$Hour=date("G",$New_Time);


  echo "<img src=\"images/themes/$themeimageset[0]/logo.gif\" alt=\"FlareZone\"/><br/>";
  echo "</p>";
  $nick = getnick_sid($sid);
if ($Hour <= 4) { echo "<h5 align=\"center\">Hello $nick you night owl!</h5><br/>"; } 

else if ($Hour <= 11) { echo "<h5 align=\"center\">Good morning $nick!</h5><br/>"; } 

else if ($Hour <= 12) { echo "<h5 align=\"center\">Enjoy your lunch $nick!</h5><br/>"; }

else if ($Hour <= 17) { echo "<h5 align=\"center\">Good afternoon $nick!</h5><br/>"; } 

else if ($Hour <= 24) { echo "<h5 align=\"center\">Good Evening $nick!</h5><br/>"; }

  echo "<p align=\"center\"><small>";
  $fmsg = htmlspecialchars(getfmsg());
  echo "$fmsg<br/>";
  echo "</small></p>";
  echo "<div class=\"mblock1\">";
  echo "<center><b><u>Menu</u></b></center><br/>";
  echo "<small>";
  
 /////inbox data
  $new_gm = getnewgml(getuid_sid($sid));
  if($new_gm>0)
  {
  echo "<a href=\"rwgmail.php?sid=$sid\">&#187;G-Mail(".$new_gm.")</a><br/>";
  }   
  
  $tmsg = getpmcount(getuid_sid($sid));
  $umsg = getunreadpm(getuid_sid($sid));
  
  if($umsg==1)
  {
  echo "<a href=\"inbox.php?action=main&amp;sid=$sid\">&#187;Inbox</a>($umsg New Message)<br/>";
  }
  if($umsg>1)
  {
  echo "<a href=\"inbox.php?action=main&amp;sid=$sid\">&#187;Inbox</a>($umsg New Messages)<br/>";
  }  
  if($umsg==0)
  {
  echo "<a href=\"inbox.php?action=main&amp;sid=$sid\">&#187;Inbox</a>($tmsg)<br/>";
  } 
  $uid = getuid_sid($sid);
  $mybuds = getnbuds($uid);
  $onbuds = getonbuds($uid);
  echo "<a href=\"lists.php?action=buds&amp;sid=$sid\">&#187;Buddies</a>($onbuds|$mybuds)";
  $reqs = getnreqs($uid);
  if($reqs>0)
  {
    echo ": <a href=\"lists.php?action=reqs&amp;sid=$sid\">$reqs</a>";
  }
  $chs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_chonline"));
  echo "<br/><a href=\"index.php?action=chat&amp;sid=$sid\">&#187;Chatrooms</a>($chs[0])<br/>";
  echo "<a href=\"index.php?action=formmenu&amp;sid=$sid\">&#187;Forums</a><br/>";
  $chs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubs"));
  echo "<a href=\"index.php?action=clmenu&amp;sid=$sid\">&#187;Clubs</a>($chs[0])<br/>";
  echo "<a href=\"index.php?action=funm&amp;sid=$sid\">&#187;Fun/Games</a><br/>";
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_vault"));
  echo "<a href=\"lists.php?action=vault&amp;sid=$sid\">&#187;Downloads</a>($noi[0])<br/>";
      $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_usergallery"));
  echo "<a href=\"usergallery.php?action=main&amp;sid=$sid\">&#187;User Gallery</a>($noi[0])<br/>";
  echo "<a href=\"index.php?action=cpanel&amp;sid=$sid\">&#187;CPanel</a><br/>";
  echo "<a href=\"index.php?action=stats&amp;sid=$sid\">&#187;Site Stats</a><br/>";
  echo "<a href=\"index.php?action=partners&amp;sid=$sid\">&#187;Partners</a>(2)<br/>";
  echo "</small>";
  echo "</div>";
  if($showshout[0]=="1"){
  echo "<br/>";
  echo "<br/>";
  echo "<div class=\"mblock2\">";
  echo "<center><b><u>ShoutBox</u></b></center><br/>";
  echo "<small>";
  echo getshoutbox($sid);
  echo "</small>";
  echo "</div>";
  }
  echo "<br/>";
  echo "<br/>";
  echo "<div class=\"mblock2\">";
  echo "<center><b><u>Online Stats</u></b></center><br/>";
  echo "<small>";
  $memberonline = "<b>Members Online:</b> <a href=\"index.php?action=online&amp;sid=$sid\">".getnumonline()."</a><br/>";
  echo "$memberonline";
  $timeout = time()  - 180;
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE perm>'0' AND lastact>'".$timeout."'"));
  echo "<b>Staff Online:</b> <a href=\"index.php?action=stfol&amp;sid=$sid\">".$noi[0]."</a><br/>";
  $timeout = time()  - 180;
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE specialid>'0' AND lastact>'".$timeout."'"));
  echo "<b>V.I.P's Online:</b> <a href=\"index.php?action=vipol&amp;sid=$sid\">".$noi[0]."</a><br/>";
  echo "</small>";
  echo "</div>";
  echo "<br/>";
  echo "<br/>";  
  echo "<p><small>";
   if (isadmin(getuid_sid($sid)))
  {
    echo "<a href=\"index.php?action=admincp&amp;sid=$sid\">&#187;Admin CP</a><br/>";
  }
  
  if(ismod($uid))
  {
    $tnor = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE reported='1'"));
    $tot = $tnor[0];
    $tnor = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_posts WHERE reported='1'"));
    $tot += $tnor[0];
    $tnor = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_topics WHERE reported='1'"));
    $tot += $tnor[0];
    $tnol = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_mlog"));
    $tol = $tnol[0];
    if($tol+$tot>0)
    {
    echo "<a href=\"modcp.php?action=main&amp;sid=$sid\">&#187;Mod R/L</a>($tot|$tol)<br/>";
    }

  }
  echo "</small></p>";
  echo "<br/>";
  echo "<br/>";
  echo "<p align=\"center\"><small>";
  echo "&#169; FlareZone 2007-2010<br/>";
  echo "<a href=\"../index.php?action=main&amp;sid=$sid\">WML Version</a><br/>";
  echo "<a href=\"index.php?action=logout&amp;sid=$sid\">Log Out</a>";
  echo "</small></p>";
  echo xhtmlfoot();
 }
}

else if($action=="clmop")
{
    $clid = $_GET["clid"];
    $who = $_GET["who"];
    addonline(getuid_sid($sid),"Moderating Club Member - xHTML","");
          $pstyle = gettheme($sid);
      echo xhtmlhead("Moderate Member",$pstyle);
    echo "<p align=\"center\">";
    $whnick = getnick_uid($who);
    echo "<b>$whnick</b>";
    echo "</p>";
    echo "<p>";
    $exs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubmembers WHERE uid='".$who."' AND clid=".$clid.""));
$cow = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubs WHERE owner='".$uid."' AND id=".$clid.""));
if($exs[0]>0 && $cow[0]>0)
{
    echo "<a href=\"genproc.php?action=dcm&amp;sid=$sid&amp;who=$who&amp;clid=$clid\">&#187;Kick $whnick out</a><br/>";
    echo "<a href=\"index.php?action=gcp&amp;sid=$sid&amp;who=$who&amp;clid=$clid\">&#187;$whnick's Club Points</a><br/>";
    echo "<a href=\"index.php?action=gpl&amp;sid=$sid&amp;who=$who&amp;clid=$clid\">&#187;Give $whnick Credits</a><br/>";
    }else{
      echo "<img src=\"images/notok.gif\" alt=\"X\"/>Missing Info!";
    }
    echo "</p>";

    echo "<p align=\"center\">";

    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

else if($action=="gcp")
{
    $clid = $_GET["clid"];
    $who = $_GET["who"];
    addonline(getuid_sid($sid),"Moderating Club Member - xHTML","");
              $pstyle = gettheme($sid);
      echo xhtmlhead("Moderate Member",$pstyle);
    echo "<p align=\"center\">";
    $whnick = getnick_uid($who);
    echo "<b>$whnick</b>";
    echo "</p>";
    echo "<p>";
    $exs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubmembers WHERE uid='".$who."' AND clid=".$clid.""));
$cow = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubs WHERE owner='".$uid."' AND id=".$clid.""));
if($exs[0]>0 && $cow[0]>0)
{
echo "<form action=\"genproc.php?action=gcp&amp;sid=$sid&amp;who=$who&amp;clid=$clid\" method=\"post\">";
    echo "Action: <select name=\"giv\">";
    echo "<option value=\"1\">Add</option>";
    echo "<option value=\"0\">Subtract</option>";
    echo "</select><br/>";
    echo "Points: <input name=\"pnt\" format=\"*N\" size=\"2\" maxlength=\"2\"/><br/>";
echo "<input type=\"submit\" value=\"GO\"/>";
echo "</form>";
    }else{
      echo "<img src=\"images/notok.gif\" alt=\"X\"/>Missing Info!";
    }
    echo "</p>";

    echo "<p align=\"center\">";

    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

else if($action=="gpl")
{
    $clid = $_GET["clid"];
    $who = $_GET["who"];
    addonline(getuid_sid($sid),"Moderating Club Member - xHTML","");
          $pstyle = gettheme($sid);
      echo xhtmlhead("Moderate Member",$pstyle);
    echo "<p align=\"center\">";
    $whnick = getnick_uid($who);
    echo "<b>$whnick</b>";
    echo "</p>";
    echo "<p>";
    $exs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubmembers WHERE uid='".$who."' AND clid=".$clid.""));
$cow = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubs WHERE owner='".$uid."' AND id=".$clid.""));
if($exs[0]>0 && $cow[0]>0)
{
    echo "<small><img src=\"images/point.gif\" alt=\"!\"/>You can only give Credits, these are real Credits, you can't subtract Credits<br/>";
    $cpl = mysql_fetch_array(mysql_query("SELECT plusses FROM ibwf_clubs WHERE id='".$clid."'"));
    echo "<img src=\"images/point.gif\" alt=\"!\"/>Your club credits is $cpl[0]<br/>";
    echo "<img src=\"images/point.gif\" alt=\"!\"/>Do not abuse the giving of Credits, your club could be deleted<br/></small><br/>";
    
echo "<form action=\"genproc.php?action=gpl&amp;sid=$sid&amp;who=$who&amp;clid=$clid\" method=\"post\">";
echo "Credits: <input name=\"pnt\" format=\"*N\" size=\"2\" maxlength=\"2\"/><br/>";
echo "<input type=\"submit\" value=\"GO\"/>";    
echo "</form>";
  
    }else{
      echo "<img src=\"images/notok.gif\" alt=\"X\"/>Missing Info!";
    }
    echo "</p>";

    echo "<p align=\"center\">";
    
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}
///////////////////////////////////Control Panel

else if($action=="cpanel")
{
    addonline(getuid_sid($sid),"Control Panel - xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("Control Panel",$pstyle);
    echo "<p align=\"center\">";
    echo "<img src=\"images/cpanel.gif\" alt=\"CPanel\"/><br/>";
    include("popups.php");
    echo "<div class=\"mblock2\">";
    echo "<h5 align=\"center\">Control Panel</h5><br/>";    
    echo "</p>";
    echo "<p><small>";
  $tmsg = getpmcount(getuid_sid($sid));
  $umsg = getunreadpm(getuid_sid($sid));
  
  if($umsg==1)
  {
  echo "<a href=\"inbox.php?action=main&amp;sid=$sid\">&#187;Inbox($umsg New Message)</a><br/>";
  }
  if($umsg>1)
  {
  echo "<a href=\"inbox.php?action=main&amp;sid=$sid\">&#187;Inbox($umsg New Messages)</a><br/>";
  }  
  if($umsg==0)
  {
  echo "<a href=\"inbox.php?action=main&amp;sid=$sid\">&#187;Inbox($tmsg)</a><br/>";
  } 
  $uid =getuid_sid($sid);
  //$new_gm = getnewgml($uid);
  echo "<a href=\"index.php?action=rwidc&amp;sid=$sid\">&#187;FlareZone ID card.</a><br/>";
  echo "<a href=\"index.php?action=myclub&amp;sid=$sid\">&#187;My Clubs</a><br/>";
  echo "<a href=\"index.php?action=viewuser&amp;sid=$sid&amp;who=$uid\">&#187;Profile</a><br/>";
  echo "<a href=\"index.php?action=uset&amp;sid=$sid\">&#187;User Settings</a><br/>";
  echo "<a href=\"index.php?action=uxset&amp;sid=$sid\">&#187;Profile Settings</a><br/>";
  echo "<a href=\"index.php?action=stset&amp;sid=$sid\">&#187;Site Settings</a><br/>";
  echo "<a href=\"index.php?action=pws&amp;sid=$sid\">&#187;Personal Wap site</a><br/>";
  echo "<a href=\"index.php?action=search&amp;sid=$sid\">&#187;Search</a><br/>";
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_vault WHERE uid='".$uid."'"));
  echo "<a href=\"lists.php?action=vault&amp;sid=$sid&amp;who=$uid\">&#187;My Vault($noi[0])</a><br/>";
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_ignore WHERE name='".$uid."'"));
  echo "<a href=\"lists.php?action=ignl&amp;sid=$sid\">&#187;Ignore List($noi[0])</a><br/>";
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_gbook WHERE gbowner='".$uid."'"));
  echo "<a href=\"lists.php?action=gbook&amp;sid=$sid&amp;who=$uid\">&#187;Guestbook($noi[0])</a><br/>";
  echo "<a href=\"index.php?action=poll&amp;sid=$sid\">&#187;My Poll</a><br/>";
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_blogs WHERE bowner='".$uid."'"));
  echo "<a href=\"lists.php?action=blogs&amp;sid=$sid&amp;who=$uid\">&#187;Blogs($noi[0])</a><br/>";
  echo "<a href=\"lists.php?action=chmood&amp;sid=$sid\">&#187;Chatmood</a><br/>";
  echo "<a href=\"status.php?action=status&amp;sid=$sid\">&#187;Status</a><br/>";
  echo "<a href=\"lists.php?action=smilies&amp;sid=$sid\">&#187;Smilies</a><br/>";
  echo "<a href=\"lists.php?action=avatars&amp;sid=$sid\">&#187;Avatars</a><br/>";  
  echo "<a href=\"lists.php?action=ecards&amp;sid=$sid\">&#187;E-Cards</a><br/>";
  echo "<a href=\"lists.php?action=bbcode&amp;sid=$sid\">&#187;BBCode</a><br/>";
  echo "<a href=\"lists.php?action=faqs&amp;sid=$sid\">&#187;F.A.Qs</a><br/>";
  echo "<a href=\"help.php?sid=$sid\">&#187;Help Menu</a><br/>";
  echo "<a href=\"index.php?action=terms&amp;sid=$sid\">&#187;Terms of use</a><br/>";
  echo "</div>";
  echo "</small></p>";
    
    echo "<p align=\"center\">";
    
    
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

///////////////////////////////////Control Panel

else if($action=="clmenu")
{
    addonline(getuid_sid($sid),"Clubs Menu - xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("Clubs Menu",$pstyle);
    echo "<p align=\"center\">";
    echo "<div class=\"mblock2\">";
    echo "<h5 align=\"center\">Clubs Menu</h5><br/>";
    echo "</p>";
    echo "<p><small>";
    $myid = getuid_sid($sid);
  echo "<a href=\"index.php?action=clubs&amp;sid=$sid\">&#187;All Clubs</a><br/>";
  echo "<a href=\"index.php?action=myclub&amp;sid=$sid\">&#187;My Clubs</a><br/>";
  echo "<a href=\"lists.php?action=clm&amp;who=$myid&amp;sid=$sid&amp;who=$uid\">&#187;Clubs I'm member of</a><br/>";
  echo "<a href=\"lists.php?action=pclb&amp;sid=$sid&amp;who=$uid\">&#187;Clubs By popularity</a><br/>";
  echo "<a href=\"lists.php?action=aclb&amp;sid=$sid&amp;who=$uid\">&#187;Clubs By Activity</a><br/>";
  //echo "<a href=\"lists.php?action=rclb&amp;sid=$sid&amp;who=$uid\">&#187;5 random clubs</a><br/><br/>";
  $ncl = mysql_fetch_array(mysql_query("SELECT id, name FROM ibwf_clubs ORDER BY created DESC LIMIT 1"));
  echo "Newest Club: <a href=\"index.php?action=gocl&amp;clid=$ncl[0]&amp;sid=$sid\">".htmlspecialchars($ncl[1])."</a><br/>";
/*
  echo "<a href=\"index.php?action=uset&amp;sid=$sid\">&#187;Settings</a><br/>";
  echo "<a href=\"index.php?action=uxset&amp;sid=$sid\">&#187;Extended Settings</a><br/>";
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_vault WHERE uid='".$uid."'"));
  echo "<a href=\"lists.php?action=vault&amp;sid=$sid&amp;who=$uid\">&#187;My Vault($noi[0])</a><br/>";
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_ignore WHERE name='".$uid."'"));
  echo "<a href=\"lists.php?action=ignl&amp;sid=$sid\">&#187;Ignore List($noi[0])</a><br/>";
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_gbook WHERE gbowner='".$uid."'"));
  echo "<a href=\"lists.php?action=gbook&amp;sid=$sid&amp;who=$uid\">&#187;Guestbook($noi[0])</a><br/>";
  echo "<a href=\"index.php?action=poll&amp;sid=$sid\">&#187;My Poll</a><br/>";
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_blogs WHERE bowner='".$uid."'"));
  echo "<a href=\"lists.php?action=blogs&amp;sid=$sid&amp;who=$uid\">&#187;Blogs($noi[0])</a><br/>";
  echo "<a href=\"lists.php?action=chmood&amp;sid=$sid\">&#187;Chatmood</a><br/>";
  echo "<a href=\"lists.php?action=smilies&amp;sid=$sid\">&#187;Smilies</a><br/>";
  echo "<a href=\"lists.php?action=avatars&amp;sid=$sid\">&#187;Avatars</a><br/>";
  echo "<a href=\"lists.php?action=bbcode&amp;sid=$sid\">&#187;BBCode</a><br/>";
  echo "</div>";
*/
  echo "</small></p>";

    echo "<p align=\"center\">";

    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}


else if($action=="rwidc")
{
    addonline(getuid_sid($sid),"FlareZone ID - xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("FlareZone ID",$pstyle);
    echo "<p align=\"center\">";
    echo "<div class=\"mblock2\">";
    echo "<h5 align=\"center\">FlareZone ID Card</h5><br/>";
    $uid = getuid_sid($sid);
    echo "<img src=\"http://FlareZone.com/rwidc.php?id=$uid\" alt=\"M id\"/><br/><br/>";
    echo "This ID card is updated automatically everytime someone request it, the source to your card is http://FlareZone.com/rwidc.php?id=$uid<br/><br/>";
    echo "you can use it as an avatar in other sites<br/><br/>";
    echo "To look at others cards view the user profile then go to more information&gt;FlareZone ID card.";
    echo "</div>";
    echo "</p>";
    echo "<p align=\"center\">";
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

///////////////////////////////////My Clubs

else if($action=="myclub")
{
    addonline(getuid_sid($sid),"My Clubs - xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("My Clubs",$pstyle);
    echo "<p align=\"center\">";
    include("popups.php");
    echo "<div class=\"mblock2\">";
    echo "<h5 align=\"center\">My Clubs</h5><br/>";
    echo "</p>";
    echo "<p>";
    $uid = getuid_sid($sid);
    if(getplusses($uid)<500)
    {
      echo "Clubs are small communities that users can create, every community should have things in common, for example a community for goths, blink 182 fans, rappers and anythin g you can think of, currently people who have more than 500 Credits only can create clubs, every user can create up to 5 clubs, to get Credits post in forms, or invite friends";
    }else{
      $uclubs = mysql_query("SELECT id, name FROM ibwf_clubs WHERE owner='".$uid."'");
      while($club=mysql_fetch_array($uclubs))
      {
        echo "<a href=\"index.php?action=gocl&amp;clid=$club[0]&amp;sid=$sid\">$club[1]</a>";
        echo ", <a href=\"genproc.php?action=dlcl&amp;clid=$club[0]&amp;sid=$sid\">[DELETE]</a><br/><br/>";
      }
      $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubs WHERE owner='".$uid."'"));
      if($noi[0]<5)
      {
      echo "<a href=\"index.php?action=addcl&amp;sid=$sid\">Add Club</a>";
      }
    }
  echo "</p>";
  echo "</div>";
    echo "<p align=\"center\">";
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

///////////////////////////////////My Clubs

else if($action=="clubs")
{
    addonline(getuid_sid($sid),"Clubs List - xHTML","");
    
    $pstyle = gettheme($sid);
    echo xhtmlhead("Clubs List",$pstyle);
    echo "<p align=\"center\">";
    echo "<b>Clubs List</b>";
    echo "</p>";
    //////ALL LISTS SCRIPT <<

    if($page=="" || $page<=0)$page=1;
    $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubs"));
    $num_items = $noi[0]; //changable
    $items_per_page= 5;
    $num_pages = ceil($num_items/$items_per_page);
    if(($page>$num_pages)&&$page!=1)$page= $num_pages;
    $limit_start = ($page-1)*$items_per_page;

    //changable sql

        $sql = "SELECT id, name, owner, description, created FROM ibwf_clubs ORDER BY created DESC LIMIT $limit_start, $items_per_page";


    echo "<p>";
    $items = mysql_query($sql);
    if(mysql_num_rows($items)>0)
    {
    while ($item = mysql_fetch_array($items))
    {
        $item[1]=htmlspecialchars($item[1]);
        $mems = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubmembers WHERE clid='".$item[0]."' AND accepted='1'"));
      $lnk = "<a href=\"index.php?action=gocl&amp;clid=$item[0]&amp;sid=$sid\">$item[1]($mems[0])</a> <small>Owner: <a href=\"index.php?action=viewuser&amp;who=$item[2]&amp;sid=$sid\">".getnick_uid($item[2])."</a></small>";
      echo "$lnk<br/><small>";
      echo htmlspecialchars($item[3])."<br/>Creation Date: (".date("d/m/y", $item[4]).")</small><br/><br/>";
    }
    }
    echo "</p>";
    echo "<p align=\"center\">";
    if($page>1)
    {
      $ppage = $page-1;
      echo "<a href=\"index.php?action=$action&amp;page=$ppage&amp;sid=$sid&amp;view=$view\">&#171;PREV</a> ";
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
      echo "<a href=\"index.php?action=$action&amp;page=$npage&amp;sid=$sid&amp;view=$view\">Next&#187;</a>";
    }
    echo "<br/>$page/$num_pages<br/>";
    if($num_pages>2)
    {
     
        $rets = "<form action=\"index.php\" method=\"get\">";
      $rets .= "Jump to page<input name=\"page\" format=\"*N\" size=\"3\"/>";
        $rets .= "<input type=\"submit\" value=\"GO\"/>";
        $rets .= "<input type=\"hidden\" name=\"action\" value=\"$action\"/>";
        $rets .= "<input type=\"hidden\" name=\"sid\" value=\"$sid\"/>";
        $rets .= "</form>";

        echo $rets;
  
    }
    echo "</p>";
    echo "<p align=\"center\">";
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

else if($action=="gocl")
{
  $clid = $_GET["clid"];
  $clinfo = mysql_fetch_array(mysql_query("SELECT name, owner, description, rules, logo, plusses, created FROM ibwf_clubs WHERE id='".$clid."'"));
    addonline(getuid_sid($sid),"Viewing Club - xHTML","");
    $clnm = htmlspecialchars($clinfo[0]);
        $pstyle = gettheme($sid);
    echo xhtmlhead($clnm,$pstyle);
    echo "<p align=\"center\">";
    echo "<small><b>$clnm</b></small><br/>";
    if(trim($clinfo[4])=="")
    {
      echo "<img src=\"images/logo.jpg\" alt=\"logo\"/>";
    }else{
        echo "<img src=\"$clinfo[4]\" alt=\"logo\"/>";
    }
    echo "</p>";
    echo "<p><small>";
    echo "Club ID: <b>$clid</b><br/>";
    $uid = getuid_sid($sid);
    $cango = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubmembers WHERE clid='".$clid."' AND uid='".$uid."' AND accepted='1'"));
    echo "Owner: <a href=\"index.php?action=viewuser&amp;who=$clinfo[1]&amp;sid=$sid\">".getnick_uid($clinfo[1])."</a><br/>";
      $mems = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubmembers WHERE clid='".$clid."' AND accepted='1'"));
      echo "Members: <a href=\"lists.php?action=clmem&amp;sid=$sid&amp;clid=$clid\">$mems[0]</a><br/>";
      echo "Created On: ".date("d/m/y", $clinfo[6])."<br/>";
      echo "Credits: $clinfo[5]<br/>";
      $fid = mysql_fetch_array(mysql_query("SELECT id FROM ibwf_forums WHERE clubid='".$clid."'"));
      $rid = mysql_fetch_array(mysql_query("SELECT id FROM ibwf_rooms WHERE clubid='".$clid."'"));
      $tps = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_topics WHERE fid='".$fid[0]."'"));
      $pss = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_posts a INNER JOIN ibwf_topics b ON a.tid = b.id WHERE b.fid='".$fid[0]."'"));
      
    if(($cango[0]>0)||ismod($uid))
    {
        $noa = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_announcements WHERE clid='".$clid."'"));
        echo "<br/><a href=\"lists.php?action=annc&amp;sid=$sid&amp;clid=$clid\"><img src=\"images/annc.gif\" alt=\"!\"/>Announcements($noa[0])</a><br/>";
        $noa = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_chat WHERE rid='".$rid[0]."'"));
        echo "<a href=\"chat.php?sid=$sid&amp;rid=$rid[0]\"><img src=\"images/chat.gif\" alt=\"*\"/>$clnm Chat($noa[0])</a><br/>";
        echo "<a href=\"index.php?action=viewfrm&amp;sid=$sid&amp;fid=$fid[0]\"><img src=\"images/1.gif\" alt=\"*\"/>$clnm Forum($tps[0]/$pss[0])</a><br/><br/>";
		$ismem = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubmembers WHERE clid='".$clid."' AND uid='".getuid_sid($sid)."'"));
		
		if($ismem[0]>0)
		{
			//unjoin 
			if($clinfo[1]!=$uid)
			{
				echo "<a href=\"genproc.php?action=unjc&amp;sid=$sid&amp;clid=$clid\">Unjoin Club</a>";
			}
		}else{
			echo "<a href=\"genproc.php?action=reqjc&amp;sid=$sid&amp;clid=$clid\">Join Now!</a>";
		}
		if(isadmin(getuid_sid($sid)))
		{
			echo "<br/><a href=\"admincp.php?action=club&amp;sid=$sid&amp;clid=$clid\">Admin Tools</a>";
		}
        if($clinfo[1]==$uid)
      {
        //club owner
        $mems = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubmembers WHERE clid='".$clid."' AND accepted='0'"));
        echo "<br/><a href=\"lists.php?action=clreq&amp;sid=$sid&amp;clid=$clid\">&#187;Requests($mems[0])</a><br/>";
      }
    }else{
      echo "Topics: <b>$tps[0]</b>, Posts: <b>$pss[0]</b><br/>";
      echo "<b>Description:</b><br/>";
      echo htmlspecialchars($clinfo[2]);
      echo "<br/><br/>";
      echo "<b>Rules:</b><br/>";
      echo htmlspecialchars($clinfo[3]);
      echo "<br/><br/>";
      echo "Seems Good? <a href=\"genproc.php?action=reqjc&amp;sid=$sid&amp;clid=$clid\">Join Now!</a>";
    }
    echo "</small></p>";
    echo "<p align=\"center\">";
    echo "<a href=\"index.php?action=clubs&amp;sid=$sid\">";
echo "Clubs list</a><br/>";
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

else if($action=="addcl")
{
    addonline(getuid_sid($sid),"Adding Club - xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("Add Club",$pstyle);
    echo "<p align=\"center\">";
    echo "<b>Add Club</b>";
    echo "</p>";
    echo "<p>";
    if(getplusses($uid)>=500)
    {
    $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubs WHERE owner='".$uid."'"));
      if($noi[0]<5)
      {
        echo "<small><img src=\"images/point.gif\" alt=\"*\"/>All Info are required except the logo<br/>";
        echo "<img src=\"images/point.gif\" alt=\"*\"/>Beside you, mods can moderate your club forums and chat<br/>";
        echo "<img src=\"images/point.gif\" alt=\"*\"/>Any leading spaces for description, name, logo, or rules will be removed<br/>";
        echo "<img src=\"images/point.gif\" alt=\"*\"/>Admins will delete your club and subtract your Credits if you abuse the using of the club<br/>";
        echo "<img src=\"images/point.gif\" alt=\"*\"/>Admins have the right to delete your club if it want active or if it was useless<br/></small><br/>";
        

echo "<form action=\"genproc.php?action=addcl&amp;sid=$sid\" method=\"post\">";
echo "Club Name:<input name=\"clnm\" maxlength=\"30\"/><br/>";
        echo "Description:<input name=\"clds\" maxlength=\"200\"/><br/>";
        echo "Rules:<input name=\"clrl\" maxlength=\"500\"/><br/>";
        echo "Logo:<input name=\"cllg\" maxlength=\"200\"/><br/>";
echo "<input type=\"submit\" value=\"Create\"/>";        
echo "</form>";  
        
        
      }else{
        echo "You already have 5 clubs";
      }
      }else{

      echo "You cant add clubs";
      }
    echo "</p>";

    echo "<p align=\"center\">";
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}
///////////////////////////////////Search

else if($action=="search")
{
    addonline(getuid_sid($sid),"Search Menu - xHTML","");
        $pstyle = gettheme($sid);
    echo xhtmlhead("Search Menu",$pstyle);
    echo "<p align=\"center\">";
    echo "<img src=\"images/search.gif\" alt=\"*\"/><br/>";
    include("popups.php");
    echo "<b>Search Menu</b>";
    echo "</p>";
    echo "<p>";
    echo "<a href=\"search.php?action=tpc&amp;sid=$sid\">&#0187;In Topics</a><br/>";
    echo "<a href=\"search.php?action=blg&amp;sid=$sid\">&#0187;In Blogs</a><br/>";
    echo "<a href=\"search.php?action=nbx&amp;sid=$sid\">&#0187;In My Inbox</a><br/>";
    echo "<a href=\"search.php?action=clb&amp;sid=$sid\">&#0187;In Clubs</a><br/><br/>";
	echo "Find Members:<br/>";
    echo "<a href=\"search.php?action=mbrn&amp;sid=$sid\">&#0187;In Nicknames</a><br/>";
	//echo "<a href=\"search.php?action=mbrl&amp;sid=$sid\">&#0187;In Location</a><br/>";
	//echo "<a href=\"search.php?action=mbrs&amp;sid=$sid\">&#0187;By sex orientation</a><br/>";
	echo "More search options for members are to come<br/>";
    echo "<br/><small>or you can just type the nickname of the member and view its profile</small><br/>";
    
   
    echo "<form method=\"post\" action=\"index.php?action=viewuser&amp;sid=$sid\">";
    echo "<br/>Nickname <input name=\"mnick\" maxlength=\"15\"/><br/>";
    echo "<input type=\"submit\" name=\"Submit\" value=\"View Profile\"/><br/>";
    echo "</form>";  
    
  echo "</p>";

    echo "<p align=\"center\">";

    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

///////////////////////////////////Settings

else if($action=="uset")
{
    addonline(getuid_sid($sid),"User Settings - xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("User Settings",$pstyle);
    echo "<onevent type=\"onenterforward\">";
    $uid = getuid_sid($sid);
    $avat = getavatar($uid);
    $email = mysql_fetch_array(mysql_query("SELECT email FROM ibwf_users WHERE id='".$uid."'"));
    $site = mysql_fetch_array(mysql_query("SELECT site FROM ibwf_users WHERE id='".$uid."'"));
    $bdy = mysql_fetch_array(mysql_query("SELECT birthday FROM ibwf_users WHERE id='".$uid."'"));
    $stats = mysql_fetch_array(mysql_query("SELECT stats FROM ibwf_users WHERE id='".$uid."'"));
    $stats2 = mysql_fetch_array(mysql_query("SELECT stats2 FROM ibwf_users WHERE id='".$uid."'"));
    $referal = mysql_fetch_array(mysql_query("SELECT referal FROM ibwf_users WHERE id='".$uid."'"));
    $langz = mysql_fetch_array(mysql_query("SELECT langz FROM ibwf_users WHERE id='".$uid."'"));
    $uloc = mysql_fetch_array(mysql_query("SELECT location FROM ibwf_users WHERE id='".$uid."'"));
    $usig = mysql_fetch_array(mysql_query("SELECT signature FROM ibwf_users WHERE id='".$uid."'"));
    $sx = mysql_fetch_array(mysql_query("SELECT sex FROM ibwf_users WHERE id='".$uid."'"));
	$uloc[0] = htmlspecialchars($uloc[0]);
  echo "<refresh>
        <setvar name=\"savat\" value=\"$avat\"/>
        <setvar name=\"semail\" value=\"$email[0]\"/>
        <setvar name=\"usite\" value=\"$site[0]\"/>
        <setvar name=\"ubday\" value=\"$bdy[0]\"/>
        <setvar name=\"stats\" value=\"$stats[0]\"/>
        <setvar name=\"stats2\" value=\"$stats2[0]\"/>
        <setvar name=\"referal\" value=\"$referal[0]\"/>
        <setvar name=\"langz\" value=\"$langz[0]\"/>
        <setvar name=\"uloc\" value=\"$uloc[0]\"/>
        <setvar name=\"usig\" value=\"$usig[0]\"/>
        <setvar name=\"sx\" value=\"$sx[0]\"/>
   ";
  echo "</refresh></onevent>";
    echo "<p align=\"center\">";
    include("popups.php");
    echo "<b>Settings</b>";
    echo "</p>";
    echo "<p>";
    
    echo "<form method=\"post\" action=\"genproc.php?action=uprof&amp;sid=$sid\">";   
    echo "Avatar: <input name=\"savat\" maxlength=\"100\" value=\"$avat\"/><br/>";
    echo "E-Mail: <input name=\"semail\" maxlength=\"100\" value=\"$email[0]\"/><br/>";
    echo "Site: <input name=\"usite\" maxlength=\"100\" value=\"$site[0]\"/><br/>";
    echo "Birthday<small>(YYYY-MM-DD)</small>: <input name=\"ubday\" maxlength=\"50\" value=\"$bdy[0]\"/><br/>";
    echo "Location: <input name=\"uloc\" maxlength=\"50\" value=\"$uloc[0]\"/><br/>";
    echo "</select><br/>";
    echo "Online Status: <select name=\"stats2\" value=\"$stats2[0]\">";
    echo "<option value=\"online\">online</option>";
    echo "<option value=\"ofline\">ofline</option>";
    echo "<option value=\"busy\">busy</option>";
    echo "</select><br/>";
    echo "Signature: <input name=\"usig\" maxlength=\"100\" value=\"$usig[0]\"/><br/>";
    echo "</select><br/>";
    echo "Martial Status: <select name=\"stats\" value=\"$stats[0]\">";
    echo "<option value=\"single\">single</option>";
    echo "<option value=\"taken\">taken</option>";
    echo "</select><br/>";
    echo "Language: <input name=\"langz\" maxlength=\"100\" value=\"$langz[0]\"/><br/>";
    echo "Referal: <input name=\"referal\" maxlength=\"100\" value=\"$referal[0]\"/><br/>";
    echo "Sex: <select name=\"usex\" value=\"$sx[0]\">";
    if($sx[0]=="M"){
    echo "<option value=\"M\" selected=\"M\">Male</option>";
    }else{
    echo "<option value=\"M\">Male</option>";
    }
    if($sx[0]=="F"){
    echo "<option value=\"F\" selected=\"F\">Female</option>";
    }else{
    echo "<option value=\"F\">Female</option>";
    }
    echo "</select><br/>";    
    echo "<input type=\"submit\" name=\"Submit\" value=\"Update\"/><br/>";
    echo "</form>";

    echo "<br/><br/>";
	$sml = mysql_fetch_array(mysql_query("SELECT hvia FROM ibwf_users WHERE id='".getuid_sid($sid)."'"));
	if($sml[0]=="1")
	{
		echo "<a href=\"genproc.php?action=shsml&amp;sid=$sid&amp;act=dis\">Disable Smilies</a>";
	}else{
		echo "<a href=\"genproc.php?action=shsml&amp;sid=$sid&amp;act=enb\">Enable Smilies</a>";
	}
	echo "<br/><br/>";
	
	echo "<form method=\"post\" action=\"genproc.php?action=upwd&amp;sid=$sid\">";   
    echo "Password: <input type=\"password\" name=\"npwd\" format=\"*x\" maxlength=\"15\"/><br/>";
    echo "Password again: <input type=\"password\" name=\"cpwd\" format=\"*x\" maxlength=\"15\"/><br/>"; 
    echo "<input type=\"submit\" name=\"Submit\" value=\"Change\"/><br/>";
    echo "</form>";
    
    echo "</p>";
    echo "<p align=\"center\">";

    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

///////////////////////////////////Site Settings

else if($action=="stset")
{
    addonline(getuid_sid($sid),"Site Settings - xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("Site Settings",$pstyle);
    echo "<p align=\"center\">";
    include("popups.php");
    echo "<b>Site View Settings</b>";
    echo "</p>";
    echo "<p>";
    echo "<form method=\"POST\" action=\"genproc.php?action=ustset&amp;sid=$sid\">";
    
    $uid = getuid_sid($sid);
    
    $showcons = mysql_fetch_array(mysql_query("SELECT showicon FROM ibwf_users WHERE id='".$uid."'"));
    $showtime = mysql_fetch_array(mysql_query("SELECT showtime FROM ibwf_users WHERE id='".$uid."'"));
    $showshout = mysql_fetch_array(mysql_query("SELECT showshout FROM ibwf_users WHERE id='".$uid."'"));
    $theme = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    
    echo "<small>Theme:</small> <select name=\"theme\" value=\"$theme[0]\">";
    if (strstr($_SERVER['HTTP_USER_AGENT'], "MOT-")) {
	echo "<optgroup>";
	}
    if($theme[0]=="1"){
    echo "<option value=\"1\" selected=\"1\">Methos</option>";
    }else{
    echo "<option value=\"1\">Methos</option>";
    }
    if($theme[0]=="2"){
    echo "<option value=\"2\" selected=\"2\">Blue</option>";
    }else{
    echo "<option value=\"2\">Blue</option>";
    }
    if($theme[0]=="3"){
    echo "<option value=\"3\" selected=\"3\">Black to White</option>";
    }else{
    echo "<option value=\"3\">Black to White</option>";
    }
    if($theme[0]=="4"){
    echo "<option value=\"4\"  selected=\"4\">Red</option>";
    }else{
    echo "<option value=\"4\">Red</option>";
    }
    if($theme[0]=="5"){
    echo "<option value=\"5\"  selected=\"5\">Green</option>";
    }else{
    echo "<option value=\"5\">Green</option>";
    }
    if($theme[0]=="6"){
    echo "<option value=\"6\"  selected=\"6\">Steel</option>";
    }else{
    echo "<option value=\"6\">Steel</option>";
    }
    if($theme[0]=="7"){
    echo "<option value=\"7\"  selected=\"7\">Opera WML</option>";
    }else{
    echo "<option value=\"7\">Opera WML</option>";
    }
    if($theme[0]=="8"){
    echo "<option value=\"8\"  selected=\"8\">Error</option>";
    }else{
    echo "<option value=\"8\">Error</option>";
    }    
    if($theme[0]=="9"){
    echo "<option value=\"9\"  selected=\"9\">Grey Orange</option>";
    }else{
    echo "<option value=\"9\">Grey Orange</option>";
    }
    if($theme[0]=="10"){
    echo "<option value=\"10\"  selected=\"10\">Pinky</option>";
    }else{
    echo "<option value=\"10\">Pinky</option>";
    }
    if($theme[0]=="11"){
    echo "<option value=\"11\"  selected=\"11\">Matrix</option>";
    }else{
    echo "<option value=\"11\">Matrix</option>";
    }
    if($theme[0]=="12"){
    echo "<option value=\"12\"  selected=\"12\">Goth</option>";
    }else{
    echo "<option value=\"12\">Goth</option>";
    }
    if($theme[0]=="13"){
    echo "<option value=\"13\"  selected=\"13\">Night Pink</option>";
    }else{
    echo "<option value=\"13\">Night Pink</option>";
    }    
    if (strstr($_SERVER['HTTP_USER_AGENT'], "MOT-")) {
	echo "</optgroup>";
	}
    echo "</select><br/><br/>";
    echo "<small>Show Icons on Main Page?:</small> <select name=\"showcons\" value=\"$showcons[0]\">";
    if($showcons[0]=="1"){
    echo "<option value=\"1\" selected=\"1\">Yes</option>";
    }else{
    echo "<option value=\"1\">Yes</option>";
    }
    if($showcons[0]=="0"){
    echo "<option value=\"0\" selected=\"0\">No</option>";
    }else{
    echo "<option value=\"0\">No</option>";
    }
    echo "</select><br/><br/>";
    echo "<small>Show Time on Main Page?:</small> <select name=\"showtime\" value=\"$showtime[0]\">";
    if($showtime[0]=="1"){
    echo "<option value=\"1\" selected=\"1\">Yes</option>";
    }else{
    echo "<option value=\"1\">Yes</option>";
    }
    if($showtime[0]=="0"){
    echo "<option value=\"0\" selected=\"0\">No</option>";
    }else{
    echo "<option value=\"0\">No</option>";
    }
    echo "</select><br/><br/>";
    echo "<small>Show Shoutbox on Main Page?:</small> <select name=\"showshout\" value=\"$showshout[0]\">";
    if($showshout[0]=="1"){
    echo "<option value=\"1\" selected=\"1\">Yes</option>";
    }else{
    echo "<option value=\"1\">Yes</option>";
    }
    if($showshout[0]=="0"){
    echo "<option value=\"0\" selected=\"0\">No</option>";
    }else{
    echo "<option value=\"0\">No</option>";
    }
    echo "</select><br/><br/>";
    echo "<input type=\"submit\" name=\"Submit\" value=\"Update\"/><br/>";
    echo "</form>";
	echo "<br/><br/>";
    echo "</p>";
    echo "<p align=\"center\">";

    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}
///////////////////////////////////Poll Topic
else if($action=="poll")
{
    addonline(getuid_sid($sid),"Administrating Poll - xHTML","");
        $pstyle = gettheme($sid);
    echo xhtmlhead("Your Poll",$pstyle);
    echo "<p>";
    $uid = getuid_sid($sid);
    if(getplusses($uid)<50)
    {
      echo "Minimum Credits required to administrate your poll is 50 credits";
    }else{
        $pid = mysql_fetch_array(mysql_query("SELECT pollid FROM ibwf_users WHERE id='".$uid."'"));
        if($pid[0] == 0)
        {
          echo "<a href=\"index.php?action=crpoll&amp;sid=$sid\">Create Poll</a>";
        }else{
          echo "<a href=\"index.php?action=viewpl&amp;sid=$sid&amp;who=$uid\">View Your Poll</a><br/>";
            echo "<a href=\"genproc.php?action=dlpoll&amp;sid=$sid\">Delete Your Poll</a><br/>";
        }
    }
    echo "</p>";
    
    echo "<p align=\"center\">";

    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
    
}else if($action=="crpoll")
{
    addonline(getuid_sid($sid),"Creating Poll - xHTML","");
    echo "<card id=\"main\" title=\"Create Poll\">";
    echo "<p>";
    if(getplusses(getuid_sid($sid))>=50)
    {
    $pid = mysql_fetch_array(mysql_query("SELECT pollid FROM ibwf_users WHERE id='".$uid."'"));
        if($pid[0] == 0)
        {
          
echo "<form action=\"genproc.php?action=crpoll&amp;sid=$sid\" method=\"post\">";
          echo "Question:<input name=\"pques\" maxlength=\"250\"/><br/>";
          echo "Option 1:<input name=\"opt1\" maxlength=\"100\"/><br/>";
          echo "Option 2:<input name=\"opt2\" maxlength=\"100\"/><br/>";
          echo "Option 3:<input name=\"opt3\" maxlength=\"100\"/><br/>";
          echo "Option 4:<input name=\"opt4\" maxlength=\"100\"/><br/>";
          echo "Option 5:<input name=\"opt5\" maxlength=\"100\"/><br/>";
echo "<input type=\"submit\" value=\"Create\"/>";          
echo "</form>";
    
    
          }else{
            echo "<img src=\"images/notok.gif\" alt=\"x\"/>You already have a poll";
          }
          }else{
            echo "<img src=\"images/notok.gif\" alt=\"x\"/>You should have at least 50 Credits to create a poll";
          }
    echo "</p>";

    echo "<p align=\"center\">";

    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}
else if($action=="pws")
{
    addonline(getuid_sid($sid),"P.W.S - xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("P.W.S",$pstyle);
    echo "<p>";
    echo "&#187;Welcome Image<br/>";
	echo "<small>The image on main page<br/>";
	echo "In Image field: type smilie code for smilie like -hi-, the image URL for external image, leave blank for other options</small><br/>";
	echo "<form method=\"post\" action=\"genproc.php?action=pws&amp;sid=$sid\">";
	echo "<select name=\"imgt\">";
	echo "<option value=\"idc\">My ID Card</option>";
	echo "<option value=\"avt\">My Current Avatar</option>";
	echo "<option value=\"sml\">Smilie</option>";
	echo "<option value=\"ilk\">Image URL</option>";
	echo "</select><br/>";
	echo "Image:<input name=\"imgo\" maxlength=\"200\"/><br/><br/>";
	echo "&#187;Welcome Message<br/>";
	echo "<small>The message that appears on first page of your site, smilies are allowed</small><br/>";
	echo "Message:<input name=\"smsg\" maxlength=\"250\"/><br/><br/>";
	echo "&#187;Theme<br/>";
	echo "<small>Themes available only on phones supporting XHTML</small><br/>";
	echo "<select name=\"thms\">";
	$themes = mysql_query("SELECT id, name FROM ibwf_themes");
	while ($theme = mysql_fetch_array($themes))
	{
	echo "<option value=\"$theme[0]\">".htmlspecialchars($theme[1])."</option>";
	}
	echo "</select><br/>";
    echo "<input type=\"submit\" name=\"Submit\" value=\"Update\"/><br/>";
    echo "</form>";  
          
    echo "</p>";
    echo "<p align=\"center\">";
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
    echo "</p>";
    echo xhtmlfoot();
}

else if($action=="pltpc")
{
  $tid = $_GET["tid"];
    addonline(getuid_sid($sid),"Creating Poll - xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("Create Poll",$pstyle);
    echo "<p>";
    if((getplusses(getuid_sid($sid))>=500)||ismod($uid))
    {
    $pid = mysql_fetch_array(mysql_query("SELECT pollid FROM ibwf_topics WHERE id='".$tid."'"));
        if($pid[0] == 0)
        {
          
          echo "<form method=\"post\" action=\"genproc.php?action=pltpc&amp;sid=$sid&amp;tid=$tid\">";
          echo "Question:<input name=\"pques\" maxlength=\"250\"/><br/>";
          echo "Option 1:<input name=\"opt1\" maxlength=\"100\"/><br/>";
          echo "Option 2:<input name=\"opt2\" maxlength=\"100\"/><br/>";
          echo "Option 3:<input name=\"opt3\" maxlength=\"100\"/><br/>";
          echo "Option 4:<input name=\"opt4\" maxlength=\"100\"/><br/>";
          echo "Option 5:<input name=\"opt5\" maxlength=\"100\"/><br/>";
          echo "<input type=\"submit\" name=\"Submit\" value=\"Create\"/><br/>";
          echo "</form>"; 
          
          
          }else{
            echo "<img src=\"images/notok.gif\" alt=\"x\"/>The topic already have a poll";
          }
          }else{
            echo "<img src=\"images/notok.gif\" alt=\"x\"/>You should have at least 500 Credits to create a poll";
          }
    echo "</p>";

    echo "<p align=\"center\">";

    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

else if($action=="stats")
{
    addonline(getuid_sid($sid),"Site statistics - xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("Site Statistics",$pstyle);
    echo "<p>";
    $norm = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users"));
    echo "<small>";
    $siteage = mysql_fetch_array(mysql_query("SELECT value  FROM ibwf_settings WHERE id='9'"));
    $sage = time()-$siteage[0];
    $stage = ceil($sage/(24*60*60));
    echo "<div class=\"mblock2\">";
    echo "<h5 align=\"center\">Site Statistics</h5><br/>";
    include("popups.php");
    echo "Site Age: <b>$stage Days</b><br/><br/>";
    echo "Registered Members: <b>$norm[0]</b><br/>";
    $memid = mysql_fetch_array(mysql_query("SELECT id, name  FROM ibwf_users ORDER BY regdate DESC LIMIT 0,1"));
    echo "The Newest Member is: <b><a href=\"index.php?action=viewuser&amp;who=$memid[0]&amp;sid=$sid\">$memid[1]</a></b><br/><br/>";
    $mols = mysql_fetch_array(mysql_query("SELECT name, value FROM ibwf_settings WHERE id='2'"));
    echo "Most online: <b>$mols[1]</b> Members on $mols[0]<br/>";
    $mols = mysql_fetch_array(mysql_query("SELECT ppl, dtm FROM ibwf_mpot WHERE ddt='".date("d m y")."'"));
    echo "<br/>Most online(<a href=\"lists.php?action=moto&amp;sid=$sid\">today only</a>): <b>$mols[0]</b> Members at $mols[1]<br/>";
    $tm24 = time() - (24*60*60) ;
    $aut = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE lastact>'".$tm24."'"));
    echo mysql_error();
    echo "<br/>Active users today <b>$aut[0]</b><br/>";
    $notc = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_topics"));
    $nops = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_posts"));
    echo "Number of Topics: <b>$notc[0]</b><br/>";
    echo "Number of Posts: <b>$nops[0]</b><br/>";
    $nopm = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private"));
    echo "Number of PMs: <b>$nopm[0]</b><br/>";
    $nopm = mysql_fetch_array(mysql_query("SELECT value FROM ibwf_settings WHERE name='Counter'"));
    echo "Counter: <b>$nopm[0]</b><br/><br/>";
    echo "</small>";
    echo "</div>";
    echo "</p>";
    echo "<p>";
    echo "<small>";
    /////
    echo "<div class=\"mblock2\">";
    echo "<h5 align=\"center\">General Stats</h5><br/>";    
    echo "<a href=\"index.php?action=l24&amp;sid=$sid\">&#187;What happend in the last 24 hours?</a><br/>";
    echo "<a href=\"lists.php?action=members&amp;sid=$sid\">&#187;Members($norm[0])</a><br/>";
    $norm = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE sex='M'"));
    echo "<a href=\"lists.php?action=males&amp;sid=$sid\">--&#187;Males($norm[0])</a><br/>";
    $norm = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE sex='F'"));
    echo "<a href=\"lists.php?action=fems&amp;sid=$sid\">--&#187;Females($norm[0])</a><br/>";     
    echo "</div>";
    
    echo "<div class=\"mblock2\">";
    echo "<h5 align=\"center\">Fun Stats</h5><br/>";
    $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_blogs"));
    echo "<a href=\"lists.php?action=allbl&amp;sid=$sid\">&#187;Blogs($noi[0])</a><br/>";
    $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE pollid>'0'"));
    echo "<a href=\"lists.php?action=polls&amp;sid=$sid\">&#187;Polls($noi[0])</a><br/>";
    $nobr=mysql_fetch_array(mysql_query("SELECT COUNT(DISTINCT browserm) FROM ibwf_users WHERE browserm IS NOT NULL "));
    echo "<a href=\"lists.php?action=brows&amp;sid=$sid\">&#187;Browsers($nobr[0])</a><br/>";
    echo "</div>";
    
    echo "<div class=\"mblock2\">";
    echo "<h5 align=\"center\">Members Toplist</h5><br/>";
    echo "<a href=\"lists.php?action=mmillionaire&amp;sid=$sid\">&#187;FlareZone Millionaires</a><br/>";
    echo "<a href=\"lists.php?action=mpandps&amp;sid=$sid\">&#187;FlareZone Prince and Princess</a><br/>";
    echo "<a href=\"lists.php?action=mquizm&amp;sid=$sid\">&#187;FlareZone Quiz Masters</a><br/>";
    echo "<a href=\"lists.php?action=mostc&amp;sid=$sid\">&#187;Most Credits</a><br/>";
    echo "<a href=\"lists.php?action=topp&amp;sid=$sid\">&#187;Top Posters</a><br/>";
    echo "<a href=\"lists.php?action=tchat&amp;sid=$sid\">&#187;Top Chatters</a><br/>";
    echo "<a href=\"lists.php?action=topb&amp;sid=$sid\">&#187;Top Battlers</a><br/>";
    echo "<a href=\"lists.php?action=tshout&amp;sid=$sid\">&#187;Top Shouters</a><br/>";
    echo "<a href=\"lists.php?action=tthemes&amp;sid=$sid\">&#187;Top Themes</a><br/>";
    echo "</div>";

    echo "<div class=\"mblock2\">";
    echo "<h5 align=\"center\">Permission Stats</h5><br/>";
    $noi = mysql_fetch_array(mysql_query("SELECT count(*) FROM ibwf_users WHERE perm>'0'"));
    echo "<a href=\"lists.php?action=staff&amp;sid=$sid\">&#187;Staff Members($noi[0])</a><br/>";
    $noi = mysql_fetch_array(mysql_query("SELECT count(*) FROM ibwf_users WHERE specialid>'0'"));
    echo "<a href=\"lists.php?action=vips&amp;sid=$sid\">&#187;V.I.P Members($noi[0])</a><br/>";
    $noi = mysql_fetch_array(mysql_query("SELECT count(*) FROM ibwf_judges"));
    echo "<a href=\"lists.php?action=judg&amp;sid=$sid\">&#187;Battles Judges($noi[0])</a><br/>";
    $noi = mysql_fetch_array(mysql_query("SELECT count(*) FROM ibwf_penalties WHERE penalty='1' OR penalty='2'"));
    echo "</div>";

    echo "<div class=\"mblock2\">";
    echo "<h5 align=\"center\">Other Stats</h5><br/>";
    $tbday=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users where month(`birthday`) = month(curdate()) and dayofmonth(`birthday`) = dayofmonth(curdate());"));
    echo "<a href=\"lists.php?action=bdy&amp;sid=$sid\">&#187;Today's Birthday($tbday[0])</a><br/>";    
    echo "<a href=\"lists.php?action=banned&amp;sid=$sid\">&#187;Banned($noi[0])</a><br/>";
    if(ismod(getuid_sid($sid)))
{
  $noi = mysql_fetch_array(mysql_query("SELECT count(*) FROM ibwf_penalties WHERE penalty='0'"));
    echo "<a href=\"lists.php?action=trashed&amp;sid=$sid\">&#187;Trashed($noi[0])</a><br/>";
    $noi = mysql_fetch_array(mysql_query("SELECT count(*) FROM ibwf_penalties WHERE penalty='2'"));
    echo "<a href=\"lists.php?action=ipban&amp;sid=$sid\">&#187;Banned IPs($noi[0])</a><br/>";
    echo "</div>";
    }
    
    echo "</small></p>";
    echo "<p align=\"center\">";
    
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

else if($action=="l24")
{
    addonline(getuid_sid($sid),"24 Hour statistics - xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("24 Hour Statistics",$pstyle);
    echo "<p>";
    echo "<small>";
    /////
    include("popups.php");
    echo "Things happened in FlareZone in the last 24 hours<br/><br/>";
    $tm24 = time() - (24*60*60) ;
    $aut = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE lastact>'".$tm24."'"));
    echo "Active Members: <b>$aut[0]</b><br/>";
$aut = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE regdate>'".$tm24."'"));
    echo "Registered Members: <b>$aut[0]</b><br/>";
    $aut = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_blogs WHERE bgdate>'".$tm24."'"));
    echo "Blogs Created: <b>$aut[0]</b><br/>";
    $aut = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubmembers WHERE joined>'".$tm24."' AND accepted='1'"));
    echo "Members Joined Clubs: <b>$aut[0]</b><br/>";
    $aut = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubs WHERE created>'".$tm24."'"));
    echo "Clubs Created: <b>$aut[0]</b><br/>";
    $aut = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_buddies WHERE reqdt>'".$tm24."' AND agreed='1'"));
    echo "Buddies Added: <b>$aut[0]</b><br/>";
    $aut = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_gbook WHERE dtime>'".$tm24."'"));
    echo "Guestbooks Signed: <b>$aut[0]</b><br/>";
    if(ismod(getuid_sid($sid))){
    $aut = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_mlog WHERE actdt>'".$tm24."'"));
    echo "ModLog Actions: <b>$aut[0]</b><br/>";
  }
  $aut = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_polls WHERE pdt>'".$tm24."'"));
    echo "Polls Added: <b>$aut[0]</b><br/>";
    $aut = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_posts WHERE dtpost>'".$tm24."'"));
    echo "Posts: <b>$aut[0]</b><br/>";
    $aut = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE timesent>'".$tm24."'"));
    echo "PMs Sent: <b>$aut[0]</b><br/>";
    $aut = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_shouts WHERE shtime>'".$tm24."'"));
    echo "Shouts: <b>$aut[0]</b><br/>";
    $aut = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_topics WHERE crdate>'".$tm24."'"));
    echo "Topics Created: <b>$aut[0]</b><br/>";
    $aut = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_vault WHERE pudt>'".$tm24."'"));
    echo "Vault Items Added: <b>$aut[0]</b><br/>;";
    echo "</small></p>";
    echo "<p align=\"center\">";
echo "<a href=\"index.php?action=stats&amp;sid=$sid\"><img src=\"images/stat.gif\" alt=\"*\"/>";
echo "Statistics</a><br/>";
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

//////////////////////////////////View category

else if($action=="viewcat")
{
    $cid = $_GET["cid"];
    addonline(getuid_sid($sid),"Viewing Category - xHTML","");
    $cinfo = mysql_fetch_array(mysql_query("SELECT name from ibwf_fcats WHERE id='".$cid."'"));
    $pstyle = gettheme($sid);
    echo xhtmlhead($cinfo[0],$pstyle);
    echo "<p>";
    $forums = mysql_query("SELECT id, name FROM ibwf_forums WHERE cid='".$cid."' AND clubid='0' ORDER BY position, id, name");
    echo "<small>";
    while($forum = mysql_fetch_array($forums))
    {
      if(canaccess(getuid_sid($sid), $forum[0]))
      {
        $notp = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_topics WHERE fid='".$forum[0]."'"));
        $nops = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_posts a INNER JOIN ibwf_topics b ON a.tid = b.id WHERE b.fid='".$forum[0]."'"));
      $iml = "<img src=\"images/2.gif\" alt=\"*\"/>";
      echo "<a href=\"index.php?action=viewfrm&amp;sid=$sid&amp;fid=$forum[0]\">$iml$forum[1]($notp[0]/$nops[0])</a><br/>";
      $lpt = mysql_fetch_array(mysql_query("SELECT id, name FROM ibwf_topics WHERE fid='".$forum[0]."' ORDER BY lastpost DESC LIMIT 0,1"));
      $nops = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_posts WHERE tid='".$lpt[0]."'"));
      if($nops[0]==0)
      {
        $pinfo = mysql_fetch_array(mysql_query("SELECT authorid FROM ibwf_topics WHERE id='".$lpt[0]."'"));
        $tluid = $pinfo[0];
        
      }else{
        $pinfo = mysql_fetch_array(mysql_query("SELECT  uid  FROM ibwf_posts WHERE tid='".$lpt[0]."' ORDER BY dtpost DESC LIMIT 0, 1"));
        
        $tluid = $pinfo[0];
      }
      $tlnm = htmlspecialchars($lpt[1]);
      $tlnick = getnick_uid($tluid);
      $tpclnk = "<a href=\"index.php?action=viewtpc&amp;sid=$sid&amp;tid=$lpt[0]&amp;go=last\">$tlnm</a>";
      $vulnk = "<a href=\"index.php?action=viewuser&amp;sid=$sid&amp;who=$tluid\">$tlnick</a>";
      echo "Last Post: $tpclnk, BY: $vulnk<br/><br/>";
      }
    }
    echo "</small>";
    echo "</p>";
    echo "<p align=\"center\">";
    $tmsg = getpmcount(getuid_sid($sid));
  $umsg = getunreadpm(getuid_sid($sid));
  if($umsg>0)
  {
  echo "<a href=\"inbox.php?action=main&amp;sid=$sid\">Inbox($umsg/$tmsg)</a><br/>";
  }
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

//////////////////////////////////View Topic

else if($action=="viewtpc")
{
  addonline(getuid_sid($sid),"Viewing Topic - xHTML","");
  $tid = $_GET["tid"];
  $go = $_GET["go"];
  $tfid = mysql_fetch_array(mysql_query("SELECT fid FROM ibwf_topics WHERE id='".$tid."'"));
  if(!canaccess(getuid_sid($sid), $tfid[0]))
    {
    $pstyle = gettheme($sid);
    echo xhtmlhead("FlareZone",$pstyle);
      echo "<p align=\"center\">";
      echo "You Don't Have A Permission To View The Contents Of This Forum<br/><br/>";
      echo "<a href=\"index.php?action=main&amp;sid=$sid\">Home</a>";
      echo "</p>";
      echo xhtmlfoot();

      exit();
    }
    
    $tinfo = mysql_fetch_array(mysql_query("SELECT name, text, authorid, crdate, views, fid, pollid from ibwf_topics WHERE id='".$tid."'"));
    $tnm = htmlspecialchars($tinfo[0]);
    $pstyle = gettheme($sid);
    echo xhtmlhead($tnm,$pstyle);
    echo "<p align=\"center\">";
    $num_pages = getnumpages($tid);
    if($page==""||$page<1)$page=1;
    if($go!="")$page=getpage_go($go,$tid);
    $posts_per_page = 5;
    if($page>$num_pages)$page=$num_pages;
    $limit_start = $posts_per_page *($page-1);
    echo "<a href=\"index.php?action=post&amp;sid=$sid&amp;tid=$tid\">Post reply</a>";
    $lastlink = "<a href=\"index.php?action=$action&amp;tid=$tid&amp;sid=$sid&amp;go=last\">Last Page</a>";
    $firstlink = "<a href=\"index.php?action=$action&amp;tid=$tid&amp;sid=$sid&amp;page=1\">First Page</a> ";
    $golink = "";
    if($page>1)
    {
      $golink = $firstlink;
    }
    if($page<$num_pages)
    {
      $golink .= $lastlink;
    }
    if($golink !="")
    {
      echo "<br/>$golink";
    }
    echo "</p>";
    echo "<p align=\"center\">";
    $vws = $tinfo[4]+1;
    $rpls = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_posts WHERE tid='".$tid."'"));
    echo "<small>Replies: $rpls[0] - Views: $vws</small><br/>";
    echo "</p>";
    echo "<p>";
    ///fm here
    
    if($page==1)
    {
      $posts_per_page=4;
      mysql_query("UPDATE ibwf_topics SET views='".$vws."' WHERE  id='".$tid."'");
      $ttext = mysql_fetch_array(mysql_query("SELECT authorid, text, crdate, pollid FROM ibwf_topics WHERE id='".$tid."'"));
      $unick = getnick_uid($ttext[0]);
      if(isonline($ttext[0]))
    {
      $iml = "<img src=\"images/onl.gif\" alt=\"+\"/>";
    }else{
        $iml = "<img src=\"images/ofl.gif\" alt=\"-\"/>";
    }
    $usl = "<br/><a href=\"index.php?action=viewuser&amp;sid=$sid&amp;who=$ttext[0]\">$iml$unick</a>";
    $topt = "<a href=\"index.php?action=tpcopt&amp;sid=$sid&amp;tid=$tid\">*</a>";
    if($go==$tid)
    {
      $fli = "<img src=\"images/flag.gif\" alt=\"!\"/>";
    }else{
      $fli ="";
    }
    $pst = parsemsg($ttext[1],$sid);
    $dtot = date("d/m/y - H:i:s",$ttext[2]);
    echo "<small>$usl: $dtot</small><br/>$fli$pst $topt<br/>";
    if($ttext[3]>0)
    {
      echo "<a href=\"index.php?action=viewtpl&amp;sid=$sid&amp;who=$tid\">POLL</a><br/>";
    }
  }
  if($page>1)
  {
    $limit_start--;
  }
  $sql = "SELECT id, text, uid, dtpost, quote FROM ibwf_posts WHERE tid='".$tid."' ORDER BY dtpost LIMIT $limit_start, $posts_per_page";
  $posts = mysql_query($sql);
  while($post = mysql_fetch_array($posts))
  {
    $unick = getnick_uid($post[2]);
    if(isonline($post[2]))
    {
      $iml = "<img src=\"images/onl.gif\" alt=\"+\"/>";
    }else{
        $iml = "<img src=\"images/ofl.gif\" alt=\"-\"/>";
    }
    $usl = "<br/><a href=\"index.php?action=viewuser&amp;sid=$sid&amp;who=$post[2]\">$iml$unick</a>";
    $pst = parsemsg($post[1], $sid);
    $topt = "<a href=\"index.php?action=pstopt&amp;sid=$sid&amp;pid=$post[0]&amp;page=$page&amp;fid=$tinfo[5]\">*</a>";
    if($post[4]>0)
    {
        $qtl = "<small><i><a href=\"index.php?action=viewtpc&amp;sid=$sid&amp;tid=$tid&amp;pst=\">(quote:p=blaze,d=16-04-2006)</a></i></small>";
    }
    if($go==$post[0])
    {
      $fli = "<img src=\"images/flag.gif\" alt=\"!\"/>";
    }else{
      $fli ="";
    }
    $dtot = date("d/m/y - H:i:s",$post[3]);
    echo "<small>$usl: $dtot</small><br/>$fli$pst $topt<br/>";
  }
    ///to here
    echo "</p>";
    echo "<p align=\"center\">";
    $tmsg = getpmcount(getuid_sid($sid));
  $umsg = getunreadpm(getuid_sid($sid));
  if($umsg>0)
  {
  echo "<a href=\"inbox.php?action=main&amp;sid=$sid\">Inbox($umsg/$tmsg)</a><br/>";
  }
    if($page>1)
    {
      $ppage = $page-1;
      echo "<a href=\"index.php?action=viewtpc&amp;page=$ppage&amp;sid=$sid&amp;tid=$tid\">&#171;PREV</a> ";
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
      echo "<a href=\"index.php?action=viewtpc&amp;page=$npage&amp;sid=$sid&amp;tid=$tid\">Next&#187;</a>";
    }
    echo "<br/>$page/$num_pages<br/>";
    if($num_pages>2)
    {
        
        $rets = "<form action=\"index.php\" method=\"get\">";
        $rets .= "Jump to page<input name=\"page\" format=\"*N\" size=\"3\"/>";
        $rets .= "<input type=\"submit\" value=\"GO\"/>";
        $rets .= "<input type=\"hidden\" name=\"action\" value=\"$action\"/>";
        $rets .= "<input type=\"hidden\" name=\"tid\" value=\"$tid\"/>";
        $rets .= "<input type=\"hidden\" name=\"sid\" value=\"$sid\"/>";
        $rets .= "</form>";

        echo $rets;


    }
echo "<br/>";
    echo "<a href=\"index.php?action=post&amp;sid=$sid&amp;tid=$tid\">Post reply</a>";
    echo "</p>";
    echo "<p><small>";
    $fid = $tinfo[5];
    $fname = getfname($fid);
    $cid = mysql_fetch_array(mysql_query("SELECT cid FROM ibwf_forums WHERE id='".$fid."'"));
    $cinfo = mysql_fetch_array(mysql_query("SELECT name FROM ibwf_fcats WHERE id='".$cid[0]."'"));
    $cname = $cinfo[0];

    echo "<a href=\"index.php?action=main&amp;sid=$sid\">";
echo "Home</a>&gt;";
    echo "<a href=\"index.php?action=formmenu&amp;sid=$sid\">";
echo "Forums</a>&gt;";

$cid = mysql_fetch_array(mysql_query("SELECT cid FROM ibwf_forums WHERE id='".$fid."'"));
    if($cid[0]>0)
    {
    $cinfo = mysql_fetch_array(mysql_query("SELECT name FROM ibwf_fcats WHERE id='".$cid[0]."'"));
    $cname = htmlspecialchars($cinfo[0]);
    echo "<a href=\"index.php?action=viewcat&amp;sid=$sid&amp;cid=$cid[0]\">";
    echo "$cname</a><br/>";
    }else{
        $cid = mysql_fetch_array(mysql_query("SELECT clubid FROM ibwf_forums WHERE id='".$fid."'"));
        $cinfo = mysql_fetch_array(mysql_query("SELECT name FROM ibwf_clubs WHERE id='".$cid[0]."'"));
        $cname = htmlspecialchars($cinfo[0]);
    echo "<a href=\"index.php?action=gocl&amp;sid=$sid&amp;clid=$cid[0]\">";
    echo "$cname Club</a><br/>";
  }
  $fname = htmlspecialchars($fname);
    echo "&gt;<a href=\"index.php?action=viewfrm&amp;sid=$sid&amp;fid=$fid\">$fname</a>&gt;$tnm";
  echo "</small></p>";
    echo xhtmlfoot();
}
//////////////////////////////////View Forum

else if($action=="viewfrm")
{
  
    $fid = $_GET["fid"];
	$view = $_GET["view"];
    if(!canaccess(getuid_sid($sid), $fid))
    {
      addonline(getuid_sid($sid),"Lost in forums - xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("FlareZone",$pstyle);
      echo "<p align=\"center\">";
      echo "You Don't Have A Permission To View The Contents Of This Forum<br/><br/>";
      echo "<a href=\"index.php?action=main&amp;sid=$sid\">Home</a>";
      echo "</p>";
      echo xhtmlfoot();

      exit();
    }
    addonline(getuid_sid($sid),"Viewing Forum - xHTML","");
    $finfo = mysql_fetch_array(mysql_query("SELECT name from ibwf_forums WHERE id='".$fid."'"));
    $fnm = htmlspecialchars($finfo[0]);
    $pstyle = gettheme($sid);
    echo xhtmlhead($fnm,$pstyle);
    echo "<p align=\"center\">";
    $norf = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_rss WHERE fid='".$fid."'"));
    if($norf[0]>0)
    {
        echo "<a href=\"rwrss.php?action=showfrss&amp;sid=$sid&amp;fid=$fid\"><img src=\"images/rss.gif\" alt=\"rss\"/>$finfo[0] Extras</a><br/>";
    }
    echo "<a href=\"index.php?action=newtopic&amp;sid=$sid&amp;fid=$fid\">New Topic</a><br/>";
    
  echo "<form method=\"get\" action=\"index.php\">"; 
  echo "View: <select name=\"vopt\">";
  echo "<option value=\"all\">All</option>";
  echo "<option value=\"new\">Since Last Visit</option>";
  echo "<option value=\"myps\">I posted In</option>";
  echo "</select>";       
  echo "<input type=\"hidden\" name=\"action\" value=\"$action\"/>";
  echo "<input type=\"hidden\" name=\"fid\" value=\"$fid\"/>";
  echo "<input type=\"hidden\" name=\"sid\" value=\"$sid\"/>";  
  echo "<input type=\"submit\" name=\"Submit\" value=\"[GO]\"/><br/>";
  echo "</form>"; 
          
	if($view=="new")
	{
		echo "<small>Viewing topics that has new posts since your last visit</small>";
	}else if($view=="myps")
	{
		echo "<small>Viewing topics contain posts by you</small>";
	}else {
	echo "<small>Viewing All topics</small>";
	}
    echo "</p>";
    echo "<p>";
    echo "<small>";
    if($page=="" || $page<=0)$page=1;
    if($page==1)
    {
      ///////////pinned topics
      $topics = mysql_query("SELECT id, name, closed, views, pollid FROM ibwf_topics WHERE fid='".$fid."' AND pinned='1' ORDER BY lastpost DESC, name, id LIMIT 0,5");
      while($topic = mysql_fetch_array($topics))
    {
      $iml = "<img src=\"images/normal.gif\" alt=\"*\"/>";
      $iml = "*";
      $atxt ="";
      if($topic[2]=='1')
      {
        //closed
        $atxt = "(X)";
      }
      if($topic[4]>0)
      {
        $pltx = "(P)";
      }else{
        $pltx = "";
      }
      $tnm = htmlspecialchars($topic[1]);
      $nop = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_posts WHERE tid='".$topic[0]."'"));
      echo "<a href=\"index.php?action=viewtpc&amp;sid=$sid&amp;tid=$topic[0]\">$iml$pltx$tnm($nop[0])$atxt</a><br/>";

    }
    echo "<br/>";
  }
  $uid = getuid_sid($sid);
  if($view=="new")
  {
  
  $ulv = mysql_fetch_array(mysql_query("SELECT lastvst FROM ibwf_users WHERE id='".$uid."'"));
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_topics WHERE fid='".$fid."' AND pinned='0' AND lastpost >='".$ulv[0]."'"));
  }
  else if($view=="myps")
  {
	$noi = mysql_fetch_array(mysql_query("SELECT COUNT(DISTINCT a.id) FROM ibwf_topics a INNER JOIN ibwf_posts b ON a.id = b.tid WHERE a.fid='".$fid."' AND a.pinned='0' AND b.uid='".$uid."'"));
  }
  else{
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_topics WHERE fid='".$fid."' AND pinned='0'"));
  }
    $num_items = $noi[0]; //changable
    $items_per_page= 10;
    $num_pages = ceil($num_items/$items_per_page);
    if($page>$num_pages)$page= $num_pages;
    $limit_start = ($page-1)*$items_per_page;
    if($limit_start<0)$limit_start=0;
	if($view=="new")
	{
	$ulv = mysql_fetch_array(mysql_query("SELECT lastvst FROM ibwf_users WHERE id='".$uid."'"));
    $topics = mysql_query("SELECT id, name, closed, views, moved, pollid FROM ibwf_topics WHERE fid='".$fid."' AND pinned='0' AND lastpost >='".$ulv[0]."' ORDER BY lastpost DESC, name, id LIMIT $limit_start, $items_per_page");
	}
	else if($view=="myps"){
	$topics = mysql_query("SELECT a.id, a.name, a.closed, a.views, a.moved, a.pollid FROM ibwf_topics a INNER JOIN ibwf_posts b ON a.id = b.tid WHERE a.fid='".$fid."' AND a.pinned='0' AND b.uid='".$uid."' GROUP BY a.id ORDER BY a.lastpost DESC, a.name, a.id  LIMIT $limit_start, $items_per_page");
	}
	else{
	$topics = mysql_query("SELECT id, name, closed, views, moved, pollid FROM ibwf_topics WHERE fid='".$fid."' AND pinned='0' ORDER BY lastpost DESC, name, id LIMIT $limit_start, $items_per_page");
	}
    
    while($topic = mysql_fetch_array($topics))
    {
      
      $nop = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_posts WHERE tid='".$topic[0]."'"));
      $iml = "<img src=\"images/normal.gif\" alt=\"*\"/>";
      if($nop[0]>24)
      {
        $iml = "<img src=\"images/hot.gif\" alt=\"*\"/>";
      }
      if($topic[4]=='1')
      {
        $iml = "<img src=\"images/moved.gif\" alt=\"*\"/>";
      }
      if($topic[2]=='1')
      {
        $iml = "<img src=\"images/closed.gif\" alt=\"*\"/>";
      }
      if($topic[5]>0)
      {
        $iml = "<img src=\"images/poll.gif\" alt=\"*\"/>";
      }
      $atxt ="";
      if($topic[2]=='1')
      {
        //closed
        $atxt = "(X)";
      }
      $tnm = htmlspecialchars($topic[1]);
      echo "<a href=\"index.php?action=viewtpc&amp;sid=$sid&amp;tid=$topic[0]\">$iml$tnm($nop[0])$atxt</a><br/>";

    }

    echo "</small>";

    echo "</p>";
    echo "<p align=\"center\">";
$tmsg = getpmcount(getuid_sid($sid));
  $umsg = getunreadpm(getuid_sid($sid));
  if($umsg>0)
  {
  echo "<a href=\"inbox.php?action=main&amp;sid=$sid\">Inbox($umsg/$tmsg)</a><br/>";
  }
    if($page>1)
    {
      $ppage = $page-1;
      echo "<a href=\"index.php?action=viewfrm&amp;page=$ppage&amp;sid=$sid&amp;fid=$fid&amp;view=$view\">&#171;PREV</a> ";
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
      echo "<a href=\"index.php?action=viewfrm&amp;page=$npage&amp;sid=$sid&amp;fid=$fid&amp;view=$view\">Next&#187;</a>";
    }
    echo "<br/>$page/$num_pages<br/>";
    if($num_pages>2)
    {
        
        $rets = "<form action=\"index.php\" method=\"get\">";
      $rets .= "Jump to page: <input name=\"page\" format=\"*N\" size=\"3\"/>";
        $rets .= "<input type=\"submit\" value=\"GO\"/>";
        $rets .= "<input type=\"hidden\" name=\"action\" value=\"$action\"/>";
        $rets .= "<input type=\"hidden\" name=\"fid\" value=\"$fid\"/>";
        $rets .= "<input type=\"hidden\" name=\"sid\" value=\"$sid\"/>";
		$rets .= "<input type=\"hidden\" name=\"view\" value=\"$view\"/>";
        $rets .= "</form>";

        echo $rets;
    }

    echo "<br/><br/><a href=\"index.php?action=newtopic&amp;sid=$sid&amp;fid=$fid\">New Topic</a><br/>";
    $cid = mysql_fetch_array(mysql_query("SELECT cid FROM ibwf_forums WHERE id='".$fid."'"));
    if($cid[0]>0)
    {
    $cinfo = mysql_fetch_array(mysql_query("SELECT name FROM ibwf_fcats WHERE id='".$cid[0]."'"));
    $cname = htmlspecialchars($cinfo[0]);
    echo "<a href=\"index.php?action=viewcat&amp;sid=$sid&amp;cid=$cid[0]\">";
    echo "$cname</a><br/>";
    }else{
        $cid = mysql_fetch_array(mysql_query("SELECT clubid FROM ibwf_forums WHERE id='".$fid."'"));
        $cinfo = mysql_fetch_array(mysql_query("SELECT name FROM ibwf_clubs WHERE id='".$cid[0]."'"));
        $cname = htmlspecialchars($cinfo[0]);
    echo "<a href=\"index.php?action=gocl&amp;sid=$sid&amp;clid=$cid[0]\">";
    echo "$cname Club</a><br/>";
    }
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}
//////////////////////////////////ONLINE USERS
else if($action=="newtopic")
{
  $fid = $_GET["fid"];
  if(!canaccess(getuid_sid($sid), $fid))
    {
    $pstyle = gettheme($sid);
    echo xhtmlhead("FlareZone",$pstyle);
      echo "<p align=\"center\">";
      echo "You Don't Have A Permission To View The Contents Of This Forum<br/><br/>";
      echo "<a href=\"index.php?action=main&amp;sid=$sid\">Home</a>";
      echo "</p>";
      echo xhtmlfoot();

      exit();
    }
    addonline(getuid_sid($sid),"Creating new topic - xHTML","index.php?action=online");
    $pstyle = gettheme($sid);
    echo xhtmlhead("New Topic",$pstyle);
    echo "<p align=\"center\">";
  echo "<form method=\"post\" action=\"genproc.php?action=newtopic&amp;sid=$sid\">";
    echo "Title:<input name=\"ntitle\" maxlength=\"30\"/><br/>";
    echo "Text:<input name=\"tpctxt\" maxlength=\"500\"/><br/>";
  echo "<input type=\"hidden\" name=\"fid\" value=\"$fid\"/>";
  echo "<input type=\"submit\" name=\"Submit\" value=\"Create\"/><br/>";
  echo "</form>";
    echo "<br/><br/><a href=\"index.php?action=viewfrm&amp;sid=$sid&amp;fid=$fid\">";
    $fname = getfname($fid);
echo "$fname</a><br/>";
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";

    echo "</p>";
    echo xhtmlfoot();
}

//////////////////////////////////////////Post reply

else if($action=="post")
{
    $tid = $_GET["tid"];
    
    $tfid = mysql_fetch_array(mysql_query("SELECT fid FROM ibwf_topics WHERE id='".$tid."'"));
    $fid = $tfid[0];
if(!canaccess(getuid_sid($sid), $fid))
    {
    $pstyle = gettheme($sid);
    echo xhtmlhead("FlareZone",$pstyle);
      echo "<p align=\"center\">";
      echo "You Don't Have A Permission To View The Contents Of This Forum<br/><br/>";
      echo "<a href=\"index.php?action=main&amp;sid=$sid\">Home</a>";
      echo "</p>";
      echo xhtmlfoot();

      exit();
    }
    addonline(getuid_sid($sid),"Posting reply - xHTML","");
    
    $pstyle = gettheme($sid);
    echo xhtmlhead("Post Reply",$pstyle);
    echo "<onevent type=\"onenterforward\">";
  echo "<refresh>
        <setvar name=\"reptxt\" value=\"\"/>
        <setvar name=\"qut\" value=\"\"/>
   ";
  echo "</refresh></onevent>";
    $qut = $_GET["qut"];
    echo "<p align=\"center\">";
  echo "<form method=\"post\" action=\"genproc.php?action=post&amp;sid=$sid\">";
  echo "Text:<input name=\"reptxt\" maxlength=\"500\"/><br/>";
  echo "<input type=\"hidden\" name=\"tid\" value=\"$tid\"/>";
  echo "<input type=\"hidden\" name=\"qut\" value=\"$qut\"/>";
  echo "<input type=\"submit\" name=\"Submit\" value=\"Reply\"/><br/>";
  echo "</form>";
         $fid = getfid($tid);
         $fname = getfname($fid);
         echo "<br/><br/><a href=\"index.php?action=viewtpc&amp;sid=$sid&amp;tid=$tid\">";
echo "Back to topic</a>";
      echo "<br/><a href=\"index.php?action=viewfrm&amp;sid=$sid&amp;fid=$fid\">";
echo "$fname</a><br/>";
         $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
    echo "</p>";
    echo xhtmlfoot();
}

//////////////////////////////////////////shout

else if($action=="shout")
{
    addonline(getuid_sid($sid),"Shouting - xHTML","");

$pstyle = gettheme($sid);
    echo xhtmlhead("Shout",$pstyle);
    echo "<p align=\"center\">";
    if(getplusses(getuid_sid($sid))<75)
    {
        echo "You should have at least 75 Credits to shout!";
    }else{
  echo "<form method=\"post\" action=\"genproc.php?action=shout&amp;sid=$sid\">";
  echo "Text:<input name=\"shtxt\" maxlength=\"100\"/><br/>";
  echo "<input type=\"submit\" name=\"Submit\" value=\"Shout\"/><br/>";
  echo "</form>";
            }
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<br/><br/><a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
    echo "</p>";
    echo xhtmlfoot();
}

//////////////////////////////////////////shout

else if($action=="annc")
{
    addonline(getuid_sid($sid),"Announcing! - xHTML","");
    $clid = $_GET["clid"];
    $pstyle = gettheme($sid);
    echo xhtmlhead("Announce!",$pstyle);
    echo "<p align=\"center\">";
    $cow = mysql_fetch_array(mysql_query("SELECT owner FROM ibwf_clubs WHERE id='".$clid."'"));
    $uid = getuid_sid($sid);
    if($cow[0]!=$uid)
    {
        echo "This club is not yours!";
    }else{
    
            
     echo "<form method=\"post\" action=\"genproc.php?action=annc&amp;sid=$sid&amp;clid=$clid\">"; 
     echo "Text:<input name=\"antx\" maxlength=\"200\"/><br/>";
     echo "<input type=\"submit\" name=\"Submit\" value=\"Announce\"/><br/>";
     echo "</form>"; 
  
            }
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<br/><br/><a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
    echo "</p>";
    echo xhtmlfoot();
}

//////////////////////////////////////////Guestbook

else if($action=="addblg")
{

    
if(!getplusses(getuid_sid($sid))>50)
    {
$pstyle = gettheme($sid);
    echo xhtmlhead("FlareZone",$pstyle);
      echo "<p align=\"center\">";
      echo "At least you should have 50 Credits to add a blog<br/><br/>";
      echo "<a href=\"index.php?action=main&amp;sid=$sid\">Home</a>";
      echo "</p>";
      echo xhtmlfoot();

      exit();
    }
    addonline(getuid_sid($sid),"Adding a blog - xHTML","");

$pstyle = gettheme($sid);
    echo xhtmlhead("Add Blog",$pstyle);
    echo "<onevent type=\"onenterforward\">";
  echo "<refresh>
        <setvar name=\"msgtxt\" value=\"\"/>
        <setvar name=\"btitle\" value=\"\"/>
   ";
  echo "</refresh></onevent>";
    
    echo "<p align=\"center\">";
    
      echo "<form method=\"post\" action=\"genproc.php?action=addblg&amp;sid=$sid\">";
    echo "Title:<input name=\"btitle\" maxlength=\"30\"/><br/>";
    echo "Text:<input name=\"msgtxt\" maxlength=\"500\"/><br/>";
  echo "<input type=\"submit\" name=\"Submit\" value=\"Add\"/><br/>";
  echo "</form>";
            
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<br/><br/><a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
    echo "</p>";
    echo xhtmlfoot();
}

//////////////////////////////////////////add vault

else if($action=="addvlt")
{


if(!getplusses(getuid_sid($sid))>25)
    {
        $pstyle = gettheme($sid);
    echo xhtmlhead("FlareZone",$pstyle);
      echo "<p align=\"center\">";
      echo "At least you should have 25 Credits to add an item to your vault<br/><br/>";
      echo "<a href=\"index.php?action=main&amp;sid=$sid\">Home</a>";
      echo "</p>";
      echo xhtmlfoot();

      exit();
    }
    addonline(getuid_sid($sid),"Adding a vault item - xHTML","");

$pstyle = gettheme($sid);
    echo xhtmlhead("Add Vault Item",$pstyle);
    echo "<onevent type=\"onenterforward\">";
  echo "<refresh>
        <setvar name=\"viname\" value=\"\"/>
        <setvar name=\"vilink\" value=\"\"/>
   ";
  echo "</refresh></onevent>";

    echo "<p align=\"center\">";
    echo "<small>The vault is used to store your downloadable links,like images, mp3's, games  etc...<br/>WARNING: if you used it to wapsites links they will got deleted and you'll lose some Credits, if you used it for ranking sites links like 2wap, mradar, you'll be banned</small><br/><br/>";
    echo "<form method=\"post\" action=\"genproc.php?action=addvlt&amp;sid=$sid\">";
    echo "Item Name:<input name=\"viname\" maxlength=\"50\"/><br/>";
    echo "Item Url:<input name=\"vilink\" maxlength=\"255\"/><br/>";
  echo "<input type=\"submit\" name=\"Submit\" value=\"Add\"/><br/>";
  echo "</form>";
      

    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<br/><br/><a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
    echo "</p>";
    echo xhtmlfoot();
}
//////////////////////////////////////////Guestbook

else if($action=="signgb")
{
$who=$_GET["who"];
addonline(getuid_sid($sid),"Signing a guestbook - xHTML","");
if(!cansigngb(getuid_sid($sid), $who))
    {
        $pstyle = gettheme($sid);
    echo xhtmlhead("Sign a Guestbook",$pstyle);
      echo "<p align=\"center\">";
      echo "You cant Sign this user guestbook<br/><br/>";
      echo "<a href=\"index.php?action=main&amp;sid=$sid\">Home</a>";
      echo "</p>";
      echo xhtmlfoot();

      exit();
    }
    

        $pstyle = gettheme($sid);
    echo xhtmlhead("Sign Guestbook",$pstyle);
    echo "<onevent type=\"onenterforward\">";
  echo "<refresh>
        <setvar name=\"msgtxt\" value=\"\"/>
        
   ";
  echo "</refresh></onevent>";

    echo "<p align=\"center\">";
    echo "<form method=\"post\" action=\"genproc.php?action=signgb&amp;sid=$sid\">";
    echo "Text:<input name=\"msgtxt\" maxlength=\"500\"/><br/>";
    echo "<input type=\"hidden\" name=\"who\" value=\"$who\"/>";
    echo "<input type=\"submit\" name=\"Submit\" value=\"Sign\"/><br/>";
    echo "</form>";

    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<br/><br/><a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
    echo "</p>";
    echo xhtmlfoot();
}

else if($action=="online")
{

  addonline(getuid_sid($sid),"Online List - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("Online List",$pstyle);


  //////ALL LISTS SCRIPT <<

    if($page=="" || $page<=0)$page=1;
    $num_items = getnumonline(); //changable
    $items_per_page= 10;
    $num_pages = ceil($num_items/$items_per_page);
    if($page>$num_pages)$page= $num_pages;
    $limit_start = ($page-1)*$items_per_page;

    //changable sql
    $sql = "SELECT
            a.name, b.place, b.userid, sex FROM ibwf_users a
            INNER JOIN ibwf_online b ON a.id = b.userid
            GROUP BY 1,2
            LIMIT $limit_start, $items_per_page
    ";
    echo "<p><small>";
    include("popups.php");
    $mols = mysql_fetch_array(mysql_query("SELECT name, value FROM ibwf_settings WHERE id='2'"));
    print "Most online: <b>$mols[1]</b><br/>";
    $mols = mysql_fetch_array(mysql_query("SELECT ppl, dtm FROM ibwf_mpot WHERE ddt='".date("d m y")."'"));
    print "Most online today only: <b>$mols[0]</b><br/>";
    $items = mysql_query($sql);
    echo mysql_error();
    while ($item = mysql_fetch_array($items))
    {
      if ($item[3]=="M"){
      $icon = "<img src=\"images/male.gif\" alt=\"M\"/>";
      }else
      if ($item[3]=="F"){
      $icon = "<img src=\"images/female.gif\" alt=\"F\"/>";
      }
      $lnk = "<a href=\"index.php?action=viewuser&amp;who=$item[2]&amp;sid=$sid\">$item[0]</a>";
      echo "$icon $lnk - $item[1] <br/>";
    }
    echo "</small></p>";
    echo "<p align=\"center\">";
    if($page>1)
    {
      $ppage = $page-1;
      echo "<a href=\"index.php?action=online&amp;page=$ppage&amp;sid=$sid\">&#171;PREV</a> ";
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
      echo "<a href=\"index.php?action=online&amp;page=$npage&amp;sid=$sid\">Next&#187;</a>";
    }
    echo "<br/>$page/$num_pages<br/>";
    if($num_pages>2)
    {
      echo getjumper($action, $sid,"index");
    }
    echo "</p>";
  ////// UNTILL HERE >>

  echo "<p align=\"center\">";
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo xhtmlfoot();
}
else if($action=="viewpl")
{
  $who = $_GET["who"];
  addonline(getuid_sid($sid),"Viewing a poll - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("View A Poll",$pstyle);
    echo "<p>";
    $uid = getuid_sid($sid);
    $pollid = mysql_fetch_array(mysql_query("SELECT pollid FROM ibwf_users WHERE id='".$who."'"));
    if($pollid[0]>0)
    {
        $polli = mysql_fetch_array(mysql_query("SELECT id, pqst, opt1, opt2, opt3, opt4, opt5, pdt FROM ibwf_polls WHERE id='".$pollid[0]."'"));
        if(trim($polli[1])!="")
        {
            $qst = parsepm($polli[1], $sid);
            echo $qst."<br/><br/>";
            $vdone = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_presults WHERE uid='".$uid."' AND pid='".$pollid[0]."'"));
            $nov = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_presults WHERE pid='".$pollid[0]."'"));
            $nov = $nov[0];
            if($vdone[0]>0)
            {
              $voted= true;
            }else{
              $voted = false;
            }
            $opt1 = $polli[2];
            if (trim($opt1)!="")
            {
              $opt1 = htmlspecialchars($opt1);
              $nov1 = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_presults WHERE pid='".$pollid[0]."' AND ans='1'"));
              $nov1 = $nov1[0];
              if($nov>0)
              {
              $per = floor(($nov1/$nov)*100);
              $rests = "Votes: $nov1($per%)";
              }else{
                $rests = "Votes: 0(0%)";
              }
                if($voted)
                {
                  $lnk = "1.$opt1 <small>$rests</small><br/>";
                }else{
              $lnk = "1.<a href=\"genproc.php?action=votepl&amp;sid=$sid&amp;plid=$pollid[0]&amp;ans=1\">$opt1</a> <small>$rests</small><br/>";
              }
              echo "$lnk";
            }
            $opt2 = $polli[3];
            if (trim($opt2)!="")
            {
              $opt2 = htmlspecialchars($opt2);
              $nov2 = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_presults WHERE pid='".$pollid[0]."' AND ans='2'"));
              $nov2 = $nov2[0];
              if($nov>0)
              {
              $per = floor(($nov2/$nov)*100);
              $rests = "Votes: $nov2($per%)";
              }else{
                $rests = "Votes: 0(0%)";
              }
              if($voted)
                {
                  $lnk = "2.$opt2 <small>$rests</small><br/>";
                }else{
              $lnk = "2.<a href=\"genproc.php?action=votepl&amp;sid=$sid&amp;plid=$pollid[0]&amp;ans=2\">$opt2</a> <small>$rests</small><br/>";
              }
              echo "$lnk";
            }
            $opt3 = $polli[4];
            if (trim($opt3)!="")
            {
              $opt3 = htmlspecialchars($opt3);
              $nov3 = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_presults WHERE pid='".$pollid[0]."' AND ans='3'"));
              $nov3 = $nov3[0];
              if($nov>0)
              {
              $per = floor(($nov3/$nov)*100);
              $rests = "Votes: $nov3($per%)";
              }else{
                $rests = "Votes: 0(0%)";
              }
              if($voted)
                {
                  $lnk = "3.$opt3 <small>$rests</small><br/>";
                }else{
              $lnk = "3.<a href=\"genproc.php?action=votepl&amp;sid=$sid&amp;plid=$pollid[0]&amp;ans=3\">$opt3</a> <small>$rests</small><br/>";
              }
              echo "$lnk";
            }
            $opt4 = $polli[5];
            if (trim($opt4)!="")
            {
              $opt4 = htmlspecialchars($opt4);
              $nov4 = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_presults WHERE pid='".$pollid[0]."' AND ans='4'"));
              $nov4 = $nov4[0];
              if($nov>0)
              {
              $per = floor(($nov4/$nov)*100);
              $rests = "Votes: $nov4($per%)";
              }else{
                $rests = "Votes: 0(0%)";
              }
              if($voted)
                {
                  $lnk = "4.$opt4 <small>$rests</small><br/>";
                }else{
              $lnk = "4.<a href=\"genproc.php?action=votepl&amp;sid=$sid&amp;plid=$pollid[0]&amp;ans=4\">$opt4</a> <small>$rests</small><br/>";
              }
              echo "$lnk";
            }
            $opt5 = $polli[6];
            if (trim($opt5)!="")
            {
              $opt5 = htmlspecialchars($opt5);
              $nov5 = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_presults WHERE pid='".$pollid[0]."' AND ans='5'"));
              $nov5 = $nov5[0];
              if($nov>0)
              {
              $per = floor(($nov5/$nov)*100);
              $rests = "Votes: $nov5($per%)";
              }else{
                $rests = "Votes: 0(0%)";
              }
              if($voted)
                {
                  $lnk = "5.$opt5 <small>$rests</small><br/>";
                }else{
              $lnk = "5.<a href=\"genproc.php?action=votepl&amp;sid=$sid&amp;plid=$pollid[0]&amp;ans=5\">$opt5</a> <small>$rests</small><br/>";
              }
              echo "$lnk";
            }
            echo "<small>".date("d m y - H:i",$polli[7])."</small>";
        }else{
            echo "<img src=\"images/notok.gif\" alt=\"x\"/>This poll doesn't exist";
        }
    }else{
        echo "<img src=\"images/notok.gif\" alt=\"x\"/>This user have no poll";
    }
    echo "</p>";
    echo "<p align=\"center\">";
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo xhtmlfoot();
    
}

else if($action=="viewtpl")
{
  $who = $_GET["who"];
  addonline(getuid_sid($sid),"Viewing a poll - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("View A Poll",$pstyle);
    echo "<p>";
    $uid = getuid_sid($sid);
    $pollid = mysql_fetch_array(mysql_query("SELECT pollid FROM ibwf_topics WHERE id='".$who."'"));
    if($pollid[0]>0)
    {
        $polli = mysql_fetch_array(mysql_query("SELECT id, pqst, opt1, opt2, opt3, opt4, opt5, pdt FROM ibwf_polls WHERE id='".$pollid[0]."'"));
        if(trim($polli[1])!="")
        {
            $qst = parsepm($polli[1], $sid);
            echo $qst."<br/><br/>";
            $vdone = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_presults WHERE uid='".$uid."' AND pid='".$pollid[0]."'"));
            $nov = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_presults WHERE pid='".$pollid[0]."'"));
            $nov = $nov[0];
            if($vdone[0]>0)
            {
              $voted= true;
            }else{
              $voted = false;
            }
            $opt1 = $polli[2];
            if (trim($opt1)!="")
            {
              $opt1 = htmlspecialchars($opt1);
              $nov1 = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_presults WHERE pid='".$pollid[0]."' AND ans='1'"));
              $nov1 = $nov1[0];
              if($nov>0)
              {
              $per = floor(($nov1/$nov)*100);
              $rests = "Votes: $nov1($per%)";
              }else{
                $rests = "Votes: 0(0%)";
              }
                if($voted)
                {
                  $lnk = "1.$opt1 <small>$rests</small><br/>";
                }else{
              $lnk = "1.<a href=\"genproc.php?action=votepl&amp;sid=$sid&amp;plid=$pollid[0]&amp;ans=1\">$opt1</a> <small>$rests</small><br/>";
              }
              echo "$lnk";
            }
            $opt2 = $polli[3];
            if (trim($opt2)!="")
            {
              $opt2 = htmlspecialchars($opt2);
              $nov2 = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_presults WHERE pid='".$pollid[0]."' AND ans='2'"));
              $nov2 = $nov2[0];
              if($nov>0)
              {
              $per = floor(($nov2/$nov)*100);
              $rests = "Votes: $nov2($per%)";
              }else{
                $rests = "Votes: 0(0%)";
              }
              if($voted)
                {
                  $lnk = "2.$opt2 <small>$rests</small><br/>";
                }else{
              $lnk = "2.<a href=\"genproc.php?action=votepl&amp;sid=$sid&amp;plid=$pollid[0]&amp;ans=2\">$opt2</a> <small>$rests</small><br/>";
              }
              echo "$lnk";
            }
            $opt3 = $polli[4];
            if (trim($opt3)!="")
            {
              $opt3 = htmlspecialchars($opt3);
              $nov3 = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_presults WHERE pid='".$pollid[0]."' AND ans='3'"));
              $nov3 = $nov3[0];
              if($nov>0)
              {
              $per = floor(($nov3/$nov)*100);
              $rests = "Votes: $nov3($per%)";
              }else{
                $rests = "Votes: 0(0%)";
              }
              if($voted)
                {
                  $lnk = "3.$opt3 <small>$rests</small><br/>";
                }else{
              $lnk = "3.<a href=\"genproc.php?action=votepl&amp;sid=$sid&amp;plid=$pollid[0]&amp;ans=3\">$opt3</a> <small>$rests</small><br/>";
              }
              echo "$lnk";
            }
            $opt4 = $polli[5];
            if (trim($opt4)!="")
            {
              $opt4 = htmlspecialchars($opt4);
              $nov4 = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_presults WHERE pid='".$pollid[0]."' AND ans='4'"));
              $nov4 = $nov4[0];
              if($nov>0)
              {
              $per = floor(($nov4/$nov)*100);
              $rests = "Votes: $nov4($per%)";
              }else{
                $rests = "Votes: 0(0%)";
              }
              if($voted)
                {
                  $lnk = "4.$opt4 <small>$rests</small><br/>";
                }else{
              $lnk = "4.<a href=\"genproc.php?action=votepl&amp;sid=$sid&amp;plid=$pollid[0]&amp;ans=4\">$opt4</a> <small>$rests</small><br/>";
              }
              echo "$lnk";
            }
            $opt5 = $polli[6];
            if (trim($opt5)!="")
            {
              $opt5 = htmlspecialchars($opt5);
              $nov5 = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_presults WHERE pid='".$pollid[0]."' AND ans='5'"));
              $nov5 = $nov5[0];
              if($nov>0)
              {
              $per = floor(($nov5/$nov)*100);
              $rests = "Votes: $nov5($per%)";
              }else{
                $rests = "Votes: 0(0%)";
              }
              if($voted)
                {
                  $lnk = "5.$opt5 <small>$rests</small><br/>";
                }else{
              $lnk = "5.<a href=\"genproc.php?action=votepl&amp;sid=$sid&amp;plid=$pollid[0]&amp;ans=5\">$opt5</a> <small>$rests</small><br/>";
              }
              echo "$lnk";
            }
            echo "<small>".date("d m y - H:i",$polli[7])."</small>";
        }else{
            echo "<img src=\"images/notok.gif\" alt=\"x\"/>This poll doesn't exist";
        }
    }else{
        echo "<img src=\"images/notok.gif\" alt=\"x\"/>This user have no poll";
    }
    echo "</p>";
    echo "<p align=\"center\">";
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo xhtmlfoot();

}
else if($action=="stfol")
{

  addonline(getuid_sid($sid),"Staff online list - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("Staff Online",$pstyle);


  //////ALL LISTS SCRIPT <<

    if($page=="" || $page<=0)$page=1;
    $timeout = 180;
  $timeon = time()  - $timeout;
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE perm>'0' AND lastact>'".$timeon."'"));
    $num_items = $noi[0]; //changable
    $items_per_page= 10;
    $num_pages = ceil($num_items/$items_per_page);
    if($page>$num_pages)$page= $num_pages;
    $limit_start = ($page-1)*$items_per_page;
    if($limit_start<0)$limit_start=0;
    //changable sql
    $sql = "
    SELECT name, perm, id FROM ibwf_users WHERE perm>'0' AND lastact>'".$timeon."'
            LIMIT $limit_start, $items_per_page
    ";
    echo "<p><small>";
    include("popups.php");
    $items = mysql_query($sql);
    echo mysql_error();
    while ($item = mysql_fetch_array($items))
    {
      $lnk = "<a href=\"index.php?action=viewuser&amp;who=$item[2]&amp;sid=$sid\">$item[0]</a>";
      if($item[1]==1)
      {
        $item[1] = "<font color=\"0000FF\">Moderator!</font>";
        $icon = "<img src=\"images/mod.gif\" alt=\"M\"/>";
      }
      else if($item[1]==2)
      {
        $item[1] = "<font color=\"FF0000\">Admin!</font>";
        $icon = "<img src=\"images/admin.gif\" alt=\"A\"/>";
      }
      else if($item[1]==3)
      {
        $item[1] = "<font color=\"00FF00\">Owner!</font>";
        $icon = "<img src=\"images/owner.gif\" alt=\"O\"/>";
      }
      echo "$icon $lnk - $item[1] <br/>";
    }
    echo "</small></p>";
    echo "<p align=\"center\">";
    if($page>1)
    {
      $ppage = $page-1;
      echo "<a href=\"index.php?action=$action&amp;page=$ppage&amp;sid=$sid\">&#171;PREV</a> ";
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
      echo "<a href=\"index.php?action=$action&amp;page=$npage&amp;sid=$sid\">Next&#187;</a>";
    }
    echo "<br/>$page/$num_pages<br/>";
    if($num_pages>2)
    {
      echo getjumper($action, $sid,"index");
    }
    echo "</p>";
  ////// UNTILL HERE >>

  echo "<p align=\"center\">";
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo xhtmlfoot();
}
//////////////////////////VIP Online Begin
else if($action=="vipol")
{

  addonline(getuid_sid($sid),"V.I.P online list - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("V.I.P's Online",$pstyle);


  //////ALL LISTS SCRIPT <<

    if($page=="" || $page<=0)$page=1;
    $timeout = 180;
  $timeon = time()  - $timeout;
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE specialid>'0' AND lastact>'".$timeon."'"));
    $num_items = $noi[0]; //changable
    $items_per_page= 10;
    $num_pages = ceil($num_items/$items_per_page);
    if($page>$num_pages)$page= $num_pages;
    $limit_start = ($page-1)*$items_per_page;
    if($limit_start<0)$limit_start=0;
    //changable sql
    $sql = "SELECT name, specialid, id FROM ibwf_users WHERE specialid>'0' AND lastact>'".$timeon."' LIMIT $limit_start, $items_per_page";
    echo "<p><small>";
    include("popups.php");
    $items = mysql_query($sql);
    echo mysql_error();
    while ($item = mysql_fetch_array($items))
    {
      $lnk = "<a href=\"index.php?action=viewuser&amp;who=$item[2]&amp;sid=$sid\">$item[0]</a>";
        if($item[1]=='1')
        {
          $tit = "FlareZone Millionaire!";
        }
        if($item[1]=='2')
        {
          $tit = "FlareZone Quiz Master!";
        }
        if($item[1]=='8')
        {
          $tit = "FlareZone Prince!";
        }
        if($item[1]=='9')
        {
          $tit = "FlareZone Princess!";
        }
       echo "$lnk - $tit <br/>";
    }
    echo "</small></p>";
    echo "<p align=\"center\">";
    if($page>1)
    {
      $ppage = $page-1;
      echo "<a href=\"index.php?action=$action&amp;page=$ppage&amp;sid=$sid\">&#171;PREV</a> ";
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
      echo "<a href=\"index.php?action=$action&amp;page=$npage&amp;sid=$sid\">Next&#187;</a>";
    }
    echo "<br/>$page/$num_pages<br/>";
    if($num_pages>2)
    {
      echo getjumper($action, $sid,"index");
    }
    echo "</p>";
  ////// UNTILL HERE >>

  echo "<p align=\"center\">";
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo xhtmlfoot();
}
//////////////////////////VIP ONLINE END


else if($action=="chbmsg")
{
  addonline(getuid_sid($sid),"Buddy Message - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("Buddy Message",$pstyle);
    echo "<onevent type=\"onenterforward\">";
    $cmsg = htmlspecialchars(getbudmsg(getuid_sid($sid)));
    echo "<refresh>
        <setvar name=\"bmsg\" value=\"$cmsg\"/>";
    echo "</refresh></onevent>";
    echo "<p align=\"center\">";
    echo "<form method=\"post\" action=\"genproc.php?action=upbmsg&amp;sid=$sid\">";
    echo "Text:<input name=\"bmsg\" maxlength=\"100\" value=\"$cmsg\"/><br/>";
    echo "<input type=\"hidden\" name=\"who\" value=\"$who\"/>";
    echo "<input type=\"submit\" name=\"Submit\" value=\"Update\"/><br/>";
    echo "</form>";

            echo "<br/><br/>";
 echo "<a href=\"lists.php?action=buds&amp;sid=$sid\">";
echo "Buddies List</a><br/>";
     $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo xhtmlfoot();
}

/////////////////////////////////viewuser profile

else if($action=="viewuser")
{
 $whonick = getnick_uid($who);
 addonline(getuid_sid($sid),"Viewing $whonick's Profile","");
  $pstyle = gettheme($sid);
    echo xhtmlhead($whonick." Profile",$pstyle);
  echo "<p align=\"center\">";
  if($who==""||$who==0)
  {
    $mnick = $_POST["mnick"];
    $who = getuid_nick($mnick);
  }
  $whonick = getnick_uid($who);
  if($whonick!="")
  {
  echo "$whonick's Profile<br/>";
  include("popups.php");
  echo "<small>";
  echo "<a href=\"inbox.php?action=sendpm&amp;who=$who&amp;sid=$sid\">Send PM</a><br/><br/>";
  echo "<a href=\"lists.php?action=sendto&amp;who=$who&amp;sid=$sid\">Send PoP Up MSG</a><br/><br/>";
  if(cansee(getuid_sid($sid), $who))
  {
    
    $unol = mysql_fetch_array(mysql_query("SELECT lastpnreas FROM ibwf_users WHERE id='".$who."'"));
    if($unol[0]!="")
    {
      echo "Last Penalty Reason: $unol[0]<br/>";
    }
    $unol = mysql_fetch_array(mysql_query("SELECT lastplreas FROM ibwf_users WHERE id='".$who."'"));
    if($unol[0]!="")
    {
      echo "Last Credits Reason: $unol[0]<br/>";
    }
    echo "";
  }
  $uid = getuid_sid($sid);
  if(budres($uid, $who)==0)
  {
    echo "<a href=\"genproc.php?action=bud&amp;who=$who&amp;sid=$sid&amp;todo=add\">Add to buddy list</a><br/>";
  }
  $ires = ignoreres($uid, $who);
  if(es==2)
  {
    echo "<a href=\"genproc.php?action=ign&amp;who=$who&amp;sid=$sid&amp;todo=del\">Remove From Ignore list</a><br/>";
  }else if($ires==1)
  {
    echo "<a href=\"genproc.php?action=ign&amp;who=$who&amp;sid=$sid&amp;todo=add\">Add to Ignore list</a><br/>";
  }
  echo "<a href=\"userfun.php?action=profile&amp;who=$who&amp;sid=$sid\">Fun and Games</a><br/>";
  $avlink = getavatar($who);
  if ($avlink=="")
  { 
  echo "<br/><img src=\"images/nopic.jpg\" alt=\"avatar\"/>";
  }else{
  echo "<br/><img src=\"$avlink\" alt=\"avatar\"/>";
  }
  echo "</small>";
  echo "</p>";
  echo "<p>";
  echo "<small>";
  echo "Member's ID: <b>$who</b><br/>";
  echo "Status: <b>".getstatus($who)."</b><br/>";
  $nopl = mysql_fetch_array(mysql_query("SELECT sex, birthday, location FROM ibwf_users WHERE id='".$who."'"));
  $uage = getage($nopl[1]);
  if($nopl[0]=='M')
  {
    $usex = "Male";
  }else if($nopl[0]=='F'){
    $usex = "Female";
  }else{
    $usex = "Shemale";
  }
  $nopl[2] = htmlspecialchars($nopl[2]);
  echo "A/S/L: <b>$uage/$usex/$nopl[2]</b><br/>";
  $staters2 = mysql_fetch_array(mysql_query("SELECT stats2 FROM ibwf_users WHERE id='".$who."'"));
  $stats2 = parsepm($staters2[0], $sid);
  echo "Online Status: <b>$stats2</b><br/>";
  $staters = mysql_fetch_array(mysql_query("SELECT stats FROM ibwf_users WHERE id='".$who."'"));
  $stats = parsepm($staters[0], $sid);
  echo "Martial Status: <b>$stats</b><br/>";
  $unol = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_topics WHERE authorid='".$who."'"));
  $tlink = "<a href=\"lists.php?action=tbuid&amp;sid=$sid&amp;who=$who\">$unol[0]</a>";
  echo "Topics: <b>$tlink</b><br/>";
  $unop = mysql_fetch_array(mysql_query("SELECT posts FROM ibwf_users WHERE id='".$who."'"));
  $unol = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_posts WHERE uid='".$who."'"));
  $plink = "<a href=\"lists.php?action=uposts&amp;sid=$sid&amp;who=$who\">$unol[0]</a>";
  echo "Posts: <b>$plink/$unop[0]</b><br/>";
  $noin = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE touid='".$who."'"));
  $nout = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE byuid='".$who."'"));
  echo "PMs IN: <b>$noin[0]</b> - OUT: <b>$nout[0]</b><br/>";
  $nopl = mysql_fetch_array(mysql_query("SELECT plusses FROM ibwf_users WHERE id='".$who."'"));
  echo "Credits: <b>$nopl[0]</b><br/>";
  $nopl = mysql_fetch_array(mysql_query("SELECT chmsgs FROM ibwf_users WHERE id='".$who."'"));
  echo "Chat Posts: <b>$nopl[0]</b><br/>";
  $nopl = mysql_fetch_array(mysql_query("SELECT battlep FROM ibwf_users WHERE id='".$who."'"));
  echo "Battle Points: <b>$nopl[0]</b><br/>";
  $judg = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_judges WHERE uid='".$who."'"));
  if($judg[0]>0)
  {
    echo "<b>Battle Board Judge</b><br/>";
  }
  $nout = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_shouts WHERE shouter='".$who."'"));
  $nopl = mysql_fetch_array(mysql_query("SELECT shouts FROM ibwf_users WHERE id='".$who."'"));
  echo "Shouts: <b><a href=\"lists.php?action=shouts&amp;sid=$sid&amp;who=$who\">$nout[0]</a>/$nopl[0]</b><br/>";
  $nopl = mysql_fetch_array(mysql_query("SELECT regdate FROM ibwf_users WHERE id='".$who."'"));
  $jdt = date("d m y-H:i:s",$nopl[0]);
  echo "Joined FlareZone: <b>$jdt</b><br/>";
  $nopl = mysql_fetch_array(mysql_query("SELECT lastact FROM ibwf_users WHERE id='".$who."'"));
  $jdt = date("d m y-H:i:s",$nopl[0]);
  echo "Last Active: <b>$jdt</b><br/>";
  $nopl = mysql_fetch_array(mysql_query("SELECT lastvst FROM ibwf_users WHERE id='".$who."'"));
  $jdt = date("d m y-H:i:s",$nopl[0]);
  echo "Last Visit: <b>$jdt</b><br/>";
  $nopl = mysql_fetch_array(mysql_query("SELECT browserm FROM ibwf_users WHERE id='".$who."'"));
  echo "Browser: <b>$nopl[0]</b><br/>";
  $langs = mysql_fetch_array(mysql_query("SELECT langz FROM ibwf_users WHERE id='".$who."'"));
  $langz = parsepm($langs[0], $sid);
  echo "Language: <b>$langz</b><br/>";
  $nopl = mysql_fetch_array(mysql_query("SELECT email FROM ibwf_users WHERE id='".$who."'"));
  echo "E-mail: <b>$nopl[0]</b><br/>";
  $referals = mysql_fetch_array(mysql_query("SELECT referal FROM ibwf_users WHERE id='".$who."'"));
  $referal = parsepm($referals[0], $sid);
  echo "FlareZone Referal: <b>$referal</b><br/>";
  $nopl = mysql_fetch_array(mysql_query("SELECT site FROM ibwf_users WHERE id='".$who."'"));
  $nopl[0] = strtolower($nopl[0]);
  echo "Site: <a href=\"$nopl[0]\">$nopl[0]</a><br/>";
  $nopl = mysql_fetch_array(mysql_query("SELECT signature FROM ibwf_users WHERE id='".$who."'"));
  $sign = parsepm($nopl[0], $sid);
  echo "Signature: $sign<br/>";
  if(ismod(getuid_sid($sid)))
   {
     $uipadd = mysql_fetch_array(mysql_query("SELECT ipadd FROM ibwf_users WHERE id='".$who."'"));
     echo "IP:<a href=\"lists.php?action=byip&amp;sid=$sid&amp;who=$who\">$uipadd[0]</a><br/>";
     $nob = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_buddies WHERE (uid='".$who."' OR tid='".$who."') AND agreed='1'"));
	 echo "Buddies: $nob[0]<br/>";
   }
  echo "<br/><a href=\"uinfo.php?who=$who&amp;sid=$sid\">More Information</a><br/>";
  echo "<a href=\"users?$whonick\">$whonick's Personal Wap Site</a><br/><br/>";
  echo "</small>";
  echo "</p>";
   echo "<p align=\"center\">";
   $noi = mysql_fetch_array(mysql_query("SELECT pollid FROM ibwf_users WHERE id='".$who."'"));
   if($noi[0]>0)
   {
   echo "<a href=\"index.php?action=viewpl&amp;who=$who&amp;sid=$sid\">Poll</a><br/>";
 }
 $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubs WHERE owner='".$who."'"));
   if($noi[0]>0)
   {
   echo "<a href=\"lists.php?action=ucl&amp;who=$who&amp;sid=$sid\">Clubs($noi[0])</a><br/>";
 }
 $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubmembers WHERE uid='".$who."'"));
   if($noi[0]>0)
   {
   echo "<a href=\"lists.php?action=clm&amp;who=$who&amp;sid=$sid\">Member In $noi[0] Clubs</a><br/>";
   }
   $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_blogs WHERE bowner='".$who."'"));
   if($noi[0]>0)
   {
   echo "<a href=\"lists.php?action=blogs&amp;who=$who&amp;sid=$sid\">Blogs($noi[0])</a><br/>";
 }
 $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_vault WHERE uid='".$who."'"));
   if($noi[0]>0)
   {
   echo "<a href=\"lists.php?action=vault&amp;who=$who&amp;sid=$sid\">Vault($noi[0])</a><br/>";
   }
   $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_gbook WHERE gbowner='".$who."'"));
   echo "<a href=\"lists.php?action=gbook&amp;who=$who&amp;sid=$sid\">Guestbook($noi[0])</a><br/>";
   $judg = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_judges WHERE uid='".getuid_sid($sid)."'"));
   if(ismod(getuid_sid($sid))||$judg[0]>0)
   {
    echo "<a href=\"index.php?action=batp&amp;who=$who&amp;sid=$sid\">Battle Points</a><br/>";
   }
   
   if(ismod(getuid_sid($sid)))
   {
     echo "<a href=\"modcp.php?action=user&amp;who=$who&amp;sid=$sid&amp;who=$who\">Mod CP</a><br/>";
   }
   }else{
     echo "<img src=\"images/notok.gif\" alt=\"X\"/> Member dos not exist<br/>";
   }
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));
    echo "<br/><a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo xhtmlfoot();

}

////////////////////////////////////////// uxset
else if($action=="uxset")
{
    addonline(getuid_sid($sid),"Extended Settings - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("Extended Settings",$pstyle);
    echo "<p>";
    echo "<a href=\"index.php?action=uadd&amp;sid=$sid\">&#187;My Address</a><br/>";
    echo "<a href=\"index.php?action=uper&amp;sid=$sid\">&#187;Personality</a><br/>";
    //echo "<a href=\"index.php?action=gmset&amp;sid=$sid\">&#187;Gmail Settings</a><br/>";
    echo "<a href=\"index.php?action=umin&amp;sid=$sid\">&#187;More about me</a><br/>";
    echo "<a href=\"index.php?action=upre&amp;sid=$sid\">&#187;Preferences</a><br/>";
    
    
    echo "</p>";
    echo "<p align=\"center\">";

    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

//////////////////////////////////////////User Address

else if($action=="uadd")
{
    addonline(getuid_sid($sid),"My Address - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("My Address",$pstyle);
    echo "<onevent type=\"onenterforward\">";
    $ainfo = mysql_fetch_array(mysql_query("SELECT country, city, street, phoneno, timezone FROM ibwf_xinfo WHERE uid='".getuid_sid($sid)."'"));
    echo "<refresh>
        <setvar name=\"ucon\" value=\"$ainfo[0]\"/>
        <setvar name=\"ucit\" value=\"$ainfo[1]\"/>
        <setvar name=\"ustr\" value=\"$ainfo[2]\"/>
        <setvar name=\"utzn\" value=\"$ainfo[4]\"/>
        <setvar name=\"uphn\" value=\"$ainfo[3]\"/>";
    echo "</refresh></onevent>";
    echo "<p>";
    echo "<small><img src=\"images/point.gif\" alt=\"!\"/>Go to Preferences and choose buddies only if you want only your buddies to see your street and phone number<br/>";
    echo "<img src=\"images/point.gif\" alt=\"!\"/>If you don't anyone to see these information just don't type them<br/>";
    echo "<img src=\"images/point.gif\" alt=\"!\"/>Timezone is required to get your e-mails from G-Mail account in your local time.<br/>";
    echo "<img src=\"images/point.gif\" alt=\"!\"/>Example on timezone is 2 for +2 hours on GMT, or -2.5 for -2:30 on GMT<br/>";
    echo "<img src=\"images/point.gif\" alt=\"!\"/>These info. will help you to meet friends and dates from where do you live<br/><br/></small>";
    
    echo "<form method=\"post\" action=\"genproc.php?action=uadd&amp;sid=$sid\">";
    echo "Contry: <input name=\"ucon\" maxlength=\"50\" value=\"$ainfo[0]\"/><br/>";
    echo "City: <input name=\"ucit\" maxlength=\"50\" value=\"$ainfo[1]\"/><br/>";
    echo "Street: <input name=\"ustr\" maxlength=\"50\" value=\"$ainfo[2]\"/><br/>";
    echo "Timezone<small>(e.g +2 or -2.5)</small>: <input name=\"utzn\" size=\"5\" value=\"$ainfo[4]\" maxlength=\"5\"/><br/>";
    echo "Phone No.: <input name=\"uphn\" maxlength=\"20\" value=\"$ainfo[3]\"/><br/>";
    echo "<input type=\"submit\" name=\"Submit\" value=\"Submit\"/><br/>";
    echo "</form>";
    
    echo "</p>";
    echo "<p align=\"center\">";
    echo "<a href=\"index.php?action=uxset&amp;sid=$sid\">";
echo "Extended Settings</a><br/>";
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}


//////////////////////////////////////////User Preferences

else if($action=="upre")
{
    addonline(getuid_sid($sid),"Preferences - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("Preferences",$pstyle);
    echo "<onevent type=\"onenterforward\">";
    $ainfo = mysql_fetch_array(mysql_query("SELECT sitedscr, budsonly, sexpre FROM ibwf_xinfo WHERE uid='".getuid_sid($sid)."'"));
    echo "<refresh>
        <setvar name=\"usds\" value=\"$ainfo[0]\"/>
        <setvar name=\"ubon\" value=\"$ainfo[1]\"/>
        <setvar name=\"usxp\" value=\"$ainfo[2]\"/>";
    echo "</refresh></onevent>";
    echo "<p>";
    echo "<small><img src=\"images/point.gif\" alt=\"!\"/>Your site already set in your normal settings<br/>";
    echo "<img src=\"images/point.gif\" alt=\"!\"/>Set buddies only to yes, so only your buddies can see your phone number, street, and real name<br/>";
    echo "<img src=\"images/point.gif\" alt=\"!\"/>Sex preference will help the correct people to find you<br/><br/></small>";
    
     if($theme[0]=="1"){
    echo "<option value=\"1\" selected=\"1\">Methos Default</option>";
    }else{
    echo "<option value=\"1\">White (Default)</option>";
    }
    
    echo "<form method=\"post\" action=\"genproc.php?action=upre&amp;sid=$sid\">";
    echo "Site description: <input name=\"usds\" maxlength=\"200\" value=\"$ainfo[0]\"/><br/>";
    echo "Buddies Only:";
    echo "<select name=\"ubon\" value=\"$ainfo[1]\">";
    if($ainfo[1]=="1"){
    echo "<option value=\"1\" selected=\"1\">Yes</option>";
    }else{
    echo "<option value=\"1\">Yes</option>";
    }
    if($ainfo[1]=="0"){
    echo "<option value=\"0\" selected=\"0\">No</option>";
    }else{
    echo "<option value=\"0\">No</option>";
    }
    echo "</select>";
    echo "<br/>Sex Preference:";
    echo "<select name=\"usxp\" value=\"$ainfo[2]\">";
    if($ainfo[2]=="F"){
    echo "<option value=\"F\" selected=\"F\">Females</option>";
    }else{
    echo "<option value=\"F\">Females</option>";
    }
    if($ainfo[2]=="M"){
    echo "<option value=\"M\" selected=\"M\">Males</option>";
    }else{
    echo "<option value=\"M\">Males</option>";
    }
    if($ainfo[2]=="B"){
    echo "<option value=\"B\" selected=\"B\">Both</option>";
    }else{
    echo "<option value=\"B\">Both</option>";
    }
    echo "</select>";
    echo "<br/><input type=\"submit\" name=\"Submit\" value=\"Submit\"/><br/>";
    echo "</form>";
   
    echo "</p>";
    echo "<p align=\"center\">";
    echo "<a href=\"index.php?action=uxset&amp;sid=$sid\">";
echo "Extended Settings</a><br/>";
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

//////////////////////////////////////////User Personaliy

else if($action=="uper")
{
    addonline(getuid_sid($sid),"Personality - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("Personality",$pstyle);
    echo "<onevent type=\"onenterforward\">";
    $ainfo = mysql_fetch_array(mysql_query("SELECT height, weight, realname, racerel, eyescolor, profession, hairtype FROM ibwf_xinfo WHERE uid='".getuid_sid($sid)."'"));
    echo "<refresh>
        <setvar name=\"uhig\" value=\"$ainfo[0]\"/>
        <setvar name=\"uwgt\" value=\"$ainfo[1]\"/>
        <setvar name=\"urln\" value=\"$ainfo[2]\"/>
        <setvar name=\"ueor\" value=\"$ainfo[3]\"/>
        <setvar name=\"ueys\" value=\"$ainfo[4]\"/>
        <setvar name=\"uher\" value=\"$ainfo[6]\"/>
        <setvar name=\"upro\" value=\"$ainfo[5]\"/>";
    echo "</refresh></onevent>";
    echo "<p>";
    
    echo "<form method=\"post\" action=\"genproc.php?action=uper&amp;sid=$sid\">";
    echo "Height: <input name=\"uhig\" maxlength=\"10\" value=\"$ainfo[0]\"/><br/>";
    echo "Weight: <input name=\"uwgt\" maxlength=\"10\" value=\"$ainfo[1]\"/><br/>";
    echo "Real Name: <input name=\"urln\" maxlength=\"100\" value=\"$ainfo[2]\"/><br/>";
    echo "Ethnic Origin: <input name=\"ueor\" maxlength=\"100\" value=\"$ainfo[3]\"/><br/>";
    echo "Eyes: <input name=\"ueys\" maxlength=\"10\" value=\"$ainfo[4]\"/><br/>";
    echo "Hair: <input name=\"uher\" maxlength=\"50\" value=\"$ainfo[6]\"/><br/>";
    echo "Profession: <input name=\"upro\" maxlength=\"100\" value=\"$ainfo[5]\"/><br/>";
    echo "<input type=\"submit\" name=\"Submit\" value=\"Submit\"/><br/>";
    echo "</form>";
    
    echo "</p>";
    echo "<p align=\"center\">";
    echo "<a href=\"index.php?action=uxset&amp;sid=$sid\">";
echo "Extended Settings</a><br/>";
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

//////////////////////////////////////////User Personaliy

else if($action=="umin")
{
    addonline(getuid_sid($sid),"More About Me - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("More About Me",$pstyle);
    echo "<onevent type=\"onenterforward\">";
    $ainfo = mysql_fetch_array(mysql_query("SELECT likes, deslikes, habitsb, habitsg, favsport, favmusic, moretext FROM ibwf_xinfo WHERE uid='".getuid_sid($sid)."'"));
    echo "<refresh>
        <setvar name=\"ulik\" value=\"$ainfo[0]\"/>
        <setvar name=\"udlk\" value=\"$ainfo[1]\"/>
        <setvar name=\"ubht\" value=\"$ainfo[2]\"/>
        <setvar name=\"ught\" value=\"$ainfo[3]\"/>
        <setvar name=\"ufsp\" value=\"$ainfo[4]\"/>
        <setvar name=\"ufmc\" value=\"$ainfo[5]\"/>
        <setvar name=\"umtx\" value=\"$ainfo[6]\"/>";
    echo "</refresh></onevent>";
    echo "<p>";
    
    echo "<form method=\"post\" action=\"genproc.php?action=umin&amp;sid=$sid\">";
    echo "Likes: <input name=\"ulik\" maxlength=\"250\" value=\"$ainfo[0]\"/><br/>";
    echo "Dislikes: <input name=\"udlk\" maxlength=\"250\" value=\"$ainfo[1]\"/><br/>";
    echo "Bad Habbits: <input name=\"ubht\" maxlength=\"250\" value=\"$ainfo[2]\"/><br/>";
    echo "Good Habbits: <input name=\"ught\" maxlength=\"250\" value=\"$ainfo[3]\"/><br/>";
    echo "Favorite Sports: <input name=\"ufsp\" maxlength=\"100\" value=\"$ainfo[4]\"/><br/>";
    echo "Favorite Music: <input name=\"ufmc\" maxlength=\"100\" value=\"$ainfo[5]\"/><br/>";
    echo "More Text: <input name=\"umtx\" maxlength=\"500\" value=\"$ainfo[6]\"/><br/>";
    echo "<input type=\"submit\" name=\"Submit\" value=\"Submit\"/><br/>";
    echo "</form>";
    
    echo "</p>";
    echo "<p align=\"center\">";
    echo "<a href=\"index.php?action=uxset&amp;sid=$sid\">";
echo "Extended Settings</a><br/>";
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

//////////////////////////////////////////G-Mail Settings

else if($action=="gmset")
{
    addonline(getuid_sid($sid),"GMail Settings - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("GMail Settings",$pstyle);
    echo "<onevent type=\"onenterforward\">";
    $ainfo = mysql_fetch_array(mysql_query("SELECT gmailun, gmailpw, gmailchk FROM ibwf_xinfo WHERE uid='".getuid_sid($sid)."'"));
    echo "<refresh>
        <setvar name=\"ugun\" value=\"$ainfo[0]\"/>
        <setvar name=\"ugpw\" value=\"$ainfo[1]\"/>
        <setvar name=\"ugch\" value=\"$ainfo[2]\"/>";
    echo "</refresh></onevent>";
    echo "<p>";
    echo "<small><img src=\"images/point.gif\" alt=\"!\"/>Set these values only if you want to be auto-logged in your gmail account<br/>";
    echo "<img src=\"images/point.gif\" alt=\"!\"/>Put in the checking field the time you want ravingwap to check your g-mail account<br/>";
    echo "<img src=\"images/point.gif\" alt=\"!\"/>Putting less than 20 minutes could slow your navigation throw ravingwap, suggested period is 30 minutes<br/>";
    echo "<img src=\"images/point.gif\" alt=\"!\"/>Valid values 0 - 99 minutes, 0 will check your e-mail with every action you make in ravingwap<br/><br/></small>";
    echo '
    G-Mail Username: <input name="ugun" maxlength="100"/><br/>
    G-Mail Password: <input name="ugpw" maxlength="200"/><br/>
    G-Mail Checking: <input name="ugch" format="*N" size="2" maxlength="2"/><br/>
    ';
    echo "<anchor>Submit";
    echo "<go href=\"genproc.php?action=gmset&amp;sid=$sid\" method=\"post\">";
    echo "<postfield name=\"ugun\" value=\"$(ugun)\"/>";
    echo "<postfield name=\"ugpw\" value=\"$(ugpw)\"/>";
    echo "<postfield name=\"ugch\" value=\"$(ugch)\"/>";
    echo "</go></anchor>";
    echo "</p>";
    echo "<p align=\"center\">";
    echo "<a href=\"index.php?action=uxset&amp;sid=$sid\">";
echo "Extended Settings</a><br/>";
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();
}

//////////////////////////////////////////Give Game Plusses

else if($action=="givegp")
{
  $who = $_GET["who"];
  addonline(getuid_sid($sid),"Giving GPs - xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("Give GPs",$pstyle);
    echo "<onevent type=\"onenterforward\">";
    echo "<refresh>
        <setvar name=\"tfgp\" value=\"0\"/>";
    echo "</refresh></onevent>";
  echo "<p align=\"center\">";
  echo "<b>Give GPs To ".getnick_uid($who)."</b><br/><br/>";
  $gps = mysql_fetch_array(mysql_query("SELECT gplus FROM ibwf_users WHERE id='".getuid_sid($sid)."'"));
  echo "You have $gps[0] GP's<br/><br/>";
  echo "GP's to give<br/>";
  echo "<input name=\"tfgp\" format=\"*N\" maxlength=\"2\"/>";
  echo "<br/><anchor>Give";
  echo "<a href=\"index.php?action=main&amp;sid=$sid\">";
  echo "<postfield name=\"ptg\" value=\"$(tfgp)\"/>";
  echo "</go></anchor>";
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<br/><br/><a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo xhtmlfoot();
}

//////////////////////////////////////////Give Battle points

else if($action=="batp")
{
  $who = $_GET["who"];
  addonline(getuid_sid($sid),"Giving Battle Points - xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("Give BP",$pstyle);
    echo "<onevent type=\"onenterforward\">";
    echo "<refresh>
        <setvar name=\"tfbp\" value=\"0\"/>";
    echo "</refresh></onevent>";
  echo "<p align=\"center\">";
  $judg = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_judges WHERE uid='".getuid_sid($sid)."'"));
  if(ismod(getuid_sid($sid))||$judg[0]>0)
  {


  echo "<b>Give/Take BPs To ".getnick_uid($who)."</b><br/><br/>";
  echo "<input name=\"tfbp\" format=\"*N\" maxlength=\"2\"/>";
  echo "<br/><anchor>Add";
  echo "<go href=\"genproc.php?action=batp&amp;sid=$sid&amp;who=$who\" method=\"post\">";
  echo "<postfield name=\"ptbp\" value=\"$(tfbp)\"/>";
  echo "<postfield name=\"giv\" value=\"1\"/>";
  echo "</go></anchor><br/>";
  echo "<anchor>Remove";
  echo "<go href=\"genproc.php?action=batp&amp;sid=$sid&amp;who=$who\" method=\"post\">";
  echo "<postfield name=\"ptbp\" value=\"$(tfbp)\"/>";
  echo "<postfield name=\"giv\" value=\"0\"/>";
  echo "</go></anchor><br/><br/>";
  }else{
    echo "You Can't Do This";
  }
    $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<br/><br/><a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo xhtmlfoot();
}

//////////////////////////////////////////Post Options

else if($action=="pstopt")
{
  $pid = $_GET["pid"];
  $page = $_GET["page"];
  $fid = $_GET["fid"];
    addonline(getuid_sid($sid),"Post Options - xHTML","");
    $pinfo= mysql_fetch_array(mysql_query("SELECT uid,tid, text  FROM ibwf_posts WHERE id='".$pid."'"));
    $trid = $pinfo[0];
    $tid = $pinfo[1];
    $ptext = htmlspecialchars($pinfo[2]);
    $pstyle = gettheme($sid);
    echo xhtmlhead("Post Options",$pstyle);
    echo "<onevent type=\"onenterforward\">";
    echo "<refresh>
        <setvar name=\"ptext\" value=\"$ptext\"/>";
    echo "</refresh></onevent>";
  echo "<p align=\"center\">";
  echo "<b>Post Options</b>";
  
  echo "</p>";
  echo "<p>";
  $trnick = getnick_uid($trid);
  echo "<a href=\"inbox.php?action=sendpm&amp;sid=$sid&amp;who=$trid\">&#187;Send PM to $trnick</a><br/>";
  echo "<a href=\"index.php?action=viewuser&amp;sid=$sid&amp;who=$trid\">&#187;View $trnick's Profile</a><br/>";
  //echo "<a href=\"index.php?action=post&amp;sid=$sid&amp;tid=$tid&amp;qut=$pid\">&#187;Quote</a><br/>";
  echo "<a href=\"genproc.php?action=rpost&amp;sid=$sid&amp;pid=$pid\">&#187;Report</a><br/>";
  echo "<a href=\"index.php?action=viewtpc&amp;sid=$sid&amp;tid=$tid&amp;page=$page\">&#171;Back to topic</a><br/><br/>";
  if(ismod(getuid_sid($sid)))
  {
    
     echo "<form method=\"post\" action=\"modproc.php?action=edtpst&amp;sid=$sid&amp;pid=$pid\">"; 
     echo "Text: <input name=\"ptext\" value=\"$ptext\" maxlength=\"500\"/> ";
     echo "<input type=\"submit\" name=\"Submit\" value=\"Edit\"/><br/>";
     echo "</form>"; 
     
echo "<br/><a href=\"modproc.php?action=delp&amp;sid=$sid&amp;pid=$pid\">&#187;DELETE</a><br/>";
  }
  echo "</p>";
echo "<p align=\"center\">";
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo xhtmlfoot();
}

else if($action=="tpcopt")
{
    $tid = $_GET["tid"];
    addonline(getuid_sid($sid),"Topic Options - xHTML","");
    $tinfo= mysql_fetch_array(mysql_query("SELECT name,fid, authorid, text, pinned, closed  FROM ibwf_topics WHERE id='".$tid."'"));
    $trid = $tinfo[2];
    $ttext = htmlspecialchars($tinfo[3]);
    $tname = htmlspecialchars($tinfo[0]);
    $pstyle = gettheme($sid);
    echo xhtmlhead("Topic Options",$pstyle);
    echo "<onevent type=\"onenterforward\">";
    echo "<refresh>
        <setvar name=\"ttext\" value=\"$ttext\"/>
        <setvar name=\"tname\" value=\"$tname\"/>";
    echo "</refresh></onevent>";
  echo "<p align=\"center\">";
  echo "<b>Topic Options</b>";

  echo "</p>";
  echo "<p>";
  echo "Topic ID: <b>$tid</b><br/>";
  $trnick = getnick_uid($trid);
  echo "<a href=\"inbox.php?action=sendpm&amp;sid=$sid&amp;who=$trid\">&#187;Send PM to $trnick</a><br/>";
  echo "<a href=\"index.php?action=viewuser&amp;sid=$sid&amp;who=$trid\">&#187;View $trnick's Profile</a><br/>";
  //echo "<a href=\"index.php?action=post&amp;sid=$sid&amp;tid=$tid&amp;qut=$pid\">&#187;Quote</a><br/>";
  $plid = mysql_fetch_array(mysql_query("SELECT pollid FROM ibwf_topics WHERE id='".$tid."'"));
  if($plid[0]==0)
  {
  if(ismod($uid))
    {
  echo "<a href=\"index.php?action=pltpc&amp;sid=$sid&amp;tid=$tid\">&#187;Add Poll</a><br/>";
}
}else{
  if(ismod($uid))
  {
    echo "<a href=\"genproc.php?action=dltpl&amp;sid=$sid&amp;tid=$tid\">&#187;Delete Poll</a><br/>";
    }
}
  echo "<a href=\"genproc.php?action=rtpc&amp;sid=$sid&amp;tid=$tid\">&#187;Report</a><br/>";
  echo "<a href=\"index.php?action=viewtpc&amp;sid=$sid&amp;tid=$tid&amp;page=1\">&#171;Back to topic</a><br/>";
  if(ismod(getuid_sid($sid)))
  {
    echo "<form method=\"post\" action=\"modproc.php?action=rentpc&amp;sid=$sid&amp;tid=$tid\">";
    echo "<br/>Title: <input name=\"tname\" value=\"$tname\" maxlength=\"25\"/>";
    echo "<br/><input type=\"submit\" name=\"Submit\" value=\"Rename\"/><br/>";
    echo "</form>";
    
    echo "<form method=\"post\" action=\"modproc.php?action=edttpc&amp;sid=$sid&amp;tid=$tid\">";
    echo "<br/>Text: <input name=\"ttext\" value=\"$ttext\" maxlength=\"500\"/> ";
    echo "<br/><input type=\"submit\" name=\"Submit\" value=\"Edit\"/><br/>";
    echo "</form>";
    
echo "<a href=\"modproc.php?action=delt&amp;sid=$sid&amp;tid=$tid\">&#187;DELETE</a><br/>";
    echo "<br/>";
    if($tinfo[5]=='1')
    {
      $ctxt = "Open";
      $cact = "0";
    }else{
        $ctxt = "Close";
      $cact = "1";
    }
    echo "<a href=\"modproc.php?action=clot&amp;sid=$sid&amp;tid=$tid&amp;tdo=$cact\">&#187;$ctxt</a><br/>";
    if($tinfo[4]=='1')
    {
      $ptxt = "Unpin";
      $pact = "0";
    }else{
        $ptxt = "Pin";
      $pact = "1";
    }
  echo "<a href=\"modproc.php?action=pint&amp;sid=$sid&amp;tid=$tid&amp;tdo=$pact\">&#187;$ptxt</a><br/>";
  //echo "<a href=\"index.php?action=post&amp;sid=$sid&amp;tid=$tid&amp;qut=$pid\">&#187;Quote</a><br/>";
  echo "<br/>Move to:<br/>";
  echo "<form method=\"post\" action=\"modproc.php?action=mvt&amp;sid=$sid&amp;tid=$tid\">";
  $forums = mysql_query("SELECT id, name FROM ibwf_forums WHERE clubid='0'");
  echo "<select name=\"mtf\">";
  while ($forum = mysql_fetch_array($forums))
  {
    echo "<option value=\"$forum[0]\">$forum[1]</option>";
  }
  echo "</select><br/>";
  echo "<input type=\"submit\" name=\"Submit\" value=\"Move\"/><br/>";
  echo "</form>";
  }
  echo "</p>";
echo "<p align=\"center\">";
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo xhtmlfoot();
}
else if ($action=="chat")           {
        addonline(getuid_sid($sid),"Chat Menu - xHTML","");
        $pstyle = gettheme($sid);
    echo xhtmlhead("Chat Menu",$pstyle);
        echo "<p align=\"center\">";
        include("popups.php");
        echo "<img src=\"images/chat.gif\" alt=\"*\"/><br/>";
        
        echo "<br/>";
        

        	$unreadinbox=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE unread='1' AND touid='".getuid_sid($sid)."'"));
        $pmtotl=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE touid='".getuid_sid($sid)."'"));
        $unrd="(".$unreadinbox[0]."/".$pmtotl[0].")";
        echo "<a href=\"inbox.php?action=main&amp;sid=$sid&amp;page=1\">Inbox$unrd</a><br/><br/> ";
        echo "<a href=\"index.php?action=uchat&amp;sid=$sid\">Users Rooms</a><br/><br/>";
        $rooms = mysql_query("SELECT id, name, perms, mage, chposts FROM ibwf_rooms WHERE static='1' AND clubid='0'");
        while ($room= mysql_fetch_array($rooms))
        {
          
          if(canenter($room[0], $sid))
          {
            $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_chonline WHERE rid='".$room[0]."'"));
            echo "<a href=\"chat.php?sid=$sid&amp;rid=$room[0]\">$room[1]($noi[0])</a><br/>";
          }
          
        }
        	

        echo "<br/><a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>Home</a><br/>";
        echo "</p>";
        echo xhtmlfoot();
                                           }
else if ($action=="uchat")           {
addonline(getuid_sid($sid),"Chat Menu - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("Chat Menu",$pstyle);
        echo "<p align=\"center\">";
        include("popups.php");
        echo "<img src=\"images/chat.gif\" alt=\"*\"/><br/>";

        echo "<br/>";


        	$unreadinbox=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE unread='1' AND touid='".getuid_sid($sid)."'"));
        $pmtotl=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE touid='".getuid_sid($sid)."'"));
        $unrd="(".$unreadinbox[0]."/".$pmtotl[0].")";
        echo "<a href=\"inbox.php?action=main&amp;sid=$sid&amp;page=1\">Inbox$unrd</a><br/><br/> ";
        echo "<a href=\"index.php?action=chat&amp;sid=$sid\">Public Rooms</a><br/>";
        echo "<a href=\"index.php?action=mkroom&amp;sid=$sid\">Create Room</a><br/><br/>";
        $rooms = mysql_query("SELECT id, name, pass FROM ibwf_rooms WHERE static='0'");
        $co=0;
        while ($room= mysql_fetch_array($rooms))
        {
            $co++;
          if(canenter($room[0], $sid))
          {
            $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_chonline WHERE rid='".$room[0]."'"));
            if($room[2]=="")
            {
            echo "<a href=\"chat.php?sid=$sid&amp;rid=$room[0]\">".htmlspecialchars($room[1])."($noi[0])</a><br/>";
            }else{
              echo "<br/><input format=\"*x\" name=\"rpw$co\" maxlength=\"10\"/><br/>";
              echo "<anchor>";
              echo htmlspecialchars($room[1]);
              echo "($noi[0])";
              echo "<go href=\"chat.php\" method=\"get\">";
              echo "<postfield name=\"rid\" value=\"$room[0]\"/>";
              echo "<postfield name=\"sid\" value=\"$sid\"/>";
              echo "<postfield name=\"rpw\" value=\"$(rpw$co)\"/>";
              echo "</go></anchor><br/>";
              
  
            }
          }

        }


          $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<br/><a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
        echo "</p>";
        echo xhtmlfoot();
                                           }
else if($action=="mkroom")
{
    addonline(getuid_sid($sid),"Creating Chatroom - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("Creating Room",$pstyle);
        echo "<p>";
        echo "<small><img src=\"images/point.gif\" alt=\"!\"/>Leave password empty if you dont want to lock the room</small><br/>";
        echo "<small><img src=\"images/point.gif\" alt=\"!\"/>Don't make the password too personal, it's visible in the database</small><br/><br/>";
        echo "Room Name: <input name=\"rname\" maxlength=\"30\"/><br/>";
        echo "Password: <input name=\"rpass\" format=\"*x\" maxlength=\"10\"/><br/>";
        echo "<anchor>Create";
        echo "<go href=\"genproc.php?action=mkroom&amp;sid=$sid\" method=\"post\">";
        echo "<postfield name=\"rname\" value=\"$(rname)\"/>";
        echo "<postfield name=\"rpass\" value=\"$(rpass)\"/>";
        echo "</go></anchor>";
        echo "</p>";
        echo "<p align=\"center\">";
          $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
        echo "<a href=\"index.php?action=chat&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/chat.gif\" alt=\"*\"/>Chatrooms</a><br/>";
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
        echo "</p>";
        echo xhtmlfoot();
}

else if ($action=="formmenu")           {
addonline(getuid_sid($sid),"Forum Index - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("FlareZone Forums",$pstyle);
    
  echo "<p align=\"center\"><small>";  
  $tmsg = getpmcount(getuid_sid($sid));
  $umsg = getunreadpm(getuid_sid($sid));
  
  if($umsg==1)
  {
  echo "<a href=\"inbox.php?action=main&amp;sid=$sid\">Inbox($umsg New Message)</a> <br/><br/>";
  }
  if($umsg>1)
  {
  echo "<a href=\"inbox.php?action=main&amp;sid=$sid\">Inbox($umsg New Messages)</a> <br/><br/>";
  }  
  echo "</small></p>";
  
  echo "<p><small>";
  echo "<div class=\"mblock1\">";
  echo "<h5 align=\"center\">Forum Menu</h5><br/>";
  include("popups.php");
  $fcats = mysql_query("SELECT id, name FROM ibwf_fcats ORDER BY position, id");
  $iml = "<img src=\"images/1.gif\" alt=\"*\"/>";
  while($fcat=mysql_fetch_array($fcats))
  {
    $catlink = "<a href=\"index.php?action=viewcat&amp;sid=$sid&amp;cid=$fcat[0]\">$iml$fcat[1]</a><br/>";
    echo "$catlink";
    $forums = mysql_query("SELECT id, name FROM ibwf_forums WHERE cid='".$fcat[0]."' AND clubid='0' ORDER BY position, id, name");
    if(getfview()==0)
    {
    echo "<br/><small>";
    while($forum=mysql_fetch_array($forums))
        {
      if(canaccess(getuid_sid($sid),$forum[0]))
      {
        
      echo "<a href=\"index.php?action=viewfrm&amp;sid=$sid&amp;fid=$forum[0]\">$forum[1]</a>, ";
      }
    }
    echo "</small>";
    }else if(getfview()==20)
    {
      echo "<form method=\"get\" action=\"index.php\">";
      echo "<br/>Forums: <select name=\"fid\">";
      while($forum=mysql_fetch_array($forums))
        {
      if(canaccess(getuid_sid($sid),$forum[0]))
      {
        $notp = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_topics WHERE fid='".$forum[0]."'"));
      echo "<option value=\"$forum[0]\">$forum[1]($notp[0])</option>";
      }
      }
      echo "</select>";
      
      $rets .= "<input type=\"hidden\" name=\"action\" value=\"viewfrm\"/>";
      $rets .= "<input type=\"hidden\" name=\"sid\" value=\"$sid\"/>";     
      echo "<input type=\"submit\" name=\"Submit\" value=\"[GO]\"/><br/>";
      echo "</form>";
      echo "</div>";
      
  
    }
    
  }
  echo "</small></p>";
  echo "<p align=\"center\">";
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<br/><a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo xhtmlfoot();
    }
                                       
                                       
                                           
else if ($action=="funm")
 {
addonline(getuid_sid($sid),"Fun/Games Menu - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("Fun/Games Menu",$pstyle);
        echo "<p align=\"center\"><small>";
        include("popups.php");
        echo "<img src=\"images/roll.gif\" alt=\"*\"/><br/>";
        echo "Hello, so you want to play some games and have fun? well you came into the right place";
        echo "</small></p>";
        echo "<p><small>";
        echo "<i><u>Just For Fun</u></i><br/>";
        echo "<a href=\"methosbabe.php?sid=$sid\">&#187;FlareZone BOT</a><br/>";
        echo "<a href=\"hangman/index.php?sid=$sid\">&#187;Hangman</a><br/>";
        echo "<a href=\"games.php?action=fci&amp;sid=$sid\">&#187;Fortune Cookie</a><br/>";
        echo "<i><u>Win Some Credits</u></i><br/>";
        echo "<a href=\"games.php?action=guessgm&amp;sid=$sid\">&#187;Guess The Number</a><br/>";
        echo "<a href=\"games.php?action=casinoi&amp;sid=$sid\">&#187;Casino</a><br/>";
        echo "<a href=\"games.php?action=lottoi&amp;sid=$sid\">&#187;Lotto</a><br/>";
        echo "<i><u>Meet New Friends</u></i><br/>";
        echo "<a href=\"games.php?action=mixabud&amp;sid=$sid\">&#187;Mix a Buddy</a><br/>";
        echo "<a href=\"games.php?action=mixabudguy&amp;sid=$sid\">&#187;Mix a Guy (For Girls Only)</a><br/>";
        echo "<a href=\"games.php?action=mixabudgirl&amp;sid=$sid\">&#187;Mix a Girl (For Guys Only)</a><br/>";
        //echo "&#187;Dares Box<br/>";
        echo "</small></p>";
        echo "<p align=\"center\">";
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
        echo "</p>";
        echo xhtmlfoot();
}

else if ($action=="partners")
 {
addonline(getuid_sid($sid),"Partner List - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("Partners",$pstyle);
        echo "<p align=\"center\"><small>";
        include("popups.php");
        echo "FlareZone Partners<br/><br/>";
        echo "</small></p>";
        echo "<p><small>";
        echo "<a href=\"http://FlareZone.com\"><b>FlareZone</b></a><br/>"; 
        echo "<a href=\"http://playtoy.wen.ru\">Playtoy</a><br/>";
        echo "<a href=\"http://farad.wen9.com\">Farad</a><br/>";   
        echo "</small></p>";
        echo "<p align=\"center\">";
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<br/><a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
        echo "</p>";
        echo xhtmlfoot();
}

///////////////////////////////view blog

else if($action=="viewblog")
{
  $bid = $_GET["bid"];
  addonline(getuid_sid($sid),"Viewing Blog - xHTML","");
$pstyle = gettheme($sid);
    echo xhtmlhead("View Blog",$pstyle);
  echo "<p>";

  $pminfo = mysql_fetch_array(mysql_query("SELECT btext, bname, bgdate,bowner, id FROM ibwf_blogs WHERE id='".$bid."'"));
    $bttl = htmlspecialchars($pminfo[1]);
    $btxt = parsemsg($pminfo[0], $sid);
    $bnick = getnick_uid($pminfo[3]);
  $vbbl = "<a href=\"index.php?action=viewuser&amp;sid=$sid&amp;who=$pminfo[3]\">$bnick</a><br/>";
  echo "Club ID: <b>$bid</b><br/>";
    echo "<b>$bttl</b> by: $vbbl<br/>";
  echo "$btxt<br/>";
  $tmstamp = $pminfo[2];
  $tmdt = date("d m y - h:i:s", $tmstamp);
  echo "<small>$tmdt</small><br/><br/>";
  $vb = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_brate WHERE uid='".$uid."' AND blogid='".$bid."'"));
  if($vb[0]==0)
  {
  echo "<select name=\"brate\">";
  echo "<option value=\"1\">1</option>";
  echo "<option value=\"2\">2</option>";
  echo "<option value=\"3\">3</option>";
  echo "<option value=\"4\">4</option>";
  echo "<option value=\"5\">5</option>";
  echo "</select><br/>";
  echo "<anchor>Rate";
  echo "<go href=\"genproc.php?action=rateb&amp;sid=$sid&amp;bid=$pminfo[4]\" method=\"post\">";
  echo "<postfield name=\"brate\" value=\"$(brate)\"/>";
  echo "</go></anchor>";
  }else{
    $rinfo = mysql_fetch_array(mysql_query("SELECT COUNT(*) as nofr, SUM(brate) as nofp FROM ibwf_brate WHERE blogid='".$bid."'"));
    $ther = $rinfo[1]/$rinfo[0];
    echo "Rate: $ther - Points: $rinfo[1]";
  }
  echo "</p>";
  echo "<p align=\"center\">";
  echo "<a href=\"lists.php?action=allbl&amp;sid=$sid\">Back to Blogs</a><br/>";
  $bnick = getnick_uid($pminfo[3]);
  echo "<a href=\"lists.php?action=blogs&amp;sid=$sid&amp;who=$pminfo[3]\">Back to $bnick's Blogs</a><br/>";
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo xhtmlfoot();

}


/////////////////////////////////ADMIN CP
else if($action=="admincp")
{
  addonline(getuid_sid($sid),"Admin CP - xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("Admin CP!",$pstyle);
  echo "<p align=\"center\">";
  include("popups.php");
  echo "<b>Admin CP</b>";
  echo "</p>";
  echo "<p><small>";
  if(isadmin(getuid_sid($sid)))
  {
    echo "<a href=\"admincp.php?action=fcats&amp;sid=$sid\">&#187;Forum Categories</a><br/>";
    echo "<a href=\"admincp.php?action=forums&amp;sid=$sid\">&#187;Forums</a><br/>";
    echo "<a href=\"admincp.php?action=ugroups&amp;sid=$sid\">&#187;User groups</a><br/>";
    echo "<a href=\"admincp.php?action=manrss&amp;sid=$sid\">&#187;Manage RSS Sources</a><br/>";
	echo "<a href=\"users/themes.php?sid=$sid\">&#187;Add Theme</a><br/>";
    echo "<a href=\"admincp.php?action=addsml&amp;sid=$sid\">&#187;Add Smilies</a><br/>";
    echo "<a href=\"admincp.php?action=addavt&amp;sid=$sid\">&#187;Add Avatar</a><br/>";
    echo "<a href=\"admincp.php?action=chrooms&amp;sid=$sid\">&#187;Chatrooms</a><br/>";
    if($uid==1) {
    echo "<a href=\"admincp.php?action=clrdta&amp;sid=$sid\">&#187;Clear Data</a><br/>";
    }
  }else{
    echo "You are not an Admin";
  }
  echo "</small></p>";
  echo "<p align=\"center\">";
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo xhtmlfoot();
}


/////////////////////////////////OWNER CP
else if($action=="ownercp")
{
  addonline(getuid_sid($sid),"Owner CP - xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("Owner CP!",$pstyle);
  echo "<p align=\"center\">";
  include("popups.php");
  echo "<b><font color=\"00FF00\">owner CP</font></b>";
  echo "</p>";
  echo "<p><small>";
  if(isowner(getuid_sid($sid)))
  {
    echo "<a href=\"ownercp.php?action=general&amp;sid=$sid\"><font color=\"FF0000\">&#187;General Settings</font></a><br/>";
    echo "<a href=\"ownercp.php?action=pmall&amp;sid=$sid\">&#187;Send Pm To All</a><br/>";
    echo "<a href=\"ownercp.php?action=fcats&amp;sid=$sid\"><font color=\"FF0000\">&#187;Forum Categories</font></a><br/>";
    echo "<a href=\"ownercp.php?action=forums&amp;sid=$sid\">&#187;Forums</a><br/>";
    echo "<a href=\"ownercp.php?action=ugroups&amp;sid=$sid\"><font color=\"FF0000\">&#187;User groups</font></a><br/>";
    echo "<a href=\"ownercp.php?action=addperm&amp;sid=$sid\">&#187;Add permissions</a><br/>";
    echo "<a href=\"ownercp.php?action=chuinfo&amp;sid=$sid\"><font color=\"FF0000\">&#187;Change user info</font></a><br/>";
    echo "<a href=\"ownercp.php?action=manrss&amp;sid=$sid\">&#187;Manage RSS Sources</a><br/>";
	echo "<a href=\"users/themes.php?sid=$sid\"><font color=\"FF0000\">&#187;Add Theme</font></a><br/>";
    echo "<a href=\"ownercp.php?action=addsml&amp;sid=$sid\">&#187;Add Smilies</a><br/>";
    echo "<a href=\"ownercp.php?action=addavt&amp;sid=$sid\"><font color=\"FF0000\">&#187;Add Avatar</font></a><br/>";
    echo "<a href=\"ownercp.php?action=chrooms&amp;sid=$sid\">&#187;Chatrooms</a><br/>";
    if($uid==1) {
    echo "<a href=\"ownercp.php?action=clrdta&amp;sid=$sid\"><font color=\"FF0000\">&#187;Clear Data</font></a><br/>";
    }
  }else{
    echo "You are not an Owner";
  }
  echo "</small></p>";
  echo "<p align=\"center\">";
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo xhtmlfoot();
}
/////////////////////////////////COMPACT INDEX
else if($action=="compact")
{
   $showicons = mysql_fetch_array(mysql_query("SELECT showicon FROM ibwf_users WHERE id='".$uid."'"));
  $showtime = mysql_fetch_array(mysql_query("SELECT showtime FROM ibwf_users WHERE id='".$uid."'"));
  $showshout = mysql_fetch_array(mysql_query("SELECT showshout FROM ibwf_users WHERE id='".$uid."'"));
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
  $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));
  if($showicons[0]=="1"){
  addvisitor();
  addonline(getuid_sid($sid),"Compact Main Page - xHTML","index.php?action=$action");
  //saveuinfo($sid);
  $pstyle = gettheme($sid);
  echo xhtmlhead("FlareZone Compact",$pstyle);
  echo "<p align=\"center\">";
  if($showtime[0]=="1"){
  echo "<small><a href=\"time.php?sid=$sid\">".date("D d M y - H:i",time() )."</a></small><br/>";
  }
  
$TimeZone="0"; ////Change the TimeZone accordingly!
$New_Time = time() + ($TimeZone * 60 * 60);

$show_date=date("D dS F, Y",$New_Time); 
$show_time=date("H:i",$New_Time); 
$Hour=date("G",$New_Time);


  echo "<img src=\"images/logo.gif\" alt=\"FlareZone\"/><br/>";
  echo "</p>";
  $nick = getnick_sid($sid);
if ($Hour <= 4) { echo "<h5 align=\"center\">Hello $nick you night owl!</h5><br/>"; } 

else if ($Hour <= 11) { echo "<h5 align=\"center\">Good morning $nick!</h5><br/>"; } 

else if ($Hour <= 12) { echo "<h5 align=\"center\">Enjoy your lunch $nick!</h5><br/>"; }

else if ($Hour <= 17) { echo "<h5 align=\"center\">Good afternoon $nick!</h5><br/>"; } 

else if ($Hour <= 24) { echo "<h5 align=\"center\">Good Evening $nick!</h5><br/>"; }

  echo "<p align=\"center\"><small>";
  $fmsg = htmlspecialchars(getfmsg());
  echo "<b><u><font color=\"0000FF\">Site Announcement</font></u></b><br/>";
  echo "<font color=\"3366FF\">$fmsg</font><br/>";
  echo "<font color=\"0000FF\">+++++++++++++++++</font><br/>";
  include("popups.php");
  echo "<br/><a href=\"index.php?action=main&amp;sid=$sid\"><b>Reload</b></a><br/>";
  echo "</small></p>";
  echo "<div class=\"mblock1\">";
  echo "<h5 align=\"center\">Menu</h5><br/>";
  echo "<small>";
  
 /////inbox data
  $new_gm = getnewgml(getuid_sid($sid));
  if($new_gm>0)
  {
  echo "<a href=\"rwgmail.php?sid=$sid\">&#187;G-Mail(".$new_gm.")</a><br/>";
  }   
  
  $tmsg = getpmcount(getuid_sid($sid));
  $umsg = getunreadpm(getuid_sid($sid));
  
  
  if($umsg==1)
  {
  echo "1. <a accesskey=\"1\" href=\"inbox.php?action=folderunread&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/inbox2.gif\" alt=\"*\"/>Inbox</a>($umsg New Message)<br/>";
  }
  if($umsg>1)
  {
  echo "1. <a accesskey=\"1\" href=\"inbox.php?action=folderunread&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/inbox2.gif\" alt=\"*\"/>Inbox</a>($umsg New Messages)<br/>";
  }  
  if($umsg==0)
  {
  echo "1. <a accesskey=\"1\" href=\"inbox.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/inbox1.gif\" alt=\"*\"/>Inbox</a>($tmsg)<br/>";
  } 
  $uid = getuid_sid($sid);
  $mybuds = getnbuds($uid);
  $onbuds = getonbuds($uid);
  echo "2. <a accesskey=\"2\" href=\"lists.php?action=buds&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/buddies.gif\" alt=\"*\"/>Buddies</a>($onbuds|$mybuds)";
  $reqs = getnreqs($uid);
  if($reqs>0)
  {
    echo ": <a href=\"lists.php?action=reqs&amp;sid=$sid\">$reqs</a>";
  }
  $chs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_chonline"));
  echo "<br/>2. <a accesskey=\"2\" href=\"index.php?action=chat&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/chat.gif\" alt=\"*\"/>Chatrooms</a>($chs[0])<br/>";

  $chs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubs"));
  echo "3. <a accesskey=\"3\" href=\"index.php?action=clmenu&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/clubs.gif\" alt=\"*\"/>Clubs</a>($chs[0])<br/>";

  echo "4. <a accesskey=\"4\" href=\"index.php?action=cpanel&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/cpanel.gif\" alt=\"*\"/>CPanel</a><br/>";

  echo "5. <a accesskey=\"5\" href=\"index.php?action=compactzone&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/stats.gif\" alt=\"*\"/>Site Stats</a><br/>";

  echo "6. <a accesskey=\"6\" href=\"index.php?action=partners&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/partners.gif\" alt=\"*\"/>Partners</a><br/>";

  echo "7. <a accesskey=\"7\" href=\"index.php?action=stats&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/stats.gif\" alt=\"*\"/>Site Stats</a><br/>";

  echo "</small>";
  echo "</div>";
  if($showshout[0]=="1"){
  echo "<br/>";
  echo "<br/>";
  echo "<div class=\"mblock2\">";
  echo "<h5 align=\"center\">ShoutBox</h5><br/>";
  echo "<small>";
  echo getshoutbox($sid);
  echo "</small>";
  echo "</div>";
  }
  echo "<br/>";
  echo "<br/>";
  echo "<div class=\"mblock2\">";
  echo "<h5 align=\"center\">Online Stats</h5><br/>";
  echo "<small>";
  echo "<i>Members Online:</i><br/>";
  $memberonline = "0.Members: <a accesskey=\"0\" href=\"index.php?action=online&amp;sid=$sid\">".getnumonline()."<br/>";
  echo "$memberonline";
  $timeout = time()  - 180;
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE perm>'0' AND lastact>'".$timeout."'"));
  echo "<i>Staff Online:</i><br/>";
  echo "*.Staff: <a accesskey=\"*\" href=\"index.php?action=stfol&amp;sid=$sid\">".$noi[0]."<br/>";
  $timeout = time()  - 180;
  $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE specialid>'0' AND lastact>'".$timeout."'"));
  echo "<i>V.I.P's Online:</i><br/>";
  echo "#.V.I.P's: <a accesskey=\"#\" href=\"index.php?action=vipol&amp;sid=$sid\">".$noi[0]."<br/>";
  echo "</small>";
  echo "</div>";
  echo "<br/>";
  echo "<br/>";  
  echo "<p><small>";
  if (isowner(getuid_sid($sid)))
  {
  echo "<div class=\"mblock2\">";
  echo "<h5 align=\"center\">Owner/Admins/Mods</h5><br/>";
  echo "<a href=\"index.php?action=ownercp&amp;sid=$sid\"><font color=\"00FF00\">&#187;Owner CP</font></a><br/>";
  }
  if (isadmin(getuid_sid($sid)))
  {
  echo "<a href=\"index.php?action=admincp&amp;sid=$sid\"><font color=\"0000FF\">&#187;Admin CP</font></a><br/>";
  }
  if(ismod($uid))
  {
  echo "<a href=\"modcp.php?action=main&amp;sid=$sid\"><font color=\"FF0000\">&#187;Mod R/L</font></a><br/>";
  echo "<h5 align=\"center\">I Would Apreciate It If Only Staff Click These Links</h5><br/>";
  echo "</div>";
  }
  echo "</small></p>";
  echo "<br/>";
  echo "<br/>";
  echo "<p align=\"center\"><small>";
  echo "<a href=\"copyrights.php\">&#169;FlareZone 2007 - 2023</a><br/>";
  echo "<font color=\"0000FF\">=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=</font><br/>";
  echo "<font color=\"3366FF\">Original Script By Irishblaze(lavalair.net)</font><br/>";
  echo "<font color=\"0000FF\">=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=</font><br/>";
  echo "<font color=\"3366FF\">Script Updates By FlareBoy</font><br/>";
  echo "<font color=\"0000FF\">=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=</font><br/>";
  echo "</small></p>";
  echo xhtmlfoot();
}
/////////////////////////////////COMPACT ZONE
else if($action=="compactzone")
{
  addonline(getuid_sid($sid),"Compact Zone- xHTML","");
    $pstyle = gettheme($sid);
    echo xhtmlhead("Compact Zone!",$pstyle);
  echo "<p align=\"center\">";
  include("popups.php");
  echo "<b><font color=\"00FF00\">Compact Zone</font></b>";
  echo "</p>";
  echo "<p><small>";
 echo "1. <a accesskey=\"1\" href=\"index.php?action=formmenu&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/forum.gif\" alt=\"*\"/><font color=\"0000FF\">Forums</font></a><br/>";

    echo "2. <a accesskey=\"2\" href=\"index.php?action=funm&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/games.gif\" alt=\"*\"/><font color=\"FF0000\">Fun/Games</font></a><br/>";

    echo "3. <a accesskey=\"3\" href=\"mshop.php?action=main&amp;sid=$sid\"><img src=\"images/shop.gif\" alt=\"*\"/><font color=\"0000FF\">FlareZone Shop</font></a><br/>";

    $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_vault"));
  echo "4. <a accesskey=\"4\" href=\"lists.php?action=vault&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/downloads.gif\" alt=\"*\"/><font color=\"FF0000\">Downloads</a>($noi[0])</font><br/>";

    $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_usergallery"));
  echo "5. <a accesskey=\"5\" href=\"usergallery.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/usergallery.gif\" alt=\"*\"/><font color=\"0000FF\">User Gallery</a>($noi[0])</font><br/>";

  echo "</small></p>";
  echo "<p align=\"center\">";
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo xhtmlfoot();
}
/////////////////////////////////Terms of use
else if($action=="terms")
{
  $uid =getuid_sid($sid);
  if($uid>0)
  {
  addonline(getuid_sid($sid),"Terms of use - xHTML","");
  $pstyle = gettheme($sid);
    echo xhtmlhead("Terms Of Use",$pstyle);
  }
$pstyle = gettheme1("1");
    echo xhtmlhead("Terms Of Use",$pstyle);
  echo "<p><small>";
  echo "<img src=\"images/point.gif\" alt=\"!\"/>Posts containing racism, links to other sites, spamming, flooding, adult content, hacking will be deleted immediately, and the posters will get warned or banned<br/>";
  echo "<img src=\"images/point.gif\" alt=\"!\"/>chatting, discriminating, posting off topics, posting useless posts (smilies only or one word post), and free posting results to delete the posts, substracting plusses and banning in some cases<br/>";
  echo "<img src=\"images/point.gif\" alt=\"!\"/>Registering more than one nickname, could result to delete all your accounts<br/>";
  echo "<img src=\"images/point.gif\" alt=\"!\"/>Never give your account password to anyone, except in some extreme cases and the admins should be informed about it<br/>";
  echo "<img src=\"images/point.gif\" alt=\"!\"/>Faking your personal information (like age, sex, location etc..) just to gain access to hidden forums or any other reason could result on banning, or a warning at least<br/>";
  echo "<img src=\"images/point.gif\" alt=\"!\"/>Females harassment, and racism will results on banning for 7 days at least without a warning, and an IP-Ban if this behavior continued<br/>";
  echo "<img src=\"images/point.gif\" alt=\"!\"/>Bumping topics (keep posting in them by the author of the topic just to keep it in first page and not for a good reason) will cause these topics to be deleted and the penalty could vary between warning, substracting plusses, or even a ban<br/>";
  echo "<img src=\"images/point.gif\" alt=\"!\"/>You can only speak in english in forums, and all the chatrooms except (International, afrikaans and mad room)<br/>";
  echo "<img src=\"images/point.gif\" alt=\"!\"/>Please report any spams, this is the only thing that we want from you for our free services<br/>";
  echo "<img src=\"images/point.gif\" alt=\"!\"/>No smoking in public, next to the pregnant ladies, or next to babies hehe<br/>";
  echo "<img src=\"images/point.gif\" alt=\"!\"/>The most important rule is to have fun here and enjoy your stay ;)<br/>";
  echo "<br/>Remeber, these rules were made for protecting you before protecting us, if you think they are a little restrictive then read <a href=\"lists.php?action=faqs&amp;sid=$sid\">our F.A.Qs</a> or ask any online staff member(only if you logged in), Thank you so much<br/>";
  echo "</small></p>";
  echo "<p align=\"center\">";
  if($uid>0)
  {
  $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'"));  
    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
echo "Home</a>";
}else{
    echo "<a href=\"index.php\"><img src=\"images/home.gif\" alt=\"*\"/>";
echo "Home</a>";
}
  echo "</p>";
  echo xhtmlfoot();
}
else{
  /////////////////////////Main Page Here
      $pstyle = gettheme1("1");
      echo xhtmlhead("FlareZone",$pstyle);
  echo "<p align=\"center\">";
  echo "<small>";
  echo "<img src=\"images/logo.gif\" alt=\"*\"/><br/>";
  $fmsg = htmlspecialchars(getfmsg());
  echo "<b><u><font color=\"FF0000\">Site Announcement</font></u></b><br/>";
  echo "<marquee><font color=\"3366FF\">$fmsg</font></marquee><br/>";
  echo "<b><font color=\"FF0000\">+++++++++++++++++</font></b><br/>";
  echo "<font color=\"3366FF\">Not registered yet?</font><br/>";
  echo "<font color=\"0000FF\" >>>>>>>><<<<<<< </font><br/>";
  echo "<a href=\"register.php?action=register\">Sign Up</a><br/>";
  echo "<font color=\"0000FF\" >>>>>>>><<<<<<< </font><br/>";
  echo "</small>";
  echo "</p>";
  echo "<p>";
  echo "<form method=\"get\" action=\"login.php\">";
  echo "<small><font color=\"FFFF00\">UserName:</font></small> <input name=\"loguid\" format=\"*x\" maxlength=\"30\"/><br/>";
  echo "<small><font color=\"FFFF00\">Password:</font></small> <input type=\"password\" name=\"logpwd\"  maxlength=\"30\"/><br/>";
  echo "<input type=\"submit\" name=\"Submit\" value=\"Log In\"/><br/>";
  echo "</form>";
  echo "</p>";
  echo "<p>";
  echo "<br/><br/>";
  echo "<small>";
  echo "<font color=\"0000FF\" >>>>>>>>>>>>>>>> </font><br/>";
  echo "<a href=\"index.php?action=terms&amp;sid=$sid\">Terms Of Use</a><br/>";
  echo "<font color=\"0000FF\" >>>>>>>>>>>>>>>> </font><br/>";
  echo "<a href=\"features.php\">Features</a><br/>";
  $onu = getnumonline() + 0;
  echo "<font color=\"0000FF\" >>>>>>>>>>>>>>>> </font><br/>";
  echo "Members Inside: $onu<br/>";
  echo "<font color=\"0000FF\" >>>>>>>>>>>>>>>> </font><br/>";
  $norm = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users"));
  echo "</small>";
  echo "</p>";
  $norm = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users"));
    echo "<small>";
    $siteage = mysql_fetch_array(mysql_query("SELECT value  FROM ibwf_settings WHERE id='9'"));
    $sage = time()-$siteage[0];
    $stage = ceil($sage/(24*60*60));
    echo "<font color=\"0000FF\">======================</font><br/>";
    echo "<b><u>Site Statistics</u></b><br/>";
    echo "<font color=\"0000FF\">======================</font><br/>";
    echo "Registered Members: <b>$norm[0]</b><br/>";
    echo "<font color=\"0000FF\">=--=--=--=--=--=--=--=</font><br/>";
    $memid = mysql_fetch_array(mysql_query("SELECT id, name  FROM ibwf_users ORDER BY regdate DESC LIMIT 0,1"));
    echo "The Newest Member is: <b><a href=\"index.php?action=viewuser&amp;who=$memid[0]&amp;sid=$sid\">$memid[1]</a></b><br/><br/>";
    $mols = mysql_fetch_array(mysql_query("SELECT name, value FROM ibwf_settings WHERE id='2'"));
    echo "<font color=\"0000FF\">=--=--=--=--=--=--=--=</font><br/>";
    echo "Most online: <b>$mols[1]</b> Members on $mols[0]<br/>";
    $mols = mysql_fetch_array(mysql_query("SELECT ppl, dtm FROM ibwf_mpot WHERE ddt='".date("d m y")."'"));
    echo "<font color=\"0000FF\">=--=--=--=--=--=--=--=</font><br/>";
    echo "<br/>Most online(<a href=\"lists.php?action=moto&amp;sid=$sid\">today only</a>): <b>$mols[0]</b> Members at $mols[1]<br/>";
    $tm24 = time() - (24*60*60) ;
    $aut = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE lastact>'".$tm24."'"));
    echo mysql_error();
    echo "<font color=\"0000FF\">=--=--=--=--=--=--=--=</font><br/>";
    echo "<br/>Active users today <b>$aut[0]</b><br/>";
    $notc = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_topics"));
    $nops = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_posts"));
    echo "<font color=\"0000FF\">=--=--=--=--=--=--=--=</font><br/>";
    echo "Number of Topics: <b>$notc[0]</b><br/>";
    echo "<font color=\"0000FF\">=--=--=--=--=--=--=--=</font><br/>";
    echo "Number of Posts: <b>$nops[0]</b><br/>";
    $nopm = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private"));
    echo "<font color=\"0000FF\">=--=--=--=--=--=--=--=</font><br/>";
    echo "Number of PMs: <b>$nopm[0]</b><br/>";
    $nopm = mysql_fetch_array(mysql_query("SELECT value FROM ibwf_settings WHERE name='Counter'"));
    echo "<font color=\"0000FF\">=--=--=--=--=--=--=--=</font><br/>";
    echo "Counter: <b>$nopm[0]</b><br/><br/>";
    echo "<font color=\"0000FF\">======================</font><br/>";
    echo "<a href=\"copyrights.php\">&#169;FlareZone 2007 - 2023</a><br/>";
    echo "<font color=\"0000FF\">======================</font><br/>";
    echo "<font color=\"0000FF\">======================</font><br/>";
    echo "<a href=\"http://lavalair.net\">Lavalair</a><br/>";
    echo "<font color=\"0000FF\">======================</font><br/>";
  echo "</p>";
  echo xhtmlfoot();
}


?>