Location: PHPKode > projects > Total ISP > total-isp/cvimage.php
<?
include "./auth.inc.php";

if (!$week)
	$week = 'week(now())';

$top=300;

$sql =  "select count(*), floor(Tstamp/300) as i,hour(Tstamp) as h, year(Tstamp) 
	FROM radacct 
	WHERE WeekNumber=$week 
	AND AcctStatusType='Stop' 
	GROUP BY i";

$res = mysql_query($sql);
$n = mysql_num_rows($res);

#find the top value
while ($row=mysql_fetch_row($res)){
	if ($row[0]>$topc)
		$topc = $row[0];
	
}


mysql_data_seek($res,0);

$img = imagecreate($n,$top+20);
$white = ImageColorAllocate($img, 255,255,255);
$red = ImageColorAllocate($img, 255,0,0);
$green = ImageColorAllocate($img,128,255,128);
$black = ImageColorAllocate($img,0,0,0);
$grey = ImageColorAllocate($img,128,128,128);

$previous = $top;
$mprevious = $top;

while ($row=mysql_fetch_row($res)){

	#hack for year 2000 hard coded - fixme
	if ($row[3] != 2000)
		break;

	$i++;
	$height = intval($top*$row[0]/$topc);
	imageline($img,$i,$top,$i,$top-$height,$green);
	
	$weekavg+=$row[0];
	$mavg+=$row[0];	

	if ($row[2] != $month){
		if ($row[2]==0){
			$tip=15;
		}elseif($row[2]==12){
			$tip=10;
		}else
			$tip=5;

                imageline($img,$i,$top,$i,$top+$tip,$black);
                $month=$row[2];
		
                $mheight=$top-intval(($mavg/30)*$top/$topc);

		imageline($img,$i-30,$mprevious,$i,$mheight,$grey);
                $mprevious=$mheight;
                $mavg=0;		

        }

	#if ($i%7 == 0){
	#	$wheight=$top-intval(($weekavg/7)*$top/$topc);
	#	imageline($img,$i-7,$previous,$i,$wheight,$red);
	#	$previous=$wheight;
	#	$weekavg=0;
	#}

}

imagegif($img,'cv.gif');
?>
<img src="cv.gif">
<BR>
Peak value is <? echo $topc ?>
<BR>
This data represents call Stop records, not the number of users online, and is sampled at 5 minute intervals.




Return current item: Total ISP