10 void display_main_menu(void)
13 output_headers(1, 0, 0, 0, 1, 0);
14 DoTemplate(HKEY("display_main_menu"), NULL, &NoCtx);
20 * System administration menu
22 void display_aide_menu(void)
25 output_headers(1, 0, 0, 0, 1, 0);
26 DoTemplate(HKEY("aide_display_menu"), NULL, &NoCtx);
33 * Display the screen to enter a generic server command
35 void display_generic(void)
37 output_headers(1, 1, 2, 0, 0, 0);
38 wc_printf("<div id=\"banner\">\n");
40 wc_printf(_("Enter a server command"));
42 wc_printf("</div>\n");
44 wc_printf("<div id=\"content\" class=\"service\">\n");
46 wc_printf("<div class=\"fix_scrollbar_bug\">"
47 "<table class=\"mainmenu_background\"><tr><td>\n");
49 wc_printf("<center>");
50 wc_printf(_("This screen allows you to enter Citadel server commands which are "
51 "not supported by WebCit. If you do not know what that means, "
52 "then this screen will not be of much use to you."));
53 wc_printf("<br />\n");
55 wc_printf("<form method=\"post\" action=\"do_generic\">\n");
56 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
58 wc_printf(_("Enter command:"));
59 wc_printf("<br /><input type=\"text\" name=\"g_cmd\" size=80 maxlength=\"250\"><br />\n");
61 wc_printf(_("Command input (if requesting SEND_LISTING transfer mode):"));
62 wc_printf("<br /><textarea name=\"g_input\" rows=10 cols=80 width=80></textarea><br />\n");
64 wc_printf("<font size=-2>");
65 wc_printf(_("Detected host header is %s://%s"), (is_https ? "https" : "http"), ChrPtr(WC->Hdr->HR.http_host));
66 wc_printf("</font>\n");
67 wc_printf("<input type=\"submit\" name=\"sc_button\" value=\"%s\">", _("Send command"));
69 wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\"><br />\n", _("Cancel"));
71 wc_printf("</form></center>\n");
72 wc_printf("</td></tr></table></div>\n");
77 * Interactive window to perform generic Citadel server commands.
88 if (!havebstr("sc_button")) {
93 output_headers(1, 1, 0, 0, 0, 0);
95 serv_puts(bstr("g_cmd"));
96 StrBuf_ServGetln(Buf);
97 svput("BOXTITLE", WCS_STRING, _("Server command results"));
98 do_template("beginboxx", NULL);
100 wc_printf("<table border=0><tr><td>Command:</td><td><tt>");
101 StrEscAppend(WCC->WBuf, sbstr("g_cmd"), NULL, 0, 0);
102 wc_printf("</tt></td></tr><tr><td>Result:</td><td><tt>");
103 StrEscAppend(WCC->WBuf, Buf, NULL, 0, 0);
104 StrBufAppendBufPlain(WCC->WBuf, HKEY("<br>\n"), 0);
105 wc_printf("</tt></td></tr></table><br />\n");
107 switch (GetServerStatus(Buf, NULL)) {
109 serv_puts("\n\n000");
110 if ( (StrLength(Buf)==3) &&
111 !strcmp(ChrPtr(Buf), "000")) {
112 StrBufAppendBufPlain(WCC->WBuf, HKEY("\000"), 0);
117 if (StrBuf_ServGetln(Buf) < 0)
119 if ( (StrLength(Buf)==3) &&
120 !strcmp(ChrPtr(Buf), "000")) {
123 StrEscAppend(WCC->WBuf, Buf, NULL, 0, 0);
124 StrBufAppendBufPlain(WCC->WBuf, HKEY("<br>\n"), 0);
128 text_to_server(bstr("g_input"));
132 len = atol(&ChrPtr(Buf)[4]);
133 StrBuf_ServGetBLOBBuffered(Buf, len);
136 len = atol(&ChrPtr(Buf)[4]);
138 memset(junk, 0, len);
139 serv_write(junk, len);
144 wc_printf("<a href=\"display_generic\">Enter another command</a><br />\n");
145 wc_printf("<a href=\"display_advanced\">Return to menu</a>\n");
146 do_template("endbox", NULL);
153 * Display the menubar.
155 * Set 'as_single_page' to display HTML headers and footers -- otherwise it's assumed
156 * that the menubar is being embedded in another page.
158 void display_menubar(int as_single_page) {
160 if (as_single_page) {
161 output_headers(0, 0, 0, 0, 0, 0);
164 "<title>MenuBar</title>\n"
165 "<style type=\"text/css\">\n"
166 "body { text-decoration: none; }\n"
169 do_template("background", NULL);
172 do_template("menubar", NULL);
174 if (as_single_page) {
183 * Display the wait / input dialog while restarting the server.
185 void display_shutdown(void)
191 if (strcmp(when, "now") == 0){
192 serv_printf("DOWN 1");
193 serv_getln(buf, sizeof buf);
194 if (atol(buf) == 500)
195 { /* upsie. maybe the server is not running as daemon? */
197 safestrncpy(WC->ImportantMessage,
199 sizeof WC->ImportantMessage);
202 output_headers(1, 0, 0, 0, 1, 0);
203 DoTemplate(HKEY("aide_display_serverrestart"), NULL, &NoCtx);
205 lingering_close(WC->Hdr->http_sock);
210 else if (strcmp(when, "page") == 0) {
213 message = bstr("message");
214 if ((message == NULL) || (IsEmptyStr(message)))
217 output_headers(1, 0, 0, 0, 1, 0);
218 DoTemplate(HKEY("aide_display_serverrestart_page"), NULL, &NoCtx);
223 serv_printf("SEXP broadcast|%s", message);
224 serv_getln(buf, sizeof buf); /* TODO: should we care? */
226 output_headers(1, 0, 0, 0, 1, 0);
227 DoTemplate(HKEY("aide_display_serverrestart_page"), NULL, &NoCtx);
231 else if (!strcmp(when, "idle")) {
232 serv_printf("SCDN 3");
233 serv_getln(buf, sizeof buf);
235 if (atol(buf) == 500)
236 { /* upsie. maybe the server is not running as daemon? */
237 safestrncpy(WC->ImportantMessage,
239 sizeof WC->ImportantMessage);
242 output_headers(1, 0, 0, 0, 1, 0);
243 DoTemplate(HKEY("aide_display_menu"), NULL, &NoCtx);
248 void _display_menubar(void) { display_menubar(0); }
254 WebcitAddUrlHandler(HKEY("display_aide_menu"), "", 0, display_aide_menu, 0);
255 WebcitAddUrlHandler(HKEY("server_shutdown"), "", 0, display_shutdown, 0);
256 WebcitAddUrlHandler(HKEY("display_main_menu"), "", 0, display_main_menu, 0);
257 WebcitAddUrlHandler(HKEY("display_generic"), "", 0, display_generic, 0);
258 WebcitAddUrlHandler(HKEY("do_generic"), "", 0, do_generic, 0);
259 WebcitAddUrlHandler(HKEY("display_menubar"), "", 0, _display_menubar, 0);