Subversion Repositories ALCASAR

Rev

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