Subversion Repositories ALCASAR

Rev

Rev 1377 | Rev 1566 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
324 richard 1
<?php
899 richard 2
//gestion de la langue
3
if (is_file("../lib/langues.php"))
4
	include("../lib/langues.php");
324 richard 5
require('/etc/freeradius-web/config.php');
6
require('../lib/attrshow.php');
7
require('../lib/defaults.php');
8
if ($user_type != 'group'){
9
	if (is_file("../lib/$config[general_lib_type]/user_info.php"))
10
		include("../lib/$config[general_lib_type]/user_info.php");
11
	if ($config[general_lib_type] == 'sql' && $config[sql_show_all_groups] == 'true'){
12
		$saved_login = $login;
13
		$login = '';
14
		if (is_file("../lib/sql/group_info.php"))
15
			include("../lib/sql/group_info.php");
16
		$login = $saved_login;
17
	}
18
}
19
else{
20
	if (is_file("../lib/$config[general_lib_type]/group_info.php"))
21
		include("../lib/$config[general_lib_type]/group_info.php");
22
}
23
if ($config[general_lib_type] == 'sql' && $config[sql_use_operators] == 'true'){
24
	$colspan=2;
25
	$show_ops = 1;
26
	include("../lib/operators.php");
27
}
28
else{
29
	$show_ops = 0;
30
	$colspan=1;
31
}
901 richard 32
?>
324 richard 33
<html>
34
<head>
911 richard 35
<title>Users & groups edition</title>
324 richard 36
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $config[general_charset]?>">
37
<link rel="stylesheet" href="/css/style.css">
38
<script language="javascript" type="text/javascript">
39
var chars='0123456789abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ'
40
function password(size)
41
  {
42
  var pass=''
43
  while(pass.length < size)
44
  {
45
    pass+=chars.charAt(Math.round(Math.random() * (chars.length)))
46
  }
47
  document.edituser.passwd.value=pass
48
  document.edituser.pwdgene.value=pass
49
}
50
</script>
51
</head>
52
<body>
53
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
901 richard 54
	<tr><th>
55
<?php
56
if ($user_type != 'group'){ echo "$l_users_managment";} else{ echo "$l_groups_managment";}
57
?>
58
	</th></tr>
324 richard 59
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" 
60
height="2"></td></tr>
61
</TABLE>
62
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
63
	<tr><td valign="middle" align="left">
64
	<center>
925 richard 65
	<table border=0 width=640 cellpadding=0 cellspacing=2>
324 richard 66
<?php
67
if ($user_type != 'group')
68
	{
69
	include("../html/user_toolbar.html.php");
901 richard 70
	$titre=$l_user;
324 richard 71
	}
72
else
73
	{
74
	include("../html/group_toolbar.html.php");
901 richard 75
	$titre=$l_group;
324 richard 76
	}
77
print <<<EOM
78
</table>
79
<br>
925 richard 80
<table border=0 width=620 cellpadding=1 cellspacing=1>
324 richard 81
<tr valign=top>
925 richard 82
<td width=400></td>
83
<td bgcolor="black">
84
	<table border=0 width=100% cellpadding=2 cellspacing=0>
324 richard 85
	<tr bgcolor="#907030" align=center valign=top><th>
910 richard 86
	<font color="white">$titre : $login ($cn)</font>
324 richard 87
	</th></tr>
88
	</table>
89
</td></tr>
90
<tr bgcolor="black" valign=top><td colspan=2>
91
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
92
	<tr><td>
93
EOM;
94
 
