<?php

######################################################################
# Modulo Splatt Forum per PHP-NUKE ver.5.X
# -------------------------
# Versione: 3.1    24/02/2002
#
# Copyright (c) 2002 by:
#
# Giorgio Ciranni (~Splatt~)
# (http://www.splatt.it)
# (webmaster@splatt.it)
# 
######################################################################
# Supporto tecnico disponibile sul Forum di http://www.splatt.it     #
######################################################################
# PHP-NUKE: Web Portal System
# ===========================
#
# Copyright (c) 2000 by Francisco Burzi (fburzi@ncc.org.ve)
# http://phpnuke.org
#
# This modules is the main administration part
#
######################################################################
# PHP-NUKE Add-On 2.0 :
# =====================
#
#              PHPBB Integration 
#        Brought to you by PHPNuke Add-On Team
#
# Copyright (c) 2000 by Richard Tirtadji AKA King Richard (rtirtadji@hotmail.com)
#                       Hutdik Hermawan AKA hotFix (hutdik76@hotmail.com)
# http://www.phpnuke.web.id
#
#
#########################################################################
# PHPBB 
# ==============
#
# Copyright (C) 2000 by James Atkinson (james@totalgeek.org)
# http://www.phpbb.com
#
######################################################################
# This program is free software. You can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License.
######################################################################

$module_name = "Forums";

	include("config.php");
    include ("header.php");
	include("modules/".$module_name."/language/lang-$language.php");

if (!eregi("admin.php", $PHP_SELF)) { die ("Access Denied"); }

if($Version_Num >= "5.4"){
	$result = mysql_query("select radminsuper,radminforum from $prefix"._authors." where aid='$aid'");
	list($radminsuper, $radminforum) = mysql_fetch_row($result);
	}
	else
		{ 
		$result = mysql_query("select radminsuper from $prefix"._authors." where aid='$aid'");
		list($radminsuper) = mysql_fetch_row($result);
	}

