Subversion Repositories ALCASAR

Rev

Rev 2393 | Rev 2402 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
324 richard 1
<?php
2319 tom.houday 2
# $Id: group_new.php 2394 2017-08-27 13:28:59Z tom.houdayer $
508 richard 3
 
2319 tom.houday 4
//Gestion de la langue
5
if (is_file("../lib/langues.php"))
6
	include("../lib/langues.php");
7
 
2393 tom.houday 8
//update Filter-Id for protocol filtering
2394 tom.houday 9
if (isset($_POST['Filter-Proto']) && isset($_POST['Status-Open-Required']) && isset($_POST['Filter-Id']))
2393 tom.houday 10
{
2394 tom.houday 11
	$filterId = (int)$_POST['Filter-Id'];
12
	$FilterProto = (int)$_POST['Filter-Proto'];
13
	$statusOpenRequired = (int)($_POST['Status-Open-Required'].'000');
14
	$filterId = $filterId+$FilterProto+$statusOpenRequired;
15
	$_POST['Filter-Id'] = str_pad($filterId, 8, '0', STR_PAD_LEFT);
2393 tom.houday 16
}
2394 tom.houday 17
if (isset($_POST['Status-Open-Required'])) {
18
	if ($_POST['Status-Open-Required'] === '0') {
19
		$_POST['Idle-Timeout'] = '600'; // 10 minutes
20
	} else {
21
		$_POST['Idle-Timeout'] = '';
22
	}
23
	$_POST['Idle-Timeout_op'] = '=';
24
}
2393 tom.houday 25
 
2319 tom.houday 26
require('/etc/freeradius-web/config.php');
27
 
28
if (!isset ($create)) $create=0;
29
if (!isset ($login)) $login='';
30
if (!isset ($selected)) $selected=array();
31
 
32
require('../lib/attrshow.php');
33
require('../lib/defaults.php');
34
require("../lib/$config[general_lib_type]/group_info.php");
35
 
1805 clement.si 36
if ($config['general_lib_type'] != 'sql'){
324 richard 37
	echo <<<EOM
38
<title>$l_title</title>
1840 raphael.pi 39
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
324 richard 40
<link rel="stylesheet" href="style.css">
41
</head>
42
<body>
43
<center>
44
<b>This page is only available if you are using sql as general library type</b>
45
</body>
46
</html>
47
EOM;
48
        exit();
49
}
50
 
51
 
2319 tom.houday 52
if (false && /* Hide operator column */ $config['general_lib_type'] == 'sql' && $config['sql_use_operators'] == 'true'){
324 richard 53
	$colspan=2;
54
	$show_ops=1;
1805 clement.si 55
	include_once("../lib/operators.php");
56
	if(!isset($selected[$op_eq])) $selected[$op_eq] = '';
324 richard 57
}else{
58
	$show_ops = 0;
59
	$colspan=1;
60
}
61
?>
2319 tom.houday 62
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
911 richard 63
<html><head><title>New group</title>
1840 raphael.pi 64
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $config['general_charset']?>">
324 richard 65
<link rel="stylesheet" href="/css/style.css">
508 richard 66
<link rel="stylesheet" type="text/css" href="/css/epoch_styles.css" />
509 richard 67
<script type="text/javascript" src="/js/epoch_classes.js"></script>
68
<script type="text/javascript" src="/js/fonctions.js"></script>
324 richard 69
<script language="javascript" type="text/javascript">
508 richard 70
/*Insertion du calendrier*/
1805 clement.si 71
	var dp_cal;
