X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=include%2Fhttp%2Fipagehandler.h;h=d0c585683b02d945b722f2c2c203a0f3d0db0dce;hb=59a5414ec47a2932a7802fcd1d98c4d80166564f;hp=be707e5791ce47bbcc6cc678edc31de7cdf70a87;hpb=b9c3763a932cebaa015a27fe111017f6f34dfbaa;p=fms.git diff --git a/include/http/ipagehandler.h b/include/http/ipagehandler.h index be707e5..d0c5856 100644 --- a/include/http/ipagehandler.h +++ b/include/http/ipagehandler.h @@ -1,38 +1,50 @@ #ifndef _ipagehandler_ #define _ipagehandler_ +#include "../ilogger.h" +#include "../idatabase.h" + +#include +#include +#include + #include #include #include #include -#include -class IPageHandler +class IPageHandler:public Poco::Net::HTTPRequestHandler,public ILogger,public IDatabase { public: - IPageHandler() {} - IPageHandler(const std::string &templatestr) { m_template=templatestr; } + IPageHandler(SQLite3DB::DB *db):IDatabase(db) {} + IPageHandler(SQLite3DB::DB *db, const std::string &templatestr, const std::string &pagename):IDatabase(db),m_template(templatestr),m_pagename(pagename) { } virtual ~IPageHandler() {} + virtual const bool WillHandleURI(const std::string &uri); + + virtual IPageHandler *New()=0; // returns a new instance of the object - /** - \brief Handles request for a page - - \return true if request was handled, false if it was ignored - */ - const bool Handle(shttpd_arg *arg); + virtual void handleRequest(Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response); private: - virtual const bool WillHandleURI(const std::string &uri)=0; virtual const std::string GeneratePage(const std::string &method, const std::map &queryvars)=0; - + protected: // converts from basename[#] query args into a vector where the vector pos is the index pos # void CreateArgArray(const std::map &vars, const std::string &basename, std::vector &args); + const std::string CreateTrueFalseDropDown(const std::string &name, const std::string &selected); + + void CreateQueryVarMap(Poco::Net::HTTPServerRequest &request, std::map &vars); + + const std::string CreateFormPassword(); + const bool ValidateFormPassword(const std::map &vars); - // replaces html control characters with elements (i.e. < becomes <) + // replaces html elements with encoded characters (i.e. < becomes <) const std::string SanitizeOutput(const std::string &input); + // don't replace space with  , because browser might convert to unicode non breaking space character + const std::string SanitizeTextAreaOutput(const std::string &input); std::string m_template; + std::string m_pagename; };