[b]Index.php[/b]
mysql_connect("localhost","********","********");
mysql_select_db("********");
$ipadr = $HTTP_SERVER_VARS["REMOTE_ADDR"];
$m_stat = mysql_query("SELECT COUNT(id) As aantal FROM `visits` WHERE ip = '$ipadr'") or die (mysql_error());
while($row = mysql_fetch_object($m_stat)){
$aantal = "$row->aantal";
$d = date("d");
$m = date("m");
$j = date("Y");
$u = date("h");
$min = date("i");
if($aantal > 0){ mysql_query("INSERT INTO `visits` ( `id` , `ip` , `dag` , `maand` , `jaar` , `uur` , `minuten`, `type` ) VALUES ('', '$ipadr', '$d', '$m', '$j', '$u', '$min', 'klik');") or die (mysql_error()); } else { mysql_query("INSERT INTO `visits` ( `id` , `ip` , `dag` , `maand` , `jaar` , `uur` , `minuten`, `type` ) VALUES ('', '$ipadr', '$d', '$m', '$j', '$u', '$min', 'uniek');") or die (mysql_error()); } }
?>
Statistieken [Dsound.nl / Barry Drooger]
" border="0" id="stats">
[b]stats.php[/b]
mysql_connect("localhost","********","********");
mysql_select_db("********");
$maand = $_GET['maand'];
$jaar = $_GET['jaar'];
$today_month = $maand;
if($today_month=="01"){ $maxday = 31; }
elseif($today_month=="02"){ $maxday = 28; }
elseif($today_month=="03"){ $maxday = 31; }
elseif($today_month=="04"){ $maxday = 30; }
elseif($today_month=="05"){ $maxday = 31; }
elseif($today_month=="06"){ $maxday = 30; }
elseif($today_month=="07"){ $maxday = 31; }
elseif($today_month=="08"){ $maxday = 31; }
elseif($today_month=="09"){ $maxday = 30; }
elseif($today_month=="10"){ $maxday = 31; }
elseif($today_month=="11"){ $maxday = 30; }
else { $maxday = 31; }
if($maand=="" || $jaar==""){ $width = 256; $height = 32; } else { $width = 800; $height = 384; }
$maxheight = $height - 20;
$grid = 15;
$aantal = $maxday;
$type = $_GET['type'];
if($type=="uniek"){ $sqlunique = "AND `type` = 'uniek'"; } else { $sqlunique = ""; }
for($a=1;$a<=$aantal;$a++){
if($a<=9) { $dag = "0" . $a; } else { $dag = $a; }
$mysql = mysql_query("SELECT * FROM `visits` WHERE dag = '$dag' AND jaar = '$jaar' AND maand = '$maand' $sqlunique") or die (mysql_error());
$hits = mysql_num_rows($mysql);
$statsday[$a] = $hits;
}
$totalstatsday = array_sum($statsday);
if($totalstatsday=="0"){
$width = 352; $height = 32;
$img = imagecreate($width, $height);
$bgcolor = imagecolorallocate($img,255,255,255);
$pcolor = imagecolorallocate($img,1,215,127);
$pcolor_u = imagecolorallocate($img,255,0,0);
$gridcolor = imagecolorallocate($img,191,191,223);
$txtcolor = imagecolorallocate($img,0,0,0);
imagestring($img,4, 16, 8, "Geen resultaten voor maand: $maand jaar: $jaar",$txtcolor);
imagerectangle($img, 0, 0, ($width-1), ($height-1), $txtcolor);
} else {
$img = imagecreate($width, $height);
$bgcolor = imagecolorallocate($img,255,255,255);
$pcolor = imagecolorallocate($img,1,215,127);
$pcolor_u = imagecolorallocate($img,255,0,0);
$gridcolor = imagecolorallocate($img,191,191,223);
$txtcolor = imagecolorallocate($img,0,0,0);
// Hieronder de code voor het maken van de grafiek... In principe hoeft hieronder niets veranderd te worden...
imagefilledrectangle($img, 0, 0, $width, $height,$bgcolor);
$gstep = ($width-30) / $aantal;
if($maand=="" || $jaar==""){ } else { //
if ($grid > 0) {
for ($v=30;$v<=$width;$v=$v+$gstep) {
imageline($img, $v, 0, $v, $maxheight, $gridcolor);
}
for ($h=0;$h<=$maxheight;$h=$h+$grid) {
imageline($img, 30, $h, $width, $h, $gridcolor);
}
}
$step = ($width-30) /$aantal;
$x = 30 - $gstep;
// Het aantal stappen verticaal berekenen
$max_pos = 0;
for ($i=0;$i