Subversion Repositories ALCASAR

Rev

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