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("display_aide_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 wprintf("<div id=\"banner\">\n");
40 wprintf(_("Enter a server command"));
44 wprintf("<div id=\"content\" class=\"service\">\n");
46 wprintf("<div class=\"fix_scrollbar_bug\">"
47 "<table class=\"mainmenu_background\"><tr><td>\n");
50 wprintf(_("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."));
55 wprintf("<form method=\"post\" action=\"do_generic\">\n");
56 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
58 wprintf(_("Enter command:"));
59 wprintf("<br /><input type=\"text\" name=\"g_cmd\" size=80 maxlength=\"250\"><br />\n");
61 wprintf(_("Command input (if requesting SEND_LISTING transfer mode):"));
62 wprintf("<br /><textarea name=\"g_input\" rows=10 cols=80 width=80></textarea><br />\n");
64 wprintf("<font size=-2>");
65 wprintf(_("Detected host header is %s://%s"), (is_https ? "https" : "http"), ChrPtr(WC->Hdr->HR.http_host));
67 wprintf("<input type=\"submit\" name=\"sc_button\" value=\"%s\">", _("Send command"));
69 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\"><br />\n", _("Cancel"));
71 wprintf("</form></center>\n");
72 wprintf("</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"));
97 svput("BOXTITLE", WCS_STRING, _("Server command results"));
98 do_template("beginboxx", NULL);
100 wprintf("<table border=0><tr><td>Command:</td><td><tt>");
101 StrEscAppend(WCC->WBuf, sbstr("g_cmd"), NULL, 0, 0);
102 wprintf("</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 wprintf("</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 StrBuf_ServGetln(Buf);
118 if ( (StrLength(Buf)==3) &&
119 !strcmp(ChrPtr(Buf), "000")) {
122 StrEscAppend(WCC->WBuf, Buf, NULL, 0, 0);
123 StrBufAppendBufPlain(WCC->WBuf, HKEY("<br>\n"), 0);
127 text_to_server(bstr("g_input"));
131 len = atol(&ChrPtr(Buf)[4]);
132 StrBuf_ServGetBLOBBuffered(Buf, len);
135 len = atol(&ChrPtr(Buf)[4]);
137 memset(junk, 0, len);
138 serv_write(junk, len);
143 wprintf("<a href=\"display_generic\">Enter another command</a><br />\n");
144 wprintf("<a href=\"display_advanced\">Return to menu</a>\n");
145 do_template("endbox", NULL);
151 * Display the menubar.
153 * Set 'as_single_page' to display HTML headers and footers -- otherwise it's assumed
154 * that the menubar is being embedded in another page.
156 void display_menubar(int as_single_page) {
158 if (as_single_page) {
159 output_headers(0, 0, 0, 0, 0, 0);
162 "<title>MenuBar</title>\n"
163 "<style type=\"text/css\">\n"
164 "body { text-decoration: none; }\n"
167 do_template("background", NULL);
170 do_template("menubar", NULL);
172 if (as_single_page) {
181 * Display the wait / input dialog while restarting the server.
183 void display_shutdown(void)
189 if (strcmp(when, "now") == 0){
190 serv_printf("DOWN 1");
191 serv_getln(buf, sizeof buf);
192 if (atol(buf) == 500)
193 { /* upsie. maybe the server is not running as daemon? */
195 safestrncpy(WC->ImportantMessage,
197 sizeof WC->ImportantMessage);
200 output_headers(1, 0, 0, 0, 1, 0);
201 DoTemplate(HKEY("display_serverrestart"), NULL, &NoCtx);
203 lingering_close(WC->Hdr->http_sock);
208 else if (strcmp(when, "page") == 0) {
211 message = bstr("message");
212 if ((message == NULL) || (IsEmptyStr(message)))
215 output_headers(1, 0, 0, 0, 1, 0);
216 DoTemplate(HKEY("display_serverrestartpage"), NULL, &NoCtx);
221 serv_printf("SEXP broadcast|%s", message);
222 serv_getln(buf, sizeof buf); /* TODO: should we care? */
224 output_headers(1, 0, 0, 0, 1, 0);
225 DoTemplate(HKEY("display_serverrestartpagedo"), NULL, &NoCtx);
229 else if (!strcmp(when, "idle")) {
230 serv_printf("SCDN 3");
231 serv_getln(buf, sizeof buf);
233 if (atol(buf) == 500)
234 { /* upsie. maybe the server is not running as daemon? */
235 safestrncpy(WC->ImportantMessage,
237 sizeof WC->ImportantMessage);
240 output_headers(1, 0, 0, 0, 1, 0);
241 DoTemplate(HKEY("display_aide_menu"), NULL, &NoCtx);
246 void _display_menubar(void) { display_menubar(0); }
252 WebcitAddUrlHandler(HKEY("display_aide_menu"), display_aide_menu, 0);
253 WebcitAddUrlHandler(HKEY("server_shutdown"), display_shutdown, 0);
254 WebcitAddUrlHandler(HKEY("display_main_menu"), display_main_menu, 0);
255 WebcitAddUrlHandler(HKEY("display_generic"), display_generic, 0);
256 WebcitAddUrlHandler(HKEY("do_generic"), do_generic, 0);
257 WebcitAddUrlHandler(HKEY("display_menubar"), _display_menubar, 0);