+ wprintf("</table>");
+ DeleteHash(&List);
+
+}
+
+
+/**
+ * \brief who is on?
+ */
+void who(void)
+{
+ char title[256];
+
+ output_headers(1, 1, 2, 0, 0, 0);
+
+ wprintf("<script type=\"text/javascript\">\n"
+ "function ConfirmKill() { \n"
+ "return confirm('%s');\n"
+ "}\n"
+ "</script>\n", _("Do you really want to kill this session?")
+ );
+
+ wprintf("<div id=\"banner\">\n");
+ wprintf("<div class=\"room_banner\">");
+ wprintf("<img src=\"static/usermanag_48x.gif\">");
+ wprintf("<h1>");
+ snprintf(title, sizeof title, _("Users currently on %s"), serv_info.serv_humannode);
+ escputs(title);
+ wprintf("</h1></div>");
+ wprintf("<ul class=\"room_actions\">\n");
+ wprintf("<li class=\"start_page\">");
+ offer_start_page();
+ wprintf("</li></ul>");
+ wprintf("</div>");
+
+ wprintf("<div id=\"content\" class=\"fix_scrollbar_bug who_is_online\">\n");
+ wprintf("<div class=\"box\">");
+ wprintf("<div class=\"boxlabel\">");
+ snprintf(title, sizeof title, _("Users currently on %s"), serv_info.serv_humannode);
+ escputs(title);
+ wprintf("</div>");
+ wprintf("<div class=\"boxcontent\">");
+ wprintf("<div id=\"who_inner\" >");
+ who_inner_div();
+ wprintf("</div>");
+
+ wprintf("<div class=\"instructions\">");
+ wprintf(_("Click on a name to read user info. Click on %s "
+ "to send an instant message to that user."),
+ "<img align=\"middle\" src=\"static/citadelchat_16x.gif\" alt=\"(p)\" border=\"0\">"
+ );
+ wprintf("</div></div>\n");
+
+ /**
+ * JavaScript to make the ajax refresh happen:
+ * See http://www.sergiopereira.com/articles/prototype.js.html for info on Ajax.PeriodicalUpdater
+ * It wants: 1. The div being updated
+ * 2. The URL of the update source
+ * 3. Other flags (such as the HTTP method and the refresh frequency)
+ */
+ wprintf(
+ "<script type=\"text/javascript\"> "
+ " new Ajax.PeriodicalUpdater('who_inner', 'who_inner_html', "
+ " { method: 'get', frequency: 30 } ); "
+ "</script> \n"
+ );
+ wDumpContent(1);
+}
+
+/**
+ * \brief end session \todo what??? does this belong here?
+ */
+void terminate_session(void)
+{
+ char buf[SIZ];
+
+ serv_printf("TERM %s", bstr("which_session"));
+ serv_getln(buf, sizeof buf);
+ who();
+}
+
+
+/**
+ * \brief Change your session info (fake roomname and hostname)
+ */
+void edit_me(void)
+{
+ char buf[SIZ];
+
+ if (havebstr("change_room_name_button")) {
+ serv_printf("RCHG %s", bstr("fake_roomname"));
+ serv_getln(buf, sizeof buf);
+ http_redirect("who");
+ } else if (havebstr("change_host_name_button")) {
+ serv_printf("HCHG %s", bstr("fake_hostname"));
+ serv_getln(buf, sizeof buf);
+ http_redirect("who");
+ } else if (havebstr("change_user_name_button")) {
+ serv_printf("UCHG %s", bstr("fake_username"));
+ serv_getln(buf, sizeof buf);
+ http_redirect("who");
+ } else if (havebstr("cancel_button")) {
+ http_redirect("who");
+ } else {
+ output_headers(1, 1, 0, 0, 0, 0);
+
+ wprintf("<div id=\"banner\">\n");
+ wprintf("<table class=\"who_banner\"><tr><td>");
+ wprintf("<span class=\"titlebar\">");
+ wprintf(_("Edit your session display"));
+ wprintf("</span></td></tr></table>\n");
+ wprintf("</div>\n<div id=\"content\">\n");
+
+ wprintf(_("This screen allows you to change the way your "
+ "session appears in the 'Who is online' listing. "
+ "To turn off any 'fake' name you've previously "
+ "set, simply click the appropriate 'change' button "
+ "without typing anything in the corresponding box. "));
+ wprintf("<br />\n");
+
+ wprintf("<form method=\"POST\" action=\"edit_me\">\n");
+ wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+
+ wprintf("<table border=0 width=100%%>\n");
+
+ wprintf("<tr><td><b>");
+ wprintf(_("Room name:"));
+ wprintf("</b></td>\n<td>");
+ wprintf("<input type=\"text\" name=\"fake_roomname\" maxlength=\"64\">\n");
+ wprintf("</td>\n<td align=center>");
+ wprintf("<input type=\"submit\" name=\"change_room_name_button\" value=\"%s\">",
+ _("Change room name"));
+ wprintf("</td>\n</tr>\n");
+
+ wprintf("<tr><td><b>");
+ wprintf(_("Host name:"));
+ wprintf("</b></td><td>");
+ wprintf("<input type=\"text\" name=\"fake_hostname\" maxlength=\"64\">\n");
+ wprintf("</td>\n<td align=center>");
+ wprintf("<input type=\"submit\" name=\"change_host_name_button\" value=\"%s\">",
+ _("Change host name"));
+ wprintf("</td>\n</tr>\n");
+
+ if (WC->is_aide) {
+ wprintf("<tr><td><b>");
+ wprintf(_("User name:"));
+ wprintf("</b></td><td>");
+ wprintf("<input type=\"text\" name=\"fake_username\" maxlength=\"64\">\n");
+ wprintf("</td>\n<td align=center>");
+ wprintf("<input type=\"submit\" name \"change_user_name_button\" value=\"%s\">",
+ _("Change user name"));
+ wprintf("</td>\n</tr>\n");
+ }
+ wprintf("<tr><td> </td><td> </td><td align=center>");
+ wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
+ _("Cancel"));
+ wprintf("</td></tr></table>\n");
+ wprintf("</form></center>\n");
+ wDumpContent(1);
+ }
+}
+
+/**
+ * \brief Wholist section
+ */
+void wholist_section(void) {
+ UserStateStruct *User;
+ void *VUser;
+ HashList *List;
+ HashPos *it;
+ char *UserName;
+ long len;
+ char buf[SIZ];
+ time_t now;
+
+ serv_puts("TIME");
+ serv_getln(buf, sizeof buf);
+ if (buf[0] == '2') {
+ now = extract_long(&buf[4], 0);
+ }
+ else {
+ now = time(NULL);
+ }
+
+ List = NewHash();
+
+ if (GetWholistSection(List, now)) {
+ SortByPayload(List, CompareUserStruct);
+ it = GetNewHashPos();
+ while (GetNextHashPos(List, it, &len, &UserName, &VUser)) {
+ User = VUser;
+ if (strcmp(User->UserName, NLI)) {
+ wprintf("<li class=\"");
+ if (User->Idle) {
+ wprintf("inactiveuser");
+ }
+ else {
+ wprintf("activeuser");
+ }
+ wprintf("\"><a href=\"showuser?who=");
+ urlescputs(User->UserName);
+ wprintf("\">");
+ escputs(User->UserName);
+ wprintf("</a></li>");
+ }
+ }
+ DeleteHashPos(&it);
+ }
+ DeleteHash(&List);
+}
+