/* ZazouMiniWebServer Copyright (C) 2003-2011 Xavier Garreau This file is part of ZazouMiniWebServer. ZazouMiniWebServer is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ZazouMiniWebServer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with ZazouMiniWebServer; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ // ZMWSConfig.h: interface for the ZMWSConfig class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_ZMWSConfig_H__E778596F_69F2_4A39_BDF8_A203D5487D17__INCLUDED_) #define AFX_ZMWSConfig_H__E778596F_69F2_4A39_BDF8_A203D5487D17__INCLUDED_ #include "ZOSAL.h" #include "ZMWSlib.h" #include #include #include // ToDo // Testing ZMWSConfig::ConfFeatures against these values // would provide more efficiency if they aren't used #define ZMWSCONFIGFEATURES_VHOSTS 1 #define ZMWSCONFIGFEATURES_DIRALIAS 2 #define ZMWSCONFIGFEATURES_VHOST_DIRALIAS 4 #define ZMWSCONFIGFEATURES_PERURL 8 #define ZMWSCONFIGFEATURES_VHOST_PERURL 16 typedef enum {PBTOKEN_OFF = 0, PBTOKEN_NOVERSION, PBTOKEN_ALL} pbtoken_type; typedef std::pair DirAliasType; typedef std::vector DirAliasesType; typedef DirAliasesType::iterator DirAliasesTypeIterator; class ZMWSHandler { public: enum {NONE = 0, DEFAULT, TRUECGI, ZMWSSAPI} handlerType; std::string handlerPath; ZMWSHandler() : handlerType(NONE) {}; }; typedef std::map HandlersType; class ZMWSVHostConfig { public: HandlersType Handlers; std::string domain; // Déf: le nom du rép de stockage std::string documentRoot; // Déf: sous DocumentRoot/_vhosts.zmwsc/domain std::string logsDir; // sous logsDir std::string defCharSet; // Default Charset pour les types texte std::string allowFrom; // IP autorisées à accéder à ce VHost std::string denyFrom; // IP interdites sur ce VHost DirAliasesType DirAliases; // Alias de répertoires pour ce VHost BOOL canIndex; // true BOOL reverseDNS; // true DWORD maxKBytes; // Maximum de ko transférables en maxKBytesDTime secondes DWORD maxKBytesDTime; // secondes entre chaque RAZ }; typedef std::map VHostsConfigType; typedef std::map VHostAliasesType; class ZMWSPerUrlConfig { HandlersType Handlers; public: BOOL AddHandler (const std::string& extension, const ZMWSHandler& handler); ZMWSHandler GetHandler(const std::string& extension) const; }; typedef std::pair PerUrlConfigType; typedef std::vector PerUrlConfigsType; typedef PerUrlConfigsType::iterator PerUrlConfigsTypeIterator; struct BaseZMWSConfig { int port; int sport; std::string bindAddr; std::string documentRoot; std::string serverRoot; std::string logsDir; std::string pathToConfigFile; std::string pathToPHP; std::string browserCmd; std::string defCharSet; std::string startPages; std::string allowFrom; std::string denyFrom; DWORD maxClients; BOOL hideConsole; BOOL try808xPorts; BOOL canIndex; BOOL beQuiet; BOOL canStop; BOOL closeBrowser; BOOL reverseDNS; BOOL writeLogs; BOOL browseNow; BOOL dropClients; // 1.1 pbtoken_type pbtoken; }; class ZMWSConfig : protected BaseZMWSConfig { protected: DWORD ConfFeatures; VHostsConfigType VHostsConfig; VHostAliasesType VHostsAliases; HandlersType Handlers; DirAliasesType DirAliases; // Alias de répertoires PerUrlConfigsType PerUrlConfigs; public: ZMWSConfig( const int& p=80, const int& httpsp=443, const std::string& dr="", const std::string& lr="_logs.zmwsc/", const std::string& ptp="php5/php-cgi", const std::string& bc="", const std::string& sp="index.php;index.html;index.htm*;index.php*", const std::string& af="", const std::string& df="", const pbtoken_type pbtoken=PBTOKEN_ALL, const DWORD& mc = 1000, const BOOL& wl = TRUE, const BOOL& hc = FALSE, const BOOL& tp = TRUE, const BOOL& rv = FALSE, const BOOL& ci = TRUE, const BOOL& bq = FALSE, const BOOL& cs = FALSE, const BOOL& cb = FALSE, const BOOL& bn = FALSE, const BOOL& dc = FALSE); virtual ~ZMWSConfig(); const int& GetPort() const { return port; } const int& GetHTTPSPort() const { return sport; } const std::string& GetBindAddr() const{ return bindAddr; } const std::string& GetDocumentRoot() const{ return documentRoot; } const std::string& GetServerRoot() const{ return serverRoot; } const std::string& GetLogsDir() const{ return logsDir; } const std::string& GetPathToPHP() const{ return pathToPHP; } const std::string& GetBrowserCmd() const{ return browserCmd; } const std::string& GetPathToConfigFile() const{ return pathToConfigFile; } const std::string& GetDefaultCharSet() const{ return defCharSet; } const std::string& GetStartPages() const { return startPages; } const std::string& GetAllowedFrom() const { return allowFrom; } const std::string& GetDeniedFrom() const { return denyFrom; } const pbtoken_type& GetPBToken() const { return pbtoken; } const BOOL& GetHideConsole() const { return hideConsole; } const BOOL& GetTry808xPorts() const { return try808xPorts; } const BOOL& GetCanIndex() const { return canIndex; } const BOOL& GetBeQuiet() const { return beQuiet; } const BOOL& GetCloseBrowser() const { return closeBrowser; } const BOOL& GetCanStop() const { return canStop; } const BOOL& GetWriteLogs() const { return writeLogs; } const BOOL& GetReverseDNS() const { return reverseDNS; } const BOOL& GetBrowseNow() const { return browseNow; } const BOOL& GetDropClients() const { return dropClients; } const DWORD& GetMaxClients() const { return maxClients; } void SetPort(const WORD& p) { port = p; } void SetHTTPSPort(const WORD& p) { sport = p; } void SetBindAddr(const std::string& ba){ bindAddr = ba; } void SetBrowserCmd(const std::string& bc){ browserCmd = bc; } void SetReverseDNS(const BOOL& revdns) { reverseDNS = revdns; } void SetCanIndex(const BOOL& i) { canIndex = i; } void SetBeQuiet(const BOOL& bq) { beQuiet = bq; } void SetCanStop(const BOOL& cs) { canStop = cs; } void SetCloseBrowser(const BOOL& cb) { closeBrowser = cb; } void SetWriteLogs (const BOOL& wl) {writeLogs = wl; } void SetPBToken(const pbtoken_type& pbt) { pbtoken = pbt; } void SetHideConsole(const BOOL& hc) { hideConsole = hc; } void SetTry808xPorts(const BOOL& tp) { try808xPorts = tp; } void SetBrowseNow(const BOOL& bn) { browseNow = bn; } void SetDropClients(const BOOL& dc) { dropClients = dc; } void SetMaxClients(const DWORD& mc) { maxClients = mc; } void SetStartPages (const std::string& sp) { startPages = sp; } BOOL SetPathToPHP(const std::string& path); BOOL SetPathToConfigFile(const std::string& cfp); BOOL SetLogsDir(const std::string& ld, const std::string& vhost=""); BOOL SetDefaultCharset(const std::string& cs, const std::string& vhost=""); BOOL SetDocumentRoot(const std::string& dr, const std::string& vhost=""); BOOL SetAllowFrom(const std::string& af, const std::string& vhost=""); BOOL SetDenyFrom(const std::string& df, const std::string& vhost=""); BOOL AddDirAlias(const std::string& alias, const std::string& real, const std::string& vhost=""); void ConfigureVHosts(); BOOL GetVHostConfig(const std::string& VHostName, ZMWSVHostConfig& vhc); BOOL SetVHostConfig(const std::string& VHostName, const ZMWSVHostConfig& vhc); BOOL GetPerUrlConfig(const std::string& url, ZMWSPerUrlConfig& puc, const BOOL& exact = 0); BOOL SetPerUrlConfig(const std::string& url, const ZMWSPerUrlConfig& puc); BOOL CreateDefaultVHost (const std::string& domainName); void AddVHostAlias(const std::string& alias, const std::string& domain); std::string GetDomainForVHostAlias(const std::string& alias); std::string GetAliasedDir(const std::string& alias, std::string& AliasedReqRootDir, const std::string& vhost=""); ZMWSHandler GetHandler(const std::string& extension, const std::string& vhost=""); void AddHandler(const std::string& extension, const ZMWSHandler& handler, const std::string& vhost=""); void GetCBaseConfig(CBaseZMWSConfig* conf) const; void FreeCBaseConfig(CBaseZMWSConfig* conf) const; }; #endif // !defined(AFX_ZMWSConfig_H__E778596F_69F2_4A39_BDF8_A203D5487D17__INCLUDED_)