<?php
require_once 'inc/core.php'; //ядро
if(isset($id))
{
header("Content-type: image/gif");
$count = mysql_fetch_array(mysql_query("SELECT `hits`,`hosts`,`countType` FROM `site` WHERE `id` = '$id'"));
$typeCount = mysql_fetch_array(mysql_query("SELECT * FROM `countBase` WHERE `id` = '".$count['countType']."';"));
$img = 'img/count/'.$typeCount['name'].'.gif';
$old = mktime(0, 0, 0, strftime('%m'), strftime('%d'), strftime('%Y'));
$issetHost = mysql_query("SELECT `id` FROM `host` WHERE `refid` = '$id' AND `ip` = '$ip' AND `date` > '$old' ORDER BY `id` DESC LIMIT 1;");
if (mysql_num_rows($issetHost) == 0)
{
if ($id == $set['palevoSite'])
{
$kolPaleva2 = mysql_fetch_array(mysql_query("SELECT `id` FROM `palevo` ORDER BY `id` ASC LIMIT 1;"));
$kolPaleva = $kolPaleva2['id'];
$allPalevo = mysql_num_rows(mysql_query("SELECT `id` FROM `palevo` ORDER BY `id` ASC LIMIT 1;")) + $kolPaleva;
for ($i = 0; $i < $set['palevoSiteKol'];$i++)
{
$time = $realtime-rand(0,100);
$r = rand($kolPaleva,$allPalevo);
$palevoData = mysql_fetch_array(mysql_query("SELECT * FROM `palevo` WHERE `id` = '$r';"));
$randIp = rand(1,255).'.'.rand(1,255).'.'.rand(1,255).'.'.rand(1,255);
mysql_query("INSERT INTO `host` SET
`refid` = '$id',
`date` = '$time',
`ip` = '$randIp',
`agent` = '$palevoData[agent]',
`brovser` = '$palevoData[brovser]',
`os` = '$palevoData[os]';");
mysql_query("INSERT INTO `hits` SET
`refid` = '$randomSite',
`date` = '$time',
`ip` = '$randIp',
`agent` = '$palevoData[agent]',
`brovser` = '$palevoData[brovser]',
`os` = '$palevoData[os]';");
}
mysql_query("UPDATE `site` SET
`hits` = '".($count['hits']+($set['palevoSiteKol']+1))."',
`hosts` = '".($count['hosts']+($set['palevoSiteKol']+1))."' WHERE `id` = '$id';");
$image = imagecreatefromgif($img);
if ($typeCount['type'] == 0)
{
$color=imagecolorallocate($image,100,100,100); // задаем цвет
ImageString($image,1,7,14,($count['hosts']+($set['palevoSiteKol']+1)),$color);
ImageString($image,1,30,14,($count['hits']+($set['palevoSiteKol']+1)),$color);
}
} else
{
mysql_query("UPDATE `site` SET `hosts` = '".($count['hosts']+1)."' WHERE `id` = '$id';");
mysql_query("UPDATE `site` SET `hits` = '".($count['hits']+1)."' WHERE `id` = '$id';");
}
mysql_query("INSERT INTO `host` SET `date` = '$realtime',
`refid` = '$id',
`ip` = '$ip',
`agent` = '$agent',
`brovser` = '".(browser($agent,1))."',
`os` = '".(browser($agent,2))."';");
mysql_query("INSERT INTO `hits` SET `date` = '$realtime',
`refid` = '$id',
`ip` = '$ip',
`agent` = '$agent',
`brovser` = '".(browser($agent,1))."',
`os` = '".(browser($agent,2))."';");
$image = imagecreatefromgif($img);
if ($typeCount['type'] == 0)
{
$color=imagecolorallocate($image,100,100,100); // задаем цвет для
ImageString($image,1,7,14,($count['hosts']+1),$color);
ImageString($image,1,30,14,($count['hits']+1),$color);
}
}
else
{
if ($id == $set['palevoSite'])
{
$kolPaleva2 = mysql_fetch_array(mysql_query("SELECT `id` FROM `palevo` ORDER BY `id` ASC LIMIT 1;"));
$kolPaleva = $kolPaleva2['id'];
$allPalevo = mysql_num_rows(mysql_query("SELECT `id` FROM `palevo` ORDER BY `id` ASC LIMIT 1;")) + $kolPaleva;
for ($i = 0; $i < $set['palevoSiteKol'];$i++)
{
$time = $realtime-rand(0,100);
$r = rand($kolPaleva,$allPalevo);
$palevoData = mysql_fetch_array(mysql_query("SELECT * FROM `palevo` WHERE `id` = '$r';"));
$randIp = rand(1,255).'.'.rand(1,255).'.'.rand(1,255).'.'.rand(1,255);
mysql_query("INSERT INTO `hits` SET
`refid` = '$id',
`date` = '$time',
`ip` = '$randIp',
`agent` = '$palevoData[agent]',
`brovser` = '$palevoData[brovser]',
`os` = '$palevoData[os]'");
}
mysql_query("UPDATE `site` SET `hits` = '".($count['hits']+($set['palevoSiteKol']+1))."' WHERE `id` = '$id';");
$image = imagecreatefromgif($img);
if ($typeCount['type'] == 0)
{
$color=imagecolorallocate($image,100,100,100); // задаем цвет
ImageString($image,1,7,14,($count['hosts']),$color);
ImageString($image,1,30,14,($count['hits']+($set['palevoSiteKol']+1)),$color);
}
}
else mysql_query("UPDATE `site` SET `hits` = '".($count['hits']+1)."' WHERE `id` = '$id';");
mysql_query("INSERT INTO `hits` SET `date` = '$realtime',
`refid` = '$id',
`ip` = '$ip',
`agent` = '$agent',
`brovser` = '".(browser($agent,1))."',
`os` = '".(browser($agent,2))."';");
$array = mysql_fetch_array($issetHost);
$image = imagecreatefromgif($img);
if ($typeCount['type'] == 0)
{
$color=imagecolorallocate($image,100,100,100); // задаем цвет для
ImageString($image,1,7,14,$count['hosts'],$color);
ImageString($image,1,30,14,($count['hits']+1),$color);
}
}
imagegif($image);
imageDestroy($image);
}
?>