summaryrefslogtreecommitdiffstats
path: root/usr/local/www/vpn_openvpn_client.php
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-05-23 01:56:00 +0545
committerPhil Davis <phil.davis@inf.org>2015-05-23 01:56:00 +0545
commite38c75a89d954d21d3d110970d4e2d165413f150 (patch)
treef72f63479ee97b765360725182efcd571357dc91 /usr/local/www/vpn_openvpn_client.php
parent88cbd0049b78bd731648be68c13e08161e5e943c (diff)
downloadpfsense-e38c75a89d954d21d3d110970d4e2d165413f150.zip
pfsense-e38c75a89d954d21d3d110970d4e2d165413f150.tar.gz
Code style www vpn_openvpn
Diffstat (limited to 'usr/local/www/vpn_openvpn_client.php')
-rw-r--r--usr/local/www/vpn_openvpn_client.php304
1 files changed, 184 insertions, 120 deletions
diff --git a/usr/local/www/vpn_openvpn_client.php b/usr/local/www/vpn_openvpn_client.php
index 4ee0278..b0b2e4e 100644
--- a/usr/local/www/vpn_openvpn_client.php
+++ b/usr/local/www/vpn_openvpn_client.php
@@ -42,39 +42,47 @@ require_once("pkg-utils.inc");
$pgtitle = array(gettext("OpenVPN"), gettext("Client"));
$shortcut_section = "openvpn";
-if (!is_array($config['openvpn']['openvpn-client']))
+if (!is_array($config['openvpn']['openvpn-client'])) {
$config['openvpn']['openvpn-client'] = array();
+}
$a_client = &$config['openvpn']['openvpn-client'];
-if (!is_array($config['ca']))
+if (!is_array($config['ca'])) {
$config['ca'] = array();
+}
$a_ca =& $config['ca'];
-if (!is_array($config['cert']))
+if (!is_array($config['cert'])) {
$config['cert'] = array();
+}
$a_cert =& $config['cert'];
-if (!is_array($config['crl']))
+if (!is_array($config['crl'])) {
$config['crl'] = array();
+}
$a_crl =& $config['crl'];
-if (is_numericint($_GET['id']))
+if (is_numericint($_GET['id'])) {
$id = $_GET['id'];
-if (isset($_POST['id']) && is_numericint($_POST['id']))
+}
+if (isset($_POST['id']) && is_numericint($_POST['id'])) {
$id = $_POST['id'];
+}
$act = $_GET['act'];
-if (isset($_POST['act']))
+if (isset($_POST['act'])) {
$act = $_POST['act'];
+}
-if (isset($id) && $a_client[$id])
+if (isset($id) && $a_client[$id]) {
$vpnid = $a_client[$id]['vpnid'];
-else
+} else {
$vpnid = 0;
+}
if ($_GET['act'] == "del") {
@@ -82,14 +90,15 @@ if ($_GET['act'] == "del") {
pfSenseHeader("vpn_openvpn_client.php");
exit;
}
- if (!empty($a_client[$id]))
+ if (!empty($a_client[$id])) {
openvpn_delete('client', $a_client[$id]);
+ }
unset($a_client[$id]);
write_config();
$savemsg = gettext("Client successfully deleted")."<br />";
}
-if($_GET['act']=="new"){
+if ($_GET['act'] == "new") {
$pconfig['autokey_enable'] = "yes";
$pconfig['tlsauth_enable'] = "yes";
$pconfig['autotls_enable'] = "yes";
@@ -101,13 +110,14 @@ if($_GET['act']=="new"){
}
global $simplefields;
-$simplefields = array('auth_user','auth_pass');
+$simplefields = array('auth_user', 'auth_pass');
-if($_GET['act']=="edit"){
+if ($_GET['act'] == "edit") {
if (isset($id) && $a_client[$id]) {
- foreach($simplefields as $stat)
+ foreach ($simplefields as $stat) {
$pconfig[$stat] = $a_client[$id][$stat];
+ }
$pconfig['disable'] = isset($a_client[$id]['disable']);
$pconfig['mode'] = $a_client[$id]['mode'];
@@ -137,8 +147,9 @@ if($_GET['act']=="edit"){
$pconfig['tlsauth_enable'] = "yes";
$pconfig['tls'] = base64_decode($a_client[$id]['tls']);
}
- } else
+ } else {
$pconfig['shared_key'] = base64_decode($a_client[$id]['shared_key']);
+ }
$pconfig['crypto'] = $a_client[$id]['crypto'];
// OpenVPN Defaults to SHA1 if unset
$pconfig['digest'] = !empty($a_client[$id]['digest']) ? $a_client[$id]['digest'] : "SHA1";
@@ -155,14 +166,15 @@ if($_GET['act']=="edit"){
// just in case the modes switch
$pconfig['autokey_enable'] = "yes";
$pconfig['autotls_enable'] = "yes";
-
+
$pconfig['no_tun_ipv6'] = $a_client[$id]['no_tun_ipv6'];
$pconfig['route_no_pull'] = $a_client[$id]['route_no_pull'];
$pconfig['route_no_exec'] = $a_client[$id]['route_no_exec'];
- if (isset($a_client[$id]['verbosity_level']))
+ if (isset($a_client[$id]['verbosity_level'])) {
$pconfig['verbosity_level'] = $a_client[$id]['verbosity_level'];
- else
+ } else {
$pconfig['verbosity_level'] = 1; // Default verbosity is 1
+ }
}
}
@@ -171,12 +183,13 @@ if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
- if (isset($id) && $a_client[$id])
+ if (isset($id) && $a_client[$id]) {
$vpnid = $a_client[$id]['vpnid'];
- else
+ } else {
$vpnid = 0;
+ }
- list($iv_iface, $iv_ip) = explode ("|",$pconfig['interface']);
+ list($iv_iface, $iv_ip) = explode ("|", $pconfig['interface']);
if (is_ipaddrv4($iv_ip) && (stristr($pconfig['protocol'], "6") !== false)) {
$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv6 protocol and an IPv4 IP address.");
} elseif (is_ipaddrv6($iv_ip) && (stristr($pconfig['protocol'], "6") === false)) {
@@ -187,71 +200,91 @@ if ($_POST) {
$input_errors[] = gettext("An IPv6 protocol was selected, but the selected interface has no IPv6 address.");
}
- if ($pconfig['mode'] != "p2p_shared_key")
+ if ($pconfig['mode'] != "p2p_shared_key") {
$tls_mode = true;
- else
+ } else {
$tls_mode = false;
+ }
/* input validation */
if ($pconfig['local_port']) {
- if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
+ if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port')) {
$input_errors[] = $result;
+ }
$portused = openvpn_port_used($pconfig['protocol'], $pconfig['interface'], $pconfig['local_port'], $vpnid);
- if (($portused != $vpnid) && ($portused != 0))
+ if (($portused != $vpnid) && ($portused != 0)) {
$input_errors[] = gettext("The specified 'Local port' is in use. Please select another value");
+ }
}
- if ($result = openvpn_validate_host($pconfig['server_addr'], 'Server host or address'))
+ if ($result = openvpn_validate_host($pconfig['server_addr'], 'Server host or address')) {
$input_errors[] = $result;
+ }
- if ($result = openvpn_validate_port($pconfig['server_port'], 'Server port'))
+ if ($result = openvpn_validate_port($pconfig['server_port'], 'Server port')) {
$input_errors[] = $result;
+ }
if ($pconfig['proxy_addr']) {
- if ($result = openvpn_validate_host($pconfig['proxy_addr'], 'Proxy host or address'))
+ if ($result = openvpn_validate_host($pconfig['proxy_addr'], 'Proxy host or address')) {
$input_errors[] = $result;
+ }
- if ($result = openvpn_validate_port($pconfig['proxy_port'], 'Proxy port'))
+ if ($result = openvpn_validate_port($pconfig['proxy_port'], 'Proxy port')) {
$input_errors[] = $result;
+ }
if ($pconfig['proxy_authtype'] != "none") {
- if (empty($pconfig['proxy_user']) || empty($pconfig['proxy_passwd']))
+ if (empty($pconfig['proxy_user']) || empty($pconfig['proxy_passwd'])) {
$input_errors[] = gettext("User name and password are required for proxy with authentication.");
+ }
}
}
- if($pconfig['tunnel_network'])
- if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'IPv4 Tunnel Network', false, "ipv4"))
+ if ($pconfig['tunnel_network']) {
+ if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'IPv4 Tunnel Network', false, "ipv4")) {
$input_errors[] = $result;
+ }
+ }
- if($pconfig['tunnel_networkv6'])
- if ($result = openvpn_validate_cidr($pconfig['tunnel_networkv6'], 'IPv6 Tunnel Network', false, "ipv6"))
+ if ($pconfig['tunnel_networkv6']) {
+ if ($result = openvpn_validate_cidr($pconfig['tunnel_networkv6'], 'IPv6 Tunnel Network', false, "ipv6")) {
$input_errors[] = $result;
+ }
+ }
- if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'IPv4 Remote Network', true, "ipv4"))
+ if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'IPv4 Remote Network', true, "ipv4")) {
$input_errors[] = $result;
+ }
- if ($result = openvpn_validate_cidr($pconfig['remote_networkv6'], 'IPv6 Remote Network', true, "ipv6"))
+ if ($result = openvpn_validate_cidr($pconfig['remote_networkv6'], 'IPv6 Remote Network', true, "ipv6")) {
$input_errors[] = $result;
+ }
- if (!empty($pconfig['use_shaper']) && (!is_numeric($pconfig['use_shaper']) || ($pconfig['use_shaper'] <= 0)))
+ if (!empty($pconfig['use_shaper']) && (!is_numeric($pconfig['use_shaper']) || ($pconfig['use_shaper'] <= 0))) {
$input_errors[] = gettext("The bandwidth limit must be a positive numeric value.");
+ }
- if ($pconfig['autokey_enable'])
+ if ($pconfig['autokey_enable']) {
$pconfig['shared_key'] = openvpn_create_key();
+ }
- if (!$tls_mode && !$pconfig['autokey_enable'])
+ 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 ($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");
+ }
+ }
/* If we are not in shared key mode, then we need the CA/Cert. */
if ($pconfig['mode'] != "p2p_shared_key") {
@@ -273,19 +306,22 @@ if ($_POST) {
$client = array();
- foreach($simplefields as $stat)
+ foreach ($simplefields as $stat) {
update_if_changed($stat, $client[$stat], $_POST[$stat]);
+ }
- if ($vpnid)
+ if ($vpnid) {
$client['vpnid'] = $vpnid;
- else
+ } else {
$client['vpnid'] = openvpn_vpnid_next();
+ }
- if ($_POST['disable'] == "yes")
+ if ($_POST['disable'] == "yes") {
$client['disable'] = true;
+ }
$client['protocol'] = $pconfig['protocol'];
$client['dev_mode'] = $pconfig['dev_mode'];
- list($client['interface'], $client['ipaddr']) = explode ("|",$pconfig['interface']);
+ list($client['interface'], $client['ipaddr']) = explode ("|", $pconfig['interface']);
$client['local_port'] = $pconfig['local_port'];
$client['server_addr'] = $pconfig['server_addr'];
$client['server_port'] = $pconfig['server_port'];
@@ -303,8 +339,9 @@ if ($_POST) {
$client['caref'] = $pconfig['caref'];
$client['certref'] = $pconfig['certref'];
if ($pconfig['tlsauth_enable']) {
- if ($pconfig['autotls_enable'])
+ if ($pconfig['autotls_enable']) {
$pconfig['tls'] = openvpn_create_key();
+ }
$client['tls'] = base64_encode($pconfig['tls']);
}
} else {
@@ -327,10 +364,11 @@ if ($_POST) {
$client['route_no_exec'] = $pconfig['route_no_exec'];
$client['verbosity_level'] = $pconfig['verbosity_level'];
- if (isset($id) && $a_client[$id])
+ if (isset($id) && $a_client[$id]) {
$a_client[$id] = $client;
- else
+ } else {
$a_client[] = $client;
+ }
openvpn_resync('client', $client);
write_config();
@@ -352,7 +390,7 @@ include("head.inc");
function mode_change() {
index = document.iform.mode.selectedIndex;
value = document.iform.mode.options[index].value;
- switch(value) {
+ switch (value) {
case "p2p_tls":
document.getElementById("tls").style.display="";
document.getElementById("tls_ca").style.display="";
@@ -375,7 +413,7 @@ function mode_change() {
function dev_mode_change() {
index = document.iform.dev_mode.selectedIndex;
value = document.iform.dev_mode.options[index].value;
- switch(value) {
+ switch (value) {
case "tun":
document.getElementById("chkboxNoTunIPv6").style.display="";
break;
@@ -386,10 +424,11 @@ function dev_mode_change() {
}
function autokey_change() {
- if (document.iform.autokey_enable.checked)
+ if (document.iform.autokey_enable.checked) {
document.getElementById("autokey_opts").style.display="none";
- else
+ } else {
document.getElementById("autokey_opts").style.display="";
+ }
}
function useproxy_changed() {
@@ -404,10 +443,11 @@ function useproxy_changed() {
function tlsauth_change() {
<?php if (!$pconfig['tls']): ?>
- if (document.iform.tlsauth_enable.checked)
+ if (document.iform.tlsauth_enable.checked) {
document.getElementById("tlsauth_opts").style.display="";
- else
+ } else {
document.getElementById("tlsauth_opts").style.display="none";
+ }
<?php endif; ?>
autotls_change();
@@ -421,22 +461,26 @@ function autotls_change() {
autocheck = false;
<?php endif; ?>
- if (document.iform.tlsauth_enable.checked && !autocheck)
+ if (document.iform.tlsauth_enable.checked && !autocheck) {
document.getElementById("autotls_opts").style.display="";
- else
+ } else {
document.getElementById("autotls_opts").style.display="none";
+ }
}
//]]>
</script>
<?php
-if (!$savemsg)
+if (!$savemsg) {
$savemsg = "";
+}
-if ($input_errors)
+if ($input_errors) {
print_input_errors($input_errors);
-if ($savemsg)
+}
+if ($savemsg) {
print_info_box($savemsg);
+}
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn openvpn client">
<tr>
@@ -455,7 +499,7 @@ if ($savemsg)
<tr>
<td class="tabcont">
- <?php if($act=="new" || $act=="edit"): ?>
+ <?php if ($act=="new" || $act=="edit"): ?>
<form action="vpn_openvpn_client.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="general information">
@@ -468,7 +512,7 @@ if ($savemsg)
<table border="0" cellpadding="0" cellspacing="0" summary="enable disable client">
<tr>
<td>
- <?php set_checked($pconfig['disable'],$chk); ?>
+ <?php set_checked($pconfig['disable'], $chk); ?>
<input name="disable" type="checkbox" value="yes" <?=$chk;?> />
</td>
<td>
@@ -489,8 +533,9 @@ if ($savemsg)
<?php
foreach ($openvpn_client_modes as $name => $desc):
$selected = "";
- if ($pconfig['mode'] == $name)
+ if ($pconfig['mode'] == $name) {
$selected = "selected=\"selected\"";
+ }
?>
<option value="<?=$name;?>" <?=$selected;?>><?=$desc;?></option>
<?php endforeach; ?>
@@ -499,33 +544,35 @@ if ($savemsg)
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
- <td width="78%" class="vtable">
+ <td width="78%" class="vtable">
<select name='protocol' class="formselect">
<?php
foreach ($openvpn_prots as $prot):
$selected = "";
- if ($pconfig['protocol'] == $prot)
+ if ($pconfig['protocol'] == $prot) {
$selected = "selected=\"selected\"";
+ }
?>
<option value="<?=$prot;?>" <?=$selected;?>><?=$prot;?></option>
<?php endforeach; ?>
</select>
- </td>
+ </td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Device mode");?></td>
- <td width="78%" class="vtable">
+ <td width="78%" class="vtable">
<select name='dev_mode' class="formselect" onchange="dev_mode_change()">
<?php
foreach ($openvpn_dev_mode as $mode):
$selected = "";
- if ($pconfig['dev_mode'] == $mode)
+ if ($pconfig['dev_mode'] == $mode) {
$selected = "selected=\"selected\"";
+ }
?>
<option value="<?=$mode;?>" <?=$selected;?>><?=$mode;?></option>
<?php endforeach; ?>
</select>
- </td>
+ </td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
@@ -534,27 +581,32 @@ if ($savemsg)
<?php
$interfaces = get_configured_interface_with_descr();
$carplist = get_configured_carp_interface_list();
- foreach ($carplist as $cif => $carpip)
+ foreach ($carplist as $cif => $carpip) {
$interfaces[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")";
+ }
$aliaslist = get_configured_ip_aliases_list();
- foreach ($aliaslist as $aliasip => $aliasif)
+ foreach ($aliaslist as $aliasip => $aliasif) {
$interfaces[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
+ }
$grouplist = return_gateway_groups_array();
foreach ($grouplist as $name => $group) {
- if($group['ipprotocol'] != inet)
+ if ($group['ipprotocol'] != inet) {
continue;
- if($group[0]['vip'] <> "")
+ }
+ if ($group[0]['vip'] <> "") {
$vipif = $group[0]['vip'];
- else
+ } else {
$vipif = $group[0]['int'];
+ }
$interfaces[$name] = "GW Group {$name}";
}
$interfaces['lo0'] = "Localhost";
$interfaces['any'] = "any";
foreach ($interfaces as $iface => $ifacename):
$selected = "";
- if ($iface == $pconfig['interface'])
+ if ($iface == $pconfig['interface']) {
$selected = "selected=\"selected\"";
+ }
?>
<option value="<?=$iface;?>" <?=$selected;?>>
<?=htmlspecialchars($ifacename);?>
@@ -645,7 +697,7 @@ if ($savemsg)
<table border="0" cellpadding="2" cellspacing="0" summary="server host name resolution">
<tr>
<td>
- <?php set_checked($pconfig['resolve_retry'],$chk); ?>
+ <?php set_checked($pconfig['resolve_retry'], $chk); ?>
<input name="resolve_retry" type="checkbox" value="yes" <?=$chk;?> />
</td>
<td>
@@ -682,22 +734,22 @@ if ($savemsg)
<table border="0" cellpadding="2" cellspacing="0" summary="user name password">
<tr>
<td align="right" width="25%">
- <span class="vexpl">
- &nbsp;<?=gettext("Username"); ?> :&nbsp;
- </span>
+ <span class="vexpl">
+ &nbsp;<?=gettext("Username"); ?> :&nbsp;
+ </span>
</td>
<td>
- <input name="auth_user" id="auth_user" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['auth_user']);?>" />
+ <input name="auth_user" id="auth_user" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['auth_user']);?>" />
</td>
</tr>
<tr>
<td align="right" width="25%">
- <span class="vexpl">
- &nbsp;<?=gettext("Password"); ?> :&nbsp;
- </span>
+ <span class="vexpl">
+ &nbsp;<?=gettext("Password"); ?> :&nbsp;
+ </span>
</td>
<td>
- <input name="auth_pass" id="auth_pass" type="password" class="formfld pwd" size="20" value="<?=htmlspecialchars($pconfig['auth_pass']);?>" />
+ <input name="auth_pass" id="auth_pass" type="password" class="formfld pwd" size="20" value="<?=htmlspecialchars($pconfig['auth_pass']);?>" />
</td>
</tr>
</table>
@@ -712,7 +764,7 @@ if ($savemsg)
<table border="0" cellpadding="2" cellspacing="0" summary="tls authentication">
<tr>
<td>
- <?php set_checked($pconfig['tlsauth_enable'],$chk); ?>
+ <?php set_checked($pconfig['tlsauth_enable'], $chk); ?>
<input name="tlsauth_enable" id="tlsauth_enable" type="checkbox" value="yes" <?=$chk;?> onclick="tlsauth_change()" />
</td>
<td>
@@ -726,7 +778,7 @@ if ($savemsg)
<table border="0" cellpadding="2" cellspacing="0" id="tlsauth_opts" summary="tls authentication options">
<tr>
<td>
- <?php set_checked($pconfig['autotls_enable'],$chk); ?>
+ <?php set_checked($pconfig['autotls_enable'], $chk); ?>
<input name="autotls_enable" id="autotls_enable" type="checkbox" value="yes" <?=$chk;?> onclick="autotls_change()" />
</td>
<td>
@@ -750,14 +802,15 @@ if ($savemsg)
</tr>
<tr id="tls_ca">
<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer Certificate Authority"); ?></td>
- <td width="78%" class="vtable">
+ <td width="78%" class="vtable">
<?php if (count($a_ca)): ?>
<select name='caref' class="formselect">
<?php
foreach ($a_ca as $ca):
$selected = "";
- if ($pconfig['caref'] == $ca['refid'])
+ if ($pconfig['caref'] == $ca['refid']) {
$selected = "selected=\"selected\"";
+ }
?>
<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['descr'];?></option>
<?php endforeach; ?>
@@ -769,7 +822,7 @@ if ($savemsg)
</tr>
<tr id="tls_cert">
<td width="22%" valign="top" class="vncellreq"><?=gettext("Client Certificate"); ?></td>
- <td width="78%" class="vtable">
+ <td width="78%" class="vtable">
<select name='certref' class="formselect">
<?php
foreach ($a_cert as $cert):
@@ -778,22 +831,26 @@ if ($savemsg)
$inuse = "";
$revoked = "";
$ca = lookup_ca($cert['caref']);
- if ($ca)
+ if ($ca) {
$caname = " (CA: {$ca['descr']})";
- if ($pconfig['certref'] == $cert['refid'])
+ }
+ if ($pconfig['certref'] == $cert['refid']) {
$selected = "selected=\"selected\"";
- if (cert_in_use($cert['refid']))
+ }
+ if (cert_in_use($cert['refid'])) {
$inuse = " *In Use";
- if (is_cert_revoked($cert))
+ }
+ if (is_cert_revoked($cert)) {
$revoked = " *Revoked";
+ }
?>
<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['descr'] . $caname . $inuse . $revoked;?></option>
<?php endforeach; ?>
<option value="" <?PHP if (empty($pconfig['certref'])) echo "selected=\"selected\""; ?>>None (Username and Password required)</option>
</select>
- <?php if (!count($a_cert)): ?>
- <b>No Certificates defined.</b> <br />Create one under <a href="system_certmanager.php">System &gt; Cert Manager</a> if one is required for this connection.
- <?php endif; ?>
+ <?php if (!count($a_cert)): ?>
+ <b>No Certificates defined.</b> <br />Create one under <a href="system_certmanager.php">System &gt; Cert Manager</a> if one is required for this connection.
+ <?php endif; ?>
</td>
</tr>
<tr id="psk">
@@ -803,7 +860,7 @@ if ($savemsg)
<table border="0" cellpadding="2" cellspacing="0" summary="shared key">
<tr>
<td>
- <?php set_checked($pconfig['autokey_enable'],$chk); ?>
+ <?php set_checked($pconfig['autokey_enable'], $chk); ?>
<input name="autokey_enable" type="checkbox" value="yes" <?=$chk;?> onclick="autokey_change()" />
</td>
<td>
@@ -832,9 +889,10 @@ if ($savemsg)
<?php
$cipherlist = openvpn_get_cipherlist();
foreach ($cipherlist as $name => $desc):
- $selected = "";
- if ($name == $pconfig['crypto'])
- $selected = " selected=\"selected\"";
+ $selected = "";
+ if ($name == $pconfig['crypto']) {
+ $selected = " selected=\"selected\"";
+ }
?>
<option value="<?=$name;?>"<?=$selected?>>
<?=htmlspecialchars($desc);?>
@@ -851,8 +909,9 @@ if ($savemsg)
$digestlist = openvpn_get_digestlist();
foreach ($digestlist as $name => $desc):
$selected = "";
- if ($name == $pconfig['digest'])
+ if ($name == $pconfig['digest']) {
$selected = " selected=\"selected\"";
+ }
?>
<option value="<?=$name;?>"<?=$selected?>>
<?=htmlspecialchars($desc);?>
@@ -870,8 +929,9 @@ if ($savemsg)
$engines = openvpn_get_engines();
foreach ($engines as $name => $desc):
$selected = "";
- if ($name == $pconfig['engine'])
+ if ($name == $pconfig['engine']) {
$selected = " selected=\"selected\"";
+ }
?>
<option value="<?=$name;?>"<?=$selected?>>
<?=htmlspecialchars($desc);?>
@@ -959,11 +1019,12 @@ if ($savemsg)
<select name="compression" class="formselect">
<?php
foreach ($openvpn_compression_modes as $cmode => $cmodedesc):
- $selected = "";
- if ($cmode == $pconfig['compression'])
- $selected = " selected=\"selected\"";
+ $selected = "";
+ if ($cmode == $pconfig['compression']) {
+ $selected = " selected=\"selected\"";
+ }
?>
- <option value="<?= $cmode ?>" <?= $selected ?>><?= $cmodedesc ?></option>
+ <option value="<?= $cmode ?>" <?= $selected ?>><?= $cmodedesc ?></option>
<?php endforeach; ?>
</select>
<br />
@@ -976,7 +1037,7 @@ if ($savemsg)
<table border="0" cellpadding="2" cellspacing="0" summary="type-of-service">
<tr>
<td>
- <?php set_checked($pconfig['passtos'],$chk); ?>
+ <?php set_checked($pconfig['passtos'], $chk); ?>
<input name="passtos" type="checkbox" value="yes" <?=$chk;?> />
</td>
<td>
@@ -995,7 +1056,7 @@ if ($savemsg)
<table border="0" cellpadding="2" cellspacing="0" summary="disable-ipv6">
<tr>
<td>
- <?php set_checked($pconfig['no_tun_ipv6'],$chk); ?>
+ <?php set_checked($pconfig['no_tun_ipv6'], $chk); ?>
<input name="no_tun_ipv6" type="checkbox" value="yes" <?=$chk;?> />
</td>
<td>
@@ -1014,7 +1075,7 @@ if ($savemsg)
<table border="0" cellpadding="2" cellspacing="0" summary="dont-pull-routes">
<tr>
<td>
- <?php set_checked($pconfig['route_no_pull'],$chk); ?>
+ <?php set_checked($pconfig['route_no_pull'], $chk); ?>
<input name="route_no_pull" type="checkbox" value="yes" <?=$chk;?> />
</td>
<td>
@@ -1033,7 +1094,7 @@ if ($savemsg)
<table border="0" cellpadding="2" cellspacing="0" summary="dont-exec-routes">
<tr>
<td>
- <?php set_checked($pconfig['route_no_exec'],$chk); ?>
+ <?php set_checked($pconfig['route_no_exec'], $chk); ?>
<input name="route_no_exec" type="checkbox" value="yes" <?=$chk;?> />
</td>
<td>
@@ -1070,14 +1131,15 @@ if ($savemsg)
</tr>
<tr id="comboboxVerbosityLevel">
- <td width="22%" valign="top" class="vncell"><?=gettext("Verbosity level");?></td>
- <td width="78%" class="vtable">
+ <td width="22%" valign="top" class="vncell"><?=gettext("Verbosity level");?></td>
+ <td width="78%" class="vtable">
<select name="verbosity_level" class="formselect">
<?php
foreach ($openvpn_verbosity_level as $verb_value => $verb_desc):
$selected = "";
- if ($pconfig['verbosity_level'] == $verb_value)
+ if ($pconfig['verbosity_level'] == $verb_value) {
$selected = "selected=\"selected\"";
+ }
?>
<option value="<?=$verb_value;?>" <?=$selected;?>><?=$verb_desc;?></option>
<?php endforeach; ?>
@@ -1088,7 +1150,7 @@ if ($savemsg)
<strong>default</strong>-<strong>4</strong> -- <?=gettext("Normal usage range"); ?>. <br />
<strong>5</strong> -- <?=gettext("Output R and W characters to the console for each packet read and write, uppercase is used for TCP/UDP packets and lowercase is used for TUN/TAP packets"); ?>. <br />
<strong>6</strong>-<strong>11</strong> -- <?=gettext("Debug info range"); ?>.
- </td>
+ </td>
</tr>
</table>
@@ -1139,10 +1201,11 @@ if ($savemsg)
<tbody>
<?php
$i = 0;
- foreach($a_client as $client):
+ foreach ($a_client as $client):
$disabled = "NO";
- if (isset($client['disable']))
+ if (isset($client['disable'])) {
$disabled = "YES";
+ }
$server = "{$client['server_addr']}:{$client['server_port']}";
?>
<tr ondblclick="document.location='vpn_openvpn_client.php?act=edit&amp;id=<?=$i;?>'">
@@ -1197,11 +1260,12 @@ useproxy_changed();
/* local utility functions */
-function set_checked($var,& $chk) {
- if($var)
+function set_checked($var, & $chk) {
+ if ($var) {
$chk = "checked=\"checked\"";
- else
+ } else {
$chk = "";
+ }
}
?>
OpenPOWER on IntegriCloud