Subversion Repositories ALCASAR

Rev

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