Files
2026-11-24 22:05:11 +01:00

224 lines
9.9 KiB
Plaintext

<%
const flag = (cc) => {
if (!cc || cc.length !== 2) { return ''; }
return String.fromCodePoint(...[...cc.toUpperCase()].map(c => 0x1F1E6 + c.charCodeAt(0) - 65));
};
%>
<!DOCTYPE html>
<html lang="en">
<head>
<%- include('../partials/head'); -%>
<%- include('../partials/admin-stalker-css'); -%>
<title>Admin - IP Tracker</title>
</head>
<body>
<%- include('../winter'); -%>
<div class="stalker-page">
<div class="page-head">
<a class="btn btn-back" href="<%= endpoint %>/dashboard">Back to dashboard</a>
<h1>IP Tracker</h1>
</div>
<div class="stat-row">
<span class="stat"><strong><%= total %></strong> IPs matched</span>
<span class="stat"><strong><%= ips.length %></strong> on this page</span>
</div>
<form class="filter-form" method="get">
<div class="filter-grid">
<label>Global search (IP / UA / route)
<input type="text" name="q" value="<%= f.q ?? '' %>" placeholder="anything...">
</label>
<label>IP contains
<input type="text" name="ip" value="<%= f.ip ?? '' %>" placeholder="e.g. 185.220">
</label>
<label>User agent contains
<input type="text" name="ua" value="<%= f.ua ?? '' %>" placeholder="e.g. Chrome/1">
</label>
<label>OS
<select name="os">
<option value="">Any</option>
<option value="windows" <%= f.os === 'windows' ? 'selected' : '' %>>Windows</option>
<option value="macos" <%= f.os === 'macos' ? 'selected' : '' %>>macOS</option>
<option value="linux" <%= f.os === 'linux' ? 'selected' : '' %>>Linux</option>
<option value="android" <%= f.os === 'android' ? 'selected' : '' %>>Android</option>
<option value="ios" <%= f.os === 'ios' ? 'selected' : '' %>>iOS</option>
<option value="chromeos" <%= f.os === 'chromeos' ? 'selected' : '' %>>ChromeOS</option>
</select>
</label>
<label>Device
<select name="device">
<option value="">Any</option>
<option value="mobile" <%= f.device === 'mobile' ? 'selected' : '' %>>Mobile</option>
<option value="phone" <%= f.device === 'phone' ? 'selected' : '' %>>Phone</option>
<option value="tablet" <%= f.device === 'tablet' ? 'selected' : '' %>>Tablet</option>
<option value="desktop" <%= f.device === 'desktop' ? 'selected' : '' %>>Desktop</option>
</select>
</label>
<label>Route visited
<input type="text" name="url" value="<%= f.url ?? '' %>" placeholder="/gallery, /page...">
</label>
<label>Country
<input type="text" name="country" value="<%= f.country ?? '' %>" placeholder="e.g. Germany">
</label>
<label>Region
<input type="text" name="region" value="<%= f.region ?? '' %>">
</label>
<label>City
<input type="text" name="city" value="<%= f.city ?? '' %>">
</label>
<label>ISP
<input type="text" name="isp" value="<%= f.isp ?? '' %>">
</label>
<label>Org
<input type="text" name="org" value="<%= f.org ?? '' %>">
</label>
<label>ASN
<input type="text" name="asn" value="<%= f.asn ?? '' %>">
</label>
<label>Last seen from
<input type="date" name="start" value="<%= f.start ?? '' %>">
</label>
<label>Last seen to
<input type="date" name="end" value="<%= f.end ?? '' %>">
</label>
<label>Min visits
<input type="number" name="minVisits" value="<%= f.minVisits ?? '' %>" min="0">
</label>
<label>Max visits
<input type="number" name="maxVisits" value="<%= f.maxVisits ?? '' %>" min="0">
</label>
<label>Sort by
<select name="sort">
<option value="">Newest activity</option>
<option value="visits" <%= f.sort === 'visits' ? 'selected' : '' %>>Most visits</option>
<option value="oldest" <%= f.sort === 'oldest' ? 'selected' : '' %>>Oldest activity</option>
</select>
</label>
</div>
<details class="geo-fence">
<summary>Geofence — center + radius, or bounding box</summary>
<div class="filter-grid">
<label>Center lat
<input type="number" step="any" name="lat" value="<%= f.lat ?? '' %>" placeholder="46.05">
</label>
<label>Center lon
<input type="number" step="any" name="lon" value="<%= f.lon ?? '' %>" placeholder="14.51">
</label>
<label>Radius (km)
<input type="number" name="radiusKm" value="<%= f.radiusKm ?? '' %>" placeholder="e.g. 50">
</label>
<label>North
<input type="number" step="any" name="north" value="<%= f.north ?? '' %>">
</label>
<label>South
<input type="number" step="any" name="south" value="<%= f.south ?? '' %>">
</label>
<label>East
<input type="number" step="any" name="east" value="<%= f.east ?? '' %>">
</label>
<label>West
<input type="number" step="any" name="west" value="<%= f.west ?? '' %>">
</label>
</div>
</details>
<div class="filter-actions">
<button class="btn" type="submit">Search</button>
<a class="btn" href="<%= endpoint %>/stalker">Clear</a>
</div>
</form>
<div class="table-wrap">
<table>
<thead>
<tr>
<th>IP</th>
<th>Location</th>
<th>ISP</th>
<th>User Agents</th>
<th>Visits</th>
<th>Last Seen</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% ips.forEach(ip => { %>
<tr>
<td data-label="IP">
<a class="ip-link" href="<%= endpoint %>/stalker/<%= ip.id %>"><%= ip.ip %></a>
</td>
<td data-label="Location">
<% if (ip.info && (ip.info.city || ip.info.country)) { %>
<% if (ip.info.countryCode) { %>
<span class="flag"><%= flag(ip.info.countryCode) %></span>
<% } %>
<% if (ip.info.city || ip.info.regionName) { %>
<span class="loc-city"><%= [ip.info.city, ip.info.regionName].filter(Boolean).join(", ") %></span>
<% } %>
<% if (ip.info.countryCode) { %>
<span class="cc-badge"><%= ip.info.countryCode %></span>
<% } %>
<% if (ip.info.country) { %>
<span class="loc-country"><%= ip.info.country %></span>
<% } %>
<% } else { %>
<span class="none">None</span>
<% } %>
</td>
<td data-label="ISP">
<% if (ip.info && ip.info.isp) { %>
<span class="isp"><%= ip.info.isp %></span>
<% } else { %>
<span class="none">None</span>
<% } %>
</td>
<td data-label="User Agents" class="ua-cell">
<% if (ip.userAgents.length) { %>
<% ip.userAgents.slice(0, 2).forEach(ua => { const p = parseUA(ua); %>
<span class="ua-chip" title="<%= ua %>"><%= p.browser %><% if (p.browserVersion) { %> <%= p.browserVersion %><% } %> · <%= p.os %></span>
<% }) %>
<% if (ip.userAgents.length > 2) { %>
<span class="ua-more">+<%= ip.userAgents.length - 2 %> more</span>
<% } %>
<% } else { %>
<span class="none">None</span>
<% } %>
</td>
<td data-label="Visits" class="num"><%= ip.visits %></td>
<td data-label="Last Seen"><span class="ISO-date-raw"><%= ip.lastUsed.toISOString() %></span></td>
<td data-label="Actions" class="actions">
<a class="btn" href="<%= endpoint %>/stalker/<%= ip.id %>">Details</a>
<form method="post" action="<%= endpoint %>/stalker/<%= ip.id %>/delete">
<button class="btn danger" type="submit">Delete</button>
</form>
</td>
</tr>
<% }) %>
<% if (ips.length === 0) { %>
<tr>
<td colspan="7" class="empty">No IPs tracked yet.</td>
</tr>
<% } %>
</tbody>
</table>
</div>
<div class="pagination">
<% for (let i = 1; i <= pages; i++) { %>
<% if (i === page) { %>
<span class="pg current"><%= i %></span>
<% } else { %>
<a class="pg" href="?page=<%= i %><%= qs ? '&' + qs : '' %>"><%= i %></a>
<% } %>
<% } %>
</div>
</div>
<%- include('../footer'); -%>
<%- include('../partials/date-parser'); -%>
</body>
</html>