]> code.citadel.org Git - citadel.git/blobdiff - webcit/who.c
* Made the frames stuff less dependent on the HTML TARGET= directive
[citadel.git] / webcit / who.c
index d4bb93e6c1ce04efd594f3a6e25293d9c013f0ed..84e7d421c80bf453baadca57f36d043cd4ddaecf 100644 (file)
@@ -1,11 +1,16 @@
+/* $Id$ */
+
 #include <stdlib.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdio.h>
 #include <signal.h>
 #include <sys/types.h>
 #include <ctype.h>
 #include <string.h>
 #include "webcit.h"
+#include "child.h"
 
 struct whouser {
        struct whouser *next;
@@ -19,15 +24,14 @@ struct whouser {
 /*
  * who is on?
  */
-void whobbs() {
+void whobbs(void) {
        struct whouser *wlist = NULL;
        struct whouser *wptr = NULL;
        char buf[256],sess,user[256],room[256],host[256];
        int foundit;
 
         printf("HTTP/1.0 200 OK\n");
-        output_headers();
-        wprintf("<HTML><HEAD><TITLE>Who is online?</TITLE></HEAD><BODY>\n");
+        output_headers(1, "bottom");
 
         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>Users currently on ");
@@ -50,17 +54,17 @@ void whobbs() {
                        for (wptr = wlist; wptr != NULL; wptr = wptr -> next) {
                                if (wptr->sessionnum == sess) {
                                        foundit = 1;
-                                       if (strcasecmp(user, &wptr->username)) {
+                                       if (strcasecmp(user, wptr->username)) {
                                                sprintf(buf, "%cBR%c%s", 
                                                        LB, RB, user);
                                                strcat(wptr->username, buf);
                                                }
-                                       if (strcasecmp(room, &wptr->roomname)) {
+                                       if (strcasecmp(room, wptr->roomname)) {
                                                sprintf(buf, "%cBR%c%s", 
                                                        LB, RB, room);
                                                strcat(wptr->roomname, buf);
                                                }
-                                       if (strcasecmp(host, &wptr->hostname)) {
+                                       if (strcasecmp(host, wptr->hostname)) {
                                                sprintf(buf, "%cBR%c%s", 
                                                        LB, RB, host);
                                                strcat(wptr->hostname, buf);
@@ -81,7 +85,17 @@ void whobbs() {
                        }
 
                while (wlist != NULL) {
-                       wprintf("<TR><TD>%d</TD><TD>", wlist->sessionnum);
+                       wprintf("<TR><TD>%d", wlist->sessionnum);
+                       if ( (is_aide) &&
+                          (wlist->sessionnum != serv_info.serv_pid) ) {
+                               wprintf(" <A HREF=\"/terminate_session&which_session=%d&session_owner=", wlist->sessionnum);
+                               urlescputs(wlist->username);
+                               wprintf("\">(kill)</A>");
+                               }
+                       if (wlist->sessionnum == serv_info.serv_pid) {
+                               wprintf(" <A HREF=\"/edit_me\">(edit)</A>");
+                               }
+                       wprintf("</TD><TD>");
                        escputs(wlist->username);
                        wprintf("</TD><TD>");
                        escputs(wlist->roomname);
@@ -93,9 +107,126 @@ void whobbs() {
                        wlist = wptr;
                        }
                }
-       wprintf("</TABLE></CENTER>\n");
-        printf("</BODY></HTML>\n");
+       wprintf("</TABLE>\n");
+       wprintf("<A HREF=\"/whobbs\">Refresh</A>\n");
+        wprintf("</CENTER></BODY></HTML>\n");
         wDumpContent();
        }
 
 
+void terminate_session(void) {
+       char buf[256];
+
+       if (!strcasecmp(bstr("confirm"), "Yes")) {
+               serv_printf("TERM %s", bstr("which_session"));
+               serv_gets(buf);
+               if (buf[0]=='2') {
+                       whobbs();
+                       }
+               else {
+                       display_error(&buf[4]);
+                       }
+               }
+
+       else {
+               printf("HTTP/1.0 200 OK\n");
+               output_headers(1, "bottom");
+               wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
+               wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>Confirm session termination");
+               wprintf("</B></FONT></TD></TR></TABLE>\n");
+       
+               wprintf("Are you sure you want to terminate session %s",
+                       bstr("which_session"));
+               if (strlen(bstr("session_owner"))>0) {
+                       wprintf(" (");
+                       escputs(bstr("session_owner"));
+                       wprintf(")");
+                       }
+               wprintf("?<BR><BR>\n");
+       
+               wprintf("<A HREF=\"/terminate_session&which_session=%s&confirm=yes\">",
+                       bstr("which_session"));
+               wprintf("Yes</A>&nbsp;&nbsp;&nbsp;");
+               wprintf("<A HREF=\"/whobbs\">No</A>");
+               wprintf("</BODY></HTML>\n");
+               wDumpContent();
+               }
+
+       }
+
+
+
+/*
+ * Change your session info (fake roomname and hostname)
+ */
+void edit_me(void) {
+       char buf[256];
+
+       printf("HTTP/1.0 200 OK\n");
+       output_headers(1, "bottom");
+
+       if (!strcasecmp(bstr("sc"), "Change room name")) {
+               serv_printf("RCHG %s", bstr("fake_roomname"));
+               serv_gets(buf);
+               whobbs();
+               }
+       else if (!strcasecmp(bstr("sc"), "Change host name")) {
+               serv_printf("HCHG %s", bstr("fake_hostname"));
+               serv_gets(buf);
+               whobbs();
+               }
+       else if (!strcasecmp(bstr("sc"), "Change user name")) {
+               serv_printf("UCHG %s", bstr("fake_username"));
+               serv_gets(buf);
+               whobbs();
+               }
+       else if (!strcasecmp(bstr("sc"), "Cancel")) {
+               whobbs();
+               }
+       else {
+
+                       wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
+                       wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>");
+               wprintf("Edit your session display");
+                       wprintf("</B></FONT></TD></TR></TABLE>\n");
+       
+               wprintf("This screen allows you to change the way your\n");
+               wprintf("session appears in the 'Who is online' listing.\n");
+               wprintf("To turn off any 'fake' name you've previously\n");
+               wprintf("set, simply click the appropriate 'change' button\n");
+               wprintf("without typing anything in the corresponding box.\n");
+               wprintf("<BR>\n");
+
+               wprintf("<FORM METHOD=\"POST\" ACTION=\"/edit_me\">\n");
+
+               wprintf("<TABLE border=0 width=100%>\n");
+
+               wprintf("<TR><TD>Room name:</TD><TD>");
+               wprintf("<INPUT TYPE=\"text\" NAME=\"fake_roomname\" MAXLENGTH=\"64\">\n");
+               wprintf("</TD><TD>");
+               wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Change room name\">");
+               wprintf("</TD></TR>\n");
+
+               wprintf("<TR><TD>Host name:</TD><TD>");
+               wprintf("<INPUT TYPE=\"text\" NAME=\"fake_hostname\" MAXLENGTH=\"64\">\n");
+               wprintf("</TD><TD>");
+               wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Change host name\">");
+               wprintf("</TD></TR>\n");
+
+               if (is_aide) {
+                       wprintf("<TR><TD>User name:</TD><TD>");
+                       wprintf("<INPUT TYPE=\"text\" NAME=\"fake_username\" MAXLENGTH=\"64\">\n");
+                       wprintf("</TD><TD>");
+                       wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Change user name\">");
+                       wprintf("</TD></TR>\n");
+                       }
+
+               wprintf("<TR><TD></TD><TD></TD><TD>");
+               wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
+               wprintf("</TD></TR></TABLE>\n");
+
+               wprintf("</FORM></CENTER></BODY></HTML>\n");
+               wDumpContent();
+               }
+       }
+