* *** HUGE CHANGES *** *** WARNING: NOT FULLY FUNCTIONAL ***
[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         int bg = 0;
43
44         serv_puts("LBIO");
45         serv_gets(buf);
46         if (buf[0] == '1')
47                 while (serv_gets(buf), strcmp(buf, "000")) {
48                         bptr = (struct namelist *) malloc(sizeof(struct namelist));
49                         bptr->next = bio;
50                         strcpy(bptr->name, buf);
51                         bio = bptr;
52                 }
53         output_headers(1, 1, 0, 0, 0, 0, 0);
54
55         serv_puts("LIST");
56         serv_gets(buf);
57         if (buf[0] != '1') {
58                 wprintf("<EM>%s</EM><br />\n", &buf[4]);
59                 goto DONE;
60         }
61
62         svprintf("BOXTITLE", WCS_STRING, "User list for %s",
63                         serv_info.serv_humannode);
64
65         do_template("beginbox");
66         wprintf("<CENTER>");
67         wprintf("<TABLE border=0 width=100%%>");
68         wprintf("<TR><TH>User Name</TH><TH>Number</TH><TH>Access Level</TH>");
69         wprintf("<TH>Last Call</TH><TH>Total Calls</TH><TH>Total Posts</TH></TR>\n");
70
71         while (serv_gets(buf), strcmp(buf, "000")) {
72                 extract(fl, buf, 0);
73                 has_bio = 0;
74                 for (bptr = bio; bptr != NULL; bptr = bptr->next) {
75                         if (!strcasecmp(fl, bptr->name))
76                                 has_bio = 1;
77                 }
78                 bg = 1 - bg;
79                 wprintf("<TR BGCOLOR=\"#%s\"><TD>",
80                         (bg ? "DDDDDD" : "FFFFFF")
81                 );
82                 if (has_bio) {
83                         wprintf("<A HREF=\"/showuser&who=");
84                         urlescputs(fl);
85                         wprintf("\">");
86                         escputs(fl);
87                         wprintf("</A>");
88                 } else {
89                         escputs(fl);
90                 }
91                 wprintf("</TD><TD>%ld</TD><TD>%d</TD><TD>",
92                         extract_long(buf, 2),
93                         extract_int(buf, 1));
94                 lc = extract_long(buf, 3);
95                 tmbuf = (struct tm *) localtime(&lc);
96                 wprintf("%02d/%02d/%04d ",
97                         (tmbuf->tm_mon + 1),
98                         tmbuf->tm_mday,
99                         (tmbuf->tm_year + 1900));
100
101
102                 wprintf("</TD><TD>%ld</TD><TD>%5ld</TD></TR>\n",
103                         extract_long(buf, 4), extract_long(buf, 5));
104
105         }
106         wprintf("</TABLE>");
107         wprintf("</CENTER>\n");
108         do_template("endbox");
109 DONE:   wDumpContent(1);
110 }
111
112
113 /*
114  * Display (non confidential) information about a particular user
115  */
116 void showuser(void)
117 {
118         char who[SIZ];
119         char buf[SIZ];
120         int have_pic;
121
122         output_headers(1, 1, 0, 0, 0, 0, 0);
123
124         svprintf("BOXTITLE", WCS_STRING, "User profile");
125         do_template("beginbox");
126
127         strcpy(who, bstr("who"));
128         serv_printf("OIMG _userpic_|%s", who);
129         serv_gets(buf);
130         if (buf[0] == '2') {
131                 have_pic = 1;
132                 serv_puts("CLOS");
133                 serv_gets(buf);
134         } else {
135                 have_pic = 0;
136         }
137
138         wprintf("<CENTER><TABLE><TR><TD>");
139         if (have_pic == 1) {
140                 wprintf("<IMG SRC=\"/image&name=_userpic_&parm=");
141                 urlescputs(who);
142                 wprintf("\">");
143         }
144         wprintf("</TD><TD><H1>%s</H1></TD></TR></TABLE></CENTER>\n", who);
145         serv_printf("RBIO %s", who);
146         serv_gets(buf);
147         if (buf[0] == '1') {
148                 fmout(NULL, "JUSTIFY");
149         }
150         wprintf("<br /><A HREF=\"/display_page&recp=");
151         urlescputs(who);
152         wprintf("\">"
153                 "<IMG SRC=\"/static/page.gif\" ALIGN=MIDDLE BORDER=0>"
154                 "&nbsp;&nbsp;"
155                 "Click here to page this user (send an instant message)"
156                 "</A>\n");
157
158         do_template("endbox");
159         wDumpContent(1);
160 }