Project

General

Profile

Download (8.77 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
require("guiconfig.inc");
35
if(isset($_POST['save'])){
36
	$_POST['username']=trim($_POST['username']);
37
	if($_POST['old_username']!="" && $_POST['old_username']!=$_POST['username']){
38
		$config['users'][$_POST['username']]=$config['users'][$_POST['old_username']];
39
		unset($config['users'][$_POST['old_username']]);
40
	}
41
	foreach(Array('fullname','expirationdate') as $field){
42
		$config['users'][$_POST['username']][$field]=trim($_POST[$field]);
43
	}
44
	if(trim($_POST['password1'])!="********" && trim($_POST['password1'])!=""){
45
		if(trim($_POST['password1'])==trim($_POST['password2'])){
46
			$config['users'][$_POST['username']]['password']=md5(trim($_POST['password1']));
47
		} else {
48
			$input_errors[]="passwords did not match --> password was not changed!";
49
		}
50
	}
51
	if($_POST['username']=="" || trim($_POST['password1'])==""){
52 5bc18ff3 Colin Smith
		$input_errors[] = "Username and password must not be empty!";
53 9699028a Scott Ullrich
		$_GET['act']="new";
54
	} else {
55
		write_config();
56
		$savemsg=$_POST['username']." successfully saved<br>";
57
	}
58
} else if ($_GET['act']=="delete" && isset($_GET['username'])){
59
	unset($config['users'][$_GET['username']]);
60
	write_config();
61
	$savemsg=$_GET['username']." successfully deleted<br>";
62
}
63
//erase expired accounts
64
$changed=false;
65
if(is_array($config['users'])){
66
	foreach($config['users'] as $username => $user){
67
		if(trim($user['expirationdate'])!="" && strtotime("-1 day")>strtotime($user['expirationdate'])){
68
			unset($config['users'][$username]);
69
			$changed=true;
70
			$savemsg.="$username has expired --> $username was deleted<br>";
71
		}
72
	}
73
	if($changed){
74
		write_config();
75
	}
76
}
77
78 4df96eff Scott Ullrich
$pgtitle = "Services: User Manager";
79
include("head.inc");
80
81 9699028a Scott Ullrich
?>
82 4df96eff Scott Ullrich
83 3d8deb41 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
84 9699028a Scott Ullrich
<?php include("fbegin.inc"); ?>
85 74f446e8 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
86 9699028a Scott Ullrich
<script language="javascript" type="text/javascript" src="datetimepicker.js">
87
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
88
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
89
//For this script, visit http://www.javascriptkit.com
90
</script>
91
<?php if ($input_errors) print_input_errors($input_errors); ?>
92
<?php if ($savemsg) print_info_box($savemsg); ?>
93
<table width="100%" border="0" cellpadding="0" cellspacing="0">
94 2d6c7764 Scott Ullrich
  <tr><td class="tabnavtbl">
95 9699028a Scott Ullrich
  <ul id="tabnav">
96 2d6c7764 Scott Ullrich
	<li class="tabinact1"><a href="services_captiveportal.php">Captive portal</a></li>
97
	<li class="tabinact"><a href="services_captiveportal_mac.php">Pass-through MAC</a></li>
98
	<li class="tabinact"><a href="services_captiveportal_ip.php">Allowed IP addresses</a></li>
99 12bd7e25 Scott Ullrich
	<li class="tabact">User Manager</li>
100 9699028a Scott Ullrich
  </ul>
101
  </td></tr>
102
  <tr>
103
  <td class="tabcont">
104
<?php
105
if($_GET['act']=="new" || $_GET['act']=="edit"){
106
	if($_GET['act']=="edit" && isset($_GET['username'])){
107
		$user=$config['users'][$_GET['username']];
108
	}
109
?>
110
	<form action="services_usermanager.php" method="post" name="iform" id="iform">
111
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
112 3d8deb41 Scott Ullrich
                <tr>
113 9699028a Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Username</td>
114 3d8deb41 Scott Ullrich
                  <td width="78%" class="vtable">
115
                    <input name="username" type="text" class="formfld" id="username" size="20" value="<? echo $_GET['username']; ?>">
116 9699028a Scott Ullrich
                    <br>
117 5bc18ff3 Colin Smith
                    <span class="vexpl">Enter the desired username.</span></td>
118 9699028a Scott Ullrich
                </tr>
119 3d8deb41 Scott Ullrich
                <tr>
120 9699028a Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Password</td>
121 3d8deb41 Scott Ullrich
                  <td width="78%" class="vtable">
122
                    <input name="password1" type="password" class="formfld" id="password1" size="20" value="<?php echo ($_GET['act']=='edit' ? "********" : "" ); ?>">
123 9699028a Scott Ullrich
                    <br>
124 5bc18ff3 Colin Smith
                    <span class="vexpl">Enter the desired password.</span></td>
125 9699028a Scott Ullrich
                </tr>
126 3d8deb41 Scott Ullrich
                <tr>
127 5bc18ff3 Colin Smith
                  <td width="22%" valign="top" class="vncellreq">Password confirmation</td>
128 3d8deb41 Scott Ullrich
                  <td width="78%" class="vtable">
129
                    <input name="password2" type="password" class="formfld" id="password2" size="20" value="<?php echo ($_GET['act']=='edit' ? "********" : "" ); ?>">
130 9699028a Scott Ullrich
                    <br>
131 5bc18ff3 Colin Smith
                    <span class="vexpl">Confirm the above password.</span></td>
132 9699028a Scott Ullrich
                </tr>
133 3d8deb41 Scott Ullrich
                <tr>
134 5bc18ff3 Colin Smith
                  <td width="22%" valign="top" class="vncell">Full name</td>
135 3d8deb41 Scott Ullrich
                  <td width="78%" class="vtable">
136 9699028a Scott Ullrich
                    <input name="fullname" type="text" class="formfld" id="fullname" size="20" value="<? echo $user['fullname']; ?>">
137
                    <br>
138 5bc18ff3 Colin Smith
                    Enter the user's full name.</td>
139 9699028a Scott Ullrich
                </tr>
140 3d8deb41 Scott Ullrich
                <tr>
141 9699028a Scott Ullrich
                  <td width="22%" valign="top" class="vncell">Expiration Date</td>
142 3d8deb41 Scott Ullrich
                  <td width="78%" class="vtable">
143 9699028a Scott Ullrich
                    <input name="expirationdate" type="text" class="formfld" id="expirationdate" size="10" value="<? echo $user['expirationdate']; ?>">
144 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>
145 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>
146 9699028a Scott Ullrich
                </tr>
147 3d8deb41 Scott Ullrich
                <tr>
148 9699028a Scott Ullrich
                  <td width="22%" valign="top">&nbsp;</td>
149 3d8deb41 Scott Ullrich
                  <td width="78%">
150
                    <input name="save" type="submit" class="formbtn" value="Save">
151 9699028a Scott Ullrich
                    <input name="old_username" type="hidden" value="<? echo $_GET['username'];?>">
152
                  </td>
153
                </tr>
154
              </table>
155
     </form>
156
<?php
157
} else {
158
	echo <<<END
159
     <table width="100%" border="0" cellpadding="0" cellspacing="0">
160
                <tr>
161
                  <td width="35%" class="listhdrr">Username</td>
162
                  <td width="20%" class="listhdrr">Full Name</td>
163
                  <td width="35%" class="listhdr">Expires</td>
164
                  <td width="10%" class="list"></td>
165
		</tr>
166
END;
167
	if(is_array($config['users'])){
168
		foreach($config['users'] as $username => $user){
169
?>
170
		<tr>
171
                  <td class="listlr">
172
                    <?php echo $username; ?>&nbsp;
173
                  </td>
174
                  <td class="listr">
175
                    <?php echo $user['fullname']; ?>&nbsp;
176
                  </td>
177
                  <td class="listbg">
178
                    <?php echo $user['expirationdate']; ?>&nbsp;
179
                  </td>
180 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>
181
                     &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>
182 9699028a Scott Ullrich
		</tr>
183
<?php
184
		}
185
	}
186
	echo <<<END
187 3d8deb41 Scott Ullrich
		<tr>
188 9699028a Scott Ullrich
                  <td class="list" colspan="3"></td>
189 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>
190 9699028a Scott Ullrich
	        </tr>
191
     </table>
192
END;
193
}
194
?>
195 3d8deb41 Scott Ullrich
196 9699028a Scott Ullrich
  </td>
197
  </tr>
198
  </table>
199
<?php include("fend.inc"); ?>