Subversion Repositories ALCASAR

Rev

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