summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins/Core/web_manageserver.lua
blob: a2936c1a8114d1174ff9f708ab2d07389928fc71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function HandleRequest_ManageServer( Request )
	local Content = "" 
	if (Request.PostParams["RestartServer"] ~= nil) then
		cRoot:Get():QueueExecuteConsoleCommand("restart");
	elseif (Request.PostParams["ReloadServer"] ~= nil) then
		cRoot:Get():GetPluginManager():ReloadPlugins();
	elseif (Request.PostParams["StopServer"] ~= nil) then
		cRoot:Get():QueueExecuteConsoleCommand("stop");
	elseif (Request.PostParams["WorldSaveAllChunks"] ~= nil) then
		cRoot:Get():GetWorld(Request.PostParams["WorldSaveAllChunks"]):SaveAllChunks();
	end
	Content = Content .. [[
	<form method="POST">
	<table>
	<th colspan="2">Manage Server</th>
	<tr><td><input type="submit" value="Restart Server" name="RestartServer">  restart the server</td></tr> <br />
	<tr><td><input type="submit" value="Reload Server" name="ReloadServer"> reload the server</td></tr> <br />
	<tr><td><input type="submit" value="Stop Server" name="StopServer"> stop the server</td></tr> <br />
	</th>
	</table>
	<table>
	<th colspan="2">Manage Worlds</th>
	]]
	local LoopWorlds = function( World )
		Content = Content .. [[
		<tr><td><input type="submit" value="]] .. World:GetName() .. [[" name="WorldSaveAllChunks"> Save all the chunks of world ]] .. World:GetName() .. [[</td></tr> <br />
		
		]]
	end
	cRoot:Get():ForEachWorld( LoopWorlds )
	Content = Content .. "</th></table>"
	
	return Content
end