<?

header("Cache-Control: no-cache");
if ($ver=="wml")header ("Content-type:text/vnd.wap.wml; charset=utf-8");
else header("Content-Type:text/html; charset=UTF-8");

require("inc.php");
$link = connect_db();
list($row, $id, $ps, $fsize1, $fsize2) = check_login($link);
require("version.php");

$us=$row["user"]; 

if($row["level"] < 5) {
if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>\n";
echo "<card id=\"error\" title=\"Ошибка доступа\">\n";
echo "<p align=\"center\">\n";
}else{
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";
echo "<title>Ошибка доступа</title>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
}
echo $fsize1;
echo "У вас нет прав доступа!\n";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close ($link);
exit;
}

require("function/bann-kick.php");
if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>\n";
if(!isset($rm)){
if ($row["level"]>6)echo "<card id=\"Ok\" title=\"Ok\" ontimer=\"apanel.php?$ses&amp;ref=$ref\"><timer value=\"10\" />\n";
else echo "<card id=\"Ok\" title=\"Ok\" ontimer=\"mpanel.php?$ses&amp;ref=$ref\"><timer value=\"10\" />\n";
} else {
echo "<card id=\"Ok\" title=\"Ok\" ontimer=\"chat.php?$ses&amp;rm=$rm&amp;ref=$ref\"><timer value=\"10\" />\n";
}
echo "<p align=\"center\">\n";    
}else{
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";
echo "<title>Ок</title>";
if(!isset($rm)){
if ($row["level"]>6) echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=apanel.php?$ses&amp;ref=$ref\">";
else echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=mpanel.php?$ses&amp;ref=$ref\">";
}else{
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=chat.php?$ses&amp;rm=$rm&amp;ref=$ref\">";
}
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
}
echo $fsize1;
if($level<$row["level"]){
echo "$bnik Забанен!<br/>\n";
if (!ctype_digit($pid)) {header("Location: index.php"); die;}
@mysql_query ("update users set banned = '1' where id ='".$pid."'"); 
$room="room".$rm;
@mysql_query("delete from $room WHERE usid = '".$pid."'"); 
$adm = @mysql_query ("Select user from users where id='1' LIMIT 1;");
$z = @mysql_fetch_array ($adm);
$administration = $z["user"];
$administration = check($administration);
$rnd = rand(0,99999999);
$today=date ("H:i");
$time = time();
$txt = "".$us." забанил юзера <b>".$bnik."</b> за нарушение Устава чата.";
mysql_query ("Insert into $room set klu4= '".$rnd."', time='".$today."', who='".$administration."', message='".$txt."', id='".$time."', towhom='', hid='0', usid='1', komu=''");
$data = date("(H:i jF)");
@$open=fopen("log/bannlist.dat","a+");
@flock ($open,LOCK_EX);
@fwrite($open,"#$bnik#room: $broom|$data|who: $us|$REMOTE_ADDR|$HTTP_USER_AGENT\n");
@fflush($open);
@flock ($open,LOCK_UN);
@fclose($open);
} else {
$levelselect = @mysql_query ("Select name from levels where level='".$level."'");
$levels = @mysql_fetch_array($levelselect);
$levname = $levels["name"];
echo "С ума сошли ".$levname."a банить!? $bnik вам это припомнит!\n";
}         
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close ($link);
?>