4 * Display a list of all users currently logged on to the Citadel server.
12 * Display inner div of Wholist
14 void who_inner_div(void) {
15 char buf[SIZ], user[SIZ], room[SIZ], host[SIZ],
16 realroom[SIZ], realhost[SIZ];
22 wprintf("<table border=\"0\" cellspacing=\"0\" width=\"100%%\" bgcolor=\"#FFFFFF\">"
24 wprintf("<th colspan=\"3\"> </th>\n");
25 wprintf("<th>%s</th>\n", _("User name"));
26 wprintf("<th>%s</th>", _("Room"));
27 wprintf("<th>%s</th>\n</tr>\n", _("From host"));
30 serv_getln(buf, sizeof buf);
32 now = extract_long(&buf[4], 0);
39 serv_getln(buf, sizeof buf);
41 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
42 sess = extract_int(buf, 0);
43 extract_token(user, buf, 1, '|', sizeof user);
44 extract_token(room, buf, 2, '|', sizeof room);
45 extract_token(host, buf, 3, '|', sizeof host);
46 extract_token(realroom, buf, 9, '|', sizeof realroom);
47 extract_token(realhost, buf, 10, '|', sizeof realhost);
48 last_activity = extract_long(buf, 5);
51 wprintf("<tr bgcolor=\"#%s\">",
52 (bg ? "DDDDDD" : "FFFFFF")
58 (sess != WC->ctdl_pid)) {
59 wprintf(" <a href=\"/terminate_session?which_session=%d", sess);
60 wprintf("\" onClick=\"return ConfirmKill();\">%s</a>", _("(kill)"));
62 if (sess == WC->ctdl_pid) {
63 wprintf(" <a href=\"/edit_me\">%s</a>", _("(edit)"));
67 /* (link to page this user) */
68 wprintf("<td><a href=\"/display_page?recp=");
71 "<img align=\"middle\" "
72 "src=\"/static/citadelchat_24x.gif\" "
74 " border=\"0\" /></a> ");
79 if ((now - last_activity) > 900L) {
81 "<img align=\"middle\" "
82 "src=\"/static/inactiveuser_24x.gif\" "
83 "alt=\"(idle)\" border=\"0\" />");
87 "<img align=\"middle\" "
88 "src=\"/static/activeuser_24x.gif\" "
89 "alt=\"(active)\" border=\"0\" />");
91 wprintf("</td>\n<td>");
95 /* username (link to user bio/photo page) */
96 wprintf("<a href=\"/showuser?who=");
103 wprintf("</td>\n\t<td>");
105 if (strlen(realroom) > 0) {
106 wprintf("<br /><i>");
110 wprintf("</td>\n\t<td>");
114 if (strlen(realhost) > 0) {
115 wprintf("<br /><i>");
119 wprintf("</td>\n</tr>");
127 * AJAX-response version of wholist inner html
129 void who_inner_html(void) {
130 output_headers(0, 0, 0, 0, 0, 0, 0);
132 wprintf("Content-type: text/html; charset=UTF-8\r\n"
134 "Connection: close\r\n"
135 "Pragma: no-cache\r\n"
136 "Cache-Control: no-cache\r\n",
154 output_headers(1, 1, 2, 0, 0, 0, 0);
156 wprintf("<script type=\"text/javascript\">\n"
157 "function ConfirmKill() { \n"
158 "return confirm('%s');\n"
160 "</script>\n", _("Do you really want to kill this session?")
163 wprintf("<div id=\"banner\">\n");
164 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
165 wprintf("<IMG SRC=\"/static/usermanag_48x.gif\" ALT=\" \" "
168 wprintf("<SPAN CLASS=\"titlebar\"> ");
170 snprintf(title, sizeof title, _("Users currently on %s"), serv_info.serv_humannode);
173 wprintf("</SPAN></TD><TD ALIGN=RIGHT>");
175 wprintf("</TD></TR></TABLE>\n");
178 wprintf("<div id=\"content\">\n");
180 wprintf("<div style=\"display:inline\" id=\"fix_scrollbar_bug\">");
184 wprintf("<div id=\"instructions\" align=center>");
185 wprintf(_("Click on a name to read user info. Click on %s "
186 "to send an instant message to that user."),
187 "<img align=\"middle\" src=\"/static/citadelchat_16x.gif\" alt=\"(p)\" border=\"0\">"
191 /* JavaScript to make the ajax refresh happen:
192 * * See http://www.sergiopereira.com/articles/prototype.js.html for info on Ajax.Updater
193 * * It wants: 1. The div being updated
194 * * 2. The URL of the update source
195 * * 3. Other flags (such as the HTTP method)
197 * * setInterval() makes it auto-run this code every 30,000 milliseconds (30 seconds)
199 * The random number parameter forces b0rken MSIE to fetch a new page instead of going to
200 * its cache, even though it's been specifically told not to cache.
204 "<script type=\"text/javascript\"> \n"
205 " setInterval(\" new Ajax.Updater('fix_scrollbar_bug', '/who_inner_html', "
206 " {method: 'get', parameters: Math.random() }); \", 3000); \n"
213 void terminate_session(void)
217 serv_printf("TERM %s", bstr("which_session"));
218 serv_getln(buf, sizeof buf);
224 * Change your session info (fake roomname and hostname)
230 if (strlen(bstr("change_room_name_button")) > 0) {
231 serv_printf("RCHG %s", bstr("fake_roomname"));
232 serv_getln(buf, sizeof buf);
233 http_redirect("/who");
234 } else if (strlen(bstr("change_host_name_button")) > 0) {
235 serv_printf("HCHG %s", bstr("fake_hostname"));
236 serv_getln(buf, sizeof buf);
237 http_redirect("/who");
238 } else if (strlen(bstr("change_user_name_button")) > 0) {
239 serv_printf("UCHG %s", bstr("fake_username"));
240 serv_getln(buf, sizeof buf);
241 http_redirect("/who");
242 } else if (strlen(bstr("cancel_button")) > 0) {
243 http_redirect("/who");
245 output_headers(1, 1, 0, 0, 0, 0, 0);
247 wprintf("<div id=\"banner\">\n");
248 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
249 wprintf("<SPAN CLASS=\"titlebar\">");
250 wprintf(_("Edit your session display"));
251 wprintf("</SPAN></TD></TR></TABLE>\n");
252 wprintf("</div>\n<div id=\"content\">\n");
254 wprintf(_("This screen allows you to change the way your "
255 "session appears in the 'Who is online' listing. "
256 "To turn off any 'fake' name you've previously "
257 "set, simply click the appropriate 'change' button "
258 "without typing anything in the corresponding box. "));
261 wprintf("<FORM METHOD=\"POST\" ACTION=\"/edit_me\">\n");
263 wprintf("<TABLE border=0 width=100%%>\n");
265 wprintf("<TR><TD><B>");
266 wprintf(_("Room name:"));
267 wprintf("</B></TD>\n<TD>");
268 wprintf("<INPUT TYPE=\"text\" NAME=\"fake_roomname\" MAXLENGTH=\"64\">\n");
269 wprintf("</TD>\n<TD ALIGN=center>");
270 wprintf("<INPUT TYPE=\"submit\" NAME=\"change_room_name_button\" VALUE=\"%s\">",
271 _("Change room name"));
272 wprintf("</TD>\n</TR>\n");
274 wprintf("<TR><TD><B>");
275 wprintf(_("Host name:"));
276 wprintf("</B></TD><TD>");
277 wprintf("<INPUT TYPE=\"text\" NAME=\"fake_hostname\" MAXLENGTH=\"64\">\n");
278 wprintf("</TD>\n<TD ALIGN=center>");
279 wprintf("<INPUT TYPE=\"submit\" NAME=\"change_host_name_button\" VALUE=\"%s\">",
280 _("Change host name"));
281 wprintf("</TD>\n</TR>\n");
284 wprintf("<TR><TD><B>");
285 wprintf(_("User name:"));
286 wprintf("</B></TD><TD>");
287 wprintf("<INPUT TYPE=\"text\" NAME=\"fake_username\" MAXLENGTH=\"64\">\n");
288 wprintf("</TD>\n<TD ALIGN=center>");
289 wprintf("<INPUT TYPE=\"submit\" NAME=\"change_user_name_button\" VALUE=\"%s\">",
290 _("Change user name"));
291 wprintf("</TD>\n</TR>\n");
293 wprintf("<TR><TD> </TD><TD> </TD><TD ALIGN=center>");
294 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
296 wprintf("</TD></TR></TABLE>\n");
297 wprintf("</FORM></CENTER>\n");