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