Project

General

Profile

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