$username = 'test';
$password = 'test';
$radserver = '192.168.6.4';
$radport = 1812;
$sharedsecret = '1234567890';
$res = radius_auth_open();
echo "$res
\n";
while(1){
if (!radius_add_server($res, $radserver, $radport, $sharedsecret, 3, 3)) break;
if (!radius_create_request($res, RADIUS_ACCESS_REQUEST)) break;
// if (!radius_put_string($res, RADIUS_NAS_IDENTIFIER, isset($HTTP_HOST) ? $HTTP_HOST : 'localhost')) break;
// if (!radius_put_int($res, RADIUS_SERVICE_TYPE, RADIUS_FRAMED)) break;
// if (!radius_put_int($res, RADIUS_FRAMED_PROTOCOL, RADIUS_PPP)) break;
// if (!radius_put_string($res, RADIUS_CALLING_STATION_ID, isset($REMOTE_HOST) ? $REMOTE_HOST : '127.0.0.1') == -1) break;
if (!radius_put_string($res, RADIUS_USER_NAME, $username)) break;
if (!radius_put_string($res, RADIUS_USER_PASSWORD, $password)) break;
$req = radius_send_request($res);
if (!$req) break;
if($req== RADIUS_ACCESS_ACCEPT) echo "ok";
else echo "fail";
exit();
}
echo 'RadiusError:' . radius_strerror($res);
?>
參考文件
http://sophie.zarb.org/distrib/Mandriva/cooker/x86_64/rpms/php-radius/files/10
http://php.net/manual/en/radius.constants.attributes.php
沒有留言:
張貼留言