<?php
$uname=bug($_COOKIE['login']);
$upass=bug($_COOKIE['pass']);
$udatam=mysql_query("SELECT * FROM `user` WHERE name='$uname' AND pass='$upass'");
if(mysql_num_rows($udatam)==1){$avt=1;};
$udata=mysql_fetch_assoc($udatam);
/////////////////////////////////Время в онлайне////////////////////////////////
$onlinelimit=time()-360;
////////////////////////Высчитываем время пользователя на сайте/////////////////
if($avt==1){
if($udata['lastvisit']>$onlinelimit){
@mysql_query("UPDATE `user` SET `onsait`=`onsait`+'".(time()-$udata['lastvisit'])."' WHERE `name`='".$udata['name']."'");
};
if(($udata['lastvisit']+999)<time()){
@mysql_query("UPDATE `user` SET `totalin`=`totalin`+1 WHERE `id`='".$udata['id']."'");
};
/////////////////////////Запись последнего посещения////////////////////////////
@mysql_query("UPDATE `user` SET `lastvisit`='".time()."'WHERE `name`='".$udata['name']."'");
};
///////////////////////Высчитываем онлайн зареганых юзеров//////////////////////
$onlinereg=mysql_result(mysql_query("SELECT count(*) FROM `user` WHERE `lastvisit`>'$onlinelimit'"),0);
////////////////////////////Определяем браузер и IP посетителя/////////////////
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']!='127.0.0.1' && ereg("^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$",$_SERVER['HTTP_X_FORWARDED_FOR'])) $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
elseif(isset($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP']!='127.0.0.1' && ereg("^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$",$_SERVER['HTTP_CLIENT_IP'])) $ip = $_SERVER['HTTP_CLIENT_IP'];
elseif(isset($_SERVER['REMOTE_ADDR']) && ereg("^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$",$_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR'];
else $ip = false;
if (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']))$brows=bug($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']);
elseif (isset($_SERVER['HTTP_USER_AGENT']))$brows=bug($_SERVER['HTTP_USER_AGENT']);
else $brows = false;
$brows=bug($brows);
//////////////////Высчитываем онлайн не зареганых посетителей///////////////////
mysql_query("DELETE FROM `online` WHERE `lastvisit`<'$onlinelimit'");
$q=mysql_result(mysql_query("SELECT count(*) FROM `online` WHERE `ip`='$ip' AND `brows`='$brows'"),0);
if(!empty($q)){
mysql_query("UPDATE `online` SET `lastvisit`='".time()."' WHERE `ip`='$ip' AND `brows`='$brows'");
}else{
mysql_query("INSERT INTO `online` (`ip`,`brows`,`lastvisit`)VALUES('$ip','$brows','".time()."')");
};
$onlineall=mysql_result(mysql_query("SELECT count(*) FROM `online`"),0);
/////////////////////Считываем настройки системы////////////////////////////////
$sysconf=mysql_query("SELECT * FROM `sysconf`");
$sysconf=mysql_fetch_assoc($sysconf);
//Бан по IP
$ipban=mysql_query("SELECT * FROM `banip` WHERE `ip`='$ip'");
if(mysql_num_rows($ipban)>0){header("Location: {$home}banip.php");exit;};
//Бан
mysql_query("DELETE FROM `ban` WHERE `date`<'".time()."'");
if($avt==1){
$inban=mysql_query("SELECT * FROM `ban` WHERE `type`='ban' AND`user`='".$udata['name']."'");
if(mysql_num_rows($inban)>0){header("Location: {$home}ban.php");exit;};
$inban=mysql_query("SELECT * FROM `ban` WHERE `type`='pred' AND `user`='".$udata['name']."'");
if(mysql_num_rows($inban)>=3){header("Location: {$home}ban.php");exit;};
};
?>