95
if ($change == 1){
96
	if (is_file("../lib/$config[general_lib_type]/change_attrs.php"))
97
		include("../lib/$config[general_lib_type]/change_attrs.php");
98
	if ($user_type != 'group'){
99
		if ($config[general_show_user_password] != 'no' && $passwd != '' 
100
			&& is_file("../lib/$config[general_lib_type]/change_passwd.php"))
101
			include("../lib/$config[general_lib_type]/change_passwd.php");
102
		if (is_file("../lib/$config[general_lib_type]/user_info.php"))
103
			include("../lib/$config[general_lib_type]/user_info.php");
104
		if ($group_change && $config[general_lib_type] == 'sql' && $config[sql_show_all_groups] == 'true'){
105
			include("../lib/sql/group_change.php");
106
			include("../lib/defaults.php");
107
		}
1377 richard 108
		# Disconnecting user for re-authentication
109
		$mac=exec("sudo /usr/sbin/chilli_query list | grep \" $login \" | awk '{print $1}'");
110
		exec("sudo /usr/sbin/chilli_query logout $mac");
324 richard 111
	}
112
	else{
113
		if (is_file("../lib/$config[general_lib_type]/group_info.php"))
114
			include("../lib/$config[general_lib_type]/group_info.php");
1377 richard 115
		# Disconnecting all users from the selected group for re-authentication
116
		if (isset($group_members)){
117
			foreach ($group_members as $g_member => $member){
118
				$mac=exec("sudo /usr/sbin/chilli_query list | grep \" $member \" | awk '{print $1}'");
119
				exec("sudo /usr/sbin/chilli_query logout $mac");
120
			}
121
		}
324 richard 122
	}
123
}
124
else if ($badusers == 1){
125
	if (is_file("../lib/add_badusers.php"))
126
		include("../lib/add_badusers.php");
127
}
128
 
129
?>
130
   <form name="edituser" method=post>
131
      <input type=hidden name=login value=<?php print $login ?>>
132
      <input type=hidden name=user_type value=<?php print $user_type ?>>
133
      <input type=hidden name=change value="0">
134
      <input type=hidden name=add value="0">
135
      <input type=hidden name=badusers value="0">
136
      <input type=hidden name=group_change value="0">
