38 lines
693 B
Lua
38 lines
693 B
Lua
#!/usr/bin/env lua
|
|
|
|
require 'helper'
|
|
require 'token'
|
|
require 'config'
|
|
|
|
function fail(msg)
|
|
print "Status: 423 Locked"
|
|
print ""
|
|
print("Error: " .. msg)
|
|
end
|
|
|
|
print "Content-Type: text/plain"
|
|
|
|
token = os.getenv("QUERY_STRING")
|
|
|
|
if token == nil or token == "" then
|
|
fail("No token given")
|
|
else
|
|
if token:sub(1, 2) == "t=" then
|
|
token = token:sub(3)
|
|
end
|
|
|
|
if token:len() == config.key_len then
|
|
print ""
|
|
b = check_token(token)
|
|
token = set_prefix(token,generate_token())
|
|
if b ~= false then
|
|
add_token(token)
|
|
qspawn("lua door.lua")
|
|
end
|
|
print(token)
|
|
else
|
|
fail("Invalid token")
|
|
end
|
|
|
|
end
|