Subversion Repositories ALCASAR

Rev

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

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