Timestamp!

This commit is contained in:
SmallJoker 2014-08-16 09:53:41 +02:00
parent c21a7c647a
commit 93dfff65ee
2 changed files with 10 additions and 10 deletions

View File

@ -12,10 +12,10 @@ function ipnames.command_whois(name, param)
return return
end end
local ip = ipnames.data[param] local ip = ipnames.data[param][1]
local names = "" local names = ""
for k, v in pairs(ipnames.data) do for k, v in pairs(ipnames.data) do
if v == ip then if v[1] == ip then
names = names.." "..k names = names.." "..k
end end
end end
@ -61,13 +61,14 @@ function ipnames.load_data()
end end
if #data >= 3 and not ignore then if #data >= 3 and not ignore then
-- Remove IP after 2 weeks -- Remove IP after 2 weeks
local cd = tonumber(data[3]) data[3] = tonumber(data[3])
if t - cd > (3600 * 24 * 14) then if t - data[3] > (3600 * 24 * 14) then
ignore = true ignore = true
end end
end end
if not ignore then if not ignore then
ipnames.data[data[1]] = data[2] data[3] = data[3] or 0
ipnames.data[data[1]] = {data[2], data[3]}
end end
end end
end end
@ -82,9 +83,7 @@ function ipnames.save_data()
ipnames.changes = false ipnames.changes = false
local file = io.open(ipnames.file, "w") local file = io.open(ipnames.file, "w")
for k, v in pairs(ipnames.data) do for k, v in pairs(ipnames.data) do
if v ~= nil then file:write(k.."|"..v[1].."|"..v[2].."\n")
file:write(k.."|"..v.."\n")
end
end end
io.close(file) io.close(file)
end end

View File

@ -63,7 +63,7 @@ minetest.register_on_prejoinplayer(function(name, ip)
local count = 1 local count = 1
local names = "" local names = ""
for k, v in pairs(ipnames.data) do for k, v in pairs(ipnames.data) do
if v == ip then if v[1] == ip then
if ipnames.whitelist[k] then if ipnames.whitelist[k] then
count = 0 count = 0
break break
@ -82,7 +82,8 @@ end)
-- Save IP if player joined -- Save IP if player joined
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
local name = player:get_player_name() local name = player:get_player_name()
ipnames.data[name] = ipnames.tmp_data[name] local t = os.time()
ipnames.data[name] = {ipnames.tmp_data[name], t}
ipnames.tmp_data[name] = nil ipnames.tmp_data[name] = nil
ipnames.changes = true ipnames.changes = true
end) end)