137
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
138
<?php
139
if ($user_type != 'group' && $config[general_show_user_password] != 'no'){
140
	echo <<<EOM
141
<tr>
142
<td align=right colspan=$colspan bgcolor="#d0ddb0">
907 richard 143
$l_new_password<br>
324 richard 144
EOM;
145
	echo <<<EOM
146
</td>
147
<td>
925 richard 148
<input type=password name=passwd value="" size=20>
907 richard 149
<br /><input type="button" value="$l_passwd_gen" onclick="password(8)">
925 richard 150
<input type="text" value="" name="pwdgene" size=10 readonly>
324 richard 151
</td>
152
</tr>
153
EOM;
154
}
155
	foreach($show_attrs as $key => $desc){
156
		$name = $attrmap["$key"];
157
		$generic = $attrmap[generic]["$key"];
158
		if ($name == 'none')
159
			continue;
160
		unset($vals);
161
		unset($selected);
162
		unset($ops);
163
		$def_added = 0;
164
		if ($item_vals["$key"][count]){
165
			for($i=0;$i<$item_vals["$key"][count];$i++){
166
				$vals[] = $item_vals["$key"][$i];
167
				$ops[] = $item_vals["$key"][operator][$i];
168
			}
169
		}
170
		else{
171
			if ($default_vals["$key"][count]){
172
				for($i=0;$i<$default_vals["$key"][count];$i++){
173
					$vals[] = $default_vals["$key"][$i];
174
					$ops[] = $default_vals["$key"][operator][$i];
175
				}
176
			}
177
			else{
178
				$vals[] = '';
179
				$ops[] = '=';
180
			}
181
			$def_added = 1;
182
		}
183
		if ($generic == 'generic' && $def_added == 0){
184
			for($i=0;$i<$default_vals["$key"][count];$i++){
185
				$vals[] = $default_vals["$key"][$i];
186
				$ops[] = $default_vals["$key"][operator][$i];
187
			}
188
		}	
189
		if ($add && $name == $add_attr){
190
			$vals[] = $default_vals["$key"][0];
191
			$ops[] = ($default_vals["$key"][operator][0] != '') ? $default_vals["$key"][operator][0] : '=';
192
		}
193
 
194
		$i = 0;
195
		foreach($vals as $val){
196
			$name1 = $name . $i;
197
			$val = ereg_replace('"','&quot;',$val);
198
			$oper_name = $name1 . '_op';
199
			$oper = $ops[$i];
200
			$selected[$oper] = 'selected';
201
			$i++;
899 richard 202
		switch ($key)
203
		{
204
				// $advanced = 1 : champs de saisie amélioré (calendrier, convertisseur, etc.) 
205
			case 'Simultaneous-Use' : 
206
				$advanced=1;
207
				$help_link="help/simultaneous_use_help.html";
208
				$desc=$l_simultaneous_use;
209
				break;
210
			case 'Max-All-Session' :
211
				$advanced=1;
212
				$help_link="help/max_all_session_help.html";
213
				$desc=$l_max_all_session;
214
				break;
215
			case 'Session-Timeout' : 
216
				$advanced=1;
217
				$help_link="help/session_timeout_help.html";
218
				$desc=$l_session_timeout;
219
				break;
220
			case 'Max-Daily-Session' :
221
				$advanced=1;
222
				$help_link="help/session_timeout_help.html";
223
				$desc=$l_daily_timeout;
224
				break;
225
			case 'Max-Monthly-Session' :
226
				$advanced=1;
227
				$help_link="help/session_timeout_help.html";
228
				$desc=$l_monthly_timeout;
229
				break;
230
			case 'Login-Time' : 
231
				$advanced=1;
232
				$help_link="help/login_time_help.html";
233
				$desc=$l_login_time;
234
				break;
235
			case 'Expiration' :
236
				$advanced=1;
237
				$help_link="help/expiration_help.html";
238
				$desc=$l_expiration;
239
				break;
240
			case 'ChilliSpot-Max-Input-Octets' :
241
				$advanced=1;
242
				$help_link="help/chillispot_max_input_octets_help.html";
243
				$desc=$l_max_input_octets;
244
				break;
245
			case 'ChilliSpot-Max-Output-Octets' :
246
				$advanced=1;
247
				$help_link="help/chillispot_max_output_octets_help.html";
248
				$desc=$l_max_output_octets;
249
				break;
250
			case 'ChilliSpot-Max-Total-Octets' :
251
				$advanced=1;
252
				$help_link="help/chillispot_max_total_octets_help.html";
253
				$desc=$l_max_total_octets;
254
				break;
255
			case 'ChilliSpot-Bandwidth-Max-Up' :
256
				$advanced=1;
257
				$help_link="help/chillispot_bandwidth_max_up_help.html";
258
				$desc=$l_max_bandwidth_up;
259
				break;
260
			case 'ChilliSpot-Bandwidth-Max-Down' :
261
				$advanced=1;
262
				$help_link="help/chillispot_bandwidth_max_down_help.html";
263
				$desc=$l_max_bandwidth_down;
264
				break;
265
			case 'WISPr-Redirection-URL' :
266
				$advanced=1;
267
				$help_link="help/wispr_redirection_url_help.html";
268
				$desc=$l_wispr_redirection;
269
				break;
1377 richard 270
			case 'Filter-Id' :
271
				$advanced=1;
272
				$help_link="help/filtering_help.html";
273
				$desc=$l_filtering;
274
				break;
899 richard 275
			default:
276
				$advanced=1;
277
				break;
278
		}
324 richard 279
			print <<<EOM
899 richard 280
			<tr>
281
			<td class="etiquette">
282
			<a href="$help_link" target=help onclick=window.open("$help_link","help","width=600,height=250,toolbar=no,scrollbars=no,resizable=yes") title="$l_click_for_help"><font color="blue">$desc</font></a>
324 richard 283
EOM;
284
			if ($show_ops){
285
				switch ($key)
286
					{
287
					case 'Simultaneous-Use' : 
925 richard 288
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>";
324 richard 289
						break;
290
					case 'Login-Time' : 
925 richard 291
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>";
324 richard 292
						break;
293
					case 'Expiration' :
1380 richard 294
						if($login == "sms" && $user_type == 'group'){
295
							echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20 disabled></td>";
296
						} else {
297
							echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>";
298
						}
324 richard 299
						break;
886 stephane 300
					case 'Max-All-Session' :
925 richard 301
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>";
886 stephane 302
						break;
324 richard 303
					case 'Session-Timeout' :
925 richard 304
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>";
324 richard 305
						break;
306
					case 'Max-Daily-Session' :
925 richard 307
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>";
324 richard 308
						break;
309
					case 'Max-Weekly-Session' :
925 richard 310
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>";
324 richard 311
						break;
312
					case 'Max-Monthly-Session' :
925 richard 313
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>";
324 richard 314
						break;
315
					case 'ChilliSpot-Max-Input-Octets' :
925 richard 316
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>";
324 richard 317
						break;
318
					case 'ChilliSpot-Max-Output-Octets' :
925 richard 319
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>";
324 richard 320
						break;
321
					case 'ChilliSpot-Max-Total-Octets' :
925 richard 322
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>";
324 richard 323
						break;
324
					case 'ChilliSpot-Bandwidth-Max-Up' :
925 richard 325
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>";
324 richard 326
						break;
327
					case 'ChilliSpot-Bandwidth-Max-Down' :
925 richard 328
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>";
324 richard 329
						break;
330
					case 'WISPr-Redirection-URL' :
925 richard 331
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>";
324 richard 332
						break;
1377 richard 333
					case 'Filter-Id' :
334
						switch($val)
335
						{
336
							case "00000001":
337
								echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=</td><td><select name=\"$name1\"><option>$l_filtering_none</option><option value=\"00000001\" selected=\"selected\">$l_filtering_havp</option><option value=\"00000011\">$l_filtering_havp_bl</option><option value=\"00000101\">$l_filtering_havp_wl</option></select></td>";
338
								break;
339
							case "00000011":
340
								echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=</td><td><select name=\"$name1\"><option>$l_filtering_none</option><option value=\"00000001\">$l_filtering_havp</option><option value=\"00000011\" selected=\"selected\">$l_filtering_havp_bl</option><option value=\"00000101\">$l_filtering_havp_wl</option></select></td>";
341
								break;
342
							case "00000101":
343
							echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=</td><td><select name=\"$name1\"><option>$l_filtering_none</option><option value=\"00000001\">$l_filtering_havp</option><option value=\"00000011\">$l_filtering_havp_bl</option><option value=\"00000101\" selected=\"selected\">$l_filtering_havp_wl</option></select></td>";
344
								break;
345
							default :
346
							echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=</td><td><select name=\"$name1\"><option selected=\"selected\">$l_filtering_none</option><option value=\"00000001\">$l_filtering_havp</option><option value=\"00000011\">$l_filtering_havp_bl</option><option value=\"00000101\">$l_filtering_havp_wl</option></select></td>";
347
								break;
348
						}
349
						break;
324 richard 350
					default :
351
						print <<<EOM
352
<td>
353
<select name=$oper_name>
354
<option $selected[$op_eq] value="=">=
355
<option $selected[$op_set] value=":=">:=
356
<option $selected[$op_add] value="+=">+=
357
<option $selected[$op_eq2] value="==">==
358
<option $selected[$op_ne] value="!=">!=
359
<option $selected[$op_gt] value=">">&gt;
360
<option $selected[$op_ge] value=">=">&gt;=
361
<option $selected[$op_lt] value="<">&lt;
362
<option $selected[$op_le] value="<=">&lt;=
363
<option $selected[$op_regeq] value="=~">=~
364
<option $selected[$op_regne] value="!~">!~
365
<option $selected[$op_exst] value="=*">=*
366
<option $selected[$op_nexst] value="!*">!*
367
</select>
368
</td>
925 richard 369
<td><input type=text name="$name1" value="$val" size=20></td>
324 richard 370
EOM;
371
						break;
372
					}
373
				}
374
			print <<<EOM
375
</tr>
376
EOM;
377
		}
378
	}
