Файл: imstat.ru/image.php
Строк: 55
<?php
define('NTOP', 1);
require_once ('system/connect.php');
require_once ('system/core.php');
header("Content-type: image/gif");
$sait_t = mysql_query("SELECT * FROM `".$prefix."sait` WHERE `id` = '".$id."'");
$timeon = mysql_fetch_array(mysql_query("SELECT * FROM `".$prefix."stat`"));
if(mysql_num_rows($sait_t) == 1 && $timeon['update'] == 0){
$sait = mysql_fetch_array($sait_t);
$operator_id = mysql_query("SELECT `on` FROM `".$prefix."ip` WHERE INET_ATON('".$ip."') BETWEEN `min` AND `max`");
if(mysql_num_rows($operator_id) > 0){
$arr = mysql_fetch_array($operator_id);
$operator = $arr['on'];
}else{
$operator = 1000;
}
$isset = mysql_query("SELECT `id` FROM `".$prefix."hosts` WHERE `id_sait` = '".$sait['id']."' AND `ip` = '".$ip."'");
$ips = explode('.', $_SERVER['REMOTE_ADDR']);
$ipnum = $ips[3] + $ips[2] * 256 + $ips[1] * 256 * 256 + $ips[0] * 256 * 256 * 256;
$oper = mysql_result(mysql_query ("SELECT `on` FROM `ip` WHERE $ipnum BETWEEN `ip`.`min` AND `ip`.`max` LIMIT 1"),0);
if (mysql_num_rows($isset) == 0 && $oper == 1){
mysql_query("INSERT INTO `".$prefix."hosts` SET `time` = '".time()."', `id_sait` = '".$sait['id']."', `ip` = '".$ip."', `browser` = '".browser()."', `operator` = '".$operator."'");
mysql_query("INSERT INTO `".$prefix."hits` SET `time` = '".time()."', `id_sait` = '".$sait['id']."' ,`ip` = '".$ip."', `browser` = '".browser()."', `operator` = '".$operator."'");
mysql_query("UPDATE `".$prefix."sait` SET `hosts` = (`hosts` + 1), `hits` = (`hits` + 1) WHERE `id` = '".$sait['id']."'");
}else{
mysql_query("INSERT INTO `".$prefix."hits` SET `time` = '".time()."', `id_sait` = '".$sait['id']."' ,`ip` = '".$ip."',`browser` = '".browser()."', `operator` = '".$operator."'");
mysql_query("UPDATE `".$prefix."sait` SET `hits` = (`hits` + 1) WHERE `id` = '".$sait['id']."'");
}
$onlines = mysql_num_rows(mysql_query("SELECT `id` FROM `".$prefix."sait_online` WHERE `ip` = '".$ip."' AND `ua` = '".$ua."' AND `time` > '".(time()-500)."' AND `id_sait` = '".$sait['id']."'"));
if($onlines >= 1){
mysql_query("UPDATE `".$prefix."sait_online` SET `time` = '".time()."' WHERE `ip` = '".$ip."' AND `ua` = '".$ua."' AND `id_sait` = '".$sait['id']."'");
}else{
mysql_query("DELETE FROM `".$prefix."sait_online` WHERE `time` < '".(time()-500)."' AND `id_sait` = '".$sait['id']."'");
mysql_query("INSERT INTO `".$prefix."sait_online` SET `id_sait` = '".$sait['id']."', `ip` = '".$ip."', `ua` = '".$ua."', `time` = '".time()."'");
}}
if(empty($act)){
$img = 'images/stat/'.$sait['image'].'.gif';
$image = imagecreatefromgif($img);
$hits = 67 - (strlen($sait['hits']) * 5);
$hosts = 67 - (strlen($sait['hosts']) * 5);
$col = mysql_fetch_array(mysql_query("SELECT `color` FROM `".$prefix."images` WHERE `name` = '".$sait['image']."'"));
$black = imagecolorallocate($image, 0, 0, 0);
$color = imagecolorallocate($image, 0, 0, 0);
ImageString($image, 1, $hits, 13, $sait['hits'], $color);
ImageString($image, 1, $hosts, 4, $sait['hosts'], $color);
}elseif($act == 'on'){
$img = 'images/stat/'.$sait['on'].'.gif';
$image = imagecreatefromgif($img);
$onlines = mysql_num_rows(mysql_query("SELECT * FROM `".$prefix."sait_online` WHERE `id_sait` = '".$sait['id']."'"));
$online = 65 - (strlen($onlines) * 5);
$colorus = imagecolorallocate($image, 255, 0, 0);
ImageString($image,1,$online,4,$onlines,$colorus);
}elseif($act == 'small'){
$img = 'images/stat/'.$sait['small'].'.gif';
$image = imagecreatefromgif($img);
}
imagegif($image);
imageDestroy($image);
?>