summaryrefslogtreecommitdiffstats
path: root/usr/local/www/system_firmware_auto.php
diff options
context:
space:
mode:
authorBill Marquette <billm@pfsense.org>2008-07-24 03:53:11 +0000
committerBill Marquette <billm@pfsense.org>2008-07-24 03:53:11 +0000
commit9140757d593279628f6e102cbd896fe7a708d494 (patch)
treef0070ebb0dfc4060d604f6e204e637e888c2487e /usr/local/www/system_firmware_auto.php
parent96e00c2ff57ee8edc17efd201c95380eadbb3ffe (diff)
downloadpfsense-9140757d593279628f6e102cbd896fe7a708d494.zip
pfsense-9140757d593279628f6e102cbd896fe7a708d494.tar.gz
DRY up the code a tad, download_file_with_progress_bar isn't related to
packages only anymore, move into pfsense-utils and allow for multiple file write functions (firmware upgrades use a different one than our standard)
Diffstat (limited to 'usr/local/www/system_firmware_auto.php')
-rwxr-xr-xusr/local/www/system_firmware_auto.php43
1 files changed, 3 insertions, 40 deletions
diff --git a/usr/local/www/system_firmware_auto.php b/usr/local/www/system_firmware_auto.php
index 87d8650..426232f 100755
--- a/usr/local/www/system_firmware_auto.php
+++ b/usr/local/www/system_firmware_auto.php
@@ -122,7 +122,7 @@ if($current_installed_pfsense_version <> $latest_version)
if($needs_system_upgrade == true) {
update_status("Downloading updates ...");
- $status = download_file_with_progress_bar("{$updater_url}/latest.tgz", "/tmp/latest.tgz");
+ $status = download_file_with_progress_bar("{$updater_url}/latest.tgz", "/tmp/latest.tgz", "read_body_firmware");
$status = download_file_with_progress_bar("{$updater_url}/latest.tgz.sha256", "/tmp/latest.tgz.sha256");
update_output_window("{$g['product_name']} download complete.");
}
@@ -176,44 +176,7 @@ if($downloaded_latest_tgz_sha256 <> $upgrade_latest_tgz_sha256) {
Helper functions
*/
-function download_file_with_progress_bar($url_file, $destination_file) {
- global $ch, $fout, $file_size, $downloaded, $counter;
- $file_size = 1;
- $downloaded = 1;
- /* open destination file */
- $fout = fopen($destination_file, "wb");
-
- /*
- Originally by Author: Keyvan Minoukadeh
- Modified by Scott Ullrich to return Content-Length size
- */
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url_file);
- curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'read_header');
- curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'read_body');
- curl_setopt($ch, CURLOPT_NOPROGRESS, '1');
-
- curl_exec($ch);
- fclose($fout);
- return 1;
-
- if ($error = curl_error($ch)) {
- return -1;
- }
-}
-
-function read_header($ch, $string) {
- global $file_size, $ch, $fout;
- $length = strlen($string);
- ereg("(Content-Length:) (.*)", $string, $regs);
- if($regs[2] <> "") {
- $file_size = intval($regs[2]);
- }
- return $length;
-}
-
-function read_body($ch, $string) {
+function read_body_firmware($ch, $string) {
global $fout, $file_size, $downloaded, $counter, $version, $latest_version, $current_installed_pfsense_version;
$length = strlen($string);
$downloaded += intval($length);
@@ -240,4 +203,4 @@ function read_body($ch, $string) {
return $length;
}
-?> \ No newline at end of file
+?>
OpenPOWER on IntegriCloud