508 richard 72
window.onload = function () {
73
	dp_cal  = new Epoch('epoch_popup','popup',document.getElementById('popup_container'));
74
};
75
/*Fin calendrier*/
324 richard 76
</script>
2319 tom.houday 77
<script type="text/javascript">
78
	function showAdvancedFields(show) {
79
		var form = document.forms['newgroup'];
80
		var btn_show = document.getElementById('show-advanced-fields');
81
		var btn_hide = document.getElementById('hide-advanced-fields');
82
 
83
		if (show) {
84
			btn_hide.style.display = null;
85
			btn_show.style.display = 'none';
86
			form.className += ' hide-advanced-fields';
87
		} else {
88
			btn_show.style.display = null;
89
			btn_hide.style.display = 'none';
90
			form.className = form.className.replace(' hide-advanced-fields', '');
91
 
92
		}
93
	}
94
</script>
95
<style type="text/css">
96
	.hide-advanced-fields .advanced-field {
97
		display: none;
98
	}
99
</style>
324 richard 100
</head>
101
<body>
102
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
911 richard 103
	<tr><th><? echo "$l_groups_managment"; ?></th></tr>
1805 clement.si 104
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1"
324 richard 105
height="2"></td></tr>
106
</TABLE>
107
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
108
	<tr bgcolor="#666666"><td>
109
	<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
110
		<tr><td valign="middle" align="left">
111
<center>
1377 richard 112
<table border=0 width=750 cellpadding=1 cellspacing=1>
324 richard 113
<tr valign=top>
114
<td width=340></td>
115
<td bgcolor="black" width=200>
116
	<table border=0 width=100% cellpadding=2 cellspacing=0>
117
	<tr bgcolor="#907030" align=right valign=top><th>
118
	<font color="white"><? echo "$l_group_create"; ?></font>
119
	</th></tr>
120
	</table>
121
</td></tr>
122
<tr bgcolor="black" valign=top><td colspan=2>
123
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
124
	<tr><td>
1805 clement.si 125
 
324 richard 126
<?php
127
if (is_file("../lib/$config[general_lib_type]/group_info.php"))
128
	include("../lib/$config[general_lib_type]/group_info.php");
