e11b644f98e237440e8b01120ae1bcf2805f7523
[citadel.git] / webcit / userlist.c
1 #include <ctype.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <stdio.h>
5 #include <fcntl.h>
6 #include <signal.h>
7 #include <sys/types.h>
8 #include <sys/wait.h>
9 #include <sys/socket.h>
10 #include <sys/time.h>
11 #include <limits.h>
12 #include <netinet/in.h>
13 #include <netdb.h>
14 #include <string.h>
15 #include <pwd.h>
16 #include <errno.h>
17 #include <stdarg.h>
18 #include <pthread.h>
19 #include <signal.h>
20 #include "webcit.h"
21
22
23
24
25 struct namelist {
26         struct namelist *next;
27         char name[32];
28 };
29
30 /*
31  * display the userlist
32  */
33 void userlist(void)
34 {
35         char buf[SIZ];
36         char fl[SIZ];
37         struct tm *tmbuf;
38         long lc;
39         struct namelist *bio = NULL;
40         struct namelist *bptr;
41         int has_bio;
42
43         serv_puts("LBIO");
44         serv_gets(buf);
45         if (buf[0] == '1')
46                 while (serv_gets(buf), strcmp(buf, "000")) {
47                         bptr = (struct namelist *) malloc(sizeof(struct namelist));
48                         bptr->next = bio;
49                         strcpy(bptr->name, buf);
50                         bio = bptr;
51                 }
52         output_headers(3);
53
54         serv_puts("LIST");
55         serv_gets(buf);
56         if (buf[0] != '1') {
57                 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
58                 goto DONE;
59         }
60         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#007700\"><TR><TD>");
61         wprintf("<SPAN CLASS=\"titlebar\">User list for ");
62         escputs(serv_info.serv_humannode);
63         wprintf("</SPAN></TD></TR></TABLE>\n");
64
65         wprintf("<CENTER><TABLE border>");
66         wprintf("<TR><TH>User Name</TH><TH>Number</TH><TH>Access Level</TH>");
67         wprintf("<TH>Last Call</TH><TH>Total Calls</TH><TH>Total Posts</TH></TR>\n");
68
69         while (serv_gets(buf), strcmp(buf, "000")) {
70                 extract(fl, buf, 0);
71                 has_bio = 0;
72                 for (bptr = bio; bptr != NULL; bptr = bptr->next) {
73                         if (!strcasecmp(fl, bptr->name))
74                                 has_bio = 1;
75                 }
76                 wprintf("<TR><TD>");
77                 if (has_bio) {
78                         wprintf("<A HREF=\"/showuser&who=");
79                         urlescputs(fl);
80                         wprintf("\">");
81                         escputs(fl);
82                         wprintf("</A>");
83                 } else {
84                         escputs(fl);
85                 }
86                 wprintf("</TD><TD>%ld</TD><TD>%d</TD><TD>",
87                         extract_long(buf, 2),
88                         extract_int(buf, 1));
89                 lc = extract_long(buf, 3);
90                 tmbuf = (struct tm *) localtime(&lc);
91                 wprintf("%02d/%02d/%04d ",
92                         (tmbuf->tm_mon + 1),
93                         tmbuf->tm_mday,
94                         (tmbuf->tm_year + 1900));
95
96
97                 wprintf("</TD><TD>%ld</TD><TD>%5ld</TD></TR>\n",
98                         extract_long(buf, 4), extract_long(buf, 5));
99
100         }
101         wprintf("</TABLE></CENTER>\n");
102       DONE:wDumpContent(1);
103 }
104
105
106 /*
107  * Display (non confidential) information about a particular user
108  */
109 void showuser(void)
110 {
111         char who[SIZ];
112         char buf[SIZ];
113         int have_pic;
114
115         output_headers(3);
116
117
118         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#007700\"><TR><TD>");
119         wprintf("<SPAN CLASS=\"titlebar\">User profile");
120         wprintf("</SPAN></TD></TR></TABLE>\n");
121
122         strcpy(who, bstr("who"));
123         serv_printf("OIMG _userpic_|%s", who);
124         serv_gets(buf);
125         if (buf[0] == '2') {
126                 have_pic = 1;
127                 serv_puts("CLOS");
128                 serv_gets(buf);
129         } else {
130                 have_pic = 0;
131         }
132
133         wprintf("<CENTER><TABLE><TR><TD>");
134         if (have_pic == 1) {
135                 wprintf("<IMG SRC=\"/image&name=_userpic_&parm=");
136                 urlescputs(who);
137                 wprintf("\">");
138         }
139         wprintf("</TD><TD><H1>%s</H1></TD></TR></TABLE></CENTER>\n", who);
140         serv_printf("RBIO %s", who);
141         serv_gets(buf);
142         if (buf[0] == '1') {
143                 fmout(NULL);
144         }
145         wprintf("<BR><A HREF=\"/display_page&recp=");
146         urlescputs(who);
147         wprintf("\">"
148                 "<IMG SRC=\"/static/page.gif\" ALIGN=MIDDLE BORDER=0>"
149                 "&nbsp;&nbsp;"
150                 "Click here to page this user (send an instant message)"
151                 "</A>\n");
152         wDumpContent(1);
153 }