summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2009-08-23 19:51:27 -0400
committerScott Ullrich <sullrich@pfsense.org>2009-08-23 19:51:27 -0400
commitb31da21e9ebfb1f1c78ad4e8d8418d23db43a817 (patch)
tree755e935d29b7f6b3db5c7bf925e90114db2928bd /usr
parent6f7a8f9917d35b0175ccb8d848b8eafc013aca51 (diff)
downloadpfsense-b31da21e9ebfb1f1c78ad4e8d8418d23db43a817.zip
pfsense-b31da21e9ebfb1f1c78ad4e8d8418d23db43a817.tar.gz
Move download_file_with_progress bar back to shared are where it belongs. These functions can be called from both console and the webConfigurator. Unbreaks pkg operations on bootup such as resinstall broken packages
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/www/guiconfig.inc65
1 files changed, 1 insertions, 64 deletions
diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc
index 5aed15a..1459a40 100755
--- a/usr/local/www/guiconfig.inc
+++ b/usr/local/www/guiconfig.inc
@@ -954,41 +954,6 @@ function update_progress_bar($percent) {
}
}
-function read_header($ch, $string) {
- global $file_size, $fout;
- $length = strlen($string);
- $regs = "";
- ereg("(Content-Length:) (.*)", $string, $regs);
- if($regs[2] <> "") {
- $file_size = intval($regs[2]);
- }
- ob_flush();
- return $length;
-}
-
-function read_body($ch, $string) {
- global $fout, $file_size, $downloaded, $sendto, $static_status, $static_output, $lastseen;
- $length = strlen($string);
- $downloaded += intval($length);
- $downloadProgress = round(100 * (1 - $downloaded / $file_size), 0);
- $downloadProgress = 100 - $downloadProgress;
- if($lastseen <> $downloadProgress and $downloadProgress < 101) {
- if($sendto == "status") {
- $tostatus = $static_status . $downloadProgress . "%";
- update_status($tostatus);
- } else {
- $tooutput = $static_output . $downloadProgress . "%";
- update_output_window($tooutput);
- }
- update_progress_bar($downloadProgress);
- $lastseen = $downloadProgress;
- }
- if($fout)
- fwrite($fout, $string);
- ob_flush();
- return $length;
-}
-
function rule_popup($src,$srcport,$dst,$dstport){
global $config;
$aliases_array = array();
@@ -1051,32 +1016,4 @@ function rule_popup($src,$srcport,$dst,$dstport){
}
}
-function download_file_with_progress_bar($url_file, $destination_file, $readbody = 'read_body') {
- global $ch, $fout, $file_size, $downloaded;
- $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, $readbody);
- curl_setopt($ch, CURLOPT_NOPROGRESS, '1');
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, '5');
- curl_setopt($ch, CURLOPT_TIMEOUT, 0);
-
- curl_exec($ch);
- $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- if($fout)
- fclose($fout);
- curl_close($ch);
- return ($http_code == 200) ? true : $http_code;
-}
-
-?>
+?> \ No newline at end of file
OpenPOWER on IntegriCloud