<?php
$admin = 2;
$file = __FILE__;
include ("../inc/inc_common.php");
include ("../inc/inc_connect.php");
include ("../inc/inc_admincheck.php");
include ("../inc/inc_getdate.php");
include ("../inc/inc_forumname.php");
$page = "Admin - Add Moderators";
$pagelink = $file;
include("../inc/inc_setonline.php");
$title = "$name1 Admin - $gfcookie[1] - Add Moderators";
include ("../inc/inc_head.php");
include ("../inc/inc_body.php");

if ($action == "add")
{
    $result=mysql_query("SELECT * FROM $userstable WHERE intId = '$mod'");
    $num_rows = mysql_num_rows( $result );
    while ( $a_row = mysql_fetch_object( $result ) )
    {
        $forums = $a_row->strForumsModerated.$id.",";
        $query = "UPDATE $userstable SET strForumsModerated = '$forums' WHERE intId = '$mod'";
        mysql_query( $query, $link ) or die ( "Error! : ".mysql_error() );
    }
}


print "<br><br><br><br><br><br>
<table border=1 cellpadding=3 cellspacing=0 style=\"border-collapse: collapse\" bordercolor=\"$bordercolor\" width=50% style=\"font-family: $font; font-size: $fontpoint\" bgcolor=\"$fgcolour\"><tr><td width=\"100%\" align=\"center\"><br><br>";

$result=mysql_query("SELECT * FROM $grouptable WHERE intId = $id");
$num_rows = mysql_num_rows( $result );
while ( $a_row = mysql_fetch_object( $result ) )
{
    print "Current moderators for $a_row->strName: ";
}

$commacount = 0;
$result = mysql_query( "SELECT * FROM $userstable WHERE strForumsModerated != '' ORDER BY strName" );
$num_rows = mysql_num_rows( $result );
while ( $a_row = mysql_fetch_object( $result ) )
{
    $fmod = explode(",", $a_row->strForumsModerated);
    $count = 0;
    while ($count < 100)
    {
        if ($id == $fmod[$count])
        {
            if ($commacount == 1)
            {
                print ", ";
            }
            print "$a_row->strName";
            $commacount = 1;
            break;
        }

        if ($fmod[$count] == "")
        {
            break;
        }
        $count ++;
    }
}

print "<br><br><form method=\"POST\" action=\"admin_moderatorsadd.php?action=add\">
<input type=\"hidden\" value=\"$id\" name=\"id\">
Add a moderator: <select name=\"mod\" size=1>";
$result=mysql_query("SELECT * FROM $userstable WHERE ynBanIp != 'Yes' ORDER BY strName");
$num_rows = mysql_num_rows( $result );
while ( $a_row = mysql_fetch_object( $result ) )
{
    print "<option value=\"$a_row->intId\">$a_row->strName</option>\n";
}
print "</select><br><br><input type=\"submit\" value=\"Add Moderator\"></form><a href=\"admin_moderators.php\">Click here to go back to the main moderators page</a>.<br><br><br></td></tr></table>";

include("../inc/inc_footer.php");
?>