Просмотр файла clikus/config/online.php

Размер файла: 1.98Kb
<?php
//make for clikus.ru
//Admin icq 91531

$time = time() - 240;
mysql_query("DELETE FROM `".prefix."online` WHERE `time` < '$time' ");

If (!$_enter)
{
	//// Не юзер
	$user = '';
}
else
{
	$user = $_USER['login'];
}


$ip = empty($_SERVER['X_FORWARDED_FOR']) ? $_SERVER['REMOTE_ADDR'] : $_SERVER['X_FORWARDED_FOR'];
$brow = $_SERVER['HTTP_USER_AGENT'];

$uniq = sha1('['.$ip.']'.$brow); /// Уникальный ключь пользователя

if(!empty($user))
{
	$_q = mysql_query("SELECT `id`,`user` FROM `".prefix."online` WHERE `user`='$user' and `uniq`<>'$uniq' LIMIT 1");
	$_q = mysql_fetch_array($_q);
	
	if(!empty($_q['id']))
	{
		mysql_query("UPDATE `".prefix."online` SET `time`='".time()."',`user`='$user',`br`='$br',`uniq`='$uniq',`ip`='$ip' WHERE `id`='$_q[id]'");
	}
}


$q = mysql_query("SELECT `id`,`user` FROM `".prefix."online` WHERE `uniq`='$uniq' LIMIT 1");
$q = mysql_fetch_array($q);

$q_ip = mysql_query("SELECT `id`,`user` FROM `".prefix."online` WHERE `uniq`<>'$uniq' and `ip`='$ip' LIMIT 1");
$q_ip = mysql_fetch_array($q_ip);


		$br = explode("/",$_SERVER['HTTP_USER_AGENT']);
		$br = mysql_escape_string($br[0]);

	if(empty($q['id']) and empty($q_ip['id']))
	{
	//// Пользователя нет 
		if(!empty($_USER['admin']))
			$adm = 2;
		elseif(!empty($_USER['moder']))
			$adm = 1;
		else
			$adm = 0;
		
				
		mysql_query("INSERT INTO `".prefix."online` (`user`,`ip`,`uniq`,`time`,`br`,`adm`) 
		VALUES ('$user','$ip','$uniq','".time()."','$br','$adm')");
	}
	elseif(!empty($q_ip['id']))
	{
		mysql_query("UPDATE `".prefix."online` SET `time`='".time()."',`user`='$user',`br`='$br',`uniq`='$uniq' WHERE `id`='$q_ip[id]'");
	}
	else
	{
		mysql_query("UPDATE `".prefix."online` SET `time`='".time()."',`user`='$user' WHERE `id`='$q[id]'");
	}
	
$users  = mysql_fetch_array(mysql_query("SELECT count(`id`) FROM `".prefix."online` WHERE `user`<>''"));
$guests = mysql_fetch_array(mysql_query("SELECT count(`id`) FROM `".prefix."online` WHERE `user`=''"));