00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _WEB_H
00021 #define _WEB_H
00022
00023 #ifdef _WIN32
00024 #define STL_USING_STRING
00025 #define STL_USING_LIST
00026 #include <stlhelper.h>
00027 #else
00028 #include <string>
00029 #include <list>
00030 #endif
00031
00032
00033 namespace Cgi {
00034
00035 class Form;
00036 class Cookies;
00037 class WebForm;
00038
00040
00041 class Web
00042 {
00043 public:
00044 Web();
00049 Web(const std::string &cd,const std::string &cp,const std::string& id = "");
00054 Web(int argc,char *argv[],const std::string &cd,const std::string &cp,const std::string& id = "");
00055 virtual ~Web();
00056
00058 void Init(const std::string& id);
00059
00060 void SetCookieDomain(const std::string &);
00061 void SetCookiePath(const std::string &);
00062 void SetCookie(const std::string &name,const std::string &value);
00063 void SetCookie(const std::string &name,long value);
00064 void SetCookie(const std::string &name,int value);
00065 void Execute();
00066 void SetCgiName(const std::string &);
00067 std::string GetCgiName();
00068 Form *GetForm();
00069 Cookies *GetCookies();
00070
00071 void RegWebForm(WebForm *);
00072
00073 virtual void GetEnvironment();
00074 virtual void ReadCookies();
00075 virtual void FormInput();
00076 virtual void ValidateAuth();
00077 virtual void CreateHeader();
00078 virtual void GenerateDocument();
00079
00080 std::string GetDate();
00081 std::string GetRequestMethod();
00082 void UpdateModified(const std::string& );
00083 std::string datetime2httpdate(const std::string& dt);
00084 const std::string& GetLastModified() { return m_lastmodified; }
00085 const std::string& GetQueryString() { return m_query_string; }
00086
00088 void SetRealm(const std::string& realm_id);
00089 const std::string& GetRealm() { return m_realm; }
00091 virtual bool ValidateUser(const std::string& user,const std::string& pw);
00093 const std::string& GetUser();
00095 bool Valid();
00096
00097 void SetContentType(const std::string& x) { m_contentType = x; }
00098 void SetContentDisposition(const std::string& x) { m_contentDisposition = x; }
00099 void SetLocation(const std::string& x) { m_location = x; }
00100
00101 protected:
00102 Form *m_pclForm;
00103 Cookies *m_pclCookies;
00104
00105 private:
00106 Web(const Web& ) {}
00107 Web& operator=(const Web& ) { return *this; }
00108 std::string m_strCookieDomain;
00109 std::string m_strCookiePath;
00110 std::string m_strCgiName;
00111 std::list<WebForm *> m_forms;
00112 std::string m_date;
00113 std::string m_method;
00114 std::string m_lastmodified;
00115 std::string m_query_string;
00116 std::string m_realm;
00117 std::string m_user;
00118 bool m_bValid;
00119 std::string m_contentType;
00120 std::string m_contentDisposition;
00121 std::string m_location;
00122 };
00123
00124 }
00125
00126 #endif // _WEB_H