| 324 |
richard |
1 |
<?php
|
|
|
2 |
require('/etc/freeradius-web/config.php');
|
|
|
3 |
|
|
|
4 |
if ($login == 'da_server_test'){
|
|
|
5 |
$login = $config[general_test_account_login];
|
|
|
6 |
$test_login=1;
|
|
|
7 |
}
|
|
|
8 |
|
|
|
9 |
echo <<<EOM
|
|
|
10 |
<html>
|
|
|
11 |
<head>
|
|
|
12 |
<title>Test de l'utilisateur $login</title>
|
|
|
13 |
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
|
|
|
14 |
<link rel="stylesheet" href="style.css">
|
|
|
15 |
</head>
|
|
|
16 |
<body>
|
|
|
17 |
<center>
|
|
|
18 |
<table border=0 width=550 cellpadding=0 cellspacing=0>
|
|
|
19 |
<tr valign=top>
|
|
|
20 |
<!--<td align=center><img src="images/title2.gif"></td>-->
|
|
|
21 |
</tr>
|
|
|
22 |
</table>
|
|
|
23 |
|
|
|
24 |
<table border=0 width=400 cellpadding=0 cellspacing=2>
|
|
|
25 |
EOM;
|
|
|
26 |
|
|
|
27 |
if (!$test_login)
|
|
|
28 |
include("../html/user_toolbar.html.php");
|
|
|
29 |
|
|
|
30 |
print <<<EOM
|
|
|
31 |
</table>
|
|
|
32 |
|
|
|
33 |
<br>
|
|
|
34 |
<table border=0 width=540 cellpadding=1 cellspacing=1>
|
|
|
35 |
<tr valign=top>
|
|
|
36 |
<td width=340></td>
|
|
|
37 |
<td bgcolor="black" width=200>
|
|
|
38 |
<table border=0 width=100% cellpadding=2 cellspacing=0>
|
|
|
39 |
<tr bgcolor="#907030" align=right valign=top><th>
|
|
|
40 |
EOM;
|
|
|
41 |
|
|
|
42 |
if ($test_login){
|
|
|
43 |
print <<<EOM
|
|
|
44 |
<font color="white">Page de Test du serveur Radius</font>
|
|
|
45 |
EOM;
|
|
|
46 |
}else{
|
|
|
47 |
print <<<EOM
|
|
|
48 |
<font color="white">Page de Test de l'utilisateur $login</font>
|
|
|
49 |
EOM;
|
|
|
50 |
}
|
|
|
51 |
?>
|
|
|
52 |
</th></tr>
|
|
|
53 |
</table>
|
|
|
54 |
</td></tr>
|
|
|
55 |
<tr bgcolor="black" valign=top><td colspan=2>
|
|
|
56 |
<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
|
|
|
57 |
<tr><td>
|
|
|
58 |
|
|
|
59 |
<?php
|
|
|
60 |
if ($server == '' || !preg_match('/^[\w\.]+$/',$server))
|
|
|
61 |
$server = $config[general_radius_server];
|
|
|
62 |
if ($port == 0 || !is_numeric($port))
|
|
|
63 |
$port = $config[general_radius_server_port];
|
|
|
64 |
if ($auth_proto == '')
|
|
|
65 |
$auth_proto = $config[general_radius_server_auth_proto];
|
|
|
66 |
$selected[$auth_proto] = 'selected';
|
|
|
67 |
|
|
|
68 |
if ($test_user == 1){
|
|
|
69 |
$tmp_file = tempnam("$config[general_tmp_dir]",'DA');
|
|
|
70 |
$req=file($config[general_auth_request_file]);
|
|
|
71 |
if ($config[general_ld_library_path] != '')
|
|
|
72 |
putenv("LD_LIBRARY_PATH=$config[general_ld_library_path]");
|
|
|
73 |
$comm = $config[general_radclient_bin] . " $server:$port" . ' auth ' . $config[general_radius_server_secret]
|
|
|
74 |
. ' >' . $tmp_file;
|
|
|
75 |
$fp = popen("$comm","w");
|
|
|
76 |
if ($fp){
|
|
|
77 |
foreach ($req as $val){
|
|
|
78 |
// Ignore comments
|
|
|
79 |
if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val))
|
|
|
80 |
continue;
|
|
|
81 |
fwrite($fp,$val);
|
|
|
82 |
}
|
|
|
83 |
if ($test_login){
|
|
|
84 |
$test=1;
|
|
|
85 |
fwrite($fp, "User-Name = \"$config[general_test_account_login]\"\n");
|
|
|
86 |
fwrite($fp, "User-Password = \"$config[general_test_account_password]\"\n");
|
|
|
87 |
pclose($fp);
|
|
|
88 |
}
|
|
|
89 |
else{
|
|
|
90 |
fwrite($fp, "User-Name = \"$login\"\n");
|
|
|
91 |
if ($auth_proto == 'chap')
|
|
|
92 |
fwrite($fp, "CHAP-Password = \"$passwd\"\n");
|
|
|
93 |
else
|
|
|
94 |
fwrite($fp, "User-Password = \"$passwd\"\n");
|
|
|
95 |
if (strlen($extra))
|
|
|
96 |
fwrite($fp,$extra);
|
|
|
97 |
pclose($fp);
|
|
|
98 |
}
|
|
|
99 |
$reply = file($tmp_file);
|
|
|
100 |
unlink($tmp_file);
|
|
|
101 |
$msg = "<b>" . strftime('%A, %e %B %Y, %T %Z') . "</b><br>\n";
|
|
|
102 |
$msg .= "<b>Server: </b><i>$server:$port</i><br><br>\n";
|
|
|
103 |
if (ereg('code 2', $reply[0]))
|
|
|
104 |
$msg .= "<b>L'authentification a <font color=green>réussie</font>";
|
|
|
105 |
else if (ereg('code 3',$reply[0]))
|
|
|
106 |
$msg .= "<b>L'authentification a <font color=red>échouée</font>";
|
|
|
107 |
else if (ereg('no response from server', $reply[0]))
|
|
|
108 |
$msg .= "<b><font color=red>Pas de réponse du serveur</font>";
|
|
|
109 |
else if (ereg('Connection refused',$reply[0]))
|
|
|
110 |
$msg .= "<b><font color=red>La connection a été refusée</font>";
|
|
|
111 |
if ($test_login)
|
|
|
112 |
$msg .= "</b><i> (test de l'utilisateur $login)</i><br>\n";
|
|
|
113 |
else
|
|
|
114 |
$msg .= "</b><br>\n";
|
|
|
115 |
array_shift($reply);
|
|
|
116 |
if (count($reply)){
|
|
|
117 |
$msg .= "<br><b>Réponse du serveur :</b><br>\n";
|
|
|
118 |
foreach ($reply as $val){
|
|
|
119 |
$msg .= "<i>$val</i><br>\n";
|
|
|
120 |
}
|
|
|
121 |
}
|
|
|
122 |
if ($test_login){
|
|
|
123 |
print <<<EOM
|
|
|
124 |
$msg
|
|
|
125 |
<br>
|
|
|
126 |
</td></tr>
|
|
|
127 |
</table>
|
|
|
128 |
</tr>
|
|
|
129 |
</table>
|
|
|
130 |
</body>
|
|
|
131 |
</html>
|
|
|
132 |
EOM;
|
|
|
133 |
exit();
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
}
|
|
|
137 |
}
|
|
|
138 |
?>
|
|
|
139 |
<form method=post>
|
|
|
140 |
<input type=hidden name=login value=<?php print $login ?>>
|
|
|
141 |
<input type=hidden name=test_user value="0">
|
|
|
142 |
<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
|
|
|
143 |
<tr>
|
|
|
144 |
<td align=right bgcolor="#d0ddb0">
|
|
|
145 |
Mot de passe utilisateur
|
|
|
146 |
</td>
|
|
|
147 |
<td>
|
|
|
148 |
<input type=password name=passwd value="<?php print $passwd ?>" size=25>
|
|
|
149 |
</td>
|
|
|
150 |
</tr>
|
|
|
151 |
<tr>
|
|
|
152 |
<td align=right bgcolor="#d0ddb0">
|
|
|
153 |
Serveur Radius
|
|
|
154 |
</td>
|
|
|
155 |
<td>
|
|
|
156 |
<input type=text name=server value="<?php print $server ?>" size=25>
|
|
|
157 |
</td>
|
|
|
158 |
</tr>
|
|
|
159 |
<tr>
|
|
|
160 |
<td align=right bgcolor="#d0ddb0">
|
|
|
161 |
Port du serveur Radius
|
|
|
162 |
</td>
|
|
|
163 |
<td>
|
|
|
164 |
<input type=text name=port value="<?php print $port ?>" size=25>
|
|
|
165 |
</td>
|
|
|
166 |
</tr>
|
|
|
167 |
<tr>
|
|
|
168 |
<td align=right bgcolor="#d0ddb0">
|
|
|
169 |
Attributs supplémentaires
|
|
|
170 |
</td>
|
|
|
171 |
<td>
|
|
|
172 |
<textarea name="extra" cols="35" wrap="PHYSICAL" rows="4"><?php print $extra ?></textarea>
|
|
|
173 |
</td>
|
|
|
174 |
</tr>
|
|
|
175 |
<tr>
|
|
|
176 |
<td align=right bgcolor="#d0ddb0">
|
|
|
177 |
Protocole d'authentification
|
|
|
178 |
</td>
|
|
|
179 |
<td>
|
|
|
180 |
<?php
|
|
|
181 |
echo <<<EOM
|
|
|
182 |
<select name="auth_proto" editable>
|
|
|
183 |
<option $selected[pap] value="pap">PAP
|
|
|
184 |
<option $selected[chap] value="chap">CHAP
|
|
|
185 |
EOM
|
|
|
186 |
?>
|
|
|
187 |
</select>
|
|
|
188 |
</td>
|
|
|
189 |
</tr>
|
|
|
190 |
|
|
|
191 |
</table>
|
|
|
192 |
<br>
|
|
|
193 |
<input type=submit class=button value="Lancement du Test" OnClick="this.form.test_user.value=1">
|
|
|
194 |
</form>
|
|
|
195 |
<?php
|
|
|
196 |
if ($test_user == 1){
|
|
|
197 |
echo <<<EOM
|
|
|
198 |
<br>
|
|
|
199 |
$msg
|
|
|
200 |
EOM;
|
|
|
201 |
}
|
|
|
202 |
?>
|
|
|
203 |
</td></tr>
|
|
|
204 |
</table>
|
|
|
205 |
</tr>
|
|
|
206 |
</table>
|
|
|
207 |
</body>
|
|
|
208 |
</html>
|