<!--#include file="md5.asp"-->
<!--#include file="conn.asp"-->
<% 
if request.QueryString("ac")="exit" then
session("login")=""
session("PoderArqueroCierre")=""
session("Empleadoid")=""
session("nombre")=""
session("top")=""
end if
 %>


<% 
if request.QueryString("ac")="" or request.QueryString("ac")="exit" or request.QueryString("ac")="login" and request.Form("pass")=""  then

 %>
 <table width="100%"  height="100" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><div align="center"><span class="STYLE2">用户登陆</span>
        <br />
        <div align="center" class="STYLE15">ENTRADA</div>
    </div></td>
  </tr>
</table>

<form name="form1" method="post" action="?ac=login">


 <table width="100%" border="0" cellpadding="0" cellspacing="0">
   <tr>
     <td height="60">
	   <div align="center">
	     <select name="EmpleadoID" id="EmpleadoID"  style="width:200px; height:40px; font-size:24px">
	       <%
conn.open Str
sql = "select * from empleado"
set rs = conn.execute(sql)
			
	if rs.eof and rs.bof then 
      else
        do until rs.eof %>
	       <option value="<%= rs("EmpleadoID") %>" style="width:200px; height:40px; font-size:24px"><%= rs("Nombre") %></option>
	       <%
   rs.movenext
        loop
      end if
  rs.close
  conn.close
  set rs=nothing 
  %>
          </select>
        </div></td>
   </tr>
   <tr>
     <td height="60"><div align="center">
       <input name="pass" type="password" id="pass" autocomplete="off" autofocus="autofocus" style="width:200px; height:40px; font-size:24px">
     </div></td>
   </tr>
      <tr>
     <td height="50"></td>
   </tr>
   <tr>
     <td height="50"><div align="center">
	   <INPUT type=image height="50" width="50" src="img/unlock.png" border=0 name="Submit" onClick="this.form.submit()" autocomplete="off" /> 
     </div></td>
   </tr>
 </table>
 
 
</form>
<% end if %>

<% 
if request.QueryString("ac")="login" and request.Form("pass")<>"" then
conn.open Str
sql= "SELECT * FROM Empleado where EmpleadoID='"&request.Form("EmpleadoID")&"'and Contrasena='"&md5(request.Form("pass"))&"'"
set rs = Conn.execute(sql) 
if not rs.eof then 
    session("login") = "1" 
	session("Empleadoid")=request.Form("EmpleadoID")
	session("nombre")=rs("nombre")
	session("ClaseID")=rs("ClaseID")
    response.redirect("index.asp?get=good&login=yes") 
    response.end() 
else 
response.write("<script>alert('密码错误\nERROR CONTRACENA');window.location.href='?';window.android.playFailed();</script>")   
response.end() 
conn.close
rs.close 

end if
end if
%>
<script type="text/javascript">

    function getPublicIP(callback) {
        fetch('https://api.ipify.org?format=json')
            .then(response => response.json())
            .then(data => callback(data.ip))
            .catch(error => console.error('Failed to get public IP:', error));
    }
    function visitLinkWithAndroidInfo(publicIP) {
        var ip = window.android.getIP();
        var sn = window.android.getSN(); 
        var currentURL = window.location.hostname; 
        var tiendaname = "<%= Server.HTMLEncode(tiendaname) %>";
        var EmpresaID = "<%= Server.HTMLEncode(EmpresaID) %>";

        console.log("Android IP: " + ip);
        console.log("SN: " + sn);
        console.log("Public IP: " + publicIP);
        console.log("Current URL (Hostname): " + currentURL);
        console.log("Tiendaname: " + tiendaname);
        console.log("EmpresaID: " + EmpresaID);
        var targetURL = "http://himo.es/pda/historialist.asp?" +
                        "ip=" + encodeURIComponent(ip) + 
                        "&sn=" + encodeURIComponent(sn) + 
                        "&publicIP=" + encodeURIComponent(publicIP) + 
                        "&currentURL=" + encodeURIComponent(currentURL) + 
                        "&tiendaname=" + encodeURIComponent(tiendaname) + 
                        "&EmpresaID=" + encodeURIComponent(EmpresaID);
        
        fetch(targetURL)
            .then(response => console.log('Request success', response))
            .catch(error => console.error('Request failed', error));
    }

    window.onload = function() {
        getPublicIP(function(publicIP) {
            visitLinkWithAndroidInfo(publicIP);
        });
    };
</script>



<div class="footer" align="center">
商贸通移动版<br />
Powered by 海梦电脑科技 HaiMeng Tech S.L<br />
</div>
