From c86c14dc50e2285e6e86eded0ae9e61fffac1550 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 17 Dec 2015 17:47:26 +0545 Subject: Code style v w --- src/usr/local/www/vpn_ipsec.php | 65 +++++++++++++++---------- src/usr/local/www/vpn_ipsec_keys.php | 22 +++++---- src/usr/local/www/vpn_ipsec_keys_edit.php | 3 +- src/usr/local/www/vpn_ipsec_mobile.php | 79 +++++++++++++++++++------------ src/usr/local/www/vpn_ipsec_phase1.php | 65 +++++++++++++++---------- src/usr/local/www/vpn_ipsec_phase2.php | 39 ++++++++------- src/usr/local/www/vpn_ipsec_settings.php | 12 +++-- src/usr/local/www/vpn_l2tp.php | 10 ++-- src/usr/local/www/vpn_l2tp_users.php | 19 ++++---- src/usr/local/www/vpn_l2tp_users_edit.php | 3 +- src/usr/local/www/vpn_openvpn_client.php | 26 +++++----- src/usr/local/www/vpn_openvpn_csc.php | 14 +++--- src/usr/local/www/vpn_openvpn_server.php | 53 +++++++++++---------- src/usr/local/www/wizard.php | 17 ++++--- 14 files changed, 251 insertions(+), 176 deletions(-) (limited to 'src/usr/local/www') diff --git a/src/usr/local/www/vpn_ipsec.php b/src/usr/local/www/vpn_ipsec.php index 9a81ab6..7a16888 100644 --- a/src/usr/local/www/vpn_ipsec.php +++ b/src/usr/local/www/vpn_ipsec.php @@ -314,10 +314,11 @@ display_top_tabs($tab_array); @@ -326,37 +327,42 @@ display_top_tabs($tab_array); $iflabels = get_configured_interface_with_descr(); $carplist = get_configured_carp_interface_list(); - foreach ($carplist as $cif => $carpip) + foreach ($carplist as $cif => $carpip) { $iflabels[$cif] = $carpip." (".get_vip_descr($carpip).")"; + } $aliaslist = get_configured_ip_aliases_list(); - foreach ($aliaslist as $aliasip => $aliasif) + foreach ($aliaslist as $aliasip => $aliasif) { $iflabels[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")"; + } $grouplist = return_gateway_groups_array(); foreach ($grouplist as $name => $group) { - if($group[0]['vip'] != "") + if ($group[0]['vip'] != "") { $vipif = $group[0]['vip']; - else + } else { $vipif = $group[0]['int']; + } $iflabels[$name] = "GW Group {$name}"; } $if = htmlspecialchars($iflabels[$ph1ent['interface']]); - } - else + } else { $if = "WAN"; + } - if (!isset($ph1ent['mobile'])) + if (!isset($ph1ent['mobile'])) { echo $if."
".$ph1ent['remote-gateway']; - else + } else { echo $if."
" . gettext("Mobile Client") . ""; + } ?> @@ -364,10 +370,11 @@ display_top_tabs($tab_array); @@ -393,10 +400,11 @@ display_top_tabs($tab_array);
> @@ -404,8 +412,9 @@ display_top_tabs($tab_array); $phase2count=0; foreach ($a_phase2 as $ph2ent) { - if ($ph2ent['ikeid'] != $ph1ent['ikeid']) + if ($ph2ent['ikeid'] != $ph1ent['ikeid']) { continue; + } $phase2count++; } $fr_prefix = "frp2{$i}"; @@ -431,8 +440,9 @@ display_top_tabs($tab_array); $ph2ent): ?> @@ -455,7 +465,7 @@ display_top_tabs($tab_array); - + @@ -471,14 +481,16 @@ display_top_tabs($tab_array); $ph2ea) { - if ($k) + if ($k) { echo ", "; + } echo $p2_ealgos[$ph2ea['name']]['name']; if ($ph2ea['keylen']) { - if ($ph2ea['keylen']=="auto") + if ($ph2ea['keylen'] == "auto") { echo " (" . gettext("auto") . ")"; - else + } else { echo " ({$ph2ea['keylen']} " . gettext("bits") . ")"; + } } } ?> @@ -487,8 +499,9 @@ display_top_tabs($tab_array); $ph2ha) { - if ($k) + if ($k) { echo ", "; + } echo $p2_halgos[$ph2ha]; } } @@ -570,13 +583,13 @@ events.push(function() { }); $('[id^=Xdel_]').click(function (event) { - if(confirm("")) { + if (confirm("")) { $('#' + event.target.id.slice(1)).click(); } }); $('[id^=Xdelp2_]').click(function (event) { - if(confirm("")) { + if (confirm("")) { $('#' + event.target.id.slice(1)).click(); } }); diff --git a/src/usr/local/www/vpn_ipsec_keys.php b/src/usr/local/www/vpn_ipsec_keys.php index 7dbd8e7..7fcd642 100644 --- a/src/usr/local/www/vpn_ipsec_keys.php +++ b/src/usr/local/www/vpn_ipsec_keys.php @@ -110,12 +110,13 @@ include("head.inc"); ?> " . gettext("You must apply the changes in order for them to take effect.")); - +} ?> @@ -173,10 +176,11 @@ if (is_subsystem_dirty('ipsec')) diff --git a/src/usr/local/www/vpn_ipsec_keys_edit.php b/src/usr/local/www/vpn_ipsec_keys_edit.php index 981e3a7..69478da 100644 --- a/src/usr/local/www/vpn_ipsec_keys_edit.php +++ b/src/usr/local/www/vpn_ipsec_keys_edit.php @@ -188,8 +188,7 @@ $section->addInput(new Form_Input( $pconfig['psk'] )); -if (isset($id) && $a_secret[$id]) -{ +if (isset($id) && $a_secret[$id]) { $form->addGlobal(new Form_Input( 'id', false, diff --git a/src/usr/local/www/vpn_ipsec_mobile.php b/src/usr/local/www/vpn_ipsec_mobile.php index 974e452..8543772 100644 --- a/src/usr/local/www/vpn_ipsec_mobile.php +++ b/src/usr/local/www/vpn_ipsec_mobile.php @@ -369,18 +369,20 @@ include("head.inc"); function dns_domain_change() { - if (document.iform.dns_domain_enable.checked) + if (document.iform.dns_domain_enable.checked) { document.iform.dns_domain.disabled = 0; - else + } else { document.iform.dns_domain.disabled = 1; + } } function dns_split_change() { - if (document.iform.dns_split_enable.checked) + if (document.iform.dns_split_enable.checked) { document.iform.dns_split.disabled = 0; - else + } else { document.iform.dns_split.disabled = 1; + } } function dns_server_change() { @@ -411,35 +413,43 @@ include("head.inc"); function pfs_group_change() { - if (document.iform.pfs_group_enable.checked) + if (document.iform.pfs_group_enable.checked) { document.iform.pfs_group.disabled = 0; - else + } else { document.iform.pfs_group.disabled = 1; + } } function login_banner_change() { - if (document.iform.login_banner_enable.checked) + if (document.iform.login_banner_enable.checked) { document.iform.login_banner.disabled = 0; - else + } else { document.iform.login_banner.disabled = 1; + } } //]]> " . gettext("You must apply the changes in order for them to take effect.")); -foreach ($a_phase1 as $ph1ent) - if (isset($ph1ent['mobile'])) +} +foreach ($a_phase1 as $ph1ent) { + if (isset($ph1ent['mobile'])) { $ph1found = true; -if ($pconfig['enable'] && !$ph1found) - print_info_box_np(gettext("Support for IPsec Mobile clients is enabled but a Phase1 definition was not found") . ".
" . gettext("Please click Create to define one."),gettext("create"),gettext("Create Phase1")); -if ($input_errors) + } +} +if ($pconfig['enable'] && !$ph1found) { + print_info_box_np(gettext("Support for IPsec Mobile clients is enabled but a Phase1 definition was not found") . ".
" . gettext("Please click Create to define one."), gettext("create"), gettext("Create Phase1")); +} +if ($input_errors) { print_input_errors($input_errors); +} $tab_array = array(); $tab_array[0] = array(gettext("Tunnels"), false, "vpn_ipsec.php"); @@ -464,8 +474,9 @@ $section = new Form_Section('Extended Authentication (Xauth)'); $authServers = array(); -foreach (auth_get_authserver_list() as $authServer) +foreach (auth_get_authserver_list() as $authServer) { $authServers[$authServer['name']] = $authServer['name']; // Value == name +} $section->addInput(new Form_Select( 'user_source', @@ -500,8 +511,9 @@ $section->addInput(new Form_Checkbox( $group = new Form_Group(''); $group->addClass('toggle-pool_enable collapse'); -if (!empty($pconfig['pool_enable'])) +if (!empty($pconfig['pool_enable'])) { $group->addClass('in'); +} $group->add(new Form_Input( 'pool_address', @@ -512,8 +524,9 @@ $group->add(new Form_Input( $netBits = array(); -for ($i = 32; $i >= 0; $i--) +for ($i = 32; $i >= 0; $i--) { $netBits[$i] = $i; +} $group->add(new Form_Select( 'pool_netbits', @@ -535,8 +548,9 @@ $section->addInput(new Form_Checkbox( $group = new Form_Group(''); $group->addClass('toggle-pool_enable_v6 collapse'); -if (!empty($pconfig['pool_enable_v6'])) +if (!empty($pconfig['pool_enable_v6'])) { $group->addClass('in'); +} $group->add(new Form_Input( 'pool_address_v6', @@ -547,8 +561,9 @@ $group->add(new Form_Input( $netBits = array(); -for ($i = 128; $i >= 0; $i--) +for ($i = 128; $i >= 0; $i--) { $netBitsv6[$i] = $i; +} $group->add(new Form_Select( 'pool_netbits_v6', @@ -583,8 +598,9 @@ $section->addInput(new Form_Checkbox( $group = new Form_Group(''); $group->addClass('toggle-dns_domain collapse'); -if (!empty($pconfig['dns_domain_enable'])) +if (!empty($pconfig['dns_domain_enable'])) { $group->addClass('in'); +} $group->add(new Form_Input( 'dns_domain', @@ -605,8 +621,9 @@ $section->addInput(new Form_Checkbox( $group = new Form_Group(''); $group->addClass('toggle-dns_split collapse'); -if (!empty($pconfig['dns_split_enable'])) +if (!empty($pconfig['dns_split_enable'])) { $group->addClass('in'); +} $group->add(new Form_Input( 'dns_split', @@ -624,13 +641,13 @@ $section->addInput(new Form_Checkbox( $pconfig['dns_server_enable'] ))->toggles('.toggle-dns_server_enable'); -for ($i = 1; $i <= 4; $i++) -{ +for ($i = 1; $i <= 4; $i++) { $group = new Form_Group('Server #' . $i); $group->addClass('toggle-dns_server_enable collapse'); - if (!empty($pconfig['dns_server_enable'])) + if (!empty($pconfig['dns_server_enable'])) { $group->addClass('in'); + } $group->add(new Form_Input( 'dns_server' . $i, @@ -649,13 +666,13 @@ $section->addInput(new Form_Checkbox( $pconfig['wins_server_enable'] ))->toggles('.toggle-wins_server_enable'); -for ($i = 1; $i <= 2; $i++) -{ +for ($i = 1; $i <= 2; $i++) { $group = new Form_Group('Server #' . $i); $group->addClass('toggle-wins_server_enable collapse'); - if (!empty($pconfig['wins_server_enable'])) + if (!empty($pconfig['wins_server_enable'])) { $group->addClass('in'); + } $group->add(new Form_Input( 'wins_server' . $i, @@ -678,8 +695,9 @@ $section->addInput(new Form_Checkbox( $group = new Form_Group('Group'); $group->addClass('toggle-pfs_group collapse'); -if (!empty($pconfig['pfs_group_enable'])) +if (!empty($pconfig['pfs_group_enable'])) { $group->addClass('in'); +} $group->add(new Form_Select( 'pfs_group', @@ -700,8 +718,9 @@ $section->addInput(new Form_Checkbox( $group = new Form_Group(''); $group->addClass('toggle-login_banner collapse'); -if (!empty($pconfig['login_banner_enable'])) +if (!empty($pconfig['login_banner_enable'])) { $group->addClass('in'); +} // TODO: should be a textarea $group->add(new Form_Input( diff --git a/src/usr/local/www/vpn_ipsec_phase1.php b/src/usr/local/www/vpn_ipsec_phase1.php index 703a993..957fe55 100644 --- a/src/usr/local/www/vpn_ipsec_phase1.php +++ b/src/usr/local/www/vpn_ipsec_phase1.php @@ -134,7 +134,7 @@ if (isset($p1index) && $a_phase1[$p1index]) { $pconfig['authentication_method'] = $a_phase1[$p1index]['authentication_method']; if (($pconfig['authentication_method'] == "pre_shared_key") || - ($pconfig['authentication_method'] == "xauth_psk_server")) { + ($pconfig['authentication_method'] == "xauth_psk_server")) { $pconfig['pskey'] = $a_phase1[$p1index]['pre-shared-key']; } else { $pconfig['certref'] = $a_phase1[$p1index]['certref']; @@ -526,21 +526,24 @@ function build_interface_list() { $carplist = get_configured_carp_interface_list(); - foreach ($carplist as $cif => $carpip) - $interfaces[$cif] = $carpip." (".get_vip_descr($carpip).")"; + foreach ($carplist as $cif => $carpip) { + $interfaces[$cif] = $carpip . " (" . get_vip_descr($carpip) . ")"; + } $aliaslist = get_configured_ip_aliases_list(); - foreach ($aliaslist as $aliasip => $aliasif) + foreach ($aliaslist as $aliasip => $aliasif) { $interfaces[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")"; + } $grouplist = return_gateway_groups_array(); foreach ($grouplist as $name => $group) { - if($group[0]['vip'] != "") + if ($group[0]['vip'] != "") { $vipif = $group[0]['vip']; - else + } else { $vipif = $group[0]['int']; + } $interfaces[$name] = "GW Group {$name}"; } @@ -554,9 +557,10 @@ function build_auth_method_list() { $list = array(); - foreach ($p1_authentication_methods as $method_type => $method_params){ - if (!$pconfig['mobile'] && $method_params['mobile']) + foreach ($p1_authentication_methods as $method_type => $method_params) { + if (!$pconfig['mobile'] && $method_params['mobile']) { continue; + } $list[$method_type] = htmlspecialchars($method_params['name']); } @@ -569,8 +573,9 @@ function build_myid_list() { $list = array(); - foreach ($my_identifier_list as $id_type => $id_params) + foreach ($my_identifier_list as $id_type => $id_params) { $list[$id_type] = htmlspecialchars($id_params['desc']); + } return($list); } @@ -580,8 +585,9 @@ function build_peerid_list() { $list = array(); - foreach ($peer_identifier_list as $id_type => $id_params) + foreach ($peer_identifier_list as $id_type => $id_params) { $list[$id_type] = htmlspecialchars($id_params['desc']); + } return($list); } @@ -591,9 +597,10 @@ function build_cert_list() { $list = array(); - if(is_array($config['cert'])) { - foreach ($config['cert'] as $cert) + if (is_array($config['cert'])) { + foreach ($config['cert'] as $cert) { $list[$cert['refid']] = $cert['descr']; + } } return($list); @@ -604,9 +611,10 @@ function build_ca_list() { $list = array(); - if(is_array($config['ca'])) { - foreach ($config['ca'] as $ca) - $list[$ca['refid']] = $ca['descr']; + if (is_array($config['ca'])) { + foreach ($config['ca'] as $ca) { + $list[$ca['refid']] = $ca['descr']; + } } return($list); @@ -617,9 +625,10 @@ function build_eal_list() { $list = array(); - if(is_array($p1_ealgos)) { - foreach ($p1_ealgos as $algo => $algodata) + if (is_array($p1_ealgos)) { + foreach ($p1_ealgos as $algo => $algodata) { $list[$algo] = htmlspecialchars($algodata['name']); + } } return($list); @@ -749,8 +758,9 @@ $group->add(new Form_Input( $pconfig['peerid_data'] )); -if($pconfig['mobile']) +if ($pconfig['mobile']) { $group->setHelp('This is known as the "group" setting on some VPN client implementations'); +} $section->add($group); @@ -910,9 +920,11 @@ print($form); /* determine if we should init the key length */ $keyset = ''; -if (isset($pconfig['ealgo']['keylen'])) - if (is_numeric($pconfig['ealgo']['keylen'])) +if (isset($pconfig['ealgo']['keylen'])) { + if (is_numeric($pconfig['ealgo']['keylen'])) { $keyset = $pconfig['ealgo']['keylen']; + } +} ?> @@ -920,7 +932,7 @@ if (isset($pconfig['ealgo']['keylen'])) $desc) -{ +foreach ($ipsec_log_cats as $cat => $desc) { $section->addInput(new Form_Select( $cat, $desc, @@ -338,8 +339,9 @@ $section->addInput(new Form_Checkbox( $group = new Form_Group('Maximum MSS'); $group->addClass('toggle-maxmss collapse'); -if (!empty($pconfig['maxmss_enable'])) +if (!empty($pconfig['maxmss_enable'])) { $group->addClass('in'); +} $group->add(new Form_Input( 'maxmss', diff --git a/src/usr/local/www/vpn_l2tp.php b/src/usr/local/www/vpn_l2tp.php index 9021b4f..17bb288 100644 --- a/src/usr/local/www/vpn_l2tp.php +++ b/src/usr/local/www/vpn_l2tp.php @@ -127,7 +127,7 @@ if ($_POST) { $subnet_end = ip2ulong($_POST['remoteip']) + $_POST['n_l2tp_units'] - 1; if ((ip2ulong($_POST['localip']) >= $subnet_start) && - (ip2ulong($_POST['localip']) <= $subnet_end)) { + (ip2ulong($_POST['localip']) <= $subnet_end)) { $input_errors[] = gettext("The specified server address lies in the remote subnet."); } if ($_POST['localip'] == get_interface_ip("lan")) { @@ -206,11 +206,13 @@ $pgtitle = array(gettext("VPN"), gettext("L2TP"), gettext("Configuration")); $shortcut_section = "l2tps"; include("head.inc"); -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} -if ($savemsg) +if ($savemsg) { print_info_box($savemsg); +} $tab_array = array(); $tab_array[] = array(gettext("Configuration"), true, "vpn_l2tp.php"); @@ -354,7 +356,7 @@ print_info_box(gettext("Don't forget to add a firewall rule to permit traffic fr