-- Use a table for fast concatenation of strings local SiteContent = {} function Output(String) table.insert(SiteContent, String) end function GetTableSize(Table) local Size = 0 for key,value in pairs(Table) do Size = Size + 1 end return Size end function GetDefaultPage() local PM = cRoot:Get():GetPluginManager() local SubTitle = "Current Game" local Content = "" Content = Content .. "

Server Name:

" Content = Content .. "

" .. cRoot:Get():GetServer():GetServerID() .. "

" Content = Content .. "

Plugins:

" Content = Content .. "

Players:


"; return Content, SubTitle end function ShowPage(WebAdmin, TemplateRequest) SiteContent = {} local BaseURL = WebAdmin:GetBaseURL(TemplateRequest.Request.Path) local Title = "MCServer WebAdmin" local MemoryUsageKiB = cRoot:GetPhysicalRAMUsage() local NumChunks = cRoot:Get():GetTotalChunkCount() local PluginPage = WebAdmin:GetPage(TemplateRequest.Request) local PageContent = PluginPage.Content local SubTitle = PluginPage.PluginName if (PluginPage.TabName ~= "") then SubTitle = PluginPage.PluginName .. " - " .. PluginPage.TabName end if (PageContent == "") then PageContent, SubTitle = GetDefaultPage() end local reqParamsClass = "" for key,value in pairs(TemplateRequest.Request.Params) do reqParamsClass = reqParamsClass .. " param-" .. string.lower(string.gsub(key, "[^a-zA-Z0-9]+", "-") .. "-" .. string.gsub(value, "[^a-zA-Z0-9]+", "-")) end if (string.gsub(reqParamsClass, "%s", "") == "") then reqParamsClass = " no-param" end Output([[ ]] .. Title .. [[
Menu
Home
Server Management
]]) local AllPlugins = WebAdmin:GetPlugins() for key,value in pairs(AllPlugins) do local PluginWebTitle = value:GetWebTitle() local TabNames = value:GetTabNames() if (GetTableSize(TabNames) > 0) then Output("\n"); for webname,prettyname in pairs(TabNames) do Output("\n") end Output("
\n"); end end Output([[
]] .. SubTitle .. [[
]] .. PageContent .. [[
]]) return table.concat(SiteContent) end