<% local msg = {} if _SESSION["logined"] ~= nil then local host = _POST["host"] local port = _POST["port"] local pass = _POST["pass"] local description = _POST["description"] local enable = _POST["enable"] local failover = _POST["failover"] local singleip = _POST["singleip"] local modify = _POST["modify"] local test = _POST["test"] if test ~= nil then local result = c_CheckGateway(host,port,pass) if result == true then rawset(msg, "code", 0) else rawset(msg, "code", -2) rawset(msg, "error", "Gateway test failed.") end elseif modify == nil then local result = c_GetGateway(host) if result ~= nil then rawset(msg, "code", -2) rawset(msg, "error", "Gateway already exists.") else local retval = c_AddGateway(host,port,pass,description,enable,failover,singleip) if retval == false then rawset(msg, "code", -3) rawset(msg, "error", "Gateway add failed.") c_AddAdminLog("administrator '".._SESSION["admin"].."' added gateway ["..host.."] failed.",ADMIN_LOG_ERROR) else rawset(msg, "code", 0) c_AddAdminLog("administrator '".._SESSION["admin"].."' added gateway ["..host.."]",ADMIN_LOG_OK) end end else local retval = c_AddGateway(host,port,pass,description,enable,failover,singleip) if retval == false then rawset(msg, "code", -3) rawset(msg, "error", "Gateway modify failed.") c_AddAdminLog("administrator '".._SESSION["admin"].."' modified gateway ["..host.."] failed.",ADMIN_LOG_ERROR) else rawset(msg, "code", 0) c_AddAdminLog("administrator '".._SESSION["admin"].."' modified gateway ["..host.."]",ADMIN_LOG_OK) end end print(json.encode(msg)) else rawset(msg, "code", -1) rawset(msg, "error", "not logged in") print(json.encode(msg)) end %>