| 
									
										
										
										
											2007-06-10 20:50:17 +00:00
										 |  |  | <?php  | 
					
						
							| 
									
										
										
										
											2007-11-21 14:26:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-15 17:58:15 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-21 14:26:24 +00:00
										 |  |  | if (isset($_GET["dir"])) { | 
					
						
							|  |  |  |   $dir = $_GET["dir"]; | 
					
						
							|  |  |  | } else { | 
					
						
							|  |  |  |   $dir = "h"; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (isset($_GET["width"])) { | 
					
						
							|  |  |  |   $length = $_GET["width"]; | 
					
						
							|  |  |  | } else { | 
					
						
							|  |  |  |   $length = 200; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (isset($_GET["per"])) { | 
					
						
							|  |  |  |   $percent = $_GET["per"]; | 
					
						
							|  |  |  | } else { | 
					
						
							|  |  |  |   $percent = 0; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //calculate length of percent full
 | 
					
						
							|  |  |  | $percentlength = round(($percent / 100) * $length); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //send headers
 | 
					
						
							|  |  |  | Header("Content-Type: image/png"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if ($dir == "v") { | 
					
						
							|  |  |  |   //create image
 | 
					
						
							|  |  |  |   $image = ImageCreate(6, $length); | 
					
						
							|  |  |  | } else { | 
					
						
							|  |  |  |   //dir == h
 | 
					
						
							|  |  |  |   //create image
 | 
					
						
							|  |  |  |   $image = ImageCreate($length, 6); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //Make colours
 | 
					
						
							|  |  |  | $grey = ImageColorAllocate($image, 200, 200, 200); | 
					
						
							|  |  |  | if($percent < '40') { | 
					
						
							|  |  |  | $colour = ImageColorAllocate($image, 0, 128, 0); | 
					
						
							|  |  |  | } elseif($percent < '70') { | 
					
						
							|  |  |  | $colour = ImageColorAllocate($image, 0, 0, 128); | 
					
						
							|  |  |  | } else { | 
					
						
							|  |  |  | $colour = ImageColorAllocate($image, 128, 0, 0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //Fill image with grey
 | 
					
						
							|  |  |  | ImageFill($image, 0, 0, $grey); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if ($dir == "v") { | 
					
						
							|  |  |  |   //create colour percent bar
 | 
					
						
							|  |  |  |   ImageFilledRectangle($image, 0, $length - $percentlength, 6, $length , $colour); | 
					
						
							|  |  |  | } else { | 
					
						
							|  |  |  |   //dir == h
 | 
					
						
							|  |  |  |   //create colour percent bar
 | 
					
						
							|  |  |  |   ImageFilledRectangle($image, 0, 0, $percentlength, 6, $colour); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //send picture to browser
 | 
					
						
							| 
									
										
										
										
											2007-11-23 11:37:28 +00:00
										 |  |  | $border = @imagecolorallocate($percent, 250, 250, 250); | 
					
						
							| 
									
										
										
										
											2007-11-21 14:26:24 +00:00
										 |  |  | imagerectangle($image, 0, 0, $length, 6, $border); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ImagePNG($image); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //clean up image as to not to crash the server
 | 
					
						
							|  |  |  | @imagedestroy($image); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-10 20:50:17 +00:00
										 |  |  | ?> 
 |