function radius_authenticate($username,$password) { global $config, $rad, $rad_userlevel; radius_init(); if ($username && $rad) { radius_create_request($rad, RADIUS_ACCESS_REQUEST); radius_put_string($rad, 1, $username); radius_put_string($rad, 2, $password); radius_put_string($rad, 4, $_SERVER['SERVER_ADDR']); $response = radius_send_request($rad); if ($response == RADIUS_ACCESS_ACCEPT) { $rad_userlevel = 1; while ($rad_attr = radius_get_attr($rad)) { if ((intval($rad_attr['attr']) == 25) && (intval($rad_attr['data']) > 0)) { $rad_userlevel = intval($rad_attr['data']); } } return 1; } } session_logout(); return 0; } function radius_auth_user_level($username) { global $rad_userlevel; return $rad_userlevel; }