--[[ TODO: - Link to Steam Community profiles - List expired bans (we could use Javascript pulldowns! :D) ]] local CONNECTFILE = [[connects.txt]] -- local BANFILE = [[C:\srp\garrysmod\cfg\banned_user.cfg]] local OUTFILE = [[dupes.html]] -- helpers local function count(t) local i = 0 for k, v in pairs(t) do i = i + 1 end return i end -- lookups local ids = {} local ips = {} -- local bans = {} -- read connect file for line in io.lines(CONNECTFILE) do -- format 1 local steamid, ip, m, d, y = string.match(line, "^%d%d:%d%d:%d%d\t[^%[]*%[(STEAM_%d:%d:%d+)%]%[([%d%.]+)%:%d+].-at (%d%d)/(%d%d)/(%d%d)") -- format 2 if not steamid then m, d, y, steamid, ip = string.match(line, "^(%d%d)/(%d%d)/(%d%d)[^%[]*%[(STEAM_%d:%d:%d+)%]%[([%d%.]+)%:%d+]") if not steamid then y, m, d, steamid, ip = string.match(line, "^(%d%d)-(%d%d)-(%d%d) %d%d:%d%d:%d%d [^%[]*%[(STEAM_%d:%d:%d+)%]%[([%d%.]+)%:%d+]") end end if steamid then -- print(steamid, ip, m, d, y) if not ids[steamid] then ids[steamid] = {} end ids[steamid][ip] = string.format("20%s-%s-%s", y, m, d) if not ips[ip] then ips[ip] = {} end ips[ip][steamid] = string.format("20%s-%s-%s", y, m, d) end end -- read bans file -- for line in io.lines(BANFILE) do -- local steamid = assert(string.match(line, "STEAM_%d:%d:%d+")) -- bans[steamid] = true -- end -- output file local f = assert(io.open(OUTFILE, "w")) local function write(str) f:write((str or "") .. "\n") end -- welp. local luasql = require("luasql.mysql") local env = luasql.mysql() local ban_con = env:connect("tacoscript2", "root") -- local srp_con = env:connect("stalker", "root") local succ, err = pcall(function() -- header write([[ Alt list

STALKER potential alt list

Generated: ]] .. os.date("%A, %b %d %Y - ") .. --[[ THE SHIT I DO TO MAKE IT LOOK PRETTY ]] os.date("%I:%M%p"):lower() .. [[

DISCLAIMER: This does not necessarily indicate alts. Some IP addresses may be re-used (extremely rare), or someone's "little brother".

]], ip)) for i, id in ipairs(sorted) do -- inline sql is no excuse for poor formatting! local cur = ban_con:execute([[ SELECT adminSteam, FROM_UNIXTIME(banStart) AS banStart, FROM_UNIXTIME(banStart + banLength) AS banEnd, banLength, banReason FROM ts2_bans WHERE banLifted = 0 AND (banLength = 0 OR banStart + banLength > UNIX_TIMESTAMP()) AND (serverGroup = 3 OR serverGroup IS NULL) AND userSteam = ']] .. id .. [[' ]]) local res = {} if cur:fetch(res, "a") then -- bant -- but is it a primaban? if tonumber(res.banLength) == 0 then write(string.format([[]], id, t[id], res.adminSteam, res.banStart, res.banReason)) else write(string.format([[]], id, t[id], res.adminSteam, res.banStart, res.banEnd, res.banReason)) end else write(string.format([[]], id, t[id])) end end end end write([[
SteamIDLast seenStatus ]]) local sorted_ips = {} for ip in pairs(ips) do sorted_ips[#sorted_ips + 1] = ip end table.sort(sorted_ips) -- write out any duplicates for i, ip in ipairs(sorted_ips) do local t = ips[ip] if count(t) > 1 then -- sort by date, oldest to newest local sorted = {} for steamid, date in pairs(t) do sorted[#sorted + 1] = steamid end local function sort(a, b) return t[a] < t[b] end table.sort(sorted, sort) write(string.format([[
%s
%s %s PERMABANNED
Admin: %s
Date: %s
Reason: %s
%s %s BANNED
Admin: %s
Date: %s, until %s
Reason: %s
%s %s OK
]]) end) if not succ then print(err) end f:close() ban_con:close() -- srp_con:close() env:close()