Google
Web alhem.net
Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

IWeb Class Reference

#include <IWeb.h>

Collaboration diagram for IWeb:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 IWeb ()
 ~IWeb ()
void ReadCookies ()
void FormInput ()
void CreateHeader ()
void GenerateDocument ()
Database & GetDatabase ()
void SetTheCookie ()
long GetUsernum ()
void SetUsernum (long x)
long GetValid ()
void SetValid (long x)
long GetForum ()
void SetForum (long x)
long GetThread ()
void SetThread (long x)
long GetPage ()
void SetPage (long x)
long GetIndex ()
void SetIndex (long x)
long GetQty ()
void SetQty (long x)
long GetMessage ()
void SetMessage (long x)

Private Attributes

Database m_db
SysLog m_log
bool m_bSetCookie
long m_image
db::Image * m_pImage
bool m_image_tn
bool m_not_modified
std::string m_cookie_to_set
AccountForm m_form1
SettingsForm m_form2
ForumsForm m_form3
ThreadListForm m_form4
ViewThreadForm m_form5
NewThreadForm m_form6
NewMessageForm m_form7
EditMessageForm m_form8
long m_usernum
long m_valid
long m_forum
long m_thread
long m_page
long m_index
long m_qty
long m_message

Constructor & Destructor Documentation

IWeb::IWeb  ) 
 

Definition at line 40 of file IWeb.cpp.

References COOKIE_DOMAIN, COOKIE_PATH, m_db, m_form1, m_form2, m_form3, m_form4, m_form5, m_form6, m_form7, m_form8, and m_log.

00040 : Web(COOKIE_DOMAIN, COOKIE_PATH) 00041 ,m_db("localhost","web","","ibank") 00042 ,m_bSetCookie(false) 00043 ,m_image(0) 00044 ,m_pImage(NULL) 00045 ,m_image_tn(false) 00046 ,m_not_modified(false) 00047 // 00048 ,m_form1(this) 00049 ,m_form2(this) 00050 ,m_form3(this) 00051 ,m_form4(this) 00052 ,m_form5(this) 00053 ,m_form6(this) 00054 ,m_form7(this) 00055 ,m_form8(this) 00056 // 00057 ,m_usernum(0) 00058 ,m_valid(0) 00059 ,m_forum(0) 00060 ,m_thread(0) 00061 ,m_page(0) 00062 ,m_index(0) 00063 ,m_qty(0) 00064 ,m_message(0) 00065 { 00066 m_db.RegErrHandler(&m_log); 00067 00068 RegWebForm(&m_form1); 00069 RegWebForm(&m_form2); 00070 RegWebForm(&m_form3); 00071 RegWebForm(&m_form4); 00072 RegWebForm(&m_form5); 00073 RegWebForm(&m_form6); 00074 RegWebForm(&m_form7); 00075 RegWebForm(&m_form8); 00076 }

IWeb::~IWeb  ) 
 

Definition at line 79 of file IWeb.cpp.

00080 { 00081 }


Member Function Documentation

void IWeb::CreateHeader  ) 
 

Definition at line 136 of file IWeb.cpp.

References BaseForm::GetMimeFromFilename(), m_bSetCookie, m_form1, m_image, m_image_tn, m_not_modified, m_pImage, and SetTheCookie().

00137 { 00138 char *if_modified_since = getenv("HTTP_IF_MODIFIED_SINCE"); 00139 // HTTP_IF_MODIFIED_SINCE=Tue, 06 Jul 2004 16:33:51 GMT 00140 00141 if (m_image && if_modified_since && datetime2httpdate(m_pImage -> modified) == if_modified_since) 00142 { 00143 printf("Status: 304 Not Modified\n\n"); 00144 m_not_modified = true; 00145 return; 00146 } 00147 if (m_bSetCookie) 00148 { 00149 SetTheCookie(); 00150 } 00151 if (m_image) 00152 { 00153 // Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT 00154 printf("Last-modified: %s\n",datetime2httpdate(m_pImage -> modified).c_str()); 00155 printf("Content-type: %s\n",m_form1.GetMimeFromFilename(m_image_tn ? "/tmp/tn.gif" : m_pImage -> filename).c_str()); 00156 } 00157 else 00158 { 00159 printf("Content-type: text/html\n"); 00160 } 00161 // End of header 00162 printf("\n"); 00163 fflush(stdout); 00164 }

void IWeb::FormInput  ) 
 

