Set up login banner graphic and background image graphic
[citadel.git] / webcit / who.c
1 /* $Id$ */
2
3 #include <stdlib.h>
4 #ifdef HAVE_UNISTD_H
5 #include <unistd.h>
6 #endif
7 #include <stdio.h>
8 #include <signal.h>
9 #include <sys/types.h>
10 #include <ctype.h>
11 #include <string.h>
12 #include "webcit.h"
13 #include "child.h"
14
15 struct whouser {
16         struct whouser *next;
17         int sessionnum;
18         char username[256];
19         char roomname[256];
20         char hostname[256];
21         char clientsoftware[256];
22         };
23         
24 /*
25  * who is on?
26  */
27 void whobbs(void) {
28         struct whouser *wlist = NULL;
29         struct whouser *wptr = NULL;
30         char buf[256],sess,user[256],room[256],host[256];
31         int foundit;
32
33         printf("HTTP/1.0 200 OK\n");
34         output_headers();
35         wprintf("<HTML><HEAD><TITLE>Who is online?</TITLE>\n");
36
37         /* Uncomment this line to cause the wholist to auto-refresh */
38         /* wprintf("<META HTTP-EQUIV=\"Refresh\" CONTENT=\"60\">\n"); */
39
40         wprintf("</HEAD><BODY BACKGROUND=\"/image&name=background\" TEXT=\"#000000\" LINK=\"#004400\">\n");
41
42         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
43         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>Users currently on ");
44         escputs(serv_info.serv_humannode);
45         wprintf("</B></FONT></TD></TR></TABLE>\n");
46
47         wprintf("<CENTER><TABLE border><TR>");
48         wprintf("<TH>Session ID</TH><TH>User Name</TH><TH>Room</TH>");
49         wprintf("<TH>From host</TH></TR>\n");
50         serv_puts("RWHO");
51         serv_gets(buf);
52         if (buf[0]=='1') {
53                 while(serv_gets(buf), strcmp(buf,"000")) {
54                         sess = extract_int(buf, 0);
55                         extract(user, buf, 1);
56                         extract(room, buf, 2);
57                         extract(host, buf, 3);
58
59                         foundit = 0;
60                         for (wptr = wlist; wptr != NULL; wptr = wptr -> next) {
61                                 if (wptr->sessionnum == sess) {
62                                         foundit = 1;
63                                         if (strcasecmp(user, wptr->username)) {
64                                                 sprintf(buf, "%cBR%c%s", 
65                                                         LB, RB, user);
66                                                 strcat(wptr->username, buf);
67                                                 }
68                                         if (strcasecmp(room, wptr->roomname)) {
69                                                 sprintf(buf, "%cBR%c%s", 
70                                                         LB, RB, room);
71                                                 strcat(wptr->roomname, buf);
72                                                 }
73                                         if (strcasecmp(host, wptr->hostname)) {
74                                                 sprintf(buf, "%cBR%c%s", 
75                                                         LB, RB, host);
76                                                 strcat(wptr->hostname, buf);
77                                                 }
78                                         }
79                                 }
80
81                         if (foundit == 0) {
82                                 wptr = (struct whouser *)
83                                         malloc(sizeof(struct whouser));
84                                 wptr->next = wlist;
85                                 wlist = wptr;
86                                 strcpy(wlist->username, user);
87                                 strcpy(wlist->roomname, room);
88                                 strcpy(wlist->hostname, host);
89                                 wlist->sessionnum = sess;
90                                 }
91                         }
92
93                 while (wlist != NULL) {
94                         wprintf("<TR><TD>%d</TD><TD>", wlist->sessionnum);
95                         escputs(wlist->username);
96                         wprintf("</TD><TD>");
97                         escputs(wlist->roomname);
98                         wprintf("</TD><TD>");
99                         escputs(wlist->hostname);
100                         wprintf("</TD></TR>\n");
101                         wptr = wlist->next;
102                         free(wlist);
103                         wlist = wptr;
104                         }
105                 }
106         wprintf("</TABLE></CENTER>\n");
107         wprintf("</BODY></HTML>\n");
108         wDumpContent();
109         }
110
111