1 |
9699028a
|
Scott Ullrich
|
#!/usr/local/bin/php
|
2 |
3d8deb41
|
Scott Ullrich
|
<?php
|
3 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
4 |
9699028a
|
Scott Ullrich
|
/*
|
5 |
|
|
services_usermanager.php
|
6 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
7 |
3d8deb41
|
Scott Ullrich
|
|
8 |
9699028a
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
9 |
|
|
All rights reserved.
|
10 |
3f345054
|
Scott Ullrich
|
Copyright (C) 2005 Pascal Suter <d-pfsense-dev@psuter.ch>.
|
11 |
3d8deb41
|
Scott Ullrich
|
All rights reserved.
|
12 |
9699028a
|
Scott Ullrich
|
(files was created by Pascal based on the source code of services_captiveportal.php from Manuel)
|
13 |
3d8deb41
|
Scott Ullrich
|
|
14 |
9699028a
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
15 |
|
|
modification, are permitted provided that the following conditions are met:
|
16 |
3d8deb41
|
Scott Ullrich
|
|
17 |
9699028a
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
18 |
|
|
this list of conditions and the following disclaimer.
|
19 |
3d8deb41
|
Scott Ullrich
|
|
20 |
9699028a
|
Scott Ullrich
|
2. Redistributions in binary form must reproduce the above copyright
|
21 |
|
|
notice, this list of conditions and the following disclaimer in the
|
22 |
|
|
documentation and/or other materials provided with the distribution.
|
23 |
3d8deb41
|
Scott Ullrich
|
|
24 |
9699028a
|
Scott Ullrich
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
25 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
26 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
27 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
28 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
29 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
30 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
31 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
32 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
33 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
34 |
|
|
*/
|
35 |
|
|
require("guiconfig.inc");
|
36 |
|
|
if(isset($_POST['save'])){
|
37 |
|
|
$_POST['username']=trim($_POST['username']);
|
38 |
|
|
if($_POST['old_username']!="" && $_POST['old_username']!=$_POST['username']){
|
39 |
|
|
$config['users'][$_POST['username']]=$config['users'][$_POST['old_username']];
|
40 |
|
|
unset($config['users'][$_POST['old_username']]);
|
41 |
|
|
}
|
42 |
|
|
foreach(Array('fullname','expirationdate') as $field){
|
43 |
|
|
$config['users'][$_POST['username']][$field]=trim($_POST[$field]);
|
44 |
|
|
}
|
45 |
|
|
if(trim($_POST['password1'])!="********" && trim($_POST['password1'])!=""){
|
46 |
|
|
if(trim($_POST['password1'])==trim($_POST['password2'])){
|
47 |
|
|
$config['users'][$_POST['username']]['password']=md5(trim($_POST['password1']));
|
48 |
|
|
} else {
|
49 |
|
|
$input_errors[]="passwords did not match --> password was not changed!";
|
50 |
|
|
}
|
51 |
|
|
}
|
52 |
|
|
if($_POST['username']=="" || trim($_POST['password1'])==""){
|
53 |
5bc18ff3
|
Colin Smith
|
$input_errors[] = "Username and password must not be empty!";
|
54 |
9699028a
|
Scott Ullrich
|
$_GET['act']="new";
|
55 |
|
|
} else {
|
56 |
|
|
write_config();
|
57 |
|
|
$savemsg=$_POST['username']." successfully saved<br>";
|
58 |
|
|
}
|
59 |
|
|
} else if ($_GET['act']=="delete" && isset($_GET['username'])){
|
60 |
|
|
unset($config['users'][$_GET['username']]);
|
61 |
|
|
write_config();
|
62 |
|
|
$savemsg=$_GET['username']." successfully deleted<br>";
|
63 |
|
|
}
|
64 |
|
|
//erase expired accounts
|
65 |
|
|
$changed=false;
|
66 |
|
|
if(is_array($config['users'])){
|
67 |
|
|
foreach($config['users'] as $username => $user){
|
68 |
|
|
if(trim($user['expirationdate'])!="" && strtotime("-1 day")>strtotime($user['expirationdate'])){
|
69 |
|
|
unset($config['users'][$username]);
|
70 |
|
|
$changed=true;
|
71 |
|
|
$savemsg.="$username has expired --> $username was deleted<br>";
|
72 |
|
|
}
|
73 |
|
|
}
|
74 |
|
|
if($changed){
|
75 |
|
|
write_config();
|
76 |
|
|
}
|
77 |
|
|
}
|
78 |
|
|
|
79 |
4df96eff
|
Scott Ullrich
|
$pgtitle = "Services: User Manager";
|
80 |
|
|
include("head.inc");
|
81 |
|
|
|
82 |
9699028a
|
Scott Ullrich
|
?>
|
83 |
4df96eff
|
Scott Ullrich
|
|
84 |
3d8deb41
|
Scott Ullrich
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
85 |
9699028a
|
Scott Ullrich
|
<?php include("fbegin.inc"); ?>
|
86 |
74f446e8
|
Bill Marquette
|
<p class="pgtitle"><?=$pgtitle?></p>
|
87 |
9699028a
|
Scott Ullrich
|
<script language="javascript" type="text/javascript" src="datetimepicker.js">
|
88 |
|
|
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
|
89 |
|
|
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
|
90 |
|
|
//For this script, visit http://www.javascriptkit.com
|
91 |
|
|
</script>
|
92 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
93 |
|
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
94 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
95 |
2d6c7764
|
Scott Ullrich
|
<tr><td class="tabnavtbl">
|
96 |
9699028a
|
Scott Ullrich
|
<ul id="tabnav">
|
97 |
2d6c7764
|
Scott Ullrich
|
<li class="tabinact1"><a href="services_captiveportal.php">Captive portal</a></li>
|
98 |
|
|
<li class="tabinact"><a href="services_captiveportal_mac.php">Pass-through MAC</a></li>
|
99 |
|
|
<li class="tabinact"><a href="services_captiveportal_ip.php">Allowed IP addresses</a></li>
|
100 |
12bd7e25
|
Scott Ullrich
|
<li class="tabact">User Manager</li>
|
101 |
9699028a
|
Scott Ullrich
|
</ul>
|
102 |
|
|
</td></tr>
|
103 |
|
|
<tr>
|
104 |
|
|
<td class="tabcont">
|
105 |
|
|
<?php
|
106 |
|
|
if($_GET['act']=="new" || $_GET['act']=="edit"){
|
107 |
|
|
if($_GET['act']=="edit" && isset($_GET['username'])){
|
108 |
|
|
$user=$config['users'][$_GET['username']];
|
109 |
|
|
}
|
110 |
|
|
?>
|
111 |
|
|
<form action="services_usermanager.php" method="post" name="iform" id="iform">
|
112 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
113 |
3d8deb41
|
Scott Ullrich
|
<tr>
|
114 |
9699028a
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">Username</td>
|
115 |
3d8deb41
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
116 |
|
|
<input name="username" type="text" class="formfld" id="username" size="20" value="<? echo $_GET['username']; ?>">
|
117 |
9699028a
|
Scott Ullrich
|
<br>
|
118 |
5bc18ff3
|
Colin Smith
|
<span class="vexpl">Enter the desired username.</span></td>
|
119 |
9699028a
|
Scott Ullrich
|
</tr>
|
120 |
3d8deb41
|
Scott Ullrich
|
<tr>
|
121 |
9699028a
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">Password</td>
|
122 |
3d8deb41
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
123 |
|
|
<input name="password1" type="password" class="formfld" id="password1" size="20" value="<?php echo ($_GET['act']=='edit' ? "********" : "" ); ?>">
|
124 |
9699028a
|
Scott Ullrich
|
<br>
|
125 |
5bc18ff3
|
Colin Smith
|
<span class="vexpl">Enter the desired password.</span></td>
|
126 |
9699028a
|
Scott Ullrich
|
</tr>
|
127 |
3d8deb41
|
Scott Ullrich
|
<tr>
|
128 |
5bc18ff3
|
Colin Smith
|
<td width="22%" valign="top" class="vncellreq">Password confirmation</td>
|
129 |
3d8deb41
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
130 |
|
|
<input name="password2" type="password" class="formfld" id="password2" size="20" value="<?php echo ($_GET['act']=='edit' ? "********" : "" ); ?>">
|
131 |
9699028a
|
Scott Ullrich
|
<br>
|
132 |
5bc18ff3
|
Colin Smith
|
<span class="vexpl">Confirm the above password.</span></td>
|
133 |
9699028a
|
Scott Ullrich
|
</tr>
|
134 |
3d8deb41
|
Scott Ullrich
|
<tr>
|
135 |
5bc18ff3
|
Colin Smith
|
<td width="22%" valign="top" class="vncell">Full name</td>
|
136 |
3d8deb41
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
137 |
9699028a
|
Scott Ullrich
|
<input name="fullname" type="text" class="formfld" id="fullname" size="20" value="<? echo $user['fullname']; ?>">
|
138 |
|
|
<br>
|
139 |
5bc18ff3
|
Colin Smith
|
Enter the user's full name.</td>
|
140 |
9699028a
|
Scott Ullrich
|
</tr>
|
141 |
3d8deb41
|
Scott Ullrich
|
<tr>
|
142 |
9699028a
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncell">Expiration Date</td>
|
143 |
3d8deb41
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
144 |
9699028a
|
Scott Ullrich
|
<input name="expirationdate" type="text" class="formfld" id="expirationdate" size="10" value="<? echo $user['expirationdate']; ?>">
|
145 |
677c0869
|
Erik Kristensen
|
<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>
|
146 |
5bc18ff3
|
Colin Smith
|
<br> <span class="vexpl">Enter this acocunt's expiration date in us-format (mm/dd/yyyy) or leave this field empty for no expiration.</span></td>
|
147 |
9699028a
|
Scott Ullrich
|
</tr>
|
148 |
3d8deb41
|
Scott Ullrich
|
<tr>
|
149 |
9699028a
|
Scott Ullrich
|
<td width="22%" valign="top"> </td>
|
150 |
3d8deb41
|
Scott Ullrich
|
<td width="78%">
|
151 |
|
|
<input name="save" type="submit" class="formbtn" value="Save">
|
152 |
9699028a
|
Scott Ullrich
|
<input name="old_username" type="hidden" value="<? echo $_GET['username'];?>">
|
153 |
|
|
</td>
|
154 |
|
|
</tr>
|
155 |
|
|
</table>
|
156 |
|
|
</form>
|
157 |
|
|
<?php
|
158 |
|
|
} else {
|
159 |
|
|
echo <<<END
|
160 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
161 |
|
|
<tr>
|
162 |
|
|
<td width="35%" class="listhdrr">Username</td>
|
163 |
|
|
<td width="20%" class="listhdrr">Full Name</td>
|
164 |
|
|
<td width="35%" class="listhdr">Expires</td>
|
165 |
|
|
<td width="10%" class="list"></td>
|
166 |
|
|
</tr>
|
167 |
|
|
END;
|
168 |
|
|
if(is_array($config['users'])){
|
169 |
|
|
foreach($config['users'] as $username => $user){
|
170 |
|
|
?>
|
171 |
|
|
<tr>
|
172 |
|
|
<td class="listlr">
|
173 |
|
|
<?php echo $username; ?>
|
174 |
|
|
</td>
|
175 |
|
|
<td class="listr">
|
176 |
|
|
<?php echo $user['fullname']; ?>
|
177 |
|
|
</td>
|
178 |
|
|
<td class="listbg">
|
179 |
|
|
<?php echo $user['expirationdate']; ?>
|
180 |
|
|
</td>
|
181 |
677c0869
|
Erik Kristensen
|
<td valign="middle" nowrap class="list"> <a href="services_usermanager.php?act=edit&username=<?php echo $username; ?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
|
182 |
|
|
<a href="services_usermanager.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>
|
183 |
9699028a
|
Scott Ullrich
|
</tr>
|
184 |
|
|
<?php
|
185 |
|
|
}
|
186 |
|
|
}
|
187 |
|
|
echo <<<END
|
188 |
3d8deb41
|
Scott Ullrich
|
<tr>
|
189 |
9699028a
|
Scott Ullrich
|
<td class="list" colspan="3"></td>
|
190 |
677c0869
|
Erik Kristensen
|
<td class="list"> <a href="services_usermanager.php?act=new"><img src="./themes/".$g['theme']."/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
|
191 |
9699028a
|
Scott Ullrich
|
</tr>
|
192 |
|
|
</table>
|
193 |
|
|
END;
|
194 |
|
|
}
|
195 |
|
|
?>
|
196 |
3d8deb41
|
Scott Ullrich
|
|
197 |
9699028a
|
Scott Ullrich
|
</td>
|
198 |
|
|
</tr>
|
199 |
|
|
</table>
|
200 |
|
|
<?php include("fend.inc"); ?>
|