<?
/*
=====================================================
 Volkov NET!! - by SaNcHeS Group 
-----------------------------------------------------
 http://AllForCS.RU/
-----------------------------------------------------
 Copyright (c) 2009 SaNcHeS Group
=====================================================
 Данный код защищен авторскими правами
=====================================================
 Файл: ip.php
-----------------------------------------------------
 Назначение: Проверка IP
=====================================================
*/

include("./../inc/config.php");
include("./passwd.php");
include("./html.php");
include("./auth.php");


echo $STYLE."<table border='0' width='100%' height='100%'>
<tr>
<td>
<p align='center'>";

$user_ip = $_GET['ip'];

if ($_GET['event'] == 'unban'){
if ($user_ip == ""){$error.="<font color='#BF0000'>Не задан IP адрес.</font><br>";}else{
@$leet = @mysql_query("SELECT * FROM `m3_ban` WHERE `ip` = '".$user_ip."';") or die (mysql_error());
if ($error == ""){
@$leet = @mysql_query("DELETE FROM `m3_ban` WHERE `ip` = '".$user_ip."';") or die (mysql_error());
echo "IP адрес $user_ip<br>удален из бан листа.";}else{echo $error;}
}}

if ($_GET['event'] == 'ban'){
if ($user_ip == ""){$error.="<font color='#BF0000'>Не задан IP адрес.</font><br>";}else{
@$leet = @mysql_query("SELECT * FROM `m3_ban` WHERE `ip` = '".$user_ip."';") or die (mysql_error());
if ($leet && @mysql_num_rows($leet)>0){$error.="<font color='#BF0000'>IP $user_ip уже есть в бан листе.</font><br>";}}
if ($error == ""){
@$leet = @mysql_query("INSERT INTO `m3_ban` (ip) VALUES ('".$user_ip."');") or die (mysql_error());
echo "IP адрес $user_ip<br>внесен в бан лист.";}else{echo $error;}

}

if (!$_GET['event']){
$ip_number = sprintf("%u", ip2long($user_ip));
$result = mysql_query("SELECT * FROM ip_to_country WHERE ip_from <= '".$ip_number."' AND ip_to >= '".$ip_number."'") or die("Could not select");
$record = mysql_fetch_assoc($result);
$country_name = $record['country'];
echo "<img src='../m3_images/flags/".$record['c2'].".gif' align='absbottom' width='20' height='12' alt='$country_name' border=1> ";
echo "$country_name IP: <a href='http://www.nic.ru/whois/?ip=$user_ip' target='_blank'>$user_ip</a><br><br>";
echo "<a href='http://www.nic.ru/whois/?ip=$user_ip' target='_blank'>Whois</a><br>";
echo "<a href='ip.php?ip=$user_ip&event=ban'>Забанить</a><br>";
echo "<a href='ip.php?ip=$user_ip&event=unban'>Разбанить</a>";}

echo "</p></td></tr></table>".$FOOT;
@mysql_free_result();
@mysql_close();
?>