<?php
defined('GCMS') or die('ОШИБКА!');
$time = time() - 300; //5 мин
$time_us = time() - 400; // 6 минут 40 секунд
$db -> query("DELETE FROM `online` WHERE `time` < '".$time."' and `login` <> ''");	//удаляем из онлайна пользователей
$db -> query("DELETE FROM `online` WHERE `time` < '".$time_us."' and `login` = ''");	//удаляем из онлайна гостей
if ($aut) {
$sql = $db -> query("SELECT `login` FROM `online` WHERE `login` = '".$ya['login']."' LIMIT 1");
if ($sql -> num_rows > 0) {
$db -> query("UPDATE `online` SET `session` = '".SID."', `ip` = '".$ip."', `browser` = '".$browser."', `time` = '".time()."' WHERE `login` = '".$ya['login']."' LIMIT 1");
} else {
$db -> query("DELETE FROM `online` WHERE `session` = '".SID."'");
$db -> query("INSERT INTO `online` SET `login` = '".$ya['login']."', `session` = '".SID."',`ip` = '".$ip."', `browser` = '".$browser."', `time` = '".time()."'");
}
} else {
$sql = $db -> query("SELECT `ip` FROM `online` WHERE `session` = '".SID."' LIMIT 1");
if ($sql -> num_rows > 0) {
$db -> query("UPDATE `online` SET `ip` = '".$ip."',`browser` = '".$browser."', `time` = '".time()."' WHERE `session` = '".SID."' LIMIT 1");
} else {
$count = $db -> dbcount('COUNT(*)','online',"`ip` = '".$ip."'");
if($count==0 or $count==null){
$db -> query("INSERT INTO `online` SET `session` = '".SID."',`ip` = '".$ip."', `browser` = '".$browser."', `time` = '".time()."'");}
}
}
unset($sql);
?>