summaryrefslogtreecommitdiffstats
path: root/usr/local/www
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2005-09-13 18:34:39 +0000
committerScott Ullrich <sullrich@pfsense.org>2005-09-13 18:34:39 +0000
commitc980716edb28b33e6340f00ab37ab36f5b860950 (patch)
treef9acce404a5c8e881302c67d93807fffb04102e3 /usr/local/www
parent1d2043b89454eafa2e9836a2e7fa84dde0296208 (diff)
downloadpfsense-c980716edb28b33e6340f00ab37ab36f5b860950.zip
pfsense-c980716edb28b33e6340f00ab37ab36f5b860950.tar.gz
Sync with m0n0wall 1.2b10:
TODO: * Add back sexy curved tabs, etc * Change image locations to themes * Add back pfSense header information and set page titles
Diffstat (limited to 'usr/local/www')
-rwxr-xr-xusr/local/www/services_captiveportal.php272
-rwxr-xr-xusr/local/www/services_captiveportal_ip.php84
-rwxr-xr-xusr/local/www/services_captiveportal_ip_edit.php51
-rwxr-xr-xusr/local/www/services_captiveportal_mac.php75
-rwxr-xr-xusr/local/www/services_captiveportal_mac_edit.php47
-rwxr-xr-xusr/local/www/services_captiveportal_users.php288
6 files changed, 252 insertions, 565 deletions
diff --git a/usr/local/www/services_captiveportal.php b/usr/local/www/services_captiveportal.php
index 22c925c..7233293 100755
--- a/usr/local/www/services_captiveportal.php
+++ b/usr/local/www/services_captiveportal.php
@@ -1,23 +1,22 @@
#!/usr/local/bin/php
-<?php
-/* $Id$ */
+<?php
/*
services_captiveportal.php
part of m0n0wall (http://m0n0.ch/wall)
-
+
Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-
+
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
-
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
@@ -30,6 +29,7 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+$pgtitle = array("Services", "Captive portal");
require("guiconfig.inc");
if (!is_array($config['captiveportal'])) {
@@ -52,19 +52,14 @@ $pconfig['idletimeout'] = $config['captiveportal']['idletimeout'];
$pconfig['enable'] = isset($config['captiveportal']['enable']);
$pconfig['auth_method'] = $config['captiveportal']['auth_method'];
$pconfig['radacct_enable'] = isset($config['captiveportal']['radacct_enable']);
+$pconfig['reauthenticate'] = isset($config['captiveportal']['reauthenticate']);
+$pconfig['reauthenticateacct'] = $config['captiveportal']['reauthenticateacct'];
$pconfig['httpslogin_enable'] = isset($config['captiveportal']['httpslogin']);
$pconfig['httpsname'] = $config['captiveportal']['httpsname'];
$pconfig['cert'] = base64_decode($config['captiveportal']['certificate']);
$pconfig['key'] = base64_decode($config['captiveportal']['private-key']);
$pconfig['logoutwin_enable'] = isset($config['captiveportal']['logoutwin_enable']);
$pconfig['nomacfilter'] = isset($config['captiveportal']['nomacfilter']);
-$pconfig['peruserbw'] = isset($config['captiveportal']['peruserbw']);
-$pconfig['bwauthmacup'] = $config['captiveportal']['bwauthmacup'];
-$pconfig['bwauthmacdn'] = $config['captiveportal']['bwauthmacdn'];
-$pconfig['bwauthipup'] = $config['captiveportal']['bwauthipup'];
-$pconfig['bwauthipdn'] = $config['captiveportal']['bwauthipdn'];
-$pconfig['bwdefaultup'] = $config['captiveportal']['bwdefaultup'];
-$pconfig['bwdefaultdn'] = $config['captiveportal']['bwdefaultdn'];
$pconfig['redirurl'] = $config['captiveportal']['redirurl'];
$pconfig['radiusip'] = $config['captiveportal']['radiusip'];
$pconfig['radiusport'] = $config['captiveportal']['radiusport'];
@@ -78,22 +73,20 @@ if ($_POST) {
/* input validation */
if ($_POST['enable']) {
- $config['captiveportal']['enable'] = $_POST['enable'] ? true : false;
-
$reqdfields = explode(" ", "cinterface");
$reqdfieldsn = explode(",", "Interface");
-
+
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
+
/* make sure no interfaces are bridged */
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
$coptif = &$config['interfaces']['opt' . $i];
if (isset($coptif['enable']) && $coptif['bridge']) {
- //$input_errors[] = "The captive portal cannot be used when one or more interfaces are bridged.";
- //break;
+ $input_errors[] = "The captive portal cannot be used when one or more interfaces are bridged.";
+ break;
}
}
-
+
if ($_POST['httpslogin_enable']) {
if (!$_POST['cert'] || !$_POST['key']) {
$input_errors[] = "Certificate and key must be specified for HTTPS login.";
@@ -103,13 +96,13 @@ if ($_POST) {
if (!strstr($_POST['key'], "BEGIN RSA PRIVATE KEY") || !strstr($_POST['key'], "END RSA PRIVATE KEY"))
$input_errors[] = "This key does not appear to be valid.";
}
-
+
if (!$_POST['httpsname'] || !is_domain($_POST['httpsname'])) {
$input_errors[] = "The HTTPS server name must be specified for HTTPS login.";
}
}
}
-
+
if ($_POST['timeout'] && (!is_numeric($_POST['timeout']) || ($_POST['timeout'] < 1))) {
$input_errors[] = "The timeout must be at least 1 minute.";
}
@@ -133,118 +126,45 @@ if ($_POST) {
$config['captiveportal']['enable'] = $_POST['enable'] ? true : false;
$config['captiveportal']['auth_method'] = $_POST['auth_method'];
$config['captiveportal']['radacct_enable'] = $_POST['radacct_enable'] ? true : false;
+ $config['captiveportal']['reauthenticate'] = $_POST['reauthenticate'] ? true : false;
+ $config['captiveportal']['reauthenticateacct'] = $_POST['reauthenticateacct'];
$config['captiveportal']['httpslogin'] = $_POST['httpslogin_enable'] ? true : false;
$config['captiveportal']['httpsname'] = $_POST['httpsname'];
$config['captiveportal']['certificate'] = base64_encode($_POST['cert']);
$config['captiveportal']['private-key'] = base64_encode($_POST['key']);
$config['captiveportal']['logoutwin_enable'] = $_POST['logoutwin_enable'] ? true : false;
- $config['captiveportal']['peruserbw'] = $_POST['peruserbw'] ? true : false;
- $config['captiveportal']['bwauthmacup'] = $_POST['bwauthmacup'];
- $config['captiveportal']['bwauthmacdn'] = $_POST['bwauthmacdn'];
- $config['captiveportal']['bwauthipup'] = $_POST['bwauthipup'];
- $config['captiveportal']['bwauthipdn'] = $_POST['bwauthipdn'];
- $config['captiveportal']['bwdefaultup'] = $_POST['bwdefaultup'];
- $config['captiveportal']['bwdefaultdn'] = $_POST['bwdefaultdn'];
$config['captiveportal']['nomacfilter'] = $_POST['nomacfilter'] ? true : false;
$config['captiveportal']['redirurl'] = $_POST['redirurl'];
$config['captiveportal']['radiusip'] = $_POST['radiusip'];
$config['captiveportal']['radiusport'] = $_POST['radiusport'];
$config['captiveportal']['radiusacctport'] = $_POST['radiusacctport'];
$config['captiveportal']['radiuskey'] = $_POST['radiuskey'];
-
+
/* file upload? */
if (is_uploaded_file($_FILES['htmlfile']['tmp_name']))
$config['captiveportal']['page']['htmltext'] = base64_encode(file_get_contents($_FILES['htmlfile']['tmp_name']));
- if (is_uploaded_file($_FILES['errfile']['tmp_name']))
+ if (is_uploaded_file($_FILES['errfile']['tmp_name']))
$config['captiveportal']['page']['errtext'] = base64_encode(file_get_contents($_FILES['errfile']['tmp_name']));
-
+
write_config();
-
- filter_configure();
-
+
$retval = 0;
if (!file_exists($d_sysrebootreqd_path)) {
config_lock();
$retval = captiveportal_configure();
- filter_configure();
config_unlock();
}
$savemsg = get_std_save_message($retval);
}
}
-
-$pgtitle = "Services: Captive Portal";
-include("head.inc");
-
?>
-
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
-<br>
<script language="JavaScript">
<!--
-function auth_method_change() {
- if (document.iform.auth_method[0].checked == false) {
- document.iform.logoutwin_enable.checked = 1;
- } else {
- document.iform.logoutwin_enable.checked = 0;
- }
- if (document.iform.auth_method[2].checked == false) {
- document.iform.radiusip.disabled = 1;
- document.iform.radiusport.disabled = 1;
- document.iform.radiuskey.disabled = 1;
- document.iform.radacct_enable.disabled = 1;
- document.iform.radiusacctport.disabled = 1;
- } else {
- document.iform.radiusip.disabled = 0;
- document.iform.radiusport.disabled = 0;
- document.iform.radiuskey.disabled = 0;
- document.iform.radacct_enable.disabled = 0;
- document.iform.radiusacctport.disabled = 0;
- }
-}
-
-function radacct_change() {
- if (document.iform.radacct_enable.checked) {
- auth_method_change();
- }
-}
-
-function enable_https() {
- if (document.iform.httpslogin_enable.checked == false) {
- document.iform.httpsname.disabled = 1;
- document.iform.cert.disabled = 1;
- document.iform.key.disabled = 1;
- } else {
- document.iform.httpsname.disabled = 0;
- document.iform.cert.disabled = 0;
- document.iform.key.disabled = 0;
- }
-}
-
-function enable_peruserbw() {
- if (document.iform.peruserbw.checked == false) {
- document.iform.bwauthmacdn.disabled = 1;
- document.iform.bwauthmacup.disabled = 1;
- document.iform.bwauthipdn.disabled = 1;
- document.iform.bwauthipup.disabled = 1;
- document.iform.bwdefaultdn.disabled = 1;
- document.iform.bwdefaultup.disabled = 1;
- } else {
- document.iform.bwauthmacdn.disabled = 0;
- document.iform.bwauthmacup.disabled = 0;
- document.iform.bwauthipdn.disabled = 0;
- document.iform.bwauthipup.disabled = 0;
- document.iform.bwdefaultdn.disabled = 0;
- document.iform.bwdefaultup.disabled = 0;
- }
-}
-
function enable_change(enable_change) {
var endis;
endis = !(document.iform.enable.checked || enable_change);
-
+
document.iform.cinterface.disabled = endis;
document.iform.idletimeout.disabled = endis;
document.iform.timeout.disabled = endis;
@@ -253,6 +173,9 @@ function enable_change(enable_change) {
document.iform.radiusport.disabled = endis;
document.iform.radiuskey.disabled = endis;
document.iform.radacct_enable.disabled = endis;
+ document.iform.radiusacctport.disabled = endis;
+ document.iform.reauthenticate.disabled = endis;
+ document.iform.reauthenticateacct.disabled = endis;
document.iform.auth_method[0].disabled = endis;
document.iform.auth_method[1].disabled = endis;
document.iform.auth_method[2].disabled = endis;
@@ -261,20 +184,9 @@ function enable_change(enable_change) {
document.iform.cert.disabled = endis;
document.iform.key.disabled = endis;
document.iform.logoutwin_enable.disabled = endis;
- //document.iform.nomacfilter.disabled = endis;
+ document.iform.nomacfilter.disabled = endis;
document.iform.htmlfile.disabled = endis;
document.iform.errfile.disabled = endis;
-
- if (enable_change && document.iform.radacct_enable.checked) {
- document.iform.logoutwin_enable.checked = 1;
- }
- if (enable_change && document.iform.auth_method[0].checked == false) {
- document.iform.logoutwin_enable.checked = 1;
- }
-
- auth_method_change();
- enable_https();
-
}
//-->
</script>
@@ -283,38 +195,33 @@ function enable_change(enable_change) {
<form action="services_captiveportal.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="tabnavtbl">
-<?php
- $tab_array = array();
- $tab_array[0] = array("Captive portal", true, "services_captiveportal.php");
- $tab_array[1] = array("Pass-through MAC", false, "services_captiveportal_mac.php");
- $tab_array[2] = array("Allowed IP addresses", false, "services_captiveportal_ip.php");
- $tab_array[3] = array("Users", false, "services_captiveportal_users.php");
- display_top_tabs($tab_array);
-?>
+ <ul id="tabnav">
+ <li class="tabact">Captive portal</li>
+ <li class="tabinact"><a href="services_captiveportal_mac.php">Pass-through MAC</a></li>
+ <li class="tabinact"><a href="services_captiveportal_ip.php">Allowed IP addresses</a></li>
+ <li class="tabinact"><a href="services_captiveportal_users.php">Users</a></li>
+ </ul>
</td></tr>
<tr>
- <td>
- <div id="mainarea">
- <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
+ <td class="tabcont">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
<td width="22%" valign="top" class="vtable">&nbsp;</td>
<td width="78%" class="vtable">
<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
<strong>Enable captive portal </strong></td>
</tr>
- <tr>
+ <tr>
<td width="22%" valign="top" class="vncellreq">Interface</td>
<td width="78%" class="vtable">
<select name="cinterface" class="formfld" id="cinterface">
- <?php
- $interfaces = array('lan' => 'LAN', 'wan' => 'WAN');
- for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
- if (isset($config['interfaces']['opt' . $i]['enable']))
- $interfaces['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
- }
- foreach ($interfaces as $iface => $ifacename):
- ?>
- <option value="<?=$iface;?>" <?php if ($iface == $pconfig['cinterface']) echo "selected"; ?>>
+ <?php $interfaces = array('lan' => 'LAN');
+ for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
+ if (isset($config['interfaces']['opt' . $i]['enable']))
+ $interfaces['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
+ }
+ foreach ($interfaces as $iface => $ifacename): ?>
+ <option value="<?=$iface;?>" <?php if ($iface == $pconfig['cinterface']) echo "selected"; ?>>
<?=htmlspecialchars($ifacename);?>
</option>
<?php endforeach; ?>
@@ -328,19 +235,19 @@ function enable_change(enable_change) {
minutes<br>
Clients will be disconnected after this amount of inactivity. They may log in again immediately, though. Leave this field blank for no idle timeout.</td>
</tr>
- <tr>
+ <tr>
<td width="22%" valign="top" class="vncell">Hard timeout</td>
- <td width="78%" class="vtable">
- <input name="timeout" type="text" class="formfld" id="timeout" size="6" value="<?=htmlspecialchars($pconfig['timeout']);?>">
+ <td width="78%" class="vtable">
+ <input name="timeout" type="text" class="formfld" id="timeout" size="6" value="<?=htmlspecialchars($pconfig['timeout']);?>">
minutes<br>
Clients will be disconnected after this amount of time, regardless of activity. They may log in again immediately, though. Leave this field blank for no hard timeout (not recommended unless an idle timeout is set).</td>
</tr>
- <tr>
+ <tr>
<td width="22%" valign="top" class="vncell">Logout popup window</td>
- <td width="78%" class="vtable">
+ <td width="78%" class="vtable">
<input name="logoutwin_enable" type="checkbox" class="formfld" id="logoutwin_enable" value="yes" <?php if($pconfig['logoutwin_enable']) echo "checked"; ?>>
<strong>Enable logout popup window</strong><br>
- If enabled, a popup window will appear when clients are allowed through the captive portal. This allows clients to explicitly disconnect themselves before the idle or hard timeout occurs. When RADIUS accounting is enabled, this option is implied.</td>
+ If enabled, a popup window will appear when clients are allowed through the captive portal. This allows clients to explicitly disconnect themselves before the idle or hard timeout occurs.</td>
</tr>
<tr>
<td valign="top" class="vncell">Redirection URL</td>
@@ -351,18 +258,31 @@ If you provide a URL here, clients will be redirected to that URL instead of the
to access after they've authenticated.</td>
</tr>
<tr>
- <td width="22%" valign="top" class="vncell">RADIUS server</td>
- <td width="78%" class="vtable">
- <table cellpadding="1" cellspacing="1">
- <td>No Authentication:&nbsp;&nbsp;</td>
- <td><input name="auth_method" type="radio" id="auth_method" value="none" <?php if($pconfig['auth_method']!="local" || $pconfig['auth_method']!="radius") echo "checked"; ?> onClick="auth_method_change()"></td>
- </tr>
- <td>Local <a href="services_captiveportal_users.php">Usermanager</a>:&nbsp;&nbsp;</td>
- <td><input name="auth_method" type="radio" id="auth_method" value="local" <?php if($pconfig['auth_method']=="local") echo "checked"; ?> onClick="auth_method_change()"></td>
- </tr>
- <td>RADIUS Authentication:&nbsp;&nbsp;</td>
- <td><input name="auth_method" type="radio" id="auth_method" value="radius" <?php if($pconfig['auth_method']=="radius") echo "checked"; ?> onClick="auth_method_change()"></td>
- </tr>
+ <td valign="top" class="vncell">MAC filtering </td>
+ <td class="vtable">
+ <input name="nomacfilter" type="checkbox" class="formfld" id="nomacfilter" value="yes" <?php if ($pconfig['nomacfilter']) echo "checked"; ?>>
+ <strong>Disable MAC filtering</strong><br>
+ If this option is set, no attempts will be made to ensure that the MAC address of clients stays the same while they're logged in. This is required when the MAC address of cannot be determined (usually because there are routers between m0n0wall and the clients).</td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Authentication</td>
+ <td width="78%" class="vtable">
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td colspan="2"><input name="auth_method" type="radio" id="auth_method" value="none" <?php if($pconfig['auth_method']!="local" && $pconfig['auth_method']!="radius") echo "checked"; ?>>
+ No authentication</td>
+ </tr>
+ <tr>
+ <td colspan="2"><input name="auth_method" type="radio" id="auth_method" value="local" <?php if($pconfig['auth_method']=="local") echo "checked"; ?>>
+ Local <a href="services_captiveportal_users.php">user manager</a></td>
+ </tr>
+ <tr>
+ <td colspan="2"><input name="auth_method" type="radio" id="auth_method" value="radius" <?php if($pconfig['auth_method']=="radius") echo "checked"; ?>>
+ RADIUS authentication</td>
+ </tr><tr>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
+ </tr>
<tr>
<td>IP address:</td>
<td><input name="radiusip" type="text" class="formfld" id="radiusip" size="20" value="<?=htmlspecialchars($pconfig['radiusip']);?>"></td>
@@ -375,19 +295,30 @@ to access after they've authenticated.</td>
</tr>
<tr>
<td>Accounting:&nbsp;&nbsp;</td>
- <td><input name="radacct_enable" type="checkbox" id="radacct_enable" value="yes" <?php if($pconfig['radacct_enable']) echo "checked"; ?> onClick="radacct_change()"></td>
+ <td><input name="radacct_enable" type="checkbox" id="radacct_enable" value="yes" <?php if($pconfig['radacct_enable']) echo "checked"; ?>>
+ send RADIUS accounting packets</td>
</tr>
<tr>
<td>Accounting port:&nbsp;&nbsp;</td>
<td><input name="radiusacctport" type="text" class="formfld" id="radiusacctport" size="5" value="<?=htmlspecialchars($pconfig['radiusacctport']);?>"></td>
- </tr></table>
+ </tr>
+ <tr>
+ <td valign="top">Reauthentication:&nbsp;&nbsp;</td>
+ <td><input name="reauthenticate" type="checkbox" id="reauthenticate" value="yes" <?php if($pconfig['reauthenticate']) echo "checked"; ?>>
+ reauthenticate connected users every minute<br><br>
+ <input name="reauthenticateacct" type="radio" value="" <?php if(!$pconfig['reauthenticateacct']) echo "checked"; ?>> no accounting updates<br>
+ <input name="reauthenticateacct" type="radio" value="stopstart" <?php if($pconfig['reauthenticateacct'] == "stopstart") echo "checked"; ?>> stop/start accounting<br>
+ <input name="reauthenticateacct" type="radio" value="interimupdate" <?php if($pconfig['reauthenticateacct'] == "interimupdate") echo "checked"; ?>> interim update</td>
+ </tr>
+ </table>
<br>
- Enter the IP address and port of the RADIUS server which users of the captive portal have to authenticate against. Leave blank to disable RADIUS authentication. Leave port number blank to use the default port (1812). Leave the RADIUS shared secret blank to not use a RADIUS shared secret. RADIUS accounting packets will also be sent to the RADIUS server if accounting is enabled (default port is 1813).
+ When using RADIUS authentication, enter the IP address and port of the RADIUS server which users of the captive portal have to authenticate against. Leave port number blank to use the default port (1812). Leave the RADIUS shared secret blank to not use a RADIUS shared secret. RADIUS accounting packets will also be sent to the RADIUS server if accounting is enabled (default port is 1813).
+ <br><br>If reauthentication is enabled, Access-Requests will be sent to the RADIUS server for each user that is logged in every minute. If an Access-Reject is received for a user, that user is disconnected from the captive portal immediately.
</tr>
<tr>
<td valign="top" class="vncell">HTTPS login</td>
<td class="vtable">
- <input name="httpslogin_enable" type="checkbox" class="formfld" id="httpslogin_enable" value="yes" <?php if($pconfig['httpslogin_enable']) echo "checked"; ?> onClick="enable_https()">
+ <input name="httpslogin_enable" type="checkbox" class="formfld" id="httpslogin_enable" value="yes" <?php if($pconfig['httpslogin_enable']) echo "checked"; ?>>
<strong>Enable HTTPS login</strong><br>
If enabled, the username and password will be transmitted over an HTTPS connection to protect against eavesdroppers. This option only applies when RADIUS authentication is used. A server name, certificate and matching private key must also be specified below.</td>
</tr>
@@ -411,12 +342,12 @@ to access after they've authenticated.</td>
<br>
Paste an RSA private key in PEM format here.</td>
</tr>
- <tr>
+ <tr>
<td width="22%" valign="top" class="vncellreq">Portal page contents</td>
- <td width="78%" class="vtable">
+ <td width="78%" class="vtable">
<?=$mandfldhtml;?><input type="file" name="htmlfile" class="formfld" id="htmlfile"><br>
<?php if ($config['captiveportal']['page']['htmltext']): ?>
- <a href="?act=viewhtml" target="_blank">View current page</a>
+ <a href="?act=viewhtml" target="_blank">View current page</a>
<br>
<br>
<?php endif; ?>
@@ -437,25 +368,24 @@ with a submit button (name=&quot;accept&quot;) and a hidden field with name=&quo
<td class="vtable">
<input name="errfile" type="file" class="formfld" id="errfile"><br>
<?php if ($config['captiveportal']['page']['errtext']): ?>
- <a href="?act=viewerrhtml" target="_blank">View current page</a>
+ <a href="?act=viewerrhtml" target="_blank">View current page</a>
<br>
<br>
<?php endif; ?>
-The contents of the HTML file that you upload here are displayed when an authentication error occurs.</td>
+The contents of the HTML file that you upload here are displayed when a RADIUS authentication error occurs.</td>
</tr>
- <tr>
+ <tr>
<td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">
+ <td width="78%">
+ <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">
</td>
</tr>
- <tr>
+ <tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%"><span class="vexpl"><span class="red"><strong>Note:<br>
- </strong></span>Changing any settings on this page will disconnect all clients! Don't forget to enable the <a href="services_dhcp.php">DHCP Server</a> on your captive portal interface! Make sure that the default/maximum DHCP lease time is higher than the timeout entered on this page. Also, the <a href="services_dnsmasq.php">DNS Forwarder</a> needs to be enabled for DNS lookups by unauthenticated clients to work. </span></td>
+ </strong></span>Changing any settings on this page will disconnect all clients! Don't forget to enable the DHCP server on your captive portal interface! Make sure that the default/maximum DHCP lease time is higher than the timeout entered on this page. Also, the DNS forwarder needs to be enabled for DNS lookups by unauthenticated clients to work. </span></td>
</tr>
</table>
- </div>
</td>
</tr>
</table>
@@ -466,5 +396,3 @@ enable_change(false);
//-->
</script>
<?php include("fend.inc"); ?>
-</body>
-</html>
diff --git a/usr/local/www/services_captiveportal_ip.php b/usr/local/www/services_captiveportal_ip.php
index 7ef988b..2266496 100755
--- a/usr/local/www/services_captiveportal_ip.php
+++ b/usr/local/www/services_captiveportal_ip.php
@@ -1,23 +1,22 @@
#!/usr/local/bin/php
<?php
-/* $Id$ */
/*
services_captiveportal_ip.php
part of m0n0wall (http://m0n0.ch/wall)
-
+
Copyright (C) 2004 Dinesh Nair <dinesh@alphaque.com>
All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-
+
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
-
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
@@ -30,6 +29,7 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+$pgtitle = array("Services", "Captive portal");
require("guiconfig.inc");
if (!is_array($config['captiveportal']['allowedip']))
@@ -67,35 +67,26 @@ if ($_GET['act'] == "del") {
exit;
}
}
-
-$pgtitle = "Services: Captive Portal: Allowed IP's";
-include("head.inc");
-
?>
-
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
<form action="services_captiveportal_ip.php" method="post">
<?php if ($savemsg) print_info_box($savemsg); ?>
<?php if (file_exists($d_allowedipsdirty_path)): ?><p>
<?php print_info_box_np("The captive portal IP address configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
+<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
<?php endif; ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="tabnavtbl">
-<?php
- $tab_array = array();
- $tab_array[0] = array("Captive portal", false, "services_captiveportal.php");
- $tab_array[1] = array("Pass-through MAC", false, "services_captiveportal_mac.php");
- $tab_array[2] = array("Allowed IP addresses", true, "services_captiveportal_ip.php");
- $tab_array[3] = array("Users", false, "services_captiveportal_users.php");
- display_top_tabs($tab_array);
-?>
+ <ul id="tabnav">
+ <li class="tabinact1"><a href="services_captiveportal.php">Captive portal</a></li>
+ <li class="tabinact"><a href="services_captiveportal_mac.php">Pass-through MAC</a></li>
+ <li class="tabact">Allowed IP addresses</li>
+ <li class="tabinact"><a href="services_captiveportal_users.php">Users</a></li>
+ </ul>
</td></tr>
<tr>
- <td>
-<div id="mainarea">
- <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <td class="tabcont">
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="30%" class="listhdrr">IP address</td>
<td width="60%" class="listhdr">Description</td>
@@ -103,37 +94,25 @@ include("head.inc");
</tr>
<?php $i = 0; foreach ($a_allowedips as $ip): ?>
<tr>
- <td class="listlr" ondblclick="document.location='services_captiveportal_ip_edit.php?id=<?=$i;?>';">
- <?php if($ip['dir'] == "to")
- echo "any <img src=\"./themes/".$g['theme']."/images/icons/icon_in.gif\" width=\"11\" height=\"11\" align=\"absmiddle\">";
- ?>
+ <td class="listlr">
+ <?php if($ip['dir'] == "to")
+ echo "any <img src=\"in.gif\" width=\"11\" height=\"11\" align=\"absmiddle\">";
+ ?>
<?=strtolower($ip['ip']);?>
- <?php if($ip['dir'] == "from")
- echo "<img src=\"./themes/".$g['theme']."/images/icons/icon_in.gif\" width=\"11\" height=\"11\" align=\"absmiddle\"> any";
- ?>
+ <?php if($ip['dir'] == "from")
+ echo "<img src=\"in.gif\" width=\"11\" height=\"11\" align=\"absmiddle\"> any";
+ ?>
</td>
- <td class="listbg" ondblclick="document.location='services_captiveportal_ip_edit.php?id=<?=$i;?>';">
- <font color="white"><?=htmlspecialchars($ip['descr']);?>&nbsp;</font>
+ <td class="listbg">
+ <?=htmlspecialchars($ip['descr']);?>&nbsp;
</td>
- <td valign="middle" nowrap class="list">
- <table border="0" cellspacing="0" cellpadding="1">
- <tr>
- <td valign="middle"><a href="services_captiveportal_ip_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
- <td valign="middle"><a href="services_captiveportal_ip.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this address?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
- </tr>
- </table>
- </td>
+ <td valign="middle" nowrap class="list"> <a href="services_captiveportal_ip_edit.php?id=<?=$i;?>"><img src="e.gif" title="edit address" width="17" height="17" border="0"></a>
+ &nbsp;<a href="services_captiveportal_ip.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this address?')"><img src="x.gif" title="delete address" width="17" height="17" border="0"></a></td>
</tr>
<?php $i++; endforeach; ?>
- <tr>
+ <tr>
<td class="list" colspan="2">&nbsp;</td>
- <td class="list">
- <table border="0" cellspacing="0" cellpadding="1">
- <tr>
- <td valign="middle"><a href="services_captiveportal_ip_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
- </td>
- </table>
- </td>
+ <td class="list"> <a href="services_captiveportal_ip_edit.php"><img src="plus.gif" title="add address" width="17" height="17" border="0"></a></td>
</tr>
<tr>
<td colspan="2" class="list"><p class="vexpl"><span class="red"><strong>
@@ -142,25 +121,22 @@ include("head.inc");
Adding allowed IP addresses will allow IP access to/from these addresses through the captive portal without being taken to the portal page. This can be used for a web server serving images for the portal page or a DNS server on another network, for example. By specifying <em>from</em> addresses, it may be used to always allow pass-through access from a client behind the captive portal.</p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
- <td><span class="vexpl">any <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_in.gif" width="11" height="11" align="absmiddle"> x.x.x.x </span></td>
+ <td><span class="vexpl">any <img src="in.gif" width="11" height="11" align="absmiddle"> x.x.x.x </span></td>
<td><span class="vexpl">All connections <strong>to</strong> the IP address are allowed</span></td>
</tr>
<tr>
<td colspan="5" height="4"></td>
</tr>
<tr>
- <td>x.x.x.x <span class="vexpl"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_in.gif" width="11" height="11" align="absmiddle"></span> any&nbsp;&nbsp;&nbsp; </td>
+ <td>x.x.x.x <span class="vexpl"><img src="in.gif" width="11" height="11" align="absmiddle"></span> any&nbsp;&nbsp;&nbsp; </td>
<td><span class="vexpl">All connections <strong>from</strong> the IP address are allowed </span></td>
</tr>
</table></td>
<td class="list">&nbsp;</td>
</tr>
</table>
-</div>
</td>
</tr>
</table>
</form>
<?php include("fend.inc"); ?>
-</body>
-</html>
diff --git a/usr/local/www/services_captiveportal_ip_edit.php b/usr/local/www/services_captiveportal_ip_edit.php
index 447d6ce..85911e6 100755
--- a/usr/local/www/services_captiveportal_ip_edit.php
+++ b/usr/local/www/services_captiveportal_ip_edit.php
@@ -1,23 +1,22 @@
#!/usr/local/bin/php
-<?php
-/* $Id$ */
+<?php
/*
services_captiveportal_ip_edit.php
part of m0n0wall (http://m0n0.ch/wall)
-
+
Copyright (C) 2004 Dinesh Nair <dinesh@alphaque.com>
All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-
+
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
-
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
@@ -30,6 +29,7 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+$pgtitle = array("Services", "Captive portal", "Edit allowed IP address");
require("guiconfig.inc");
if (!is_array($config['captiveportal']['allowedip']))
@@ -56,9 +56,9 @@ if ($_POST) {
/* input validation */
$reqdfields = explode(" ", "ip dir");
$reqdfieldsn = explode(",", "Allowed IP address,Direction");
-
+
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
+
if (($_POST['ip'] && !is_ipaddr($_POST['ip']))) {
$input_errors[] = "A valid IP address must be specified. [".$_POST['ip']."]";
}
@@ -66,11 +66,11 @@ if ($_POST) {
foreach ($a_allowedips as $ipent) {
if (isset($id) && ($a_allowedips[$id]) && ($a_allowedips[$id] === $ipent))
continue;
-
+
if (($ipent['dir'] == $_POST['dir']) && ($ipent['ip'] == $_POST['ip'])){
$input_errors[] = "[" . $_POST['ip'] . "] already allowed." ;
break ;
- }
+ }
}
if (!$input_errors) {
@@ -83,32 +83,25 @@ if ($_POST) {
$a_allowedips[$id] = $ip;
else
$a_allowedips[] = $ip;
-
+
write_config();
touch($d_allowedipsdirty_path) ;
-
+
header("Location: services_captiveportal_ip.php");
exit;
}
}
-
-$pgtitle = "Services: Captive Portal: Allowed IP's: Edit";
-include("head.inc");
-
?>
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<form action="services_captiveportal_ip_edit.php" method="post" name="iform" id="iform">
- <?display_topbar()?>
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td width="22%" valign="top" class="vncellreq">Direction</td>
- <td width="78%" class="vtable">
+ <td width="78%" class="vtable">
<select name="dir" class="formfld">
- <?php
+ <?php
$dirs = explode(" ", "From To") ;
foreach ($dirs as $dir): ?>
<option value="<?=strtolower($dir);?>" <?php if (strtolower($dir) == strtolower($pconfig['dir'])) echo "selected";?> >
@@ -116,28 +109,28 @@ include("head.inc");
</option>
<?php endforeach; ?>
</select>
- <br>
- <span class="vexpl">Use <em>From</em> to always allow an IP address through the captive portal (without authentication).
+ <br>
+ <span class="vexpl">Use <em>From</em> to always allow an IP address through the captive portal (without authentication).
Use <em>To</em> to allow access from all clients (even non-authenticated ones) behind the portal to this IP address.</span></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq">IP address</td>
- <td width="78%" class="vtable">
+ <td width="78%" class="vtable">
<?=$mandfldhtml;?><input name="ip" type="text" class="formfld" id="ip" size="17" value="<?=htmlspecialchars($pconfig['ip']);?>">
- <br>
+ <br>
<span class="vexpl">IP address</span></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell">Description</td>
- <td width="78%" class="vtable">
+ <td width="78%" class="vtable">
<input name="descr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
<br> <span class="vexpl">You may enter a description here
for your reference (not parsed).</span></td>
</tr>
<tr>
<td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()">
+ <td width="78%">
+ <input name="Submit" type="submit" class="formbtn" value="Save">
<?php if (isset($id) && $a_allowedips[$id]): ?>
<input name="id" type="hidden" value="<?=$id;?>">
<?php endif; ?>
diff --git a/usr/local/www/services_captiveportal_mac.php b/usr/local/www/services_captiveportal_mac.php
index 956bb65..056b90f 100755
--- a/usr/local/www/services_captiveportal_mac.php
+++ b/usr/local/www/services_captiveportal_mac.php
@@ -1,23 +1,22 @@
#!/usr/local/bin/php
<?php
-/* $Id$ */
/*
services_captiveportal_mac.php
part of m0n0wall (http://m0n0.ch/wall)
-
+
Copyright (C) 2004 Dinesh Nair <dinesh@alphaque.com>
All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-
+
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
-
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
@@ -30,6 +29,7 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+$pgtitle = array("Services", "Captive portal");
require("guiconfig.inc");
if (!is_array($config['captiveportal']['passthrumac']))
@@ -67,35 +67,26 @@ if ($_GET['act'] == "del") {
exit;
}
}
-
-$pgtitle = "Services: Captive Portal: MACs";
-include("head.inc");
-
?>
-
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
<form action="services_captiveportal_mac.php" method="post">
<?php if ($savemsg) print_info_box($savemsg); ?>
<?php if (file_exists($d_passthrumacsdirty_path)): ?><p>
<?php print_info_box_np("The captive portal MAC address configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
+<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
<?php endif; ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="tabnavtbl">
-<?php
- $tab_array = array();
- $tab_array[0] = array("Captive portal", false, "services_captiveportal.php");
- $tab_array[1] = array("Pass-through MAC", true, "services_captiveportal_mac.php");
- $tab_array[2] = array("Allowed IP addresses", false, "services_captiveportal_ip.php");
- $tab_array[3] = array("Users", false, "services_captiveportal_users.php");
- display_top_tabs($tab_array);
-?>
+ <ul id="tabnav">
+ <li class="tabinact1"><a href="services_captiveportal.php">Captive portal</a></li>
+ <li class="tabact">Pass-through MAC</li>
+ <li class="tabinact"><a href="services_captiveportal_ip.php">Allowed IP addresses</a></li>
+ <li class="tabinact"><a href="services_captiveportal_users.php">Users</a></li>
+ </ul>
</td></tr>
<tr>
- <td>
-<div id="mainarea">
- <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <td class="tabcont">
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="30%" class="listhdrr">MAC address</td>
<td width="60%" class="listhdr">Description</td>
@@ -103,50 +94,30 @@ include("head.inc");
</tr>
<?php $i = 0; foreach ($a_passthrumacs as $mac): ?>
<tr>
- <td class="listlr" ondblclick="document.location='services_captiveportal_mac_edit.php?id=<?=$i;?>';">
+ <td class="listlr">
<?=strtolower($mac['mac']);?>
</td>
- <td class="listbg" ondblclick="document.location='services_captiveportal_mac_edit.php?id=<?=$i;?>';">
- <font color="white"><?=htmlspecialchars($mac['descr']);?>&nbsp;</font>
+ <td class="listbg">
+ <?=htmlspecialchars($mac['descr']);?>&nbsp;
</td>
- <td valign="middle" nowrap class="list">
- <table border="0" cellspacing="0" cellpadding="1">
- <tr>
- <td valign="middle"><a href="services_captiveportal_mac_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
- <td valign="middle"><a href="services_captiveportal_mac.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this host?')"><img src="x.gif" width="17" height="17" border="0"></a></td>
- </tr>
- </table>
- </td>
+ <td valign="middle" nowrap class="list"> <a href="services_captiveportal_mac_edit.php?id=<?=$i;?>"><img src="e.gif" title="edit host" width="17" height="17" border="0"></a>
+ &nbsp;<a href="services_captiveportal_mac.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this host?')"><img src="x.gif" title="delete host" width="17" height="17" border="0"></a></td>
</tr>
<?php $i++; endforeach; ?>
- <tr>
+ <tr>
<td class="list" colspan="2">&nbsp;</td>
- <td class="list">
- <table border="0" cellspacing="0" cellpadding="1">
- <tr>
- <td valign="middle"><a href="services_captiveportal_mac_edit.php"><img src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
- </tr>
- </table>
- </td>
+ <td class="list"> <a href="services_captiveportal_mac_edit.php"><img src="plus.gif" title="add host" width="17" height="17" border="0"></a></td>
</tr>
<tr>
- <td class="list" colspan="2">&nbsp;</td>
- <td class="list"> <a href="services_captiveportal_mac_edit.php"><img src="plus.gif" title="add host" width="17" height="17" border="0"></a></td>
- </tr>
- <tr>
- <tr>
<td colspan="2" class="list"><span class="vexpl"><span class="red"><strong>
Note:<br>
</strong></span>
- Adding MAC addresses as pass-through MACs allows them access through the captive portal automatically without being taken to the portal page. Pass-through MACs will however still be disconnected after the captive portal timeout period.</span></td>
+ Adding MAC addresses as pass-through MACs allows them access through the captive portal automatically without being taken to the portal page. The pass-through MACs can change their IP addresses on the fly and upon the next access, the pass-through tables are changed accordingly. Pass-through MACs will however still be disconnected after the captive portal timeout period.</span></td>
<td class="list">&nbsp;</td>
</tr>
</table>
-</div>
</td>
</tr>
</table>
</form>
<?php include("fend.inc"); ?>
-</body>
-</html>
diff --git a/usr/local/www/services_captiveportal_mac_edit.php b/usr/local/www/services_captiveportal_mac_edit.php
index 1f7cf56..f204d0f 100755
--- a/usr/local/www/services_captiveportal_mac_edit.php
+++ b/usr/local/www/services_captiveportal_mac_edit.php
@@ -1,23 +1,22 @@
#!/usr/local/bin/php
-<?php
-/* $Id$ */
+<?php
/*
services_captiveportal_mac_edit.php
part of m0n0wall (http://m0n0.ch/wall)
-
+
Copyright (C) 2004 Dinesh Nair <dinesh@alphaque.com>
All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-
+
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
-
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
@@ -30,6 +29,7 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+$pgtitle = array("Services", "Captive portal", "Edit pass-through MAC address");
require("guiconfig.inc");
if (!is_array($config['captiveportal']['passthrumac']))
@@ -55,12 +55,11 @@ if ($_POST) {
/* input validation */
$reqdfields = explode(" ", "mac");
$reqdfieldsn = explode(",", "MAC address");
-
+
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
- /* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
- $_POST['mac'] = strtolower(str_replace("-", ":", $_POST['mac']));
-
+
+ $_POST['mac'] = str_replace("-", ":", $_POST['mac']);
+
if (($_POST['mac'] && !is_macaddr($_POST['mac']))) {
$input_errors[] = "A valid MAC address must be specified. [".$_POST['mac']."]";
}
@@ -68,11 +67,11 @@ if ($_POST) {
foreach ($a_passthrumacs as $macent) {
if (isset($id) && ($a_passthrumacs[$id]) && ($a_passthrumacs[$id] === $macent))
continue;
-
+
if ($macent['mac'] == $_POST['mac']){
$input_errors[] = "[" . $_POST['mac'] . "] already allowed." ;
break;
- }
+ }
}
if (!$input_errors) {
@@ -84,45 +83,37 @@ if ($_POST) {
$a_passthrumacs[$id] = $mac;
else
$a_passthrumacs[] = $mac;
-
+
write_config();
touch($d_passthrumacsdirty_path) ;
-
+
header("Location: services_captiveportal_mac.php");
exit;
}
}
-
-$pgtitle = "Services: Captive Portal: MACs: Edit";
-include("head.inc");
-
?>
-
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<form action="services_captiveportal_mac_edit.php" method="post" name="iform" id="iform">
- <?display_topbar()?>
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td width="22%" valign="top" class="vncellreq">MAC address</td>
- <td width="78%" class="vtable">
+ <td width="78%" class="vtable">
<?=$mandfldhtml;?><input name="mac" type="text" class="formfld" id="mac" size="17" value="<?=htmlspecialchars($pconfig['mac']);?>">
- <br>
+ <br>
<span class="vexpl">MAC address (6 hex octets separated by colons)</span></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell">Description</td>
- <td width="78%" class="vtable">
+ <td width="78%" class="vtable">
<input name="descr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
<br> <span class="vexpl">You may enter a description here
for your reference (not parsed).</span></td>
</tr>
<tr>
<td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
+ <td width="78%">
<input name="Submit" type="submit" class="formbtn" value="Save">
<?php if (isset($id) && $a_passthrumacs[$id]): ?>
<input name="id" type="hidden" value="<?=$id;?>">
diff --git a/usr/local/www/services_captiveportal_users.php b/usr/local/www/services_captiveportal_users.php
index 91d1b91..370f530 100755
--- a/usr/local/www/services_captiveportal_users.php
+++ b/usr/local/www/services_captiveportal_users.php
@@ -1,26 +1,25 @@
#!/usr/local/bin/php
-<?php
-/* $Id$ */
+<?php
/*
services_captiveportal_users.php
part of m0n0wall (http://m0n0.ch/wall)
-
- Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
+
+ Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
All rights reserved.
Copyright (C) 2005 Pascal Suter <d-monodev@psuter.ch>.
- All rights reserved.
+ All rights reserved.
(files was created by Pascal based on the source code of services_captiveportal.php from Manuel)
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-
+
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
-
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
@@ -32,250 +31,79 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
+$pgtitle = array("Services", "Captive portal");
require("guiconfig.inc");
-if(isset($_POST['save'])){
- //value-checking
- if(trim($_POST['password1'])!="********" &&
- trim($_POST['password1'])!="" &&
- trim($_POST['password1'])!=trim($_POST['password2'])){
- //passwords are to be changed but don't match
- $input_errors[]="passwords don't match";
- }
- if((trim($_POST['password1'])=="" || trim($_POST['password1'])=="********") &&
- (trim($_POST['password2'])=="" || trim($_POST['password2'])=="********")){
- //assume password should be left as is if a password is set already.
- if(!empty($config['users'][$_POST['old_username']]['password'])){
- $_POST['password1']="********";
- $_POST['password2']="********";
- } else {
- $input_errors[]="password must not be empty";
- }
- } else {
- if(trim($_POST['password1'])!=trim($_POST['password2'])){
- //passwords are to be changed or set but don't match
- $input_errors[]="passwords don't match";
- } else {
- //check password for invalid characters
- if(!preg_match('/^[a-zA-Z0-9_\-\.@\~\(\)\&\*\+§?!\$£°\%;:]*$/',$_POST['username'])){
- $input_errors[] = "password contains illegal characters, only letters from A-Z and a-z, _, -, .,@,~,(,),&,*,+,§,?,!,$,£,°,%,;,: and numbers are allowed";
- //test pw: AZaz_-.@~()&*+§?!$£°%;:
- }
- }
- }
- if($_POST['username']==""){
- $input_errors[] = "username must not be empty!";
- }
- //check for a valid expirationdate if one is set at all (valid means, strtotime() puts out a time stamp
- //so any strtotime compatible time format may be used. to keep it simple for the enduser, we only claim
- //to accept MM/DD/YYYY as inputs. advanced users may use inputs like "+1 day", which will be converted to
- //MM/DD/YYYY based on "now" since otherwhise such an entry would lead to a never expiring expirationdate
- if(trim($_POST['expirationdate'])!=""){
- if(strtotime($_POST['expirationdate'])>0){
- if(strtotime("-1 day")>strtotime(date("m/d/Y",strtotime($_POST['expirationdate'])))){
- $input_errors[] = "selected expiration date lies in the past";
- } else {
- //convert from any strtotime compatible date to MM/DD/YYYY
- $expdate = strtotime($_POST['expirationdate']);
- $_POST['expirationdate'] = date("m/d/Y",$expdate);
- }
- } else {
- $input_errors[] = "invalid expiration date format, use MM/DD/YYYY instead";
- }
- }
- //check username: only allow letters from A-Z and a-z, _, -, . and numbers from 0-9 (note: username can
- //not contain characters which are not allowed in an xml-token. i.e. if you'd use @ in a username, config.xml
- //could not be parsed anymore!
- if(!preg_match('/^[a-zA-Z0-9_\-\.]*$/',$_POST['username'])){
- $input_errors[] = "username contains illegal characters, only letters from A-Z and a-z, _, -, . and numbers are allowed";
- }
- if(!empty($input_errors)){
- //there are illegal inputs --> print out error message and show formular again (and fill in all recently entered values
- //except passwords
- $_GET['act']="new";
- $_POST['old_username']=($_POST['old_username'] ? $_POST['old_username'] : $_POST['username']);
- $_GET['username']=$_POST['old_username'];
- foreach(Array("username","fullname","expirationdate") as $field){
- $config['users'][$_POST['old_username']][$field]=$_POST[$field];
- }
- } else {
- //all values are okay --> saving changes
- $_POST['username']=trim($_POST['username']);
- if($_POST['old_username']!="" && $_POST['old_username']!=$_POST['username']){
- //change the username (which is used as array-index)
- $config['users'][$_POST['username']]=$config['users'][$_POST['old_username']];
- unset($config['users'][$_POST['old_username']]);
- }
- foreach(Array('fullname','expirationdate') as $field){
- $config['users'][$_POST['username']][$field]=trim($_POST[$field]);
- }
- if(trim($_POST['password1'])!="********" && trim($_POST['password1'])!=""){
- $config['users'][$_POST['username']]['password']=md5(trim($_POST['password1']));
- }
+if (!is_array($config['captiveportal']['user'])) {
+ $config['captiveportal']['user'] = array();
+}
+captiveportal_users_sort();
+$a_user = &$config['captiveportal']['user'];
+
+if ($_GET['act'] == "del") {
+ if ($a_user[$_GET['id']]) {
+ unset($a_user[$_GET['id']]);
write_config();
- $savemsg=$_POST['username']." successfully saved<br>";
+ header("Location: services_captiveportal_users.php");
+ exit;
}
-} else if ($_GET['act']=="delete" && isset($_GET['username'])){
- unset($config['users'][$_GET['username']]);
- write_config();
- $savemsg=$_GET['username']." successfully deleted<br>";
}
+
//erase expired accounts
-$changed=false;
-if(is_array($config['users'])){
- foreach($config['users'] as $username => $user){
- if(trim($user['expirationdate'])!="" && strtotime("-1 day")>strtotime($user['expirationdate']) && empty($input_errors)){
- unset($config['users'][$username]);
- $changed=true;
- $savemsg.="$username has expired --> $username was deleted<br>";
- }
- }
- if($changed){
- write_config();
+$changed = false;
+for ($i = 0; $i < count($a_user); $i++) {
+ if ($a_user[$i]['expirationdate'] && (strtotime("-1 day") > strtotime($a_user[$i]['expirationdate']))) {
+ unset($a_user[$i]);
+ $changed = true;
}
}
-
-
-$pgtitle = "Services: Captive Portal: Users";
-include("head.inc");
+if ($changed) {
+ write_config();
+ header("Location: services_captiveportal_users.php");
+ exit;
+}
?>
-
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
-<script language="javascript" type="text/javascript" src="datetimepicker.js">
-//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
-//Script featured on JavaScript Kit (http://www.javascriptkit.com)
-//For this script, visit http://www.javascriptkit.com
-</script>
-<?php if ($input_errors) print_input_errors($input_errors); ?>
-<?php if ($savemsg) print_info_box($savemsg); ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td>
-<?php
- $tab_array = array();
- $tab_array[0] = array("Captive portal", false, "services_captiveportal.php");
- $tab_array[1] = array("Pass-through MAC", false, "services_captiveportal_mac.php");
- $tab_array[2] = array("Allowed IP addresses", false, "services_captiveportal_ip.php");
- $tab_array[3] = array("Users", true, "services_captiveportal_users.php");
- display_top_tabs($tab_array);
-?>
+ <ul id="tabnav">
+ <li class="tabinact1"><a href="services_captiveportal.php">Captive portal</a></li>
+ <li class="tabinact"><a href="services_captiveportal_mac.php">Pass-through MAC</a></li>
+ <li class="tabinact"><a href="services_captiveportal_ip.php">Allowed IP addresses</a></li>
+ <li class="tabact">Users</li>
+ </ul>
</td></tr>
<tr>
- <td>
-<?php
-if($_GET['act']=="new" || $_GET['act']=="edit"){
- if($_GET['act']=="edit" && isset($_GET['username'])){
- $user=$config['users'][$_GET['username']];
- }
-?>
- <form action="services_captiveportal_users.php" method="post" name="iform" id="iform">
-<div id="mainarea">
- <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td width="22%" valign="top" class="vncellreq">Username</td>
- <td width="78%" class="vtable">
- <input name="username" type="text" class="formfld" id="username" size="20" value="<? echo $_GET['username']; ?>">
- <br>
- <span class="vexpl">Username to be used</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Password</td>
- <td width="78%" class="vtable">
- <input name="password1" type="password" class="formfld" id="password1" size="20" value="<?php echo ($_GET['act']=='edit' ? "********" : "" ); ?>">
- <br>
- <span class="vexpl">Password for the user</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">confirm Password</td>
- <td width="78%" class="vtable">
- <input name="password2" type="password" class="formfld" id="password2" size="20" value="<?php echo ($_GET['act']=='edit' ? "********" : "" ); ?>">
- <br>
- <span class="vexpl">Confirm the above Password</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Full Name</td>
- <td width="78%" class="vtable">
- <input name="fullname" type="text" class="formfld" id="fullname" size="20" value="<? echo $user['fullname']; ?>">
- <br>
- Full Name of current user, for your own information only</td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Expiration Date</td>
- <td width="78%" class="vtable">
- <input name="expirationdate" type="text" class="formfld" id="expirationdate" size="10" value="<? echo $user['expirationdate']; ?>">
- <a href="javascript:NewCal('expirationdate','mmddyyyy')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
- <br> <span class="vexpl">enter nothing if account doesnt expire, otherwhise enter the expiration date in us-format: mm/dd/yyyy</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input name="save" type="submit" class="formbtn" value="Save">
- <input name="old_username" type="hidden" value="<? echo $_GET['username'];?>">
- </td>
- </tr>
- </table>
- </div>
- </form>
-<?php
-} else {
- echo <<<END
-<div id="mainarea">
- <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <td class="tabcont">
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="35%" class="listhdrr">Username</td>
- <td width="20%" class="listhdrr">Full Name</td>
+ <td width="20%" class="listhdrr">Full name</td>
<td width="35%" class="listhdr">Expires</td>
<td width="10%" class="list"></td>
</tr>
-END;
- if(is_array($config['users'])){
- foreach($config['users'] as $username => $user){
-?>
+ <?php $i = 0; foreach($a_user as $userent): ?>
<tr>
- <td class="listlr" ondblclick="document.location='services_captiveportal_users_edit.php?act=edit&username=<?=$username;?>';">
- <?php echo $username; ?>&nbsp;
- </td>
- <td class="listr" ondblclick="document.location='services_captiveportal_users_edit.php?act=edit&username=<?=$username;?>';">
- <?php echo $user['fullname']; ?>&nbsp;
+ <td class="listlr">
+ <?=htmlspecialchars($userent['name']); ?>&nbsp;
</td>
- <td class="listbg" ondblclick="document.location='services_captiveportal_users_edit.php?act=edit&username=<?=$username;?>';">
- <font color="white"><?php echo $user['expirationdate']; ?>&nbsp;</font>
+ <td class="listr">
+ <?=htmlspecialchars($userent['fullname']);?>&nbsp;
</td>
- <td valign="middle" nowrap class="list">
- <table border="0" cellspacing="0" cellpadding="1">
- <tr>
- <td valign="middle"><a href="services_captiveportal_users.php?act=edit&username=<?php echo $username; ?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
- <td valign="middle"><a href="services_captiveportal_users.php?act=delete&username=<?php echo $username; ?>" onclick="return confirm('Do you really want to delete this User?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
- </tr>
- </table>
+ <td class="listbg">
+ <?=$userent['expirationdate']; ?>&nbsp;
</td>
+ <td valign="middle" nowrap class="list"> <a href="services_captiveportal_users_edit.php?id=<?=$i; ?>"><img src="e.gif" title="edit user" width="17" height="17" border="0"></a>
+ &nbsp;<a href="services_captiveportal_users.php?act=del&id=<?=$i; ?>" onclick="return confirm('Do you really want to delete this user?')"><img src="x.gif" title="delete user" width="17" height="17" border="0"></a></td>
</tr>
-<?php
- }
- }
- echo '
- <tr>
- <td class="list" colspan="3"></td>
- <td class="list">
- <table border="0" cellspacing="0" cellpadding="1">
- <tr>
- <td valign="middle"><a href="services_captiveportal_users.php?act=new"><img src="./themes/'.$g['theme'].'/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </div>
- ';
-}
-?>
-
- </td>
- </tr>
- </table>
+ <?php $i++; endforeach; ?>
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list"> <a href="services_captiveportal_users_edit.php"><img src="plus.gif" title="add user" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+</td>
+</tr>
+</table>
<?php include("fend.inc"); ?>
-
-</body>
-</html>
OpenPOWER on IntegriCloud