Subversion Repositories ALCASAR

Rev

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