* added Date: and Last-Modified: headers to HTTP output
authorArt Cancro <ajc@citadel.org>
Sun, 7 May 2000 23:46:55 +0000 (23:46 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 7 May 2000 23:46:55 +0000 (23:46 +0000)
* masquerade room/host screen now runs in wholist window, and returns to it

webcit/ChangeLog
webcit/tools.c
webcit/webcit.c
webcit/webcit.h
webcit/who.c

index 1075ca42a2e2a54787c79cef30b8f357a3417279..16a9f99e70303df7eebbefe146a7d597dbd2d085 100644 (file)
@@ -1,4 +1,8 @@
 $Log$
+Revision 211.17  2000/05/07 23:46:55  ajc
+* added Date: and Last-Modified: headers to HTTP output
+* masquerade room/host screen now runs in wholist window, and returns to it
+
 Revision 211.16  2000/05/02 17:32:06  ajc
 * Font related changes to html
 
@@ -431,3 +435,4 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index 9216105fc4269073e708964272a1f91532bab2c9..d8204f93e25ce74ccd055b3d66c29958e5705f30 100644 (file)
 #include "webcit.h"
 
 
+char *ascmonths[] = {
+       "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+       "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
+
+char *ascdays[] = {
+       "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+};
 
 
 char *safestrncpy(char *dest, const char *src, size_t n)
@@ -139,11 +147,6 @@ char ch;
 void fmt_date(char *buf, time_t thetime) {
        struct tm *tm;
 
-       char *ascmonths[] = {
-               "Jan", "Feb", "Mar", "Apr", "May", "Jun",
-               "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
-       };
-
        strcpy(buf, "");
        tm = localtime(&thetime);
 
@@ -156,3 +159,34 @@ void fmt_date(char *buf, time_t thetime) {
                ( (tm->tm_hour > 12) ? "pm" : "am" )
        );
 }
+
+
+
+
+/*
+ * Format a date/time stamp to the format used in HTTP headers
+ */
+void httpdate(char *buf, time_t thetime) {
+       struct tm *tm;
+
+       strcpy(buf, "");
+       tm = localtime(&thetime);
+
+       sprintf(buf, "%s, %02d %s %4d %02d:%02d:%02d",
+               ascdays[tm->tm_wday],
+               tm->tm_mday,
+               ascmonths[tm->tm_mon],
+               tm->tm_year + 1900,
+               tm->tm_hour,
+               tm->tm_min,
+               tm->tm_sec
+       );
+}
+
+
+
+
+
+
+
+
index e7d0047ff19f4be45f562cadd7cf73534d16cb4f..72da8375e86356ad457c45e97eccac94f0b449c4 100644 (file)
@@ -289,18 +289,23 @@ void output_headers(int controlcode)
        char cookie[256];
        int print_standard_html_head = 0;
        int refresh30 = 0;
+       char httpnow[256];
 
        print_standard_html_head        =       controlcode & 0x03;
        refresh30                       =       ((controlcode & 0x04) >> 2);
 
        wprintf("HTTP/1.0 200 OK\n");
 
+       httpdate(httpnow, time(NULL));
+
        if (print_standard_html_head > 0) {
                wprintf("Content-type: text/html\n");
                wprintf("Server: %s\n", SERVER);
                wprintf("Connection: close\n");
                wprintf("Pragma: no-cache\n");
                wprintf("Cache-Control: no-store\n");
+               wprintf("Date: %s\n"
+                       "Last-modified: %s\n", httpnow, httpnow);
        }
        stuff_to_cookie(cookie, WC->wc_session, WC->wc_username,
                        WC->wc_password, WC->wc_roomname);
@@ -398,6 +403,7 @@ void check_for_express_messages()
 void output_static(char *what)
 {
        char buf[4096];
+       char datebuf[256];
        long thisblock;
        FILE *fp;
        struct stat statbuf;
@@ -428,6 +434,13 @@ void output_static(char *what)
                bytes = statbuf.st_size;
                fprintf(stderr, "Static: %s, %ld bytes\n", what, bytes);
                wprintf("Content-length: %ld\n", (long) bytes);
+
+               httpdate(datebuf, time(NULL));
+               wprintf("Date: %s\n", datebuf);
+
+               httpdate(datebuf, statbuf.st_mtime);
+               wprintf("Last-modified: %s\n", datebuf);
+
                wprintf("\n");
                while (bytes > 0) {
                        thisblock = sizeof(buf);
index bdb0a081d60fda527e0f5107c2270de997305e28..72873a1f0c28c410e4f90c8437da776c22b36683 100644 (file)
@@ -257,4 +257,5 @@ void mime_parser(char *content,
                    void *cbcontent,                                                                char *cbtype,                                                                   size_t cblength)
 );
 void fmt_date(char *buf, time_t thetime);
+void httpdate(char *buf, time_t thetime);
 void end_webcit_session(void);
index b172f6b15fd7beb9501c87c65fc14a6f2b2e08fd..8fa8ed8ff916d848b1c3e162abc53e841889c05b 100644 (file)
@@ -124,7 +124,7 @@ void whobbs(void)
                        }
                        if (wlist->sessionnum == serv_info.serv_pid) {
                                wprintf(" <A HREF=\"/edit_me\" "
-                                       "TARGET=\"_parent\">(edit)</A>");
+                                       ">(edit)</A>");
                        }
                        /* username */
                        wprintf("</TD>\n\t<TD>");
@@ -145,6 +145,7 @@ void whobbs(void)
        wprintf("<TABLE BORDER=0 BGCOLOR=\"#003399\">\n<TR><TD ALIGN=center VALIGN=center CELLPADING=20>\n");
        wprintf("<B><A HREF=\"javascript:window.close();\">Close window</A></B>\n");
        wprintf("</TD></TR>\n</TABLE></FONT>\n</CENTER>");
+
        wDumpContent(1);
 }
 
@@ -183,7 +184,7 @@ void edit_me(void)
                whobbs();
        } else {
 
-               output_headers(1);
+               output_headers(3);
 
                wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
                wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");