2

次のシナリオで 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");
   }
?>

ありがとうございました...

4

1 に答える 1

0

問題が解決しました ...

暗号化されていないシンプルなパスワードを渡しているので、HTTP PAP を確認してください

forum.mikrotik.com/...

于 2016-09-09T07:22:36.697 に答える