diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2010-03-19 20:27:09 -0400 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2010-03-19 20:27:09 -0400 |
commit | 10189b2a112941b1e8fbb242856005b4b158e4d3 (patch) | |
tree | cf8652aca072c04b1e9425079ff272945571329e /etc | |
parent | 63e8a8abab53c61a1e81fc01c0b132caa1894915 (diff) | |
download | pfsense-10189b2a112941b1e8fbb242856005b4b158e4d3.zip pfsense-10189b2a112941b1e8fbb242856005b4b158e4d3.tar.gz |
Add unzip support if unzip binary exists
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/pfsense-utils.inc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 4774726..dbc128f 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -1719,6 +1719,8 @@ function update_alias_url_data() { /* if the item is tar gzipped then extract */ if(stristr($config['aliases']['alias'][$x]['aliasurl'], ".tgz")) process_alias_tgz($temp_filename); + if(stristr($config['aliases']['alias'][$x]['aliasurl'], ".zip")) + process_alias_unzip($temp_filename); if(file_exists("{$temp_filename}/aliases")) { $file_contents = file_get_contents("{$temp_filename}/aliases"); $file_contents = str_replace("#", "\n#", $file_contents); @@ -1754,7 +1756,26 @@ function update_alias_url_data() { unlock($lockkey); } +function process_alias_unzip($temp_filename) { + if(!file_exists("/usr/local/bin/unzip")) + return; + mwexec("/bin/mv {$temp_filename}/aliases {$temp_filename}/aliases.zip"); + mwexec("/usr/local/bin/unzip {$temp_filename}/aliases.tgz -d {$temp_filename}/aliases/"); + unlink("{$temp_filename}/aliases.zip"); + $files_to_process = return_dir_as_array("{$temp_filename}/"); + /* foreach through all extracted files and build up aliases file */ + $fd = fopen("{$temp_filename}/aliases", "w"); + foreach($files_to_process as $f2p) { + $file_contents = file_get_contents($f2p); + fwrite($fd, $file_contents); + unlink($f2p); + } + fclose($fd); +} + function process_alias_tgz($temp_filename) { + if(!file_exists("/usr/bin/tar")) + return; mwexec("/bin/mv {$temp_filename}/aliases {$temp_filename}/aliases.tgz"); mwexec("/usr/bin/tar xzf {$temp_filename}/aliases.tgz -C {$temp_filename}/aliases/"); unlink("{$temp_filename}/aliases.tgz"); |