Commit fe848ddd authored by Ad Schellevis's avatar Ad Schellevis

(legacy) refactor vpn_pppoe_edit.php, zap jquery.ipv4v6ify.js row_helper.js

parent 181dd67b
/*jslint browser: true, eqeqeq: true, undef: true */
/*global jQuery */
/******************************************************************************
Lines above are for jslint, the JavaScript verifier. http://www.jslint.com/
******************************************************************************/
/* MIT-licensed code from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some */
/* (C) 2007 Mozilla Developer Network and/or Jeff Walden */
if (!Array.prototype.some) {
Array.prototype.some = function(fun /*, thisp */) {
"use strict";
if (!this) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function") {
throw new TypeError();
}
var thisp = arguments[1];
for (var i = 0; i < len; i++) {
if (i in t && fun.call(thisp, t[i], i, t)) {
return true;
}
}
return false;
};
}
(function ($) {
// --------------------------------------------------------------------
// find pairs of <input class='ipv4v6'> (textbox for IPv4 or IPv6 addr)
// and <select class='ipv4v6'> (dropdown for # bits in CIDR) and
// activate behavior that restricts options in the <select> when an
// ipv4 address is typed in the <input>.
// --------------------------------------------------------------------
var _ipv4v6ify = function (input1, input2) {
var options = Array.prototype.slice.call(input2.options, 0);
var has_128 = options.some(function (x) { return parseInt(x.value, 10) === 128; });
var has_0 = options.some(function (x) { return parseInt(x.value, 10) === 0; });
var max_ipv6 = has_128 ? 128 : 127;
var min_ipv6 = has_0 ? 0 : 1;
var max_ipv4 = has_128 ? 32 : 31;
var min_ipv4 = has_0 ? 0 : 1;
var was_ipv4 = undefined;
var is_ipv4 = undefined;
var restrict_bits_to_ipv4 = function () {
input2.options.length = 0;
for (var i = 0; i < options.length; i += 1) {
var val = parseInt(options[i].value, 10);
if (val >= min_ipv4 && val <= max_ipv4) {
input2.options.add(options[i]);
}
}
};
var unrestrict_bits = function () {
input2.options.length = 0;
for (var i = 0; i < options.length; i += 1) {
input2.options.add(options[i]);
}
};
var onchange_handler = function () {
was_ipv4 = is_ipv4;
is_ipv4 = /\./.test(input1.value) && !/\:/.test(input1.value);
// handle state transitions to gracefully change the
// value in the dropdown.
var bits = parseInt($(input2).val(), 10);
if (was_ipv4 === false && is_ipv4 === true) {
restrict_bits_to_ipv4();
/* min_ipv4 -> min_ipv4 */
/* ... -> ... */
/* max_ipv4 -> max_ipv4 */
/* ... -> ... */
/* max_ipv6 -> max_ipv4 */
if (bits < min_ipv4) {
$(input2).val(min_ipv4);
}
else if (bits < max_ipv4) {
$(input2).val(bits);
}
else {
$(input2).val(max_ipv4);
}
}
else if (was_ipv4 === true && is_ipv4 === false) {
unrestrict_bits();
/* min_ipv4 -> min_ipv4 */
/* ... -> ... */
/* max_ipv4 -> max_ipv4 */
if (bits < min_ipv4) {
$(input2).val(min_ipv6);
}
else if (bits < max_ipv4) {
$(input2).val(bits);
}
else {
$(input2).val(max_ipv6);
}
}
else if (was_ipv4 === undefined && is_ipv4 === true) {
// initial value is an ipv4 address
restrict_bits_to_ipv4();
/* min_ipv4 -> min_ipv4 */
/* ... -> ... */
/* max_ipv4 -> max_ipv4 */
/* ... -> ... */
/* max_ipv6 -> max_ipv4 */
if (bits < min_ipv4) {
$(input2).val(min_ipv4);
}
else if (bits < max_ipv4) {
$(input2).val(bits);
}
else {
$(input2).val(max_ipv4);
}
}
};
$(input1).unbind("change").bind("change", onchange_handler).trigger("change");
};
$.fn.extend({
"ipv4v6ify": function () {
return this.each(function () {
var inputs, i, input1, input2;
inputs = $(this).find(":input.ipv4v6").toArray();
for (i = 0; i < inputs.length - 1; i += 1) {
input1 = inputs[i];
input2 = inputs[i + 1];
if (input1.type === "text" && input2.type === "select-one") {
_ipv4v6ify(input1, input2);
}
}
});
}
});
$(function () {
$(document).ipv4v6ify();
});
})(jQuery);
// Global Variables
var rowname = new Array(4999);
var rowtype = new Array(4999);
var newrow = new Array(4999);
var rowsize = new Array(4999);
for (i = 0; i < 4999; i++) {
rowname[i] = '';
rowtype[i] = '';
newrow[i] = '';
rowsize[i] = '30';
}
var field_counter_js = 0;
var loaded = 0;
var is_streaming_progress_bar = 0;
var temp_streaming_text = "";
var addRowTo = (function() {
return (function (tableId) {
var $ = jQuery;
var d, tbody, tr, td, bgc, i, ii, j;
d = document;
tbody = d.getElementById(tableId).getElementsByTagName("tbody").item(0);
tr = d.createElement("tr");
for (i = 0; i < field_counter_js; i++) {
td = d.createElement("td");
if(typeof(rowtype[i]) == 'function') {
td.innerHTML="<input type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "' />" + rowtype[i](rowname[i], rowsize[i], totalrows) + " ";
} else if(rowtype[i] == 'textbox') {
td.innerHTML="<input type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "' /><input size='" + rowsize[i] + "' class='formfld unknown' type='text' name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "' /> ";
} else if(rowtype[i] == 'textbox,ipv4v6') {
td.innerHTML="<input type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "' /><input size='" + rowsize[i] + "' class='formfld unknown ipv4v6' type='text' name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "' /> ";
} else if(rowtype[i] == 'password') {
td.innerHTML="<input type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "' /><input type='password' size='" + rowsize[i] + "' class='formfld pwd' name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "' /> ";
} else if(rowtype[i] == 'select') {
var cidr;
var str;
for (cidr = 128; cidr>= 1; cidr--) {
str=str + "<option value=\"" + cidr + "\" >" + cidr + "</option>";
}
td.innerHTML="<input type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "' /><select size='1' name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "'>" + str + "</select> ";
} else if(rowtype[i] == 'select,ipv4v6') {
var cidr;
var str;
for (cidr = 128; cidr>= 1; cidr--) {
str=str + "<option value=\"" + cidr + "\" >" + cidr + "</option>";
}
td.innerHTML="<input type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "' /><select class='ipv4v6' size='1' name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "'>" + str + "</select> ";
} else if(rowtype[i] == 'select_source') {
var cidr;
var str;
for (cidr = 128; cidr>= 1; cidr--) {
str=str + "<option value=\"" + cidr + "\" >" + cidr + "</option>";
}
td.innerHTML="<input type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "' /><select size='1' name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "'>" + str + "</select> ";
} else {
td.innerHTML="<input type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "' /><input type='checkbox' name='" + rowname[i] + totalrows + "' /> ";
}
tr.appendChild(td);
}
td = d.createElement("td");
td.rowSpan = "1";
td.innerHTML = '<a onclick="removeRow(this); return false;" href="#" class="btn btn-default btn-xs"><span class="fa fa-trash"></span></a>';
tr.appendChild(td);
tbody.appendChild(tr);
totalrows++;
if($(tr).ipv4v6ify)
$(tr).ipv4v6ify();
});
})();
function removeRow(el) {
var cel;
while (el && el.nodeName.toLowerCase() != "tr")
el = el.parentNode;
if (el && el.parentNode) {
cel = el.getElementsByTagName("td").item(0);
el.parentNode.removeChild(el);
}
}
function find_unique_field_name(field_name) {
// loop through field_name and strip off -NUMBER
var last_found_dash = 0;
for (var i = 0; i < field_name.length; i++) {
// is this a dash, if so, update
// last_found_dash
if (field_name.substr(i,1) == "-" )
last_found_dash = i;
}
if (last_found_dash < 1)
return field_name;
return(field_name.substr(0,last_found_dash));
}
<?php <?php
/* /*
Copyright (C) 2014-2015 Deciso B.V. Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com) Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com)
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");
...@@ -50,65 +50,77 @@ function vpn_pppoe_get_id() ...@@ -50,65 +50,77 @@ function vpn_pppoe_get_id()
return $vpnid; return $vpnid;
} }
if (!isset($config['pppoes']['pppoe'])) { if (empty($config['pppoes']['pppoe']) || !is_array($config['pppoes']['pppoe'])) {
$config['pppoes'] = array();
$config['pppoes']['pppoe'] = array(); $config['pppoes']['pppoe'] = array();
} }
$a_pppoes = &$config['pppoes']['pppoe']; $a_pppoes = &$config['pppoes']['pppoe'];
if (is_numericint($_GET['id'])) { $copy_fields = array('remoteip', 'localip', 'mode', 'interface', 'n_pppoe_units', 'pppoe_subnet', 'dns1', 'dns2', 'descr', 'pppoeid');
$id = $_GET['id'];
}
if (isset($_POST['id']) && is_numericint($_POST['id'])) {
$id = $_POST['id'];
}
if (isset($id) && $a_pppoes[$id]) { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pppoecfg =& $a_pppoes[$id]; if (isset($_GET['id']) && !empty($a_pppoes[$_GET['id']])) {
$id = $_GET['id'];
$pconfig['remoteip'] = $pppoecfg['remoteip']; }
$pconfig['localip'] = $pppoecfg['localip']; $pconfig = array();
$pconfig['mode'] = $pppoecfg['mode']; foreach ($copy_fields as $fieldname) {
$pconfig['interface'] = $pppoecfg['interface']; if (isset($id) && !empty($a_pppoes[$id][$fieldname])) {
$pconfig['n_pppoe_units'] = $pppoecfg['n_pppoe_units']; $pconfig[$fieldname] = $a_pppoes[$id][$fieldname];
$pconfig['pppoe_subnet'] = $pppoecfg['pppoe_subnet']; } else {
$pconfig['pppoe_dns1'] = $pppoecfg['dns1']; $pconfig[$fieldname] = null;
$pconfig['pppoe_dns2'] = $pppoecfg['dns2'];
$pconfig['descr'] = $pppoecfg['descr'];
$pconfig['username'] = $pppoecfg['username'];
$pconfig['pppoeid'] = $pppoecfg['pppoeid'];
if (is_array($pppoecfg['radius'])) {
$pconfig['radacct_enable'] = isset($pppoecfg['radius']['accounting']);
$pconfig['radiusissueips'] = isset($pppoecfg['radius']['radiusissueips']);
if (is_array($pppoecfg['radius']['server'])) {
$pconfig['radiusenable'] = isset($pppoecfg['radius']['server']['enable']);
$pconfig['radiusserver'] = $pppoecfg['radius']['server']['ip'];
$pconfig['radiusserverport'] = $pppoecfg['radius']['server']['port'];
$pconfig['radiusserveracctport'] = $pppoecfg['radius']['server']['acctport'];
$pconfig['radiussecret'] = $pppoecfg['radius']['server']['secret'];
} }
if (is_array($pppoecfg['radius']['server2'])) { }
$pconfig['radiussecenable'] = isset($pppoecfg['radius']['server2']['enable']); // split username / password
$pconfig['radiusserver2'] = $pppoecfg['radius']['server2']['ip']; $pconfig['users_username'] = array();
$pconfig['radiusserver2port'] = $pppoecfg['radius']['server2']['port']; $pconfig['users_password'] = array();
$pconfig['radiusserver2acctport'] = $pppoecfg['radius']['server2']['acctport']; $pconfig['users_ip'] = array();
$pconfig['radiussecret2'] = $pppoecfg['radius']['server2']['secret2']; if (isset($id) && !empty($a_pppoes[$id]['username'])) {
foreach (explode(' ', $a_pppoes[$id]['username']) as $userinfo) {
$parts = explode(':', $userinfo);
$pconfig['users_username'][] = $parts[0];
$pconfig['users_password'][] = base64_decode($parts[1]);
$pconfig['users_ip'][] = !empty($parts[2]) ? $parts[2] : "";
} }
$pconfig['radius_nasip'] = $pppoecfg['radius']['nasip'];
$pconfig['radius_acct_update'] = $pppoecfg['radius']['acct_update'];
} }
}
if ($_POST) { // radius properties
unset($input_errors); $pconfig['radacct_enable'] = isset($id) && isset($a_pppoes[$id]['radius']['accounting']);
$pconfig['radiusissueips'] = isset($id) && isset($a_pppoes[$id]['radius']['radiusissueips']);
$pconfig['radiusenable'] = isset($id) && isset($a_pppoes[$id]['radius']['server']['enable']);
$pconfig['radiusserver'] = isset($id) && isset($a_pppoes[$id]['radius']['server']['ip']) ? $a_pppoes[$id]['radius']['server']['ip'] : null;
$pconfig['radiusserverport'] = isset($id) && isset($a_pppoes[$id]['radius']['server']['port']) ? $a_pppoes[$id]['radius']['server']['port'] : null;
$pconfig['radiusserveracctport'] = isset($id) && isset($a_pppoes[$id]['radius']['server']['acctport']) ? $a_pppoes[$id]['radius']['server']['acctport'] : null;
$pconfig['radiussecret'] = isset($id) && isset($a_pppoes[$id]['radius']['server']['secret']) ? $a_pppoes[$id]['radius']['server']['secret'] : null;
$pconfig['radiussecenable'] = isset($id) && isset($a_pppoes[$id]['radius']['server2']['enable']);
$pconfig['radiusserver2'] = isset($id) && isset($a_pppoes[$id]['radius']['server2']['ip']) ? $a_pppoes[$id]['radius']['server2']['ip'] : null;
$pconfig['radiusserver2port'] = isset($id) && isset($a_pppoes[$id]['radius']['server2']['port']) ? $a_pppoes[$id]['radius']['server2']['port'] : null;
$pconfig['radiusserver2acctport'] = isset($id) && isset($a_pppoes[$id]['radius']['server2']['acctport']) ? $a_pppoes[$id]['radius']['server2']['acctport'] : null;
$pconfig['radiussecret2'] = isset($id) && isset($a_pppoes[$id]['radius']['server2']['secret2']) ? $a_pppoes[$id]['radius']['server2']['secret2'] : null;
$pconfig['radius_nasip'] = isset($id) && isset($a_pppoes[$id]['radius']['nasip']) ? $a_pppoes[$id]['radius']['nasip'] : null;
$pconfig['radius_acct_update'] = isset($id) && isset($a_pppoes[$id]['radius']['acct_update']) ? $a_pppoes[$id]['radius']['acct_update'] : null;
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['id']) && !empty($a_pppoes[$_POST['id']])) {
$id = $_POST['id'];
}
$input_errors = array();
$pconfig = $_POST; $pconfig = $_POST;
/* input validation */ /* input validation */
if ($_POST['mode'] == "server") { foreach ($pconfig['users_username'] as $item_idx => $usr) {
if (empty($pconfig['users_password'][$item_idx])) {
$input_errors[] = sprintf(gettext("No password specified for username %s"), $usr);
}
if ($pconfig['users_ip'][$item_idx] <> "" && !is_ipaddr($pconfig['users_ip'][$item_idx])) {
$input_errors[] = sprintf(gettext("Incorrect ip address specified for username %s"), $usr);
}
}
if ($pconfig['mode'] == "server") {
$reqdfields = explode(" ", "localip remoteip"); $reqdfields = explode(" ", "localip remoteip");
$reqdfieldsn = array(gettext("Server address"),gettext("Remote start address")); $reqdfieldsn = array(gettext("Server address"),gettext("Remote start address"));
if ($_POST['radiusenable']) { if (!empty($pconfig['radiusenable'])) {
$reqdfields = array_merge($reqdfields, explode(" ", "radiusserver radiussecret")); $reqdfields = array_merge($reqdfields, explode(" ", "radiusserver radiussecret"));
$reqdfieldsn = array_merge( $reqdfieldsn = array_merge(
$reqdfieldsn, $reqdfieldsn,
...@@ -118,123 +130,83 @@ if ($_POST) { ...@@ -118,123 +130,83 @@ if ($_POST) {
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
if (($_POST['localip'] && !is_ipaddr($_POST['localip']))) { if (!empty($pconfig['localip']) && !is_ipaddr($pconfig['localip'])) {
$input_errors[] = gettext("A valid server address must be specified."); $input_errors[] = gettext("A valid server address must be specified.");
} }
if (($_POST['pppoe_subnet'] && !is_ipaddr($_POST['remoteip']))) { if (!empty($pconfig['pppoe_subnet']) && !is_ipaddr($pconfig['remoteip'])) {
$input_errors[] = gettext("A valid remote start address must be specified."); $input_errors[] = gettext("A valid remote start address must be specified.");
} }
if (($_POST['radiusserver'] && !is_ipaddr($_POST['radiusserver']))) { if (!empty($pconfig['radiusserver']) && !is_ipaddr($pconfig['radiusserver'])) {
$input_errors[] = gettext("A valid RADIUS server address must be specified."); $input_errors[] = gettext("A valid RADIUS server address must be specified.");
} }
$_POST['remoteip'] = $pconfig['remoteip'] = gen_subnet($_POST['remoteip'], $_POST['pppoe_subnet']); $pconfig['remoteip'] = gen_subnet($pconfig['remoteip'], $pconfig['pppoe_subnet']);
$subnet_start = ip2ulong($_POST['remoteip']); $subnet_start = ip2ulong($pconfig['remoteip']);
$subnet_end = ip2ulong($_POST['remoteip']) + $_POST['pppoe_subnet'] - 1; $subnet_end = ip2ulong($pconfig['remoteip']) + $pconfig['pppoe_subnet'] - 1;
if ((ip2ulong($_POST['localip']) >= $subnet_start) && if ((ip2ulong($pconfig['localip']) >= $subnet_start) &&
(ip2ulong($_POST['localip']) <= $subnet_end)) { (ip2ulong($pconfig['localip']) <= $subnet_end)) {
$input_errors[] = gettext("The specified server address lies in the remote subnet."); $input_errors[] = gettext("The specified server address lies in the remote subnet.");
} }
if ($_POST['localip'] == get_interface_ip($_POST['interface'])) { if ($pconfig['localip'] == get_interface_ip($pconfig['interface'])) {
$input_errors[] = gettext("The specified server address is equal to an interface ip address."); $input_errors[] = gettext("The specified server address is equal to an interface ip address.");
} }
for ($x=0; $x<4999; $x++) {
if ($_POST["username{$x}"]) {
if (empty($_POST["password{$x}"])) {
$input_errors[] = sprintf(gettext("No password specified for username %s"), $_POST["username{$x}"]);
}
if ($_POST["ip{$x}"] <> "" && !is_ipaddr($_POST["ip{$x}"])) {
$input_errors[] = sprintf(gettext("Incorrect ip address specified for username %s"), $_POST["username{$x}"]);
}
}
}
} }
if ($_POST['pppoeid'] && !is_numeric($_POST['pppoeid'])) { if (!empty($pconfig['pppoeid']) && !is_numeric($_POST['pppoeid'])) {
$input_errors[] = gettext("Wrong data submitted"); $input_errors[] = gettext("Wrong data submitted");
} }
if (!$input_errors) { if (count($input_errors) == 0) {
$pppoecfg = array(); $pppoecfg = array();
// convert user/pass/ip combination
$pppoecfg['remoteip'] = $_POST['remoteip']; $pconfig['username'] = array();
$pppoecfg['localip'] = $_POST['localip']; foreach ($pconfig['users_username'] as $item_idx => $usr) {
$pppoecfg['mode'] = $_POST['mode']; $user_item = $usr . ":" . base64_encode($pconfig['users_password'][$item_idx]) ;
$pppoecfg['interface'] = $_POST['interface']; if (!empty($pconfig['users_ip'][$item_idx])) {
$pppoecfg['n_pppoe_units'] = $_POST['n_pppoe_units']; $user_item .= ":".$pconfig['users_ip'][$item_idx];
$pppoecfg['pppoe_subnet'] = $_POST['pppoe_subnet']; }
$pppoecfg['descr'] = $_POST['descr']; $pconfig['username'][] = $user_item ;
if ($_POST['radiusserver'] || $_POST['radiusserver2']) {
$pppoecfg['radius'] = array();
$pppoecfg['radius']['nasip'] = $_POST['radius_nasip'];
$pppoecfg['radius']['acct_update'] = $_POST['radius_acct_update'];
} }
if ($_POST['radiusserver']) { if (count($pconfig['username']) > 0) {
$pppoecfg['radius']['server'] = array(); $pppoecfg['username'] = implode(' ', $pconfig['username']);
$pppoecfg['radius']['server']['ip'] = $_POST['radiusserver'];
$pppoecfg['radius']['server']['secret'] = $_POST['radiussecret'];
$pppoecfg['radius']['server']['port'] = $_POST['radiusserverport'];
$pppoecfg['radius']['server']['acctport'] = $_POST['radiusserveracctport'];
} }
if ($_POST['radiusserver2']) {
$pppoecfg['radius']['server2'] = array();
$pppoecfg['radius']['server2']['ip'] = $_POST['radiusserver2']; // copy simple fields
$pppoecfg['radius']['server2']['secret2'] = $_POST['radiussecret2']; foreach ($copy_fields as $fieldname) {
$pppoecfg['radius']['server2']['port'] = $_POST['radiusserver2port']; if (isset($pconfig[$fieldname]) && $pconfig[$fieldname] != "") {
$pppoecfg['radius']['server2']['acctport'] = $_POST['radiusserver2acctport']; $pppoecfg[$fieldname] = $pconfig[$fieldname];
} }
if ($_POST['pppoe_dns1'] <> "") {
$pppoecfg['dns1'] = $_POST['pppoe_dns1'];
}
if ($_POST['pppoe_dns2'] <> "") {
$pppoecfg['dns2'] = $_POST['pppoe_dns2'];
}
if ($_POST['radiusenable'] == "yes") {
$pppoecfg['radius']['server']['enable'] = true;
} }
if ($_POST['radiussecenable'] == "yes") { // radius settings (array)
$pppoecfg['radius']['server2']['enable'] = true; if (!empty($pconfig['radiusserver']) || !empty($pconfig['radiusserver2'])) {
$pppoecfg['radius'] = array();
$pppoecfg['radius']['server']['enable'] = !empty($pconfig['radiusenable']);
$pppoecfg['radius']['server2']['enable'] = !empty($pconfig['radiussecenable']);
$pppoecfg['radius']['accounting'] = !empty($pconfig['radacct_enable']);
$pppoecfg['radius']['radiusissueips'] = !empty($pconfig['radiusissueips']);
$pppoecfg['radius']['nasip'] = $pconfig['radius_nasip'];
$pppoecfg['radius']['acct_update'] = $pconfig['radius_acct_update'];
} }
if (!empty($pconfig['radiusserver'])) {
if ($_POST['radacct_enable'] == "yes") { $pppoecfg['radius']['server'] = array();
$pppoecfg['radius']['accounting'] = true; $pppoecfg['radius']['server']['ip'] = $pconfig['radiusserver'];
$pppoecfg['radius']['server']['secret'] = $pconfig['radiussecret'];
$pppoecfg['radius']['server']['port'] = $pconfig['radiusserverport'];
$pppoecfg['radius']['server']['acctport'] = $pconfig['radiusserveracctport'];
} }
if (!empty($pconfig['radiusserver2'])) {
if ($_POST['radiusissueips'] == "yes") { $pppoecfg['radius']['server2'] = array();
$pppoecfg['radius']['radiusissueips'] = true; $pppoecfg['radius']['server2']['ip'] = $pconfig['radiusserver2'];
$pppoecfg['radius']['server2']['secret2'] = $pconfig['radiussecret2'];
$pppoecfg['radius']['server2']['port'] = $pconfig['radiusserver2port'];
$pppoecfg['radius']['server2']['acctport'] = $pconfig['radiusserver2acctport'];
} }
if ($_POST['pppoeid']) { if (!isset($pconfig['pppoeid'])) {
$pppoecfg['pppoeid'] = $_POST['pppoeid'];
} else {
$pppoecfg['pppoeid'] = vpn_pppoe_get_id(); $pppoecfg['pppoeid'] = vpn_pppoe_get_id();
} }
$users = array();
for ($x=0; $x<4999; $x++) {
if ($_POST["username{$x}"]) {
$usernam = $_POST["username{$x}"] . ":" . base64_encode($_POST["password{$x}"]);
if ($_POST["ip{$x}"]) {
$usernam .= ":" . $_POST["ip{$x}"];
}
$users[] = $usernam;
}
}
if (count($users) > 0) {
$pppoecfg['username'] = implode(" ", $users);
}
if (!isset($id)) {
$id = count($a_pppoes);
}
if (file_exists('/tmp/.vpn_pppoe.apply')) { if (file_exists('/tmp/.vpn_pppoe.apply')) {
$toapplylist = unserialize(file_get_contents('/tmp/.vpn_pppoe.apply')); $toapplylist = unserialize(file_get_contents('/tmp/.vpn_pppoe.apply'));
} else { } else {
...@@ -242,7 +214,11 @@ if ($_POST) { ...@@ -242,7 +214,11 @@ if ($_POST) {
} }
$toapplylist[] = $pppoecfg['pppoeid']; $toapplylist[] = $pppoecfg['pppoeid'];
$a_pppoes[$id] = $pppoecfg; if (!isset($id)) {
$a_pppoes[] = $pppoecfg;
} else {
$a_pppoes[$id] = $pppoecfg;
}
write_config(); write_config();
mark_subsystem_dirty('vpnpppoe'); mark_subsystem_dirty('vpnpppoe');
...@@ -253,428 +229,346 @@ if ($_POST) { ...@@ -253,428 +229,346 @@ if ($_POST) {
} }
include("head.inc"); include("head.inc");
legacy_html_escape_form_data($pconfig);
?> ?>
<body> <body>
<?php include("fbegin.inc"); ?> <?php include("fbegin.inc"); ?>
<script type="text/javascript" src="/javascript/row_helper.js"></script>
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ $( document ).ready(function() {
rowname[0] = "username"; /**
rowtype[0] = "textbox"; * Aliases
rowsize[0] = "20"; */
function removeRow() {
rowname[1] = "password"; if ( $('#users_table > tbody > tr').length == 1 ) {
rowtype[1] = "password"; $('#users_table > tbody > tr:last > td > input').each(function(){
rowsize[1] = "20"; $(this).val("");
});
rowname[2] = "ip"; } else {
rowtype[2] = "textbox"; $(this).parent().parent().remove();
rowsize[2] = "10"; }
//]]> }
</script> // add new detail record
$("#addNew").click(function(){
<script type="text/javascript"> // copy last row and reset values
//<![CDATA[ $('#users_table > tbody').append('<tr>'+$('#users_table > tbody > tr:last').html()+'</tr>');
function get_radio_value(obj) $('#users_table > tbody > tr:last > td > input').each(function(){
{ $(this).val("");
for (i = 0; i < obj.length; i++) { });
if (obj[i].checked) $(".act-removerow").click(removeRow);
return obj[i].value; });
} $(".act-removerow").click(removeRow);
return null; });
}
function enable_change(enable_over) {
if ((get_radio_value(document.iform.mode) == "server") || enable_over) {
document.iform.remoteip.disabled = 0;
document.iform.descr.disabled = 0;
document.iform.localip.disabled = 0;
document.iform.radiusenable.disabled = 0;
document.iform.interface.disabled = 0;
document.iform.n_pppoe_units.disabled = 0;
document.iform.pppoe_subnet.disabled = 0;
document.iform.pppoe_dns1.disabled = 0;
document.iform.pppoe_dns2.disabled = 0;
if (document.iform.radiusenable.checked || enable_over) {
document.iform.radacct_enable.disabled = 0;
document.iform.radiusserver.disabled = 0;
document.iform.radiussecret.disabled = 0;
document.iform.radiusserverport.disabled = 0;
document.iform.radiusserveracctport.disabled = 0;
document.iform.radiusissueips.disabled = 0;
document.iform.radius_nasip.disabled = 0;
document.iform.radiusissueips.disabled = 0;
document.iform.radius_nasip.disabled = 0;
document.iform.radius_acct_update.disabled = 0;
document.iform.radiussecenable.disabled = 0;
if (document.iform.radiussecenable.checked || enable_over) {
document.iform.radiusserver2.disabled = 0;
document.iform.radiussecret2.disabled = 0;
document.iform.radiusserver2port.disabled = 0;
document.iform.radiusserver2acctport.disabled = 0;
} else {
document.iform.radiusserver2.disabled = 1;
document.iform.radiussecret2.disabled = 1;
document.iform.radiusserver2port.disabled = 1;
document.iform.radiusserver2acctport.disabled = 1;
}
} else {
document.iform.radacct_enable.disabled = 1;
document.iform.radiusserver.disabled = 1;
document.iform.radiussecret.disabled = 1;
document.iform.radiusserverport.disabled = 1;
document.iform.radiusserveracctport.disabled = 1;
document.iform.radiusissueips.disabled = 1;
document.iform.radius_nasip.disabled = 1;
document.iform.radius_acct_update.disabled = 1;
document.iform.radiussecenable.disabled = 1;
}
} else {
document.iform.interface.disabled = 1;
document.iform.n_pppoe_units.disabled = 1;
document.iform.pppoe_subnet.disabled = 1;
document.iform.remoteip.disabled = 1;
document.iform.descr.disabled = 1;
document.iform.localip.disabled = 1;
document.iform.pppoe_dns1.disabled = 1;
document.iform.pppoe_dns2.disabled = 1;
document.iform.radiusenable.disabled = 1;
document.iform.radiussecenable.disabled = 1;
document.iform.radacct_enable.disabled = 1;
document.iform.radiusserver.disabled = 1;
document.iform.radiussecret.disabled = 1;
document.iform.radiusserverport.disabled = 1;
document.iform.radiusserveracctport.disabled = 1;
document.iform.radiusserver2.disabled = 1;
document.iform.radiussecret2.disabled = 1;
document.iform.radiusserver2port.disabled = 1;
document.iform.radiusserver2acctport.disabled = 1;
document.iform.radiusissueips.disabled = 1;
document.iform.radius_nasip.disabled = 1;
document.iform.radius_acct_update.disabled = 1;
}
}
//]]>
</script> </script>
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid">
<div class="container-fluid"> <div class="row">
<?php
<div class="row"> if (isset($input_errors) && count($input_errors) > 0) {
<?php print_input_errors($input_errors);
if (isset($input_errors) && count($input_errors) > 0) { }?>
print_input_errors($input_errors); <section class="col-xs-12">
} <div class="content-box">
if (isset($savemsg)) { <form method="post" name="iform" id="iform">
print_info_box($savemsg); <div class="table-responsive">
} <table class="table table-striped">
?> <tr>
<td width="22%"><strong><?=gettext("PPPoE server configuration");?></strong></td>
<section class="col-xs-12"> <td width="78%" align="right">
<small><?=gettext("full help"); ?> </small>
<div class="content-box"> <i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_page" type="button"></i>
</td>
<form action="vpn_pppoe_edit.php" method="post" name="iform" id="iform"> </tr>
<input type='hidden' name='username' value='textbox' class="formfld unknown" /> <tr>
<input type='hidden' name='password' value='textbox' /> <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Mode");?></td>
<input type='hidden' name='ip' value='textbox' /> <td>
<input name="mode" type="radio" value="off" <?=$pconfig['mode'] != "server" ? "checked=\"checked\"" : "";?> />
<div class="table-responsive"> <?=gettext("Off"); ?>
<table class="table table-striped table-sort"> &nbsp;
<input type="radio" name="mode" value="server" <?=$pconfig['mode'] == "server" ? "checked=\"checked\"" : "";?>/>
<tr> <?=gettext("Enable PPPoE server"); ?></td>
<td height="16" colspan="2" class="listtopic" valign="top"><?php echo gettext("PPPoE server configuration"); ?></td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top" class="vtable">&nbsp;</td> <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Interface"); ?></td>
<td width="78%" class="vtable"> <td>
<input name="mode" type="radio" onclick="enable_change(false)" value="off" <?php if ($pconfig['mode'] != "server") { <select name="interface" class="selectpicker" id="interface">
echo "checked=\"checked\""; <?php
}?> /> foreach (get_configured_interface_with_descr() as $iface => $ifacename) :?>
<?=gettext("Off"); ?> <option value="<?=$iface;?>" <?= $iface == $pconfig['interface'] ? "selected=\"selected\"" : "";?>>
</td> <?=htmlspecialchars($ifacename);?>
</tr> </option>
<tr> <?php
<td width="22%" valign="top" class="vtable">&nbsp;</td> endforeach;?>
<td width="78%" class="vtable"> </select>
<input type="radio" name="mode" value="server" onclick="enable_change(false)" <?php if ($pconfig['mode'] == "server") { </td>
echo "checked=\"checked\""; </tr>
} ?> /> <tr>
<?=gettext("Enable PPPoE server"); ?></td> <td><a id="help_for_pppoe_subnet" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Subnet netmask"); ?></td>
</tr> <td>
<select id="pppoe_subnet" name="pppoe_subnet">
<tr> <?php
<td width="22%" valign="top" class="vncell"><b><?=gettext("Interface"); ?></b></td> for ($x=0; $x<33; $x++):?>
<td width="78%" valign="top" class="vtable"> <option value="<?=$x;?>" <?=$x == $pconfig['pppoe_subnet'] ? "selected=\"selected\"" : "" ;?>>
<?=$x;?>
<select name="interface" class="formselect" id="interface"> <?php
<?php endfor;?>
$interfaces = get_configured_interface_with_descr(); </select>
foreach ($interfaces as $iface => $ifacename) : <div class="hidden" for="help_for_pppoe_subnet">
?> <?=gettext("Hint");?>: 24 <?=gettext("is"); ?> 255.255.255.0
<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) { </div>
echo "selected=\"selected\""; </td>
} ?>> </tr>
<?=htmlspecialchars($ifacename);?> <tr>
</option> <td><a id="help_for_n_pppoe_units" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("No. PPPoE users"); ?></td>
<?php <td>
endforeach; <select id="n_pppoe_units" name="n_pppoe_units">
?> <?php
</select> <br /> for ($x=0; $x<255; $x++):?>
<option value="<?=$x;?>" <?=$x == $pconfig['n_pppoe_units'] ? "selected=\"selected\"" : "" ;?>>
</td> <?=$x;?>
</tr> <?php
<tr> endfor;?>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet netmask"); ?></td> </select>
<td width="78%" class="vtable"> <div class="hidden" for="help_for_n_pppoe_units">
<select id="pppoe_subnet" name="pppoe_subnet"> <?=gettext("Hint: 10 is ten PPPoE clients"); ?>
<?php </div>
for ($x=0; $x<33; $x++) { </td>
if ($x == $pconfig['pppoe_subnet']) { </tr>
$selected = "selected=\"selected\""; <tr>
} else { <td><a id="help_for_localip" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Server address"); ?></td>
$selected = ""; <td>
} <input name="localip" type="text" value="<?=$pconfig['localip'];?>" />
echo "<option value=\"{$x}\" {$selected}>{$x}</option>\n"; <div class="hidden" for="help_for_localip">
} <?=gettext("Enter the IP address the PPPoE server should give to clients for use as their \"gateway\"."); ?>
?> <br />
</select> <?=gettext("Typically this is set to an unused IP just outside of the client range."); ?>
<br /><?=gettext("Hint"); <br />
?>: 24 <?=gettext("is"); ?> 255.255.255.0 <br />
</td> <?=gettext("NOTE: This should NOT be set to any IP address currently in use on this firewall."); ?>
</tr> </div>
<tr> </td>
<td width="22%" valign="top" class="vncellreq"><?=gettext("No. PPPoE users"); ?></td> </tr>
<td width="78%" class="vtable"> <tr>
<select id="n_pppoe_units" name="n_pppoe_units"> <td><a id="help_for_remoteip" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Remote address range"); ?></td>
<?php <td>
for ($x=0; $x<255; $x++) { <input name="remoteip" type="text" value="<?=$pconfig['remoteip'];?>" />
if ($x == $pconfig['n_pppoe_units']) { <div class="hidden" for="help_for_remoteip">
$selected = "selected=\"selected\""; <?=gettext("Specify the starting address for the client IP address subnet."); ?>
} else { </div>
$selected = ""; </td>
} </tr>
echo "<option value=\"{$x}\" {$selected}>{$x}</option>\n"; <tr>
} <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Description"); ?></td>
?> <td>
</select> <input name="descr" type="text" value="<?=$pconfig['descr'];?>" />
<br /><?=gettext("Hint: 10 is ten PPPoE clients"); ?> </td>
</td> </tr>
</tr> <tr>
<tr> <td><a id="help_for_dns" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("DNS servers"); ?></td>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Server address"); ?></td> <td>
<td width="78%" class="vtable"> <input name="dns1" type="text" value="<?=$pconfig['dns1'];?>" />
<input name="localip" type="text" class="formfld unknown" id="localip" size="20" value="<?=htmlspecialchars($pconfig['localip']);?>" /> <br />
<br /> <input name="dns2" type="text" value="<?=$pconfig['dns2'];?>" />
<?=gettext("Enter the IP address the PPPoE server should give to clients for use as their \"gateway\""); ?>. <div class="hidden" for="help_for_dns">
<br /> <?=gettext("If entered they will be given to all PPPoE clients, else LAN DNS and one WAN DNS will go to all clients"); ?>
<?=gettext("Typically this is set to an unused IP just outside of the client range"); ?>. </div>
<br /> </td>
<br /> </tr>
<?=gettext("NOTE: This should NOT be set to any IP address currently in use on this firewall"); ?>.</td> <tr>
</tr> <td><a id="help_for_radiusenable" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("RADIUS"); ?></td>
<tr> <td>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote address range"); ?></td> <input name="radiusenable" type="checkbox" value="yes" <?=!empty($pconfig['radiusenable']) ? "checked=\"checked\"" : ""; ?>/>
<td width="78%" class="vtable"> <strong><?=gettext("Use a RADIUS server for authentication"); ?></strong><br/>
<input name="remoteip" type="text" class="formfld unknown" id="remoteip" size="20" value="<?=htmlspecialchars($pconfig['remoteip']);?>" /> <div class="hidden" for="help_for_radiusenable">
<br /> <?=gettext("When set, all users will be authenticated using " .
<?=gettext("Specify the starting address for the client IP address subnet"); ?>.<br /> "the RADIUS server specified below. The local user database " .
</td> "will not be used."); ?>
</tr> </div>
<tr> <input name="radacct_enable" type="checkbox" value="yes" <?=!empty($pconfig['radacct_enable']) ? "checked=\"checked\"" : "";?> />
<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td> <strong><?=gettext("Enable RADIUS accounting"); ?> <br /></strong>
<td width="78%" class="vtable"> <div class="hidden" for="help_for_radiusenable">
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" /> <?=gettext("Sends accounting packets to the RADIUS server"); ?>.
<br /> </div>
</td> <input name="radiussecenable" type="checkbox" value="yes" <?=!empty($pconfig['radiussecenable']) ? "checked=\"checked\"" : "";?> />
</tr> <strong><?=gettext("Use Backup RADIUS Server"); ?></strong><br />
<tr> <div class="hidden" for="help_for_radiusenable">
<td width="22%" valign="top" class="vncell"><?=gettext("DNS servers"); ?></td> <?=gettext("When set, if primary server fails all requests will be sent via backup server"); ?>
<td width="78%" class="vtable"> </div>
<input name="pppoe_dns1" type="text" class="formfld unknown" id="pppoe_dns1" size="20" value="<?=htmlspecialchars($pconfig['pppoe_dns1']);?>" /> </td>
<br /> </tr>
<input name="pppoe_dns2" type="text" class="formfld unknown" id="pppoe_dns2" size="20" value="<?=htmlspecialchars($pconfig['pppoe_dns2']);?>" /> <tr>
<br /> <td><a id="help_for_radius_nasip" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("NAS IP Address"); ?></td>
<?=gettext("If entered they will be given to all PPPoE clients, else LAN DNS and one WAN DNS will go to all clients"); ?><br /> <td>
</td> <input name="radius_nasip" type="text" id="radius_nasip" value="<?=$pconfig['radius_nasip'];?>" />
</tr> <div class="hidden" for="help_for_radius_nasip">
<tr> <?=gettext("RADIUS server NAS IP Address"); ?>
<td width="22%" valign="top" class="vncell"><?=gettext("RADIUS"); ?></td> </div>
<td width="78%" class="vtable"> </td>
<input name="radiusenable" type="checkbox" id="radiusenable" onclick="enable_change(false)" value="yes" <?php if ($pconfig['radiusenable']) { </tr>
echo "checked=\"checked\""; <tr>
} ?> /> <td><a id="help_for_radius_acct_update" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("RADIUS Accounting Update"); ?></td>
<strong><?=gettext("Use a RADIUS server for authentication"); ?><br /> <td>
</strong><?=gettext("When set, all users will be authenticated using " . <input name="radius_acct_update" type="text" value="<?=$pconfig['radius_acct_update'];?>" />
"the RADIUS server specified below. The local user database " . <div class="hidden" for="help_for_radius_acct_update">
"will not be used"); ?>.<br /> <?=gettext("RADIUS accounting update period in seconds"); ?>
<br /> </div>
<input name="radacct_enable" type="checkbox" id="radacct_enable" onclick="enable_change(false)" value="yes" <?php if ($pconfig['radacct_enable']) { </td>
echo "checked=\"checked\""; </tr>
} ?> /> <tr>
<strong><?=gettext("Enable RADIUS accounting"); ?> <br /> <td><a id="help_for_radiusissueips" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("RADIUS issued IPs"); ?></td>
<br /> <td>
</strong><?=gettext("Sends accounting packets to the RADIUS server"); ?>.<br /> <input name="radiusissueips" value="yes" type="checkbox" <?=!empty($pconfig['radiusissueips']) ? "checked=\"checked\"" : "";?> />
<input name="radiussecenable" type="checkbox" id="radiussecenable" onclick="enable_change(false)" value="yes" <?php if ($pconfig['radiussecenable']) { <div class="hidden" for="help_for_radiusissueips">
echo "checked=\"checked\""; <?=gettext("Issue IP Addresses via RADIUS server."); ?>
} ?> /> </div>
<strong><?=gettext("Use Backup RADIUS Server"); ?></strong><br /> </td>
<?=gettext("When set, if primary server fails all requests will be sent via backup server"); ?></td> </tr>
</tr> <tr>
<tr> <td><a id="help_for_radiusserver" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("RADIUS server Primary"); ?></td>
<td width="22%" valign="top" class="vncellreq"><?=gettext("NAS IP Address"); ?></td> <td>
<td width="78%" class="vtable"> <table class="table table-condensed">
<input name="radius_nasip" type="text" class="formfld unknown" id="radius_nasip" size="20" value="<?=htmlspecialchars($pconfig['radius_nasip']);?>" /> <thead>
<br /><?=gettext("RADIUS server NAS IP Address"); ?><br /> <tr>
</td> <th><?=gettext("Server");?></th>
</tr> <th><?=gettext("Port");?></th>
<tr> <th><?=gettext("AccPort");?></th>
<td width="22%" valign="top" class="vncellreq"><?=gettext("RADIUS Accounting Update"); ?></td> </tr>
<td width="78%" class="vtable"> </thead>
<input name="radius_acct_update" type="text" class="formfld unknown" id="radius_acct_update" size="20" value="<?=htmlspecialchars($pconfig['radius_acct_update']);?>" /> <tbody>
<br /><?=gettext("RADIUS accounting update period in seconds"); ?> <tr>
</td> <td><input name="radiusserver" type="text" value="<?=$pconfig['radiusserver'];?>" /></td>
</tr> <td><input name="radiusserverport" type="text" value="<?=$pconfig['radiusserverport'];?>" /></td>
<tr> <td><input name="radiusserveracctport" type="text" value="<?=$pconfig['radiusserveracctport'];?>" /></td>
<td width="22%" valign="top" class="vncell"><?=gettext("RADIUS issued IPs"); ?></td> </tr>
<td width="78%" valign="top" class="vtable"> </tbody>
<input name="radiusissueips" value="yes" type="checkbox" class="formfld" id="radiusissueips" <?php if ($pconfig['radiusissueips']) { </table>
echo "checked=\"checked\""; <div class="hidden" for="help_for_radiusserver">
} ?> /> <?=gettext("Enter the IP address, authentication port and accounting port (optional) of the RADIUS server."); ?><br />
<br /><?=gettext("Issue IP Addresses via RADIUS server"); ?>.</td> <br /> <?=gettext("standard port 1812 and 1813 accounting"); ?>
</tr> </div>
<tr> </td>
<td width="22%" valign="top" class="vncell"><?=gettext("RADIUS server Primary"); ?></td> </tr>
<td width="78%" class="vtable"> <tr>
<input name="radiusserver" type="text" class="formfld unknown" id="radiusserver" size="20" value="<?=htmlspecialchars($pconfig['radiusserver']);?>" /> <td><a id="help_for_radiussecret" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("RADIUS primary shared secret"); ?></td>
<input name="radiusserverport" type="text" class="formfld unknown" id="radiusserverport" size="4" value="<?=htmlspecialchars($pconfig['radiusserverport']);?>" /> <td>
<input name="radiusserveracctport" type="text" class="formfld unknown" id="radiusserveracctport" size="4" value="<?=htmlspecialchars($pconfig['radiusserveracctport']);?>" /> <input name="radiussecret" type="password" value="<?=$pconfig['radiussecret'];?>" />
<br /><?=gettext("Enter the IP address, authentication port and accounting port (optional) of the RADIUS server."); ?><br /> <div class="hidden" for="help_for_radiussecret">
<br /> <?=gettext("standard port 1812 and 1813 accounting"); ?></td> <?=gettext("Enter the shared secret that will be used to authenticate " .
</tr> "to the RADIUS server"); ?>.
<tr> </div>
<td width="22%" valign="top" class="vncell"><?=gettext("RADIUS primary shared secret"); ?></td> </td>
<td width="78%" valign="top" class="vtable"> </tr>
<input name="radiussecret" type="password" class="formfld pwd" id="radiussecret" size="20" value="<?=htmlspecialchars($pconfig['radiussecret']);?>" /> <tr>
<br /><?=gettext("Enter the shared secret that will be used to authenticate " . <td><a id="help_for_radiusserver2" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("RADIUS server Secondary"); ?></td>
"to the RADIUS server"); ?>.</td> <td>
</tr> <table class="table table-condensed">
<tr> <thead>
<td width="22%" valign="top" class="vncell"><?=gettext("RADIUS server Secondary"); ?></td> <tr>
<td width="78%" class="vtable"> <th><?=gettext("Server");?></th>
<input name="radiusserver2" type="text" class="formfld unknown" id="radiusserver2" size="20" value="<?=htmlspecialchars($pconfig['radiusserver2']);?>" /> <th><?=gettext("Port");?></th>
<input name="radiusserver2port" type="text" class="formfld unknown" id="radiusserver2port" size="4" value="<?=htmlspecialchars($pconfig['radiusserver2port']);?>" /> <th><?=gettext("AccPort");?></th>
<input name="radiusserver2acctport" type="text" class="formfld unknown" id="radiusserver2acctport" size="4" value="<?=htmlspecialchars($pconfig['radiusserver2acctport']);?>" /> </tr>
<br /><?=gettext("Enter the IP address, authentication port and accounting port (optional) of the backup RADIUS server."); ?><br /> </thead>
<br /> <?=gettext("standard port 1812 and 1813 accounting"); ?></td> <tbody>
</tr> <tr>
<tr> <td><input name="radiusserver2" type="text" value="<?=$pconfig['radiusserver2'];?>" /></td>
<td width="22%" valign="top" class="vncell"><?=gettext("RADIUS secondary shared secret"); ?></td> <td><input name="radiusserver2port" type="text" value="<?=$pconfig['radiusserver2port'];?>" /></td>
<td width="78%" valign="top" class="vtable"> <td><input name="radiusserver2acctport" type="text" value="<?=$pconfig['radiusserver2acctport'];?>" /></td>
<input name="radiussecret2" type="password" class="formfld pwd" id="radiussecret2" size="20" value="<?=htmlspecialchars($pconfig['radiussecret2']);?>" /> </tr>
<br /> </tbody>
<?=gettext("Enter the shared secret that will be used to authenticate " . </table>
"to the RADIUS server"); ?>.</td> <div class="hidden" for="help_for_radiusserver2">
</tr> <?=gettext("Enter the IP address, authentication port and accounting port (optional) of the backup RADIUS server."); ?><br />
<tr> <br /> <?=gettext("standard port 1812 and 1813 accounting"); ?>
<td width="22%" valign="top" class="vncell"><div id="addressnetworkport"><?=gettext("User (s)");?></div></td> </div>
<td width="78%" class="vtable"> </td>
<table id="usertable" summary="users"> </tr>
<tbody> <tr>
<tr> <td><a id="help_for_radiussecret2" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a><?=gettext("RADIUS secondary shared secret"); ?></td>
<td><div id="onecolumn"><?=gettext("Username");?></div></td> <td>
<td><div id="twocolumn"><?=gettext("Password");?></div></td> <input name="radiussecret2" type="password" id="radiussecret2" size="20" value="<?=htmlspecialchars($pconfig['radiussecret2']);?>" />
<td><div id="thirdcolumn"><?=gettext("IP");?></div></td> <div class="hidden" for="help_for_radiussecret2">
</tr> <?=gettext("Enter the shared secret that will be used to authenticate " ."to the RADIUS server"); ?>.
<?php </div>
$counter = 0; </td>
$usernames = $pconfig['username']; </tr>
if ($usernames <> "") : <tr>
$item = explode(" ", $usernames); <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("User (s)");?></td>
foreach ($item as $ww) : <td>
$wws = explode(":", $ww); <table class="table table-striped table-condensed" id="users_table">
$user = $wws[0]; <thead>
$passwd = base64_decode($wws[1]); <tr>
$ip = $wws[2]; <th></th>
$tracker = $counter; <th><?=gettext("Username");?></th>
?> <th><?=gettext("Password");?></th>
<tr> <th><?=gettext("IP");?></th>
<td> </tr>
<input name="username<?php echo $tracker; ?>" type="text" class="formfld unknown" id="username<?php echo $tracker; </thead>
?>" size="20" value="<?=htmlspecialchars($user);?>" /> <tbody>
</td> <?php
<td> if (count($pconfig['users_username']) == 0 ) {
<input name="password<?php echo $tracker; ?>" type="password" class="formfld pwd" id="password<?php echo $tracker; $pconfig['users_username'][] = "";
?>" size="20" value="<?=htmlspecialchars($passwd);?>" /> $pconfig['users_password'][] = "";
</td> $pconfig['users_ip'][] = "";
<td>
<input name="ip<?php echo $tracker; ?>" type="text" class="formfld unknown" id="ip<?php echo $tracker;
?>" size="10" value="<?=htmlspecialchars($ip);?>" />
</td>
<td>
<a onclick="removeRow(this); return false;" href="#" class="btn btn-default btn-xs"><span class="fa fa-trash text-muted"></span></a>
</td>
</tr>
<?php
$counter++;
endforeach;
endif;
?>
</tbody>
</table>
<a onclick="javascript:addRowTo('usertable'); return false;" href="#" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-plus"></span></a>
</td>
</tr>
<tr>
<td height="16" colspan="2" valign="top"></td>
</tr>
<tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">
<?php
if (isset($id)) {
echo "<input type=\"hidden\" name=\"id\" id=\"id\" value=\"" . htmlspecialchars($id, ENT_QUOTES | ENT_HTML401) . "\" />";
}
?>
<?php
if (isset($pconfig['pppoeid'])) {
echo "<input type=\"hidden\" name=\"pppoeid\" id=\"pppoeid\" value=\"{$pppoeid}\" />";
} }
?> foreach($pconfig['users_username'] as $item_idx => $user):?>
<input name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" onclick="enable_change(true)" /> <tr>
<a href="vpn_pppoe.php"><input name="Cancel" type="button" class="btn btn-default" value="<?=gettext("Cancel"); ?>" /></a> <td>
</td> <div style="cursor:pointer;" class="act-removerow btn btn-default btn-xs" alt="remove"><span class="glyphicon glyphicon-minus"></span></div>
</tr> </td>
<tr> <td>
<td width="22%" valign="top">&nbsp;</td> <input name="users_username[]" type="text" value="<?=$user;?>" />
<td width="78%"><span class="vexpl"><span class="red"><strong><?=gettext("Note"); ?>:<br /> </td>
</strong></span><?=gettext("don't forget to add a firewall rule to permit " . <td>
"traffic from PPPoE clients"); ?>!</span></td> <input name="users_password[]" type="password" value="<?=$pconfig['users_password'][$item_idx];?>" />
</tr> </td>
</table> <td>
</div> <input name="users_ip[]" type="text" value="<?=$pconfig['users_ip'][$item_idx];?>" />
</form> </td>
</div> </tr>
</section> <?php
</div> endforeach;?>
</div> </tbody>
</section> <tfoot>
<tr>
<script type="text/javascript"> <td colspan="4">
//<![CDATA[ <div id="addNew" style="cursor:pointer;" class="btn btn-default btn-xs" alt="add"><span class="glyphicon glyphicon-plus"></span></div>
enable_change(false); </td>
</tr>
field_counter_js = 3; </tfoot>
rows = 1; </table>
totalrows = <?php echo $counter; ?>; </td>
loaded = <?php echo $counter; ?>; </tr>
//]]> <tr>
</script> <td width="22%" valign="top">&nbsp;</td>
<td width="78%">
<?php
if (isset($id)) {
echo "<input type=\"hidden\" name=\"id\" id=\"id\" value=\"" . htmlspecialchars($id, ENT_QUOTES | ENT_HTML401) . "\" />";
}
if (!empty($pconfig['pppoeid'])) {
echo "<input type=\"hidden\" name=\"pppoeid\" id=\"pppoeid\" value=\"{$pconfig['pppoeid']}\" />";
}
?>
<input name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
<a href="vpn_pppoe.php"><input name="Cancel" type="button" class="btn btn-default" value="<?=gettext("Cancel"); ?>" /></a>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td width="78%">
<span class="text-danger"><strong><?=gettext("Note"); ?>:<br /></strong></span>
<?=gettext("don't forget to add a firewall rule to permit " ."traffic from PPPoE clients!"); ?>
</td>
</tr>
</table>
</div>
</form>
</div>
</section>
</div>
</div>
</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