Definition at line 100 of file IWeb.cpp.

References m_db, m_image, m_image_tn, m_pImage, m_usernum, m_valid, and SetPage().

00101 { 00102 std::string page = GetForm() -> getvalue("page"); 00103 if (page.size()) 00104 { 00105 SetPage(atoi(page.c_str())); 00106 } 00107 std::string img = GetForm() -> getvalue("img"); 00108 if (img.size()) 00109 { 00110 m_pImage = new db::Image(m_db, atol(img.c_str())); 00111 m_image = m_pImage -> num; 00112 } 00113 else 00114 { 00115 img = GetForm() -> getvalue("imgtn"); 00116 if (img.size()) 00117 { 00118 m_pImage = new db::Image(m_db, atol(img.c_str())); 00119 m_image = m_pImage -> num; 00120 m_image_tn = true; 00121 } 00122 } 00123 std::string logout = GetForm() -> getvalue("logout"); 00124 if (logout.size() && atoi(logout.c_str()) == 1) 00125 { 00126 Query q(m_db); 00127 char sql[1000]; 00128 sprintf(sql,"delete from valid where account=%ld and valid=%ld",m_usernum,m_valid); 00129 q.execute(sql); 00130 } 00131 //printf("\n<html><body><h3>debug forminput</h3>"); 00132 Web::FormInput(); 00133 }

void IWeb::GenerateDocument  ) 
 

Definition at line 167 of file IWeb.cpp.

References EditMessageForm::Display(), NewMessageForm::Display(), NewThreadForm::Display(), ViewThreadForm::Display(), ThreadListForm::Display(), ForumsForm::Display(), SettingsForm::Display(), AccountForm::Display(), GetDatabase(), m_cookie_to_set, m_form1, m_form2, m_form3, m_form4, m_form5, m_form6, m_form7, m_form8, m_forum, m_image, m_image_tn, m_message, m_not_modified, m_page, m_pImage, m_thread, m_usernum, m_valid, and SetPage().

