php - Mikrtotik - Internal login page causing Infinte loops -


i trying use mikrotik hotspot following scenario.

when user connected hotspot, login.html page redirect external page index.php check exist user csv.

if user exist redirect redirect.html. if user not exist redirect register.html & register.php store user info in csv file.

whole upper scenario working fine.

the main problem when redirect.html called, browser loops between external server address , internal server address repeatedly , rapidly.

here login.html code

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

here redirect.html code

<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 use 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 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> 

here index.php code

<?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");    } ?> 

in last here register.php code

<?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 open file!");     fwrite($myfile, $macaddress. "," . $name . "\n");     fclose($myfile);     header("location: http://192.168.88.1/redirect.html");    } ?> 

thankyou...

problem solved ...

i'm passing password simple not encrypted check http pap

forum.mikrotik.com/...


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -