diff options
author | Ermal Luçi <eri@pfsense.org> | 2010-02-03 20:52:26 +0000 |
---|---|---|
committer | Ermal Luçi <eri@pfsense.org> | 2010-02-03 20:52:26 +0000 |
commit | 4f71820014dcafbe2e344b7b6c97cccc2f01f5b9 (patch) | |
tree | df9460211d9fbe96a14e5c1418aa5ad4b8c952c1 /config | |
parent | e55530fd09ffa4d405adc80ea125af41cee94092 (diff) | |
download | pfsense-packages-4f71820014dcafbe2e344b7b6c97cccc2f01f5b9.tar.gz pfsense-packages-4f71820014dcafbe2e344b7b6c97cccc2f01f5b9.tar.bz2 pfsense-packages-4f71820014dcafbe2e344b7b6c97cccc2f01f5b9.zip |
Ticket #260. Prevent some errors from happening.
Diffstat (limited to 'config')
-rwxr-xr-x | config/openvpn-client-export/vpn_openvpn_export.php | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/config/openvpn-client-export/vpn_openvpn_export.php b/config/openvpn-client-export/vpn_openvpn_export.php index 1f10716a..f9eca667 100755 --- a/config/openvpn-client-export/vpn_openvpn_export.php +++ b/config/openvpn-client-export/vpn_openvpn_export.php @@ -101,13 +101,17 @@ if($act == "conf") { $exp_name = openvpn_client_export_prefix($srvid); $exp_name = urlencode($exp_name."-config.ovpn"); $exp_data = openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoken); - $exp_size = strlen($exp_data); - - header("Content-Type: application/octet-stream"); - header("Content-Disposition: attachment; filename={$exp_name}"); - header("Content-Length: $exp_size"); - echo $exp_data; - exit; + if (!$exp_data) + $input_errors[] = "Failed to export config files!"; + else { + $exp_size = strlen($exp_data); + + header("Content-Type: application/octet-stream"); + header("Content-Disposition: attachment; filename={$exp_name}"); + header("Content-Length: $exp_size"); + echo $exp_data; + exit; + } } if($act == "visc") { @@ -127,14 +131,18 @@ if($act == "visc") { $exp_name = openvpn_client_export_prefix($srvid); $exp_name = urlencode($exp_name."-Viscosity.visc.zip"); $exp_path = viscosity_openvpn_client_config_exporter($srvid, $usrid, $crtid, $useaddr, $usetoken, $password); - $exp_size = filesize($exp_path); - - header("Content-Type: application/octet-stream"); - header("Content-Disposition: attachment; filename={$exp_name}"); - header("Content-Length: $exp_size"); - readfile($exp_path); - //unlink($exp_path); - exit; + if (!$exp_path) + $input_errors[] = "Failed to export config files!"; + else { + $exp_size = filesize($exp_path); + + header("Content-Type: application/octet-stream"); + header("Content-Disposition: attachment; filename={$exp_name}"); + header("Content-Length: $exp_size"); + readfile($exp_path); + //unlink($exp_path); + exit; + } } if($act == "inst") { @@ -154,14 +162,18 @@ if($act == "inst") { $exp_name = openvpn_client_export_prefix($srvid); $exp_name = urlencode($exp_name."-install.exe"); $exp_path = openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $usetoken, $password); - $exp_size = filesize($exp_path); - - header("Content-Type: application/octet-stream"); - header("Content-Disposition: attachment; filename={$exp_name}"); - header("Content-Length: $exp_size"); - readfile($exp_path); - unlink($exp_path); - exit; + if (!$exp_path) + $input_errors[] = "Failed to export config files!"; + else { + $exp_size = filesize($exp_path); + + header("Content-Type: application/octet-stream"); + header("Content-Disposition: attachment; filename={$exp_name}"); + header("Content-Length: $exp_size"); + readfile($exp_path); + unlink($exp_path); + exit; + } } include("head.inc"); |