From c980716edb28b33e6340f00ab37ab36f5b860950 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Tue, 13 Sep 2005 18:34:39 +0000 Subject: 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 --- usr/local/www/services_captiveportal.php | 272 ++++++++------------ usr/local/www/services_captiveportal_ip.php | 84 +++---- usr/local/www/services_captiveportal_ip_edit.php | 51 ++-- usr/local/www/services_captiveportal_mac.php | 75 ++---- usr/local/www/services_captiveportal_mac_edit.php | 47 ++-- usr/local/www/services_captiveportal_users.php | 288 +++++----------------- 6 files changed, 252 insertions(+), 565 deletions(-) (limited to 'usr/local') 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 -. 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"); - ?> - - -

-
@@ -283,38 +195,33 @@ function enable_change(enable_change) {
-
- +
-
- - +
+ + - + - + - - + - + 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. @@ -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. - - @@ -411,12 +342,12 @@ to access after they've authenticated.
Paste an RSA private key in PEM format here. - + - +The contents of the HTML file that you upload here are displayed when a RADIUS authentication error occurs. - + - - + + 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.
  onClick="enable_change(false)"> Enable captive portal
Interface
Hard timeout - + + minutes
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).
Logout popup window + > Enable logout popup window
- 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.
Redirection URL
RADIUS server - - - - - - - - - - + + + + + + + + + + +
No Authentication:   onClick="auth_method_change()">
Local Usermanager:   onClick="auth_method_change()">
RADIUS Authentication:   onClick="auth_method_change()">
MAC filtering + > + Disable MAC filtering
+ 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).
Authentication + + + + + + + + + + + + + @@ -375,19 +295,30 @@ to access after they've authenticated. - + -
> + No authentication
> + Local user manager
> + RADIUS authentication
  
IP address:
Accounting:   onClick="radacct_change()">> + send RADIUS accounting packets
Accounting port:  
+
Reauthentication:  > + reauthenticate connected users every minute

+ > no accounting updates
+ > stop/start accounting
+ > interim update

- 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). +

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.
HTTPS login - onClick="enable_https()"> + > Enable HTTPS login
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.
Portal page contents +
- View current page + View current page

@@ -437,25 +368,24 @@ with a submit button (name="accept") and a hidden field with name=&quo

- View current page + View current page

-The contents of the HTML file that you upload here are displayed when an authentication error occurs.
  - + +
  Note:
-
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.
-
@@ -466,5 +396,3 @@ enable_change(false); //--> - - 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 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"); - ?> - - -

You must apply the changes in order for them to take effect.");?>
+

-
- +
-
- +
+ @@ -103,37 +94,25 @@ include("head.inc"); - - - + - + - +
IP address Description
- "; - ?> + + "; + ?> - any"; - ?> + any"; + ?> -   + +   - - - - - -
-
+  
  - - - - -
-

@@ -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 from addresses, it may be used to always allow pass-through access from a client behind the captive portal.

- + - +
any x.x.x.x any x.x.x.x All connections to the IP address are allowed
x.x.x.x any    x.x.x.x any    All connections from the IP address are allowed
 
-
- - 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 - 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"); - ?> - -

- - - - -
Direction + -
- Use From to always allow an IP address through the captive portal (without authentication). +
+ Use From to always allow an IP address through the captive portal (without authentication). Use To to allow access from all clients (even non-authenticated ones) behind the portal to this IP address.
IP address + -
+
IP address
Description +
You may enter a description here for your reference (not parsed).
  - + + 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 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"); - ?> - - -

You must apply the changes in order for them to take effect.");?>
+

-
- +
-
- +
+ @@ -103,50 +94,30 @@ include("head.inc"); - - - + - + - + - - - - - + 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.
MAC address Description
+ -   + +   - - - - - -
-
+  
  - - - - -
-
 
Note:
- 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.
 
-
- - 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 - 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"); - ?> - - -

- - - - + +
MAC address + -
+
MAC address (6 hex octets separated by colons)
Description +
You may enter a description here for your reference (not parsed).
  + 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 -. + + Copyright (C) 2003-2005 Manuel Kasper . All rights reserved. Copyright (C) 2005 Pascal Suter . - 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
"; + 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
"; } + //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
"; - } - } - 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; +} ?> - - -

- - - - + + + +
- +
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
Username - -
- Username to be used
Password - "> -
- Password for the user
confirm Password - "> -
- Confirm the above Password
Full Name - -
- Full Name of current user, for your own information only
Expiration Date - - Pick a date -
enter nothing if account doesnt expire, otherwhise enter the expiration date in us-format: mm/dd/yyyy
  - - -
-
- - - + - -
+ - + -END; - if(is_array($config['users'])){ - foreach($config['users'] as $username => $user){ -?> + - - - - + - - - - -
UsernameFull NameFull name Expires
-   - -   + +   -   + +   - - - - - -
+
+   +  
- - - - -
-
- - '; -} -?> - -
+ +
+
- - - -- cgit v1.1