Subversion Repositories ALCASAR

Rev

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

Rev Author Line No. Line
1 root 1
<?php
2
# Choice of language
3
$Language = 'en';
4
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
5
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
6
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
7
if($Language == 'fr'){
8
  $l_title = "Cr&eacute;ation d'un usager";
9
  $l_frame_top = "Gestion des usagers";
10
  $l_frame = "Cr&eacute;ation d'un usager";
11
  $l_user_exist = "existe d&eacute;j&agrave;";
12
  $l_login = "Identifiant";
13
  $l_password = "Mot de passe";
14
  $l_passwd_gen = "g&eacute;n&eacute;rer";
15
  $l_group = "Groupe";
16
  $l_group_empty = "La liste des groupes est vide";
17
  $l_name = "Nom et pr&eacute;nom";
18
  $l_email = "Adresse de couriel";
19
}
20
else {
21
  $l_title = "Create a user";
22
  $l_frame_top = "Users admin";
23
  $l_frame = "Create a user";
24
  $l_user_exist = "already exist";
25
  $l_login = "Login";
26
  $l_password = "Password";
27
  $l_passwd_gen = "generate";
28
  $l_group = "Group";
29
  $l_group_empty = "The group list is empty";
30
  $l_name = "Surname and name";
31
  $l_email = "Email Address";
32
}
33
 
34
 
35
require('/etc/freeradius-web/config.php');
36
if ($show == 1){
37
	header("Location: user_admin.php?login=$login");
38
	exit;
39
}
40
require('../lib/attrshow.php');
41
require('../lib/defaults.php');
42
 
43
if ($config[general_lib_type] == 'sql' && $config[sql_use_operators] == 'true'){
44
	$colspan=2;
45
	$show_ops=1;
46
}else{
47
	$show_ops = 0;
48
	$colspan=1;
49
}
50
echo "<html><head><title>$l_title</title>";
51
?>
52
 
53
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $config[general_charset]?>">
54
<link rel="stylesheet" href="/css/style.css">
55
<script language="javascript" type="text/javascript">
56
var chars='0123456789abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ'
57
function password(size)
58
  {
59
  var pass=''
60
  while(pass.length < size)
61
  {
62
    pass+=chars.charAt(Math.round(Math.random() * (chars.length)))
63
  }
113 richard 64
  document.newuser.passwd.value=pass
65
  document.newuser.pwdgene.value=pass
1 root 66
}
113 richard 67
function formControl(){
68
	var myregex = /[\S]+/gi; //un ou plusieurs caractères non blanc" (tous les caractères sauf espace, retour chariot, tabulation, saut de ligne, saut de page).
69
	if (myregex.test(document.newuser.login.value)){
70
		document.newuser.create.value=1;
71
		return true;
72
	} else {
73
		alert("Votre identifiant est invalide.");//non internationnalisé
74
		return false;
75
	}
76
}
1 root 77
</script>
78
</head>
79
<body>
80
 
81
<?php
82
include("password_generator.jsc");
83
echo "<TABLE width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
84
echo "<tr><th>$l_frame_top</th></tr>";
85
?>
86
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" 
87
height="2"></td></tr>
88
</TABLE>
89
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
90
	<tr bgcolor="#666666"><td>
91
	<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
92
		<tr><td valign="middle" align="left">
93
<center>
94
<table border=0 width=550 cellpadding=1 cellspacing=1>
95
<tr valign=top>
96
<td width=340></td>
97
<td bgcolor="black" width=200>
98
	<table border=0 width=100% cellpadding=2 cellspacing=0>
99
	<tr bgcolor="#907030" align=right valign=top><th>
100
	<font color="white"><? echo "$l_frame"; ?></font>
101
	</th></tr>
102
	</table>
103
</td></tr>
104
<tr bgcolor="black" valign=top><td colspan=2>
105
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
106
	<tr><td>
107
 
108
<?php
109
if ($create == 1){
110
	if (is_file("../lib/$config[general_lib_type]/user_info.php"))
111
		include("../lib/$config[general_lib_type]/user_info.php");
112
	if ($user_exists != "no"){
113
		echo <<<EOM
114
<b><i>$login</i> $l_user_exist</b>
115
EOM;
116
	}
117
	else{
118
		if (is_file("../lib/$config[general_lib_type]/create_user.php"))
119
			include("../lib/$config[general_lib_type]/create_user.php");
120
		require("../lib/defaults.php");
121
		if (is_file("../lib/$config[general_lib_type]/user_info.php"))
122
			include("../lib/$config[general_lib_type]/user_info.php");
123
	}
124
}
125
?>
113 richard 126
   <form name="newuser" method=post>
1 root 127
      <input type=hidden name=create value="0">
128
      <input type=hidden name=show value="0">
129
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
130
<?php
131
	echo <<<EOM
132
	<tr>
133
		<td align=right colspan=$colspan bgcolor="#d0ddb0">
134
		$l_login
135
		</td><td>
136
		<input type=text name="login" value="$login" size=35>
137
		</td>
138
	</tr>
139
	<tr>
140
		<td align=right colspan=$colspan bgcolor="#d0ddb0">
141
		$l_password
142
		</td><td>
143
		<input type=password name="passwd" size=35>
144
		<br /><input type="button" value="$l_passwd_gen" onclick="password(8)">
145
		<input type="text" value="" name="pwdgene" size=20 readonly>
146
		</td>
147
	</tr>
