Advertisement
kaeza

Untitled

Jun 17th, 2014
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. xban = { }
  2. dofile("../serialize.lua")
  3.  
  4. -- Additional names to remove from database.
  5. local to_remove = {
  6.     "asdf", "qwerty", "Guest.*", "Admin.*",
  7. }
  8.  
  9. local db = loadfile("xban.db")()
  10.  
  11. local logfile = assert(io.open("log.txt", "a"))
  12.  
  13. local function print(x) logfile:write(x.."\n") end
  14.  
  15. print("\n\
  16. \n\
  17. === LOG STARTED: "..os.date().. " ===\n")
  18.  
  19. local entry = { }
  20.  
  21. for i, e in ipairs(db) do
  22.     for _, name in pairs(e.names) do
  23.         if name:match("%d+%.%d+%.%d+%.%d+") then
  24.             e.names[name] = nil
  25.             print(("Removed IP `%s'"):format(name))
  26.         elseif entry[name] then
  27.             e.names[name] = nil
  28.             entry[name].names[name] = nil
  29.             print(("Removed name `%s' due to duplicate entry"):format(name))
  30.         end
  31.         for k in pairs(to_remove) do
  32.             if name:match(k) then
  33.                 e.names[name] = nil
  34.             end
  35.         end
  36.         entry[name] = e
  37.     end
  38.     if #e.names == 0 then
  39.         table.remove(db, i)
  40.     end
  41. end
  42.  
  43. local f = assert(io.open("xban.db.new", "w"))
  44. f:write(xban.serialize(db))
  45. f:close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement