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

html.cpp

Go to the documentation of this file.
00001 // html.cpp 00002 /* 00003 Copyright (C) 2001-2004 Anders Hedstrom (grymse@alhem.net) 00004 00005 This program is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU General Public License 00007 as published by the Free Software Foundation; either version 2 00008 of the License, or (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 #ifdef WIN32 00020 #include <Config-win.h> 00021 static int getpid() { return 0; } 00022 #endif 00023 #include <stdio.h> 00024 #include <stdlib.h> 00025 #ifndef WIN32 00026 #include <unistd.h> 00027 #endif 00028 #include <string> 00029 #include <libcgi++.h> 00030 00031 #include "dbd.h" 00032 00033 #include "html.h" 00034 00035 00036 void error(char *s) 00037 { 00038 fprintf(out,"\n"); // End of http header 00039 00040 fprintf(out,"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\">\n"); 00041 fflush(out); 00042 fprintf(out,"<html><head><title>Error</title>"); 00043 fprintf(out,"<link rel=\"STYLESHEET\" href=\"/style/dbd.css\" type=\"text/css\">"); 00044 fprintf(out,"<link rel='SHORTCUT ICON' href='/favicon.ico'>"); 00045 fprintf(out,"</head>\n"); 00046 fprintf(out,"<body> <h1>Error</h1> This is the text of the error message: '%s' </body></html>\n",s); 00047 fflush(out); 00048 #ifndef WIN32 00049 exit(-1); 00050 #endif 00051 } 00052 00053 void header_top(char *s,long useronline) 00054 { 00055 fprintf(out,"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\">\n"); 00056 fflush(out); 00057 fprintf(out,"<html><head><base target=rf><title>%s</title>",s); 00058 fprintf(out,"<link rel=\"STYLESHEET\" href=\"/style/dbd.css\" type=\"text/css\">"); 00059 fprintf(out,"<link rel='SHORTCUT ICON' href='/favicon.ico'>"); 00060 fprintf(out,"</head>\n"); 00061 fprintf(out,"<body>"); // background=/image/dbdinnehall.gif BGPROPERTIES=fixed>\n"); 00062 if (*s) 00063 fprintf(out,"<h3>%s</h3>",s); 00064 } 00065 00066 00067 // normal page header when user is logged in 00068 00069 void header0(char *s,long useronline,Cookies *cs) 00070 { 00071 char slask[100]; 00072 00073 fprintf(out,"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\">\n"); 00074 fflush(out); 00075 fprintf(out,"<html><head><base target=rf><title>%s</title>",s); 00076 fprintf(out,"<link rel=\"STYLESHEET\" href=\"/style/dbd.css\" type=\"text/css\">"); 00077 fprintf(out,"<link rel='SHORTCUT ICON' href='/favicon.ico'>"); 00078 fprintf(out,"</head>\n"); 00079 fprintf(out,"<body>"); // background=/image/dbdinnehall.gif BGPROPERTIES=fixed>\n"); 00080 // new menu 00081 std::string td_class = "x"; 00082 std::string a_class = "x"; 00083 /* 00084 set_cookie(cs,"ui",0L); 00085 set_cookie(cs,"dba","0"); 00086 set_cookie(cs,"ed","0"); 00087 */ 00088 /* 00089 bool design = false; 00090 bool ui = (cs -> getvalue("ui",slask,100) && *slask && atoi(slask)) ? true : false; 00091 bool dba = (cs -> getvalue("dba",slask,100) && *slask && atoi(slask)) ? true : false; 00092 bool ed = (cs -> getvalue("ed",slask,100) && *slask && atoi(slask)) ? true : false; 00093 cs -> getvalue("show_page",slask,100); 00094 int show_page = atoi(slask); 00095 bool sql = show_page == 20; 00096 bool diagram = show_page == 38; 00097 bool ls = show_page == 22; 00098 if (sql || diagram || ls) 00099 { 00100 ui = dba = ed = false; 00101 } 00102 if (!ui && !dba && !ed && !sql && !diagram && !ls) 00103 { 00104 design = true; 00105 } 00106 */ 00107 cs -> getvalue("flik",slask,20); 00108 int flik = atoi(slask); 00109 fprintf(out,"<table cellpadding=0 cellspacing=0><tr>"); 00110 fprintf(out,"<td class=mbeg>&nbsp;</td>"); 00111 00112 // flik 2 00113 // td_class = design ? "y" : "x"; 00114 td_class = (flik == 2) ? "y" : "x"; 00115 fprintf(out,"<td class=%s><a class=%s href=\"/cgi-bin/dbd/dbd?design=0\">design</a></td>",td_class.c_str(),a_class.c_str()); 00116 // flik 3 - edit data 00117 // td_class = ed ? "y" : "x"; 00118 td_class = (flik == 3) ? "y" : "x"; 00119 fprintf(out,"<td class=%s><a class=%s href=\"/cgi-bin/dbd/dbd?ed=0\">edit</a></td>",td_class.c_str(),a_class.c_str()); 00120 // flik 4 00121 // td_class = diagram ? "y" : "x"; 00122 td_class = (flik == 4) ? "y" : "x"; 00123 fprintf(out,"<td class=%s><a class=%s href=\"/cgi-bin/dbd/dbd?diagram=0\">diagram</a></td>",td_class.c_str(),a_class.c_str()); 00124 // flik 5 - generate sql 00125 // td_class = sql ? "y" : "x"; 00126 td_class = (flik == 5) ? "y" : "x"; 00127 fprintf(out,"<td class=%s><a class=%s href=\"/cgi-bin/dbd/dbd?sql=1\">code</a></td>",td_class.c_str(),a_class.c_str()); 00128 // flik 7 - db access 00129 // td_class = dba ? "y" : "x"; 00130 td_class = (flik == 7) ? "y" : "x"; 00131 fprintf(out,"<td class=%s><a class=%s href=\"/cgi-bin/dbd/dbd?dba=0\">share</a></td>",td_class.c_str(),a_class.c_str()); 00132 // flik 8 00133 // td_class = ls ? "y" : "x"; 00134 // td_class = (flik == 8) ? "y" : "x"; 00135 // fprintf(out,"<td class=%s><a class=%s href=\"/cgi-bin/dbd/dbd?ls=0\">live&nbsp;sync</a></td>",td_class.c_str(),a_class.c_str()); 00136 // flik 10 00137 td_class = (flik == 10) ? "y" : "x"; 00138 fprintf(out,"<td class='%s'><a class='%s' href='/cgi-bin/dbd/dbd?import=0'>import</a></td>",td_class.c_str(),a_class.c_str()); 00139 00140 // flik 6 - user info 00141 // td_class = ui ? "y" : "x"; 00142 td_class = (flik == 6) ? "y" : "x"; 00143 fprintf(out,"<td class=%s><a class=%s href=\"/cgi-bin/dbd/dbd?ui=0\">settings</a></td>",td_class.c_str(),a_class.c_str()); 00144 // flik 9 00145 td_class = "x"; 00146 fprintf(out,"<td class=%s><a target=_top class=%s href=\"/cgi-bin/dbd/dbd?logout=0\">logout</a></td>",td_class.c_str(),a_class.c_str()); 00147 00148 fprintf(out,"</tr></table>"); 00149 fprintf(out,"<div style=\"width: 100%; height: 8px; background: #c0c0c0\">"); 00150 fprintf(out,"</div>"); 00151 fprintf(out,"<div style=\"width: 100%; height: 4px; background: #ffffff\">"); 00152 fprintf(out,"</div>"); 00153 // end of new menu 00154 fprintf(out,"<div style=\"padding: 5px;\">"); 00155 00156 if (*s) 00157 fprintf(out,"<h3>%s</h3>",s); 00158 } 00159 00160 00161 // top header (useronline = 1), login header, new user header 00162 00163 void header(char *s,long useronline) 00164 { 00165 fprintf(out,"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\">\n"); 00166 fflush(out); 00167 fprintf(out,"<html><head><base target=rf><title>%s</title>",s); 00168 // if (*s) 00169 // fprintf(out,"<title>%s: %s</title>",TITLE,s); 00170 // else 00171 // fprintf(out,"<title>%s</title>",TITLE); 00172 fprintf(out,"<link rel=\"STYLESHEET\" href=\"/style/dbd.css\" type=\"text/css\">"); 00173 fprintf(out,"<link rel='SHORTCUT ICON' href='/favicon.ico'>"); 00174 fprintf(out,"</head>\n"); 00175 fprintf(out,"<body>"); // bgcolor=\"#66ddfe\">"); 00176 fprintf(out,"<table width=\"100%%\" cellpadding=0 cellspacing=0><tr><td valign=middle>"); 00177 if (*s) 00178 fprintf(out,"<h1>%s: %s</h1>",TITLE,s); 00179 else 00180 fprintf(out,"<h1>%s</h1>",TITLE); 00181 // fprintf(out,"<img src=/image/dbdlogo.gif>"); 00182 fprintf(out,"</td>"); 00183 fprintf(out,"<td valign=top align=right>"); 00184 // fprintf(out,"<form action=/cgi-bin/dbd/dbd method=post>"); 00185 // fprintf(out,"<input type=submit name=logout value=\" Logout \">"); 00186 // fprintf(out,"</form>"); 00187 00188 // useronline = 1 design 00189 // 2 db access 00190 // 3 user info 00191 // 4 - 00192 // 5 edit data 00193 // 6 generate sql 00194 // 00195 00196 if (useronline) 00197 { 00198 useronline = 999; 00199 fprintf(out,"[\n"); 00200 if (useronline == 1) 00201 fprintf(out,"design\n"); 00202 else 00203 fprintf(out,"<a href=\"/cgi-bin/dbd/dbd?design=0\">design</a>\n"); 00204 fprintf(out,"|\n"); 00205 fprintf(out,"<a href=\"/cgi-bin/dbd/dbd?ed=0\">edit&nbsp;data</a>\n"); 00206 fprintf(out,"|\n"); 00207 fprintf(out,"<a href=\"/cgi-bin/dbd/dbd?sql=1\">generate&nbsp;sql</a>\n"); 00208 fprintf(out,"|\n"); 00209 fprintf(out,"<a href=\"/cgi-bin/dbd/dbd?diagram=0\">diagram</a>\n"); 00210 fprintf(out,"|\n"); 00211 if (useronline == 2) 00212 fprintf(out,"db&nbsp;access\n"); 00213 else 00214 fprintf(out,"<a href=\"/cgi-bin/dbd/dbd?dba=0\">db&nbsp;access</a>\n"); 00215 fprintf(out,"|\n"); 00216 if (useronline == 3) 00217 fprintf(out,"user&nbsp;info\n"); 00218 else 00219 fprintf(out,"<a href=\"/cgi-bin/dbd/dbd?ui=0\">user&nbsp;info</a>\n"); 00220 fprintf(out,"|\n"); 00221 fprintf(out,"<a target=_top href=\"/cgi-bin/dbd/dbd?logout=0\">logout</a>\n"); 00222 fprintf(out,"]"); 00223 fprintf(out,"<br>"); 00224 fprintf(out,"[ <a href=\"/cgi-bin/dbd/dbd?ls=0\">live&nbsp;sync</a> ]"); 00225 } 00226 fprintf(out,"</td></tr></table>"); 00227 } 00228 00229 void nullheader(char *s,long useronline) 00230 { 00231 fprintf(out,"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\">\n"); 00232 fflush(out); 00233 fprintf(out,"<html><head><title>%s</title>",s); 00234 // if (*s) 00235 // fprintf(out,"<title>%s: %s</title>",TITLE,s); 00236 // else 00237 // fprintf(out,"<title>%s</title>",TITLE); 00238 fprintf(out,"<link rel=\"STYLESHEET\" href=\"/style/dbd.css\" type=\"text/css\">"); 00239 fprintf(out,"<link rel='SHORTCUT ICON' href='/favicon.ico'>"); 00240 fprintf(out,"</head>\n"); 00241 fprintf(out,"<body style=\"padding: 10px;\">"); // bgcolor=\"#66ddfe\">"); 00242 fprintf(out,"<table width=\"100%%\" cellpadding=0 cellspacing=0><tr><td valign=middle>"); 00243 if (*s) 00244 fprintf(out,"<h1>%s: %s</h1>",TITLE,s); 00245 else 00246 fprintf(out,"<h1>%s</h1>",TITLE); 00247 // fprintf(out,"<img src=/image/dbdlogo.gif>"); 00248 fprintf(out,"</td>"); 00249 fprintf(out,"<td valign=top align=right>"); 00250 // fprintf(out,"<form action=/cgi-bin/dbd/dbd method=post>"); 00251 // fprintf(out,"<input type=submit name=logout value=\" Logout \">"); 00252 // fprintf(out,"</form>"); 00253 00254 // useronline = 1 design 00255 // 2 db access 00256 // 3 user info 00257 // 4 - 00258 // 5 edit data 00259 // 6 generate sql 00260 // 00261 00262 if (useronline) 00263 { 00264 useronline = 999; 00265 fprintf(out,"[\n"); 00266 if (useronline == 1) 00267 fprintf(out,"design\n"); 00268 else 00269 fprintf(out,"<a href=\"/cgi-bin/dbd/dbd?design=0\">design</a>\n"); 00270 fprintf(out,"|\n"); 00271 fprintf(out,"<a href=\"/cgi-bin/dbd/dbd?ed=0\">edit&nbsp;data</a>\n"); 00272 fprintf(out,"|\n"); 00273 fprintf(out,"<a href=\"/cgi-bin/dbd/dbd?sql=1\">generate&nbsp;sql</a>\n"); 00274 fprintf(out,"|\n"); 00275 fprintf(out,"<a href=\"/cgi-bin/dbd/dbd?diagram=0\">diagram</a>\n"); 00276 fprintf(out,"|\n"); 00277 if (useronline == 2) 00278 fprintf(out,"db&nbsp;access\n"); 00279 else 00280 fprintf(out,"<a href=\"/cgi-bin/dbd/dbd?dba=0\">db&nbsp;access</a>\n"); 00281 fprintf(out,"|\n"); 00282 if (useronline == 3) 00283 fprintf(out,"user&nbsp;info\n"); 00284 else 00285 fprintf(out,"<a href=\"/cgi-bin/dbd/dbd?ui=0\">user&nbsp;info</a>\n"); 00286 fprintf(out,"|\n"); 00287 fprintf(out,"<a target=_top href=\"/cgi-bin/dbd/dbd?logout=0\">logout</a>\n"); 00288 fprintf(out,"]"); 00289 fprintf(out,"<br>"); 00290 fprintf(out,"[ <a href=\"/cgi-bin/dbd/dbd?ls=0\">live&nbsp;sync</a> ]"); 00291 } 00292 fprintf(out,"</td></tr></table>"); 00293 } 00294 00295 void footer() 00296 { 00297 fprintf(out,"<br><br>[\n"); 00298 fprintf(out,"<a target=_top href=\"/cgi-bin/dbd/dbd?repair=0\">repair frames</a>\n]<br>"); 00299 fprintf(out,"<br>"); 00300 fprintf(out,"</div>"); // padding 5px 00301 fprintf(out,"</body></html>\n"); 00302 } 00303 00304 // images 00305 00306 void iplus() 00307 { 00308 fprintf(out,"<img src='/image/iplus-cont-0.gif' width=19 height=16 align=texttop border=0>"); 00309 } 00310 00311 void iplusend() 00312 { 00313 fprintf(out,"<img src='/image/iplus-end-0.gif' width=19 height=16 align=texttop border=0>"); 00314 } 00315 00316 void iexpanded() 00317 { 00318 fprintf(out,"<img src='/image/iminus-cont-0.gif' width=19 height=16 align=texttop border=0>"); 00319 } 00320 00321 void inotexpanded() 00322 { 00323 fprintf(out,"<img src='/image/iplus-cont-0.gif' width=19 height=16 align=texttop border=0>"); 00324 } 00325 00326 void iclosed() 00327 { 00328 fprintf(out,"<img src='/image/ifolder-closed-0.gif' width=16 height=16 align=texttop border=0>"); 00329 } 00330 00331 void iminus() 00332 { 00333 fprintf(out,"<img src='/image/iminus-cont-0.gif' width=19 height=16 align=texttop border=0>"); 00334 } 00335 00336 void iminusend() 00337 { 00338 fprintf(out,"<img src='/image/iminus-end-0.gif' width=19 height=16 align=texttop border=0>"); 00339 } 00340 00341 void iopen() 00342 { 00343 fprintf(out,"<img src='/image/ifolder-open-0.gif' width=16 height=16 align=texttop border=0>"); 00344 } 00345 00346 void ivertline() 00347 { 00348 fprintf(out,"<img src='/image/ivert-line-0.gif' width=19 height=16 align=texttop border=0>"); 00349 } 00350 00351 void ibranchcont() 00352 { 00353 fprintf(out,"<img src='/image/ibranch-cont-0.gif' width=19 height=16 align=texttop border=0>"); 00354 } 00355 00356 void ibranchend() 00357 { 00358 fprintf(out,"<img src='/image/ibranch-end-0.gif' width=19 height=16 align=texttop border=0>"); 00359 } 00360 00361 void iglobe() 00362 { 00363 fprintf(out,"<img src='/image/globe.gif' width=16 height=16 align=texttop border=0>"); 00364 } 00365 00366 void iglobe0() 00367 { 00368 fprintf(out,"<img src='/image/iglobe-0.gif' width=16 height=16 align=texttop border=0>"); 00369 } 00370 00371 void ithumbsup() 00372 { 00373 fprintf(out,"<img src='/image/thumbsup2.gif' height=16 align=texttop border=0>"); 00374 } 00375 00376 void ithumbsdown() 00377 { 00378 fprintf(out,"<img src='/image/thumbsdn2.gif' height=16 align=texttop border=0>"); 00379 } 00380 00381 void ipascal() 00382 { 00383 fprintf(out,"<img src='/image/pascal.gif' height=16 align=texttop border=0>"); 00384 } 00385 00386 void iempty() 00387 { 00388 fprintf(out,"<img src='/image/iempty.gif' height=16 align=texttop border=0>"); 00389 }

Generated on Thu Feb 10 22:42:34 2005 for Distributed URL Classification Tool by doxygen 1.3.7