From 4f71820014dcafbe2e344b7b6c97cccc2f01f5b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Wed, 3 Feb 2010 20:52:26 +0000 Subject: Ticket #260. Prevent some errors from happening. --- .../openvpn-client-export/vpn_openvpn_export.php | 58 +++++++++++++--------- 1 file 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"); -- cgit v1.2.3