From af8c9154614a2885a7df5fcaf3e9d080d6a455d6 Mon Sep 17 00:00:00 2001 From: faketruth Date: Mon, 20 Aug 2012 16:36:40 +0000 Subject: Can now edit some generic server settings through the WebAdmin (port, description, etc) git-svn-id: http://mc-server.googlecode.com/svn/trunk@766 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- MCServer/Plugins/Core/main.lua | 1 + MCServer/Plugins/Core/web_serversettings.lua | 110 +++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 MCServer/Plugins/Core/web_serversettings.lua (limited to 'MCServer') diff --git a/MCServer/Plugins/Core/main.lua b/MCServer/Plugins/Core/main.lua index 220dd940e..803600431 100644 --- a/MCServer/Plugins/Core/main.lua +++ b/MCServer/Plugins/Core/main.lua @@ -136,6 +136,7 @@ function Initialize( Plugin ) local WebPlugin = Plugin:CreateWebPlugin() WebPlugin:SetName( Plugin:GetName() ) + WebPlugin:AddTab( "Server Settings", HandleRequest_ServerSettings ) WebPlugin:AddTab( "Playerlist", HandleRequest_PlayerList ) WebPlugin:AddTab( "Whitelist", HandleRequest_WhiteList ) WebPlugin:AddTab( "Permissions", HandleRequest_Permissions ) diff --git a/MCServer/Plugins/Core/web_serversettings.lua b/MCServer/Plugins/Core/web_serversettings.lua new file mode 100644 index 000000000..4e4901f4c --- /dev/null +++ b/MCServer/Plugins/Core/web_serversettings.lua @@ -0,0 +1,110 @@ +local CurrentlyEditingIni = nil + +-- Some HTML helper functions +local function HTML_Option( value, text, selected ) + if( selected == true ) then + return "" + else + return "" + end +end + +local function HTML_Select_On_Off( name, defaultValue ) + local Content = "" + Content = Content .. "" + return Content +end + + +local function ShowGeneralSettings( Request ) + local Content = "" + local InfoMsg = nil + + local SettingsIni = cIniFile("settings.ini") + if( SettingsIni:ReadFile() == false ) then + InfoMsg = "ERROR: Could not read settings.ini!" + end + + if( Request.PostParams["general_submit"] ~= nil ) then + + SettingsIni:SetValue("Server", "Description",Request.PostParams["Server_Description"],false ) + if( tonumber( Request.PostParams["Server_MaxPlayers"] ) ~= nil ) then + SettingsIni:SetValue("Server", "MaxPlayers", Request.PostParams["Server_MaxPlayers"], false ) + end + if( tonumber( Request.PostParams["Server_Port"] ) ~= nil ) then + SettingsIni:SetValue("Server", "Port", Request.PostParams["Server_Port"], false ) + end + if( tonumber( Request.PostParams["Authentication_Authenticate"] ) ~= nil ) then + SettingsIni:SetValue("Authentication", "Authenticate", Request.PostParams["Authentication_Authenticate"], false ) + end + if( SettingsIni:WriteFile() == false ) then + InfoMsg = "ERROR: Could not write to settings.ini!" + else + InfoMsg = "INFO: Successfully saved changes to settings.ini" + end + end + + + Content = Content .. "
" + + Content = Content .. "

General Settings

" + if( InfoMsg ~= nil ) then + Content = Content .. "

" .. InfoMsg .. "

" + end + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "
Server
Description:
Max Players:
Port:

" + + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "
Authentication
Authenticate:" .. HTML_Select_On_Off("Authentication_Authenticate", SettingsIni:GetValueI("Authentication", "Authenticate") ) .. "
" + + Content = Content .. " WARNING: Any changes made here might require a server restart to be applied!" + Content = Content .. "
" + + return Content +end + + +local function ShowMonstersSettings( Request ) + return "

Monsters Settings

" +end + +local function ShowWorldsSettings( Request ) + return "

Worlds Settings

" +end + +function HandleRequest_ServerSettings( Request ) + local Content = "" + + Content = Content .. "

Server Settings

" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "
GeneralMonstersWorlds
" + Content = Content .. "
" + + if( Request.Params["tab"] == "Monsters" ) then + Content = Content .. ShowMonstersSettings( Request ) + elseif( Request.Params["tab"] == "Worlds" ) then + Content = Content .. ShowWorldsSettings( Request ) + else + Content = Content .. ShowGeneralSettings( Request ) -- Default to general settings + end + + return Content +end \ No newline at end of file -- cgit v1.2.3