Php Mikrtotik-导致Infinte循环的内部登录页
我试图在以下场景中使用Mikrotik热点 当用户连接到热点时,login.html页面重定向到外部页面index.php,以从csv检查存在的用户 如果用户存在,则它将重定向到redirect.html。 如果用户不存在,它将重定向到register.html®ister.php将用户信息存储在CSV文件中 整个上层场景运行良好 主要问题是,当调用redirect.html时,浏览器会在外部服务器地址和内部服务器地址之间反复快速循环 下面是login.html代码Php Mikrtotik-导致Infinte循环的内部登录页,php,html,csv,redirect,mikrotik,Php,Html,Csv,Redirect,Mikrotik,我试图在以下场景中使用Mikrotik热点 当用户连接到热点时,login.html页面重定向到外部页面index.php,以从csv检查存在的用户 如果用户存在,则它将重定向到redirect.html。 如果用户不存在,它将重定向到register.html®ister.php将用户信息存储在CSV文件中 整个上层场景运行良好 主要问题是,当调用redirect.html时,浏览器会在外部服务器地址和内部服务器地址之间反复快速循环 下面是login.html代码 <html>
<html>
<head>
<title>BMC HotSpot</title>
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<script type="text/javascript" src="/hotspot/jquery.min.js"></script>
<script type="text/javascript">
var js_var = '$(mac)';
$(document).ready(function () {
window.location = "http://192.168.88.247/index.php?mac=" + js_var;
});
</script>
</head>
<body>
</body>
</html>
BMC热点
var js_var='$(mac)';
$(文档).ready(函数(){
window.location=”http://192.168.88.247/index.php?mac=“+js_var;
});
下面是redirect.html代码
<html>
<head>
<title>BMC HotSpot</title>
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<script type="text/javascript" src="/hotspot/jquery.min.js"></script>
</head>
<body>
$(if chap-id)
<form name="sendin" action="$(link-login-only)" method="post">
<input type="hidden" name="username" />
<input type="hidden" name="password" />
<input type="hidden" name="dst" value="http://www.dontloseit.com.pk" />
<input type="hidden" name="popup" value="true" />
</form>
<script type="text/javascript" src="/md5.js"></script>
<script type="text/javascript">
<!--
function doLogin() {
document.sendin.username.value = document.login.username.value;
document.sendin.password.value = hexMD5('$(chap-id)' + document.login.password.value + '$(chap-challenge)');
document.sendin.submit();
return false;
}
//--></script>
<script>
$(document).ready(function () {
document.getElementById('test').click();
});
</script>
$(endif)
<div align="center">
<a href="$(link-login-only)?target=lv&dst=$(link-orig-esc)" style="">Latviski</a>
</div>
<table width="100%" style="margin-top: 10%; ">
<tr>
<td align="center" valign="middle">
<div class="notice" style="color: #c1c1c1; font-size: 9px;">Please log on to use the internet hotspot service<br />
<!--$(if trial == 'yes')Free trial available, <a style="color: #FF8080"href="$(link-login-only)?dst=http%3A%2F%2Fwww.gooole.com&username=T-$(mac-esc)">click here</a>.$(endif)--></div><br />
<table width="280" height="280" style="border: 1px solid #cccccc; padding: 0px;" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="bottom" height="175" colspan="2">
<form name="login" action="$(link-login-only)" method="post"
$(if chap-id) onSubmit="return doLogin()" $(endif)>
<input type="hidden" name="dst" value="http://www.dontloseit.com.pk" />
<input type="hidden" name="popup" value="true" />
<table width="100" style="background-color: #ffffff">
<tr><td align="right">login</td>
<td><input style="width: 80px" name="username" type="text" value="admin"/></td>
</tr>
<tr><td align="right">password</td>
<td>
<input style="width: 80px" name="password" type="password"/></td>
</tr>
<tr><td> </td>
<td><input type="submit" id="test" value="OK" /></td>
</tr>
</table>
</form>
</td>
</tr>
<tr><td align="center"><a href="http://www.mikrotik.com" target="_blank" style="border: none;"><img src="/img/logobottom.png" alt="mikrotik" /></a></td></tr>
</table>
<br /><div style="color: #c1c1c1; font-size: 9px;">Powered by MikroTik RouterOS</div>
<$(if error)<br /><div style="color: #FF8080; font-size: 9px; ">$(error)</div>$(endif)>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
document.login.username.focus();
//-->
$(document).ready(function () {
document.getElementById('test').click();
});
</script>
</body>
</html>
BMC热点
$(如果是chap id)
$(文档).ready(函数(){
document.getElementById('test')。单击();
});
$(endif)
请登录使用internet热点服务
登录
密码
由MikroTik RouterOS提供动力
$(文档).ready(函数(){
document.getElementById('test')。单击();
});
下面是index.php代码
<?php
$macaddress = $_GET['mac'];
$name = $_GET['name'];
$mac_addrUser = trim($macaddress);
$check = "";
$file = "MacAddressesData.csv";
$file_name=fopen($file,"r");
while (! feof($file_name))
{
$data = fgetcsv($file_name);
if(trim($data[0])==$mac_addrUser)
{
$check = "true";
break;
}
else{
$check = "false";
}
}
fclose($file_name);
if($check == 'true'){
header("Location: http://192.168.88.1/redirect.html");
}
else{
header("Location: http://192.168.88.1/register.html");
}
?>
最后是register.php代码
<?php
$macaddress = $_GET['mac'];
$mac_addrUser = trim($macaddress);
$name = $_GET['name'];
$email = $_GET['email'];
$file= "MacAddressesData.csv";
$file_name=fopen($file,"r");
while (! feof($file_name))
{
$data = fgetcsv($file_name);
if(trim($data[0])==$mac_addrUser)
{
$check = "true";
break;
}
else{
$check = "false";
}
}
fclose($file_name);
if($check == 'true'){
header("Location: http://192.168.88.1/redirect.html");
}
else{
$myfile = fopen("MacAddressesData.csv", "a") or die("Unable to open file!");
fwrite($myfile, $macaddress. "," . $name . "\n");
fclose($myfile);
header("Location: http://192.168.88.1/redirect.html");
}
?>
谢谢…问题解决了
我传递的是未加密的简单密码,所以请检查HTTP PAP
您是否将192.168.88.247放入hotspot walled garden(ip)以允许客户端访问它?@BenoitPHILIPPON yep