Mikrotik - 使用无限循环的内部登录页面

Mikrtotik - Internal login page causing Infinte loops

我正在尝试在以下情况下使用 Mikrotik 热点。

当用户连接到热点时,login.html页面重定向到外部页面index.php检查是否存在来自 csv 的用户。

如果用户存在则它将重定向到 redirect.html。 如果用户不存在,它将重定向到 register.html & register.php 将用户信息存储在 CSV 文件中。

整个上层场景运行良好。

主要问题是当调用redirect.html时,浏览器在外部服务器地址和内部服务器地址之间反复快速循环。

这里是login.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>

这是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&amp;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&amp;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>&nbsp;</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>

这是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

forum.mikrotik.com/...