Subversion Repositories ALCASAR

Rev

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