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