Subversion Repositories ALCASAR

Rev

Rev 1707 | Rev 1838 | 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
		if (is_file("../lib/$config[general_lib_type]/create_user.php"))
98
			include("../lib/$config[general_lib_type]/create_user.php");
99
		/*  Petit traitement pré-impression pour la lisibilité */
100
		/*  Récupération des attributs du groupe le cas échéant */
1805 clement.si 101
		if (isset($group) && $group!=''){
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;}
107
		/*  Si les valeurs de durée sont vide remplissage avec la valeur 'Illimitée'*/
108
		/*  et formatage des secondes sous le format Heure min ses*/
109
		if ($sto_imp==''){ $sto_imp='-';}
110
			else { $sto_imp=sec_imp($sto_imp);}
111
		if ($mas_imp==''){ $mas_imp='-';}
1805 clement.si 112
			else { $mas_imp=sec_imp($mas_imp);}
1326 richard 113
		if ($mds_imp==''){ $mds_imp='-';}
114
			else { $mds_imp=sec_imp($mds_imp);}
115
		if ($mms_imp==''){ $mms_imp='-';}
116
			else { $mms_imp=sec_imp($mms_imp);}
117
		/*Formatage de la date afin d'être lisible dans toute les langues 'jj mm yyyy'*/
118
		if ($Expiration!=''){ $Expiration=date("d - m - Y",strtotime($Expiration));}
1805 clement.si 119
			else { $Expiration='-';}
1326 richard 120
		if ($show != 3) //utilisateur normal
1805 clement.si 121
		{
1326 richard 122
			//Appel du ticket d'impression , passage en paramètres des valeurs à afficher
123
			echo'	<form name="impression" method="post" action="ticket_user.php" target=_blank>
124
					<input type="hidden" name="langue_imp" value="'.$langue_imp.'">
125
					<input type="hidden" name="log_imp" value="'.$login.'">
126
					<input type="hidden" name="passwd_imp" value="'.$passwd_imp.'">
127
					<input type="hidden" name="sto_imp" value="'.$sto_imp.'">
128
					<input type="hidden" name="mas_imp" value="'.$mas_imp.'">
129
					<input type="hidden" name="mds_imp" value="'.$mds_imp.'">
130
					<input type="hidden" name="mms_imp" value="'.$mms_imp.'">
131
					<input type="hidden" name="exp_imp" value="'.$Expiration.'">
132
				</form>';
133
			echo'	<script type="text/javascript"> document.forms["impression"].submit();</script>';
134
			//fin ticket impression
135
		}
136
		else //utilisateur = adresse mac
137
		{
1707 richard 138
			exec("sudo /usr/bin/systemctl reload chilli.service");
1326 richard 139
		}
140
		require("../lib/defaults.php");
141
		if (is_file("../lib/$config[general_lib_type]/user_info.php"))
142
			include("../lib/$config[general_lib_type]/user_info.php");
143
	}
144
}
145
?>
146
   <form name="newuser" method=post>
147
      <input type=hidden name=create value="0">
148
      <input type=hidden name=show value="0">
149
	  <input type=hidden name=langue_imp value='fr'>
