summaryrefslogtreecommitdiffstats
path: root/usr/local/www/progress.php
blob: 0a6b50d0e14c77bc6032778eeef763429455d92e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php

/* $Id$ */

include("guiconfig.inc");

if($config['theme'] <> "")
	$g['theme'] = $config['theme'];
else
	$g['theme'] = "pfsense";

$url = 'progress.php?UPLOAD_IDENTIFIER='.  $_GET["UPLOAD_IDENTIFIER"] .'&e=1';

function nice_value($x) {
   if ($x < 100)    return $x;
   if ($x < 10000)  return sprintf("%.2fKB", $x/1000);
   if ($x < 900000) return sprintf("%dKB", $x/1000);
   return sprintf("%.2fMB", $x/1000/1000);
}

$X = upload_progress_meter_get_info( $_GET["UPLOAD_IDENTIFIER"] );
if (!$X) {

   if ( array_key_exists( "e", $_GET ) ) {
      echo "<HTML><BODY onLoad='window.close();'>" . gettext("Invalid Meter ID") . "! {$_GET["UPLOAD_IDENTIFIER"]}";
      echo ('</BODY></HTML>');
   }else{
      echo ('<HTML><meta HTTP-EQUIV="Refresh" CONTENT="1; url='. $url .'"><BODY></BODY></HTML>');
   }
   exit;

} else {

   $meter = sprintf("%.2f", $X['bytes_uploaded'] / $X['bytes_total'] * 100);

   $sp = $X['speed_last'];
   if ($sp < 10000) $speed  = sprintf("%.2f", $sp / 1000);
   else $speed  = sprintf("%d", $sp / 1000);

   $eta = sprintf("%02d:%02d", $X['est_sec'] / 60, $X['est_sec'] % 60 );

   $upl   = nice_value($X['bytes_uploaded']);
   $total = nice_value($X['bytes_total']);

   if ($X['bytes_total'] > 1 && $X['bytes_uploaded'] >= $X['bytes_total'] && $X['est_sec'] == 0) {
      echo ('<HTML><BODY onLoad="window.close()"> ' . gettext("UPLOAD completed") . '!</BODY></HTML>');
      exit;
   }
}

?>

<HTML>
<HEAD>

<meta HTTP-EQUIV="Refresh" CONTENT="1; url=<?=$url?>">

<TITLE><?=gettext("Uploading Files... Please wait..."); ?></TITLE>

<style type='text/css'> td {font-size: 10pt }</style>

</HEAD>
<BODY BGCOLOR="#FFFFFF">

<table height="100%" width="100%" cellPadding="4" cellSpacing="4" style="border:1px solid #990000;">
<tr><td>

   <font face="arial"><b><center><?=gettext("Uploading files...");?></b></center>

   <br>

   <table width="100%" height="15" colspacing="0" cellpadding="0" cellspacing="0" border="0" align="top" nowrap>
	<td width="5" height="15" background="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" align="top"></td>
	<td>
		<table WIDTH="100%" height="15" colspacing="0" cellpadding="0" cellspacing="0" border="0" align="top" nowrap>
			<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif"><?php echo("<img src='./themes/".$g['theme']."/images/misc/bar_blue.gif' height='15' WIDTH='$meter%'>");?></td>
		</table>

	</td>
	<td width="5" height="15" background="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" align="top"></td>
   </table>

   <br>

   <TABLE WIDTH="100%">
   <tr>
   <td align="right"><font face="arial"><b><?=gettext("Time Remaining:");?></td><td><font face="arial"><?=$eta?></td>
   <td align="right"><font face="arial"><b><?=gettext("Speed:");?></td><td><font face="arial"><font face="arial"><?=$speed?><?=gettext("KB/sec");?></td>
   </tr>

   <tr>
   <td align="right"><font face="arial"><b><?=gettext("Uploaded:");?></td><td><font face="arial"><?=$upl?></td>
   <td align="right"><font face="arial"><b><?=gettext("File Size:");?></td><td><font face="arial"><?=$total?></td>
   </tr>

   <tr>
   <td align="right"><font face="arial"><b><?=gettext("Completed:");?></td><td><font face="arial"><?=$meter?>%</td>
   <td align="right"><font face="arial"><b></td><td><font face="arial"></td>
   </tr>

</td></tr>
</table>

</BODY>
</HTML>
OpenPOWER on IntegriCloud