From 67ac70d1cae637c7dd9b5781f2c0acd09a5f61dd Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 31 Jul 2015 19:13:49 +0200 Subject: vpn_openvpn_export_shared.php - developer style guide fixes --- .../vpn_openvpn_export_shared.php | 54 ++++++++++++++-------- 1 file changed, 35 insertions(+), 19 deletions(-) (limited to 'config/openvpn-client-export') diff --git a/config/openvpn-client-export/vpn_openvpn_export_shared.php b/config/openvpn-client-export/vpn_openvpn_export_shared.php index 26efc1ed..e961c1d1 100644 --- a/config/openvpn-client-export/vpn_openvpn_export_shared.php +++ b/config/openvpn-client-export/vpn_openvpn_export_shared.php @@ -1,9 +1,10 @@ $server) { - if (isset($server['disable'])) + if (isset($server['disable'])) { continue; + } $ras_user = array(); - if ($server['mode'] != "p2p_shared_key") + if ($server['mode'] != "p2p_shared_key") { continue; - + } $ras_serverent = array(); $prot = $server['protocol']; $port = $server['local_port']; - if ($server['description']) + if ($server['description']) { $name = "{$server['description']} {$prot}:{$port}"; - else + } + else { $name = "Shared Key Server {$prot}:{$port}"; + } $ras_serverent['index'] = $sindex; $ras_serverent['name'] = $name; $ras_serverent['mode'] = $server['mode']; @@ -63,12 +68,14 @@ foreach($a_server as $sindex => $server) { } $id = $_GET['id']; -if (isset($_POST['id'])) +if (isset($_POST['id'])) { $id = $_POST['id']; +} $act = $_GET['act']; -if (isset($_POST['act'])) +if (isset($_POST['act'])) { $act = $_POST['act']; +} $error = false; @@ -82,8 +89,9 @@ if(($act == "skconf") || ($act == "skzipconf")) { if (empty($_GET['useaddr'])) { $error = true; $input_errors[] = "You need to specify an IP or hostname."; - } else + } else { $useaddr = $_GET['useaddr']; + } $proxy = ""; if (!empty($_GET['proxy_addr']) || !empty($_GET['proxy_port'])) { @@ -91,32 +99,37 @@ if(($act == "skconf") || ($act == "skzipconf")) { if (empty($_GET['proxy_addr'])) { $error = true; $input_errors[] = "You need to specify an address for the proxy port."; - } else + } else { $proxy['ip'] = $_GET['proxy_addr']; + } if (empty($_GET['proxy_port'])) { $error = true; $input_errors[] = "You need to specify a port for the proxy ip."; - } else + } else { $proxy['port'] = $_GET['proxy_port']; + } $proxy['proxy_type'] = $_GET['proxy_type']; $proxy['proxy_authtype'] = $_GET['proxy_authtype']; if ($_GET['proxy_authtype'] != "none") { if (empty($_GET['proxy_user'])) { $error = true; $input_errors[] = "You need to specify a username with the proxy config."; - } else + } else { $proxy['user'] = $_GET['proxy_user']; + } if (!empty($_GET['proxy_user']) && empty($_GET['proxy_password'])) { $error = true; $input_errors[] = "You need to specify a password with the proxy user."; - } else + } else { $proxy['password'] = $_GET['proxy_password']; + } } } $exp_name = openvpn_client_export_prefix($srvid); - if ($act == "skzipconf") + if ($act == "skzipconf") { $zipconf = true; + } $exp_data = openvpn_client_export_sharedkey_config($srvid, $useaddr, $proxy, $zipconf); if (!$exp_data) { $input_errors[] = "Failed to export config files!"; @@ -136,10 +149,11 @@ if(($act == "skconf") || ($act == "skzipconf")) { header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename={$exp_name}"); header("Content-Length: $exp_size"); - if ($zipconf) + if ($zipconf) { readfile("{$g['tmp_path']}/{$exp_data}"); - else + } else { echo $exp_data; + } @unlink("{$g['tmp_path']}/{$exp_data}"); exit; @@ -276,10 +290,12 @@ function useproxy_changed(obj) { //]]> -- cgit v1.2.3