150
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
1805 clement.si 151
<?php
1377 richard 152
if($create==0){
1326 richard 153
	echo <<<EOM
154
	<tr>
155
		<td class="etiquette" colspan=$colspan>
156
		$l_login
157
		</td><td>
158
		<input type=text name="login" value="$login" size=20>
159
		</td>
160
	</tr>
161
	<tr>
162
		<td class="etiquette" colspan=$colspan>
163
		$l_password
164
		</td><td>
165
		<input type=password name="passwd" size=20>
166
		<br><input type="button" value="$l_passwd_gen" onclick="password(8,'newuser')">
167
		<input type="text" value="" name="pwdgene" size=10 readonly>
168
		</td>
169
	</tr>
170
EOM;
1805 clement.si 171
	if ($config['general_lib_type'] == 'sql'){
1326 richard 172
		if (isset($member_groups))
173
			$selected[$member_groups[0]] = 'selected';
174
		echo <<<EOM
175
	<tr>
176
		<td class="etiquette" colspan=$colspan>
177
		$l_group
178
		</td><td>
179
EOM;
180
		include_once("../lib/$config[general_lib_type]/group_info.php");
181
		if (isset($existing_groups)){
182
			echo "<select name=\"Fgroup\">";
183
			echo "<option value=\"\" selected>";
184
			foreach ($member_groups as $group)
185
				echo "<option value=\"$group\">$group\n";
186
			echo " </select>";
187
			}
188
		else echo "$l_group_empty";
189
	echo "</td></tr>";
190
	}
1805 clement.si 191
	if ($config['general_lib_type'] == 'ldap' ||
192
	($config['general_lib_type'] == 'sql' && $config['sql_use_user_info_table'] == 'true')){
1326 richard 193
		echo <<<EOM
194
	<tr>
195
		<td class="etiquette" colspan=$colspan>
196
		$l_name
197
		</td><td>
198
		<input type=text name="Fcn" value="$cn" size=20>
199
		</td>
200
	</tr>
201
	<tr>
202
		<td class="etiquette" colspan=$colspan>
203
		$l_email
204
		</td><td>
205
		<input type=text name="Fmail" value="$mail" size=20>
206
		</td>
207
	</tr>
208
EOM;
209
	}
210
	foreach($show_attrs as $key => $desc){
211
		$name = $attrmap["$key"];
212
		if ($name == 'none')
213
			continue;
214
		$oper_name = $name . '_op';
1805 clement.si 215
		if(isset($item_vals["$key"][0]) && $item_vals["$key"][0] != ''){
216
			$val = $item_vals["$key"][0];
217
		} else if(isset($default_vals["$key"][0])) {
218
			$val = $default_vals["$key"][0];
219
		} else {
220
			$val = '';
221
		}
1326 richard 222
		/*
223
		Gestion d'un mode simple ou d'un mode avancé
224
		Définition du mode avancé: les attributs concernant la gestion des octets, de la bande passante
225
		*/
226
		switch ($key)
227
		{
228
			case 'ChilliSpot-Max-Input-Octets' :
229
			case 'ChilliSpot-Max-Output-Octets' :
230
			case 'ChilliSpot-Max-Total-Octets' :
231
			case 'ChilliSpot-Bandwidth-Max-Up' :
232
			case 'ChilliSpot-Bandwidth-Max-Down' :
233
			case 'WISPr-Redirection-URL' :
1805 clement.si 234
			case 'Login-Time' :
1326 richard 235
			case 'Session-Timeout' :
236
			case 'Max-Daily-Session' :
237
			case 'Max-Monthly-Session' :
238
				$advanced=0; //<-- attribut non-affiché
239
				break;
1805 clement.si 240
			case 'Simultaneous-Use' :
1326 richard 241
				$advanced=1;
242
				$help_link="help/simultaneous_use_help.html";
243
				$desc=$l_simultaneous_use;
244
				break;
245
			case 'Max-All-Session' :
246
				$advanced=1;
247
				$help_link="help/max_all_session_help.html";
248
				$desc=$l_max_all_session;
249
				break;
250
			case 'Expiration' :
251
				$advanced=1;
252
				$help_link="help/expiration_help.html";
253
				$desc=$l_expiration;
254
				break;
1377 richard 255
			case 'Filter-Id' :
256
				$advanced=1;
257
				$help_link="help/filtering_help.html";
258
				$desc=$l_filtering;
259
				break;
1326 richard 260
			default:
261
				$advanced=1;
262
				break;
263
		}
264
		if ($show_ops && $advanced){
265
		print <<<EOM
266
			<tr>
267
			<td class="etiquette" colspan=$colspan>
268
			<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>
269
			</td>
270
EOM;
271
			switch ($key){
1805 clement.si 272
				case 'Simultaneous-Use' :
1326 richard 273
				case 'Max-All-Session' :
274
				case 'Max-Daily-Session' :
275
				case 'Max-Weekly-Session' :
276
				case 'Max-Monthly-Session' :
1805 clement.si 277
				case 'Login-Time' :
1326 richard 278
				case 'Expiration' :
279
					echo "<input type=\"hidden\" name=$oper_name value=\":=\">";
280
					break;
1377 richard 281
				case 'Filter-Id' :
282
					echo "<input type=\"hidden\" name=$oper_name value=\":=\">";
283
					break;
1326 richard 284
				case 'Session-Timeout' :
285
				case 'ChilliSpot-Max-Input-Octets' :
286
				case 'ChilliSpot-Max-Output-Octets' :
287
				case 'ChilliSpot-Max-Total-Octets' :
288
				case 'ChilliSpot-Bandwidth-Max-Up' :
289
				case 'ChilliSpot-Bandwidth-Max-Down' :
290
				case 'WISPr-Redirection-URL' :
291
					echo "<input type=\"hidden\" name=$oper_name value=\"=\">";
292
					break;
293
				default :
294
					print <<<EOM
295
					<td>
296
						<select name=$oper_name>
297
							<option $selected[$op_eq] value="=">=
298
							<option $selected[$op_set] value=":=">:=
299
							<option $selected[$op_add] value="+=">+=
300
							<option $selected[$op_eq2] value="==">==
301
							<option $selected[$op_ne] value="!=">!=
302
							<option $selected[$op_gt] value=">">&gt;
303
							<option $selected[$op_ge] value=">=">&gt;=
304
							<option $selected[$op_lt] value="<">&lt;
305
							<option $selected[$op_le] value="<=">&lt;=
306
							<option $selected[$op_regeq] value="=~">=~
307
							<option $selected[$op_regne] value="!~">!~
308
							<option $selected[$op_exst] value="=*">=*
309
							<option $selected[$op_nexst] value="!*">!*
310
						</select>
311
					</td>
312
EOM;
313
					break;
314
			}
315
		}
1805 clement.si 316
/*
1326 richard 317
Ajout du pré-remplissage de cellule
1805 clement.si 318
du choix d'unité (pour les durées limites de session,journée et de mois)
1326 richard 319
et d'un calendrier pour la date d'expiration
320
Sauf dans le cas de la visualisation
321
*/
322
		if ($advanced){echo "<td>";}
323
		if ($create==0 && $advanced){
324
			switch ($name){
325
				case 'Simultaneous-Use' :
326
					/*Pré-remplissage avec la valeur '1' pour empécher plusieurs connexions silmutanées*/
327
					$val=1;//<--cette valeur correspond au nombre de session simultanée en commentant cette ligne la valeur n'est plus pré-remplie
328
					echo"<input type=text name=\"$name\" value=\"$val\" size=20>";
329
					break;
330
				/*
1805 clement.si 331
				Choix de l'unité heures, minutes ou secondes
332
				pour les durées limites de session,journée et de mois
333
				*/
1326 richard 334
				case 'Session-Timeout' :
335
				case 'Max-Daily-Session' :
336
					/*valeur d'origine de durée limite */
337
					echo"<input type=text name=\"$name\" onfocus=\"this.value=''\" value=\"$val\" size=20>";
338
					/* Choix d'unité*/
339
					echo" <select name=\"$name"."_opt"."\" onchange=\"temps(this,'$name','newuser')\">
340
							<option value=\"s\" selected>s</option>
341
							<option value=\"m\" >m</option>
342
							<option value=\"H\" >H</option>
343
						</select>";
344
					break;
345
				case 'Max-All-Session' :
346
				case 'Max-Monthly-Session' :
347
					/*valeur d'origine de durée limite */
348
					echo"<input type=text name=\"$name\" onfocus=\"this.value=''\" value=\"$val\" size=20>";
349
					/* Choix d'unité*/
350
					echo" <select name=\"$name"."_opt"."\" onchange=\"temps(this,'$name','newuser')\">
351
							<option value=\"s\" selected>s</option>
352
							<option value=\"m\" >m</option>
353
							<option value=\"H\" >H</option>
354
							<option value=\"J\" >J</option>
355
						</select>";
356
					break;
1566 richard 357
				case 'Expiration' :
1326 richard 358
					/*Pré-remplissage avec la date du lendemain*/
1484 richard 359
/*					$val=date("d F Y",strtotime("+1 day"));//<--en commentant cette ligne la valeur n'est plus pré-remplie
1326 richard 360
					/*Ajout du calendrier pour choisir la date*/
361
					echo"<input id=\"popup_container\" type=text name=\"$name\" value=\"$val\" size=20>";
362
					break;
1377 richard 363
				case 'Filter-Id' :
364
					echo "<select name='Filter-Id'>";
1566 richard 365
					echo "<option value=\"\">$l_filtering_none</option>";
1377 richard 366
					echo "<option value=\"00000001\">$l_filtering_havp</option>";
367
					echo "<option value=\"00000011\">$l_filtering_havp_bl</option>";
368
					echo "<option value=\"00000101\">$l_filtering_havp_wl</option>";
369
					echo "</select>";
370
					break;
1326 richard 371
				default :
372
					if ($advanced) echo"<input type=text name=\"$name\" value=\"$val\" size=20>";
373
					break;
374
			}
375
		}
376
	}
377
	print <<<EOM
378
	<tr>
379
		<td class="etiquette" colspan=$colspan>
380
			$l_lang_ticket
381
		</td>
382
		<td width=20>
383
EOM;
384
/*Choix de la langue du ticket d'impression*/
385
	echo" <select name=\"$langue_imp\" onchange=\"lang_imp(this,'newuser')\">
386
			<option value=\"fr\" selected>Fran&ccedil;ais</option>
387
			<option value=\"en\" >English</option>
388
			<option value=\"nl\" >Nederlandse</option>
389
			<option value=\"de\" >Deutsch</option>
390
			<option value=\"es\" >Espa&ntilde;ol</option>
391
			<option value=\"it\" >Italiano</option>
392
			<option value=\"pt\" >Portugês</option>
1805 clement.si 393
		</select></td></tr>";
1377 richard 394
}
395
echo "</table>";
1326 richard 396
if($create == 1)
397
{
1566 richard 398
	$ticket_name="ticket_".$login.".pdf";
399
	echo "<a href=\"$ticket_name\">Ticket</a><br/><br/>";
1377 richard 400
	echo "<center><a href=\"user_admin.php?login=$login\">$l_show_profile</a></center>";
1326 richard 401
}
402
else
403
{
404
	echo "<input type=submit class=button value=\"$l_create\" OnClick=\"return formControl('newuser');\">";
405
	echo "<input type='hidden' name='nbtickets' value=''>";
406
	echo "<input type=submit class=button value=\"$l_advanced_menu\" style=\"float: right;\" OnClick=\"this.form.show.value=2\">";
407
	echo "<br>$l_or :<br>";
1377 richard 408
	echo "<input type=button class=button value=\"$l_create_multiple\" OnClick=\"return createTickets(this.form, '$l_createTicketsMSG');\">";
1326 richard 409
	echo $l_create_multiple_comment;
410
}
411
?>
412
</form>
413
</td></tr>
414
</table>
415
</td></tr>
416
</TABLE>
417
</td></tr>
418
</TABLE>
419
</body>
420
</html>