* the exact minute. :)
*/
static char *unset = "; expires=28-May-1971 18:10:00 GMT";
-
+StrBuf *csslocal = NULL;
HashList *HandlerHash = NULL;
void WebcitAddUrlHandler(const char * UrlString,
do_template("head", NULL);
/* check for ImportantMessages (these display in a div overlaying the main screen) */
- if (!IsEmptyStr(WC->ImportantMessage)) {
+ if (!IsEmptyStr(WCC->ImportantMessage)) {
wprintf("<div id=\"important_message\">\n"
"<span class=\"imsg\">");
- escputs(WC->ImportantMessage);
+ StrEscAppend(WCC->WBuf, NULL, WCC->ImportantMessage, 0, 0);
wprintf("</span><br />\n"
"</div>\n"
);
- StrBufAppendPrintf(WCC->trailing_javascript,
- "setTimeout('hide_imsg_popup()', 5000); \n"
+ StrBufAppendBufPlain(WCC->trailing_javascript,
+ HKEY("setTimeout('hide_imsg_popup()', 5000); \n"),
+ 0
);
WCC->ImportantMessage[0] = 0;
}
-
+ else if (StrLength(WCC->ImportantMsg) > 0) {
+ wprintf("<div id=\"important_message\">\n"
+ "<span class=\"imsg\">");
+ StrEscAppend(WCC->WBuf, WCC->ImportantMsg, NULL, 0, 0);
+ wprintf("</span><br />\n"
+ "</div>\n"
+ );
+ StrBufAppendBufPlain(WCC->trailing_javascript,
+ HKEY("setTimeout('hide_imsg_popup()', 5000); \n"),
+ 0
+ );
+ FlushStrBuf(WCC->ImportantMsg);
+ }
if ( (WCC->logged_in) && (!unset_cookies) ) {
- //DoTemplate(HKEY("iconbar"), NULL, &NoCtx);
+ /*DoTemplate(HKEY("iconbar"), NULL, &NoCtx);*/
page_popup();
}
const StrBuf *MimeType;
const StrBuf *Tmpl = sbstr("template");
begin_burst();
- output_headers(0, 0, 0, 0, 1, 0);
MimeType = DoTemplate(SKEY(Tmpl), NULL, &NoCtx);
http_transmit_thing(ChrPtr(MimeType), 0);
}
}
case 1:
while (!Done) {
- StrBuf_ServGetlnBuffered(Buf);
+ StrBuf_ServGetln(Buf);
if ( (StrLength(Buf)==3) &&
!strcmp(ChrPtr(Buf), "000")) {
Done = 1;
}
- lprintf (1,"ajax: [%s]\n",ChrPtr(Buf));
StrBufAppendBuf(WCC->WBuf, Buf, 0);
StrBufAppendBufPlain(WCC->WBuf, HKEY("\n"), 0);
}
/*
* Entry point for WebCit transaction
*/
-void session_loop(HashList *HTTPHeaders,
- StrBuf *ReqLine,
+void session_loop(StrBuf *ReqLine,
StrBuf *request_method,
StrBuf *ReadBuf,
const char **Pos)
c_httpauth_pass = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_PASS));
WCC= WC;
- if (WCC->WBuf == NULL)
- WC->WBuf = NewStrBufPlain(NULL, 32768);
- FlushStrBuf(WCC->WBuf);
-
- if (WCC->HBuf == NULL)
- WCC->HBuf = NewStrBuf();
- FlushStrBuf(WCC->HBuf);
WCC->upload_length = 0;
WCC->upload = NULL;
}
- if (GetHash(HTTPHeaders, HKEY("COOKIE"), &vLine) &&
+ if (GetHash(WCC->headers, HKEY("COOKIE"), &vLine) &&
(vLine != NULL)){
cookie_to_stuff((StrBuf *)vLine, NULL,
c_username,
c_password,
c_roomname);
}
- if (GetHash(HTTPHeaders, HKEY("AUTHORIZATION"), &vLine) &&
+ if (GetHash(WCC->headers, HKEY("AUTHORIZATION"), &vLine) &&
(vLine!=NULL)) {
StrBufDecodeBase64((StrBuf*)vLine);
StrBufExtract_token(c_httpauth_user, (StrBuf*)vLine, 0, ':');
StrBufExtract_token(c_httpauth_pass, (StrBuf*)vLine, 1, ':');
}
- if (GetHash(HTTPHeaders, HKEY("CONTENT-LENGTH"), &vLine) &&
+ if (GetHash(WCC->headers, HKEY("CONTENT-LENGTH"), &vLine) &&
(vLine!=NULL)) {
ContentLength = StrToi((StrBuf*)vLine);
}
- if (GetHash(HTTPHeaders, HKEY("CONTENT-TYPE"), &vLine) &&
+ if (GetHash(WCC->headers, HKEY("CONTENT-TYPE"), &vLine) &&
(vLine!=NULL)) {
ContentType = (StrBuf*)vLine;
}
- if (GetHash(HTTPHeaders, HKEY("USER-AGENT"), &vLine) &&
+ if (GetHash(WCC->headers, HKEY("USER-AGENT"), &vLine) &&
(vLine!=NULL)) {
safestrncpy(user_agent, ChrPtr((StrBuf*)vLine), sizeof user_agent);
#ifdef TECH_PREVIEW
#endif
}
if ((follow_xff) &&
- GetHash(HTTPHeaders, HKEY("X-FORWARDED-HOST"), &vLine) &&
+ GetHash(WCC->headers, HKEY("X-FORWARDED-HOST"), &vLine) &&
(vLine != NULL)) {
WCC->http_host = (StrBuf*)vLine;
}
if ((StrLength(WCC->http_host) == 0) &&
- GetHash(HTTPHeaders, HKEY("HOST"), &vLine) &&
+ GetHash(WCC->headers, HKEY("HOST"), &vLine) &&
(vLine!=NULL)) {
WCC->http_host = (StrBuf*)vLine;
}
- if (GetHash(HTTPHeaders, HKEY("X-FORWARDED-FOR"), &vLine) &&
+ if (GetHash(WCC->headers, HKEY("X-FORWARDED-FOR"), &vLine) &&
(vLine!=NULL)) {
browser_host = (StrBuf*) vLine;
}
/* If the client sent a nonce that is incorrect, kill the request. */
- if (strlen(bstr("nonce")) > 0) {
+ if (havebstr("nonce")) {
lprintf(9, "Comparing supplied nonce %s to session nonce %ld\n",
bstr("nonce"), WCC->nonce);
if (ibstr("nonce") != WCC->nonce) {
if ( (!follow_xff) || (StrLength(browser_host) == 0) ) {
if (browser_host == NULL) {
browser_host = NewStrBuf();
- Put(HTTPHeaders, HKEY("FreeMeWithTheOtherHeaders"),
+ Put(WCC->headers, HKEY("FreeMeWithTheOtherHeaders"),
browser_host, HFreeStrBuf);
}
locate_host(browser_host, WCC->http_sock);
* our session's authentication.
*/
if (!strncasecmp(action, "groupdav", 8)) {
- groupdav_main(HTTPHeaders,
+ groupdav_main(WCC->headers,
ReqLine, request_method,
ContentType, /* do GroupDAV methods */
ContentLength, content, body_start);
* POST to the GroupDAV code as well.
*/
if ((strcasecmp(ChrPtr(request_method), "GET")) && (strcasecmp(ChrPtr(request_method), "POST"))) {
- groupdav_main(HTTPHeaders, ReqLine,
+ groupdav_main(WCC->headers, ReqLine,
request_method, ContentType, /** do GroupDAV methods */
ContentLength, content, body_start);
if (!WCC->logged_in) {
{
wcsession *WCC = WC;
if (WCC != NULL)
- return (!IsEmptyStr(WCC->ImportantMessage));
+ return ((!IsEmptyStr(WCC->ImportantMessage)) ||
+ (StrLength(WCC->ImportantMsg) > 0));
else
return 0;
}
wcsession *WCC = WC;
if (WCC != NULL) {
-/*
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType,
- WCC->ImportantMessage, 0);
-*/
- StrEscAppend(Target, NULL, WCC->ImportantMessage, 0, 0);
- WCC->ImportantMessage[0] = '\0';
+ if (!IsEmptyStr(WCC->ImportantMessage)) {
+ StrEscAppend(Target, NULL, WCC->ImportantMessage, 0, 0);
+ WCC->ImportantMessage[0] = '\0';
+ }
+ else if (StrLength(WCC->ImportantMsg) > 0) {
+ StrEscAppend(Target, WCC->ImportantMsg, NULL, 0, 0);
+ FlushStrBuf(WCC->ImportantMsg);
+ }
}
}
void tmplput_csslocal(StrBuf *Target, WCTemplputParams *TP)
{
- extern StrBuf *csslocal;
StrBufAppendBuf(Target,
csslocal, 0);
}
-
-
+extern char static_local_dir[PATH_MAX];
void
InitModule_WEBCIT
(void)
{
+ char dir[SIZ];
WebcitAddUrlHandler(HKEY("blank"), blank_page, ANONYMOUS);
WebcitAddUrlHandler(HKEY("do_template"), url_do_template, ANONYMOUS);
WebcitAddUrlHandler(HKEY("sslg"), seconds_since_last_gexp, AJAX);
RegisterNamespace("CSSLOCAL", 0, 0, tmplput_csslocal, CTX_NONE);
RegisterNamespace("IMPORTANTMESSAGE", 0, 0, tmplput_importantmessage, CTX_NONE);
RegisterNamespace("TRAILING_JAVASCRIPT", 0, 0, tmplput_trailing_javascript, CTX_NONE);
+
+ snprintf(dir, SIZ, "%s/static.local/webcit.css", static_local_dir);
+ if (!access(dir, R_OK)) {
+ lprintf(9, "Using local Stylesheet [%s]\n", dir);
+ csslocal = NewStrBufPlain(HKEY("<link href=\"static.local/webcit.css\" rel=\"stylesheet\" type=\"text/css\">"));
+ }
+ else
+ lprintf(9, "Didn't find site local Stylesheet [%s]\n", dir);
+
}
+
+void
+ServerStartModule_WEBCIT
+(void)
+{
+ HandlerHash = NewHash(1, NULL);
+}
+
+
+void
+ServerShutdownModule_WEBCIT
+(void)
+{
+ FreeStrBuf(&csslocal);
+ DeleteHash(&HandlerHash);
+}
+
+
+
+void
+SessionNewModule_WEBCIT
+(wcsession *sess)
+{
+ sess->ImportantMsg = NewStrBuf();
+ sess->WBuf = NewStrBuf();
+ sess->HBuf = NewStrBuf();
+}
+
+void
+SessionDetachModule_WEBCIT
+(wcsession *sess)
+{
+ if (StrLength(sess->WBuf) > SIZ * 30) /* Bigger than 120K? release. */
+ {
+ FreeStrBuf(&sess->WBuf);
+ sess->WBuf = NewStrBuf();
+ }
+ else
+ FlushStrBuf(sess->WBuf);
+ FlushStrBuf(sess->HBuf);
+}
+
+void
+SessionDestroyModule_WEBCIT
+(wcsession *sess)
+{
+ FreeStrBuf(&sess->WBuf);
+ FreeStrBuf(&sess->HBuf);
+ FreeStrBuf(&sess->UrlFragment1);
+ FreeStrBuf(&sess->UrlFragment2);
+ FreeStrBuf(&sess->UrlFragment3);
+ FreeStrBuf(&sess->UrlFragment4);
+ FreeStrBuf(&sess->ImportantMsg);
+}
+