Subversion Repositories ALCASAR

Rev

Rev 2132 | Rev 2226 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
1805 clement.si 1
<?php
1578 richard 2
 
2006 raphael.pi 3
//update Filter-Id for protocol filtering
4
if (isset($_POST['Filter-Proto']) && isset($_POST['Filter-Id']))
5
{
6
	$upId = (int)$_POST['Filter-Proto'];
7
	$downId = (int)$_POST['Filter-Id'];
8
	$upId = $upId+$downId;
9
	$upId = str_pad($upId, 8, '0', STR_PAD_LEFT);
10
	$_POST['Filter-Id'] = $upId;
11
}
12
 
1805 clement.si 13
if (!isset ($create)) $create=0;
14
if (!isset ($show)) $show=0;
1326 richard 15
// ticket d'impression (thank's to Geoffroy MUSITELLI)
16
//gestion de la langue
17
if (is_file("../lib/langues.php"))
18
	include("../lib/langues.php");
19
 
1805 clement.si 20
if(!isset($login)) $login = '';
21
if(!isset($cn)) $cn = '';
22
if(!isset($mail)) $mail = '';
23
if(!isset($langue_imp)) $langue_imp = '';
24
 
1326 richard 25
require('/etc/freeradius-web/config.php');
26
if($show == 2)
27
{
28
	header("Location: user_new2.php");
29
	exit;
30
}
31
require('../lib/attrshow.php');
32
require('../lib/defaults.php');
1805 clement.si 33
if ($config['general_lib_type'] == 'sql' && $config['sql_use_operators'] == 'true'){
1326 richard 34
	$colspan=2;
35
	$show_ops=1;
36
}else{
37
	$show_ops = 0;
38
	$colspan=1;
39
}
40
?>
41
<html><head><title>Voucher creation</title>
1805 clement.si 42
<meta http-equiv="Content-Type" content="text/html; charset=<?php  echo $config['general_charset']?>">
1326 richard 43
<link rel="stylesheet" href="/css/style.css">
44
<link rel="stylesheet" type="text/css" href="/css/epoch_styles.css" />
45
<script type="text/javascript" src="/js/epoch_classes.js"></script>
46
<script type="text/javascript" src="/js/fonctions.js"></script>
47
<script language="javascript" type="text/javascript">
48
 
49
/*Insertion du calendrier */
1805 clement.si 50
	var dp_cal;
1326 richard 51
window.onload = function () {
52
	dp_cal  = new Epoch('epoch_popup','popup',document.getElementById('popup_container'));
53
};
54
</script>
55
</head>
56
<body>
57
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
58
	<tr><th><?php  echo"$l_users_managment"; ?></th></tr>
59
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
60
</TABLE>
61
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
62
	<tr bgcolor="#666666"><td>
63
	<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
64
		<tr><td valign="middle" align="left">
65
<center>
66
<table border=0 width=620 cellpadding=1 cellspacing=1>
67
<tr valign=top>
68
<td width=400></td>
69
<td bgcolor="black">
70
	<table border=0 width=100% cellpadding=2 cellspacing=0>
71
	<tr bgcolor="#907030" align=right valign=top><th>
72
	<font color="white"><?php  echo "$l_user_create"; ?></font>
73
	</th></tr>
74
	</table>
75
</td></tr>
76
<tr bgcolor="black" valign=top><td colspan=2>
77
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
1805 clement.si 78
	<tr><td>
79
<?php
1326 richard 80
function sec_imp($time)
1805 clement.si 81
/* Formatage des secondes avant l'impression */
82
{
83
	$result = '';
1326 richard 84
	$jour = 0;$heure = 0;$minute = 0;$seconde = 0;
85
	$jour = floor($time/86400);
86
	$reste = $time%86400;
87
    	if ($jour!=0) $result = $jour.' J ';
88
	$heure = floor($reste/3600);
89
    	$reste = $reste%3600;
90
    	if ($heure!=0) $result = $result.$heure.' H ';
91
	$minute = floor($reste/60);
92
    	if ($minute!=0) $result = $result.$minute.' min ';
93
	$seconde = $reste%60;
94
    	if ($seconde!=0) $result = $result.$seconde.' s ';
95
   	return $result;
1805 clement.si 96
}
1326 richard 97
 
