Commit 3daf864e authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

whitespace vpn_openvpn_export_shared.php

(cherry picked from commit e5621835)
parent 48c6d5e6
<?php <?php
/* /*
Copyright (C) 2008 Shrew Soft Inc. Copyright (C) 2008 Shrew Soft Inc.
Copyright (C) 2010 Ermal Luçi Copyright (C) 2010 Ermal Luçi
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, 1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer. this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
require_once("guiconfig.inc"); require_once("guiconfig.inc");
...@@ -153,7 +153,7 @@ $( document ).ready(function() { ...@@ -153,7 +153,7 @@ $( document ).ready(function() {
}); });
var servers = new Array(); var servers = new Array();
<?php foreach ($ras_server as $sindex => $server) : <?php foreach ($ras_server as $sindex => $server) :
?> ?>
servers[<?=$sindex;?>] = new Array(); servers[<?=$sindex;?>] = new Array();
servers[<?=$sindex; servers[<?=$sindex;
...@@ -166,102 +166,102 @@ endforeach; ?> ...@@ -166,102 +166,102 @@ endforeach; ?>
function download_begin(act) { function download_begin(act) {
var index = document.getElementById("server").selectedIndex; var index = document.getElementById("server").selectedIndex;
var useaddr; var useaddr;
if (document.getElementById("useaddr").value == "other") { if (document.getElementById("useaddr").value == "other") {
if (document.getElementById("useaddr_hostname").value == "") { if (document.getElementById("useaddr_hostname").value == "") {
alert("<?=gettext('Please specify an IP address or hostname.') ?>"); alert("<?=gettext('Please specify an IP address or hostname.') ?>");
return; return;
} }
useaddr = document.getElementById("useaddr_hostname").value; useaddr = document.getElementById("useaddr_hostname").value;
} else } else
useaddr = document.getElementById("useaddr").value; useaddr = document.getElementById("useaddr").value;
var useproxy = 0; var useproxy = 0;
var useproxypass = 0; var useproxypass = 0;
if (document.getElementById("useproxy").checked) if (document.getElementById("useproxy").checked)
useproxy = 1; useproxy = 1;
var proxyaddr = document.getElementById("proxyaddr").value; var proxyaddr = document.getElementById("proxyaddr").value;
var proxyport = document.getElementById("proxyport").value; var proxyport = document.getElementById("proxyport").value;
if (useproxy) { if (useproxy) {
if (!proxyaddr || !proxyport) { if (!proxyaddr || !proxyport) {
alert("<?=gettext('The proxy ip and port cannot be empty') ?>"); alert("<?=gettext('The proxy ip and port cannot be empty') ?>");
return; return;
} }
if (document.getElementById("useproxypass").value != 'none') if (document.getElementById("useproxypass").value != 'none')
useproxypass = 1; useproxypass = 1;
var proxytype = document.getElementById("useproxytype").value; var proxytype = document.getElementById("useproxytype").value;
var proxyauth = document.getElementById("useproxypass").value; var proxyauth = document.getElementById("useproxypass").value;
var proxyuser = document.getElementById("proxyuser").value; var proxyuser = document.getElementById("proxyuser").value;
var proxypass = document.getElementById("proxypass").value; var proxypass = document.getElementById("proxypass").value;
var proxyconf = document.getElementById("proxyconf").value; var proxyconf = document.getElementById("proxyconf").value;
if (useproxypass) { if (useproxypass) {
if (!proxyuser) { if (!proxyuser) {
alert("<?=gettext('Please fill the proxy username and password.') ?>"); alert("<?=gettext('Please fill the proxy username and password.') ?>");
return; return;
} }
if (!proxypass || !proxyconf) { if (!proxypass || !proxyconf) {
alert("<?=gettext('The proxy password or confirm field is empty') ?>"); alert("<?=gettext('The proxy password or confirm field is empty') ?>");
return; return;
} }
if (proxypass != proxyconf) { if (proxypass != proxyconf) {
alert("<?=gettext('The proxy password and confirm fields must match') ?>"); alert("<?=gettext('The proxy password and confirm fields must match') ?>");
return; return;
} }
} }
} }
var dlurl; var dlurl;
dlurl = "/vpn_openvpn_export_shared.php?act=" + act; dlurl = "/vpn_openvpn_export_shared.php?act=" + act;
dlurl += "&srvid=" + servers[index][0]; dlurl += "&srvid=" + servers[index][0];
dlurl += "&useaddr=" + useaddr; dlurl += "&useaddr=" + useaddr;
if (useproxy) { if (useproxy) {
dlurl += "&proxy_type=" + escape(proxytype); dlurl += "&proxy_type=" + escape(proxytype);
dlurl += "&proxy_addr=" + proxyaddr; dlurl += "&proxy_addr=" + proxyaddr;
dlurl += "&proxy_port=" + proxyport; dlurl += "&proxy_port=" + proxyport;
dlurl += "&proxy_authtype=" + proxyauth; dlurl += "&proxy_authtype=" + proxyauth;
if (useproxypass) { if (useproxypass) {
dlurl += "&proxy_user=" + proxyuser; dlurl += "&proxy_user=" + proxyuser;
dlurl += "&proxy_password=" + proxypass; dlurl += "&proxy_password=" + proxypass;
} }
} }
window.open(dlurl,"_self"); window.open(dlurl,"_self");
} }
function server_changed() { function server_changed() {
var table = document.getElementById("clients"); var table = document.getElementById("clients");
while (table.rows.length > 1 ) { while (table.rows.length > 1 ) {
table.deleteRow(1); table.deleteRow(1);
} }
var index = document.getElementById("server").selectedIndex; var index = document.getElementById("server").selectedIndex;
if (servers[index][2] == 'p2p_shared_key') { if (servers[index][2] == 'p2p_shared_key') {
var row = table.insertRow(table.rows.length); var row = table.insertRow(table.rows.length);
var cell0 = row.insertCell(0); var cell0 = row.insertCell(0);
var cell1 = row.insertCell(1); var cell1 = row.insertCell(1);
cell0.innerHTML = "Other Shared Key OS Client"; cell0.innerHTML = "Other Shared Key OS Client";
cell1.innerHTML += "<div>"; cell1.innerHTML += "<div>";
cell1.innerHTML += "<button type='button' class='btn btn-primary btn-xs' onclick='download_begin(\"skconf\")'>Configuration</button>"; cell1.innerHTML += "<button type='button' class='btn btn-primary btn-xs' onclick='download_begin(\"skconf\")'>Configuration</button>";
cell1.innerHTML += "&nbsp;"; cell1.innerHTML += "&nbsp;";
cell1.innerHTML += "<button type='button' class='btn btn-primary btn-xs' onclick='download_begin(\"skzipconf\")'>Configuration archive</button>"; cell1.innerHTML += "<button type='button' class='btn btn-primary btn-xs' onclick='download_begin(\"skzipconf\")'>Configuration archive</button>";
cell1.innerHTML += "</div>"; cell1.innerHTML += "</div>";
} }
} }
function useaddr_changed(obj) { function useaddr_changed(obj) {
if (obj.value == "other") if (obj.value == "other")
$('#HostName').show(); $('#HostName').show();
else else
$('#HostName').hide(); $('#HostName').hide();
} }
......
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