Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and exploring the core foundations for app libraries.
Set SessionLookup=oConn.Execute("SELECT * FROM site_sessions WHERE session_ID="&Session.SessionID)
If Not SessionLookup.EOF Then
Session_ID=SessionLookup("session_ID")
Else
Set oXMLHTTPLocIP=CreateObject("MSXML2.ServerXMLHTTP")
LocIP="http://api.ipify.org/"
oXMLHTTPLocIP.Open "GET",LocIP,False
oXMLHTTPLocIP.Send
If oXMLHTTPLocIP.Status="200" Then
IP=oXMLHTTPLocIP.responseText
Set oXMLHTTPLoc=CreateObject("MSXML2.ServerXMLHTTP")
IP=oXMLHTTPLocIP.responseText
LocAPI="http://ip-api.com/json/"&IP&"?fields=countryCode,city"
oXMLHTTPLoc.Open "GET",LocAPI,False
oXMLHTTPLoc.Send
If oXMLHTTPLoc.Status="200" Then
GetTextFromUrlLoc=oXMLHTTPLoc.responseText
CityLoc=Replace(Split(Split(GetTextFromUrlLoc,",")(0),":")(1),"""","")
CountryLoc=Replace(Replace(Split(Split(GetTextFromUrlLoc,",")(1),":")(1),"""",""),"}","")
End If
End If
oConn.Execute("INSERT INTO site_sessions(session_ID,brand_ID,session_IP,session_geoCity,session_geoCountry,session_timezone,session_date,session_time) VALUES("&Session.SessionID&",'"&SubDomain("brand_ID")&"','"&IP&"','"&CityLoc&"','"&CountryLoc&"','"&Timezone()&"','"&Date()&"','"&Time()&"')")
Set NewSession=oConn.Execute("SELECT @@IDENTITY AS New_Session_ID")
Session_ID=Cstr(NewSession("New_Session_ID"))
End If
Do more with
Set httpIP=CreateObject("MSXML2.ServerXMLHTTP")
LocIP="http://api.ipify.org/"
httpIP.Open "GET",LocIP,False
httpIP.Send
WScript.Echo "httpIP status:", httpIP.Status
If httpIP.Status="200" Then
IP=httpIP.responseText
WScript.Echo "httpIP response:", httpIP.responseText
Set httpLocation=CreateObject("MSXML2.ServerXMLHTTP")
IP=httpIP.responseText
LocAPI="http://ip-api.com/json/"&IP&"?fields=countryCode,city"
httpLocation.Open "GET",LocAPI,False
httpLocation.Send
WScript.Echo "httpLocation status:", httpLocation.Status
If httpLocation.Status="200" Then
WScript.Echo "httpLocation response:", httpLocation.responseText
GetTextFromUrlLoc=httpLocation.responseText
City = Replace(Split(Split(GetTextFromUrlLoc,",")(0),":")(1),"""","")
Country = Replace(Replace(Split(Split(GetTextFromUrlLoc,",")(1),":")(1),"""",""),"}","")
WScript.Echo "City: ", City
WScript.Echo "Country: ", Country
End If
End If
Set httpIP=CreateObject("MSXML2.ServerXMLHTTP")
LocIP="http://ip-api.com/json"
httpIP.Open "GET",LocIP,False
httpIP.Send
WScript.Echo "httpIP status:", httpIP.Status
If httpIP.Status="200" Then
IP=httpIP.responseText
WScript.Echo "httpIP response:", httpIP.responseText
End If
Set oXMLHTTPLoc=CreateObject("MSXML2.ServerXMLHTTP")
LocAPI="http://ip-api.com/json/"&IP&"?fields=countryCode,city"
oXMLHTTPLoc.Open "GET",LocAPI,False
oXMLHTTPLoc.Send
If oXMLHTTPLoc.Status="200" Then
GetTextFromUrlLoc=oXMLHTTPLoc.responseText
CityLoc=Replace(Split(Split(GetTextFromUrlLoc,",")(0),":")(1),"""","")
CountryLoc=Replace(Replace(Split(Split(GetTextFromUrlLoc,",")(1),":")(1),"""",""),"}","")
End If
Premium Content
You need an Expert Office subscription to comment.Start Free Trial