diff options
-rw-r--r-- | src/usr/local/www/vpn_ipsec.php | 65 | ||||
-rw-r--r-- | src/usr/local/www/vpn_ipsec_keys.php | 22 | ||||
-rw-r--r-- | src/usr/local/www/vpn_ipsec_keys_edit.php | 3 | ||||
-rw-r--r-- | src/usr/local/www/vpn_ipsec_mobile.php | 79 | ||||
-rw-r--r-- | src/usr/local/www/vpn_ipsec_phase1.php | 65 | ||||
-rw-r--r-- | src/usr/local/www/vpn_ipsec_phase2.php | 39 | ||||
-rw-r--r-- | src/usr/local/www/vpn_ipsec_settings.php | 12 | ||||
-rw-r--r-- | src/usr/local/www/vpn_l2tp.php | 10 | ||||
-rw-r--r-- | src/usr/local/www/vpn_l2tp_users.php | 19 | ||||
-rw-r--r-- | src/usr/local/www/vpn_l2tp_users_edit.php | 3 | ||||
-rw-r--r-- | src/usr/local/www/vpn_openvpn_client.php | 26 | ||||
-rw-r--r-- | src/usr/local/www/vpn_openvpn_csc.php | 14 | ||||
-rw-r--r-- | src/usr/local/www/vpn_openvpn_server.php | 53 | ||||
-rw-r--r-- | src/usr/local/www/wizard.php | 17 |
14 files changed, 251 insertions, 176 deletions
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); </td> <td onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>"> <?php - if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1") + if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1") { echo "V1"; - else + } else { echo "V2"; + } ?> </td> <td> @@ -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."<br />".$ph1ent['remote-gateway']; - else + } else { echo $if."<br /><strong>" . gettext("Mobile Client") . "</strong>"; + } ?> </td> <td onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>"> <?=$spans?> <?php - if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1") + if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1") { echo "{$ph1ent['mode']}"; + } ?> <?=$spane?> </td> @@ -364,10 +370,11 @@ display_top_tabs($tab_array); <?=$p1_ealgos[$ph1ent['encryption-algorithm']['name']]['name']?> <?php if ($ph1ent['encryption-algorithm']['keylen']) { - if ($ph1ent['encryption-algorithm']['keylen']=="auto") + if ($ph1ent['encryption-algorithm']['keylen'] == "auto") { echo " (" . gettext("auto") . ")"; - else + } else { echo " ({$ph1ent['encryption-algorithm']['keylen']} " . gettext("bits") . ")"; + } } ?> </td> @@ -393,10 +400,11 @@ display_top_tabs($tab_array); <td colspan="2"></td> <td colspan="7" class="contains-table"> <?php - if (isset($_POST["tdph2-{$i}-visible"])) + if (isset($_POST["tdph2-{$i}-visible"])) { $tdph2_visible = htmlspecialchars($_POST["tdph2-{$i}-visible"]); - else + } else { $tdph2_visible = 0; + } ?> <input type="hidden" name="tdph2-<?=$i?>-visible" id="tdph2-<?=$i?>-visible" value="<?=$tdph2_visible?>" /> <div id="shph2but-<?=$i?>" <?=($tdph2_visible == '1' ? 'style="display:none"' : '')?>> @@ -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); <tbody class="p2-entries"> <?php $j = 0; foreach ($a_phase2 as $ph2index => $ph2ent): ?> <?php - if ($ph2ent['ikeid'] != $ph1ent['ikeid']) + if ($ph2ent['ikeid'] != $ph1ent['ikeid']) { continue; + } $fr_c = $fr_prefix . "c" . $j; $fr_d = $fr_prefix . "d" . $j; @@ -440,9 +450,9 @@ display_top_tabs($tab_array); $iconfn = "pass"; $entryStatus = (isset($ph2ent['disabled']) || isset($ph1ent['disabled']) ? 'disabled' : 'enabled'); - if ($entryStatus == 'disabled') + if ($entryStatus == 'disabled') { $iconfn .= "_d"; - + } ?> <tr id="<?=$fr_prefix . $j?>" ondblclick="document.location='vpn_ipsec_phase2.php?p2index=<?=$ph2ent['uniqid']?>'" class="<?= $entryStatus ?>"> <td> @@ -455,7 +465,7 @@ display_top_tabs($tab_array); <td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')"> <?=$ph2ent['mode']?> </td> -<?php if(($ph2ent['mode'] == "tunnel") or ($ph2ent['mode'] == "tunnel6")): ?> +<?php if (($ph2ent['mode'] == "tunnel") or ($ph2ent['mode'] == "tunnel6")): ?> <td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')"> <?=ipsec_idinfo_to_text($ph2ent['localid']); ?> </td> @@ -471,14 +481,16 @@ display_top_tabs($tab_array); <td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')"> <?php foreach ($ph2ent['encryption-algorithm-option'] as $k => $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); <?php if (!empty($ph2ent['hash-algorithm-option']) && is_array($ph2ent['hash-algorithm-option'])) { foreach ($ph2ent['hash-algorithm-option'] as $k => $ph2ha) { - if ($k) + if ($k) { echo ", "; + } echo $p2_halgos[$ph2ha]; } } @@ -570,13 +583,13 @@ events.push(function() { }); $('[id^=Xdel_]').click(function (event) { - if(confirm("<?=gettext('Are you sure you wish to delete this P1 entry?')?>")) { + if (confirm("<?=gettext('Are you sure you wish to delete this P1 entry?')?>")) { $('#' + event.target.id.slice(1)).click(); } }); $('[id^=Xdelp2_]').click(function (event) { - if(confirm("<?=gettext('Are you sure you wish to delete this P2 entry?')?>")) { + if (confirm("<?=gettext('Are you sure you wish to delete this P2 entry?')?>")) { $('#' + 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"); ?> <?php -if ($savemsg) +if ($savemsg) { print_info_box($savemsg); +} -if (is_subsystem_dirty('ipsec')) +if (is_subsystem_dirty('ipsec')) { print_info_box_np(gettext("The IPsec tunnel configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect.")); - +} ?> <?php @@ -143,18 +144,20 @@ if (is_subsystem_dirty('ipsec')) <tr> <td> <?php - if ($secretent['ident'] == 'allusers') + if ($secretent['ident'] == 'allusers') { echo gettext("ANY USER"); - else + } else { echo htmlspecialchars($secretent['ident']); + } ?> </td> <td> <?php - if (empty($secretent['type'])) + if (empty($secretent['type'])) { echo 'PSK'; - else + } else { echo htmlspecialchars($secretent['type']); + } ?> </td> <td> @@ -173,10 +176,11 @@ if (is_subsystem_dirty('ipsec')) </td> <td> <?php - if (empty($secretent['type'])) + if (empty($secretent['type'])) { echo 'PSK'; - else + } else { echo htmlspecialchars($secretent['type']); + } ?> </td> <td> 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; + } } //]]> </script> <?php -if ($savemsg) +if ($savemsg) { print_info_box($savemsg); -if (is_subsystem_dirty('ipsec')) +} +if (is_subsystem_dirty('ipsec')) { print_info_box_np(gettext("The IPsec tunnel configuration has been changed") . ".<br />" . 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") . ".<br />" . 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") . ".<br />" . 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'])) <script type="text/javascript"> //<![CDATA[ -events.push(function(){ +events.push(function() { function myidsel_change() { hideGroupInput('myid_data', ($('#myid_type').val() == 'myaddress')); @@ -1028,21 +1040,24 @@ events.push(function(){ ?> } - if( bits ) + if (bits) { $('#ealgo_keylen').val(bits); + } } function dpdchkbox_change() { - hide = ! $('#dpd_enable').prop('checked'); + hide = !$('#dpd_enable').prop('checked'); hideInput('dpd_delay', hide); hideInput('dpd_maxfail', hide); - if(! $('#dpd_delay').val()) + if (!$('#dpd_delay').val()) { $('#dpd_delay').val('10') + } - if(! $('#dpd_maxfail').val()) + if (!$('#dpd_maxfail').val()) { $('#dpd_maxfail').val('5') + } } // ---------- Monitor elements for change and call the appropriate display functions ---------- diff --git a/src/usr/local/www/vpn_ipsec_phase2.php b/src/usr/local/www/vpn_ipsec_phase2.php index 85d5f1c..336739b 100644 --- a/src/usr/local/www/vpn_ipsec_phase2.php +++ b/src/usr/local/www/vpn_ipsec_phase2.php @@ -261,11 +261,13 @@ if ($_POST) { $entered = array(); $entered['type'] = $pconfig['localid_type']; - if (isset($pconfig['localid_address'])) + if (isset($pconfig['localid_address'])) { $entered['address'] = $pconfig['localid_address']; + } - if (isset($pconfig['localid_netbits'])) + if (isset($pconfig['localid_netbits'])) { $entered['netbits'] = $pconfig['localid_netbits']; + } $entered_localid_data = ipsec_idinfo_to_cidr($entered, false, $pconfig['mode']); if ($localid_data == $entered_localid_data) { @@ -466,7 +468,7 @@ function pconfig_to_ealgos(& $pconfig) { return $ealgos; } -function ealgos_to_pconfig(& $ealgos,& $pconfig) { +function ealgos_to_pconfig(& $ealgos, & $pconfig) { $pconfig['ealgos'] = array(); foreach ($ealgos as $algo_data) { @@ -479,7 +481,7 @@ function ealgos_to_pconfig(& $ealgos,& $pconfig) { return $ealgos; } -function pconfig_to_idinfo($prefix,& $pconfig) { +function pconfig_to_idinfo($prefix, & $pconfig) { $type = $pconfig[$prefix."id_type"]; $address = $pconfig[$prefix."id_address"]; @@ -495,7 +497,7 @@ function pconfig_to_idinfo($prefix,& $pconfig) { } } -function idinfo_to_pconfig($prefix,& $idinfo,& $pconfig) { +function idinfo_to_pconfig($prefix, & $idinfo, & $pconfig) { switch ($idinfo['type']) { case "address": @@ -513,8 +515,9 @@ function idinfo_to_pconfig($prefix,& $idinfo,& $pconfig) { } } -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} $tab_array = array(); $tab_array[0] = array(gettext("Tunnels"), !$editing_mobile, "vpn_ipsec.php"); @@ -545,8 +548,9 @@ $group = new Form_Group('Local Network'); $group->addClass('opt_localid'); $subnetarray = get_configured_interface_with_descr(); -foreach($subnetarray as $ifname => $ifdescr) +foreach ($subnetarray as $ifname => $ifdescr) { $subnetarray[$ifname] = $ifdescr . ' subnet'; +} $group->add(new Form_Select( 'localid_type', @@ -567,8 +571,9 @@ $group = new Form_Group('NAT/BINAT translation'); $group->addClass('opt_natid'); $subnetarray = get_configured_interface_with_descr(); -foreach($subnetarray as $ifname => $ifdescr) +foreach ($subnetarray as $ifname => $ifdescr) { $subnetarray[$ifname] = $ifdescr . ' subnet'; +} // Tack none, address & network on the beginning $subnetarray = array('none' => gettext('None'), 'address' => 'Address', 'network' => 'Network') + $subnetarray; @@ -638,11 +643,11 @@ foreach ($p2_ealgos as $algo => $algodata) { 'ealgos[]', null, $algodata['name'], - (is_array($pconfig['ealgos']) && in_array($algo,$pconfig['ealgos'])), + (is_array($pconfig['ealgos']) && in_array($algo, $pconfig['ealgos'])), $algo ))->addClass('multi'); - if(is_array($algodata['keysel'])) { + if (is_array($algodata['keysel'])) { $list = array(); $key_hi = $algodata['keysel']['hi']; $key_lo = $algodata['keysel']['lo']; @@ -660,8 +665,9 @@ foreach ($p2_ealgos as $algo => $algodata) { } - if($i == $rows) + if ($i == $rows) { $group->setHelp('Use 3DES for best compatibility or if you have a hardware crypto accelerator card. Blowfish is usually the fastest in software encryption.'); + } $i++; $section->add($group); @@ -748,7 +754,7 @@ print($form); <script type="text/javascript"> //<![CDATA[ -events.push(function(){ +events.push(function() { // ---------- On changing "Mode" ---------------------------------------------------------------------------------- function change_mode() { @@ -779,8 +785,7 @@ events.push(function(){ if (typeof(bits) === "undefined") { if (value === "tunnel") { bits = 24; - } - else if (value === "tunnel6") { + } else if (value === "tunnel6") { bits = 64; } } @@ -830,8 +835,7 @@ events.push(function(){ if (typeof(bits) === "undefined") { if (value === "tunnel") { bits = 24; - } - else if (value === "tunnel6") { + } else if (value === "tunnel6") { bits = 64; } } @@ -886,8 +890,7 @@ events.push(function(){ if (typeof(bits) === "undefined") { if (value === "tunnel") { bits = 24; - } - else if (value === "tunnel6") { + } else if (value === "tunnel6") { bits = 64; } } diff --git a/src/usr/local/www/vpn_ipsec_settings.php b/src/usr/local/www/vpn_ipsec_settings.php index 62a6869..2062716 100644 --- a/src/usr/local/www/vpn_ipsec_settings.php +++ b/src/usr/local/www/vpn_ipsec_settings.php @@ -252,11 +252,13 @@ function maxmss_checked(obj) { </script> <?php -if ($savemsg) +if ($savemsg) { print_info_box($savemsg); +} -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} $tab_array = array(); $tab_array[0] = array(gettext("Tunnels"), false, "vpn_ipsec.php"); @@ -269,8 +271,7 @@ $form = new Form; $section = new Form_Section('Start IPsec in debug mode based on sections selected'); -foreach ($ipsec_log_cats as $cat => $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 <script type="text/javascript"> //<![CDATA[ -events.push(function(){ +events.push(function() { function setL2TP () { hide = ! $('#mode').prop('checked'); diff --git a/src/usr/local/www/vpn_l2tp_users.php b/src/usr/local/www/vpn_l2tp_users.php index 7e714c1..101889a 100644 --- a/src/usr/local/www/vpn_l2tp_users.php +++ b/src/usr/local/www/vpn_l2tp_users.php @@ -101,20 +101,23 @@ if ($_GET['act'] == "del") { include("head.inc"); -if ($savemsg) +if ($savemsg) { print_info_box($savemsg, success); +} -if (isset($config['l2tp']['radius']['enable'])) +if (isset($config['l2tp']['radius']['enable'])) { print_info_box(gettext("Warning: RADIUS is enabled. The local user database will not be used.")); +} -if (is_subsystem_dirty('l2tpusers')) +if (is_subsystem_dirty('l2tpusers')) { print_info_box_np(gettext("The l2tp user list has been modified") . ".<br />" . gettext("You must apply the changes in order for them to take effect") . ".<br /><b>" . gettext("Warning: this will terminate all current l2tp sessions!") . "</b>"); +} - $tab_array = array(); - $tab_array[] = array(gettext("Configuration"), false, "vpn_l2tp.php"); - $tab_array[] = array(gettext("Users"), true, "vpn_l2tp_users.php"); - display_top_tabs($tab_array); +$tab_array = array(); +$tab_array[] = array(gettext("Configuration"), false, "vpn_l2tp.php"); +$tab_array[] = array(gettext("Users"), true, "vpn_l2tp_users.php"); +display_top_tabs($tab_array); ?> <div class="table-responsive"> <table class="table table-striped table-hover"> @@ -132,7 +135,7 @@ if (is_subsystem_dirty('l2tpusers')) <?=htmlspecialchars($secretent['name'])?> </td> <td> - <?php if($secretent['ip'] == "") $secretent['ip'] = "Dynamic"?> + <?php if ($secretent['ip'] == "") $secretent['ip'] = "Dynamic"?> <?=htmlspecialchars($secretent['ip'])?> </td> <td> diff --git a/src/usr/local/www/vpn_l2tp_users_edit.php b/src/usr/local/www/vpn_l2tp_users_edit.php index 6d6e360..4a2078a 100644 --- a/src/usr/local/www/vpn_l2tp_users_edit.php +++ b/src/usr/local/www/vpn_l2tp_users_edit.php @@ -178,8 +178,9 @@ include("head.inc"); ?> <?php -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} ?> <form class="form-horizontal" action="vpn_l2tp_users_edit.php" method="post" name="iform" id="iform"> diff --git a/src/usr/local/www/vpn_openvpn_client.php b/src/usr/local/www/vpn_openvpn_client.php index 19a9609..bc3d533 100644 --- a/src/usr/local/www/vpn_openvpn_client.php +++ b/src/usr/local/www/vpn_openvpn_client.php @@ -300,14 +300,14 @@ if ($_POST) { if (!$tls_mode && !$pconfig['autokey_enable']) { if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") || - !strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----")) { + !strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----")) { $input_errors[] = gettext("The field 'Shared Key' does not appear to be valid"); } } if ($tls_mode && $pconfig['tlsauth_enable'] && !$pconfig['autotls_enable']) { if (!strstr($pconfig['tls'], "-----BEGIN OpenVPN Static key V1-----") || - !strstr($pconfig['tls'], "-----END OpenVPN Static key V1-----")) { + !strstr($pconfig['tls'], "-----END OpenVPN Static key V1-----")) { $input_errors[] = gettext("The field 'TLS Authentication Key' does not appear to be valid"); } } @@ -406,14 +406,17 @@ if ($_POST) { include("head.inc"); -if (!$savemsg) +if (!$savemsg) { $savemsg = ""; +} -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} -if ($savemsg) +if ($savemsg) { print_info_box($savemsg, 'success'); +} $tab_array = array(); $tab_array[] = array(gettext("Server"), false, "vpn_openvpn_server.php"); @@ -423,7 +426,7 @@ $tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.x add_package_tabs("OpenVPN", $tab_array); display_top_tabs($tab_array); -if($act=="new" || $act=="edit") : +if ($act=="new" || $act=="edit"): $form = new Form(); $section = new Form_Section('General Information'); @@ -573,8 +576,9 @@ if($act=="new" || $act=="edit") : if (count($a_ca)) { $list = array(); - foreach ($a_ca as $ca) + foreach ($a_ca as $ca) { $list[$ca['refid']] = $ca['descr']; + } $section->addInput(new Form_Select( 'caref', @@ -788,7 +792,7 @@ else: <tbody> <?php $i = 0; - foreach($a_client as $client): + foreach ($a_client as $client): $server = "{$client['server_addr']}:{$client['server_port']}"; ?> <tr <?=isset($server['disable']) ? 'class="disabled"':''?>> @@ -827,15 +831,15 @@ endif; // Note: // The following *_change() functions were converted from Javascript/DOM to JQuery but otherwise -// mostly left unchanged. The logic on this form is complex andthis works! +// mostly left unchanged. The logic on this form is complex and this works! ?> <script type="text/javascript"> //<![CDATA[ -events.push(function(){ +events.push(function() { function mode_change() { - switch($('#mode').val()) { + switch ($('#mode').val()) { case "p2p_tls": hideCheckbox('tlsauth_enable', false); hideInput('caref', false); diff --git a/src/usr/local/www/vpn_openvpn_csc.php b/src/usr/local/www/vpn_openvpn_csc.php index 94d9455..0dddf20 100644 --- a/src/usr/local/www/vpn_openvpn_csc.php +++ b/src/usr/local/www/vpn_openvpn_csc.php @@ -310,11 +310,13 @@ if ($_POST) { include("head.inc"); -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} -if ($savemsg) +if ($savemsg) { print_info_box($savemsg, 'success'); +} $tab_array = array(); $tab_array[] = array(gettext("Server"), false, "vpn_openvpn_server.php"); @@ -324,7 +326,7 @@ $tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.x add_package_tabs("OpenVPN", $tab_array); display_top_tabs($tab_array); -if($act=="new" || $act=="edit"): +if ($act == "new" || $act == "edit"): $form = new Form(); $section = new Form_Section('General Information'); @@ -610,11 +612,11 @@ if($act=="new" || $act=="edit"): <script type="text/javascript"> //<![CDATA[ -events.push(function(){ +events.push(function() { // Hide/show that section, but have to also respect the wins_server_enable checkbox function setNetbios() { - if($('#netbios_enable').prop('checked')) { + if ($('#netbios_enable').prop('checked')) { hideInput('netbios_ntype', false); hideInput('netbios_scope', false); hideCheckbox('wins_server_enable', false); @@ -669,7 +671,7 @@ else : // Not an 'add' or an 'edit'. Just the table of Override CSCs <tbody> <?php $i = 0; - foreach($a_csc as $csc): + foreach ($a_csc as $csc): $disabled = isset($csc['disable']) ? "Yes":"No"; ?> <tr> diff --git a/src/usr/local/www/vpn_openvpn_server.php b/src/usr/local/www/vpn_openvpn_server.php index 4a475b4..6f8e9c4 100644 --- a/src/usr/local/www/vpn_openvpn_server.php +++ b/src/usr/local/www/vpn_openvpn_server.php @@ -221,9 +221,9 @@ if ($_GET['act'] == "edit") { $pconfig['dns_server4'] = $a_server[$id]['dns_server4']; if ($pconfig['dns_server1'] || - $pconfig['dns_server2'] || - $pconfig['dns_server3'] || - $pconfig['dns_server4']) { + $pconfig['dns_server2'] || + $pconfig['dns_server3'] || + $pconfig['dns_server4']) { $pconfig['dns_server_enable'] = true; } @@ -231,7 +231,7 @@ if ($_GET['act'] == "edit") { $pconfig['ntp_server2'] = $a_server[$id]['ntp_server2']; if ($pconfig['ntp_server1'] || - $pconfig['ntp_server2']) { + $pconfig['ntp_server2']) { $pconfig['ntp_server_enable'] = true; } @@ -243,7 +243,7 @@ if ($_GET['act'] == "edit") { $pconfig['wins_server2'] = $a_server[$id]['wins_server2']; if ($pconfig['wins_server1'] || - $pconfig['wins_server2']) { + $pconfig['wins_server2']) { $pconfig['wins_server_enable'] = true; } @@ -345,14 +345,14 @@ if ($_POST) { if (!$tls_mode && !$pconfig['autokey_enable']) { if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") || - !strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----")) { + !strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----")) { $input_errors[] = gettext("The field 'Shared Key' does not appear to be valid"); } } if ($tls_mode && $pconfig['tlsauth_enable'] && !$pconfig['autotls_enable']) { if (!strstr($pconfig['tls'], "-----BEGIN OpenVPN Static key V1-----") || - !strstr($pconfig['tls'], "-----END OpenVPN Static key V1-----")) { + !strstr($pconfig['tls'], "-----END OpenVPN Static key V1-----")) { $input_errors[] = gettext("The field 'TLS Authentication Key' does not appear to be valid"); } } @@ -438,7 +438,7 @@ if ($_POST) { $input_errors[] = gettext("Using a tunnel network and server bridge settings together is not allowed."); } if (($pconfig['serverbridge_dhcp_start'] && !$pconfig['serverbridge_dhcp_end']) || - (!$pconfig['serverbridge_dhcp_start'] && $pconfig['serverbridge_dhcp_end'])) { + (!$pconfig['serverbridge_dhcp_start'] && $pconfig['serverbridge_dhcp_end'])) { $input_errors[] = gettext("Server Bridge DHCP Start and End must both be empty, or defined."); } if (($pconfig['serverbridge_dhcp_start'] && !is_ipaddrv4($pconfig['serverbridge_dhcp_start']))) { @@ -594,14 +594,17 @@ $shortcut_section = "openvpn"; include("head.inc"); -if (!$savemsg) +if (!$savemsg) { $savemsg = ""; +} -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} -if ($savemsg) +if ($savemsg) { print_info_box_np($savemsg, 'success'); +} $tab_array = array(); $tab_array[] = array(gettext("Server"), true, "vpn_openvpn_server.php"); @@ -613,7 +616,7 @@ display_top_tabs($tab_array); $form = new Form(); -if($act=="new" || $act=="edit") : +if ($act=="new" || $act=="edit"): $section = new Form_Section('General Information'); @@ -642,8 +645,9 @@ if($act=="new" || $act=="edit") : $authmodes[0] = key($auth_servers); } - foreach ($auth_servers as $auth_server_key => $auth_server) + foreach ($auth_servers as $auth_server_key => $auth_server) { $options[$auth_server_key] = $auth_server['name']; + } $section->addInput(new Form_Select( 'authmode', @@ -717,8 +721,9 @@ if($act=="new" || $act=="edit") : if (count($a_ca)) { $list = array(); - foreach ($a_ca as $ca) + foreach ($a_ca as $ca) { $list[$ca['refid']] = $ca['descr']; + } $section->addInput(new Form_Select( 'caref', @@ -776,7 +781,7 @@ if($act=="new" || $act=="edit") : 'dh_length', 'DH Parameter length (bits)', $pconfig['dh_length'], - array_combine($openvpn_dh_lengths,$openvpn_dh_lengths) + array_combine($openvpn_dh_lengths, $openvpn_dh_lengths) ))->setHelp(count($a_cert) ? '':sprintf('No Certificates defined. You may create one here: %s', '<a href="system_camanager.php">System > Cert Manager</a>')); if (!$pconfig['shared_key']) { @@ -1202,7 +1207,7 @@ else: <tbody> <?php $i = 0; - foreach($a_server as $server): + foreach ($a_server as $server): ?> <tr <?=isset($server['disable']) ? 'class="disabled"':''?>> <td> @@ -1246,7 +1251,7 @@ endif; <script type="text/javascript"> //<![CDATA[ -events.push(function(){ +events.push(function() { function mode_change() { value = $('#mode').val(); @@ -1257,7 +1262,7 @@ events.push(function(){ hideInput('crlref', false); hideLabel('Peer Certificate Revocation list', false); - switch(value) { + switch (value) { case "p2p_tls": case "server_tls": case "server_user": @@ -1297,7 +1302,7 @@ events.push(function(){ break; } - switch(value) { + switch (value) { case "p2p_shared_key": hideClass('advanced', true); hideInput('remote_network', false); @@ -1360,7 +1365,7 @@ events.push(function(){ // Hide 'autotls_enable' AND 'tls' if mode == p2p_shared_key // Otherwise hide 'tls' based on state of 'autotls_enable' function autotls_change() { - if(($('#mode').val() == 'p2p_shared_key') || (!$('#tlsauth_enable').prop('checked'))){ + if (($('#mode').val() == 'p2p_shared_key') || (!$('#tlsauth_enable').prop('checked'))) { hideInput('tls', true); hideInput('autotls_enable', true); } else { @@ -1372,7 +1377,7 @@ events.push(function(){ function autokey_change() { var hide = $('#autokey_enable').prop('checked') - if($('#mode').val() != 'p2p_shared_key') { + if ($('#mode').val() != 'p2p_shared_key') { hideCheckbox('autokey_enable', true); hideInput('shared_key', true); } else { @@ -1442,7 +1447,7 @@ events.push(function(){ mvalue = $('#mode').val(); - switch(mvalue) { + switch (mvalue) { case "p2p_shared_key": sharedkey = true; p2p = true; @@ -1459,7 +1464,7 @@ events.push(function(){ value = $('#dev_mode').val(); - switch(value) { + switch (value) { case "tun": hideCheckbox('no_tun_ipv6', false); hideInput('tunnel_network', false); @@ -1490,7 +1495,7 @@ events.push(function(){ hideInput('serverbridge_dhcp_end', false); hideInput('topology', true); - if( $('#serverbridge_dhcp').prop('checked')) { + if ($('#serverbridge_dhcp').prop('checked')) { disableInput('serverbridge_interface', false); disableInput('serverbridge_dhcp_start', false); disableInput('serverbridge_dhcp_end', false); diff --git a/src/usr/local/www/wizard.php b/src/usr/local/www/wizard.php index 2f97112..a1f0381 100644 --- a/src/usr/local/www/wizard.php +++ b/src/usr/local/www/wizard.php @@ -482,7 +482,7 @@ $form->addGlobal(new Form_Input( $section = new Form_Section(fixup_string($title)); -if($description) { +if ($description) { $section->addInput(new Form_StaticText( null, fixup_string($description) @@ -523,7 +523,7 @@ if ($pkg['step'][$stepid]['fields']['field'] != "") { } - if(DEBUG) { + if (DEBUG) { print('Step: ' . $pkg['step'][$stepid]['id'] . ', Field: ' . $field['type'] . ', Name: ' . $name . '<br />'); } @@ -585,10 +585,11 @@ if ($pkg['step'][$stepid]['fields']['field'] != "") { $etitle = (fixup_string($field['displayname'])) ? $field['displayname'] : $field['name']; - if (($field['multiple'] != "") && ($field['multiple'] != "0")) + if (($field['multiple'] != "") && ($field['multiple'] != "0")) { $multiple = true; - else + } else { $multiple = false; + } if ($field['add_to_interfaces_selection'] != "") { if ($field['add_to_interfaces_selection'] == $value) { @@ -612,8 +613,9 @@ if ($pkg['step'][$stepid]['fields']['field'] != "") { } } - if ($value == $ifname) + if ($value == $ifname) { array_push($selected, $value); + } $canecho = 0; if ($field['interface_filter'] != "") { @@ -673,8 +675,9 @@ if ($pkg['step'][$stepid]['fields']['field'] != "") { foreach ($config['ca'] as $ca) { $caname = htmlspecialchars($ca['descr']); - if ($value == $caname) + if ($value == $caname) { $selected = $value; + } $canecho = 0; if ($field['certca_filter'] != "") { @@ -998,7 +1001,7 @@ if ($pkg['step'][$stepid]['disableallfieldsbydefault'] != "") { <script type="text/javascript"> //<![CDATA[ -events.push(function(){ +events.push(function() { enablechange(); disablechange(); showchange(); |