File: D:/web/hyperflight/geoipcheck.asp
<%Option Explicit%>
<!--#include file="dbfunctions.asp"-->
<%
' (SS,6/6/14) looks up the country for current or given IP, used by Shopping admin
' (SS,4/8/14) added missing closing html tag from end
%>
<html>
<head>
<title>Geo IP Country Check</title>
<style type="text/css">
table{
border-collapse: collapse;
border: 1px solid black;
font-family: Cambria;
}
table td{
border: 1px solid black;
padding: 5px;
}
</style>
</head>
<body>
<%
Dim LIPAddress, LIPAddressInt, LCountryCode, LCountryName, LIPRange, LIPCount
LIPAddress = Request.QueryString("ip")
If LIPAddress = "" Then LIPAddress = Request.ServerVariables("REMOTE_ADDR")
LIPAddressInt = IPAddressToInt(LIPAddress)
LCountryCode = "?"
LCountryName = "?"
If LIPAddressInt <> 0 Then
OpenDatabaseCommon
OpenQueryCommon("SELECT * FROM geo_ip_country WHERE IPStartInteger <= " & LIPAddressInt & " AND IPEndInteger >= " & LIPAddressInt)
If Not EndOfQueryCommon Then
LCountryCode = GetQueryValueCommon("CountryISOCode")
LCountryName = GetQueryValueCommon("CountryName")
LIPRange = GetQueryValueCommon("IPStartDottedDecimal") & " -> " & GetQueryValueCommon("IPEndDottedDecimal")
LIPCount = GetQueryValueCommon("IPEndInteger") - GetQueryValueCommon("IPStartInteger") + 1
End If
CloseQueryCommon
CloseDatabaseCommon
End If
%>
<table>
<tr><td>IP Address</td><td style="font-weight: bold"><%=LIPAddress%></td></tr>
<tr><td>Country Code</td><td style="font-weight: bold"><%=LCountryCode%></td></tr>
<tr>
<td>Country Name</td><td style="font-weight: bold"><div style="float: left; padding-top: 2px"><%=LCountryName%></div>
<%If LCountryCode <> "?" Then%>
<img src="/common/flags/iso/24/<%=LCountryCode%>.png" style="vertical-align: middle; float: right">
<%End If%>
</td>
</tr>
<tr><td>IP Range</td><td style="font-weight: bold"><%=LIPRange%></td></tr>
<tr><td>IP Count</td><td style="font-weight: bold"><%=LIPCount%></td></tr>
</table>
</body>
</html>