Subversion Repositories ALCASAR

Rev

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