Subversion Repositories ALCASAR

Rev

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