local globle = require "cgilua.globle" require "cgilua.serialize" local msg = "" if(cgi.action=="save") then local data = {} local storage = ap.storage() local file = assert(io.open(ap.env("DOCUMENT_ROOT").."/docroot/sv/data/system.db","w+")) file:write "return " for k in pairs(storage) do data[k]=globle.get(k) end cgilua.serialize(data, function(s) file:write(s) end) file:close() elseif(cgi.action=="load") then local f = loadfile(ap.env("DOCUMENT_ROOT").."/docroot/sv/data/system.db") or "return {}" local data = f() for k in pairs(data) do globle.set(k,data[k]) end end return cgilua.redirect("/index.html")