if (($radminforum==1) OR ($radminsuper==1)) {

######################################################################
#  Sub-menu Forum 
######################################################################
function SplattForumConfigAdmin() {
    global $hlpfile, $admin, $prefix, $bgcolor1, $bgcolor2;
   	OpenTable();
	echo "<center><b>"._FORUMMENU."</b></center><br>";
	echo "<table border=1 width=100%><tr>";
    echo" <td width=25% bgcolor=$bgcolor2 align=center><a href=admin.php?op=SplattForumPrefAdmin>"._FORUMPREF."</a><br><small>"._FORUMPREFDESC."</small></td>";
	echo "<td width=25% bgcolor=$bgcolor2 align=center><a href=admin.php?op=SplattForumAdmin>"._FORUM."</a><br><small>"._FORUMDESC."</small></td>";
	echo "<td width=25% bgcolor=$bgcolor2 align=center><a href=admin.php?op=SplattRankForumAdmin>"._FORUMRANK."</a><br><small>"._FORUMRANKDESC."</small></td>";
	echo "<td width=25% bgcolor=$bgcolor2 align=center><a href=admin.php?op=SplattAccessForumAdmin>"._FORUMACC."</a><br><small>"._FORUMACCDESC."</small></td>";
	echo "<td width=25% bgcolor=$bgcolor2 align=center><a href=\"admin.php\"><img src=\"images/forum/door_exit.gif\" border=\"0\" alt=\"EXIT\"></a></td></tr>";
	echo "</table><br>";
	CloseTable();
	echo "<br>";	

}

######################################################################
#  Menu' preferenze generali 
######################################################################

function SplattForumPrefAdmin() {
    global $hlpfile, $admin, $prefix, $bgcolor1, $bgcolor2;

	SplattForumConfigAdmin();
    OpenTable(); 
    $result = mysql_query("select * from ${prefix}_config");
    list($allow_html,$allow_bbcode,$allow_sig,$posts_per_page,$hot_threshold,$topics_per_page,$index_head,$index_foot, $max_upfile) = mysql_fetch_row($result);

$index_head=stripslashes($index_head);
$index_foot=stripslashes($index_foot);

    echo "<center><font size=4><b>"._FCONF."</b></center><br>";
    echo "<font size=2>";
    echo "<form action=admin.php method=post>";    
    echo "<table border=1 width=100%><tr>";
	echo" <td width=33% bgcolor=$bgcolor2 align=center><b>"._FALHTML."</b></td>";
	echo "<td width=33% bgcolor=$bgcolor2 align=center><b>"._FALBBC. "</b></td>";
	echo "<td width=33% bgcolor=$bgcolor2 align=center><b>"._FALSIGN."</b></td></tr>";
    echo "<tr><td align=center>";
    if ($allow_html==1) {    
    echo "<INPUT TYPE=RADIO NAME=allow_html VALUE=1 CHECKED>"._FSI."<INPUT TYPE=RADIO NAME=allow_html VALUE=0> "._FNO.""; 
    } else {
    echo "<INPUT TYPE=RADIO NAME=allow_html VALUE=1>"._FSI."<INPUT TYPE=RADIO NAME=allow_html VALUE=0 CHECKED>"._FNO."";
    }
    echo"</td><td align=center>";
    if ($allow_bbcode==1) {
    echo "<INPUT TYPE=RADIO NAME=allow_bbcode VALUE=1 CHECKED>"._FSI."<INPUT TYPE=RADIO NAME=allow_bbcode VALUE=0>"._FNO.""; 
    } else {
    echo "<INPUT TYPE=RADIO NAME=allow_bbcode VALUE=1>"._FSI."<INPUT TYPE=RADIO NAME=allow_bbcode VALUE=0 CHECKED>"._FNO.""; 
    }
    echo"</td><td align=center>";
    if ($allow_sig==1) {
    echo "<INPUT TYPE=RADIO NAME=allow_sig VALUE=1 CHECKED>"._FSI."<INPUT TYPE=RADIO NAME=allow_sig VALUE=0> "._FNO.""; 
    } else {
    echo "<INPUT TYPE=RADIO NAME=allow_sig VALUE=1>"._FSI."<INPUT TYPE=RADIO NAME=allow_sig VALUE=0 CHECKED>"._FNO.""; 
    }
	echo"</td></tr></table><br>";
    echo "<table border=1 width=100%><tr>";
	echo "<td width=25% bgcolor=$bgcolor2 align=center><b>"._FHOTOP."</b></td>";
	echo "<td width=25% bgcolor=$bgcolor2 align=center><b>"._FPOSTP."</b><br><small>"._FMESSCO1."</small></td>";
	echo "<td width=25% bgcolor=$bgcolor2 align=center><b>"._FTOPPF."</b><br><small>"._FMESCO2."</small></td>";	echo "<td width=25% bgcolor=$bgcolor2 align=center><b>"._MAXFILE."</b><br><small>"._MAXUPFILE."</small></td></tr>";
	echo "<tr>";
	echo "<td align=\"center\"><INPUT TYPE=\"TEXT\" NAME=\"hot_threshold\" size=\"4\" value=\"$hot_threshold\">";
	echo "&nbsp;&nbsp;</td>";
	echo "<td align=\"center\"><INPUT TYPE=\"TEXT\" NAME=\"posts_per_page\" size=\"4\" value=\"$posts_per_page\">";
	echo "&nbsp;&nbsp;</td>";
	echo "<td align=\"center\"><input type=\"text\" name=\"topics_per_page\" size=\"4\" value=\"$topics_per_page\">"; 
	echo "&nbsp;&nbsp;</td>";


	echo "<td align=\"center\"><input type=\"text\" name=\"max_upfile\" size=\"6\" value=\"$max_upfile\">";


    echo "&nbsp;&nbsp;</td></tr></table><br>";
    echo "<table border=1 width=100%><tr>";
    echo "<td width=50% bgcolor=$bgcolor2 align=center><b>"._FINMSGH."</b></td>";
	echo "<td width=50% bgcolor=$bgcolor2 align=center><b>"._FINMSGF."</b></td>";
	echo "</tr><tr>";
	echo "<td width=50% align=center><TEXTAREA NAME=index_head cols=40 rows=6 wrap=virtual>$index_head</TEXTAREA><br></td>";
	echo "<td width=50% align=center><textarea name=index_foot cols=40 rows=6>$index_foot</textarea><br></td>";
    echo "</td></tr></table><br>";
	echo "<center>";
	echo "<input type=hidden name=op value=SplattForumConfigChange>";
	echo "<input type=submit value="._FSAVC.">";
	echo "</form></center>";
	CloseTable();
}
######################################################################
#  Funzione amministrazione ranghi Forum 
######################################################################
function SplattRankForumAdmin() {
global $hlpfile, $admin, $prefix, $bgcolor1, $bgcolor2;
	SplattForumConfigAdmin();
	OpenTable();
    echo "<center><font size=4><b>"._FORANKSI."</b></center><br>";
    echo "<form action=admin.php method=post>";
    echo "<table border=1 width=100%><tr>";
    echo "<td bgcolor=$bgcolor2><center>"._FTITL."</td>";
    echo "<td bgcolor=$bgcolor2><center>"._RANKIM."</td>";
    echo "<td bgcolor=$bgcolor2><center>"._FMINPO."</td>";
    echo "<td bgcolor=$bgcolor2><center>"._FMAXPO."</td>";
    echo "<td bgcolor=$bgcolor2><center>"._FRANSP."</td>";
	echo "<td bgcolor=$bgcolor2><center>"._FOPTIONS."</td></tr>";
    $result = mysql_query("select rank_id, rank_title, rank_min, rank_max, rank_special, rank_image from ${prefix}_ranks order by rank_id");

    while(list($rank_id, $rank_title, $rank_min, $rank_max, $rank_special, $rank_image) = mysql_fetch_row($result)) {
    echo "<td align=center>$rank_title</td>";
		if($rank_image ==""){
	echo "<td align=center>"._NONE."</td>";
		}
else {echo "<td align=center><img src=\"images/forum/special/$rank_image\"></td>";}
	echo "<td align=center>$rank_min</td>";
	echo "<td align=center>$rank_max</td>";
        if ($rank_special ==1) {
    echo"<td align=center>on</td>";
		}
        else {
    echo"<td align=center>off</td>";
		}
    echo"<td align=center><a href=admin.php?op=SplattRankForumEdit&rank_id=$rank_id>"._FAEDIT."</a> | <a href=admin.php?op=SplattRankForumDel&rank_id=$rank_id&ok=0>"._FCANC."</a></td><tr>";
    }
    echo "</form></td></tr></table><br></center>";
    echo "<form action=admin.php method=post>";
    echo "<table border=1 width=100%><tr>";
	echo "<td align=center bgcolor=$bgcolor2>"._FTITL." </td>";
    echo "<td bgcolor=$bgcolor2><center>"._RANKIM."</td>";
	echo "<td align=center bgcolor=$bgcolor2>"._FMINPO."</td>";
	echo "<td align=center bgcolor=$bgcolor2>"._FMAXPO."</td>";
	echo "<td align=center bgcolor=$bgcolor2>"._FRANSP."</td>";
	echo "<td align=center bgcolor=$bgcolor2>"._FADDNRAN."</td>";
	echo "</tr><tr>";
	echo "<td align=center><input type=text name=rank_title size=20></td>";
	echo "<td align=center><input type=text name=rank_image size=20></td>";
    echo "<td align=center><input type=text name=rank_min size=3 maxsize=3></td>";
    echo "<td align=center><input type=text name=rank_max size=3 maxsize=3></td>";
    echo "<td align=center><input type=checkbox name=rank_special value=1></td>";
    echo "<td align=center><input type=hidden name=op value=SplattRankForumAdd>";
    echo" <input type=submit value="._FADD.">&nbsp;&nbsp;";
	echo "</tr></table>";
    echo "</form>";
	echo "<br>"._RANKIMD."<br><br>";

$handle=opendir("./images/forum/special/");
                while ($file = readdir($handle))
                        {
                        $filelist[] = $file;
                }
                asort($filelist);
                while (list ($key, $file) = each ($filelist))
                {
                ereg(".gif|.jpg",$file);
                if ($file == "." || $file == ".." || $file == "index.html" || $file == "blank.gif") $count= $count++;
                else {
                        echo "  &nbsp;";
                        echo "$file: <IMG SRC=\"images/forum/special/$file\" BORDER=0 alt=\"$file\"><br>";
                        }
                }
	echo "<br><br><hr>"._RANKIMB."<br>";

	CloseTable();
}
######################################################################
#  Funzione amministrazione accessi Forum 
######################################################################
function SplattAccessForumAdmin() {
    global $start, $hlpfile, $admin, $prefix, $bgcolor1, $bgcolor2;
	SplattForumConfigAdmin();
	OpenTable();
    
/* echo"<form action=admin.php method=post>"
    ."<center><b>"._FPRAC."</b></center>"
    ."<table border=1 width=100%><tr>"
    ."<td align=\"center\" bgcolor=$bgcolor2 width=80%><b>"._FLIVAC."</b></td>"
	."<td align=center bgcolor=$bgcolor2 width=20%><b>"._FOPTIONS."</b></td></tr>";

    $result = mysql_query("select access_id, access_title from ${prefix}_access order by access_id");
    while(list($access_id, $access_title) = mysql_fetch_row($result)) 
	     {
          echo "<td align=center>$access_title</td><tr><br>";
          echo "<td align=center><a href=admin.php?op=SplattAccessForumEdit&access_id=$access_id>"._FAEDIT."</a></td><tr><br>";
         }
    echo "</form></td></tr></table>";
    echo "<br>";
*/

if(!isset($start)) {$start = 0;}

        $sql = "SELECT u.uid, u.uname, u.user_level, a.access_title FROM ".$prefix."_users u, ${prefix}_access a WHERE u.uid != 1 AND u.user_level != -1 AND u.user_level = a.access_id ORDER BY u.uname limit $start, 30";
    $result = mysql_query($sql);

$numutenti = mysql_query("SELECT * FROM $prefix"._users."");

$total_users=mysql_num_rows($numutenti);
$totalpage=($total_users % 30);
echo"<center><b>Total Users:</b> $total_users</center><br>";

$count = 1;
$next = $start + 30;
if($total_users > 30) {
    if($next >= $total_users)
                 echo "<b><font size=1 color=$textcolor2>"._FNEXTP."</font></b>\n";
               else
                 echo "  <a href=\"admin.php?op=SplattAccessForumAdmin&start=$next\"><font size=1 color=$textcolor2> "._FNEXTP."</font></a><font size=1 color=$textcolor2> | </font>";
   for($x = 0; $x < $total_users; $x++) {
      if(!($x % 30)) {
         if($x == $start)
           echo "<b><font size=1 color=$textcolor2>$count</font></b>\n";
         else
           echo "<a href=\"admin.php?op=SplattAccessForumAdmin&start=$x\"><font size=1 color=$textcolor2>$count</a>\n";
         $count++;
         if(!($count % 50)) echo "<BR>";

			}
		}
	}

	echo "<br><br><table border=1 width=100%><tr>";
    echo "<td align=center bgcolor=$bgcolor2>"._FUSID."</td>";
	echo "<td align=center bgcolor=$bgcolor2>"._FCUSACL."</td>";
	echo "<td align=center bgcolor=$bgcolor2>"._FOPTIONS."</td></tr>";

    while(list($uid, $uname, $access_id, $access_title) = mysql_fetch_row($result)) 
	    {


         echo "<td align=center>$uname</td><td align=center>$access_title</td>";
         echo "<td align=center><a href=admin.php?op=SplattAccessUserEdit&user_id=$uid&access_id=$access_id>"._FAEDIT."</a> </td><tr>";
        }
    echo "</td></tr></table></center>";
    echo "<form action=admin.php method=post>";
    echo "<table border=1 width=100%><tr>";
	echo "<td align=center bgcolor=$bgcolor2>"._FUSID."</td>";
    echo "<td align=center bgcolor=$bgcolor2>"._FUT." </td>";
	echo "<td align=center bgcolor=$bgcolor2>"._FADNUSAC."</td></tr><tr>";
	echo "<td align=center><input type=text name=user_name size=10></td>";
    echo "<td align=center><select name=access_id>";
    $result = mysql_query("select access_id, access_title from ${prefix}_access where access_id != -1 AND access_id != 4 order by access_id");
    while(list($access_id, $access_title) = mysql_fetch_row($result)) 
		{
         echo "        <option value=".$access_id.">".$access_title."</option>";
        }
    echo "</select>";
	echo "</td>";
    echo "<td align=center><input type=hidden name=op value=SplattAccessUserAdd>";
    echo "<input type=submit value="._FADD.">";
	echo "</tr></table>";
    echo "</form>";
    CloseTable();
}
######################################################################
#  Funzione amministrazione categorie e Forum 
######################################################################	
function SplattForumAdmin() {
    global $hlpfile, $admin, $prefix, $bgcolor1, $bgcolor2, $lastid;
	SplattForumConfigAdmin();
    OpenTable();
    echo "<center><font size=4><b>"._FCATE."</b></font></center>";
    echo "<form action=admin.php method=post>";
    echo "<center><table border=1 width=100%><tr>";
//	echo "<td align=\"center\" bgcolor=\"$bgcolor2\"><center>"._BBAORDER."</td>";
	echo "<td align=\"center\" bgcolor=\"$bgcolor2\"><center>"._CATORDE."</td>";
  //  echo "<td align=center bgcolor=$bgcolor2><center>"._FID."</td>";
    echo "<td align=center bgcolor=$bgcolor2><center>"._FCATT."</td>";
    echo "<td align=center bgcolor=$bgcolor2><center>"._FNUM."</td>";
	echo "<td align=center bgcolor=$bgcolor2>"._FOPTIONS."</td></tr>";
    $result = mysql_query("select cat_id, cat_order, cat_title from ${prefix}_catagories order by cat_order");
    while(list($cat_id, $cat_order, $cat_title) = mysql_fetch_row($result)) 
	     {
          $gets = mysql_query("select count(*) as total from ${prefix}_forums where cat_id=$cat_id");
          $numbers= mysql_fetch_array($gets);
//echo "<td align=center>$cat_order</td>";
echo "<td align=\"center\"><a href=\"admin.php?op=SplattForumCatOrder&cat_id=$cat_id&cat_order=$cat_order&lastid=$lastid&changes=up\"><img src=\"images/up.gif\" border=\"0\" alt=\""._CATUP."\"></a>&nbsp;<a href=\"admin.php?op=SplattForumCatOrder&cat_id=$cat_id&cat_order=$cat_order&lastid=$lastid&changes=down\"><img src=\"images/down.gif\" border=\"0\" alt=\""._CATDOWN."\"></a></td>";
           // echo "<td align=center>$cat_id</td>";
            echo "<td align=center>$cat_title</td>";
            echo "<td align=center>$numbers[total]</td>";
            echo "<td align=center><a href=\"admin.php?op=SplattForumGo&cat_id=$cat_id&ctg=$cat_title\">"._FEDFO."</a> | <a href=admin.php?op=SplattForumCatEdit&cat_id=$cat_id>"._FAEDIT." "._FCATT."</a> | <a href=admin.php?op=SplattForumCatDel&cat_id=$cat_id&ok=0>"._FCANC."</a></td><tr>";
         }
    echo "</form></td></tr>";
	echo "<tr><td colspan=\"4\" align=\"left\"><a href=\"admin.php?op=SplattForumResetOrder\">&nbsp;"._CATRESET."</a></tr></td></table>";
    echo "<br><br>";

    echo "<form action=admin.php method=post>";
    echo "<table border=1 width=100%><tr>";
	echo "<td align=center bgcolor=$bgcolor2>"._FCATT." </td>";
	echo "<td align=center bgcolor=$bgcolor2>"._FADDCAT."</td></tr><tr>";
	echo "<td align=center><input type=text name=catagories size=31></td>";
	echo "<td align=center>";
    echo "<input type=hidden name=op value=SplattForumCatAdd>";
    echo "<input type=submit value="._FADD.">";
	echo "</td></tr></table>";
    echo "</form>";
    echo "</td></tr></table></td></tr></table>";

    CloseTable();
}

######################################################################
function SplattRankForumEdit($rank_id) {
    global $hlpfile, $admin, $prefix, $bgcolor1, $bgcolor2;
    include ("config.php");
	SplattForumConfigAdmin();
    $hlpfile = "manual/$language/rankphpbb.html";
    

    $result = mysql_query("select rank_title, rank_min, rank_max, rank_special, rank_image from ${prefix}_ranks where rank_id='$rank_id'");
    list($rank_title, $rank_min, $rank_max, $rank_special,$rank_image) = mysql_fetch_row($result);

    OpenTable();
    echo "
    <center><font size=4><b>"._EDITRANK."</b></font></center>
    <form action=admin.php method=post>
    <input type=hidden name=rank_id value=$rank_id>
    <table border=1 width=100%><tr>
	<td align=center bgcolor=$bgcolor2>"._FTITL.": </td>
	<td align=center bgcolor=$bgcolor2>"._RANKIM.": </td>
	<td align=center bgcolor=$bgcolor2>"._FMINPO." </td>
	<td align=center bgcolor=$bgcolor2>"._FMAXPO." </td>
	<td align=center bgcolor=$bgcolor2>"._FRANSP." </td>
	<td align=center bgcolor=$bgcolor2>"._FOPTIONS." </td></tr><tr>
	<td align=center><input type=text name=rank_title size=20 value=\"$rank_title\"></td>
	<td align=center><input type=text name=rank_image size=20 value=\"$rank_image\"></td>";
    if ($rank_special == 1) {
    echo "<td align=center>active</td>
	<td align=center><input type=hidden name=rank_min value=\"$rank_min\"></td>
    <td align=center><input type=hidden name=rank_max value=\"$rank_max\"></td>
    <td align=center><input type=hidden name=rank_special value=$rank_special></td>";
    } else {
    echo "<td align=center><input type=text name=rank_min size=3 value=\"$rank_min\"></td>
    <td align=center><input type=text name=rank_max size=3 value=\"$rank_max\"></td>
    <td align=center><input type=checkbox name=rank_special value=1></td>";
    }
    echo"
    <td align=center>
    <input type=hidden name=op value=SplattRankForumSave>
    <input type=submit value="._FSAVC.">
    </td></tr></table>
	</form>    ";

	echo "<br>"._RANKIMD."<br><br>";

$handle=opendir("./images/forum/special/");
                while ($file = readdir($handle))
                        {
                        $filelist[] = $file;
                }
                asort($filelist);
                while (list ($key, $file) = each ($filelist))
                {
                ereg(".gif|.jpg",$file);
                if ($file == "." || $file == ".." || $file == "index.html") $count= $count++;
                else {
                        echo "  &nbsp;";
                        echo "<IMG SRC=\"images/forum/special/$file\" BORDER=0 alt=\"$file\">&nbsp;";
                        $count++;
                        }
                if ($count == "9") { echo "<br>"; $count = 1; }

                }
	echo "<br><br><hr>"._RANKIMB."<br>";
	CloseTable();
    include("footer.php");
}

######################################################################
function SplattForumConfigChange($allow_html,$allow_bbcode,$allow_sig,$posts_per_page,$hot_threshold,$topics_per_page, $index_head,$index_foot,$max_upfile) 

    {
     global $prefix;
     $index_head = addslashes($index_head);
     $index_foot = addslashes($index_foot);

     mysql_query("update ${prefix}_config set allow_html='$allow_html', allow_bbcode='$allow_bbcode', allow_sig='$allow_sig', posts_per_page='$posts_per_page', hot_threshold='$hot_threshold', topics_per_page='$topics_per_page',  index_head='$index_head', index_foot='$index_foot', max_upfile='$max_upfile' ");

SplattForumPrefAdmin();
 }
	

######################################################################
function SplattRankForumDel($rank_id, $ok=0) {
global $prefix;
    if($ok==1) {
        mysql_query("delete from ${prefix}_ranks where rank_id=$rank_id");
				SplattRankForumAdmin();
    } else {

        //GraphicAdmin($hlpfile);
        OpenTable();
        echo "<center><br>";
        echo "<font size=3 color=Red>";
        echo "<b>"._WADELRA."</b><br><br><font color=Black>";
		        echo "[ <a href=admin.php?op=SplattRankForumDel&rank_id=$rank_id&ok=1>".translate("Yes")."</a> | <a href=admin.php?op=SplattRankForumAdmin>".translate("No")."</a> ]<br><br>";

    }
        echo "</TD></TR></TABLE></TD></TR></TABLE>";
        include("footer.php");
}
######################################################################
function SplattRankForumAdd($rank_title,$rank_min,$rank_max,$rank_special,$rank_image) {
global $prefix;
    if ($rank_special == 1) {
    mysql_query("insert into ${prefix}_ranks values (NULL, '$rank_title', '-1' ,'-1' ,'$rank_special', '$rank_image')");
    } else {
    mysql_query("insert into ${prefix}_ranks values (NULL, '$rank_title', '$rank_min' ,'$rank_max' ,'0','$rank_image')");
    }
	SplattRankForumAdmin();
}
######################################################################
function SplattRankForumSave($rank_id, $rank_title, $rank_min, $rank_max, $rank_special,$rank_image) {
global $prefix;
    mysql_query("update ${prefix}_ranks set rank_title='$rank_title',rank_min='$rank_min',rank_max='$rank_max',rank_special='$rank_special',rank_image='$rank_image' where rank_id='$rank_id'");
	SplattRankForumAdmin();
}

/*
######################################################################
function SplattAccessForumEdit($access_id) {
    global $hlpfile, $prefix, $admin, $bgcolor1, $bgcolor2;
    include ("config.php");
    $hlpfile = "manual/$language/accessphpbb.html";
    SplattForumConfigAdmin();
    $result = mysql_query("select access_title from ${prefix}_splattforum_access where access_id='$access_id'");
    list($access_title) = mysql_fetch_row($result);

    OpenTable();
    echo "
    <center><font size=4><b>"._FAEDIT." "._FLIVAC."</b></font></center>
    <form action=admin.php method=post>
    <input type=hidden name=access_id value=$access_id>
    <table border=1 width=100%><tr><td align=center bgcolor=$bgcolor2>
    "._FLIVAC." </td>
	<td align=center bgcolor=$bgcolor2>"._FOPTIONS."</td></tr>
	<td align=center><input type=text name=access_title size=31 value=\"$access_title\"></td>";
    echo"<td align=center>    
    <input type=hidden name=op value=SplattAccessForumSave>
    <input type=submit value="._SAVECHANGES.">
	</td></tr></table>
    </form>";
    CloseTable();
    include("footer.php");

}
######################################################################
*/
/*
function SplattAccessForumDel($access_id, $ok=0) {
global $prefix;
    if($ok==1) {
        mysql_query("delete from ${prefix}_splattforum_access where access_id=$access_id");
        SplattAccessForumAdmin();
    } else {

        GraphicAdmin($hlpfile);
        OpenTable();
        echo "<center><br>";
        echo "<font size=3 color=Red>";
        echo "<b>"._FWARDEL."</b><br><br><font color=Black>";
            echo "[ <a href=admin.php?op=SplattAccessForumDel&access_id=$access_id&ok=1>"._FSI."</a> | <a href=admin.php?op=SplattAccessForumAdmin>"._FNO."</a> ]<br><br>";
}
        echo "</TD></TR></TABLE></TD></TR></TABLE>";
        include("footer.php");
}
*/
/*
######################################################################
function SplattAccessUserDel($user_id, $ok=0) {
global $prefix;
    if($ok==1) {
        mysql_query("delete from ${prefix}_splattforum_users_status where uid=$user_id");
        SplattAccessForumAdmin();
    } else {
        GraphicAdmin($hlpfile);
        OpenTable();
        echo "<center><br>";
        echo "<font size=3 color=Red>";
        echo "<b>"._WARDELU."</b><br><br><font color=Black>";
		echo "[ <a href=admin.php?op=SplattAccessUserDel&user_id=$user_id&ok=1>"._FSI."</a> | <a href=admin.php?op=SplattAccessForumAdmin>"._FNO."</a> ]<br><br>";

    }
        echo "</TD></TR></TABLE></TD></TR></TABLE>";
        include("footer.php");
}
######################################################################
*/

function SplattAccessUserEdit($user_id, $access_id) {
    global $hlpfile, $admin, $prefix, $bgcolor1, $bgcolor2;
    include ("config.php");
    $hlpfile = "manual/$language/accessphpbb.html";
   	SplattForumConfigAdmin(); 
    $result = mysql_query("select uid, name, uname from ".$prefix."_users where uid='$user_id'");
    list($uid, $name, $uname) = mysql_fetch_row($result);
    OpenTable();
    echo "
    <center><font size=4><b>"._FEDUSAC."</b></font></center>
    <form action=admin.php method=post>
    <input type=hidden name=user_id value=$user_id>
    <table border=1 width=100%><tr>
    <td align=center bgcolor=$bgcolor2>"._FUSID." </td>
	<td align=center bgcolor=$bgcolor2>"._FNAME." </td>
    <td align=center bgcolor=$bgcolor2>"._FLIVAC." </td>
	<td align=center bgcolor=$bgcolor2>"._FOPTIONS."</td>
	</tr><tr>
	<td>$uname</td>
	<td>$name</td><td align=center>
	<select name=access_id>";
    $result = mysql_query("select access_id, access_title from ${prefix}_access where access_id != -1 AND access_id != 4 order by access_id");
    while(list($aid, $access_title) = mysql_fetch_row($result)) {
            echo "        <option value='".$aid."'";
            if ("$aid" == "$access_id") echo " selected";
            echo ">".$access_title."</option>";
        }
        echo"</select></td><td align=center>
    <input type=hidden name=op value=SplattAccessUserSave>
    <input type=submit value="._FSAV."></td></tr></table>
    </form>";
	CloseTable();
    include("footer.php");
}
######################################################################
function SplattAccessUserSave($user_id, $access_id) {
global $prefix;
        if ($access_id == -1) $access_id = 1;
        if ($access_id > 0) {
                mysql_query("update ${prefix}_users set user_level='$access_id' where uid='$user_id'");
            SplattAccessForumAdmin();
        } else {
                die("<font size=+1>"._ERRORE1."</font><hr>No valid access_id specified, access_id=".$access_id);
        }
}


/*
######################################################################
function SplattAccessUserAdd($user_name, $access_id) {
global $prefix;
        list($uid) = mysql_fetch_row(mysql_query("select uid from ".$prefix."_users where uname = '".$user_name."'"));
        if ($access_id == -1) $access_id = 1;
        if ($access_id > 0) {
                if ($uid > 0) {
                    mysql_query("insert into ${prefix}_splattforum_users_status (uid, posts, attachsig, rank, level) values ('$uid', '0', '0', '0', '$access_id')");
                    SplattAccessForumAdmin();
                } else {
                        die("<font size=+1>"._ERRORE1."</font><hr>Not a valid user specified, uid=".$uid." name=".$user_name);
                }
        } else {
                die("<font size=+1>"._ERRORE1."</font><hr>No valid access_id specified, access_id=".$access_id);
        }
}
######################################################################
*/
/*

function SplattAccessForumAdd($access_title) {
global $prefix;
    mysql_query("insert into ${prefix}_splattforum_access values (NULL, '$access_title')");
	SplattForumConfigAdmin();
}

######################################################################
function SplattAccessForumSave($access_id, $access_title) {
global $prefix;
    mysql_query("update ${prefix}_splattforum_access set access_title='$access_title' where access_id='$access_id'");
	SplattForumConfigAdmin();
}
*/
######################################################################
function SplattForumGoAdd($forum_name, $forum_desc, $forum_access, $mods, $cat_id, $forum_type, $forum_pass, $forum_notify_email, $forum_atch) {
global $prefix, $cat_id, $cat_title;

    mysql_query("insert into ${prefix}_forums values (NULL, '$forum_name', '$forum_desc', '$forum_access', NULL, '$cat_id', '$forum_type', '$forum_pass', '$forum_notify_email', '$forum_atch')");
    list($forum_id) = mysql_fetch_array(mysql_query("SELECT forum_id FROM ${prefix}_forums WHERE forum_name = '$forum_name' AND forum_desc = '$forum_desc' AND cat_id = '$cat_id' AND forum_type = '$forum_type'"));
        $count = 0;

        if (is_array($mods)) {
                while(list($null, $mod) = each($mods)) {
                        if (list($ulevel) = mysql_fetch_array(mysql_query("SELECT user_level FROM ${prefix}_users WHERE uid = $mod"))) {
                                if ($ulevel < 2) {
                                        if (!isset($level_query)) { $level_query = "UPDATE ${prefix}_users SET user_level = 2 WHERE "; }
                                        if ($count > 0) { $level_query .= "OR"; }
                                        $level_query .= "uid = '$mod' ";
                                        $count++;
                                }
                        }
                 }
                $count = 0;
                reset($mods);
                while(list($null, $mod) = each($mods)) {
                         if (!mysql_query("INSERT INTO ${prefix}_forum_mods (forum_id, user_id) VALUES ('$forum_id','$mod')")) {
                                echo "Error -- Add Moderator";
                                echo mysql_errno() . " --- " . mysql_error() . "<br>";
                                return false;
                         }
                }

                 if (isset($level_query)) {
                         if (!mysql_query($level_query)) {
                                 echo "Error -- Updating Level";
                                 return false;
                         }
                 }
        }
		
 /*   Header("Location: admin.php?op=SplattForumGo&cat_id=$cat_id&ctg=$cat_title");*/
 SplattForumAdmin();
}
######################################################################

function SplattForumGoSave($forum_id, $forum_name, $forum_desc, $forum_access, $mods, $rem_mods, $cat_id, $forum_type, $forum_pass, $forum_notify_email, $forum_atch) {
global $prefix,$ctg;

        if (isset($forum_pass)) {
                mysql_query("update ${prefix}_forums set forum_name='$forum_name', forum_desc='$forum_desc', forum_access='$forum_access', cat_id='$cat_id', forum_type='$forum_type', forum_pass='$forum_pass', forum_notify_email='$forum_notify_email', forum_atch='$forum_atch' where forum_id='$forum_id'");
        } else {
                mysql_query("update ${prefix}_forums set forum_name='$forum_name', forum_desc='$forum_desc', forum_access='$forum_access', cat_id='$cat_id', forum_type='$forum_type', forum_notify_email='$forum_notify_email', forum_atch='$forum_atch' where forum_id='$forum_id'");
        }

        $count = 0;
        if (is_array($mods)) {
                while(list($null, $mod) = each($mods)) {
                        if (list($ulevel) = mysql_fetch_array(mysql_query("SELECT user_level FROM ${prefix}_users WHERE uid = $mod"))) {
                                if ($ulevel < 2) {
                                        if (!isset($level_query)) { $level_query = "UPDATE ${prefix}_users SET user_level = 2 WHERE "; }
                                        if ($count > 0) { $level_query .= "OR"; }
                                        $level_query .= "uid = '$mod' ";
                                        $count++;
                                }
                        }
                 }

                $count = 0;
                reset($mods);
                while(list($null, $mod) = each($mods)) {
                        if (!mysql_query("INSERT INTO ${prefix}_forum_mods (forum_id, user_id) VALUES ('$forum_id','$mod')")) {
                                echo "Error -- Add Moderator";
                                echo mysql_errno() . " --- " . mysql_error() . "<br>";
                                return false;
                         }
                }

                 if (isset($level_query)) {
                         if (!mysql_query($level_query)) {
                                 echo "Error -- Updating Level";
                                 return false;
                         }
                 }
        }
        if (is_array($rem_mods)) {
                $count = 0;
                while(list($null, $rem_mod) = each($rem_mods)) {
                        if (!mysql_query("DELETE FROM ${prefix}_forum_mods WHERE forum_id = '$forum_id' AND user_id = '$rem_mod'")) {
                                echo "Error -- Delete Moderator";
                                return false;
                        }
                }
        }
   SplattForumGo($cat_id,$ctg);
}
######################################################################
function SplattForumCatDel($cat_id, $ok=0) {
global $prefix;
    if($ok==1) {
                $result = mysql_query("select forum_id from ${prefix}_forums where cat_id='$cat_id'");
                while(list($forum_id) = mysql_fetch_row($result)) {
                        mysql_query("delete from ${prefix}_forumtopics where forum_id=$forum_id");
                }
                mysql_query("delete from ${prefix}_forums where cat_id=$cat_id");
                mysql_query("delete from ${prefix}_catagories where cat_id=$cat_id");
                SplattForumAdmin();
    } else {

                GraphicAdmin($hlpfile);
                OpenTable();
                echo "<center><br>";
                echo "<font size=3 color=Red>";
                echo "<b>"._WADELCAT."</b><br><br><font color=Black>";
        echo "[ <a href=admin.php?op=SplattForumCatDel&cat_id=$cat_id&ok=1>"._FSI."</a> | <a href=admin.php?op=SplattForumAdmin>"._FNO."</a> ]<br><br>";
				
    }
        echo "</TD></TR></TABLE></TD></TR></TABLE>";
        include("footer.php");
}
######################################################################
function SplattForumGoDel($forum_id, $ok=0) {
global $prefix;
    if($ok==1) {
                mysql_query("delete from ${prefix}_forumtopics where forum_id=$forum_id");
                mysql_query("delete from ${prefix}_forums where forum_id=$forum_id");
                SplattForumAdmin();
    } else {
                GraphicAdmin($hlpfile);
                OpenTable();
                echo "<center><br>";
                echo "<font size=3 color=Red>";
                echo "<b>"._WADELFO."</b><br><br><font color=Black>";
				echo "[ <a href=admin.php?op=SplattForumGoDel&forum_id=$forum_id&ok=1>"._FSI."</a> | <a href=admin.php?op=SplattForumAdmin>"._FNO."</a> ]<br><br>";

    }
        echo "</TD></TR></TABLE></TD></TR></TABLE>";
        include("footer.php");
}
######################################################################
function SplattForumCatSave($cat_id, $cat_title) {
global $prefix;
    mysql_query("update ${prefix}_catagories set cat_title='$cat_title' where cat_id='$cat_id'");
	SplattForumAdmin();
}
######################################################################
function SplattForumCatEdit($cat_id) {
    global $hlpfile, $admin, $prefix, $bgcolor1, $bgcolor2;
    include('config.php');
	SplattForumConfigAdmin();
    $result = mysql_query("select cat_id, cat_title from ${prefix}_catagories where cat_id='$cat_id'");
    list($cat_id, $cat_title) = mysql_fetch_row($result);
    OpenTable();
    echo "
    <center><font size=4><b>"._FAEDIT." "._FCATT."</b></font></center>
    <form action=admin.php method=post>
    <input type=hidden name=cat_id value=$cat_id>
    <table border=1 width=100%><tr>
	<td align=center bgcolor=$bgcolor2> "._FCATT.": </td>
	<td align=center bgcolor=$bgcolor2>"._FOPTIONS."</td></tr>
	<td align=center><input type=text name=cat_title size=31 value=\"$cat_title\"></td><td align=center>
    <input type=hidden name=op value=SplattForumCatSave>
    <input type=submit value="._FSAVC.">
	</td></tr></table>
    </form>   ";
	CloseTable();
    include("footer.php");
}
######################################################################


function SplattForumGoEdit($forum_id) {
    global $hlpfile, $admin, $db, $prefix;
    include('config.php');
	SplattForumConfigAdmin();
    $result = mysql_query("select forum_id, forum_name, forum_desc, forum_access, forum_moderator, cat_id, forum_type, forum_notify_email, forum_atch from ${prefix}_forums where forum_id='$forum_id'");
    list($forum_id, $forum_name, $forum_desc, $forum_access, $forum_moderator, $cat_id, $forum_type, $forum_notify_email, $forum_atch) = mysql_fetch_row($result);
    OpenTable();
    echo "
                <center><font size=4><b>"._FEDFO." $forum_name</b></font></center>
                <form action=admin.php method=post>
                <input type=hidden name=forum_id value=$forum_id>
                <table border=0 width=100%><tr><td>
                <tr><td>"._FNAME.": </td><td><input type=text name=forum_name size=31 value=\"$forum_name\"></td></tr>
                <tr><td>"._FDESCR.": </td><td><textarea name=forum_desc cols=60 rows=5>$forum_desc</textarea></td></tr>
                <tr><td> "._FMODS.": </td>
                <td>";

    echo "<b>"._FATTUA.":</b><br>";

    $sql = "SELECT u.uname, u.uid FROM ".$prefix."_users u, ${prefix}_forum_mods f WHERE f.forum_id = '$forum_id' AND u.uid = f.user_id";

    if(!$r = mysql_query($sql))
        die("Error connecting to the database.");
    if($row = mysql_fetch_array($r)) {
            do {
                    echo "$row[uname] (<input type=\"checkbox\" name=\"rem_mods[]\" value=\"$row[uid]\"> "._FCANC.")<BR>";
                    $current_mods[] = $row[uid];
            } while($row = mysql_fetch_array($r));

            echo "<BR>";
     } else {
             echo ""._NOMODSA."<BR><BR>\n";
     }

    echo "<b>"._FADD.":</b><br>";
        $sql = "SELECT uid, uname FROM ".$prefix."_users WHERE uid != 1 AND user_level != -1 ";

        if (is_array($current_mods)) {
            reset($current_mods);
            while(list($null, $currMod) = each($current_mods)) {
                    $sql .= "AND uid != $currMod ";
            }
        }
        $sql .= "ORDER BY uname";

    echo "<SELECT NAME=\"mods[]\" size=\"10\" multiple>";

        if(!$r = mysql_query($sql))
                die("An Error Occurred<HR>Could not connect to the database. Please check the config file.");
        if($row = mysql_fetch_array($r)) {
                do {
                        $s = "";
                        if($row[uid] == $myrow[forum_moderator]) { $s = "SELECTED"; }
                        echo "<OPTION VALUE=\"$row[uid]\" $s>$row[uname]</OPTION>\n";
                } while($row = mysql_fetch_array($r));
        } else {
                echo "<OPTION VALUE=\"0\">"._FNONE."</OPTION>\n";
        }

    echo "</select></td></tr>
    <tr><td>"._FLIVAC.": </td>
    <td><SELECT NAME=forum_access>";

    if ($forum_access == 0) {
        $selected_option_0 = " selected";
    }
    if ($forum_access == 1) {
        $selected_option_1 = " selected";
    }
    if ($forum_access == 2) {
        $selected_option_2 = " selected";
    }

        echo "<OPTION VALUE=0$selected_option_0>"._FANON."</OPTION>";
        echo "<OPTION VALUE=1$selected_option_1>"._FREG."</OPTION>";
        echo "<OPTION VALUE=2$selected_option_2>"._FMODERAM."</OPTION>";


        echo"</SELECT>";


    echo"
    </td></tr>
    <tr><td>"._FAEDIT." "._FCATT.": </td>
    <td><SELECT NAME=cat_id>";
    $result = mysql_query("select cat_id, cat_title from ${prefix}_catagories");
    while(list($cat_id1, $cat_title) = mysql_fetch_row($result)) {
        if ($cat_id1 == $cat_id) {
            echo "<OPTION VALUE=\"$cat_id\" selected>$cat_title</OPTION>";
    } else {
            echo "<OPTION VALUE=\"$cat_id\">$cat_title</OPTION>";
    }
    }
    echo "
    </SELECT>
    </td></tr>
    <tr><td>"._FTIPO.": </td>
    <td><SELECT NAME=forum_type>";
    if ($forum_type == 0) {
        echo "<OPTION VALUE=0 selected>"._FPUBLIC."</OPTION>";
    } else {
        echo "<OPTION VALUE=0>"._FPUBLIC."</OPTION>";
    }

    if ($forum_type == 1) {
        echo "<OPTION VALUE=1 selected>"._FPRIVA."</OPTION>";
    } else {
        echo "<OPTION VALUE=1>"._FPRIVA."</OPTION>";
    }

        echo "
        </SELECT>
    </td></tr>
    <tr><td>"._FPASSIF.": </td><td><input type=text name=forum_pass size=31>&nbsp;<i>("._FOPPR.")</i></td></tr>
<tr><td>"._FNOTMAIL.":</td>
<td><input type=text size=31 name=forum_notify_email value=$forum_notify_email>&nbsp;<i>("._FOPTIO.")</i></td></tr>";

echo"<tr><td>"._FORUMATCHM.": </td><td><SELECT NAME=forum_atch>";

if ($forum_atch == 1) {
        echo "<OPTION VALUE=1 selected>"._FSI."</OPTION>";
		echo"<OPTION VALUE=0>"._FNO."</OPTION>";
}
else
{
        echo"<OPTION VALUE=0 selected>"._FNO."</OPTION>";
		echo "<OPTION VALUE=1>"._FSI."</OPTION>";
}
   echo"</SELECT></td></tr></table>

    <input type=hidden name=op value=SplattForumGoSave>
    <input type=submit value="._FSAVC.">
    </form>

    </td></tr></table></td></tr></table>";
    include("footer.php");
}
######################################################################
function SplattForumGo($cat_id,$ctg) {
    global $hlpfile, $bgcolor2, $admin, $cat_title, $prefix, $module_name;
    include('config.php');
    include ("modules/".$module_name."/functions.php");  
   
    SplattForumConfigAdmin();
 
/* Make a database connection */

if(!$db = @mysql_connect("$dbhost", "$dbuname", "$dbpass")) {
    die("<font size=\"+1\">An Error Occured</font><hr>phpBB was unable to connect to the database. <BR>Please check $dbhost, $dbuser, and $dbpasswd in config.php.");
}

if(!@mysql_select_db("$dbname",$db)) {
    die("<font size=\"+1\">An Error Occured</font><hr>Forum unable to find the database <b>$dbname</b> on your MySQL server. <br>Please make sure you run the installation script.");
}

    OpenTable();
    echo "
    <center><font size=4><b>"._FPRAT." $ctg</b></font></center>
    <form action=admin.php method=post>
    <center><table border=1 width=100%><tr>
        <td bgcolor=$bgcolor2><center>"._FNAME."</td>
        <td bgcolor=$bgcolor2><center>"._FDESCR."</td>
        <td bgcolor=$bgcolor2><center>"._FMODS."</td>
        <td bgcolor=$bgcolor2><center>"._FACCE."</td>
        <td bgcolor=$bgcolor2><center>"._FTIPO."</td>
		<td bgcolor=$bgcolor2><center>"._FNOTIF."</td>
		<td bgcolor=$bgcolor2><center>"._FORUMATCHM."</td>
		<td>&nbsp</td></tr>";
    
    
    $result = mysql_query("select forum_id, forum_name, forum_desc, forum_access, forum_type, forum_notify_email, forum_atch from ${prefix}_forums where cat_id='$cat_id'");
    while(list($forum_id, $forum_name, $forum_desc, $forum_access, $forum_type, $forum_notify_email, $forum_atch) = mysql_fetch_row($result)) {

                $moderators = get_moderators($forum_id, $db);

                echo "
                <tr>
                <td align=center>$forum_name</td>
                <td align=center>$forum_desc</td>";

                echo "<td align=center>";

                if (is_array($moderators)) {
                        $count = 0;
                        reset ($moderators);
                        while(list($null, $mods) = each($moderators)) {
                                while(list($mod_id, $mod_name) = each($mods)) {

                                        if($count > 0) { echo ", "; }

                                        echo "<a href=\"modules.php?name=Your_Account&op=userinfo&uname=$mod_name\">$mod_name</a>";

                                        $count++;
                                }
                        }
                }
                echo "&nbsp;</td>";

                switch($forum_access) {
                case (0):
                                echo "<td align=center>"._FANON."</td>";
                                break;
                case (1):
                                echo "<td align=center>"._FREG."</td>";
                                break;
                case (2):
                                echo "<td align=center>"._FMODERAM."</td>";
                                break;
                }
                if ($forum_type==0) {
                        echo "<td align=center>"._FPUBLIC."</td>";
                }
                else {
                        echo "<td align=center>"._FPRIVA."</td>";
}
if(empty($forum_notify_email)) {
                        echo "<td align=center>"._FNO."</td>";
                }
                else {
                        echo "<td align=center>"._FSI."</td>";

                }
if ($forum_atch==0) {
                        echo "<td align=center>"._FNO."</td>";
                }
                else {
                        echo "<td align=center>"._FSI."</td>";
}
                echo "
                <td align=center><a href=admin.php?op=SplattForumGoEdit&forum_id=$forum_id>"._FAEDIT."</a> | <a href=admin.php?op=SplattForumGoDel&forum_id=$forum_id&ok=0>"._FCANC."</a></td></tr>";
    }
    echo "</form></td></tr></table>
    <br><br>
    </center><font size=4><b>"._FADDMOR." $ctg</b><br><br>
    <font size=2>
    <form action=admin.php method=post>
    <table border=0 width=100%>
    <tr><td>"._FNAME.": </td><td><input type=text name=forum_name size=31></td></tr>
    <tr><td>"._FDESCR.": </td><td><textarea name=forum_desc cols=60 rows=5></textarea></td></tr>
    <tr><td> "._FMODS.": </td>
    <td>";

    $sql = "SELECT uid, uname FROM ".$prefix."_users WHERE uid != 1  AND user_level != -1 ORDER BY uname";

    
    echo "<SELECT NAME=\"mods[]\" size=\"10\" multiple>";

    if(!$r = mysql_query($sql))
            die("An Error Occurred<HR>Could not connect to the database. Please check the config file.");
    if($row = mysql_fetch_array($r)) {
            do {
                $s = "";
                if($row[uid] == $myrow[forum_moderator]) { $s = "SELECTED"; }
                echo "<OPTION VALUE=\"$row[uid]\" $s>$row[uname]</OPTION>\n";
        } while($row = mysql_fetch_array($r));
    } else {
            echo "<OPTION VALUE=\"0\">"._FNONE."</OPTION>\n";
    }

    echo "</select></td></tr>
    <tr><td>"._FLIVAC.": </td>
    <td><SELECT NAME=forum_access>
                <OPTION VALUE=0>"._FANON."</OPTION>
                <OPTION VALUE=1>"._FREG."</OPTION>
                <OPTION VALUE=2>"._FMODERAM."</OPTION>
        </SELECT>
    </td></tr>
    <tr><td>"._FTIPO.": </td>
    <td><SELECT NAME=forum_type>
                <OPTION VALUE=0>"._FPUBLIC."</OPTION>
                <OPTION VALUE=1>"._FPRIVA."</OPTION>
        </SELECT>
    </td></tr>
    <tr><td>"._FPASSIF.":</td><td><input type=text name=forum_pass size=31>&nbsp;<i>("._FOPPR.")</i></td></tr>

<tr><td>"._FNOTMAIL.":</td>
<td><input type=text size=31 name=forum_notify_email>&nbsp;<i>("._FOPTIO.")</i></td></tr>

<tr><td>"._FORUMATCHM.": </td>
    <td><SELECT NAME=forum_atch>
                <OPTION VALUE=0>"._FNO."</OPTION>
                <OPTION VALUE=1>"._FSI."</OPTION>
        </SELECT>
    </td></tr>
    </table>
    <input type=hidden name=cat_id value=$cat_id>
	<input type=hidden name=cat_title value=$cat_title>
	<input type=hidden name=ctg value=$ctg>
    <input type=hidden name=op value=SplattForumGoAdd>
    <input type=submit value="._FADD.">
    </form>
    </td></tr></table></td></tr></table>";
	CloseTable();
    include("footer.php");
}
#######################################
function SplattForumCatOrder($cat_id,$cat_order,$changes,$lastid) {
global $prefix, $dbi;


if($changes=="up") {



/*
$sql = "SELECT cat_order FROM ".$prefix."_catagories ORDER BY cat_order DESC LIMIT 1";
                if(!$r  = mysql_query($sql)) {
                        die("Error quering the database");
                           }
                 list($last_number) = mysql_fetch_array($r);
                 if($last_number != $cat_order) {
                    $order = $cat_order - 1;


$las = "select cat_id from ".$prefix."_catagories where cat_order = '$orders'";

if(!$r = mysql_query($las)) {
                              die("Error connecting to the database<BR>".mysql_error($db));
                              }

list($catlast) = mysql_fetch_row($las);
*/

//$order = $cat_order--;
         if($cat_order != "1") {
         $order = $cat_order - 1;

$sql2 = "UPDATE ".$prefix."_catagories SET cat_order = $cat_order  WHERE cat_order = '$order'";
                    if(!$r = mysql_query($sql2)) {
                              die("Error connecting to the database<BR>".mysql_error($db));
							}

            $sql1 = "UPDATE ".$prefix."_catagories SET cat_order = $order WHERE cat_id = '$cat_id'";
                    if(!$r = mysql_query($sql1)) {
                              die("Error connecting to the database<BR>".mysql_error($db));
                              }

            
                             
                    Header("Location: admin.php?op=SplattForumAdmin");
                } else {
                    //include ("header.php");
                        echo "<center>"._BBACATHIGHEST."<br><a href=\"admin.php?op=SplattForumAdmin\">"._BBABACKTOFORUM."</a></center>";
                    include ("footer.php");
            }
} else {
         $sql = "SELECT cat_order FROM ".$prefix."_catagories ORDER BY cat_order DESC LIMIT 1";
                if(!$r  = mysql_query($sql)) {
                        die("Error quering the database");
                           }
                 list($last_number) = mysql_fetch_array($r);
                 if($last_number != $cat_order) {
                    $order = $cat_order + 1;
                    $sql = "UPDATE ".$prefix."_catagories SET cat_order = $cat_order WHERE cat_order = $order";
                    if(!$r  = mysql_query($sql)) {
                              die("Error quering the database");
                              }
                    $sql = "UPDATE ".$prefix."_catagories SET cat_order = $order where cat_id = $cat_id";
                    if(!$r  = mysql_query($sql)) {
                              die("Error quering the database");
                              }
                    Header("Location: admin.php?op=SplattForumAdmin");
                } else {
                   // include ("header.php");
                        echo "<center>"._BBACATLOWEST."<br><a href=\"admin.php?op=SplattForumAdmin\">"._BBABACKTOFORUM."</a></center>";
                    include ("footer.php");
            }
}
}




######################################################################
function SplattForumCatAdd($catagories) {
global $prefix;

$risultato = mysql_query("SELECT * FROM ".$prefix."_catagories");
$num_cat=mysql_num_rows($risultato);

$num_cat = $num_cat +1;

    mysql_query("insert into ${prefix}_catagories values (NULL, '$catagories','$num_cat')");
		SplattForumAdmin();
	}



######################################################################
function SplattForumResetOrder() {
global $prefix;


$query = "select cat_id from ".$prefix."_catagories";
$result = mysql_query($query) or
		die(mysql_error());
	while(list($cat_id) = mysql_fetch_array($result)){

	mysql_query("update ".$prefix."_catagories set cat_order = '$cat_id' where cat_id = '$cat_id'");
} 

//echo"Inserted default data in cat_order field ---> OK!<br>";

	SplattForumAdmin();
	}


}
else
	{echo"<center>ACCESSO NEGATO!</center>";}
?>