<?php
$cAdminLevel = 0; // Thanks to Cal Henderson for pointing out that I'd missed that line - oops!
$cCheck = $gfcookie[1];
$eCheck = $gfcookie[2];
$result = mysql_query("SELECT * FROM $userstable WHERE strName = '$cCheck' AND strEmail = '$eCheck'");
$num_rows = mysql_num_rows( $result );
$totalusers = $num_rows;
while ( $a_row = mysql_fetch_object( $result ) )
{
    $cAdminLevel = $a_row->intAdminLevel;
}

if (isset($groupid) AND $cAdminLevel < 2)
{
    $result = mysql_query("SELECT * FROM $userstable WHERE strName = '$cCheck' AND strEmail = '$eCheck'");
    $num_rows = mysql_num_rows( $result );
    $totalusers = $num_rows;
    while ( $a_row = mysql_fetch_object( $result ) )
    {
        $fmod = explode(",", $a_row->strForumsModerated);
        $count = 0;
        while ($count < 100)
        {
            if ($groupid == $fmod[$count])
            {
                $cAdminLevel = 2;
                break;
            }

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

if ($admin == 1 AND $cAdminLevel < 6)
{
    header("Location: ../index.php");
    exit;
}
if ($admin == 1 AND $cAdminLevel = "")
{
    header("Location: ../index.php");
    exit;
}
if ($admin == 2 AND $cAdminLevel < 6)
{
    header("Location: ../index.php");
    exit;
}
if ($admin == 2 AND $cAdminLevel = "")
{
    header("Location: ../index.php");
    exit;
}
?>