Commit 78148368 authored by Ad Schellevis's avatar Ad Schellevis

(legacy) vpn_openvpn_client.php add duplicate option + some style fixes and...

(legacy) vpn_openvpn_client.php add duplicate option + some style fixes and cleanups. closes https://github.com/opnsense/core/issues/676
parent 2d531c30
<?php <?php
/* /*
Copyright (C) 2014-2015 Deciso B.V. Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2008 Shrew Soft Inc. Copyright (C) 2008 Shrew Soft Inc.
All rights reserved. All rights reserved.
...@@ -44,9 +44,13 @@ $a_client = &$config['openvpn']['openvpn-client']; ...@@ -44,9 +44,13 @@ $a_client = &$config['openvpn']['openvpn-client'];
$vpnid = 0; $vpnid = 0;
$act = null; $act = null;
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (isset($_GET['id']) && is_numericint($_GET['id'])) { if (isset($_GET['dup']) && isset($a_client[$_GET['dup']])) {
$configId = $_GET['dup'];
} elseif (isset($_GET['id']) && isset($a_client[$_GET['id']])) {
$id = $_GET['id']; $id = $_GET['id'];
$configId = $id;
} }
if (isset($_GET['act'])) { if (isset($_GET['act'])) {
$act = $_GET['act']; $act = $_GET['act'];
} }
...@@ -60,7 +64,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -60,7 +64,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['verbosity_level'] = 1; // Default verbosity is 1 $pconfig['verbosity_level'] = 1; // Default verbosity is 1
// edit existing. // edit existing.
if ($act=="edit" && isset($id) && $a_client[$id]) { if (isset($configId)) {
// 1 on 1 copy of config attributes // 1 on 1 copy of config attributes
$copy_fields = "auth_user,auth_pass,disable,mode,protocol,interface $copy_fields = "auth_user,auth_pass,disable,mode,protocol,interface
,local_port,server_addr,server_port,resolve_retry ,local_port,server_addr,server_port,resolve_retry
...@@ -71,8 +75,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -71,8 +75,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
foreach (explode(",", $copy_fields) as $fieldname) { foreach (explode(",", $copy_fields) as $fieldname) {
$fieldname = trim($fieldname); $fieldname = trim($fieldname);
if (isset($a_client[$id][$fieldname])) { if (isset($a_client[$configId][$fieldname])) {
$pconfig[$fieldname] = $a_client[$id][$fieldname]; $pconfig[$fieldname] = $a_client[$configId][$fieldname];
} elseif (!isset($pconfig[$fieldname])) { } elseif (!isset($pconfig[$fieldname])) {
// initialize element // initialize element
$pconfig[$fieldname] = null; $pconfig[$fieldname] = null;
...@@ -80,24 +84,24 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -80,24 +84,24 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} }
// load / convert // load / convert
if (!empty($a_client[$id]['ipaddr'])) { if (!empty($a_client[$configId]['ipaddr'])) {
$pconfig['interface'] = $pconfig['interface'] . '|' . $a_client[$id]['ipaddr']; $pconfig['interface'] = $pconfig['interface'] . '|' . $a_client[$configId]['ipaddr'];
} }
if (isset($a_client[$id]['tls'])) { if (isset($a_client[$configId]['tls'])) {
$pconfig['tls'] = base64_decode($a_client[$id]['tls']); $pconfig['tls'] = base64_decode($a_client[$configId]['tls']);
} else { } else {
$pconfig['tls'] = null; $pconfig['tls'] = null;
$pconfig['tlsauth_enable'] = null; $pconfig['tlsauth_enable'] = null;
} }
if (isset($a_client[$id]['shared_key'])) { if (isset($a_client[$configId]['shared_key'])) {
$pconfig['shared_key'] = base64_decode($a_client[$id]['shared_key']); $pconfig['shared_key'] = base64_decode($a_client[$configId]['shared_key']);
} else { } else {
$pconfig['shared_key'] = null ; $pconfig['shared_key'] = null ;
} }
if (isset($id) && $a_client[$id]) { if (isset($id)) {
$vpnid = $a_client[$id]['vpnid']; $vpnid = $a_client[$id]['vpnid'];
} }
} elseif ($act=="new") { } elseif ($act=="new") {
...@@ -119,7 +123,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -119,7 +123,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} }
} }
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['id']) && is_numericint($_POST['id'])) { if (isset($_POST['id']) && isset($a_client[$_POST['id']])) {
$id = $_POST['id']; $id = $_POST['id'];
} }
if (isset($_POST['act'])) { if (isset($_POST['act'])) {
...@@ -128,7 +132,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -128,7 +132,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if ($act == "del") { if ($act == "del") {
// remove client // remove client
if (!isset($id) || !isset($a_client[$id])) { if (!isset($id)) {
header("Location: vpn_openvpn_client.php"); header("Location: vpn_openvpn_client.php");
exit; exit;
} }
...@@ -142,7 +146,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -142,7 +146,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig = $_POST; $pconfig = $_POST;
$input_errors = array(); $input_errors = array();
if (isset($id) && $a_client[$id]) { if (isset($id)) {
$vpnid = $a_client[$id]['vpnid']; $vpnid = $a_client[$id]['vpnid'];
} }
if (isset($pconfig['mode']) && $pconfig['mode'] != "p2p_shared_key") { if (isset($pconfig['mode']) && $pconfig['mode'] != "p2p_shared_key") {
...@@ -297,7 +301,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -297,7 +301,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$client['shared_key'] = base64_encode($pconfig['shared_key']); $client['shared_key'] = base64_encode($pconfig['shared_key']);
} }
if (isset($id) && isset($a_client[$id])) { if (isset($id)) {
$a_client[$id] = $client; $a_client[$id] = $client;
} else { } else {
$a_client[] = $client; $a_client[] = $client;
...@@ -446,21 +450,17 @@ endif; ?> ...@@ -446,21 +450,17 @@ endif; ?>
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<?php <?php
if (isset($input_errors) && count($input_errors) > 0) { if (isset($input_errors) && count($input_errors) > 0) {
print_input_errors($input_errors); print_input_errors($input_errors);
} }
if (isset($savemsg)) { if (isset($savemsg)) {
print_info_box($savemsg); print_info_box($savemsg);
} }?>
?>
<section class="col-xs-12"> <section class="col-xs-12">
<div class="tab-content content-box col-xs-12"> <div class="tab-content content-box col-xs-12">
<?php if ($act=="new" || $act=="edit") : <?php
?> if ($act=="new" || $act=="edit") :?>
<form action="vpn_openvpn_client.php" method="post" name="iform" id="iform"> <form action="vpn_openvpn_client.php" method="post" name="iform" id="iform">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped"> <table class="table table-striped">
...@@ -488,17 +488,14 @@ if (isset($savemsg)) { ...@@ -488,17 +488,14 @@ if (isset($savemsg)) {
$openvpn_client_modes = array( $openvpn_client_modes = array(
'p2p_tls' => gettext("Peer to Peer ( SSL/TLS )"), 'p2p_tls' => gettext("Peer to Peer ( SSL/TLS )"),
'p2p_shared_key' => gettext("Peer to Peer ( Shared Key )") ); 'p2p_shared_key' => gettext("Peer to Peer ( Shared Key )") );
foreach ($openvpn_client_modes as $name => $desc) : foreach ($openvpn_client_modes as $name => $desc) :
$selected = ""; $selected = "";
if ($pconfig['mode'] == $name) { if ($pconfig['mode'] == $name) {
$selected = "selected=\"selected\""; $selected = "selected=\"selected\"";
} }?>
?> <option value="<?=$name;?>" <?=$selected;?>><?=$desc;?></option>
<option value="<?=$name;
?>" <?=$selected;
?>><?=$desc;?></option>
<?php <?php
endforeach; ?> endforeach; ?>
</select> </select>
</td> </td>
</tr> </tr>
...@@ -507,17 +504,14 @@ endforeach; ?> ...@@ -507,17 +504,14 @@ endforeach; ?>
<td> <td>
<select name='protocol' class="form-control"> <select name='protocol' class="form-control">
<?php <?php
foreach (array("UDP", "UDP6", "TCP", "TCP6") as $prot) : foreach (array("UDP", "UDP6", "TCP", "TCP6") as $prot) :
$selected = ""; $selected = "";
if ($pconfig['protocol'] == $prot) { if ($pconfig['protocol'] == $prot) {
$selected = "selected=\"selected\""; $selected = "selected=\"selected\"";
} }?>
?> <option value="<?=$prot;?>" <?=$selected;?>><?=$prot;?></option>
<option value="<?=$prot;
?>" <?=$selected;
?>><?=$prot;?></option>
<?php <?php
endforeach; ?> endforeach; ?>
</select> </select>
</td> </td>
</tr> </tr>
...@@ -525,16 +519,13 @@ endforeach; ?> ...@@ -525,16 +519,13 @@ endforeach; ?>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Device mode");?></td> <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Device mode");?></td>
<td> <td>
<select name='dev_mode' class="form-control" onchange="dev_mode_change()"> <select name='dev_mode' class="form-control" onchange="dev_mode_change()">
<?php <?php
foreach (array("tun", "tap") as $mode) : foreach (array("tun", "tap") as $mode) :
$selected = ""; $selected = "";
if ($pconfig['dev_mode'] == $mode) { if ($pconfig['dev_mode'] == $mode) {
$selected = "selected=\"selected\""; $selected = "selected=\"selected\"";
} }?>
?> <option value="<?=$mode;?>" <?=$selected;?>><?=$mode;?></option>
<option value="<?=$mode;
?>" <?=$selected;
?>><?=$mode;?></option>
<?php <?php
endforeach; ?> endforeach; ?>
</select> </select>
...@@ -547,15 +538,15 @@ endforeach; ?> ...@@ -547,15 +538,15 @@ endforeach; ?>
<?php <?php
$interfaces = get_configured_interface_with_descr(); $interfaces = get_configured_interface_with_descr();
$carplist = get_configured_carp_interface_list(); $carplist = get_configured_carp_interface_list();
foreach ($carplist as $cif => $carpip) { foreach ($carplist as $cif => $carpip) {
$interfaces[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")"; $interfaces[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")";
} }
$aliaslist = get_configured_ip_aliases_list(); $aliaslist = get_configured_ip_aliases_list();
foreach ($aliaslist as $aliasip => $aliasif) { foreach ($aliaslist as $aliasip => $aliasif) {
$interfaces[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")"; $interfaces[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
} }
$grouplist = return_gateway_groups_array(); $grouplist = return_gateway_groups_array();
foreach ($grouplist as $name => $group) { foreach ($grouplist as $name => $group) {
if ($group['ipprotocol'] != inet) { if ($group['ipprotocol'] != inet) {
continue; continue;
} }
...@@ -565,20 +556,17 @@ foreach ($grouplist as $name => $group) { ...@@ -565,20 +556,17 @@ foreach ($grouplist as $name => $group) {
$vipif = $group[0]['int']; $vipif = $group[0]['int'];
} }
$interfaces[$name] = "GW Group {$name}"; $interfaces[$name] = "GW Group {$name}";
} }
$interfaces['lo0'] = "Localhost"; $interfaces['lo0'] = "Localhost";
$interfaces['any'] = "any"; $interfaces['any'] = "any";
foreach ($interfaces as $iface => $ifacename) : foreach ($interfaces as $iface => $ifacename) :
$selected = ""; $selected = "";
if ($iface == $pconfig['interface']) { if ($iface == $pconfig['interface']) {
$selected = "selected=\"selected\""; $selected = "selected=\"selected\"";
} }?>
?> <option value="<?=$iface;?>" <?=$selected;?>><?=htmlspecialchars($ifacename);?></option>
<option value="<?=$iface;
?>" <?=$selected;
?>><?=htmlspecialchars($ifacename);?></option>
<?php <?php
endforeach; ?> endforeach; ?>
</select> <br /> </select> <br />
</td> </td>
</tr> </tr>
...@@ -625,7 +613,7 @@ endforeach; ?> ...@@ -625,7 +613,7 @@ endforeach; ?>
<option value="basic" <?=$pconfig['proxy_authtype'] == "ntlm" ? "selected=\"selected\"" : "" ?> > <?=gettext("ntlm"); ?></option> <option value="basic" <?=$pconfig['proxy_authtype'] == "ntlm" ? "selected=\"selected\"" : "" ?> > <?=gettext("ntlm"); ?></option>
</select> </select>
<div style="display:none" id="proxy_authtype_opts"> <div style="display:none" id="proxy_authtype_opts">
<div><?=gettext("Username"); ?> <br/></div <div><?=gettext("Username"); ?> <br/></div>
<div><input name="proxy_user" id="proxy_user" class="form-control unknown" type="text" size="20" value="<?=$pconfig['proxy_user'];?>" /></div> <div><input name="proxy_user" id="proxy_user" class="form-control unknown" type="text" size="20" value="<?=$pconfig['proxy_user'];?>" /></div>
<div><?=gettext("Password"); ?> </div> <div><?=gettext("Password"); ?> </div>
<div><input name="proxy_passwd" id="proxy_passwd" type="password" class="form-control pwd" size="20" value="<?=$pconfig['proxy_passwd'];?>" /></div> <div><input name="proxy_passwd" id="proxy_passwd" type="password" class="form-control pwd" size="20" value="<?=$pconfig['proxy_passwd'];?>" /></div>
...@@ -678,15 +666,14 @@ endforeach; ?> ...@@ -678,15 +666,14 @@ endforeach; ?>
<td> <td>
<input name="tlsauth_enable" id="tlsauth_enable" type="checkbox" value="yes" <?= !empty($pconfig['tlsauth_enable']) ? "checked=\"checked\"" : "";?> onclick="tlsauth_change()" /> <input name="tlsauth_enable" id="tlsauth_enable" type="checkbox" value="yes" <?= !empty($pconfig['tlsauth_enable']) ? "checked=\"checked\"" : "";?> onclick="tlsauth_change()" />
<?=gettext("Enable authentication of TLS packets"); ?>. <?=gettext("Enable authentication of TLS packets"); ?>.
<?php
<?php if (empty($pconfig['tls'])) : if (empty($pconfig['tls'])) :?>
?>
<div id="tlsauth_opts"> <div id="tlsauth_opts">
<input name="autotls_enable" id="autotls_enable" type="checkbox" value="yes"<?= !empty($pconfig['autotls_enable']) ? "checked=\"checked\"" : "";?> onclick="autotls_change()" /> <input name="autotls_enable" id="autotls_enable" type="checkbox" value="yes" <?= !empty($pconfig['autotls_enable']) ? "checked=\"checked\"" : "";?> onclick="autotls_change()" >
<?=gettext("Automatically generate a shared TLS authentication key"); ?>. <?=gettext("Automatically generate a shared TLS authentication key"); ?>.
</div> </div>
<?php <?php
endif; ?> endif; ?>
<div id="autotls_opts"> <div id="autotls_opts">
<textarea name="tls" cols="65" rows="7" class="formpre"><?=isset($pconfig['tls'])?$pconfig['tls']:"";?></textarea> <textarea name="tls" cols="65" rows="7" class="formpre"><?=isset($pconfig['tls'])?$pconfig['tls']:"";?></textarea>
<p class="text-muted"><em><small><?=gettext("Paste your shared key here"); ?>.</small></em></p> <p class="text-muted"><em><small><?=gettext("Paste your shared key here"); ?>.</small></em></p>
...@@ -696,37 +683,32 @@ endif; ?> ...@@ -696,37 +683,32 @@ endif; ?>
<tr id="tls_ca"> <tr id="tls_ca">
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Peer Certificate Authority"); ?></td> <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Peer Certificate Authority"); ?></td>
<td> <td>
<?php if (isset($config['ca'])) : <?php
?> if (isset($config['ca'])) :?>
<select name='caref' class="form-control"> <select name='caref' class="form-control">
<?php <?php
foreach ($config['ca'] as $ca) : foreach ($config['ca'] as $ca) :
$selected = ""; $selected = "";
if (isset($pconfig['caref']) && $pconfig['caref'] == $ca['refid']) { if (isset($pconfig['caref']) && $pconfig['caref'] == $ca['refid']) {
$selected = "selected=\"selected\""; $selected = "selected=\"selected\"";
} }?>
?> <option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['descr'];?></option>
<option value="<?=$ca['refid'];
?>" <?=$selected;
?>><?=$ca['descr'];?></option>
<?php <?php
endforeach; ?> endforeach; ?>
</select> </select>
<?php <?php
else : else :?>
?> <b><?=gettext("No Certificate Authorities defined.");?></b> <br />
<b><?=gettext("No Certificate Authorities defined."); <?=gettext("Create one under");?> <a href="system_camanager.php"><?=gettext("System: Certificates");?></a>.
?></b> <br /><?=gettext("Create one under"); <?php
?> <a href="system_camanager.php"><?=gettext("System: Certificates");?></a>. endif; ?>
<?php
endif; ?>
</td> </td>
</tr> </tr>
<tr id="tls_cert"> <tr id="tls_cert">
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Client Certificate"); ?></td> <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Client Certificate"); ?></td>
<td> <td>
<select name='certref' class="form-control"> <select name='certref' class="form-control">
<?php <?php
foreach (isset($config['cert']) ? $config['cert'] : array() as $cert) : foreach (isset($config['cert']) ? $config['cert'] : array() as $cert) :
$selected = ""; $selected = "";
$caname = ""; $caname = "";
...@@ -746,37 +728,31 @@ endif; ?> ...@@ -746,37 +728,31 @@ endif; ?>
} }
if (is_cert_revoked($cert)) { if (is_cert_revoked($cert)) {
$revoked = " *Revoked"; $revoked = " *Revoked";
} }?>
?> <option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['descr'] . $caname . $inuse . $revoked;?></option>
<option value="<?=$cert['refid']; <?php
?>" <?=$selected;
?>><?=$cert['descr'] . $caname . $inuse . $revoked;?></option>
<?php
endforeach; ?> endforeach; ?>
<option value="" <?=empty($pconfig['certref'])? "selected=\"selected\"" : ""; <option value="" <?=empty($pconfig['certref'])? "selected=\"selected\"" : "";?>>
?>> <?=gettext("None"); <?=gettext("None");?> <?=gettext("(Username and Password required)");?>
?> <?=gettext("(Username and Password required)");?></option> </option>
</select> </select>
<?php if (!isset($config['cert']) || count($config['cert']) == 0) :
?>
<b><?=gettext("No Certificates defined.");
?></b> <br /><?=gettext("Create one under");
?> <a href="system_certmanager.php"><?=gettext("System: Certificates");
?></a> <?=gettext("if one is required for this connection.");?>
<?php <?php
endif; ?> if (!isset($config['cert']) || count($config['cert']) == 0) :?>
<b><?=gettext("No Certificates defined.");?></b> <br /><?=gettext("Create one under");?>
<a href="system_certmanager.php"><?=gettext("System: Certificates");?></a> <?=gettext("if one is required for this connection.");?>
<?php
endif; ?>
</td> </td>
</tr> </tr>
<tr id="psk"> <tr id="psk">
<td><?=gettext("Shared Key"); ?></td> <td><?=gettext("Shared Key"); ?></td>
<td> <td>
<?php if (empty($pconfig['shared_key'])) : <?php
?> if (empty($pconfig['shared_key'])) :?>
<input name="autokey_enable" id="autokey_enable" type="checkbox" value="yes" <?= !empty($pconfig['autokey_enable']) ? "checked=\"checked\"" : "";?> onclick="autokey_change()" /> <input name="autokey_enable" id="autokey_enable" type="checkbox" value="yes" <?= !empty($pconfig['autokey_enable']) ? "checked=\"checked\"" : "";?> onclick="autokey_change()" />
<?=gettext("Automatically generate a shared key"); ?>. <?=gettext("Automatically generate a shared key"); ?>.
<?php
<?php endif; ?>
endif; ?>
<div id="autokey_opts"> <div id="autokey_opts">
<textarea name="shared_key" cols="65" rows="7" class="formpre"><?=isset($pconfig['shared_key']) ? $pconfig['shared_key'] : "";?></textarea> <textarea name="shared_key" cols="65" rows="7" class="formpre"><?=isset($pconfig['shared_key']) ? $pconfig['shared_key'] : "";?></textarea>
<em><small><?=gettext("Paste your shared key here"); ?>.</small></em> <em><small><?=gettext("Paste your shared key here"); ?>.</small></em>
...@@ -787,17 +763,15 @@ endif; ?> ...@@ -787,17 +763,15 @@ endif; ?>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Encryption algorithm"); ?></td> <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Encryption algorithm"); ?></td>
<td> <td>
<select name="crypto" class="form-control"> <select name="crypto" class="form-control">
<?php <?php
$cipherlist = openvpn_get_cipherlist(); $cipherlist = openvpn_get_cipherlist();
foreach ($cipherlist as $name => $desc) : foreach ($cipherlist as $name => $desc) :
$selected = ""; $selected = "";
if ($name == $pconfig['crypto']) { if ($name == $pconfig['crypto']) {
$selected = " selected=\"selected\""; $selected = " selected=\"selected\"";
} }?>
?> <option value="<?=$name;?>"<?=$selected?>><?=htmlspecialchars($desc);?></option>
<option value="<?=$name; <?php
?>"<?=$selected?>><?=htmlspecialchars($desc);?></option>
<?php
endforeach; ?> endforeach; ?>
</select> </select>
</td> </td>
...@@ -806,17 +780,15 @@ endif; ?> ...@@ -806,17 +780,15 @@ endif; ?>
<td><a id="help_for_digest" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Auth Digest Algorithm"); ?></td> <td><a id="help_for_digest" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Auth Digest Algorithm"); ?></td>
<td> <td>
<select name="digest" class="form-control"> <select name="digest" class="form-control">
<?php <?php
$digestlist = openvpn_get_digestlist(); $digestlist = openvpn_get_digestlist();
foreach ($digestlist as $name => $desc) : foreach ($digestlist as $name => $desc) :
$selected = ""; $selected = "";
if ($name == $pconfig['digest']) { if ($name == $pconfig['digest']) {
$selected = " selected=\"selected\""; $selected = " selected=\"selected\"";
} }?>
?> <option value="<?=$name;?>"<?=$selected?>><?=htmlspecialchars($desc);?></option>
<option value="<?=$name; <?php
?>"<?=$selected?>><?=htmlspecialchars($desc);?></option>
<?php
endforeach; ?> endforeach; ?>
</select> </select>
<div class="hidden" for="help_for_digest"> <div class="hidden" for="help_for_digest">
...@@ -828,17 +800,15 @@ endif; ?> ...@@ -828,17 +800,15 @@ endif; ?>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Hardware Crypto"); ?></td> <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Hardware Crypto"); ?></td>
<td> <td>
<select name="engine" class="form-control"> <select name="engine" class="form-control">
<?php <?php
$engines = openvpn_get_engines(); $engines = openvpn_get_engines();
foreach ($engines as $name => $desc) : foreach ($engines as $name => $desc) :
$selected = ""; $selected = "";
if ($name == $pconfig['engine']) { if ($name == $pconfig['engine']) {
$selected = " selected=\"selected\""; $selected = " selected=\"selected\"";
} }?>
?> <option value="<?=$name;?>"<?=$selected?>><?=htmlspecialchars($desc);?></option>
<option value="<?=$name; <?php
?>"<?=$selected?>><?=htmlspecialchars($desc);?></option>
<?php
endforeach; ?> endforeach; ?>
</select> </select>
</td> </td>
...@@ -1016,9 +986,7 @@ endif; ?> ...@@ -1016,9 +986,7 @@ endif; ?>
</div> </div>
</td> </td>
</tr> </tr>
</table> </table>
<br /> <br />
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="icons"> <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="icons">
<tr> <tr>
...@@ -1026,42 +994,37 @@ endif; ?> ...@@ -1026,42 +994,37 @@ endif; ?>
<td width="78%"> <td width="78%">
<input name="save" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" /> <input name="save" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
<input name="act" type="hidden" value="<?=$act;?>" /> <input name="act" type="hidden" value="<?=$act;?>" />
<?php if (isset($id) && $a_client[$id]) : <?php
?> if (isset($id) && $a_client[$id]) :?>
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" /> <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
<?php <?php
endif; ?> endif; ?>
</td> </td>
</tr> </tr>
</table> </table>
</div> </div>
</form> </form>
<?php
<?php else:?>
else :
?>
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td> <td><?=gettext("Disabled"); ?></td>
<td width="10%" class="listhdrr"><?=gettext("Protocol"); ?></td> <td><?=gettext("Protocol"); ?></td>
<td width="30%" class="listhdrr"><?=gettext("Server"); ?></td> <td><?=gettext("Server"); ?></td>
<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td> <td><?=gettext("Description"); ?></td>
<td width="10%" class="list"></td> <td></td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
$i = 0; $i = 0;
foreach ($a_client as $client) : foreach ($a_client as $client) :
$disabled = "NO"; $disabled = "NO";
if (isset($client['disable'])) { if (isset($client['disable'])) {
$disabled = "YES"; $disabled = "YES";
} }
$server = "{$client['server_addr']}:{$client['server_port']}"; $server = "{$client['server_addr']}:{$client['server_port']}";?>
?>
<tr ondblclick="document.location='vpn_openvpn_client.php?act=edit&amp;id=<?=$i;?>'"> <tr ondblclick="document.location='vpn_openvpn_client.php?act=edit&amp;id=<?=$i;?>'">
<td> <td>
<?=$disabled;?> <?=$disabled;?>
...@@ -1076,24 +1039,28 @@ else : ...@@ -1076,24 +1039,28 @@ else :
<?=htmlspecialchars($client['description']);?> <?=htmlspecialchars($client['description']);?>
</td> </td>
<td> <td>
<a href="vpn_openvpn_client.php?act=edit&amp;id=<?=$i;?>" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a> <a href="vpn_openvpn_client.php?act=edit&amp;id=<?=$i;?>" class="btn btn-default btn-xs">
<a id="del_<?=$i; <span class="glyphicon glyphicon-pencil"></span>
?>" title="<?=gettext("delete client"); ?>" class="act_delete btn btn-default btn-xs"><span class="fa fa-trash text-muted"></span></a> </a>
<a id="del_<?=$i;?>" title="<?=gettext("delete client"); ?>" class="act_delete btn btn-default btn-xs">
<span class="fa fa-trash text-muted"></span>
</a>
<a href="vpn_openvpn_client.php?act=new&dup=<?=$i;?>" class="btn btn-default btn-xs" data-toggle="tooltip" title="<?=gettext("clone rule");?>">
<span class="fa fa-clone text-muted"></span>
</a>
</td> </td>
</tr> </tr>
<?php <?php
$i++; $i++;
endforeach; endforeach;?>
?>
</tbody> </tbody>
</table> </table>
<?php
<?php endif; ?>
endif; ?>
</div> </div>
</section> </section>
</div> </div>
</div> </div>
</section> </section>
<?php include("foot.inc"); ?> <?php include("foot.inc"); ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment