Subversion Repositories ALCASAR

Rev

Rev 1484 | Rev 1578 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

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