userlist.c: added. This adds "userlist" and "show user" functions.
authorArt Cancro <ajc@citadel.org>
Mon, 14 Dec 1998 01:50:36 +0000 (01:50 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 14 Dec 1998 01:50:36 +0000 (01:50 +0000)
webcit/ChangeLog
webcit/Makefile.in
webcit/child.h
webcit/userlist.c [new file with mode: 0644]
webcit/webcit.c

index 6c53eb9e64af7c8163c8707e16bdb52ad29057c5..e42a7b9dc2dab111cc39a4007559809cb289342b 100644 (file)
@@ -7,6 +7,7 @@ Sun Dec 13 13:35:12 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
          and kill idle sessions.
        * messages.c: added "delete message" functionality
        * messages.c: added "move message" functionality
+       * userlist.c: added.  This adds "userlist" and "show user" functions.
 
 Fri Dec 11 21:14:36 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Brought over message reading and entry functions from old WebCit
index 1444065b831de5a50b77b32ee4cfa3b0fee11b49..fca74cf24b277bf2e52dc19c48aa23102a5a987e 100644 (file)
@@ -33,9 +33,9 @@ snprintf.o: snprintf.c
 
 
 webcit: webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o \
-       roomops.o tools.o messages.o
+       roomops.o tools.o messages.o userlist.o
        $(CC) webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o \
-       tools.o roomops.o messages.o -o webcit
+       tools.o roomops.o messages.o userlist.o -o webcit
 
 webcit.o: webcit.c webcit.h child.h
        $(CC) $(CFLAGS) $(DEFS) -c webcit.c
@@ -55,6 +55,9 @@ serv_func.o: serv_func.c webcit.h child.h
 who.o: who.c webcit.h child.h
        $(CC) $(CFLAGS) $(DEFS) -c who.c
 
+userlist.o: userlist.c webcit.h child.h
+       $(CC) $(CFLAGS) $(DEFS) -c userlist.c
+
 tools.o: tools.c webcit.h
        $(CC) $(CFLAGS) $(DEFS) -c tools.c
 
index 78bc3123651c00a9b6fa98770842c346a8ead2e8..e8e037681d249dfcc3b4db607cb7b95582460bff 100644 (file)
@@ -48,3 +48,5 @@ void confirm_delete_msg(void);
 void delete_msg(void);
 void confirm_move_msg(void);
 void move_msg(void);
+void userlist(void);
+void showuser(void);
diff --git a/webcit/userlist.c b/webcit/userlist.c
new file mode 100644 (file)
index 0000000..abe0971
--- /dev/null
@@ -0,0 +1,142 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <ctype.h>
+#include <string.h>
+#include <time.h>
+#include "webcit.h"
+#include "child.h"
+
+struct namelist {
+       struct namelist *next;
+       char name[32];
+       };
+
+/*
+ * display the userlist
+ */
+void userlist(void) { 
+       char buf[256];
+       char fl[256];
+       struct tm *tmbuf;
+       long lc;
+       struct namelist *bio = NULL;
+       struct namelist *bptr;
+       int has_bio;
+
+       serv_puts("LBIO");
+       serv_gets(buf);
+       if (buf[0]=='1') while (serv_gets(buf), strcmp(buf,"000")) {
+               bptr = (struct namelist *) malloc(sizeof(struct namelist));
+               bptr->next = bio;
+               strcpy(bptr->name, buf);
+               bio = bptr;
+               }
+
+
+        printf("HTTP/1.0 200 OK\n");
+        output_headers();
+        wprintf("<HTML><HEAD><TITLE>User list</TITLE>\n");
+        wprintf("</HEAD><BODY BACKGROUND=\"/image&name=background\" TEXT=\"#000000\" LINK=\"#004400\">\n");
+
+       serv_puts("LIST");
+       serv_gets(buf);
+       if (buf[0]!='1') {
+               wprintf("<EM>%s</EM><BR>\n",&buf[4]);
+               goto DONE;
+               }
+
+
+        wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
+        wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
+        wprintf("<B>User list for ");
+       escputs(serv_info.serv_humannode);
+        wprintf("</B></FONT></TD></TR></TABLE>\n");
+
+       wprintf("<CENTER><TABLE border>");
+       wprintf("<TR><TH>User Name</TH><TH>Number</TH><TH>Access Level</TH>");
+       wprintf("<TH>Last Call</TH><TH>Total Calls</TH><TH>Total Posts</TH></TR>\n");
+
+       while (serv_gets(buf), strcmp(buf,"000")) {
+               extract(fl,buf,0);
+               has_bio = 0;
+               for (bptr=bio; bptr!=NULL; bptr=bptr->next) {
+                       if (!strcasecmp(fl,bptr->name)) has_bio = 1;
+                       }
+               wprintf("<TR><TD>");
+               if (has_bio) {
+                       wprintf("<A HREF=\"/showuser&who=");
+                       urlescputs(fl);
+                       wprintf("\">");
+                       escputs(fl);
+                       wprintf("</A>");
+                       }
+               else {
+                       escputs(fl);
+                       }
+               wprintf("</TD><TD>%ld</TD><TD>%d</TD><TD>",
+                       extract_long(buf,2),
+                       extract_int(buf,1));
+               lc = extract_long(buf,3);
+               tmbuf = (struct tm *)localtime(&lc);
+               wprintf("%02d/%02d/%04d ",
+                       (tmbuf->tm_mon+1),
+                       tmbuf->tm_mday,
+                       (tmbuf->tm_year + 1900));
+               
+
+               wprintf("</TD><TD>%ld</TD><TD>%5ld</TD></TR>\n",
+                       extract_long(buf,4),extract_long(buf,5));
+
+               }
+       wprintf("</TABLE></CENTER>\n");
+DONE:   wprintf("</BODY></HTML>\n");
+        wDumpContent();
+       }
+
+
+/*
+ * Display (non confidential) information about a particular user
+ */
+void showuser(void) {
+       char who[256];
+       char buf[256];
+       int have_pic;
+
+        printf("HTTP/1.0 200 OK\n");
+        output_headers();
+        wprintf("<HTML><HEAD><TITLE>User profile</TITLE>\n");
+        wprintf("</HEAD><BODY BACKGROUND=\"/image&name=background\" TEXT=\"#000000\" LINK=\"#004400\">\n");
+
+
+        wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
+        wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>User profile");
+        wprintf("</B></FONT></TD></TR></TABLE>\n");
+
+       strcpy(who, bstr("who"));
+       serv_printf("OIMG _userpic_|%s", who);
+       serv_gets(buf);
+       if (buf[0]=='2') {
+               have_pic = 1;
+               serv_puts("CLOS");
+               serv_gets(buf);
+               }
+       else {
+               have_pic = 0;
+               }
+
+       wprintf("<CENTER><TABLE><TR><TD>");
+       if (have_pic == 1) {
+               wprintf("<IMG SRC=\"/image&name=_userpic_&parm=");
+               urlescputs(who);
+               wprintf("\">");
+               }
+       wprintf("</TD><TD><H1>%s</H1></TD></TR></TABLE></CENTER>\n",who);
+       serv_printf("RBIO %s",who);
+       serv_gets(buf);
+       if (buf[0]=='1') fmout(NULL);
+       wprintf("</BODY></HTML>\n");
+        wDumpContent();
+       }
index d5f931dfc0c1cc29aa4422b0357e1c02c2f118e9..c683e5082cb164b5a272a24eac884c330773137b 100644 (file)
@@ -595,6 +595,14 @@ fclose(fp);
                move_msg();
                }
 
+       else if (!strcasecmp(action, "userlist")) {
+               userlist();
+               }
+
+       else if (!strcasecmp(action, "showuser")) {
+               showuser();
+               }
+
        /* When all else fails... */
        else {
                printf("HTTP/1.0 200 OK\n");