00168 { 00169 db::Account account(GetDatabase(), m_usernum); 00170 char sql[1000]; 00171 sprintf(sql,"select * from valid where account=%ld and valid=%ld",m_usernum,m_valid); 00172 db::Valid valid(&GetDatabase(), sql); 00173 /* 00174 { 00175 size_t i = 0; 00176 while (environ[i]) 00177 { 00178 DEB( fprintf(fil,"%s\n",environ[i]);) 00179 i++; 00180 } 00181 } 00182 */ 00183 if (!account.num || !valid.num) 00184 { 00185 SetPage( 1 ); 00186 } 00187 else 00188 if (m_image && m_not_modified) 00189 { 00190 return; 00191 } 00192 else 00193 if (m_image) 00194 { 00195 cgi::Base64 bomb; 00196 bomb.decode_to_stdout(m_image_tn ? m_pImage -> image_tn : m_pImage -> image_data); 00197 return; 00198 } 00199 // HTML start 00200 printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n"); 00201 printf("<html>\n"); 00202 printf("<head>\n"); 00203 printf("<link rel=\"STYLESHEET\" href=\"/style/ib.css\" type=\"text/css\">\n"); 00204 // printf("<link rel=\"SHORTCUT ICON\" href=\"http://www.alhem.net/icon/flags/se.png\">\n"); 00205 printf("<title>IBank :: The Image Vault</title>\n"); 00206 printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n"); 00207 // printf("<SCRIPT language=\"JavaScript\" SRC=\"http://www.alhem.net/js/overlib_mini4.js\" type=\"text/javascript\"></SCRIPT>\n"); 00208 00209 printf("</head>\n"); 00210 printf("<body>\n"); 00211 // printf("<div id=\"overDiv\" style=\"position:absolute; visibility:hide; z-index:1;\"></div>\n"); 00212 if (0) 00213 { 00214 char key[200]; 00215 char val[200]; 00216 printf("<h3>Form</h3>"); 00217 GetForm() -> getfirst(key,200,val,200); 00218 while (*key) 00219 { 00220 printf("%s == '%s'<br>",key,val); 00221 printf("getvalue(%s) == '%s'<br>",key,GetForm() -> getvalue(key).c_str()); 00222 GetForm() -> getnext(key,200,val,200); 00223 } 00224 printf("<h3>Cookies</h3>"); 00225 printf("<b>Cookie value to set == '%s'</b><br>",m_cookie_to_set.c_str()); 00226 for (cookie_v::iterator it = GetCookies() -> GetCookies().begin(); it != 00227 GetCookies() -> GetCookies().end(); it++) 00228 { 00229 COOKIE *p = *it; 00230 printf("%s == '%s'<br>",p -> name,p -> value); 00231 } 00232 printf("<hr>"); 00233 } 00234 if (m_page > 1 && 0) 00235 { 00236 printf("<table width=\"100%%\"><tr><td><a href=\"http://www.alhem.net/\"><img border=0 src=\"/icons/ahl.png\"></a></td>"); 00237 printf("<td>"); 00238 printf("<center>\n"); 00239 printf("<script type=\"text/javascript\" src=\"/js/goog.js\"></script>"); 00240 printf("</center>\n"); 00241 printf("</td>"); 00242 /* 00243 printf("<td align=right>"); 00244 printf("<a href=\"http://www.bosrup.com/web/overlib/\">"); 00245 printf("<img src=\"/image/power.gif\" width=\"88\" height=\"31\" alt=\"Popups by overLIB!\" border=\"0\"></a>"); 00246 printf("</td>"); 00247 */ 00248 printf("</tr></table>"); 00249 } // m_page > 2 00250 fflush(stdout); 00251 00252 switch (m_page) 00253 { 00254 case 1: // login / register 00255 m_form1.Display( 0 ); 00256 break; 00257 case 2: // user settings 00258 m_form2.Display( m_usernum ); 00259 break; 00260 case 3: // forums 00261 m_form3.Display( 0 ); 00262 break; 00263 case 4: // threads 00264 m_form4.Display( m_forum ); 00265 break; 00266 case 5: // view thread 00267 m_form5.Display( m_thread ); 00268 break; 00269 case 6: // new thread 00270 m_form6.Display( m_forum ); 00271 break; 00272 case 7: // new message 00273 m_form7.Display( m_thread ); 00274 break; 00275 case 8: // edit message 00276 m_form8.Display( m_message ); 00277 break; 00278 } 00279 fflush(stdout); 00280 00281 // Footer 00282 printf("</body>\n"); 00283 printf("</html>\n"); 00284 fflush(stdout); 00285 }

Database& IWeb::GetDatabase  )  [inline]
 

Definition at line 55 of file IWeb.h.

References m_db.

Referenced by GenerateDocument().

00055 { return m_db; }

long IWeb::GetForum  )  [inline]
 

Definition at line 66 of file IWeb.h.

References m_forum.

00066 { return m_forum; }

long IWeb::GetIndex  )  [inline]
 

Definition at line 72 of file IWeb.h.

References m_index.

00072 { return m_index; }

long IWeb::GetMessage  )  [inline]
 

Definition at line 76 of file IWeb.h.

References m_message.

00076 { return m_message; }

long IWeb::GetPage  )  [inline]
 

Definition at line 70 of file IWeb.h.

References m_page.

00070 { return m_page; }

long IWeb::GetQty  )  [inline]
 

Definition at line 74 of file IWeb.h.

References m_qty.

00074 { return m_qty; }

long IWeb::GetThread  )  [inline]
 

Definition at line 68 of file IWeb.h.

References m_thread.

00068 { return m_thread; }

long IWeb::GetUsernum  )  [inline]
 

