diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2008-11-24 03:12:07 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2008-11-24 03:12:07 +0000 |
commit | 8999038a6c5b85cd9efb1a6fbced532128ebf87a (patch) | |
tree | 921a0af82fd0d30853fdb7c1cd08308ba2624f5f /usr/local/www | |
parent | 660b5c0405662625d48201296cbf45ddccc52923 (diff) | |
download | pfsense-8999038a6c5b85cd9efb1a6fbced532128ebf87a.zip pfsense-8999038a6c5b85cd9efb1a6fbced532128ebf87a.tar.gz |
Switch back over to upload_progress_meter now that it is a freebsd port.
Diffstat (limited to 'usr/local/www')
-rwxr-xr-x | usr/local/www/system_firmware.php | 22 | ||||
-rw-r--r-- | usr/local/www/upload_progress.php | 111 |
2 files changed, 68 insertions, 65 deletions
diff --git a/usr/local/www/system_firmware.php b/usr/local/www/system_firmware.php index 1d07438..a6f6b20 100755 --- a/usr/local/www/system_firmware.php +++ b/usr/local/www/system_firmware.php @@ -46,11 +46,8 @@ $curcfg = $config['system']['firmware']; require_once("xmlrpc_client.inc"); /* Allow additional execution time 0 = no limit. */ -ini_set('max_execution_time', '3600'); -ini_set('max_input_time', '3600'); - -/* Construct an upload_id for this session */ -$upload_id = $_SERVER['REQUEST_TIME'] . $_SESSION['Username']; +ini_set('max_execution_time', '9999'); +ini_set('max_input_time', '9999'); /* if upgrade in progress, alert user */ if(file_exists($d_firmwarelock_path)) { @@ -212,13 +209,16 @@ print_info_box($sig_warning); <input name="Submit" type="submit" class="formbtn" value="Enable firmware upload"> </form> <?php else: ?> - <form action="system_firmware.php" method="post"> + <form id='sysfirmware' name='sysfirmware' action="system_firmware.php" method="post"> <input name="Submit" type="submit" class="formbtn" value="Disable firmware upload"> </form> - <br><br> - </form> - <form action="system_firmware.php" method="post" enctype="multipart/form-data"> - <input type="hidden" name="APC_UPLOAD_PROGRESS" value="<?=$upload_id?>" /> + <br> + <form id='sysupload' name='sysupload' action="system_firmware.php" method="post" enctype="multipart/form-data"> +<?php + /* Construct an upload_id for this session */ + $_SESSION['uploadid'] = uniqid(); +?> + <input type="hidden" name="UPLOAD_IDENTIFIER" value="<?=$_SESSION['uploadid']?>"> <strong>Firmware image file: </strong> <input name="ulfile" type="file" class="formfld"> <br><br> @@ -236,7 +236,7 @@ print_info_box($sig_warning); } } ?> - <input name="Submit" type="submit" class="formbtn" value="Upgrade firmware" onClick="window.open('progress.php?uploadid=<?=$upload_id?>','UploadMeter','width=370,height=115', true); return true;"> + <input name="Submit" type="submit" class="formbtn" value="Upgrade firmware" onClick="window.open('upload_progress.php','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; ?> diff --git a/usr/local/www/upload_progress.php b/usr/local/www/upload_progress.php index 8642a79..7df83ff 100644 --- a/usr/local/www/upload_progress.php +++ b/usr/local/www/upload_progress.php @@ -39,57 +39,28 @@ include("guiconfig.inc"); // sanitize the ID value -$id = $_REQUEST['uploadid']; -if (strlen($id) == 0) { - echo "Invalid uploadid#."; +$id = $_SESSION['uploadid']; +if (!$id) { + echo "Invalid upload id#."; exit; } -// ensure the uploaded status data exists in the session -if (!array_key_exists($id, $_SESSION[self::SESSION_KEY])) { - $_SESSION[self::SESSION_KEY][$id] = array( - 'id' => $id, - 'finished' => false, - 'percent' => 0, - 'total' => 0, - 'complete' => 0 - ); -} - -// retrieve the data from the session so it can be updated and returned -$ret = $_SESSION[self::SESSION_KEY][$id]; - // retrieve the upload data from APC -$status = apc_fetch('upload_' . $id); +$info = uploadprogress_get_info($id); // false is returned if the data isn't found -if ($status) { - $ret['finished'] = (bool) $status['done']; - $ret['total'] = $status['total']; - $ret['complete'] = $status['current']; - // calculate the completed percentage - if ($ret['total'] > 0) - $ret['percent'] = $ret['complete'] / $ret['total'] * 100; - // write the changed data back to the session - $_SESSION[self::SESSION_KEY][$id] = $ret; -} +if (!$info) { -if (!$ret) { - - if ( array_key_exists( "e", $_GET ) ) { - echo "<html><body onLoad='window.close();'>Invalid Meter ID! {$_REQUEST['uploadid]}"; - echo ('</body></html>'); - exit; - } else { - echo ('<html><meta http-equiv="Refresh" CONTENT="1; url=progress.php?uploadid={$id}"><body></body></html>'); - exit; - } + echo "Could not locate progress {$id}. Trying again..."; + echo "<html><meta http-equiv=\"Refresh\" CONTENT=\"1; url=upload_progress.php?uploadid={$id}\"><body></body></html>"; + exit; } else { - if ($ret['percent'] > "99") { + if (intval($info['percent']) > "99") { - echo ('<html><body onLoad="window.close()"> UPLOAD completed!</body></html>'); + //echo ('<html><body onLoad="window.close()"> UPLOAD completed!</body></html>'); + echo ('<html><body> UPLOAD completed!</body></html>'); } else { @@ -115,7 +86,10 @@ if (!$ret) { <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"> - <?echo("<img src='./themes/".$g['theme']."/images/misc/bar_blue.gif' height='15' WIDTH='$meter%'>");?> + <?php + $meter = sprintf("%.2f", $info['bytes_uploaded'] / $info['bytes_total'] * 100); + echo "<img src='./themes/{$g['theme']}/images/misc/bar_blue.gif' height='15' WIDTH='{$meter}%'>"; + ?> </td> </table> </td> @@ -124,20 +98,49 @@ if (!$ret) { <br> <table width="100%"> <tr> - <td align="right"><font face="arial"><b>Uploaded:</td> - <td><font face="arial"><?=$ret['finished']?></td> - <td align="right"><font face="arial"><b>File Size:</td> - <td><font face="arial"><?=$ret['total']?></td> + <td align="right"> + <font face="arial"><b>Uploaded: + </td> + <td> + <font face="arial"> + <?=$info['bytes_uploaded']?> + </td> + <td align="right"> + <font face="arial"> + <b>File Size: + </td> + <td> + <font face="arial"> + <?=$info['bytes_total']?> + </td> </tr> <tr> - <td align="right"><font face="arial"><b>Completed:</td> - <td><font face="arial"><?=$ret['complete']?>%</td> - <td align="right"><font face="arial"><b></td> - <td><font face="arial"></td> - </tr> - </table> - </td> - </tr> - </table> + <td align="right"> + <font face="arial"> + <b>Completed: + </td> + <td> + <font face="arial"> + <?=$info['bytes_total']-$info['bytes_uploaded']?>% + </td> + <td align="right"> + <font face="arial"><b> + Estimated: + </td> + <td> + <font face="arial"> + <?=$info['est_sec']?> + </td> + </tr> + </table> + </td> + </tr> +</table> </body> </html> + +<?php + +}} + +?> |