This is just a simple progress bar script I made with in 30 minutes in PHP.
It gets the value of the percentage from the URL via $_GET and if it is empty, not numeric or it is more than 100, it will set its default value to 100.
The script also writes the value of percentage slap-bang in the centre of the image.
I will post the script below, but you will need to manually save the images yourself, alternatively, you can download the full package by clicking here.
progressbar.php
PHP Code:
<?php
//fix headers
ob_start();
//create the image
$progress = imagecreate( 208, 28 );
//start the image
$start = imagecreatefrompng( "start.png" );
imagecopy( $progress, $start, 0, 0, 0, 0, imagesx( $start ), imagesy( $start ) );
//get value of percentage
$percent = strip_tags( $_GET['p'] );
if( ( empty( $percent ) ) || ( $percent > 100 ) || ( !is_numeric( $percent ) ) ) $percent = "100";
//put the middle image in
$middle = imagecreatefrompng( "middle.png" );
for( $i = 6; $i <= ( $percent * 2 ); $i++ )
{
imagecopy( $progress, $middle, $i, 0, 0, 0, imagesx( $middle ), imagesy( $middle ) );
}
//put the percentage value in text
$black = imagecolorallocate( $progress, 0, 0, 0 );
imagestring( $progress, 4, ( $i / 2 ) - 7, 6, $percent . "%", $black );
//end the image
$end = imagecreatefrompng( "end.png" );
imagecopy( $progress, $end, $i, 0, 0, 0, imagesx( $end ), imagesy( $end ) );
//output the image
header( "Content-Type: image/PNG" );
imagepng( $progress );
imagedestroy( $progress );
ob_flush();
?>
Save these images in the same directory as progessbar.php
start.png
http://www.mark-eriksson.com/projects/ProgressBar/start.png
middle.png
http://www.mark-eriksson.com/projects/ProgressBar/middle.png
end.png
http://www.mark-eriksson.com/projects/ProgressBar/end.png
I hope you enjoy this, if you use this please leave credits ;)
If you want to see a live demo to this, click here
The Password to the .RAR file is (as always)
Thanks,
- m0nsta.