379
if ($user_type != 'group'){
380
	echo <<<EOM
381
<tr>
382
<td align=right colspan=$colspan bgcolor="#d0ddb0">
910 richard 383
$l_group_member<br><font size=-2><i>($l_main_group)</i></font>
324 richard 384
</td>
385
<td>
386
EOM;
387
if (isset($member_groups)){
388
	echo "<select size=5 name=\"edited_groups[]\" multiple OnChange=\"this.form.group_change.value=1\">";
389
	if ($config[sql_show_all_groups] == 'true'){
390
		foreach ($existing_groups as $group => $count){
391
			if ($member_groups[$group] == $group)
392
				echo "<option selected value=\"$group\">$group\n";
393
			else
394
				echo "<option value=\"$group\">$group\n";
395
			}
396
		}else{
397
		foreach ($member_groups as $group)
398
			echo "<option value=\"$group\">$group\n";
399
		}
400
		echo "</select></td></tr>";
401
	}
402
	else{
403
		echo "aucun group</td></tr>";
404
	}
405
} 
406
echo "</table><br>";
910 richard 407
echo "<input type=submit class=button value=$l_change OnClick=\"this.form.change.value=1\">";
324 richard 408
//if ($user_type != 'group'){
409
//	echo <<<EOM
410
//<br><br>
411
//<input type=submit class=button value="Add to Badusers" OnClick="this.form.badusers.value=1">
412
//<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>
413
//EOM;
414
//}
415
?>
416
</form>
417
</td></tr>
418
</table>
419
</tr>
420
</table>
421
</td></tr>
422
</TABLE>
423
</body>
424
</html>