<?php
if ($gfcookie[1] == "")
{
    header("Location: index.php");
    exit;
}
$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 = "Forum Subscriptions";
$pagelink = $file;
include("inc/inc_setonline.php");
$title = "$name1 Forum Subscriptions";
include ("inc/inc_head.php");
include ("inc/inc_body.php");
$title = "$name1 Forum Subscriptions";
include ("inc/inc_title.php");

print "</centeR><table border=0 width=\"100%\" cellpadding=1 cellspacing=0><tr><td  width=\"20%\">
<table border=0 cellpadding=1 cellspacing=0><tr><td>
<font face=\"$font\" size=$fontsize><image src=\"images/folder_icon.gif\">&nbsp;<a href=\"index.php\">$name1&nbsp;Home</a>
</td></tr>
<tr><td><image src=\"images/folder_line.gif\">
<font face=\"$font\" size=$fontsize><image src=\"images/open_folder_icon.gif\">&nbsp;Forum&nbsp;Subs</td></tr>
</table>
</td><td><center>";

include ("inc/inc_navigation.php");
include ("inc/inc_newmailsdisplay.php");
print "</td></tr></table><br><center>";

//end of include files...
$grimforumname = $name1;

if ($action == "change")
{
    $ilist = "0***";
    for ($i = 0; $i <= $num; $i++)
    {
        if ($fs[$i] == "")
        {
            $ilist .= "$i***";
        }
    }

    $query = "UPDATE $userstable SET strSubscribedForums = '$ilist' WHERE strName = '$gfcookie[1]'";
    mysql_query( $query, $link ) or die ( "Error! : ".mysql_error() );
}


//split the list
$result=mysql_query("SELECT * FROM $userstable WHERE strName = '$gfcookie[1]'");
$num_rows = mysql_num_rows( $result );
while ( $a_row = mysql_fetch_object( $result ) )
{
    $nosub = explode("***", $a_row->strSubscribedForums);
}




print "<br><br><font face=\"$font\" size=$fontsize>If there are any forums displayed that you do not wish to see, uncheck the box next to them.<br>
You can see them again by checking the box.<br>
When you have finished, click on the 'Update My Settings' button below.<br><br>
<a href=\"editprofile.php\">Back to my profile</a>.<br><br>

<table border=1 cellpadding=2 cellspacing=0 style=\"border-collapse: collapse\" bordercolor=#111111 width=\"85%\" bgcolor=$fgcolour>
<tr><td width=100%><font face=$font size=4>&nbsp;<b>$grimforumname</td></tr></table>

<table border=1 cellpadding=2 cellspacing=0 style=\"border-collapse: collapse\" bordercolor=#111111 width=\"85%\" bgcolor=$fgcolour>
<form method=\"post\" action=\"forumsub.php?action=change\">
";

$result=mysql_query("SELECT * FROM $grouptable");
$num = mysql_num_rows( $result );
print "<input type=\"hidden\" value=\"$num\" name=\"num\">";

$result = mysql_query( "SELECT * FROM $grouptable WHERE ynGroupMaster = '1' ORDER BY intGroupOrder" );
$num_rows = mysql_num_rows( $result );

//Dispay records
while ( $a_row = mysql_fetch_object( $result ) )
{
    $skip = 0;
    $subskip = 0;
    for ($i = 0; $i <= $num; $i++)
    {
        if ($nosub[$i] == $a_row->intId)
        {
            $skip = 1;
            $subskip = 1;
            break;
        }
    }
    print "<tr><td width=\"20%\"><font face=$font size=2>";
    if ($skip == 1)
    {
        print "<font color=\"$swearcolor\">";
    }
    print "&nbsp;
    $a_row->strName</td><td width=\"3%\">";
    if ($skip == 1)
    {
        print "<input type=\"checkbox\" name=\"fs[$a_row->intId]\" value=1>";
    }
    else
    {
        print "<input type=\"checkbox\" checked name=\"fs[$a_row->intId]\" value=1>";
    }

    print "</td><td>&nbsp;</td></tr>";
    $groupid = $a_row->intGroupId;

    $resultb = mysql_query( "SELECT * FROM $grouptable WHERE ynGroupMaster = '0' AND intGroupId = '$groupid' ORDER BY strName" );
    $num_rowsb = mysql_num_rows( $resultb );
    while ( $b_row = mysql_fetch_object( $resultb ) )
    {
        $skip = 0;
        for ($i = 0; $i <= $num; $i++)
        {
            if ($nosub[$i] == $b_row->intId)
            {
                $skip = 1;
                break;
            }
        }
        if ($subskip == 1)
        {
            $skip = 1;
        }
        print "<tr bgcolor=\"$bgcolour\"><td width=\"20%\"><font face=$font size=2>";

        if ($skip == 1)
        {
            print "<font color=\"$swearcolor\">";
        }


        print "&nbsp;
        $b_row->strName</td><td width=\"3%\">";
        if ($skip == 1)
        {
            print "<input type=\"checkbox\" name=\"fs[$b_row->intId]\" value=1>";
        }
        else
        {
            print "<input type=\"checkbox\" checked name=\"fs[$b_row->intId]\" value=1>";
        }

        print "</td><td><font face=$font size=$fontsize color=\"$fontcolor\">
        &nbsp;$b_row->strComments</td></tr>";
    }
}
print "</table><br><input type=\"submit\" value=\"Update My Settings\"></form>";

include ("inc/inc_footer.php");