File: user_edit.php3

package info (click to toggle)
freeradius 1.0.2-4sarge3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 9,792 kB
  • ctags: 6,980
  • sloc: ansic: 52,618; sh: 9,731; php: 5,764; perl: 2,309; makefile: 1,056; sql: 730; python: 159; tcl: 33; sed: 23
file content (281 lines) | stat: -rw-r--r-- 7,547 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
<?php
if ($edit_group == 1){
	header("Location: group_admin.php3?login=$group_to_edit");
	exit;
}
require('../conf/config.php3');
require('../lib/attrshow.php3');
require('../lib/defaults.php3');
if ($user_type != 'group'){
	if (is_file("../lib/$config[general_lib_type]/user_info.php3"))
		include("../lib/$config[general_lib_type]/user_info.php3");
}
else{
	if (is_file("../lib/$config[general_lib_type]/group_info.php3"))
		include("../lib/$config[general_lib_type]/group_info.php3");
}
if ($config[general_lib_type] == 'sql' && $config[sql_use_operators] == 'true'){
	$colspan=2;
	$show_ops = 1;
	include("../lib/operators.php3");
}
else{
	$show_ops = 0;
	$colspan=1;
}


echo <<<EOM
<html>
<head>
EOM;

if ($user_type != 'group')
	echo " <title>subscription configuration for $login ($cn)</title>\n";
else
	echo " <title>subscription configuration for $login</title>\n";
?>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $config[general_charset]?>">
<link rel="stylesheet" href="style.css">
</head>
<body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black">
<center>
<table border=0 width=550 cellpadding=0 cellspacing=0>
<tr valign=top>
<td align=center><img src="images/title2.gif"></td>
</tr>
</table>
<table border=0 width=400 cellpadding=0 cellspacing=2>

<?php
if ($user_type != 'group')
	include("../html/user_toolbar.html.php3");
else
	include("../html/group_toolbar.html.php3");	

print <<<EOM
</table>

<br>
<table border=0 width=540 cellpadding=1 cellspacing=1>
<tr valign=top>
<td width=75%>&nbsp;</td>
<td bgcolor="black" width=25% align=right>
	<table border=0 width="200" cellpadding=2 cellspacing=0>
	<tr bgcolor="#907030" align=center valign=top><th>
	<font color="white">User Preferences for $login ($cn)</font>&nbsp;
	</th></tr>
	</table>
</td></tr>
<tr bgcolor="black" valign=top><td colspan=2>
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
	<tr><td>
EOM;
   
if ($change == 1){
	if (is_file("../lib/$config[general_lib_type]/change_attrs.php3"))
		include("../lib/$config[general_lib_type]/change_attrs.php3");
	if ($user_type != 'group'){
		if ($config[general_show_user_password] != 'no' && $passwd != '' 
			&& is_file("../lib/$config[general_lib_type]/change_passwd.php3"))
			include("../lib/$config[general_lib_type]/change_passwd.php3");
		if (is_file("../lib/$config[general_lib_type]/user_info.php3"))
			include("../lib/$config[general_lib_type]/user_info.php3");
	}
	else{
		if (is_file("../lib/$config[general_lib_type]/group_info.php3"))
			include("../lib/$config[general_lib_type]/group_info.php3");
	}
}
else if ($badusers == 1){
	if (is_file("../lib/add_badusers.php3"))
		include("../lib/add_badusers.php3");
}
	
?>
   <form name="edituser" method=post>
      <input type=hidden name=login value=<?php print $login ?>>
      <input type=hidden name=user_type value=<?php print $user_type ?>>
      <input type=hidden name=change value="0">
      <input type=hidden name=add value="0">
      <input type=hidden name=badusers value="0">
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
<?php
if ($user_type == 'group')
	echo <<<EOM
