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

BaseForm Class Reference

#include <BaseForm.h>

Inheritance diagram for BaseForm:

Inheritance graph
[legend]
Collaboration diagram for BaseForm:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 BaseForm (Web *, const std::string &)
 ~BaseForm ()
long AddImage (long num, const std::string &filename)
std::string GetMimeFromFilename (const std::string &)
std::string GetAccountName (db::Account &)
bool valid_email (const std::string &)
void viewtext (const std::string &, bool in_textarea=false)
void viewtn (long num)
void Navigator (long forum=0, long thread=0, long message=0)

Private Attributes

Mime m_mime

Detailed Description

File ......... BaseForm.h Published .... 2004-07-09 Author ....... grymse@alhem.net

Definition at line 33 of file BaseForm.h.


Constructor & Destructor Documentation

BaseForm::BaseForm Web *  pWeb,
const std::string &  x
 

File ......... BaseForm.cpp Published .... 2004-07-09 Author ....... grymse@alhem.net

Definition at line 40 of file BaseForm.cpp.

References BaseForm().

Referenced by BaseForm().

00040 : WebForm(pWeb,x) 00041 ,m_mime("/usr/local/apache/conf/mime.types") 00042 { 00043 }

BaseForm::~BaseForm  ) 
 

Definition at line 46 of file BaseForm.cpp.

00047 { 00048 }


Member Function Documentation

long BaseForm::AddImage long  num,
const std::string &  filename
 

Definition at line 51 of file BaseForm.cpp.

References AddImage().

Referenced by AddImage().

00052 { 00053 IWeb *pWeb = static_cast<IWeb *>(GetWeb()); 00054 Database& db = pWeb -> GetDatabase(); 00055 db::Image pic(&db); 00056 cgi::Base64 bomb; 00057 size_t x = 0; 00058 size_t y = 0; 00059 00060 unlink("/tmp/tn.gif"); 00061 unlink("/tmp/geometry"); 00062 { 00063 FILE *fil; 00064 char cmd[1000]; 00065 sprintf(cmd,"%s -verbose -geometry 128 %s /tmp/tn.gif 2>/tmp/geometry",_CONVERT,filename.c_str()); 00066 system( cmd ); 00067 if ((fil = fopen("/tmp/geometry", "rt")) != NULL) 00068 { 00069 fgets(cmd, 1000, fil); 00070 { 00071 cgi::Parse pa(cmd); 00072 pa.getword(cmd); // file=>file 00073 { 00074 pa.getword(); // type 00075 pa.getword(cmd); // geometry XxY 00076 { 00077 cgi::Parse pa(cmd,"x="); 00078 x = pa.getvalue(); 00079 y = pa.getvalue(); 00080 } 00081 } 00082 } 00083 fclose(fil); 00084 } 00085 } 00086 pic.owner = num; 00087 bomb.encode_from_file( (char *)filename.c_str(), pic.image_data); 00088 bomb.encode_from_file( "/tmp/tn.gif", pic.image_tn); 00089 pic.filename = filename; 00090 pic.xsize = x; 00091 pic.ysize = y; 00092 pic.modified = GetDate(); 00093 pic.save(); 00094 return pic.num; 00095 }

std::string BaseForm::GetAccountName db::Account &   ) 
 

Definition at line 116 of file BaseForm.cpp.

References GetAccountName(), and valid_email().

Referenced by GetAccountName().

00117 { 00118 char slask[1000]; 00119 if (account.show_email && valid_email(account.email)) 00120 { 00121 sprintf(slask,"<b>%s</b><br>&nbsp;(<a href=\"mailto:%s\">%s</a>)",account.name.c_str(),account.email.c_str(),account.email.c_str()); 00122 return slask; 00123 } 00124 sprintf(slask,"<b>%s</b>",account.name.c_str()); 00125 return slask; 00126 }

std::string BaseForm::GetMimeFromFilename const std::string &   ) 
 

Definition at line 98 of file BaseForm.cpp.

References Mime::GetMimeFromExtension(), GetMimeFromFilename(), and m_mime.

Referenced by IWeb::CreateHeader(), and GetMimeFromFilename().

00099 { 00100 std::string tmp; 00101 size_t x = 0; 00102 for (size_t i = 0; i < filename.size(); i++) 00103 { 00104 if (filename[i] >= 'A' && filename[i] <= 'Z') 00105 tmp += (char)(filename[i] + 32); 00106 else 00107 tmp += filename[i]; 00108 if (filename[i] == '.') 00109 x = i + 1; 00110 } 00111 std::string ext = filename.substr(x); 00112 return m_mime.GetMimeFromExtension(ext); 00113 }

void BaseForm::Navigator long  forum = 0,
long  thread = 0,
long  message = 0
 

Definition at line 172 of file BaseForm.cpp.

References Navigator().

Referenced by Navigator().

00173 { 00174 IWeb *pWeb = static_cast<IWeb *>(GetWeb()); 00175 Database& db = pWeb -> GetDatabase(); 00176 00177 printf("<div class=navigator>"); 00178 printf("<table cellpadding=0 cellspacing=0 width=\"100%%\"><tr><td>"); 00179 if (!nforum) 00180 { 00181 printf("<b>Forums</b>"); 00182 return; 00183 } 00184 db::Forum forum(db, nforum); 00185 printf("<a href=\"%s?page=3\">Forums</a>&nbsp;-&nbsp;",GetCgiName().c_str()); 00186 if (!nthread) 00187 { 00188 nbprintf("<b>%s</b>",forum.name.c_str()); 00189 return; 00190 } 00191 db::Thread thread(db, nthread); 00192 printf("<a href=\"%s?ForumsForm=select&forum=%ld\">",GetCgiName().c_str(),forum.num); 00193 nbprintf("%s</a> - ",forum.name.c_str()); 00194 if (!nmessage) 00195 { 00196 if (!thread.num) 00197 thread.title = "&lt;new topic>"; 00198 nbprintf("<b>%s</b>",thread.title.c_str()); 00199 return; 00200 } 00201 db::Message message(db, nmessage); 00202 printf("<a href=\"%s?ThreadListForm=view&thread=%ld\">",GetCgiName().c_str(),thread.num); 00203 nbprintf("%s</a> - ",thread.title.c_str()); 00204 { 00205 if (!message.num) 00206 message.title = "&lt;new message>"; 00207 nbprintf("<b>%s</b>",message.title.c_str()); 00208 } 00209 }

bool BaseForm::valid_email const std::string &   ) 
 

Definition at line 129 of file BaseForm.cpp.

References valid_email().

Referenced by GetAccountName(), and valid_email().

00130 { 00131 char *s = strstr(email.c_str(),"@"); 00132 if (s && strstr(s,".")) 00133 return true; 00134 return false; 00135 }

void BaseForm::viewtext const std::string &  ,
bool  in_textarea = false
 

Definition at line 138 of file BaseForm.cpp.

References viewtext().

Referenced by viewtext().

00139 { 00140 for (size_t i = 0; i < str.size(); i++) 00141 { 00142 if (str[i] == 13 && !in_textarea) 00143 { 00144 } 00145 else 00146 if (str[i] == 10 && !in_textarea) 00147 { 00148 printf("<br>"); 00149 } 00150 else 00151 if (str[i] == '<') 00152 { 00153 printf("&lt;"); 00154 } 00155 else 00156 if (str[i] == '&') 00157 { 00158 printf("&amp;"); 00159 } 00160 else 00161 { 00162 printf("%c",str[i]); 00163 } 00164 } 00165 if (!in_textarea) 00166 { 00167 printf("<br>"); 00168 } 00169 }

void BaseForm::viewtn long  num  ) 
 

