= 0; $x--) { //for($x = 0; $x < 15; $x++) { $todaystarted = mktime(0,0,0, date('n'), date('j')-$x-1, date('Y')); $yearpostfix = date('Y', $todaystarted); @$uniquehitsyesterday = mysql_result(mysql_query("SELECT SUM(hour0 + hour1 + hour2 + hour3 + hour4 + hour5 + hour6 + hour7 + hour8 + hour9 + hour10 + hour11 + hour12 + hour13 + hour14 + hour15 + hour16 + hour17 + hour18 + hour19 + hour20 + hour21 + hour22 + hour23) FROM uniquehits_".$yearpostfix." WHERE counterid = '$id' AND time = $todaystarted"), 0); if(empty($uniquehitsyesterday)) { $values[] = 0; } else { $values[] = $uniquehitsyesterday; $c++; } } $columns = count($values); $avage = array_sum($values) / $c; $width = 450; $height = 200; $padding = 2; $column_width = ($width / $columns); $im = imagecreate($width + 10, $height + 45); $gray = imagecolorallocate ($im, 255, 102, 0); $gray_dark = imagecolorallocate ($im, 130, 128, 154); $white = imagecolorallocate ($im, 255, 255, 255); imagefilledrectangle($im, 0, 0, $width + 10, $height + 45, $white); $maxv = 0; for($i=0; $i < $columns; $i++)$maxv = max($values[$i], $maxv); $daynames = array('Man', 'Tir', 'Ons', 'Tor', 'Fre', 'Lør', 'Søn'); $time = time() - 1382400; for($i = 0; $i < $columns; $i++) { $time = $time + 86400; $column_height = ($height / 100) * (( $values[$i] / $maxv) * 100); $x1 = $i * $column_width + 5; $y1 = $height - $column_height + 5; $x2 = (($i + 1) * $column_width) - $padding + 5; $y2 = $height + 5; imagefilledrectangle($im, $x1, $y1, $x2, $y2, $gray); putenv('GDFONTPATH=' . realpath('./includes/fonts/')); imageline($im, $x2, $y1, $x2, $y2, $gray_dark); $bbox = imagettfbbox(10, 0, 'visitor2.ttf', $values[$i]); $x = $x1 - ($bbox[2] / 2) + 15; imagettftext($im, 10, 0, $x, $y1 + 10, $white, 'visitor2.ttf', $values[$i]); $todaystarted = mktime(0, 0, 0, date('n'), date('j')-$i-1, date('Y')); $day = $daynames[date('N', $time)-1]; $bbox = imagettfbbox(10, 0, 'visitor2.ttf', $day); $x = $x1 - ($bbox[2] / 2) + 15; imagettftext($im, 10, 0, $x, 215, $gray_dark, 'visitor2.ttf', $day); $bbox = imagettfbbox(10, 0, 'visitor2.ttf', date("j", $time)); $x = $x1 - ($bbox[2] / 2) + 15; imagettftext($im, 10, 0, $x, 225, $gray_dark, 'visitor2.ttf', date("j", $time)); } $bbox = imagettfbbox(9, 0, 'verdana.ttf', html_entity_decode("©")." L i v e C o u n t e r . d k"); $x = $width - 3 - $bbox[2]; imagettftext($im, 9, 0, $x, 240, $gray_dark, 'verdana.ttf', html_entity_decode("©")." L i v e C o u n t e r . d k"); $sitequery = mysql_query("SELECT site FROM counters WHERE id = '$id' LIMIT 1") or die(mysql_error()); $siterow = mysql_fetch_assoc($sitequery); $str = str_split(toolong($siterow['site'], 20)); for($x = 0; $x < count($str); $x++)$site .= $str[$x].' '; imagettftext($im, 9, 0, 15, 240, $gray_dark, 'verdana.ttf', $site); $y = 205 - ($height / 100) * (($avage / $maxv) * 100); for($x = 0; $x < 460; $x++) { if($x%4 == 0)imageline($im, $x, $y, $x, $y, $gray_dark); } //header("Content-type: image/png"); imagepng($im, 'images/diagrams/'.$id.'.png'); imagedestroy($im); } header('Location: /images/diagrams/'.$id.'.png'); } } } ?>