<% local msg = {} if _SESSION["logined"] ~= nil then local taskname = _POST["taskname"] local tasktype = _POST["type"] local daynum = _POST["day"] local datefrom = _POST["datefrom"] local timefrom = _POST["timefrom"] local script = _POST["script"] local modify = _POST["modify"] local reset = false if (_SESSION["admin_readonly"] ~= nil and _SESSION["admin_readonly"] == 1) or (_SESSION["admin_domainadmin"] ~= nil and _SESSION["admin_domainadmin"] == 1) then rawset(msg, "code", -2) rawset(msg, "error", "admin read only") print(json.encode(msg)) end if taskname ~= nil then if modify == nil then local result = c_TaskExist(taskname) if result == true then rawset(msg, "code", -3) rawset(msg, "error", "task already exists") print(json.encode(msg)) else local status,err = loadstring(script) if not status then if type(err) == "string" then rawset(msg, "code", -4) rawset(msg, "error", string.format('Lua Error: %s',err)) print(json.encode(msg)) end else c_AddTask(taskname,tasktype,daynum,datefrom,timefrom,script,reset) c_AddAdminLog("administrator '".._SESSION["admin"].."' added a task '"..taskname.."'.",ADMIN_LOG_OK) rawset(msg, "code", 0) print(json.encode(msg)) end end else local status,err = loadstring(script) if not status then if type(err) == "string" then rawset(msg, "code", -4) rawset(msg, "error", string.format("Lua Error: %s",err)) print(json.encode(msg)) end else c_AddTask(taskname,tasktype,daynum,datefrom,timefrom,script,reset) c_AddAdminLog("administrator '".._SESSION["admin"].."' modified the task '"..taskname.."'.",ADMIN_LOG_OK) rawset(msg, "code", 0) print(json.encode(msg)) end end end else rawset(msg, "code", -1) rawset(msg, "error", "not logged in") print(json.encode(msg)) end %>