<?php 
require_once ("radius_config.php");
require_once('radius.class.php'); 
require_once('func_core.php');
?> 
<html> 
<head>
<link href="images/panel.ico" rel="shortcut icon" type="image/x-icon" />
				<title>UniOTP Logon deamon
				</title>
				<style>
					.auth_user{
						background:url(images/otp_user.png) no-repeat #ffffff;
						border:1px solid #000000;
						background-position:1px 1px;
						padding-left:20px;
						vertical-align:center;
						font-size:16px;
					}
					.auth_pwd{
						background:url(images/otp_lock.png) no-repeat #ffffff;
						border:1px solid #000000;
						background-position:1px 1px;
						padding-left:20px;
						vertical-align:center;
						font-size:16px;
					}
				</style>
				<center>
				<H1>
				UniOTP Authentication System<hr>
				</H1>
				</center>
				</head>
				<body bgcolor=#f0faff >
				<?php
				if(isset($_POST['username']) && isset($_POST['password']) && ('' != $_POST['username']) && ('' != $_POST['password']))
				{
					$radius = new Radius($secu_ip_radius_srv, $secu_shared_key, $secu_udp_timeout, $secu_authentication_port);
					$ret = $radius->AccessRequest($_POST['username'], $_POST['password']);
					if (ACCESS_ACCEPT == $ret)
					{
						$doneinfo = "User:".$_POST['username']."'s access request accepted<br>";
						$title = "Auth succeed";
						show_done($doneinfo,$title,$_SERVER['PHP_SELF']);
					}
					else if(ACCESS_CHALLENGE == $ret)
					{
						$errinfo = "Challenge information received. <br>Challenge information:".$radius->GetChallengeMsg()." <br />";
						$title = "Challenge request";
						show_error($errinfo,$title,$_SERVER['PHP_SELF']);
					}
					else
					{
						$errinfo = "User:".$_POST['username']."'s access request rejected<br>";
						$title = "Auth failed";
						show_error($errinfo,$title,$_SERVER['PHP_SELF']);
					}
				}
				else
				{
					?>
				<center>
				<div style="width:300px;height:150px;border:solid 1px #dddddd;">
					<div style="height:25%;width:100%;background:#ddeeff;">
						<span style="font-weight:bold;font-size:24px;text-align:left;margin-top:5px;position:relative;top:10px;left:0px;">User Logon</span>
					</div>
					<table>
						<form action=<?php echo $_SERVER['PHP_SELF'];?> method="post"><tr><td width="25%">
							Username</td><td><input class="auth_user" type="text" name="username" maxlength=20 /></td></tr><tr><td width="25%">
							Password</td><td><input class="auth_pwd" type="password" name="password" /></td></tr>
							<tr height=10px;></tr><tr><td colspan="2">
							<input type="submit" value="submit"/></td></tr>
						</form>
					</table>
				</div>
				</center>
			<?php
			}
			?>
<html> 
