X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fwebcit.c;h=b702b3f626e90bf5246a790ede576b16825b28c7;hb=0f89947a2fdbf186228acb81b2355d86365adf82;hp=ffb40a9c72d20091a239f854eaafc9604b5a1a36;hpb=c2c0e5dde0db19cee987d703446f07383866a8e2;p=citadel.git
diff --git a/webcit/webcit.c b/webcit/webcit.c
index ffb40a9c7..b702b3f62 100644
--- a/webcit/webcit.c
+++ b/webcit/webcit.c
@@ -383,7 +383,6 @@ void output_headers( int do_httpheaders, /* 1 = output HTTP headers
}
if (do_htmlhead) {
- /* wprintf("\n"); */
begin_burst();
do_template("head");
}
@@ -391,11 +390,8 @@ void output_headers( int do_httpheaders, /* 1 = output HTTP headers
/* ICONBAR */
if (do_htmlhead) {
- if (WC->HaveInstantMessages) {
- wprintf("
\n");
- }
+
+ /* check for ImportantMessages (these display in a div overlaying the main screen) */
if (strlen(WC->ImportantMessage) > 0) {
wprintf("\n");
embed_room_banner(NULL, navbar_default);
@@ -433,24 +433,12 @@ void http_redirect(char *whichpage) {
wprintf("URI: %s\r\n", whichpage);
wprintf("Content-type: text/html; charset=utf-8\r\n\r\n");
wprintf("");
- wprintf("Go
here.", whichpage);
+ wprintf("Go
here.", whichpage);
wprintf("\n");
}
-void check_for_instant_messages()
-{
- char buf[SIZ];
-
- serv_puts("NOOP");
- serv_getln(buf, sizeof buf);
- if (buf[3] == '*') WC->HaveInstantMessages = 1;
-}
-
-
-
-
/*
* Output a piece of content to the web browser
*/
@@ -706,17 +694,17 @@ void url_do_template(void) {
* Offer to make any page the user's "start page."
*/
void offer_start_page(void) {
- wprintf("
this_page);
wprintf("\">");
wprintf(_("Make this my start page"));
wprintf("");
/*
- wprintf("
wc_roomname);
wprintf("\" title=\"RSS 2.0 feed for ");
escputs(WC->wc_roomname);
- wprintf("\">\n");
+ wprintf("\">
\n");
*/
}
@@ -824,6 +812,85 @@ void end_ajax_response(void) {
wDumpContent(0);
}
+void ajax_servcmd(void)
+{
+ char buf[1024];
+ char gcontent[1024];
+ char *junk;
+ size_t len;
+
+ begin_ajax_response();
+
+ serv_printf("%s", bstr("g_cmd"));
+ serv_getln(buf, sizeof buf);
+ wprintf("%s\n", buf);
+
+ if (buf[0] == '8') {
+ serv_printf("\n\n000");
+ }
+ if ((buf[0] == '1') || (buf[0] == '8')) {
+ while (serv_getln(gcontent, sizeof gcontent), strcmp(gcontent, "000")) {
+ wprintf("%s\n", gcontent);
+ }
+ wprintf("000");
+ }
+ if (buf[0] == '4') {
+ text_to_server(bstr("g_input"), 0);
+ serv_puts("000");
+ }
+ if (buf[0] == '6') {
+ len = atol(&buf[4]);
+ junk = malloc(len);
+ serv_read(junk, len);
+ free(junk);
+ }
+ if (buf[0] == '7') {
+ len = atol(&buf[4]);
+ junk = malloc(len);
+ memset(junk, 0, len);
+ serv_write(junk, len);
+ free(junk);
+ }
+
+ end_ajax_response();
+
+ /* This is kind of an ugly hack, but this is the only place it can go.
+ * If the command was GEXP, then the instant messenger window must be
+ * running, so reset the "last_pager_check" watchdog timer so
+ * that page_popup() doesn't try to open it a second time.
+ */
+ if (!strncasecmp(bstr("g_cmd"), "GEXP", 4)) {
+ WC->last_pager_check = time(NULL);
+ }
+}
+
+
+/*
+ * Helper function for the asynchronous check to see if we need
+ * to open the instant messenger window.
+ */
+void seconds_since_last_gexp(void)
+{
+ char buf[256];
+
+ begin_ajax_response();
+ if ( (time(NULL) - WC->last_pager_check) < 30) {
+ wprintf("NO\n");
+ }
+ else {
+ serv_puts("NOOP");
+ serv_getln(buf, sizeof buf);
+ if (buf[3] == '*') {
+ wprintf("YES");
+ }
+ else {
+ wprintf("NO");
+ }
+ }
+ end_ajax_response();
+}
+
+
/*
@@ -850,8 +917,8 @@ void session_loop(struct httprequest *req)
char *content = NULL;
char *content_end = NULL;
struct httprequest *hptr;
- char browser_host[SIZ];
- char user_agent[SIZ];
+ char browser_host[256];
+ char user_agent[256];
int body_start = 0;
int is_static = 0;
@@ -872,11 +939,11 @@ void session_loop(struct httprequest *req)
safestrncpy(c_httpauth_string, "", sizeof c_httpauth_string);
safestrncpy(c_httpauth_user, DEFAULT_HTTPAUTH_USER, sizeof c_httpauth_user);
safestrncpy(c_httpauth_pass, DEFAULT_HTTPAUTH_PASS, sizeof c_httpauth_pass);
+ strcpy(browser_host, "");
WC->upload_length = 0;
WC->upload = NULL;
WC->vars = NULL;
-
WC->is_wap = 0;
hptr = req;
@@ -956,6 +1023,13 @@ void session_loop(struct httprequest *req)
else if (!strncasecmp(buf, "Host: ", 6)) {
safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
}
+ else if (!strncasecmp(buf, "X-Forwarded-For: ", 17)) {
+ safestrncpy(browser_host, &buf[17], sizeof browser_host);
+ while (num_tokens(browser_host, ',') > 1) {
+ remove_token(browser_host, 0, ',');
+ }
+ striplt(browser_host);
+ }
/* Only WAP gateways explicitly name this content-type */
else if (strstr(buf, "text/vnd.wap.wml")) {
WC->is_wap = 1;
@@ -1049,7 +1123,16 @@ void session_loop(struct httprequest *req)
else {
WC->connected = 1;
serv_getln(buf, sizeof buf); /* get the server welcome message */
- locate_host(browser_host, WC->http_sock);
+
+ /* From what host is our user connecting? Go with
+ * the host at the other end of the HTTP socket,
+ * unless we are following X-Forwarded-For: headers
+ * and such a header has already turned up something.
+ */
+ if ( (!follow_xff) || (strlen(browser_host) == 0) ) {
+ locate_host(browser_host, WC->http_sock);
+ }
+
get_serv_info(browser_host, user_agent);
if (serv_info.serv_rev_level < MINIMUM_CIT_VERSION) {
wprintf(_("You are connected to a Citadel "
@@ -1169,11 +1252,6 @@ void session_loop(struct httprequest *req)
}
}
- /*
- * If there are instant messages waiting, retrieve them for display.
- */
- check_for_instant_messages();
-
if (!strcasecmp(action, "image")) {
output_image();
@@ -1203,10 +1281,20 @@ void session_loop(struct httprequest *req)
display_main_menu();
} else if (!strcasecmp(action, "who")) {
who();
+ } else if (!strcasecmp(action, "sslg")) {
+ seconds_since_last_gexp();
} else if (!strcasecmp(action, "who_inner_html")) {
begin_ajax_response();
who_inner_div();
end_ajax_response();
+ } else if (!strcasecmp(action, "iconbar_ajax_menu")) {
+ begin_ajax_response();
+ do_iconbar();
+ end_ajax_response();
+ } else if (!strcasecmp(action, "iconbar_ajax_rooms")) {
+ begin_ajax_response();
+ do_iconbar_roomlist();
+ end_ajax_response();
} else if (!strcasecmp(action, "knrooms")) {
knrooms();
} else if (!strcasecmp(action, "gotonext")) {
@@ -1237,6 +1325,10 @@ void session_loop(struct httprequest *req)
embed_message(arg1);
} else if (!strcasecmp(action, "printmsg")) {
print_message(arg1);
+ } else if (!strcasecmp(action, "msgheaders")) {
+ display_headers(arg1);
+ } else if (!strcasecmp(action, "wiki")) {
+ display_wiki_page(arg1, arg2);
} else if (!strcasecmp(action, "display_enter")) {
display_enter();
} else if (!strcasecmp(action, "post")) {
@@ -1284,7 +1376,7 @@ void session_loop(struct httprequest *req)
} else if (!strcasecmp(action, "editinfo")) {
save_edit(_("Room info"), "EINF 1", 1);
} else if (!strcasecmp(action, "display_editbio")) {
- sprintf(buf, "RBIO %s", WC->wc_username);
+ sprintf(buf, "RBIO %s", WC->wc_fullname);
display_edit(_("Your bio"), "NOOP", buf, "editbio", 3);
} else if (!strcasecmp(action, "editbio")) {
save_edit(_("Your bio"), "EBIO", 0);
@@ -1297,13 +1389,13 @@ void session_loop(struct httprequest *req)
} else if (!strcasecmp(action, "display_editpic")) {
display_graphics_upload(_("your photo"),
"UIMG 0|_userpic_",
- "/editpic");
+ "editpic");
} else if (!strcasecmp(action, "editpic")) {
do_graphics_upload("UIMG 1|_userpic_");
} else if (!strcasecmp(action, "display_editroompic")) {
display_graphics_upload(_("the icon for this room"),
"UIMG 0|_roompic_",
- "/editroompic");
+ "editroompic");
} else if (!strcasecmp(action, "editroompic")) {
do_graphics_upload("UIMG 1|_roompic_");
} else if (!strcasecmp(action, "delete_floor")) {
@@ -1317,7 +1409,7 @@ void session_loop(struct httprequest *req)
bstr("which_floor"));
display_graphics_upload(_("the icon for this floor"),
buf,
- "/editfloorpic");
+ "editfloorpic");
} else if (!strcasecmp(action, "editfloorpic")) {
sprintf(buf, "UIMG 1|_floorpic_|%s",
bstr("which_floor"));
@@ -1359,6 +1451,8 @@ void session_loop(struct httprequest *req)
display_generic();
} else if (!strcasecmp(action, "do_generic")) {
do_generic();
+ } else if (!strcasecmp(action, "ajax_servcmd")) {
+ ajax_servcmd();
} else if (!strcasecmp(action, "display_menubar")) {
display_menubar(1);
} else if (!strcasecmp(action, "mimepart")) {
@@ -1377,8 +1471,6 @@ void session_loop(struct httprequest *req)
create_user();
} else if (!strcasecmp(action, "changeview")) {
change_view();
- } else if (!strcasecmp(action, "do_stuff_to_msgs")) {
- do_stuff_to_msgs();
} else if (!strcasecmp(action, "change_start_page")) {
change_start_page();
} else if (!strcasecmp(action, "display_floorconfig")) {
@@ -1405,8 +1497,6 @@ void session_loop(struct httprequest *req)
begin_ajax_response();
summary_inner_div();
end_ajax_response();
- } else if (!strcasecmp(action, "iconbar")) {
- do_iconbar();
} else if (!strcasecmp(action, "display_customize_iconbar")) {
display_customize_iconbar();
} else if (!strcasecmp(action, "commit_iconbar")) {
@@ -1429,6 +1519,8 @@ void session_loop(struct httprequest *req)
recp_autocomplete(bstr("cc"));
} else if (!strcasecmp(action, "bcc_autocomplete")) {
recp_autocomplete(bstr("bcc"));
+ } else if (!strcasecmp(action, "set_floordiv_expanded")) {
+ set_floordiv_expanded(arg1);
} else if (!strcasecmp(action, "diagnostics")) {
output_headers(1, 1, 1, 0, 0, 0);
wprintf("Session: %d
\n", WC->wc_session);
@@ -1457,5 +1549,4 @@ SKIP_ALL_THIS_CRAP:
free(WC->upload);
WC->upload_length = 0;
}
-
}