Definition at line 212 of file BaseForm.cpp.

References viewtn().

Referenced by viewtn().

00213 { 00214 // IWeb *pWeb = static_cast<IWeb *>(GetWeb()); 00215 // Database& db = pWeb -> GetDatabase(); 00216 // db::Image image(db, num); 00217 00218 /* 00219 printf("<img"); 00220 printf(" onmouseout=\"return nd();\""); 00221 printf(" onmouseover=\"return overlib('<img src=%s?img=%ld>');\"", 00222 GetCgiName().c_str(), num); 00223 printf(" border=\"0\" src=\"%s?imgtn=%ld\" alt=\"Thumbnail\">", GetCgiName().c_str(), num); 00224 */ 00225 printf("<a class=tn href=\"%s?img=%ld\">",GetCgiName().c_str(),num); 00226 printf("<img border=\"0\" src=\"%s?imgtn=%ld\" alt=\"Thumbnail\">",GetCgiName().c_str(),num); 00227 /* 00228 printf("<img"); 00229 printf(" onmouseout=\"return nd();\""); 00230 printf(" onmouseover=\"return overlib('<img src=%s?img=%ld>', WRAP, ABOVE, FOLLOWMOUSE, 0, OFFSETX, 50);\"", 00231 GetCgiName().c_str(), num); 00232 printf(" border=\"0\" src=\"%s?imgtn=%ld\" alt=\"Thumbnail\">", GetCgiName().c_str(), num); 00233 */ 00234 printf("</a>"); 00235 }


Member Data Documentation

Mime BaseForm::m_mime [private]
 

Definition at line 49 of file BaseForm.h.

Referenced by GetMimeFromFilename().


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