8fd97db3538772189e4f33c83c35cfe44b58d9e1
[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(1);
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("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
62         wprintf("<B>User list for ");
63         escputs(serv_info.serv_humannode);
64         wprintf("</B></FONT></TD></TR></TABLE>\n");
65
66         wprintf("<CENTER><TABLE border>");
67         wprintf("<TR><TH>User Name</TH><TH>Number</TH><TH>Access Level</TH>");
68         wprintf("<TH>Last Call</TH><TH>Total Calls</TH><TH>Total Posts</TH></TR>\n");
69
70         while (serv_gets(buf), strcmp(buf, "000")) {
71                 extract(fl, buf, 0);
72                 has_bio = 0;
73                 for (bptr = bio; bptr != NULL; bptr = bptr->next) {
74                         if (!strcasecmp(fl, bptr->name))
75                                 has_bio = 1;
76                 }
77                 wprintf("<TR><TD>");
78                 if (has_bio) {
79                         wprintf("<A HREF=\"/showuser&who=");
80                         urlescputs(fl);
81                         wprintf("\">");
82                         escputs(fl);
83                         wprintf("</A>");
84                 } else {
85                         escputs(fl);
86                 }
87                 wprintf("</TD><TD>%ld</TD><TD>%d</TD><TD>",
88                         extract_long(buf, 2),
89                         extract_int(buf, 1));
90                 lc = extract_long(buf, 3);
91                 tmbuf = (struct tm *) localtime(&lc);
92                 wprintf("%02d/%02d/%04d ",
93                         (tmbuf->tm_mon + 1),
94                         tmbuf->tm_mday,
95                         (tmbuf->tm_year + 1900));
96
97
98                 wprintf("</TD><TD>%ld</TD><TD>%5ld</TD></TR>\n",
99                         extract_long(buf, 4), extract_long(buf, 5));
100
101         }
102         wprintf("</TABLE></CENTER>\n");
103       DONE:wDumpContent(1);
104 }
105
106
107 /*
108  * Display (non confidential) information about a particular user
109  */
110 void showuser(void)
111 {
112         char who[SIZ];
113         char buf[SIZ];
114         int have_pic;
115
116         output_headers(1);
117
118
119         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>");
120         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>User profile");
121         wprintf("</B></FONT></TD></TR></TABLE>\n");
122
123         strcpy(who, bstr("who"));
124         serv_printf("OIMG _userpic_|%s", who);
125         serv_gets(buf);
126         if (buf[0] == '2') {
127                 have_pic = 1;
128                 serv_puts("CLOS");
129                 serv_gets(buf);
130         } else {
131                 have_pic = 0;
132         }
133
134         wprintf("<CENTER><TABLE><TR><TD>");
135         if (have_pic == 1) {
136                 wprintf("<IMG SRC=\"/image&name=_userpic_&parm=");
137                 urlescputs(who);
138                 wprintf("\">");
139         }
140         wprintf("</TD><TD><H1>%s</H1></TD></TR></TABLE></CENTER>\n", who);
141         serv_printf("RBIO %s", who);
142         serv_gets(buf);
143         if (buf[0] == '1') {
144                 fmout(NULL);
145         }
146         wprintf("<BR><A HREF=\"/display_page&recp=");
147         urlescputs(who);
148         wprintf("\">"
149                 "<IMG SRC=\"/static/page.gif\" ALIGN=MIDDLE BORDER=0>"
150                 "&nbsp;&nbsp;"
151                 "Click here to page this user (send an instant message)"
152                 "</A>\n");
153         wDumpContent(1);
154 }