Project

General

Profile

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