]> code.citadel.org Git - citadel.git/blob - webcit/userlist.c
userlist.c: added. This adds "userlist" and "show user" functions.
[citadel.git] / webcit / userlist.c
1 #include <stdlib.h>
2 #include <unistd.h>
3 #include <stdio.h>
4 #include <signal.h>
5 #include <sys/types.h>
6 #include <ctype.h>
7 #include <string.h>
8 #include <time.h>
9 #include "webcit.h"
10 #include "child.h"
11
12 struct namelist {
13         struct namelist *next;
14         char name[32];
15         };
16
17 /*
18  * display the userlist
19  */
20 void userlist(void) { 
21         char buf[256];
22         char fl[256];
23         struct tm *tmbuf;
24         long lc;
25         struct namelist *bio = NULL;
26         struct namelist *bptr;
27         int has_bio;
28
29         serv_puts("LBIO");
30         serv_gets(buf);
31         if (buf[0]=='1') while (serv_gets(buf), strcmp(buf,"000")) {
32                 bptr = (struct namelist *) malloc(sizeof(struct namelist));
33                 bptr->next = bio;
34                 strcpy(bptr->name, buf);
35                 bio = bptr;
36                 }
37
38
39         printf("HTTP/1.0 200 OK\n");
40         output_headers();
41         wprintf("<HTML><HEAD><TITLE>User list</TITLE>\n");
42         wprintf("</HEAD><BODY BACKGROUND=\"/image&name=background\" TEXT=\"#000000\" LINK=\"#004400\">\n");
43
44         serv_puts("LIST");
45         serv_gets(buf);
46         if (buf[0]!='1') {
47                 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
48                 goto DONE;
49                 }
50
51
52         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
53         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
54         wprintf("<B>User list for ");
55         escputs(serv_info.serv_humannode);
56         wprintf("</B></FONT></TD></TR></TABLE>\n");
57
58         wprintf("<CENTER><TABLE border>");
59         wprintf("<TR><TH>User Name</TH><TH>Number</TH><TH>Access Level</TH>");
60         wprintf("<TH>Last Call</TH><TH>Total Calls</TH><TH>Total Posts</TH></TR>\n");
61
62         while (serv_gets(buf), strcmp(buf,"000")) {
63                 extract(fl,buf,0);
64                 has_bio = 0;
65                 for (bptr=bio; bptr!=NULL; bptr=bptr->next) {
66                         if (!strcasecmp(fl,bptr->name)) has_bio = 1;
67                         }
68                 wprintf("<TR><TD>");
69                 if (has_bio) {
70                         wprintf("<A HREF=\"/showuser&who=");
71                         urlescputs(fl);
72                         wprintf("\">");
73                         escputs(fl);
74                         wprintf("</A>");
75                         }
76                 else {
77                         escputs(fl);
78                         }
79                 wprintf("</TD><TD>%ld</TD><TD>%d</TD><TD>",
80                         extract_long(buf,2),
81                         extract_int(buf,1));
82                 lc = extract_long(buf,3);
83                 tmbuf = (struct tm *)localtime(&lc);
84                 wprintf("%02d/%02d/%04d ",
85                         (tmbuf->tm_mon+1),
86                         tmbuf->tm_mday,
87                         (tmbuf->tm_year + 1900));
88                 
89
90                 wprintf("</TD><TD>%ld</TD><TD>%5ld</TD></TR>\n",
91                         extract_long(buf,4),extract_long(buf,5));
92
93                 }
94         wprintf("</TABLE></CENTER>\n");
95 DONE:   wprintf("</BODY></HTML>\n");
96         wDumpContent();
97         }
98
99
100 /*
101  * Display (non confidential) information about a particular user
102  */
103 void showuser(void) {
104         char who[256];
105         char buf[256];
106         int have_pic;
107
108         printf("HTTP/1.0 200 OK\n");
109         output_headers();
110         wprintf("<HTML><HEAD><TITLE>User profile</TITLE>\n");
111         wprintf("</HEAD><BODY BACKGROUND=\"/image&name=background\" TEXT=\"#000000\" LINK=\"#004400\">\n");
112
113
114         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
115         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>User profile");
116         wprintf("</B></FONT></TD></TR></TABLE>\n");
117
118         strcpy(who, bstr("who"));
119         serv_printf("OIMG _userpic_|%s", who);
120         serv_gets(buf);
121         if (buf[0]=='2') {
122                 have_pic = 1;
123                 serv_puts("CLOS");
124                 serv_gets(buf);
125                 }
126         else {
127                 have_pic = 0;
128                 }
129
130         wprintf("<CENTER><TABLE><TR><TD>");
131         if (have_pic == 1) {
132                 wprintf("<IMG SRC=\"/image&name=_userpic_&parm=");
133                 urlescputs(who);
134                 wprintf("\">");
135                 }
136         wprintf("</TD><TD><H1>%s</H1></TD></TR></TABLE></CENTER>\n",who);
137         serv_printf("RBIO %s",who);
138         serv_gets(buf);
139         if (buf[0]=='1') fmout(NULL);
140         wprintf("</BODY></HTML>\n");
141         wDumpContent();
142         }