Definition at line 62 of file IWeb.h.

References m_usernum.

00062 { return m_usernum; }

long IWeb::GetValid  )  [inline]
 

Definition at line 64 of file IWeb.h.

References m_valid.

00064 { return m_valid; }

void IWeb::ReadCookies  ) 
 

Definition at line 84 of file IWeb.cpp.

References m_forum, m_index, m_message, m_page, m_qty, m_thread, m_usernum, and m_valid.

00085 { 00086 char slask[1000]; 00087 GetCookies() -> getvalue("ibc", slask, 1000); 00088 cgi::Parse pa(slask,":"); 00089 m_usernum = pa.getvalue(); 00090 m_valid = pa.getvalue(); 00091 m_forum = pa.getvalue(); 00092 m_thread = pa.getvalue(); 00093 m_page = pa.getvalue(); 00094 m_index = pa.getvalue(); 00095 m_qty = pa.getvalue(); 00096 m_message = pa.getvalue(); 00097 }

void IWeb::SetForum long  x  )  [inline]
 

Definition at line 67 of file IWeb.h.

References m_bSetCookie, m_forum, and SetForum().

Referenced by SetForum().

00067 { if (x != m_forum) m_bSetCookie = true; m_forum = x; }

void IWeb::SetIndex long  x  )  [inline]
 

Definition at line 73 of file IWeb.h.

References m_bSetCookie, m_index, and SetIndex().

Referenced by SetIndex().

00073 { if (x != m_index) m_bSetCookie = true; m_index = x; }

void IWeb::SetMessage long  x  )  [inline]
 

Definition at line 77 of file IWeb.h.

References m_bSetCookie, m_message, and SetMessage().

Referenced by SetMessage().

00077 { if (x != m_message) m_bSetCookie = true; m_message = x; }

void IWeb::SetPage long  x  )  [inline]
 

Definition at line 71 of file IWeb.h.

References m_bSetCookie, m_page, and SetPage().

Referenced by FormInput(), GenerateDocument(), and SetPage().

00071 { if (x != m_page) m_bSetCookie = true; m_page = x; }

void IWeb::SetQty long  x  )  [inline]
 

Definition at line 75 of file IWeb.h.

References m_bSetCookie, m_qty, and SetQty().

Referenced by SetQty().

00075 { if (x != m_qty) m_bSetCookie = true; m_qty = x; }

void IWeb::SetTheCookie  ) 
 

Definition at line 292 of file IWeb.cpp.

References m_cookie_to_set, m_forum, m_index, m_message, m_page, m_qty, m_thread, m_usernum, and m_valid.

Referenced by CreateHeader().

00293 { 00294 char slask[1000]; 00295 sprintf(slask,"%ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld", 00296 m_usernum,m_valid,m_forum,m_thread,m_page,m_index,m_qty,m_message); 00297 SetCookie("ibc", slask); 00298 m_cookie_to_set = slask; 00299 }

void IWeb::SetThread long  x  )  [inline]
 

Definition at line 69 of file IWeb.h.

References m_bSetCookie, m_thread, and SetThread().

Referenced by SetThread().

00069 { if (x != m_thread) m_bSetCookie = true; m_thread = x; }

void IWeb::SetUsernum long  x  )  [inline]
 

Definition at line 63 of file IWeb.h.

References m_bSetCookie, m_usernum, and SetUsernum().

Referenced by SetUsernum().

00063 { if (x != m_usernum) m_bSetCookie = true; m_usernum = x; }

void IWeb::SetValid long  x  )  [inline]
 

Definition at line 65 of file IWeb.h.

References m_bSetCookie, m_valid, and SetValid().

Referenced by SetValid().

00065 { if (x != m_valid) m_bSetCookie = true; m_valid = x; }


Member Data Documentation

bool IWeb::m_bSetCookie [private]
 

Definition at line 82 of file IWeb.h.

Referenced by CreateHeader(), SetForum(), SetIndex(), SetMessage(), SetPage(), SetQty(), SetThread(), SetUsernum(), and SetValid().

