Commit a52e5e1d authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(legacy) fix spacing, add toggle in vpn_openvpn_server.php

(cherry picked from commit 3f2c5304)
parent 0ad90288
......@@ -127,7 +127,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['id']) && is_numericint($_POST['id'])) {
if (isset($_POST['id']) && isset($a_server[$_POST['id']])) {
$id = $_POST['id'];
}
if (isset($_POST['act'])) {
......@@ -136,15 +136,25 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if ($act == "del") {
// action delete
if (!isset($a_server[$id])) {
if (isset($a_server[$id])) {
openvpn_delete('server', $a_server[$id]);
unset($a_server[$id]);
write_config();
}
header("Location: vpn_openvpn_server.php");
exit;
} elseif ($act == "toggle") {
if (isset($id)) {
if (isset($a_server[$id]['disable'])) {
unset($a_server[$id]['disable']);
} else {
$a_server[$id]['disable'] = true;
}
if (!empty($a_server[$id])) {
openvpn_delete('server', $a_server[$id]);
}
unset($a_server[$id]);
openvpn_resync('server', $a_server[$id]);
write_config();
}
header("Location: vpn_openvpn_server.php");
exit;
} else {
// action add/update
$input_errors = array();
......@@ -439,6 +449,14 @@ $( document ).ready(function() {
}]
});
});
// link toggle buttons
$(".act_toggle").click(function(){
$.post(window.location, {act: 'toggle', id:$(this).data("id")}, function(data) {
location.reload();
});
});
// init form (old stuff)
if (document.iform != undefined) {
mode_change();
......@@ -700,24 +718,18 @@ function tuntap_change() {
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<?php
<?php
if (isset($input_errors) && count($input_errors) > 0) {
print_input_errors($input_errors);
}
if (isset($savemsg)) {
print_info_box($savemsg);
}
?>
}?>
<section class="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_server.php" method="post" name="iform" id="iform">
<div class="table-responsive">
<table class="table table-striped">
<tr>
......@@ -745,7 +757,7 @@ function tuntap_change() {
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Server Mode");?></td>
<td>
<select name='mode' id='mode' class="form-control" onchange='mode_change(); tuntap_change()'>
<?php
<?php
$openvpn_server_modes = array(
'p2p_tls' => gettext("Peer to Peer ( SSL/TLS )"),
'p2p_shared_key' => gettext("Peer to Peer ( Shared Key )"),
......@@ -756,12 +768,9 @@ function tuntap_change() {
$selected = "";
if ($pconfig['mode'] == $name) {
$selected = "selected=\"selected\"";
}
?>
<option value="<?=$name;
?>" <?=$selected;
?>><?=$desc;?></option>
<?php
}?>
<option value="<?=$name;?>" <?=$selected;?>><?=$desc;?></option>
<?php
endforeach; ?>
</select>
</td>
......@@ -770,7 +779,7 @@ function tuntap_change() {
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Backend for authentication");?></td>
<td>
<select name='authmode[]' id='authmode' class="form-control" multiple="multiple" size="5">
<?php
<?php
if (isset($pconfig['authmode'])) {
$authmodes = explode(",", $pconfig['authmode']);
} else {
......@@ -781,10 +790,10 @@ function tuntap_change() {
$selected = "";
if (in_array($auth_key, $authmodes)) {
$selected = "selected=\"selected\"";
}
?>
}?>
<option value="<?=htmlspecialchars($auth_key); ?>" <?=$selected; ?>><?=htmlspecialchars($auth_server['name']);?></option>
<?php endforeach; ?>
<?php
endforeach; ?>
</select>
</td>
</tr>
......@@ -792,17 +801,14 @@ function tuntap_change() {
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Protocol");?></td>
<td>
<select name='protocol' class="form-control">
<?php
<?php
foreach (array("UDP", "UDP6", "TCP", "TCP6") as $prot) :
$selected = "";
if ($pconfig['protocol'] == $prot) {
$selected = "selected=\"selected\"";
}
?>
<option value="<?=$prot;
?>" <?=$selected;
?>><?=$prot;?></option>
<?php
}?>
<option value="<?=$prot;?>" <?=$selected;?>><?=$prot;?></option>
<?php
endforeach; ?>
</select>
</td>
......@@ -811,7 +817,7 @@ function tuntap_change() {
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Device Mode"); ?></td>
<td>
<select name="dev_mode" class="form-control" onchange='tuntap_change()'>
<?php
<?php
foreach (array("tun", "tap") as $device) :
$selected = "";
if (! empty($pconfig['dev_mode'])) {
......@@ -822,12 +828,9 @@ function tuntap_change() {
if ($device == "tun") {
$selected = "selected=\"selected\"";
}
}
?>
<option value="<?=$device;
?>" <?=$selected;
?>><?=$device;?></option>
<?php
}?>
<option value="<?=$device;?>" <?=$selected;?>><?=$device;?></option>
<?php
endforeach; ?>
</select>
</td>
......@@ -836,7 +839,7 @@ function tuntap_change() {
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Interface"); ?></td>
<td>
<select name="interface" class="form-control">
<?php
<?php
$interfaces = get_configured_interface_with_descr();
$carplist = get_configured_carp_interface_list();
foreach ($carplist as $cif => $carpip) {
......@@ -867,7 +870,8 @@ function tuntap_change() {
}
?>
<option value="<?=$iface; ?>"<?=$selected;?>><?=htmlspecialchars($ifacename);?></option>
<?php endforeach; ?>
<?php
endforeach; ?>
</select> <br />
</td>
</tr>
......@@ -887,7 +891,7 @@ function tuntap_change() {
</td>
</tr>
<tr>
<td colspan="2" class="list" height="12"></td>
<td colspan="2" height="12"></td>
</tr>
<tr>
<td colspan="2"><?=gettext("Cryptographic Settings"); ?></td>
......@@ -936,39 +940,38 @@ endif; ?>
<tr id="tls_ca">
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Peer Certificate Authority"); ?></td>
<td>
<?php if (isset($config['ca'])) :
?>
<?php
if (isset($config['ca'])) :?>
<select name='caref' class="form-control">
<?php
<?php
foreach ($config['ca'] as $ca) :
$selected = "";
if ($pconfig['caref'] == $ca['refid']) {
$selected = "selected=\"selected\"";
}
?>
<option value="<?=htmlspecialchars($ca['refid']);
?>" <?=$selected;
?>><?=htmlspecialchars($ca['descr']);?></option>
<?php
<option value="<?=htmlspecialchars($ca['refid']);?>" <?=$selected;?>>
<?=htmlspecialchars($ca['descr']);?>
</option>
<?php
endforeach; ?>
</select>
<?php
else :
?>
<b><?=gettext("No Certificate Authorities defined.");
?></b> <br /><?=gettext("Create one under")?> <a href="system_camanager.php"> <?=gettext("System: Certificates");?></a>.
<?php
endif; ?>
<?php
else :?>
<b><?=gettext("No Certificate Authorities defined.");?></b>
<br /><?=gettext("Create one under")?> <a href="system_camanager.php"> <?=gettext("System: Certificates");?></a>.
<?php
endif; ?>
</td>
</tr>
<tr id="tls_crl">
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Peer Certificate Revocation List"); ?></td>
<td>
<?php if (isset($config['crl'])) :
?>
<?php
if (isset($config['crl'])) :?>
<select name='crlref' class="form-control">
<option value="">None</option>
<?php
<?php
foreach ($config['crl'] as $crl) :
if (isset($acrl['refid'])) {
$selected = "";
......@@ -980,31 +983,28 @@ endif; ?>
$selected = "selected=\"selected\"";
}
}
}
?>
<option value="<?=htmlspecialchars($crl['refid']);
?>" <?=$selected;
?>><?=htmlspecialchars($crl['descr'] . $caname);?></option>
<?php
}?>
<option value="<?=htmlspecialchars($crl['refid']);?>" <?=$selected;?>>
<?=htmlspecialchars($crl['descr'] . $caname);?>
</option>
<?php
endforeach; ?>
</select>
<?php
else :
?>
<b><?=gettext("No Certificate Revocation Lists (CRLs) defined.");
?></b> <br /><?=gettext("Create one under");
?> <a href="system_crlmanager.php"><?=gettext("System: Certificates");?></a>.
<?php
endif; ?>
<?php
else :?>
<b><?=gettext("No Certificate Revocation Lists (CRLs) defined.");?></b>
<br /><?=gettext("Create one under");?> <a href="system_crlmanager.php"><?=gettext("System: Certificates");?></a>.
<?php
endif; ?>
</td>
</tr>
<tr id="tls_cert">
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Server Certificate"); ?></td>
<td>
<?php if (isset($config['cert'])) :
?>
<?php
if (isset($config['cert'])) :?>
<select name='certref' class="form-control">
<?php
<?php
foreach ($config['cert'] as $cert) :
$selected = "";
$caname = "";
......@@ -1026,27 +1026,25 @@ endif; ?>
$revoked = " *Revoked";
}
?>
<option value="<?=htmlspecialchars($cert['refid']);
?>" <?=$selected;
?>><?=htmlspecialchars($cert['descr'] . $caname . $inuse . $revoked);?></option>
<?php
<option value="<?=htmlspecialchars($cert['refid']);?>" <?=$selected;?>>
<?=htmlspecialchars($cert['descr'] . $caname . $inuse . $revoked);?>
</option>
<?php
endforeach; ?>
</select>
<?php
else :
?>
<b><?=gettext("No Certificates defined.");
?></b> <br /><?=gettext("Create one under");
?> <a href="system_certmanager.php"><?=gettext("System: Certificates");?></a>.
<?php
endif; ?>
<?php
else :?>
<b><?=gettext("No Certificates defined.");?></b>
<br /><?=gettext("Create one under");?> <a href="system_certmanager.php"><?=gettext("System: Certificates");?></a>.
<?php
endif; ?>
</td>
</tr>
<tr id="tls_dh">
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("DH Parameters Length"); ?></td>
<td>
<select name="dh_length" class="form-control">
<?php
<?php
foreach (array(1024, 2048, 4096) as $length) :
$selected = "";
if ($length == $pconfig['dh_length']) {
......@@ -1054,7 +1052,7 @@ endif; ?>
}
?>
<option<?=$selected?>><?=$length;?></option>
<?php
<?php
endforeach; ?>
</select>
<span>
......@@ -1065,8 +1063,8 @@ endif; ?>
<tr id="psk">
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Shared Key"); ?></td>
<td>
<?php if (empty($pconfig['shared_key'])) :
?>
<?php
if (empty($pconfig['shared_key'])) :?>
<table border="0" cellpadding="2" cellspacing="0" summary="shared key">
<tr>
<td>
......@@ -1079,8 +1077,8 @@ endif; ?>
</td>
</tr>
</table>
<?php
endif; ?>
<?php
endif; ?>
<table border="0" cellpadding="2" cellspacing="0" id="autokey_opts" summary="shared key">
<tr>
<td>
......@@ -1095,7 +1093,7 @@ endif; ?>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Encryption algorithm"); ?></td>
<td>
<select name="crypto" class="form-control">
<?php
<?php
$cipherlist = openvpn_get_cipherlist();
foreach ($cipherlist as $name => $desc) :
$selected = "";
......@@ -1106,7 +1104,7 @@ endif; ?>
<option value="<?=$name;?>"<?=$selected?>>
<?=htmlspecialchars($desc);?>
</option>
<?php
<?php
endforeach; ?>
</select>
</td>
......@@ -1115,7 +1113,7 @@ endif; ?>
<td><a id="help_for_digest" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Auth Digest Algorithm"); ?></td>
<td>
<select name="digest" class="form-control">
<?php
<?php
$digestlist = openvpn_get_digestlist();
foreach ($digestlist as $name => $desc) :
$selected = "";
......@@ -1126,7 +1124,8 @@ endif; ?>
<option value="<?=$name;?>"<?=$selected?>>
<?=htmlspecialchars($desc);?>
</option>
<?php endforeach; ?>
<?php
endforeach; ?>
</select>
<div class="hidden" for="help_for_digest">
<?php echo gettext("NOTE: Leave this set to SHA1 unless all clients are set to match. SHA1 is the default for OpenVPN."); ?>
......@@ -1137,7 +1136,7 @@ endif; ?>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Hardware Crypto"); ?></td>
<td>
<select name="engine" class="form-control">
<?php
<?php
$engines = openvpn_get_engines();
foreach ($engines as $name => $desc) :
$selected = "";
......@@ -1148,7 +1147,8 @@ endif; ?>
<option value="<?=$name;?>"<?=$selected?>>
<?=htmlspecialchars($desc);?>
</option>
<?php endforeach; ?>
<?php
endforeach; ?>
</select>
</td>
</tr>
......@@ -1159,7 +1159,7 @@ endif; ?>
<tr><td>
<select name="cert_depth" class="form-control">
<option value=""><?=gettext('Do Not Check') ?></option>
<?php
<?php
$openvpn_cert_depths = array(
1 => gettext('One (Client+Server)'),
2 => gettext('Two (Client+Intermediate+Server)'),
......@@ -1174,11 +1174,13 @@ endif; ?>
}
?>
<option value="<?= $depth ?>" <?= $selected ?>><?= $depthdesc ?></option>
<?php
<?php
endforeach; ?>
</select>
</td></tr>
<tr><td>
</td>
</tr>
<tr>
<td>
<div class="hidden" for="help_for_cert_depth">
<span>
<?=gettext("When a certificate-based client logs in, do not accept certificates below this depth. Useful for denying certificates made with intermediate CAs generated from the same CA as the server."); ?>
......@@ -1200,7 +1202,7 @@ endif; ?>
</td>
</tr>
<tr>
<td colspan="2" class="list" height="12"></td>
<td colspan="2" height="12"></td>
</tr>
<tr>
<td colspan="2"><?=gettext("Tunnel Settings"); ?></td>
......@@ -1250,7 +1252,7 @@ endif; ?>
<td width="22%" ><a id="help_for_serverbridge_interface" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Bridge Interface"); ?></td>
<td>
<select name="serverbridge_interface" class="form-control">
<?php
<?php
$serverbridge_interface['none'] = "none";
$serverbridge_interface = array_merge($serverbridge_interface, get_configured_interface_with_descr());
$carplist = get_configured_carp_interface_list();
......@@ -1267,11 +1269,10 @@ endif; ?>
$selected = "selected=\"selected\"";
}
?>
<option value="<?=$iface;
?>" <?=$selected;?>>
<option value="<?=$iface;?>" <?=$selected;?>>
<?=htmlspecialchars($ifacename);?>
</option>
<?php
<?php
endforeach; ?>
</select>
<div class="hidden" for="help_for_serverbridge_interface">
......@@ -1387,7 +1388,7 @@ endif; ?>
<td width="22%" ><a id="help_for_compression" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Compression"); ?></td>
<td>
<select name="compression" class="form-control">
<?php
<?php
foreach ($openvpn_compression_modes as $cmode => $cmodedesc) :
$selected = "";
if ($cmode == $pconfig['compression']) {
......@@ -1395,7 +1396,7 @@ endif; ?>
}
?>
<option value="<?= $cmode ?>" <?= $selected ?>><?= $cmodedesc ?></option>
<?php
<?php
endforeach; ?>
</select>
<div class="hidden" for="help_for_compression">
......@@ -1448,7 +1449,7 @@ endif; ?>
</td>
</tr>
<tr>
<td colspan="2" class="list" height="12"></td>
<td colspan="2" height="12"></td>
</tr>
<tr>
<td colspan="2"><?=gettext("Client Settings"); ?></td>
......@@ -1578,16 +1579,14 @@ endif; ?>
<?=gettext("Node Type"); ?>:&nbsp;
</span>
<select name='netbios_ntype' class="form-control">
<?php
<?php
foreach ($netbios_nodetypes as $type => $name) :
$selected = "";
if ($pconfig['netbios_ntype'] == $type) {
$selected = "selected=\"selected\"";
}
?>
<option value="<?=$type;
?>" <?=$selected;
?>><?=$name;?></option>
<option value="<?=$type;?>" <?=$selected;?>><?=$name;?></option>
<?php
endforeach; ?>
</select>
......@@ -1647,7 +1646,7 @@ endif; ?>
</td>
</tr>
<tr>
<td colspan="2" class="list" height="12"></td>
<td colspan="2" height="12"></td>
</tr>
<tr>
<td colspan="2"><?=gettext("Advanced configuration"); ?></td>
......@@ -1666,7 +1665,7 @@ endif; ?>
<td width="22%" ><a id="help_for_verbosity_level" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Verbosity level");?></td>
<td>
<select name="verbosity_level" class="form-control">
<?php
<?php
foreach ($openvpn_verbosity_level as $verb_value => $verb_desc) :
$selected = '';
if ($pconfig['verbosity_level'] == $verb_value) {
......@@ -1674,7 +1673,8 @@ endif; ?>
}
?>
<option value="<?=$verb_value; ?>" <?=$selected; ?>><?=$verb_desc;?></option>
<?php endforeach; ?>
<?php
endforeach; ?>
</select>
<div class="hidden" for="help_for_verbosity_level">
<?=gettext("Each level shows all info from the previous levels. Level 3 is recommended if you want a good summary of what's happening without being swamped by output."); ?><br /> <br />
......@@ -1690,66 +1690,57 @@ endif; ?>
<td width="78%">
<input name="save" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
<input name="act" type="hidden" value="<?=$act;?>" />
<?php if (isset($id) && $a_server[$id]) :
?>
<?php
if (isset($id) && $a_server[$id]) :?>
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
<?php
endif; ?>
<?php
endif; ?>
</td>
</tr>
</table>
</div>
</form>
<?php
else :
?>
<?php
else :?>
<table class="table table-striped">
<thead>
<tr>
<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
<td width="10%" class="listhdrr"><?=gettext("Protocol / Port"); ?></td>
<td width="30%" class="listhdrr"><?=gettext("Tunnel Network"); ?></td>
<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
<td width="10%" class="list"></td>
<td></td>
<td><?=gettext("Protocol / Port"); ?></td>
<td><?=gettext("Tunnel Network"); ?></td>
<td><?=gettext("Description"); ?></td>
<td></td>
</tr>
</thead>
<tbody>
<?php
<?php
$i = 0;
foreach ($a_server as $server) :
$disabled = "NO";
if (!empty($server['disable'])) {
$disabled = "YES";
}
?>
foreach ($a_server as $server) :?>
<tr>
<td ondblclick="document.location='vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>'">
<?=$disabled;?>
<td>
<a href="#" class="act_toggle" data-id="<?=$i;?>" data-toggle="tooltip" title="<?=(empty($server['disable'])) ? gettext("disable") : gettext("enable");?>">
<span class="glyphicon glyphicon-play <?=(empty($server['disable'])) ? "text-success" : "text-muted";?>"></span>
</a>
</td>
<td ondblclick="document.location='vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>'">
<?=htmlspecialchars($server['protocol']);
?> / <?=htmlspecialchars($server['local_port']);?>
<td>
<?=htmlspecialchars($server['protocol']);?> / <?=htmlspecialchars($server['local_port']);?>
</td>
<td ondblclick="document.location='vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>'">
<td>
<?=htmlspecialchars($server['tunnel_network']);?> <?=!empty($server['tunnel_networkv6']) ? "," :""?>
<?=htmlspecialchars($server['tunnel_networkv6']);?>
</td>
<td ondblclick="document.location='vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>'">
<td>
<?=htmlspecialchars($server['description']);?>
</td>
<td valign="middle">
<a href="vpn_openvpn_server.php?act=edit&amp;id=<?=$i;
?>" title="<?=gettext("edit server"); ?>" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
<a id="del_<?=$i;
?>" title="<?=gettext("delete server"); ?>" class="act_delete btn btn-default btn-xs"><span class="fa fa-trash text-muted"></span></a>
<td>
<a href="vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>" title="<?=gettext("edit server"); ?>" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
<a id="del_<?=$i;?>" title="<?=gettext("delete server"); ?>" class="act_delete btn btn-default btn-xs"><span class="fa fa-trash text-muted"></span></a>
</td>
</tr>
<?php
<?php
$i++;
endforeach;
?>
endforeach;?>
<tr><td colspan="5">&nbsp;</td></tr>
</tbody>
<tfoot>
......@@ -1759,10 +1750,8 @@ else :
</td></tr>
</tfoot>
</table>
<?php
endif; ?>
<?php
endif; ?>
</div>
</section>
</div>
......
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