File size: 2.53Kb
<?
///////////////////////////
///by Kyber 2011
///Поддержка klybok.net
///ICQ 626-000-895
///Не для продажы!!!
///Потрачено 23 часа
///Реквизиты для помощи:
///R 191559143752
///Z 109983295073
///U 211922671748
///Изменять код скрипта ЗАПРЕЩЕНО!!!
///Нарушители получат блок хостинга
///////////////////////////
session_name('SID'); session_start();
$sess = session_id();
include_once 'CONFIG.php';
if(!($db=mysql_connect($mysql['host'], $mysql['user'],$mysql['pass']))) die('Database Error!!!');
if (!mysql_select_db($mysql['db'])) die('Database Error!!!');
mysql_query('set charset utf8',$db);
mysql_query('SET names utf8',$db);
mysql_query('set character_set_client="utf8"',$db);
mysql_query('set character_set_connection="utf8"',$db);
mysql_query('set character_set_result="utf8"',$db);
$SET = mysql_fetch_assoc(mysql_query("SELECT * FROM `set`"));
$time = time();
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && filter_var($_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP))
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
elseif (isset($_SERVER['REMOTE_ADDR']) && filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP)) $ip = $_SERVER['REMOTE_ADDR'];
else $ip = 'unk';
if (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])) {
$ua = htmlspecialchars(mysql_escape_string(trim($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])));
} elseif(isset($_SERVER['HTTP_USER_AGENT'])) {
$ua = htmlspecialchars(mysql_escape_string(trim($_SERVER['HTTP_USER_AGENT'])));
} else $ua = 'unk';
mysql_query("DELETE FROM `g` WHERE `time` < '".($time-600)."'");
if (isset($_SESSION['uid'])) {
$q = mysql_query("SELECT * FROM `users` WHERE `id` = '$_SESSION[uid]' LIMIT 1 ");
if (mysql_num_rows($q) != 0) {
$U = mysql_fetch_assoc($q);
mysql_query("UPDATE `users` SET `sess` = '$sess', `ip` = '$ip', `ua` = '$ua', `time` = '$time' WHERE `id` = '$U[id]'");
$mib = mysql_result(mysql_query("SELECT MAX(id) FROM `ban` WHERE `user` = '$U[id]'"), 0);
$ban = mysql_fetch_assoc(mysql_query("SELECT * FROM `ban` WHERE `id` = '$mib'"));
if ($time < $ban['t2']) {
if ($_SERVER['SCRIPT_NAME'] != '/ban.php') header('Location: '.H.'ban.php?');
}
}
}
if (!isset($U)) {
$q = mysql_query("SELECT `id` FROM `g` WHERE `sess` = '$sess' OR (`ip` = '$ip' AND `ua` = '$ua') ");
if ( mysql_num_rows($q) > 0) {
$id = mysql_result($q, 0);
mysql_query("UPDATE `g` SET `ua` = '$ua', `ip` = '$ip', `sess` = '$sess', `time` = '$time' WHERE `id` = '$id' LIMIT 1 " );
}
else mysql_query("INSERT INTO `g` (ua, ip, sess, time) VALUES ('$ua', '$ip', '$sess', '$time')");
}
?>