note 35444 deleted from function.flush by sniper
| From: | sniper@php.net | Date: | Mon, 13 Oct 2003 01:34:36 +0000 |
| Subject: | note 35444 deleted from function.flush by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58451@lists.php.net to get a copy of this message | ||
Note Submitter: php@project2501.plus.com
----
a nice little script that produces a progress bar using the flush function, while creating a file of
fixed size, filled with random readable ascii characters
<!-- Clear msie buffer <?=str_repeat(":",500);?> -->
<style>
body{
font-family: courier;
size: 12px;
}
</style>
<?
ini_set("max_execution_time",3000000);
// don't let script timeout for a long time.
if(isset($amount))
{
echo "<br />Generating file of size: ".$amount." bytes";
if($amount>102400)
{
echo "<br />Estimated Processing Time: ~".(round($amount/102400)*3)."
seconds";
}
echo "<br /><br
/>↓0%.........................................100%↓<br />";
$handle = fopen("./file_$amount.dat","w");
$starttime = time();
for($i=0, $j=0 ; $i<$amount ; $i++, $j++)
{
if($j==round($amount/50))
{
echo '.';
flush();
$j=-1;
}
fwrite($handle,chr(rand(32,126)));
}
fclose($handle);
echo "<br /><br />file_$amount.dat created in ~".(time()-$starttime)."
seconds.";
}
?>
<br /><br />usage: <?=$PHP_SELF?>?amount=numberofbytes