std::string IWeb::m_cookie_to_set [private]
 

Definition at line 87 of file IWeb.h.

Referenced by GenerateDocument(), and SetTheCookie().

Database IWeb::m_db [private]
 

Definition at line 80 of file IWeb.h.

Referenced by FormInput(), GetDatabase(), and IWeb().

AccountForm IWeb::m_form1 [private]
 

Definition at line 89 of file IWeb.h.

Referenced by CreateHeader(), GenerateDocument(), and IWeb().

SettingsForm IWeb::m_form2 [private]
 

Definition at line 90 of file IWeb.h.

Referenced by GenerateDocument(), and IWeb().

ForumsForm IWeb::m_form3 [private]
 

Definition at line 91 of file IWeb.h.

Referenced by GenerateDocument(), and IWeb().

ThreadListForm IWeb::m_form4 [private]
 

Definition at line 92 of file IWeb.h.

Referenced by GenerateDocument(), and IWeb().

ViewThreadForm IWeb::m_form5 [private]
 

Definition at line 93 of file IWeb.h.

Referenced by GenerateDocument(), and IWeb().

NewThreadForm IWeb::m_form6 [private]
 

Definition at line 94 of file IWeb.h.

Referenced by GenerateDocument(), and IWeb().

NewMessageForm IWeb::m_form7 [private]
 

Definition at line 95 of file IWeb.h.

Referenced by GenerateDocument(), and IWeb().

EditMessageForm IWeb::m_form8 [private]
 

Definition at line 96 of file IWeb.h.

Referenced by GenerateDocument(), and IWeb().

long IWeb::m_forum [private]
 

Definition at line 100 of file IWeb.h.

Referenced by GenerateDocument(), GetForum(), ReadCookies(), SetForum(), and SetTheCookie().

long IWeb::m_image [private]
 

Definition at line 83 of file IWeb.h.

Referenced by CreateHeader(), FormInput(), and GenerateDocument().

bool IWeb::m_image_tn [private]
 

Definition at line 85 of file IWeb.h.

Referenced by CreateHeader(), FormInput(), and GenerateDocument().

long IWeb::m_index [private]
 

Definition at line 103 of file IWeb.h.

Referenced by GetIndex(), ReadCookies(), SetIndex(), and SetTheCookie().

SysLog IWeb::m_log [private]
 

Definition at line 81 of file IWeb.h.

Referenced by IWeb().

long IWeb::m_message [private]
 

Definition at line 105 of file IWeb.h.

Referenced by GenerateDocument(), GetMessage(), ReadCookies(), SetMessage(), and SetTheCookie().

bool IWeb::m_not_modified [private]
 

Definition at line 86 of file IWeb.h.

Referenced by CreateHeader(), and GenerateDocument().

long IWeb::m_page [private]
 

Definition at line 102 of file IWeb.h.

Referenced by GenerateDocument(), GetPage(), ReadCookies(), SetPage(), and SetTheCookie().

db::Image* IWeb::m_pImage [private]
 

Definition at line 84 of file IWeb.h.

Referenced by CreateHeader(), FormInput(), and GenerateDocument().

long IWeb::m_qty [private]
 

Definition at line 104 of file IWeb.h.

Referenced by GetQty(), ReadCookies(), SetQty(), and SetTheCookie().

long IWeb::m_thread [private]
 

Definition at line 101 of file IWeb.h.

Referenced by GenerateDocument(), GetThread(), ReadCookies(), SetTheCookie(), and SetThread().

long IWeb::m_usernum [private]
 

Definition at line 98 of file IWeb.h.

Referenced by FormInput(), GenerateDocument(), GetUsernum(), ReadCookies(), SetTheCookie(), and SetUsernum().

long IWeb::m_valid [private]
 

Definition at line 99 of file IWeb.h.

Referenced by FormInput(), GenerateDocument(), GetValid(), ReadCookies(), SetTheCookie(), and SetValid().


The documentation for this class was generated from the following files:
Generated on Sat Feb 12 00:14:57 2005 for IBank by doxygen 1.3.7