Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Unifi中的外部门户_Javascript_Php_Jquery_Html_Session - Fatal编程技术网

Javascript Unifi中的外部门户

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.

我正在unifi AC中创建一个外部门户,在那里,用户将通过身份验证,然后,如果他们存在,他们将被允许使用internet连接一段时间。问题是,在用户通过身份验证后,我获得了一些允许用户使用internet的代码,但他们不为我工作。 因此,用户在外部门户中经过身份验证,但不允许启动 使用互联网允许用户开始使用互联网的代码是 在函数sendAuthentication中

login.php源代码

<?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合作,则需要有关如何使其工作的帮助