Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xban = { }
- dofile("../serialize.lua")
- -- Additional names to remove from database.
- local to_remove = {
- "asdf", "qwerty", "Guest.*", "Admin.*",
- }
- local db = loadfile("xban.db")()
- local logfile = assert(io.open("log.txt", "a"))
- local function print(x) logfile:write(x.."\n") end
- print("\n\
- \n\
- === LOG STARTED: "..os.date().. " ===\n")
- local entry = { }
- for i, e in ipairs(db) do
- for _, name in pairs(e.names) do
- if name:match("%d+%.%d+%.%d+%.%d+") then
- e.names[name] = nil
- print(("Removed IP `%s'"):format(name))
- elseif entry[name] then
- e.names[name] = nil
- entry[name].names[name] = nil
- print(("Removed name `%s' due to duplicate entry"):format(name))
- end
- for k in pairs(to_remove) do
- if name:match(k) then
- e.names[name] = nil
- end
- end
- entry[name] = e
- end
- if #e.names == 0 then
- table.remove(db, i)
- end
- end
- local f = assert(io.open("xban.db.new", "w"))
- f:write(xban.serialize(db))
- f:close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement