ap.rputs [[
用户管理
]]
local globle = require "cgilua.globle"
local users = {}
local msg = ""
if (cgi.authname) then
users = globle.get(cgi.authname.."_users") or {}
if (cgi["action"]=="添加" and users ) then
users[cgi.username] = cgi.password
msg = "用户"..cgi.username.."添加成功"
globle.set(cgi.authname.."_users",users)
end
if(cgi["action"]=="删除" and users ) then
msg = "用户"..cgi.username.."删除成功"
users[cgi.username] = nil
globle.set(cgi.authname.."_users",users)
end
if(cgi["action"]=="查询" and users ) then
if (users[cgi.username] == nil) then
msg = "用户"..cgi.username.."不存在"
else
msg = "用户"..cgi.username.." 口令"..users[cgi.username]
end
end
end
ap.rputs [[
]]
if(msg) then
ap.print ""
ap.print (msg);
ap.print "
"
end
ap.rputs [[
]]
if (not cgi.authname) then
ap.rputs [[
]]
end
ap.rputs [[
]]
if (cgi["action"]=="列表") then
ap.print "
"
for k in pairs(users) do
ap.rputs [[
]]
ap.rputs(k)
ap.rputs [[=]]
ap.rputs(tostring(users[k]))
ap.rputs [[
]]
end
end
ap.rputs [[
]]