2 * This module implements server commands related to the display and
3 * manipulation of the "Who's online" list.
5 * Copyright (c) 1987-2019 by the citadel.org team
7 * This program is open source software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 3.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
25 #include <sys/types.h>
30 #include <libcitadel.h>
33 #include "citserver.h"
40 #include "ctdl_module.h"
42 /* Don't show the names of private rooms unless the viewing
43 * user also knows the rooms.
45 void GenerateRoomDisplay(char *real_room,
51 strcpy(real_room, viewed->room.QRname);
52 if (viewed->room.QRflags & QR_MAILBOX) {
53 strcpy(real_room, &real_room[11]);
55 if (viewed->room.QRflags & QR_PRIVATE) {
56 CtdlRoomAccess(&viewed->room, &viewer->user, &ra, NULL);
57 if ( (ra & UA_KNOWN) == 0) {
58 strcpy(real_room, " ");
62 if (viewed->cs_flags & CS_CHAT) {
63 while (strlen(real_room) < 14) {
64 strcat(real_room, " ");
66 strcpy(&real_room[14], "<chat>");
74 * display who's online
76 void cmd_rwho(char *argbuf) {
77 struct CitContext *nptr;
81 char room[ROOMNAMELEN];
84 /* So that we don't keep the context list locked for a long time
85 * we create a copy of it first
87 nptr = CtdlGetContextArray(&nContexts) ;
90 /* Couldn't malloc so we have to bail but stick to the protocol */
91 cprintf("%d%c \n", LISTING_FOLLOWS, CtdlCheckExpress() );
96 aide = ( (CC->user.axlevel >= AxAideU) || (CC->internal_pgm) ) ;
97 cprintf("%d%c \n", LISTING_FOLLOWS, CtdlCheckExpress() );
99 for (i=0; i<nContexts; i++) {
103 if (!aide && nptr[i].state == CON_SYS)
106 if (!aide && nptr[i].kill_me != 0)
109 if (nptr[i].cs_flags & CS_POSTING) {
116 GenerateRoomDisplay(room, &nptr[i], CC);
118 if ((aide) && (spoofed)) {
122 if ((nptr[i].cs_flags & CS_STEALTH) && (aide)) {
126 if (((nptr[i].cs_flags&CS_STEALTH)==0) || (aide)) {
128 cprintf("%d|%s|%s|%s|%s|%ld|%s|%s|",
129 nptr[i].cs_pid, nptr[i].curr_user, room,
130 nptr[i].cs_host, nptr[i].cs_clientname,
131 (long)(nptr[i].lastidle),
132 nptr[i].lastcmdname, flags
135 cprintf("|"); // no spoofed user names anymore
136 cprintf("|"); // no spoofed room names anymore
137 cprintf("|"); // no spoofed host names anymore
139 cprintf("%d\n", nptr[i].logged_in);
143 /* release our copy of the context list */
146 /* Now it's magic time. Before we finish, call any EVT_RWHO hooks
147 * so that external paging modules such as serv_icq can add more
148 * content to the Wholist.
150 PerformSessionHooks(EVT_RWHO);
156 * enter or exit "stealth mode"
158 void cmd_stel(char *cmdbuf)
162 requested_mode = extract_int(cmdbuf,0);
164 if (CtdlAccessCheck(ac_logged_in)) return;
166 if (requested_mode == 1) {
167 CC->cs_flags = CC->cs_flags | CS_STEALTH;
168 PerformSessionHooks(EVT_STEALTH);
170 if (requested_mode == 0) {
171 CC->cs_flags = CC->cs_flags & ~CS_STEALTH;
172 PerformSessionHooks(EVT_UNSTEALTH);
175 cprintf("%d %d\n", CIT_OK,
176 ((CC->cs_flags & CS_STEALTH) ? 1 : 0) );
180 CTDL_MODULE_INIT(rwho)
184 CtdlRegisterProtoHook(cmd_rwho, "RWHO", "Display who is online");
185 CtdlRegisterProtoHook(cmd_stel, "STEL", "Enter/exit stealth mode");
186 //CtdlRegisterSessionHook(dead_io_check, EVT_TIMER, PRIO_QUEUE + 50);
190 /* return our module name for the log */