98
if ($create == 1){
99
	if (is_file("../lib/$config[general_lib_type]/user_info.php"))
100
		include("../lib/$config[general_lib_type]/user_info.php");
101
	if ($user_exists != "no"){
102
		echo <<<EOM
1377 richard 103
<b><i>$login</i> $l_user_exists</b>
1326 richard 104
EOM;
105
	}
106
	else{
1881 raphael.pi 107
 
108
		/*création de l'utilisateur*/
109
		if (is_file("../lib/$config[general_lib_type]/create_user.php"))
110
			include("../lib/$config[general_lib_type]/create_user.php");
1326 richard 111
		/*  Petit traitement pré-impression pour la lisibilité */
112
		/*  Récupération des attributs du groupe le cas échéant */
1874 raphael.pi 113
		if (isset($_POST['Fgroup']) && $_POST['Fgroup']!=''){
114
			$group = $_POST['Fgroup'];
1880 raphael.pi 115
			$Fgroup = $_POST['Fgroup'];
1326 richard 116
			$saved_login = $login;
117
			$login = $group;
118
			if (is_file("../lib/sql/group_info.php"))
119
				include("../lib/sql/group_info.php");
120
			$login = $saved_login;}
1880 raphael.pi 121
 
122
 
1326 richard 123
		/*  Si les valeurs de durée sont vide remplissage avec la valeur 'Illimitée'*/
124
		/*  et formatage des secondes sous le format Heure min ses*/
125
		if ($sto_imp==''){ $sto_imp='-';}
126
			else { $sto_imp=sec_imp($sto_imp);}
127
		if ($mas_imp==''){ $mas_imp='-';}
1805 clement.si 128
			else { $mas_imp=sec_imp($mas_imp);}
1326 richard 129
		if ($mds_imp==''){ $mds_imp='-';}
130
			else { $mds_imp=sec_imp($mds_imp);}
131
		if ($mms_imp==''){ $mms_imp='-';}
132
			else { $mms_imp=sec_imp($mms_imp);}
133
		/*Formatage de la date afin d'être lisible dans toute les langues 'jj mm yyyy'*/
134
		if ($Expiration!=''){ $Expiration=date("d - m - Y",strtotime($Expiration));}
1805 clement.si 135
			else { $Expiration='-';}
1326 richard 136
		if ($show != 3) //utilisateur normal
1805 clement.si 137
		{
1326 richard 138
			//Appel du ticket d'impression , passage en paramètres des valeurs à afficher
2197 tom.houday 139
			echo'	<form name="impression" method="post" action="ticket_user.php" target="_blank">
1326 richard 140
					<input type="hidden" name="langue_imp" value="'.$langue_imp.'">
2197 tom.houday 141
					<input type="hidden" name="log_imp"    value="'.$login.'">
1326 richard 142
					<input type="hidden" name="passwd_imp" value="'.$passwd_imp.'">
2197 tom.houday 143
					<input type="hidden" name="sto_imp"    value="'.$sto_imp.'">
144
					<input type="hidden" name="mas_imp"    value="'.$mas_imp.'">
145
					<input type="hidden" name="mds_imp"    value="'.$mds_imp.'">
146
					<input type="hidden" name="mms_imp"    value="'.$mms_imp.'">
147
					<input type="hidden" name="exp_imp"    value="'.$Expiration.'">
1326 richard 148
				</form>';
2197 tom.houday 149
			echo'	<a href="#" onclick="document.forms[\'impression\'].submit();">Ticket</a>';
1326 richard 150
			//fin ticket impression
151
		}
152
		else //utilisateur = adresse mac
153
		{
1707 richard 154
			exec("sudo /usr/bin/systemctl reload chilli.service");
1326 richard 155
		}
156
		require("../lib/defaults.php");
157
		if (is_file("../lib/$config[general_lib_type]/user_info.php"))
158
			include("../lib/$config[general_lib_type]/user_info.php");
159
	}
160
}
161
?>
162
   <form name="newuser" method=post>
163
      <input type=hidden name=create value="0">
164
      <input type=hidden name=show value="0">
165
	  <input type=hidden name=langue_imp value='fr'>
