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 d88c6a9f Scott Ullrich
$pgtitle = array("Services","User Manager");
79 4df96eff Scott Ullrich
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
<script language="javascript" type="text/javascript" src="datetimepicker.js">
86
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
87
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
88
//For this script, visit http://www.javascriptkit.com
89
</script>
90
<?php if ($input_errors) print_input_errors($input_errors); ?>
91
<?php if ($savemsg) print_info_box($savemsg); ?>
92
<table width="100%" border="0" cellpadding="0" cellspacing="0">
93 2d6c7764 Scott Ullrich
  <tr><td class="tabnavtbl">
94 9699028a Scott Ullrich
  <ul id="tabnav">
95 2d6c7764 Scott Ullrich
	<li class="tabinact1"><a href="services_captiveportal.php">Captive portal</a></li>
96
	<li class="tabinact"><a href="services_captiveportal_mac.php">Pass-through MAC</a></li>
97
	<li class="tabinact"><a href="services_captiveportal_ip.php">Allowed IP addresses</a></li>
98 12bd7e25 Scott Ullrich
	<li class="tabact">User Manager</li>
99 9699028a Scott Ullrich
  </ul>
100
  </td></tr>
101
  <tr>
102
  <td class="tabcont">
103
<?php
104
if($_GET['act']=="new" || $_GET['act']=="edit"){
105
	if($_GET['act']=="edit" && isset($_GET['username'])){
106
		$user=$config['users'][$_GET['username']];
107
	}
108
?>
109
	<form action="services_usermanager.php" method="post" name="iform" id="iform">
110
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
111 3d8deb41 Scott Ullrich
                <tr>
112 9699028a Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Username</td>
113 3d8deb41 Scott Ullrich
                  <td width="78%" class="vtable">
114 b5c78501 Seth Mos
                    <input name="username" type="text" class="formfld user" id="username" size="20" value="<? echo $_GET['username']; ?>">
115 9699028a Scott Ullrich
                    <br>
116 5bc18ff3 Colin Smith
                    <span class="vexpl">Enter the desired username.</span></td>
117 9699028a Scott Ullrich
                </tr>
118 3d8deb41 Scott Ullrich
                <tr>
119 9699028a Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Password</td>
120 3d8deb41 Scott Ullrich
                  <td width="78%" class="vtable">
121 b5c78501 Seth Mos
                    <input name="password1" type="password" class="formfld pwd" id="password1" size="20" value="<?php echo ($_GET['act']=='edit' ? "********" : "" ); ?>">
122 9699028a Scott Ullrich
                    <br>
123 5bc18ff3 Colin Smith
                    <span class="vexpl">Enter the desired password.</span></td>
124 9699028a Scott Ullrich
                </tr>
125 3d8deb41 Scott Ullrich
                <tr>
126 5bc18ff3 Colin Smith
                  <td width="22%" valign="top" class="vncellreq">Password confirmation</td>
127 3d8deb41 Scott Ullrich
                  <td width="78%" class="vtable">
128 b5c78501 Seth Mos
                    <input name="password2" type="password" class="formfld pwd" id="password2" size="20" value="<?php echo ($_GET['act']=='edit' ? "********" : "" ); ?>">
129 9699028a Scott Ullrich
                    <br>
130 5bc18ff3 Colin Smith
                    <span class="vexpl">Confirm the above password.</span></td>
131 9699028a Scott Ullrich
                </tr>
132 3d8deb41 Scott Ullrich
                <tr>
133 5bc18ff3 Colin Smith
                  <td width="22%" valign="top" class="vncell">Full name</td>
134 3d8deb41 Scott Ullrich
                  <td width="78%" class="vtable">
135 b5c78501 Seth Mos
                    <input name="fullname" type="text" class="formfld unknown" id="fullname" size="20" value="<? echo $user['fullname']; ?>">
136 9699028a Scott Ullrich
                    <br>
137 5bc18ff3 Colin Smith
                    Enter the user's full name.</td>
138 9699028a Scott Ullrich
                </tr>
139 3d8deb41 Scott Ullrich
                <tr>
140 9699028a Scott Ullrich
                  <td width="22%" valign="top" class="vncell">Expiration Date</td>
141 3d8deb41 Scott Ullrich
                  <td width="78%" class="vtable">
142 b5c78501 Seth Mos
                    <input name="expirationdate" type="text" class="formfld unknown" id="expirationdate" size="10" value="<? echo $user['expirationdate']; ?>">
143 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>
144 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>
145 9699028a Scott Ullrich
                </tr>
146 3d8deb41 Scott Ullrich
                <tr>
147 9699028a Scott Ullrich
                  <td width="22%" valign="top">&nbsp;</td>
148 3d8deb41 Scott Ullrich
                  <td width="78%">
149
                    <input name="save" type="submit" class="formbtn" value="Save">
150 9699028a Scott Ullrich
                    <input name="old_username" type="hidden" value="<? echo $_GET['username'];?>">
151
                  </td>
152
                </tr>
153
              </table>
154
     </form>
155
<?php
156
} else {
157
	echo <<<END
158
     <table width="100%" border="0" cellpadding="0" cellspacing="0">
159
                <tr>
160
                  <td width="35%" class="listhdrr">Username</td>
161
                  <td width="20%" class="listhdrr">Full Name</td>
162
                  <td width="35%" class="listhdr">Expires</td>
163
                  <td width="10%" class="list"></td>
164
		</tr>
165
END;
166
	if(is_array($config['users'])){
167
		foreach($config['users'] as $username => $user){
168
?>
169
		<tr>
170
                  <td class="listlr">
171
                    <?php echo $username; ?>&nbsp;
172
                  </td>
173
                  <td class="listr">
174
                    <?php echo $user['fullname']; ?>&nbsp;
175
                  </td>
176
                  <td class="listbg">
177
                    <?php echo $user['expirationdate']; ?>&nbsp;
178
                  </td>
179 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>
180
                     &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>
181 9699028a Scott Ullrich
		</tr>
182
<?php
183
		}
184
	}
185
	echo <<<END
186 3d8deb41 Scott Ullrich
		<tr>
187 9699028a Scott Ullrich
                  <td class="list" colspan="3"></td>
188 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>
189 9699028a Scott Ullrich
	        </tr>
190
     </table>
191
END;
192
}
193
?>
194 3d8deb41 Scott Ullrich
195 9699028a Scott Ullrich
  </td>
196
  </tr>
197
  </table>
198
<?php include("fend.inc"); ?>