<% local msg = {} if _SESSION["logined"] ~= nil then local domain = _POST["domain"] local event_type = _POST["type"] or "ftp" local event = _POST["event"] local bExecute = false if _POST["bExecute"] == "1" then bExecute = true end local strExeFile = _POST["strExeFile"] local strParam = _POST["strParam"] local bLogfile = false if _POST["bLogfile"] == "1" then bLogfile = true end local strLogFileName = _POST["strLogFileName"] local strLogText = _POST["strLogText"] local bSendMail = false if _POST["bSendMail"] == "1" then bSendMail = true end local strMailTo = _POST["strMailTo"] local strSubject = _POST["strSubject"] local strPlainText = _POST["strPlainText"] local strAttachFile = _POST["strAttachFile"] local nPriority = _POST["nPriority"] or 2 local bLua = false if _POST["bLua"] == "1" then bLua = true end local strLua = _POST["strLua"] 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 is readonly or domain admin") print(json.encode(msg)) exit() end if event_type ~= nil then event_type = string.lower(event_type) if event_type == "http" then local status,err = loadstring(strLua) if not status then if type(err) == "string" then rawset(msg, "code", -3) rawset(msg, "error", string.format("Lua Error: %s!", err)) end else c_SetHTTPEvent(domain,event,bExecute,strExeFile,strParam,bLogfile,strLogFileName,strLogText,bSendMail,strMailTo,strSubject,strPlainText,strAttachFile,nPriority,bLua,strLua) c_AddAdminLog("administrator '".._SESSION["admin"].."' modified the http event ["..event.."].",ADMIN_LOG_OK) rawset(msg, "code", 0) end elseif event_type == "ssh" then local status,err = loadstring(strLua) if not status then if type(err) == "string" then rawset(msg, "code", -3) rawset(msg, "error", string.format("Lua Error: %s!", err)) end else c_SetSSHEvent(domain,event,bExecute,strExeFile,strParam,bLogfile,strLogFileName,strLogText,bSendMail,strMailTo,strSubject,strPlainText,strAttachFile,nPriority,bLua,strLua) c_AddAdminLog("administrator '".._SESSION["admin"].."' modified the ssh event ["..event.."].",ADMIN_LOG_OK) rawset(msg, "code", 0) end else local status,err = loadstring(strLua) if not status then if type(err) == "string" then rawset(msg, "code", -3) rawset(msg, "error", string.format("Lua Error: %s!", err)) end else c_SetFTPEvent(domain,event,bExecute,strExeFile,strParam,bLogfile,strLogFileName,strLogText,bSendMail,strMailTo,strSubject,strPlainText,strAttachFile,nPriority,bLua,strLua) c_AddAdminLog("administrator '".._SESSION["admin"].."' modified the ftp event ["..event.."].",ADMIN_LOG_OK) rawset(msg, "code", 0) end end end if(rawget(msg, "code") == nil) then rawset(msg, "code", -4) rawset(msg, "error", "Unknown error") end print(json.encode(msg)) else rawset(msg, "code", -1) rawset(msg, "error", "not logged in") print(json.encode(msg)) end %>