All pastes #246830 Raw Edit

Something

public php v1 · immutable
#246830 ·published 2006-11-12 19:18 UTC
rendered paste body
<?phperror_reporting(E_ALL);	$bar_height = 15;	$bar_spacing = 5;	$grid_space = 50;	$bar_title_space = 70;	$graph_title = "WorxReferral Url Click Tracking.";	$graph_title_space = 20;	$graph_footer = "Powered by: <a href='http://worxtech.com'>WorxTech</a>";	$graph_footer_space = 20;// 0=red, 1=green, 2=blue, 3=random	$bar_colour = 0;session_start();header("Content-type: image/jpg");$amounts = $_SESSION['amounts'];asort($amounts);$pic_width = $bar_title_space+max($amounts)+($grid_space*1.5);$pic_height = ($bar_height+$bar_spacing+2)*sizeof($amounts)+20+$graph_title_space+$graph_footer_space;$pic = ImageCreate($pic_width+1,$pic_height+1);$white = ImageColorAllocate($pic,255,255,255);$grey  = ImageColorAllocate($pic,200,200,200);$lt_grey  = ImageColorAllocate($pic,210,210,210);$black = ImageColorAllocate($pic,0,0,0);ImageFilledRectangle($pic,0,0,$pic_width,$pic_height,$white);ImageString($pic,5,($pic_width/2)-(strlen($graph_title)*5),0,$graph_title,$black);ImageString($pic, 2,($pic_width/2)-(strlen($graph_footer)*3),$pic_height-$graph_footer_space, $graph_footer, $grey);for($x_axis=$bar_title_space ; ($x_axis-$bar_title_space)<max($amounts)+$grid_space ; $x_axis+=$grid_space){	ImageLine($pic,$x_axis,$graph_title_space,$x_axis,$pic_height-$graph_footer_space,$grey);	ImageLine($pic,$x_axis,($pic_height-$graph_footer_space-25),$x_axis-($bar_title_space+$grid_space),($pic_height-$graph_footer_space-25),$grey);	ImageString($pic, 3, $x_axis+5, ($pic_height-$graph_footer_space-20), $x_axis-($bar_title_space), $black);}$y_axis=$graph_title_space;if($bar_colour!=3){	$col = 180;	$decrement = intval($col/count($amounts));}foreach($amounts as $key=>$amount){	ImageString($pic, 2, ($bar_title_space-(strlen($key)*6)), $y_axis, $key, $black);	if($bar_colour==3)	{		$tempCol = ImageColorAllocate($pic,rand(50,200),rand(50,200),rand(50,200));	} else {		$col -= $decrement;		if($bar_colour==0)		{			$tempCol = ImageColorAllocate($pic,255,$col,$col);		} else if($bar_colour==1)		{			$tempCol = ImageColorAllocate($pic,$col,200,$col);		} else if($bar_colour==2)		{			$tempCol = ImageColorAllocate($pic,$col,$col,255);		}	}	ImageFilledRectangle($pic,($bar_title_space+1),$y_axis,$amount+$bar_title_space,($y_axis+$bar_height),$tempCol);	if(($amount)<15)	{		ImageString($pic, 2, ($amount+3)+$bar_title_space, $y_axis, $amount, $black);	} else {		ImageString($pic, 2, ($amount-(strlen($amount)*6))+$bar_title_space, $y_axis, $amount, $white);	}	$y_axis+=($bar_spacing+1)+$bar_height;}ImageJPG($pic);ImageDestroy($pic);?>