diff options
Diffstat (limited to 'usr/local')
-rwxr-xr-x | usr/local/www/progress.php | 85 | ||||
-rwxr-xr-x | usr/local/www/system_firmware.php | 8 |
2 files changed, 92 insertions, 1 deletions
diff --git a/usr/local/www/progress.php b/usr/local/www/progress.php new file mode 100755 index 0000000..8826f4a --- /dev/null +++ b/usr/local/www/progress.php @@ -0,0 +1,85 @@ +#!/usr/local/bin/php + +<?php + +$url = 'progress.php?ulfile='. $_GET["ulfile"] .'&e=1'; + +function nice_value($x) { + if ($x < 100) $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["ulfile"] ); +if (!$X) { + + if ( array_key_exists( "e", $_GET ) ) { + echo ('<HTML><BODY onLoad="window.close()"> Invalid meter ID!</BODY></HTML>'); + }else{ + echo ('<HTML><meta HTTP-EQUIV="Refresh" CONTENT="1; url='. $url .'"><BODY></BODY></HTML>'); + } + +}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()"> UPLOAD completed!</BODY></HTML>'); + }else{ + +?> + +<HTML> +<HEAD> + +<meta HTTP-EQUIV="Refresh" CONTENT="1; url=<?=$url?>"> + +<TITLE>Uploading Files... Please wait ...</TITLE> + +<style type='text/css'> td {font-size: 10pt } td.uplmtr {font-size:6pt; height:12px}</style> + +</HEAD> +<BODY BGCOLOR="#C0C0C0"> + +Uploading files... + +<table border=1 WIDTH="100%" cellPadding=0 cellSpacing=0 style='BORDER-BOTTOM: 0px inset; BORDER-LEFT: 0px inset; BORDER-RIGHT: 0px inset; BORDER-TOP: 0px inset'> <tr><td> + <table border=0 WIDTH="100%" COLS="34"><tr> + + <? + + for ($i=0; $i<100; $i+=3) { + $color = ($i<$meter) ? " bgcolor='#00007F' " : ''; + $width = ($i+3<100) ? "3" : 100-$i; + echo("<td $color class='uplmtr' WIDTH='$width%'> </td>\n"); + } + ?> + +</tr></table> +</td></tr></table> + +<TABLE WIDTH=100%><TR><TD> +<?=$eta?> left (at <?=$speed?>KB/sec) +</TD><TD ALIGN=right> +<?=$upl?>/<?=$total?>(<?=$meter?>%) +</TD></TR><TR><TD> + +</TD></TR></TABLE> + +</BODY> +</HTML> + +<? } } ?> + + diff --git a/usr/local/www/system_firmware.php b/usr/local/www/system_firmware.php index d6afe94..7204047 100755 --- a/usr/local/www/system_firmware.php +++ b/usr/local/www/system_firmware.php @@ -170,6 +170,12 @@ if ($_POST && !file_exists($d_firmwarelock_path)) { else $fwinfo = "Using alternate firmware URL, cannot determine if {$config['system']['alt_firmware_url']['firmware_base_url']}{$config['system']['alt_firmware_url']['firmware_filename']} is newer than current."; } + +$id = rand() . '.' . time(); + +$mth = ini_get('upload_progress_meter.store_method'); +$dir = ini_get('upload_progress_meter.file.filename_template'); + ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> @@ -234,7 +240,7 @@ print_info_box($sig_warning); <br><br> <strong>Firmware image file: </strong> <input name="ulfile" type="file" class="formfld"> <br><br> - <input name="Submit" type="submit" class="formbtn" value="Upgrade firmware"> + <input name="Submit" type="submit" class="formbtn" value="Upgrade firmware" onClick="window.open('progress.php?ulfile=<?=$id?>','UploadMeter','width=370,height=115', true); return true; "> <?php endif; else: ?> <strong>You must reboot the system before you can upgrade the firmware.</strong> <?php endif; ?> |