File: D:/web/common/geoip/geoip-check-log.asp
<%@ Language="VBScript" %>
<%
Option Explicit
'=== Helper: VBScript-compatible IIf() substitute =====================
Function IIf(condition, truePart, falsePart)
If condition Then
IIf = truePart
Else
IIf = falsePart
End If
End Function
'--- CONFIG ------------------------------------------------------------
Const CONNSTR = "DSN=MySQL_common;"
Const adCmdText = 1
Const adParamInput = 1
Const FLAG_PATH = "flags/"
Const GLOBE_ICON = "flags/globe.svg"
'-----------------------------------------------------------------------
Dim conn, cmd, rs, sql, whereSQL, filterDate, filterCountry
filterDate = Trim(Request("date"))
filterCountry = Trim(Request("country"))
whereSQL = ""
'=== Simple flag path resolver ========================================
Function GetFlagSrc(ByVal iso)
If iso = "" Then
GetFlagSrc = GLOBE_ICON
Else
GetFlagSrc = FLAG_PATH & LCase(iso) & ".svg"
End If
End Function
'=== Build SQL with filters ===========================================
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open CONNSTR
Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = conn
cmd.CommandType = adCmdText
sql = "SELECT ID, DateTimeChecked, IPAddress, " & _
"CountryISO, Country, Found, " & _
"CountryOldISO, CountryOld, FoundOld " & _
"FROM geoip_check_log "
If filterDate <> "" Then
whereSQL = "WHERE DATE(DateTimeChecked)=? "
cmd.Parameters.Append cmd.CreateParameter("@p1", 200, adParamInput, 10, filterDate)
End If
If filterCountry <> "" Then
If whereSQL = "" Then
whereSQL = "WHERE (Country LIKE ? OR CountryOld LIKE ?) "
Else
whereSQL = whereSQL & "AND (Country LIKE ? OR CountryOld LIKE ?) "
End If
cmd.Parameters.Append cmd.CreateParameter("@p2", 200, adParamInput, 100, "%" & filterCountry & "%")
cmd.Parameters.Append cmd.CreateParameter("@p3", 200, adParamInput, 100, "%" & filterCountry & "%")
End If
sql = sql & whereSQL & "ORDER BY DateTimeChecked DESC LIMIT 100"
cmd.CommandText = sql
Set rs = cmd.Execute()
%>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>GeoIP Check Log</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
<style>
.flag{width:22px;height:16px;vertical-align:middle;margin-right:6px;border:1px solid #ddd}
.note{color:#666;font-size:0.9em;margin-top:0.5em}
th,td{font-size:0.9em;vertical-align:middle}
.has-text-danger{color:#d33!important}
.has-text-success{color:#090!important}
a.ip-link{color:#3273dc;text-decoration:none}
a.ip-link:hover{text-decoration:underline}
</style>
</head>
<body class="section">
<div class="container">
<h1 class="title is-3">GeoIP Check Log</h1>
<form method="get" action="geoip-check-log.asp" class="box" style="margin-bottom:1.5em">
<div class="field is-grouped">
<div class="control">
<input class="input" type="date" name="date" value="<%=Server.HTMLEncode(filterDate)%>" placeholder="Filter by date">
</div>
<div class="control is-expanded">
<input class="input" type="text" name="country" value="<%=Server.HTMLEncode(filterCountry)%>" placeholder="Filter by country">
</div>
<div class="control">
<button type="submit" class="button is-primary">Filter</button>
</div>
<div class="control">
<a href="geoip-check-log.asp" class="button is-light">Clear</a>
</div>
</div>
<p class="note">Showing the 100 most recent entries<% If filterDate<>"" Or filterCountry<>"" Then Response.Write(" (filtered)") End If %>.</p>
</form>
<table class="table is-striped is-fullwidth is-hoverable">
<thead>
<tr>
<th>ID</th>
<th>Date/Time</th>
<th>IP Address</th>
<th>New Country</th>
<th>Found</th>
<th>Old Country</th>
<th>Found</th>
</tr>
</thead>
<tbody>
<% If rs.EOF Then %>
<tr><td colspan="7"><em>No log entries found.</em></td></tr>
<% Else
Do Until rs.EOF
Dim ip, country, countryISO, oldCountry, oldCountryISO, ipLink
ip = rs("IPAddress") & ""
country = rs("Country") & ""
oldCountry = rs("CountryOld") & ""
countryISO = rs("CountryISO") & ""
oldCountryISO = rs("CountryOldISO") & ""
ipLink = "https://www.ip2location.com/demo/" & Server.URLEncode(ip)
%>
<tr>
<td><%=rs("ID")%></td>
<td><%=rs("DateTimeChecked")%></td>
<td><a href="<%=ipLink%>" target="_blank" class="ip-link"><%=Server.HTMLEncode(ip)%></a></td>
<td>
<img class="flag" src="<%=GetFlagSrc(countryISO)%>" alt="<%=Server.HTMLEncode(country)%> flag">
<%=Server.HTMLEncode(country)%>
</td>
<td class="<%=IIf(rs("Found")=1,"has-text-success","has-text-danger")%>"><%=IIf(rs("Found")=1,"Yes","No")%></td>
<td>
<img class="flag" src="<%=GetFlagSrc(oldCountryISO)%>" alt="<%=Server.HTMLEncode(oldCountry)%> flag">
<%=Server.HTMLEncode(oldCountry)%>
</td>
<td class="<%=IIf(rs("FoundOld")=1,"has-text-success","has-text-danger")%>"><%=IIf(rs("FoundOld")=1,"Yes","No")%></td>
</tr>
<%
rs.MoveNext
Loop
End If %>
</tbody>
</table>
<p style="margin-top:1em">
<a href="geoip-checker.asp" class="button is-link">🔍 Back to GeoIP Checker</a>
</p>
</div>
</body>
</html>
<%
rs.Close
conn.Close
Set rs = Nothing
Set cmd = Nothing
Set conn = Nothing
%>