Oops. Oh well, I though anyone could answer things. Turns out, only
resarchers can. I guess that is what I get for not reading the FAQ
first.
Well some resarcher will have an easy time with this one :-)
Here is the code I was going to use :
<?php
/*
* php+gd dynamic progress bar demo script.
* copyright 2003, B. Johannessen <bob@db.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version, and provided that the above
* copyright and permission notice is included with all distributed
* copies of this or derived software.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* A copy of the GNU General Public License is available from the GNU
* website at the following URL: http://www.gnu.org/licenses/gpl.txt
*
*/
$width = $_REQUEST['width'];
$done = $_REQUEST['done'];
$total = $_REQUEST['total'];
$style = $_REQUEST['style'];
if($_SERVER['PATH_INFO'] == '/source') {
$source = str_replace(' ', ' ', htmlspecialchars(implode('',
file('progress.php'))));
$show = 'source';
}
else if($_SERVER['PATH_INFO'] == '/source-demo') {
$source = str_replace(' ', ' ', htmlspecialchars(implode('',
file('progress-demo.php'))));
$show = 'source';
}
else if(!$width && !$done && !$total && !$style) {
$show = 'form';
}
else if(!in_array($style, array('winxp', 'osx', 'led', 'solaris'))) {
$show = 'form';
}
else {
$uri = 'http://db.org/demo/progress.php?img=';
$uri .= $style . '/' . $width . '/' . $done . '/' . $total;
if($done > 0) {
$prev = 'http://db.org/demo/progress-demo.php?style=';
$prev .= $style . '&width=' . $width . '&done=' . ($done -
1) . '&total=' . $total;
}
if($total > $done) {
$next = 'http://db.org/demo/progress-demo.php?style=';
$next .= $style . '&width=' . $width . '&done=' . ($done +
1) . '&total=' . $total;
}
}
$title = 'PHP+GD Progress Bar Demo';
?>
<?php include('header.php'); ?>
<?php if($show == 'form') { ?>
<div class="metabox">
<h2>Help</h2>
<div class="metabox-content">
<p>
<b>Style</b>: The style of the resulting progress bar.
</p>
<p>
<b>Width</b>: The width of the progress bar image.
</p>
<p>
<b>Steps</b>: The number of steps from 0% to 100%.
</p>
</div>
</div>
<?php } ?>
<div class="metabox">
<h2>About</h2>
<div class="metabox-content">
<p>
This demo shows how to create dynamic progress bar images using
the <acronym title="PHP Hypertext Preprocessor">PHP</acronym>
<abbr title="GD Graphics Library">GD</abbr> functions.
To learn how it works, check out the
<a href="http://db.org/demo/progress-demo.php/source-demo"
title="PHP source code for the demo script">source for the demo</a>
and
<a href="http://db.org/demo/progress-demo.php/source"
title="PHP source code for the image generator">the source for the
script creating the images</a>.
</p>
<p>
If you want to use the script, you will need to download
<a href="http://db.org/downloads/fragments.tar.gz"
title="Archive containing the style fragments used in this demo">the
style fragments</a>
</p>
</div>
</div>
<?php include('middle.php'); ?>
<?php if($show == 'form') { ?>
<h2>Demo</h2>
<form method="get" action="http://db.org/demo/progress-demo.php">
<table>
<tr>
<td>
Style:
</td>
<td>
<select name="style">
<option value="winxp">Win XP</option>
<option value="osx">OSX</option>
<option value="led">LED</option>
<option value="solaris">Solaris</option>
</select>
</td>
</tr>
<tr>
<td>
Width:
</td>
<td>
<select name="width">
<option value="120">120</option>
<option value="240">240</option>
<option value="480">480</option>
<option value="640">640</option>
</select>
</td>
</tr>
<tr>
<td>
Steps:
</td>
<td>
<input type="text" name="total" value="12" size="4">
<input type="hidden" name="done" value="0">
<input type="submit" value="Start">
</td>
</tr>
</table>
</form>
<?php } else if($show == 'source-demo' || $show == 'source') { ?>
<h2>Source</h2>
<pre class="php-source"><?=$source?></pre>
<?php } else { ?>
<h2><?=$done?>/<?=$total?></h2>
<p>
<img src="<?=$uri?>" alt="Progress: <?=$done?>/<?=$total?>"/>
</p>
<p>
<?php if(isset($prev)) { ?>
[<a href="<?=$prev?>">prev</a>]
<?php } ?>
[<a href="http://db.org/demo/progress-demo.php">new</a>]
<?php if(isset($next)) { ?>
[<a href="<?=$next?>">next</a>]
<?php } ?>
</p>
<?php } ?>
<?php include('footer.php'); ?> |