<?php
include ("inc/inc_common.php");
include ("inc/inc_connect.php");
include ("inc/inc_admincheck.php");

if ($cAdminLevel < 4)
{
    //kick out non-moderators...
    header("Location: topics.php?groupid=$groupid");
    exit;
}

//Here, we will read this users IP, add it to the ban list, then delete the user. First, find the IP.


$result = mysql_query( "SELECT * FROM $userstable WHERE strName = '$userid'" );
$num_rows = mysql_num_rows( $result );
while ( $a_row = mysql_fetch_object( $result ) )
{
    $iptoban = $a_row->strIp;
    $name = "IpBan$a_row->intId";
}



//Add the IP to $userstable and flag it as banned

$link = mysql_connect( "localhost", $user, $pass );
if ( ! $link )
   die( "Could not connect to MySQL" );
mysql_select_db( $db, $link )
   or die ( "Could not open $db: ".mysql_error() );

    $query = "INSERT INTO $userstable ( strName, strIp, ynBanIp ) values( '$name', '$iptoban', 'Yes')";

    mysql_query( $query, $link )
    or die ( "Could not add data to \"$forumtable\" table: "
    .mysql_error() );


//now, finally, delete the member. They must have been very naughty!

$query = "DELETE FROM $userstable WHERE strName = '$userid'";
mysql_query( $query, $link )
or die ( "Could not delete from \"$forumtable\" table: "
.mysql_error() );

header("Location: profile.php?userid=$userid");
exit;

?>