129
if ($create == 1){
130
	if ($group_exists != "no"){
131
		echo <<<EOM
907 richard 132
<b><i>$login</i> $l_already_exist</b>
324 richard 133
EOM;
134
	}
135
	else{
136
		if (is_file("../lib/$config[general_lib_type]/create_group.php"))
137
			include("../lib/$config[general_lib_type]/create_group.php");
138
		if (is_file("../lib/$config[general_lib_type]/group_info.php"))
139
			include("../lib/$config[general_lib_type]/group_info.php");
140
	}
141
}
1377 richard 142
if ($create == 0){
324 richard 143
?>
2319 tom.houday 144
   <form name="newgroup" method="post" class="">
145
      <input type="hidden" name="create" value="0">
146
      <input type="hidden" name="show" value="0">
324 richard 147
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
148
<?php
149
	echo <<<EOM
150
	<tr>
508 richard 151
		<td class="etiquette" colspan=$colspan>
907 richard 152
		$l_created_groups
324 richard 153
		</td><td>
154
EOM;
155
		if (!isset($existing_groups))
907 richard 156
			echo "<b>$l_group_empty</b>\n";
324 richard 157
		else{
1805 clement.si 158
			echo "<select name=\"existing_groups\">\n";
324 richard 159
			foreach ($existing_groups as $group => $count)
160
				echo "<option value=\"$group\">$group\n";
161
			echo "</select>\n";
162
		}
163
	echo <<<EOM
164
		</td>
165
	</tr>
166
	<tr>
508 richard 167
		<td class="etiquette" colspan=$colspan>
907 richard 168
		$l_group_name
324 richard 169
		</td><td>
170
		<input type=text name="login" value="$login" size=35>
171
		</td>
172
	</tr>
173
	<tr>
508 richard 174
		<td class="etiquette" colspan=$colspan>
907 richard 175
		$l_group_members
324 richard 176
		</td><td>
1377 richard 177
		<textarea name=members cols="50" wrap="PHYSICAL" rows=5></textarea>
324 richard 178
		</td>
179
	</tr>
1805 clement.si 180
 
324 richard 181
EOM;
182
	foreach($show_attrs as $key => $desc){
2394 tom.houday 183
		if ($key === 'Idle-Timeout') continue;
324 richard 184
		$name = $attrmap["$key"];
185
		if ($name == 'none')
186
			continue;
187
		$oper_name = $name . '_op';
1805 clement.si 188
		if(isset($item_vals["$key"][0]) && $item_vals["$key"][0] != ''){
189
			$val = $item_vals["$key"][0];
190
		} else if(isset($default_vals["$key"][0])) {
191
			$val = $default_vals["$key"][0];
192
		} else {
193
			$val = '';
194
		}
508 richard 195
		switch ($key)
196
		{
1805 clement.si 197
		// $advanced = 1 : champs de saisie amélioré (calendrier, convertisseur, etc.)
198
			case 'Simultaneous-Use' :
2319 tom.houday 199
				$advanced = false;
200
				$help_link = "help/simultaneous_use_help.html";
201
				$desc = $l_simultaneous_use;
907 richard 202
				break;
203
			case 'Max-All-Session' :
2319 tom.houday 204
				$advanced = false;
205
				$help_link = "help/max_all_session_help.html";
206
				$desc = $l_max_all_session;
907 richard 207
				break;
1805 clement.si 208
			case 'Session-Timeout' :
2319 tom.houday 209
				$advanced = true;
210
				$help_link = "help/session_timeout_help.html";
211
				$desc = $l_session_timeout;
907 richard 212
				break;
213
			case 'Max-Daily-Session' :
2319 tom.houday 214
				$advanced = true;
215
				$help_link = "help/session_timeout_help.html";
216
				$desc = $l_daily_timeout;
907 richard 217
				break;
218
			case 'Max-Monthly-Session' :
2319 tom.houday 219
				$advanced = true;
220
				$help_link = "help/session_timeout_help.html";
221
				$desc = $l_monthly_timeout;
907 richard 222
				break;
1805 clement.si 223
			case 'Login-Time' :
2319 tom.houday 224
				$advanced = true;
225
				$help_link = "help/login_time_help.html";
226
				$desc = $l_login_time;
907 richard 227
				break;
228
			case 'Expiration' :
2319 tom.houday 229
				$advanced = false;
230
				$help_link = "help/expiration_help.html";
231
				$desc = $l_expiration;
907 richard 232
				break;
508 richard 233
			case 'ChilliSpot-Max-Input-Octets' :
2319 tom.houday 234
				$advanced = true;
235
				$help_link = "help/chillispot_max_input_octets_help.html";
236
				$desc = $l_max_input_octets;
907 richard 237
				break;
508 richard 238
			case 'ChilliSpot-Max-Output-Octets' :
2319 tom.houday 239
				$advanced = true;
240
				$help_link = "help/chillispot_max_output_octets_help.html";
241
				$desc = $l_max_output_octets;
907 richard 242
				break;
508 richard 243
			case 'ChilliSpot-Max-Total-Octets' :
2319 tom.houday 244
				$advanced = true;
245
				$help_link = "help/chillispot_max_total_octets_help.html";
246
				$desc = $l_max_total_octets;
907 richard 247
				break;
508 richard 248
			case 'ChilliSpot-Bandwidth-Max-Up' :
2319 tom.houday 249
				$advanced = true;
250
				$help_link = "help/chillispot_bandwidth_max_up_help.html";
251
				$desc = $l_max_bandwidth_up;
907 richard 252
				break;
508 richard 253
			case 'ChilliSpot-Bandwidth-Max-Down' :
2319 tom.houday 254
				$advanced = true;
255
				$help_link = "help/chillispot_bandwidth_max_down_help.html";
256
				$desc = $l_max_bandwidth_down;
907 richard 257
				break;
508 richard 258
			case 'WISPr-Redirection-URL' :
2319 tom.houday 259
				$advanced = true;
260
				$help_link = "help/wispr_redirection_url_help.html";
261
				$desc = $l_wispr_redirection;
508 richard 262
				break;
1377 richard 263
			case 'Filter-Id' :
2319 tom.houday 264
				$advanced = false;
265
				$help_link = "help/filtering_help.html";
266
				$desc = $l_filtering;
1377 richard 267
				break;
508 richard 268
			default:
2319 tom.houday 269
				$advanced = true;
508 richard 270
				break;
271
		}
2319 tom.houday 272
 
273
		$advancedField = ($advanced) ? ' class="advanced-field"' : '';
274
 
275
		if ($show_ops){
907 richard 276
		print <<<EOM
2319 tom.houday 277
			<tr$advancedField>
907 richard 278
			<td class="etiquette">
2319 tom.houday 279
			<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>
907 richard 280
			</td>
324 richard 281
EOM;
2319 tom.houday 282
			switch ($key) {
1805 clement.si 283
				case 'Simultaneous-Use' :
890 stephane 284
				case 'Max-All-Session' :
508 richard 285
				case 'Max-Daily-Session' :
286
				case 'Max-Weekly-Session' :
287
				case 'Max-Monthly-Session' :
1805 clement.si 288
				case 'Login-Time' :
907 richard 289
				case 'Expiration' :
2319 tom.houday 290
					echo "<td><select name=\"$oper_name\"><option $selected[$op_eq] value=\":=\">:=";
508 richard 291
					break;
1377 richard 292
				case 'Filter-Id' :
2319 tom.houday 293
					echo "<td><select name=\"$oper_name\"><option $selected[$op_eq] value=\":=\">:=";
1377 richard 294
					break;
907 richard 295
				case 'Session-Timeout' :
508 richard 296
				case 'ChilliSpot-Max-Input-Octets' :
297
				case 'ChilliSpot-Max-Output-Octets' :
298
				case 'ChilliSpot-Max-Total-Octets' :
299
				case 'ChilliSpot-Bandwidth-Max-Up' :
300
				case 'ChilliSpot-Bandwidth-Max-Down' :
301
				case 'WISPr-Redirection-URL' :
2319 tom.houday 302
					echo "<td><select name=\"$oper_name\"><option $selected[$op_eq] value=\"=\">=";
508 richard 303
					break;
304
				default :
305
					print <<<EOM
306
					<td>
2319 tom.houday 307
						<select name=\"$oper_name\">
907 richard 308
							<option $selected[$op_eq] value="=">=
309
							<option $selected[$op_set] value=":=">:=
310
							<option $selected[$op_add] value="+=">+=
311
							<option $selected[$op_eq2] value="==">==
312
							<option $selected[$op_ne] value="!=">!=
313
							<option $selected[$op_gt] value=">">&gt;
314
							<option $selected[$op_ge] value=">=">&gt;=
315
							<option $selected[$op_lt] value="<">&lt;
316
							<option $selected[$op_le] value="<=">&lt;=
317
							<option $selected[$op_regeq] value="=~">=~
318
							<option $selected[$op_regne] value="!~">!~
319
							<option $selected[$op_exst] value="=*">=*
320
							<option $selected[$op_nexst] value="!*">!*
321
						</select>
508 richard 322
					</td>
324 richard 323
EOM;
508 richard 324
					break;
325
			}
2319 tom.houday 326
		} else {
327
			print <<<EOM
328
				<tr$advancedField>
329
				<td class="etiquette" colspan="$colspan">
330
				<a href="$help_link" target="help" onclick="window.open('$help_link','help','width=600,height=350,toolbar=no,scrollbars=no,resizable=yes')" title="$l_click_for_help"><font color="blue">$desc</font></a>
331
EOM;
332
			switch ($key) {
333
				case 'Simultaneous-Use' :
334
				case 'Max-All-Session' :
335
				case 'Max-Daily-Session' :
336
				case 'Max-Weekly-Session' :
337
				case 'Max-Monthly-Session' :
338
				case 'Login-Time' :
339
				case 'Expiration' :
340
					echo "<input type=\"hidden\" name=\"$oper_name\" value=\":=\">";
341
					break;
342
				case 'Filter-Id' :
343
					echo "<input type=\"hidden\" name=\"$oper_name\" value=\":=\">";
344
					break;
345
				case 'Session-Timeout' :
346
				case 'ChilliSpot-Max-Input-Octets' :
347
				case 'ChilliSpot-Max-Output-Octets' :
348
				case 'ChilliSpot-Max-Total-Octets' :
349
				case 'ChilliSpot-Bandwidth-Max-Up' :
350
				case 'ChilliSpot-Bandwidth-Max-Down' :
351
				case 'WISPr-Redirection-URL' :
352
					echo "<input type=\"hidden\" name=\"$oper_name\" value=\"=\">";
353
					break;
354
				default :
355
					print <<<EOM
356
						<select name=\"$oper_name\">
357
							<option $selected[$op_eq] value="=">=</option>
358
							<option $selected[$op_set] value=":=">:=</option>
359
							<option $selected[$op_add] value="+=">+=</option>
360
							<option $selected[$op_eq2] value="==">==</option>
361
							<option $selected[$op_ne] value="!=">!=</option>
362
							<option $selected[$op_gt] value=">">&gt;</option>
363
							<option $selected[$op_ge] value=">=">&gt;=</option>
364
							<option $selected[$op_lt] value="<">&lt;</option>
365
							<option $selected[$op_le] value="<=">&lt;=</option>
366
							<option $selected[$op_regeq] value="=~">=~</option>
367
							<option $selected[$op_regne] value="!~">!~</option>
368
							<option $selected[$op_exst] value="=*">=*</option>
369
							<option $selected[$op_nexst] value="!*">!*</option>
370
						</select>
371
EOM;
372
					break;
373
			}
374
			echo '</td>';
324 richard 375
		}
1805 clement.si 376
 
377
/*
378
Ajout du choix d'unité (pour les durées limites de session, journée et de mois)
508 richard 379
et d'un calendrier pour la date d'expiration
380
Sauf dans le cas de la visualisation
381
*/
2319 tom.houday 382
	echo '<td>';
383
	if ($create == 0) {
508 richard 384
		switch ($name){
385
			/*
2319 tom.houday 386
			Choix de l'unité jour, heures, minutes ou secondes
387
			pour les durées limites max, de session,de journée et de mois
1805 clement.si 388
			*/
508 richard 389
			case 'Session-Timeout' :
390
			case 'Max-Daily-Session' :
2319 tom.houday 391
				/*valeur d'origine de durée limite */
392
				echo"<input type=\"text\" name=\"$name\" onfocus=\"this.value=''\" value=\"$val\" size=10>";
393
				/* Choix d'unité*/
2321 tom.houday 394
				echo" <select name=\"$name"."_opt"."\" onchange=\"temps(this,'$name','newgroup')\">
2319 tom.houday 395
						<option value=\"s\" selected>s</option>
396
						<option value=\"m\" >m</option>
397
						<option value=\"H\" >H</option>
398
					</select>";
399
				break;
508 richard 400
			case 'Max-Monthly-Session' :
907 richard 401
			case 'Max-All-Session' :
508 richard 402
				/*valeur d'origine de durée limite */
2319 tom.houday 403
				echo"<input type=\"text\" name=\"$name\" onfocus=\"this.value=''\" value=\"$val\" size=10>";
508 richard 404
				/* Choix d'unité*/
2321 tom.houday 405
				echo" <select name=\"$name"."_opt"."\" onchange=\"temps(this,'$name','newgroup')\">
508 richard 406
						<option value=\"s\" selected>s</option>
407
						<option value=\"m\" >m</option>
408
						<option value=\"H\" >H</option>
2319 tom.houday 409
						<option value=\"J\" >J</option>
508 richard 410
					</select>";
411
				break;
412
			case 'Expiration' :
413
				/*Ajout du calendrier pour choisir la date*/
2319 tom.houday 414
				echo"<input id=\"popup_container\" type=\"text\" name=\"$name\" value=\"$val\" size=\"20\">";
508 richard 415
				break;
1377 richard 416
			case 'Filter-Id' :
417
				echo "<select name='Filter-Id'>";
2319 tom.houday 418
				echo "<option value=\"\">$l_filtering_none</option>";
1377 richard 419
				echo "<option value=\"00000001\">$l_filtering_havp</option>";
420
				echo "<option value=\"00000011\">$l_filtering_havp_bl</option>";
421
				echo "<option value=\"00000101\">$l_filtering_havp_wl</option>";
422
				echo "</select>";
423
				break;
508 richard 424
			default :
2319 tom.houday 425
				echo "<input type=\"text\" name=\"$name\" value=\"$val\" size=\"20\">";
508 richard 426
				break;
2319 tom.houday 427
		}
324 richard 428
	}
508 richard 429
/*fin Ajout*/
430
}
2006 raphael.pi 431
 
2319 tom.houday 432
/*Network protocole filtering*/
2006 raphael.pi 433
print <<<EOM
2319 tom.houday 434
	<tr>
435
		<td class="etiquette" colspan="$colspan">
436
		<a href="help/protocols_help.html" target="help" onclick="window.open('help/protocols_help.html','help','width=600,height=250,toolbar=no,scrollbars=no,resizable=yes')" title="$l_click_for_help"><font color="blue">$l_proto</font></a>
437
		</td>
438
		<td width=20>
2006 raphael.pi 439
EOM;
2319 tom.houday 440
	echo" <select name='Filter-Proto'>
441
			<option value=\"00000000\" selected>$l_proto_0</option>
442
			<option value=\"10000000\" >$l_proto_1</option>
443
			<option value=\"01000000\" >$l_proto_2</option>
444
			<option value=\"00100000\" >$l_proto_3</option>
445
		</select></td></tr>";
2394 tom.houday 446
 
447
	// User need to keep status page open
448
	print <<<EOM
449
	<tr class="advanced-field">
450
	<td class="etiquette" colspan="$colspan">
451
		<a href="help/statusOpenRequired_help.html" target=help onclick="window.open('help/statusOpenRequired_help.html','help','width=600,height=250,toolbar=no,scrollbars=no,resizable=yes')" title="$l_click_for_help"><font color="blue">$l_statusOpenRequired</font></a>
452
	</td>
453
EOM;
454
	echo "<td width=20>
455
		<label><input type=\"radio\" name=\"Status-Open-Required\" value=\"1\" checked>$l_yes</label>
456
		<label><input type=\"radio\" name=\"Status-Open-Required\" value=\"0\">$l_no</label>
457
		</select></td>
458
	</tr>";
324 richard 459
echo "</table><BR>";
2394 tom.houday 460
 
1377 richard 461
}
324 richard 462
if ($create == 1)
1377 richard 463
	echo "<br/><center><a href=\"group_admin.php?login=$login\">$l_show_profile</a></center>";
2383 tom.houday 464
else {
907 richard 465
	echo "<input type=submit class=button value=\"$l_create\" OnClick=\"return formControl('newgroup');\">";
2319 tom.houday 466
	echo "<button type=\"button\" id =\"show-advanced-fields\" onclick=\"showAdvancedFields(true)\" style=\"float: right;\">$l_simple_menu</button>";
467
	echo "<button type=\"button\" id =\"hide-advanced-fields\" onclick=\"showAdvancedFields(false)\" style=\"float: right; display: none;\">$l_advanced_menu</button>";
2383 tom.houday 468
}
324 richard 469
?>
470
<br><br>
471
</form>
472
	</td></tr>
473
</table>
474
</tr>
475
</table>
2319 tom.houday 476
</center>
324 richard 477
</TD></TR>
478
</TABLE>
479
</td></tr>
480
</TABLE>
481
</body>
482
</html>