2013-07-28 20:37:59 -04:00
|
|
|
-- Use a table for fast concatenation of strings
|
|
|
|
local SiteContent = {}
|
|
|
|
function Output(String)
|
|
|
|
table.insert(SiteContent, String)
|
|
|
|
end
|
|
|
|
|
2013-08-06 13:28:09 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-28 20:37:59 -04:00
|
|
|
function GetTableSize(Table)
|
|
|
|
local Size = 0
|
|
|
|
for key,value in pairs(Table) do
|
|
|
|
Size = Size + 1
|
|
|
|
end
|
|
|
|
return Size
|
|
|
|
end
|
|
|
|
|
2013-08-06 13:28:09 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-28 20:37:59 -04:00
|
|
|
function GetDefaultPage()
|
|
|
|
local PM = cRoot:Get():GetPluginManager()
|
|
|
|
|
2014-10-23 13:59:49 -04:00
|
|
|
local SubTitle = "Home"
|
2013-07-28 20:37:59 -04:00
|
|
|
local Content = ""
|
|
|
|
|
2014-10-23 13:59:49 -04:00
|
|
|
Content = Content .. "<h4>Home Home Home</h4><ul>I have no idea what this content should do.</ul>"
|
2013-07-28 20:37:59 -04:00
|
|
|
|
|
|
|
return Content, SubTitle
|
|
|
|
end
|
|
|
|
|
2013-08-06 13:28:09 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-28 20:37:59 -04:00
|
|
|
function ShowPage(WebAdmin, TemplateRequest)
|
|
|
|
SiteContent = {}
|
|
|
|
local BaseURL = WebAdmin:GetBaseURL(TemplateRequest.Request.Path)
|
2014-08-31 08:39:58 -04:00
|
|
|
local Title = "MCServer WebAdmin"
|
2013-10-08 14:24:35 -04:00
|
|
|
local MemoryUsageKiB = cRoot:GetPhysicalRAMUsage()
|
2013-07-28 20:37:59 -04:00
|
|
|
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
|
|
|
|
|
2014-10-05 05:08:10 -04:00
|
|
|
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
|
|
|
|
|
2013-07-28 20:37:59 -04:00
|
|
|
Output([[
|
2014-10-27 14:31:51 -04:00
|
|
|
/* Copyright Justin S and MCServer Team, licensed under CC-BY-SA 3.0 */
|
2013-07-28 20:37:59 -04:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<head>
|
2014-10-27 13:45:41 -04:00
|
|
|
<title>]] .. Title .. [[</title>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,300" rel="stylesheet" type="text/css">
|
|
|
|
<link rel="stylesheet" type="text/css" href="/style.css">
|
|
|
|
<link rel="icon" href="/favicon.ico">
|
2013-07-28 20:37:59 -04:00
|
|
|
</head>
|
|
|
|
<body>
|
2014-10-27 13:45:41 -04:00
|
|
|
<div class="contention">
|
|
|
|
<div class="pagehead">
|
|
|
|
<div class="row1">
|
|
|
|
<div class="wrapper">
|
|
|
|
<img src="/logo_login.png" alt="MCServer Logo" class="logo">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="panel">
|
|
|
|
<div class="upper">
|
|
|
|
<div class="wrapper">
|
|
|
|
<ul class="menu top_links">
|
2014-10-27 14:13:25 -04:00
|
|
|
<li><a>Server Name: <strong>]] .. cRoot:Get():GetServer():GetServerID() .. [[</strong></a></li>
|
|
|
|
<li><a>Memory: <strong>]] .. MemoryUsageKiB / 1024 .. [[MB</strong></a></li>
|
|
|
|
<li><a>Chunks: <strong>]] .. NumChunks .. [[</strong></a></li>
|
2014-10-27 13:45:41 -04:00
|
|
|
</ul>
|
2014-10-27 14:13:25 -04:00
|
|
|
<div class="welcome"><strong>Welcome back, ]] .. TemplateRequest.Request.Username .. [[</strong> <a href=".././"><img src="/log_out.png" style="vertical-align:bottom;"> Log Out</a></div>
|
2014-10-27 13:45:41 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row2 push10">
|
|
|
|
<div class="wrapper padtopp">
|
|
|
|
<table width="100%" border="0" align="center"><tbody>
|
|
|
|
<tr>
|
|
|
|
<td width="180" valign="top">
|
|
|
|
<table border="0" cellspacing="0" cellpadding="5" class="tborder">
|
|
|
|
<tbody><tr>
|
|
|
|
<td class="thead"><strong>Menu</strong></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="trow1 smalltext"><a href=']] .. BaseURL .. [[' class='usercp_nav_item usercp_nav_home'>Home</a></td>
|
|
|
|
</tr>
|
2014-10-27 14:13:25 -04:00
|
|
|
<tr><td class="tcat"><div><span class="smalltext"><strong><font color="#000">Server Management</font></strong></span></div></td></tr></tbody><tbody style="" id="usercppms_e"><tr><td class="trow1 smalltext">
|
2013-07-28 20:37:59 -04:00
|
|
|
]])
|
2013-08-06 13:28:09 -04:00
|
|
|
|
2014-08-31 08:51:07 -04:00
|
|
|
|
2013-07-28 20:37:59 -04:00
|
|
|
local AllPlugins = WebAdmin:GetPlugins()
|
|
|
|
for key,value in pairs(AllPlugins) do
|
|
|
|
local PluginWebTitle = value:GetWebTitle()
|
|
|
|
local TabNames = value:GetTabNames()
|
|
|
|
if (GetTableSize(TabNames) > 0) then
|
2014-10-23 13:59:49 -04:00
|
|
|
Output("<div><a class='usercp_nav_item usercp_nav_pmfolder' style='text-decoration:none;'><b>"..PluginWebTitle.."</b></a></div>\n");
|
2013-07-28 20:37:59 -04:00
|
|
|
|
|
|
|
for webname,prettyname in pairs(TabNames) do
|
2014-10-23 13:59:49 -04:00
|
|
|
Output("<div><a href='" .. BaseURL .. PluginWebTitle .. "/" .. webname .. "' class='usercp_nav_item usercp_nav_sub_pmfolder'>" .. prettyname .. "</a></div>\n")
|
2013-07-28 20:37:59 -04:00
|
|
|
end
|
2014-10-23 13:59:49 -04:00
|
|
|
|
|
|
|
Output("<br>\n");
|
2013-07-28 20:37:59 -04:00
|
|
|
end
|
|
|
|
end
|
2013-08-06 13:28:09 -04:00
|
|
|
|
2013-07-28 20:37:59 -04:00
|
|
|
|
2014-10-23 13:59:49 -04:00
|
|
|
Output([[</td></tr></tbody>
|
2014-10-27 13:45:41 -04:00
|
|
|
</table>
|
|
|
|
</td>
|
|
|
|
<td valign="top" style='padding-left:25px;'>
|
|
|
|
<table border="0" cellspacing="0" cellpadding="5" class="tborder">
|
|
|
|
<tbody><tr>
|
|
|
|
<td class="thead" colspan="2"><strong>]] .. SubTitle .. [[</strong></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="trow2">
|
|
|
|
]] .. PageContent .. [[
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody></table>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody></table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="footer">
|
|
|
|
<div class="upper">
|
|
|
|
<div class="wrapper">
|
|
|
|
<ul class="menu bottom_links">
|
2014-10-27 14:13:25 -04:00
|
|
|
<li><a href=http://www.mc-server.org target=_blank>MCServer</a></li>
|
|
|
|
<li><a href=http://forum.mc-server.org target=_blank>Forums</a></li>
|
|
|
|
<li><a href=http://builds.cuberite.org target=_blank>Buildserver</a></li>
|
|
|
|
<li><a href=http://mc-server.xoft.cz/LuaAPI target=_blank>API Documentation</a></li>
|
|
|
|
<li><a href=http://book.mc-server.org/ target=_blank>User's Manual</a></li>
|
2014-10-27 13:45:41 -04:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class=lower>
|
|
|
|
<div class=wrapper>
|
|
|
|
<span id=current_time><strong>Current time:</strong> <script type=text/javascript>document.write('Time: <strong><span id="date-time">',new Date().toLocaleString(),"</span></strong>");if(document.getElementById){onload=function(){setInterval("document.getElementById ('date-time').firstChild.data = new Date().toLocaleString()",50)}};</script></span>
|
|
|
|
<span id=copyright>
|
|
|
|
Copyright © <a href=http://www.mc-server.org target=_blank>MCServer Team</a> 2014.
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body></html>
|
2014-10-05 05:08:10 -04:00
|
|
|
]])
|
2013-07-28 20:37:59 -04:00
|
|
|
|
|
|
|
return table.concat(SiteContent)
|
2014-08-31 08:39:58 -04:00
|
|
|
end
|