diff options
author | madmaxoft <github@xoft.cz> | 2013-10-20 09:14:30 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-10-20 09:14:30 +0200 |
commit | 0258213d243c9d13cc3e50a4e2708552932bb097 (patch) | |
tree | 4f232ee448faf9749a82304081b7f4c7634a2ffc /source/WebAdmin.h | |
parent | APIDump: Undocumented member variables are listed. (diff) | |
parent | Added a string reserve. (diff) | |
download | cuberite-0258213d243c9d13cc3e50a4e2708552932bb097.tar cuberite-0258213d243c9d13cc3e50a4e2708552932bb097.tar.gz cuberite-0258213d243c9d13cc3e50a4e2708552932bb097.tar.bz2 cuberite-0258213d243c9d13cc3e50a4e2708552932bb097.tar.lz cuberite-0258213d243c9d13cc3e50a4e2708552932bb097.tar.xz cuberite-0258213d243c9d13cc3e50a4e2708552932bb097.tar.zst cuberite-0258213d243c9d13cc3e50a4e2708552932bb097.zip |
Diffstat (limited to '')
-rw-r--r-- | source/WebAdmin.h | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/source/WebAdmin.h b/source/WebAdmin.h index 488cec274..fbe6a6b4a 100644 --- a/source/WebAdmin.h +++ b/source/WebAdmin.h @@ -51,18 +51,18 @@ struct HTTPRequest { typedef std::map< std::string, std::string > StringStringMap; typedef std::map< std::string, HTTPFormData > FormDataMap; - + AString Method; AString Path; AString Username; // tolua_end - + /// Parameters given in the URL, after the questionmark StringStringMap Params; // >> EXPORTED IN MANUALBINDINGS << - + /// Parameters posted as a part of a form - either in the URL (GET method) or in the body (POST method) StringStringMap PostParams; // >> EXPORTED IN MANUALBINDINGS << - + /// Same as PostParams FormDataMap FormData; // >> EXPORTED IN MANUALBINDINGS << } ; // tolua_export @@ -101,7 +101,7 @@ class cWebAdmin : { public: // tolua_end - + typedef std::list< cWebPlugin* > PluginList; @@ -110,7 +110,7 @@ public: /// Initializes the object. Returns true if successfully initialized and ready to start bool Init(void); - + /// Starts the HTTP server taking care of the admin. Returns true if successful bool Start(void); @@ -121,32 +121,35 @@ public: PluginList GetPlugins() const { return m_Plugins; } // >> EXPORTED IN MANUALBINDINGS << // tolua_begin - + /// Returns the amount of currently used memory, in KiB, or -1 if it cannot be queried static int GetMemoryUsage(void); sWebAdminPage GetPage(const HTTPRequest& a_Request); - + /// Returns the contents of the default page - the list of plugins and players AString GetDefaultPage(void); - + AString GetBaseURL(const AString& a_URL); - + + // Escapes text passed into it, so it can be embedded into html. + AString GetHTMLEscapedString( const AString& a_Input ); + // tolua_end AString GetBaseURL(const AStringVector& a_URLSplit); - + protected: /// Common base class for request body data handlers class cRequestData { public: virtual ~cRequestData() {} // Force a virtual destructor in all descendants - + /// Called when a new chunk of body data is received virtual void OnBody(const char * a_Data, int a_Size) = 0; } ; - + /// The body handler for requests in the "/webadmin" and "/~webadmin" paths class cWebadminRequestData : public cRequestData, @@ -154,13 +157,13 @@ protected: { public: cHTTPFormParser m_Form; - - + + cWebadminRequestData(cHTTPRequest & a_Request) : m_Form(a_Request, *this) { } - + // cRequestData overrides: virtual void OnBody(const char * a_Data, int a_Size) override; @@ -169,31 +172,31 @@ protected: virtual void OnFileData(cHTTPFormParser & a_Parser, const char * a_Data, int a_Size) override {} virtual void OnFileEnd(cHTTPFormParser & a_Parser) override {} } ; - - + + /// Set to true if Init() succeeds and the webadmin isn't to be disabled bool m_IsInitialized; /// The webadmin.ini file, used for the settings and allowed logins cIniFile m_IniFile; - + PluginList m_Plugins; /// The Lua template script to provide templates: cLuaState m_TemplateScript; - + /// The HTTP server which provides the underlying HTTP parsing, serialization and events cHTTPServer m_HTTPServer; AString GetTemplate(void); - + /// Handles requests coming to the "/webadmin" or "/~webadmin" URLs void HandleWebadminRequest(cHTTPConnection & a_Connection, cHTTPRequest & a_Request); - + /// Handles requests for the root page void HandleRootRequest(cHTTPConnection & a_Connection, cHTTPRequest & a_Request); - + // cHTTPServer::cCallbacks overrides: virtual void OnRequestBegun (cHTTPConnection & a_Connection, cHTTPRequest & a_Request) override; virtual void OnRequestBody (cHTTPConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, int a_Size) override; |