<% ' Este script se utiliza para guardar en la intranet la ip de los usuarios que acceden al index de la página web ' Funciones para obtener la página web actual Function strLeft(str1, str2) strLeft = Left(str1, InStr(str1, str2) - 1) End Function Function curPageURL() Dim s, protocol, port If (Request.ServerVariables("HTTPS") = "on") Then s = "s" Else s = "" End If Protocol = strleft(LCase(Request.ServerVariables("SERVER_PROTOCOL")), "/") & s If (Request.ServerVariables("SERVER_PORT") = "80") Then port = "" Else port = ":" & Request.ServerVariables("SERVER_PORT") End If curPageURL = protocol & "://" & Request.ServerVariables("SERVER_NAME") & port & Request.ServerVariables("SCRIPT_NAME") End Function ' Cogemos la IP del usuario userIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR") If userIPAddress = "" Then userIPAddress = Request.ServerVariables("REMOTE_ADDR") End If If (Not UserIPAddress = "") Then On Error Resume Next Dim url, objXML url = "http://api.ipinfodb.com/v2/ip_query.php?key=f3ca7e43e19794b1d6b5c362e16d9fa1ddadb444239c39666e2bff172823ab39&ip=" & userIPAddress Set objXML = Server.CreateObject("MSXML2.FreeThreadedDOMDocument") If (Not Err.Description = "") Then 'Response.Write("An error occured when retrieving data from an external source.") 'Response.Write(Err.Description) 'Response.End Else ' Tomamos los datos de geolocalización del usuario objXML.setProperty "ServerHTTPRequest", True objXML.async = False objXML.Load url strCountryName = objXML.documentElement.childNodes(2).text strRegionName = objXML.documentElement.childNodes(4).text strCity = objXML.documentElement.childNodes(5).text strWeb = Replace(curPageURL(), "/ip_usuarios.asp", "") Set objXML = Nothing ' Insertamos los datos en la base de datos de la intranet Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP") 'For version 3.0 of XMLHTTP 'Set objXML = Server.CreateObject("Microsoft.XMLHTTP") 'For other version of XMLHTTP url = "http://desatascar.net/intranet/insertardatosusuarioweb.asp?fecha=" & date & "&hora=" & time & "&ip=" & userIPAddress & "&pais=" & strCountryName & "&provincia=" & strRegionName & "&ciudad=" & strCity & "&web=" & strWeb objXML.Open "GET", url, false objXML.Send Set objXML = Nothing End If End If %>