From b20e94d48dcadbcaf3ec9f66ef07cc228e0d5ef7 Mon Sep 17 00:00:00 2001 From: faketruth Date: Tue, 21 Aug 2012 14:24:23 +0000 Subject: Can add/remove worlds from WebAdmin git-svn-id: http://mc-server.googlecode.com/svn/trunk@770 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- MCServer/Plugins/Core/web_serversettings.lua | 79 +++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 2 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/Core/web_serversettings.lua b/MCServer/Plugins/Core/web_serversettings.lua index 3056d7e8b..63b5aab47 100644 --- a/MCServer/Plugins/Core/web_serversettings.lua +++ b/MCServer/Plugins/Core/web_serversettings.lua @@ -116,7 +116,7 @@ local function ShowMonstersSettings( Request ) Animal Spawn Interval: Monster Types: - +
WARNING: Any changes made here might require a server restart in order to be applied! ]] @@ -125,7 +125,82 @@ local function ShowMonstersSettings( Request ) end local function ShowWorldsSettings( Request ) - return "

Worlds Settings

" + local Content = "" + local InfoMsg = nil + local bSaveIni = false + + local SettingsIni = cIniFile("settings.ini") + if( SettingsIni:ReadFile() == false ) then + InfoMsg = [[ERROR: Could not read settings.ini!]] + end + + if( Request.PostParams["RemoveWorld"] ~= nil ) then + Content = Content .. Request.PostParams["RemoveWorld"] + local WorldIdx = string.sub( Request.PostParams["RemoveWorld"], string.len("Remove ") ) + local KeyIdx = SettingsIni:FindKey("Worlds") + local WorldName = SettingsIni:GetValue( KeyIdx, WorldIdx ) + if( SettingsIni:DeleteValueByID( KeyIdx, WorldIdx ) == true ) then + InfoMsg = "INFO: Successfully removed world " .. WorldName .. "!
" + bSaveIni = true + end + end + + if( Request.PostParams["AddWorld"] ~= nil ) then + if( Request.PostParams["WorldName"] ~= nil and Request.PostParams["WorldName"] ~= "" ) then + SettingsIni:SetValue("Worlds", "World", Request.PostParams["WorldName"], true ) + InfoMsg = "INFO: Successfully added world " .. Request.PostParams["WorldName"] .. "!
" + bSaveIni = true + end + end + + if( Request.PostParams["worlds_submit"] ~= nil ) then + SettingsIni:SetValue("Worlds", "DefaultWorld", Request.PostParams["Worlds_DefaultWorld"], false ) + if( Request.PostParams["Worlds_World"] ~= nil ) then + SettingsIni:SetValue("Worlds", "World", Request.PostParams["Worlds_World"], true ) + end + bSaveIni = true + end + + if( bSaveIni == true ) then + if( InfoMsg == nil ) then InfoMsg = "" end + if( SettingsIni:WriteFile() == false ) then + InfoMsg = InfoMsg .. "ERROR: Could not write to settings.ini!" + else + InfoMsg = InfoMsg .. "INFO: Successfully saved changes to settings.ini" + end + end + + Content = Content .. "

Worlds Settings

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

" .. InfoMsg .. "

" + end + + Content = Content .. [[ +
+ + + + ]] + + local KeyIdx = SettingsIni:FindKey("Worlds") + local NumValues = SettingsIni:GetNumValues( KeyIdx ) + for i = 0, NumValues-1 do + local ValueName = SettingsIni:GetValueName(KeyIdx, i ) + if( ValueName == "World" ) then + local WorldName = SettingsIni:GetValue(KeyIdx, i) + Content = Content .. [[ + ]] + end + end + + Content = Content .. [[ + + +
Worlds
Default World:
]] .. ValueName .. [[:
]] .. WorldName .. [[
Add World:

+ + WARNING: Any changes made here might require a server restart in order to be applied! +
]] + return Content end function HandleRequest_ServerSettings( Request ) -- cgit v1.2.3