Note: The attributes contained in the groups the user belongs to<br>
are extracted after the attributes in the radcheck/radreply tables.<br>
Please take that into consideration when adding attributes in the group<br>
and selecting operators.
<br>
EOM;
if ($user_type != 'group' && $config[general_show_user_password] != 'no'){
	echo <<<EOM
<tr>
<td align=right colspan=$colspan bgcolor="#d0ddb0">
User Password (changes only)<br>
EOM;
if ($user_password_exists == 'yes')
	echo "<font size=-2>User password <font color=\"green\"><b>exists</b></font></font>\n";
else
	echo "<font size=-2>User password <font color=\"red\"><b>does not exist</b></font></font>\n";
	echo <<<EOM
</td>
<td>
<input type=password name=passwd value="" size=40>
</td>
</tr>
EOM;
}
	foreach($show_attrs as $key => $desc){
		$name = $attrmap["$key"];
		$generic = $attrmap[generic]["$key"];
		if ($name == 'none')
			continue;
		unset($vals);
		unset($selected);
		unset($ops);
		$def_added = 0;
		if ($item_vals["$key"][count]){
			for($i=0;$i<$item_vals["$key"][count];$i++){
				$vals[] = $item_vals["$key"][$i];
				$ops[] = $item_vals["$key"][operator][$i];
			}
		}
		else{
			if ($default_vals["$key"][count]){
				for($i=0;$i<$default_vals["$key"][count];$i++){
					$vals[] = $default_vals["$key"][$i];
					$ops[] = $default_vals["$key"][operator][$i];
				}
			}
			else{
				$vals[] = '';
				$ops[] = '=';
			}
			$def_added = 1;
		}
		if ($generic == 'generic' && $def_added == 0){
			for($i=0;$i<$default_vals["$key"][count];$i++){
				$vals[] = $default_vals["$key"][$i];
				$ops[] = $default_vals["$key"][operator][$i];
			}
		}	
		if ($add && $name == $add_attr){
			$vals[] = $default_vals["$key"][0];
			$ops[] = ($default_vals["$key"][operator][0] != '') ? $default_vals["$key"][operator][0] : '=';
		}

		$i = 0;
		foreach($vals as $val){
			$name1 = $name . $i;
			$val = ereg_replace('"','&quot;',$val);
			$oper_name = $name1 . '_op';
			$oper = $ops[$i];
			$selected[$oper] = 'selected';
			$i++;
			print <<<EOM
<tr>
<td align=right bgcolor="#d0ddb0">
EOM;
			$desc = addslashes($desc);
			eval("\$desc = \"$desc\";");
			$desc = stripslashes($desc);
			if ($i == 1)
				echo "$desc\n";
			else
				echo "$desc ($i)\n";
			print <<<EOM
</td>
EOM;
			if ($show_ops)
				print <<<EOM
<td>
<select name=$oper_name>
<option $selected[$op_eq] value="=">=
<option $selected[$op_set] value=":=">:=
<option $selected[$op_add] value="+=">+=
<option $selected[$op_eq2] value="==">==
<option $selected[$op_ne] value="!=">!=
<option $selected[$op_gt] value=">">&gt;
<option $selected[$op_ge] value=">=">&gt;=
<option $selected[$op_lt] value="<">&lt;
<option $selected[$op_le] value="<=">&lt;=
<option $selected[$op_regeq] value="=~">=~
<option $selected[$op_regne] value="!~">!~
<option $selected[$op_exst] value="=*">=*
<option $selected[$op_nexst] value="!*">!*
</select>
</td>
EOM;

			print <<<EOM
<td>
<input type=text name="$name1" value="$val" size=40>
</td>
</tr>
EOM;
		}
	}
?>
<tr>
<td align=right colspan=<?php print $colspan ?> bgcolor="#d0ddb0">
Add Attribute
</td>
<td>
<select name="add_attr" OnChange="this.form.add.value=1;this.form.submit()">
<?php
foreach ($show_attrs as $key => $desc){
	$name = $attrmap["$key"];
	print <<<EOM
<option value="$name">$desc
EOM;
}
?>
</select>
</td>
</tr>

<?php
if (isset($member_groups)){
	echo <<<EOM
<tr>
<input type=hidden name=edit_group value=0>
<td align=right colspan=$colspan bgcolor="#d0ddb0">
Member of
</td>
<td>
<select name="group_to_edit">
EOM;
	foreach ($member_groups as $group){
		echo "<option value=\"$group\">$group\n";
	}
	echo <<<EOM
</select>
&nbsp;&nbsp;&nbsp;
<input type=submit class=button value="Edit Group" OnClick="this.form.edit_group.value=1">
</td>
</tr>
EOM;
}
?>
	</table>
<br>
<input type=submit class=button value=Change OnClick="this.form.change.value=1">
<?php
if ($user_type != 'group'){
	echo <<<EOM
<br><br>
<input type=submit class=button value="Add to Badusers" OnClick="this.form.badusers.value=1">
<a href="help/badusers_help.html" target=bu_help onclick=window.open("help/badusers_help.html","bu_help","width=600,height=210,toolbar=no,scrollbars=no,resizable=yes") title="BADUSERS Help Page"><font color="blue">&lt;--Help</font></a>
EOM;
}
?>
</form>
	</td></tr>
</table>
</tr>
</table>
</body>
</html>