diff options
author | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-01-22 21:15:11 +0100 |
---|---|---|
committer | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-01-22 21:15:11 +0100 |
commit | 738b1b3467e5556667464bc33294a7485d37097b (patch) | |
tree | 0f42294589a7574e391644609e315694b194639f /source/cWebAdmin.cpp | |
parent | Bug FS#131 http://www.mc-server.org/support/index.php?do=details&task_id=131 should be fixed (diff) | |
download | cuberite-738b1b3467e5556667464bc33294a7485d37097b.tar cuberite-738b1b3467e5556667464bc33294a7485d37097b.tar.gz cuberite-738b1b3467e5556667464bc33294a7485d37097b.tar.bz2 cuberite-738b1b3467e5556667464bc33294a7485d37097b.tar.lz cuberite-738b1b3467e5556667464bc33294a7485d37097b.tar.xz cuberite-738b1b3467e5556667464bc33294a7485d37097b.tar.zst cuberite-738b1b3467e5556667464bc33294a7485d37097b.zip |
Diffstat (limited to 'source/cWebAdmin.cpp')
-rw-r--r-- | source/cWebAdmin.cpp | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/source/cWebAdmin.cpp b/source/cWebAdmin.cpp index bc22a4681..86dbf5990 100644 --- a/source/cWebAdmin.cpp +++ b/source/cWebAdmin.cpp @@ -99,28 +99,7 @@ void cWebAdmin::Request_Handler(webserver::http_request* r) std::string Menu;
std::string Content;
std::string Template = WebAdmin->GetTemplate();
-
- Content += "<h3>Current Game</h3>";
- Content += "<h4>Server Name:</h4>";
- Content += "<p>" + std::string( cRoot::Get()->GetServer()->GetServerID() ) + "</p>";
-
- Content += "<h4>Plugins:</h4><p>";
- cPluginManager* PM = cRoot::Get()->GetPluginManager();
- const cPluginManager::PluginList & List = PM->GetAllPlugins();
- for( cPluginManager::PluginList::const_iterator itr = List.begin(); itr != List.end(); ++itr )
- {
- Content += std::string( (*itr)->GetName() ) + "<br>";
- }
- Content += "</p>";
- Content += "<h4>Players:</h4><p>";
-
- cWorld* World = cRoot::Get()->GetWorld(); // TODO - Create a list of worlds and players
- cWorld::PlayerList PlayerList = World->GetAllPlayers();
- for( cWorld::PlayerList::iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr )
- {
- Content += std::string( (*itr)->GetName() ) + "<br>";
- }
- Content += "</p>";
+ std::string FoundPlugin;
for( PluginList::iterator itr = WebAdmin->m_Plugins.begin(); itr != WebAdmin->m_Plugins.end(); ++itr )
{
@@ -133,9 +112,11 @@ void cWebAdmin::Request_Handler(webserver::http_request* r) Request.Params = new cStringMap(r->params_);
Request.Path = r->path_;
+
+
if( Split.size() > 1 )
{
- std::string FoundPlugin = "";
+
for( PluginList::iterator itr = WebAdmin->m_Plugins.begin(); itr != WebAdmin->m_Plugins.end(); ++itr )
{
if( (*itr)->GetName() == Split[1] )
@@ -145,14 +126,40 @@ void cWebAdmin::Request_Handler(webserver::http_request* r) break;
}
}
+ }
+
+ delete Request.Params;
+
+ if( FoundPlugin.empty() ) // Default page
+ {
+ Content.clear();
+ FoundPlugin = "Current Game";
+ Content += "<h4>Server Name:</h4>";
+ Content += "<p>" + std::string( cRoot::Get()->GetServer()->GetServerID() ) + "</p>";
+
+ Content += "<h4>Plugins:</h4><ul>";
+ cPluginManager* PM = cRoot::Get()->GetPluginManager();
+ if( PM )
+ {
+ const cPluginManager::PluginList & List = PM->GetAllPlugins();
+ for( cPluginManager::PluginList::const_iterator itr = List.begin(); itr != List.end(); ++itr )
+ {
+ Content += std::string("<li>") + std::string( (*itr)->GetName() ) + "</li>";
+ }
+ }
+ Content += "</ul>";
+ Content += "<h4>Players:</h4><ul>";
- if( FoundPlugin.compare("") != 0 ) // Add some header
+ cWorld* World = cRoot::Get()->GetWorld(); // TODO - Create a list of worlds and players
+ cWorld::PlayerList PlayerList = World->GetAllPlayers();
+ for( cWorld::PlayerList::iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr )
{
- Content = "<h3>" + FoundPlugin + "</h3>\n<p>" + Content + "</p>";
+ Content += std::string("<li>") + std::string( (*itr)->GetName() ) + "</li>";
}
+ Content += "</ul><br>";
}
- delete Request.Params;
+
if( Split.size() > 1 )
{
@@ -192,6 +199,7 @@ void cWebAdmin::Request_Handler(webserver::http_request* r) ReplaceString( Template, std::string("{USERNAME}"), r->username_ );
ReplaceString( Template, std::string("{MENU}"), Menu );
+ ReplaceString( Template, std::string("{PLUGIN_NAME}"), FoundPlugin );
ReplaceString( Template, std::string("{CONTENT}"), Content );
ReplaceString( Template, std::string("{TITLE}"), "MCServer" );
|