hi all,
plz help in dis,a php page is getting hi load on server. here is the code
plz help in dis,a php page is getting hi load on server. here is the code
PHP Code:
<?php
include("conf.php");
include("func.php");
Connect($dbserver,$dbname,$dbuser,$dbpass);
$dt=Date("Y-m-d");
$tdt=date("Y-m-d");
$lrd=mysql_fetch_array(mysql_query("SELECT text FROM misc where dscr='CLR'"));
$lrd=strtotime($lrd[0]);
$nrd=mktime(0,0,0,date("m",$lrd),date("d",$lrd)-2,date("Y",$lrd));
$ddt=date("Y-m-d",$nrd);
$sid = $_GET["sid"];
$ip = $_SERVER['REMOTE_ADDR'];
$sql = "SELECT * FROM sites where id='".$sid."' and banned='0';";
$sites = mysql_fetch_array(mysql_query($sql));
$date = date("Y-m-d");
// Check Unique IP in table visitor
$check_ip = mysql_fetch_row(mysql_query("SELECT ip FROM visitor WHERE ip='".$ip."' and date='".$date."' and sid='".$sid."'"));
if(empty($check_ip))
{
mysql_query("INSERT INTO visitor SET date='".$date."', ip='".$ip."', sid='".$sid."'");
$hosts = $sites[ur]+1;
mysql_query("UPDATE sites SET ur='".$hosts."' WHERE id='".$sid."'");
/* Update Total Hosts
$thost = $sites[thost]+1;
mysql_query("UPDATE sites SET thost='".$thost."' WHERE id='".$sid."'");
*/
}
//Update Today & Total Hists
$thits = $sites[9]+1;
$dhits = $sites[8]+1;
$res = mysql_query("UPDATE sites SET dhits='".$dhits."', thits='".$thits."' WHERE id='".$sid."'");
$week_day = date("w");
$today = date("Ymd");
// Today
$result1 = "SELECT ur FROM sites WHERE id='".$sid."' LIMIT 1;";
$result = mysql_query($result1);
$row = mysql_fetch_array($result);
$host_today = $row['ur'];
//--------------------- Place on top --------------------------
$result1 = "SELECT * FROM sites WHERE ur >= $host_today ORDER BY ur DESC;";
$result = mysql_query($result1);
$top_place = mysql_num_rows($result);
$total = "SELECT thits FROM sites WHERE id='".$sid."' LIMIT 1;";
// Online Users
$timestamp = time();
$timeout = $timestamp - 900;
$del_online = mysql_query("DELETE FROM online WHERE timestamp<$timeout");
$check_on = mysql_fetch_row(mysql_query("SELECT ip FROM online WHERE sid='".$sid."' and ip='".$ip."'"));
if(empty($check_on))
{
$insert = mysql_query("INSERT INTO online VALUES('".$sid."','".$timestamp."','".$ip."')");
}
else
{
$result = mysql_query("UPDATE online SET timestamp='".$timestamp." WHERE ip='".$ip."''");
}
$online = mysql_num_rows(mysql_query("SELECT * FROM online WHERE sid='".$sid."'"));
if($c=="" OR $c=="1")
{
Header("Content-Type: Image/GIF");
$image_file=ImageCreateFromGIF("images/count11.gif");
$font_color=ImageColorAllocate($image_file,128,64,0);
$fc=ImageColorAllocate($image_file,0,0,0);
$tfc=ImageColorAllocate($image_file,10,10,10);
$font_file="images/visitor2.ttf";
ImageTtfText($image_file,10,0,36,12,$font_color,$font_file,"HOST:");
ImageTtfText($image_file,10,0,36,20,$font_color,$font_file,"HITS:");
ImageTtfText($image_file,14,0,10,20,$fc,$font_file,"$top_place");
ImageTtfText($image_file,10,0,70,10,$fc,$font_file,"$host_today");
ImageTtfText($image_file,10,0,70,20,$fc,$font_file,"$dhits");
ImageTtfText($image_file,14,0,125,20,$fc,$font_file,"$online");
ImageGIF($image_file);
ImageDestroy($image_file);
exit;
}
elseif($c=="2")
{
Header("Content-Type: Image/GIF");
$image_file=ImageCreateFromGIF("images/count22.gif");
$font_color=ImageColorAllocate($image_file,128,64,0);
$fc=ImageColorAllocate($image_file,0,0,0);
$tfc=ImageColorAllocate($image_file,10,10,10);
$font_file="images/visitor2.ttf";
ImageTtfText($image_file,9,0,15,34,$fc,$font_file,"$top_place");
ImageTtfText($image_file,11,0,27,57,$font_color,$font_file,"ONLINE:");
ImageTtfText($image_file,10,0,22,45,$font_color,$font_file,"$host_today");
ImageTtfText($image_file,10,0,62,45,$fc,$font_file,"$dhits");
ImageTtfText($image_file,14,0,70,57,$fc,$font_file,"$online");
ImageGIF($image_file);
ImageDestroy($image_file);
exit;
}
elseif($c=="3")
{
Header("Content-Type: Image/GIF");
$image_file=ImageCreateFromGIF("images/count33.gif");
$font_color=ImageColorAllocate($image_file,128,64,0);
$fc=ImageColorAllocate($image_file,0,0,0);
$tfc=ImageColorAllocate($image_file,10,10,10);
$font_file="images/visitor2.ttf";
ImageTtfText($image_file,14,0,30,30,$fc,$font_file,"$online");
ImageGIF($image_file);
ImageDestroy($image_file);
exit;
}
mysql_close();
?>
Comment