Javascript Unifi中的外部门户
我正在unifi AC中创建一个外部门户,在那里,用户将通过身份验证,然后,如果他们存在,他们将被允许使用internet连接一段时间。问题是,在用户通过身份验证后,我获得了一些允许用户使用internet的代码,但他们不为我工作。 因此,用户在外部门户中经过身份验证,但不允许启动 使用互联网允许用户开始使用互联网的代码是 在函数sendAuthentication中 login.php源代码Javascript Unifi中的外部门户,javascript,php,jquery,html,session,Javascript,Php,Jquery,Html,Session,我正在unifi AC中创建一个外部门户,在那里,用户将通过身份验证,然后,如果他们存在,他们将被允许使用internet连接一段时间。问题是,在用户通过身份验证后,我获得了一些允许用户使用internet的代码,但他们不为我工作。 因此,用户在外部门户中经过身份验证,但不允许启动 使用互联网允许用户开始使用互联网的代码是 在函数sendAuthentication中 login.php源代码 <?php session_start(); require_once('dbconnect.
<?php session_start();
require_once('dbconnect.php');
$username = trim($_POST['username']);
$password = trim(md5($_POST['pass']));
$query = "select * from students where email='".$username."' && password='".$password."'";
$result = mysql_query($query) or die (mysql_error());
$row = mysql_fetch_array($result);
if($username === $row['email'] && $password === $row['password']){
//Minutes to authorize, change to suit your needs
echo '<script language="javascript">';
echo 'alert("Successfully login")';
echo '</script>';
sendAuthorization($_SESSION['id'], (12*60));
return true;
}
else{
$_SESSION['error']=TRUE;
header('location:http://b4w.uhuruone.co.tz/guest/s/default/');
}
function sendAuthorization($id, $minutes)
{
$unifiServer = "https://41.38.13.78:8443";
$unifiUser = "bro4wote";
$unifiPass = "rt@b45w";
// Start Curl for login
$ch = curl_init();
// We are posting data
curl_setopt($ch, CURLOPT_POST, TRUE);
// Set up cookies
$cookie_file = "/tmp/unifi_cookie";
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
// Allow Self Signed Certs
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
// Force SSL3 only
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
// Login to the UniFi controller
curl_setopt($ch, CURLOPT_URL, "$unifiServer/login");
curl_setopt($ch, CURLOPT_POSTFIELDS,
"login=login&username=$unifiUser&password=$unifiPass");
// send login command
curl_exec ($ch);
// Send user to authorize and the time allowed
$data = json_encode(array(
'cmd'=>'authorize-guest',
'mac'=>$id,
'minutes'=>$minutes));
// Send the command to the API
curl_setopt($ch, CURLOPT_URL, $unifiServer.'/api/cmd/stamgr');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'json='.$data);
curl_exec ($ch);
// Logout of the UniFi Controller
curl_setopt($ch, CURLOPT_URL, $unifiServer.'/logout');
curl_exec ($ch);
curl_close ($ch);
unset($ch);
}
?>
<p>Connecting to the network...</p>
<script>
//allow time for the authorization to go through
setTimeout("location.href='http://www.Google.com'",6000);
</script>
如果有任何人曾与外部Unifi AC合作,则需要有关如何使其工作的帮助