166
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
1805 clement.si 167
<?php
1377 richard 168
if($create==0){
1326 richard 169
	echo <<<EOM
170
	<tr>
171
		<td class="etiquette" colspan=$colspan>
172
		$l_login
173
		</td><td>
174
		<input type=text name="login" value="$login" size=20>
175
		</td>
176
	</tr>
177
	<tr>
178
		<td class="etiquette" colspan=$colspan>
179
		$l_password
180
		</td><td>
181
		<input type=password name="passwd" size=20>
182
		<br><input type="button" value="$l_passwd_gen" onclick="password(8,'newuser')">
183
		<input type="text" value="" name="pwdgene" size=10 readonly>
184
		</td>
185
	</tr>
186
EOM;
1805 clement.si 187
	if ($config['general_lib_type'] == 'sql'){
1326 richard 188
		if (isset($member_groups))
189
			$selected[$member_groups[0]] = 'selected';
190
		echo <<<EOM
191
	<tr>
192
		<td class="etiquette" colspan=$colspan>
193
		$l_group
194
		</td><td>
195
EOM;
196
		include_once("../lib/$config[general_lib_type]/group_info.php");
197
		if (isset($existing_groups)){
198
			echo "<select name=\"Fgroup\">";
199
			echo "<option value=\"\" selected>";
200
			foreach ($member_groups as $group)
201
				echo "<option value=\"$group\">$group\n";
202
			echo " </select>";
203
			}
204
		else echo "$l_group_empty";
205
	echo "</td></tr>";
206
	}
1805 clement.si 207
	if ($config['general_lib_type'] == 'ldap' ||
208
	($config['general_lib_type'] == 'sql' && $config['sql_use_user_info_table'] == 'true')){
1326 richard 209
		echo <<<EOM
210
	<tr>
211
		<td class="etiquette" colspan=$colspan>
212
		$l_name
213
		</td><td>
214
		<input type=text name="Fcn" value="$cn" size=20>
215
		</td>
216
	</tr>
217
	<tr>
218
		<td class="etiquette" colspan=$colspan>
219
		$l_email
220
		</td><td>
221
		<input type=text name="Fmail" value="$mail" size=20>
222
		</td>
223
	</tr>
224
EOM;
225
	}
226
	foreach($show_attrs as $key => $desc){
227
		$name = $attrmap["$key"];
228
		if ($name == 'none')
229
			continue;
230
		$oper_name = $name . '_op';
1805 clement.si 231
		if(isset($item_vals["$key"][0]) && $item_vals["$key"][0] != ''){
232
			$val = $item_vals["$key"][0];
233
		} else if(isset($default_vals["$key"][0])) {
234
			$val = $default_vals["$key"][0];
235
		} else {
236
			$val = '';
237
		}
1326 richard 238
		/*
239
		Gestion d'un mode simple ou d'un mode avancé
240
		Définition du mode avancé: les attributs concernant la gestion des octets, de la bande passante
241
		*/
242
		switch ($key)
243
		{
244
			case 'ChilliSpot-Max-Input-Octets' :
245
			case 'ChilliSpot-Max-Output-Octets' :
246
			case 'ChilliSpot-Max-Total-Octets' :
247
			case 'ChilliSpot-Bandwidth-Max-Up' :
248
			case 'ChilliSpot-Bandwidth-Max-Down' :
249
			case 'WISPr-Redirection-URL' :
1805 clement.si 250
			case 'Login-Time' :
1326 richard 251
			case 'Session-Timeout' :
252
			case 'Max-Daily-Session' :
253
			case 'Max-Monthly-Session' :
254
				$advanced=0; //<-- attribut non-affiché
255
				break;
1805 clement.si 256
			case 'Simultaneous-Use' :
1326 richard 257
				$advanced=1;
258
				$help_link="help/simultaneous_use_help.html";
259
				$desc=$l_simultaneous_use;
260
				break;
261
			case 'Max-All-Session' :
262
				$advanced=1;
263
				$help_link="help/max_all_session_help.html";
264
				$desc=$l_max_all_session;
265
				break;
266
			case 'Expiration' :
267
				$advanced=1;
268
				$help_link="help/expiration_help.html";
269
				$desc=$l_expiration;
270
				break;
1377 richard 271
			case 'Filter-Id' :
272
				$advanced=1;
273
				$help_link="help/filtering_help.html";
274
				$desc=$l_filtering;
275
				break;
1326 richard 276
			default:
277
				$advanced=1;
278
				break;
279
		}
280
		if ($show_ops && $advanced){
281
		print <<<EOM
282
			<tr>
283
			<td class="etiquette" colspan=$colspan>
284
			<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>
285
			</td>
286
EOM;
287
			switch ($key){
1805 clement.si 288
				case 'Simultaneous-Use' :
1326 richard 289
				case 'Max-All-Session' :
290
				case 'Max-Daily-Session' :
291
				case 'Max-Weekly-Session' :
292
				case 'Max-Monthly-Session' :
1805 clement.si 293
				case 'Login-Time' :
1326 richard 294
				case 'Expiration' :
295
					echo "<input type=\"hidden\" name=$oper_name value=\":=\">";
296
					break;
1377 richard 297
				case 'Filter-Id' :
298
					echo "<input type=\"hidden\" name=$oper_name value=\":=\">";
299
					break;
1326 richard 300
				case 'Session-Timeout' :
301
				case 'ChilliSpot-Max-Input-Octets' :
302
				case 'ChilliSpot-Max-Output-Octets' :
303
				case 'ChilliSpot-Max-Total-Octets' :
304
				case 'ChilliSpot-Bandwidth-Max-Up' :
305
				case 'ChilliSpot-Bandwidth-Max-Down' :
306
				case 'WISPr-Redirection-URL' :
307
					echo "<input type=\"hidden\" name=$oper_name value=\"=\">";
308
					break;
309
				default :
310
					print <<<EOM
311
					<td>
312
						<select name=$oper_name>
313
							<option $selected[$op_eq] value="=">=
314
							<option $selected[$op_set] value=":=">:=
315
							<option $selected[$op_add] value="+=">+=
316
							<option $selected[$op_eq2] value="==">==
317
							<option $selected[$op_ne] value="!=">!=
318
							<option $selected[$op_gt] value=">">&gt;
319
							<option $selected[$op_ge] value=">=">&gt;=
320
							<option $selected[$op_lt] value="<">&lt;
321
							<option $selected[$op_le] value="<=">&lt;=
322
							<option $selected[$op_regeq] value="=~">=~
323
							<option $selected[$op_regne] value="!~">!~
324
							<option $selected[$op_exst] value="=*">=*
325
							<option $selected[$op_nexst] value="!*">!*
326
						</select>
327
					</td>
328
EOM;
329
					break;
330
			}
331
		}
1805 clement.si 332
/*
1326 richard 333
Ajout du pré-remplissage de cellule
1805 clement.si 334
du choix d'unité (pour les durées limites de session,journée et de mois)
1326 richard 335
et d'un calendrier pour la date d'expiration
336
Sauf dans le cas de la visualisation
337
*/
338
		if ($advanced){echo "<td>";}
339
		if ($create==0 && $advanced){
340
			switch ($name){
341
				case 'Simultaneous-Use' :
342
					/*Pré-remplissage avec la valeur '1' pour empécher plusieurs connexions silmutanées*/
343
					$val=1;//<--cette valeur correspond au nombre de session simultanée en commentant cette ligne la valeur n'est plus pré-remplie
344
					echo"<input type=text name=\"$name\" value=\"$val\" size=20>";
345
					break;
346
				/*
1805 clement.si 347
				Choix de l'unité heures, minutes ou secondes
348
				pour les durées limites de session,journée et de mois
349
				*/
1326 richard 350
				case 'Session-Timeout' :
351
				case 'Max-Daily-Session' :
352
					/*valeur d'origine de durée limite */
353
					echo"<input type=text name=\"$name\" onfocus=\"this.value=''\" value=\"$val\" size=20>";
354
					/* Choix d'unité*/
355
					echo" <select name=\"$name"."_opt"."\" onchange=\"temps(this,'$name','newuser')\">
356
							<option value=\"s\" selected>s</option>
357
							<option value=\"m\" >m</option>
358
							<option value=\"H\" >H</option>
359
						</select>";
360
					break;
361
				case 'Max-All-Session' :
362
				case 'Max-Monthly-Session' :
363
					/*valeur d'origine de durée limite */
364
					echo"<input type=text name=\"$name\" onfocus=\"this.value=''\" value=\"$val\" size=20>";
365
					/* Choix d'unité*/
366
					echo" <select name=\"$name"."_opt"."\" onchange=\"temps(this,'$name','newuser')\">
367
							<option value=\"s\" selected>s</option>
368
							<option value=\"m\" >m</option>
369
							<option value=\"H\" >H</option>
370
							<option value=\"J\" >J</option>
371
						</select>";
372
					break;
1566 richard 373
				case 'Expiration' :
1326 richard 374
					/*Pré-remplissage avec la date du lendemain*/
1484 richard 375
/*					$val=date("d F Y",strtotime("+1 day"));//<--en commentant cette ligne la valeur n'est plus pré-remplie
1326 richard 376
					/*Ajout du calendrier pour choisir la date*/
377
					echo"<input id=\"popup_container\" type=text name=\"$name\" value=\"$val\" size=20>";
378
					break;
1377 richard 379
				case 'Filter-Id' :
380
					echo "<select name='Filter-Id'>";
1838 raphael.pi 381
					echo "<option value=\"00000000\">$l_filtering_none</option>";
1377 richard 382
					echo "<option value=\"00000001\">$l_filtering_havp</option>";
383
					echo "<option value=\"00000011\">$l_filtering_havp_bl</option>";
384
					echo "<option value=\"00000101\">$l_filtering_havp_wl</option>";
385
					echo "</select>";
386
					break;
1326 richard 387
				default :
388
					if ($advanced) echo"<input type=text name=\"$name\" value=\"$val\" size=20>";
389
					break;
390
			}
391
		}
392
	}
2006 raphael.pi 393
 
2132 richard 394
	/*Network protocole filtering*/
1326 richard 395
	print <<<EOM
396
	<tr>
397
		<td class="etiquette" colspan=$colspan>
2006 raphael.pi 398
		<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>
399
		</td>
400
		<td width=20>
401
EOM;
402
	echo" <select name='Filter-Proto'>
403
			<option value=\"00000000\" selected>$l_proto_0</option>
404
			<option value=\"10000000\" >$l_proto_1</option>
405
			<option value=\"01000000\" >$l_proto_2</option>
406
			<option value=\"00100000\" >$l_proto_3</option>
407
		</select></td></tr>";
408
	print <<<EOM
409
	<tr>
410
		<td class="etiquette" colspan=$colspan>
1326 richard 411
			$l_lang_ticket
412
		</td>
413
		<td width=20>
414
EOM;
2132 richard 415
/*Voucher language*/
1326 richard 416
	echo" <select name=\"$langue_imp\" onchange=\"lang_imp(this,'newuser')\">
417
			<option value=\"fr\" selected>Fran&ccedil;ais</option>
418
			<option value=\"en\" >English</option>
419
			<option value=\"nl\" >Nederlandse</option>
420
			<option value=\"de\" >Deutsch</option>
421
			<option value=\"es\" >Espa&ntilde;ol</option>
422
			<option value=\"it\" >Italiano</option>
423
			<option value=\"pt\" >Portugês</option>
2113 richard 424
			<option value=\"ar\" >العربية</option>
1805 clement.si 425
		</select></td></tr>";
1377 richard 426
}
427
echo "</table>";
1326 richard 428
if($create == 1)
429
{
1377 richard 430
	echo "<center><a href=\"user_admin.php?login=$login\">$l_show_profile</a></center>";
1326 richard 431
}
432
else
433
{
434
	echo "<input type=submit class=button value=\"$l_create\" OnClick=\"return formControl('newuser');\">";
435
	echo "<input type='hidden' name='nbtickets' value=''>";
436
	echo "<input type=submit class=button value=\"$l_advanced_menu\" style=\"float: right;\" OnClick=\"this.form.show.value=2\">";
437
	echo "<br>$l_or :<br>";
1377 richard 438
	echo "<input type=button class=button value=\"$l_create_multiple\" OnClick=\"return createTickets(this.form, '$l_createTicketsMSG');\">";
1326 richard 439
	echo $l_create_multiple_comment;
440
}
441
?>
442
</form>
443
</td></tr>
444
</table>
445
</td></tr>
446
</TABLE>
447
</td></tr>
448
</TABLE>
449
</body>
450
</html>