Apache-AxKit-Plugin-Upload
view release on metacpan or search on metacpan
lib/Apache/AxKit/Plugin/Upload.pm view on Meta::CPAN
my ($start, $sizetotal, $file, $location, $nf, $custom, $running, $lock);
sub print_html {
my ($now, $sizedone) = @_;
my $elapsed = $now-$start;
my $todo = 0;
$todo = ($sizetotal - $sizedone) * $elapsed / $sizedone if $sizedone > 0;
my $percent = 0;
$percent = int($sizedone*100/$sizetotal) if $sizetotal > 0;
my $showpercent = ($percent?$percent:1);
#warn("printing: $percent");
my $speed = 0;
$speed = $nf->format_bytes($sizedone / $elapsed,1) if $elapsed > 0;
$sizedone = $nf->format_bytes($sizedone,1);
my $sizetotal = $nf->format_bytes($sizetotal,1);
$elapsed = sprintf("%i:%02i",int($elapsed/60),$elapsed%60);
$todo = sprintf("%i:%02i",int($todo/60),$todo%60);
local(*FH);
open(FH, ">$file.tmp") || warn("could not open $file.tmp: $!");
if (!$custom && $percent == 100) {
print FH << "EOF";
<html>
<head>
<title>Upload Status</title>
</head>
<body bgcolor="#ffffff" text="#000000">
<table border="0" width="264" cellspacing="0" cellpadding="1" style="table-layout: fixed;">
<tr>
<td width="40" height="24"><font face="sans-serif">$percent\%</font></td>
<td width="224" height="24" bgcolor="#000000"><table border="0" width="222" cellspacing="0" cellpadding="1" style="table-layout: fixed;" bgcolor="#ffffff">
<tr>
<td height="22"><table border="0" width="$showpercent\%" cellspacing="0" cellpadding="0" style="table-layout: fixed;">
<tr><td height="20" bgcolor="#000080"><font size="-7"> </font></td></tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td align="center"><font face="sans-serif" size="-1">$sizedone / $sizetotal, ${speed}b/s, $todo</font></td>
</tr>
</table>
lib/Apache/AxKit/Plugin/Upload.pm view on Meta::CPAN
} else {
print FH << "EOF";
<html>
<head>
<title>Upload Status</title>
<meta http-equiv="Refresh" CONTENT="1; URL=$location" />
</head>
<body bgcolor="#ffffff" text="#000000">
<table border="0" width="264" cellspacing="0" cellpadding="1" style="table-layout: fixed;">
<tr>
<td width="40" height="24"><font face="sans-serif">$percent\%</font></td>
<td width="224" height="24" bgcolor="#000000"><table border="0" width="222" cellspacing="0" cellpadding="1" style="table-layout: fixed;" bgcolor="#ffffff">
<tr>
<td height="22"><table border="0" width="$showpercent\%" cellspacing="0" cellpadding="0" style="table-layout: fixed;">
<tr><td height="20" bgcolor="#000080"><font size="-7"> </font></td></tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td align="center"><font face="sans-serif" size="-1">$sizedone / $sizetotal, ${speed}b/s, $todo</font></td>
</tr>
</table>
lib/Apache/AxKit/Plugin/Upload.pm view on Meta::CPAN
}
sub progress {
my ($done, $total, $message) = @_;
my $now = time();
my $elapsed = $now-$start;
my $todo = 0;
$todo = ($total - $done) * $elapsed / $done if $done > 0;
my $percent = 0;
$percent = int($done*100/$total) if $total > 0;
my $showpercent = ($percent?$percent:1);
$todo = sprintf("%i:%02i",int($todo/60),$todo%60);
local(*FH);
open(FH, ">$file.tmp") || warn("could not open $file.tmp: $!");
if ($percent == 100) {
print FH << "EOF";
<html>
<head>
<title>Upload Status</title>
</head>
<body bgcolor="#ffffff" text="#000000">
<table border="0" width="264" cellspacing="0" cellpadding="1" style="table-layout: fixed;">
<tr>
<td width="40" height="24"><font face="sans-serif" size="-1">$percent\%</font></td>
<td width="224" height="24" bgcolor="#000000"><table border="0" width="222" cellspacing="0" cellpadding="1" style="table-layout: fixed;" bgcolor="#ffffff">
<tr>
<td height="22"><table border="0" width="$showpercent\%" cellspacing="0" cellpadding="0" style="table-layout: fixed;">
<tr><td height="20" bgcolor="#000080"><font size="-7"> </font></td></tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td align="center"><font face="sans-serif" size="-1">$message</font></td>
</tr>
</table>
lib/Apache/AxKit/Plugin/Upload.pm view on Meta::CPAN
} else {
print FH << "EOF";
<html>
<head>
<title>Upload Status</title>
<meta http-equiv="Refresh" CONTENT="1; URL=$location" />
</head>
<body bgcolor="#ffffff" text="#000000">
<table border="0" width="264" cellspacing="0" cellpadding="1" style="table-layout: fixed;">
<tr>
<td width="40" height="24"><font face="sans-serif" size="-1">$percent\%</font></td>
<td width="224" height="24" bgcolor="#000000"><table border="0" width="222" cellspacing="0" cellpadding="1" style="table-layout: fixed;" bgcolor="#ffffff">
<tr>
<td height="22"><table border="0" width="$showpercent\%" cellspacing="0" cellpadding="0" style="table-layout: fixed;">
<tr><td height="20" bgcolor="#000080"><font size="-7"> </font></td></tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td align="center"><font face="sans-serif" size="-1">$message</font></td>
</tr>
</table>
( run in 0.598 second using v1.01-cache-2.11-cpan-10c994e2082 )