148
EOM;
149
	if ($config[general_lib_type] == 'sql'){
150
		if (isset($member_groups))
151
			$selected[$member_groups[0]] = 'selected';
152
		echo <<<EOM
153
	<tr>
154
		<td align=right colspan=$colspan bgcolor="#d0ddb0">
155
		$l_group
156
		</td><td>
157
EOM;
158
		include_once("../lib/$config[general_lib_type]/group_info.php");
159
		if (isset($existing_groups)){
160
			echo "	<select name=\"Fgroup\">";
161
			foreach ($member_groups as $group)
162
				echo "<option value=\"$group\" $selected[$group]>$group\n";
163
			echo " </select>";
164
			}
165
		else echo "$l_group_empty";
166
	echo "</td></tr>";
167
	}
168
	if ($config[general_lib_type] == 'ldap' ||
169
	($config[general_lib_type] == 'sql' && $config[sql_use_user_info_table] == 'true')){
170
		echo <<<EOM
171
	<tr>
172
		<td align=right colspan=$colspan bgcolor="#d0ddb0">
173
		$l_name
174
		</td><td>
175
		<input type=text name="Fcn" value="$cn" size=35>
176
		</td>
177
	</tr>
178
	<tr>
179
		<td align=right colspan=$colspan bgcolor="#d0ddb0">
180
		$l_email
181
		</td><td>
182
		<input type=text name="Fmail" value="$mail" size=35>
183
		</td>
184
	</tr>
185
	<tr>
186
		<td align=right colspan=$colspan bgcolor="#d0ddb0">
187
		Service
188
		</td><td>
189
		<input type=text name="Fou" value="$ou" size=35>
190
		</td>
191
	</tr>
192
	<tr>
193
		<td align=right colspan=$colspan bgcolor="#d0ddb0">
194
		Nro TPH personnel
195
		</td><td>
196
		<input type=text name="Fhomephone" value="$homephone" size=35>
197
		</td>
198
	</tr>
199
	<tr>
200
		<td align=right colspan=$colspan bgcolor="#d0ddb0">
201
		Nro TPH bureau
202
		</td><td>
203
		<input type=text name="Ftelephonenumber" value="$telephonenumber" size=35>
204
		</td>
205
	</tr>
206
	<tr>
207
		<td align=right colspan=$colspan bgcolor="#d0ddb0">
208
		Nro TPH mobile
209
		</td><td>
210
		<input type=text name="Fmobile" value="$mobile" size=35>
211
		</td>
212
	</tr>
213
EOM;
214
	}
215
	foreach($show_attrs as $key => $desc){
216
		$name = $attrmap["$key"];
217
		if ($name == 'none')
218
			continue;
219
		$oper_name = $name . '_op';
220
		$val = ($item_vals["$key"][0] != "") ? $item_vals["$key"][0] : $default_vals["$key"][0];
221
		print <<<EOM
222
<tr>
223
<td align=right bgcolor="#d0ddb0">
224
$desc
225
</td>
226
EOM;
227
 
228
		if ($show_ops){
229
				switch ($key)
230
					{
231
					case 'Simultaneous-Use' : 
232
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
233
						break;
234
					case 'Login-Time' : 
235
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
236
						break;
237
					case 'Expiration' :
238
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
239
						break;
240
					case 'Session-Timeout' :
241
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
242
						break;
243
					case 'Max-Daily-Session' :
244
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
245
						break;
246
					case 'Max-Weekly-Session' :
247
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
248
						break;
249
					case 'Max-Monthly-Session' :
250
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
251
						break;
113 richard 252
					case 'ChilliSpot-Max-Input-Octets' :
253
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
254
						break;
255
					case 'ChilliSpot-Max-Output-Octets' :
256
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
257
						break;
258
					case 'ChilliSpot-Max-Total-Octets' :
259
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
260
						break;
261
					case 'ChilliSpot-Bandwidth-Max-Up' :
262
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
263
						break;
264
					case 'ChilliSpot-Bandwidth-Max-Down' :
265
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
266
						break;
267
					case 'WISPr-Redirection-URL' :
268
						echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
269
						break;
1 root 270
					default :
271
						print <<<EOM
272
<td>
273
<select name=$oper_name>
274
<option $selected[$op_eq] value="=">=
275
<option $selected[$op_set] value=":=">:=
276
<option $selected[$op_add] value="+=">+=
277
<option $selected[$op_eq2] value="==">==
278
<option $selected[$op_ne] value="!=">!=
279
<option $selected[$op_gt] value=">">&gt;
280
<option $selected[$op_ge] value=">=">&gt;=
281
<option $selected[$op_lt] value="<">&lt;
282
<option $selected[$op_le] value="<=">&lt;=
283
<option $selected[$op_regeq] value="=~">=~
284
<option $selected[$op_regne] value="!~">!~
285
<option $selected[$op_exst] value="=*">=*
286
<option $selected[$op_nexst] value="!*">!*
287
</select>
288
</td>
289
EOM;
290
						break;
291
					}
292
		}
293
		print <<<EOM
294
<td>
295
<input type=text name="$name" value="$val" size=35>
296
</td>
297
</tr>
298
EOM;
299
	}
300
echo "</table><BR>";
301
if ($create == 1)
302
	echo "<input type=submit class=button value=\"Afficher le profil de l'utilisateur\" OnClick=\"this.form.show.value=1\">";
303
	else{
113 richard 304
	//echo "<input type=submit class=button value=\"Cr&eacute;er\" OnClick=\"this.form.create.value=1\">";}
305
	echo "<input type=submit class=button value=\"Cr&eacute;er\" OnClick=\"return formControl();\">";}
1 root 306
?>
307
</form>
308
	</td></tr>
309
</table>
310
</tr>
311
</table>
312
</TD></TR>
313
</TABLE>
314
</td></tr>
315
</TABLE>
316
</body>
317
</html>