-
Notifications
You must be signed in to change notification settings - Fork 4
/
radius.demo.php
54 lines (46 loc) · 1.7 KB
/
radius.demo.php
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
<?php
require_once('radius.class.php');
?>
<html>
<head>
<title>
Pure PHP radius class demo
</title>
</head>
<body>
<?php
if ((isset($_POST['user'])) && ('' != trim($_POST['user'])))
{
$radius = new Radius('127.0.0.1', 'secret');
$radius->SetNasIpAddress('127.0.0.1'); // Needed for some devices, and not auto_detected if PHP not runned through a web server
// Enable Debug Mode for the demonstration
$radius->SetDebugMode(TRUE);
if ($radius->AccessRequest($_POST['user'], $_POST['pass']))
{
echo "<strong>Authentication accepted.</strong>";
}
else
{
echo "<strong>Authentication rejected.</strong>";
}
echo "<br />";
echo "<br /><strong>GetReadableReceivedAttributes</strong><br />";
echo $radius->GetReadableReceivedAttributes();
echo "<br />";
echo "<a href=\"".$_SERVER['PHP_SELF']."\">Reload authentication form</a>";
}
else
{
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
User: <input name="user" type="text" value="user" />
<br />
Pass: <input name="pass" type="text" value="pass" /> (text type for educational purpose only) <!-- type="text" for educational purpose only ! -->
<br />
<input name="submit" type="submit" value="Check authentication" />
</form>
<?php
}
?>
</body>
<html>