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);
32 * Interactive window to perform generic Citadel server commands.
36 WCTemplputParams SubTP;
43 if (!havebstr("sc_button")) {
48 memset(&SubTP, 0, sizeof(WCTemplputParams));
50 serv_puts(bstr("g_cmd"));
51 StrBuf_ServGetln(Buf);
53 switch (GetServerStatus(Buf, NULL)) {
56 if ( (StrLength(Buf)==3) &&
57 !strcmp(ChrPtr(Buf), "000")) {
58 StrBufAppendBufPlain(Buf, HKEY("\000"), 0);
62 LineBuf = NewStrBuf();
63 StrBufAppendBufPlain(Buf, HKEY("\n"), 0);
65 StrBuf_ServGetln(LineBuf);
66 if ( (StrLength(LineBuf)==3) &&
67 !strcmp(ChrPtr(LineBuf), "000")) {
70 StrBufAppendBuf(Buf, LineBuf, 0);
71 StrBufAppendBufPlain(Buf, HKEY("\n"), 0);
78 text_to_server(bstr("g_input"));
82 len = atol(&ChrPtr(Buf)[4]);
83 StrBuf_ServGetBLOBBuffered(Buf, len);
86 len = atol(&ChrPtr(Buf)[4]);
89 serv_write(junk, len);
95 output_headers(1, 0, 0, 0, 1, 0);
97 SubTP.Filter.ContextType = CTX_STRBUF;
100 DoTemplate(HKEY("aide_display_generic_result"), NULL, &SubTP);
108 * Display the wait / input dialog while restarting the server.
110 void display_shutdown(void)
116 if (strcmp(when, "now") == 0){
117 serv_printf("DOWN 1");
118 serv_getln(buf, sizeof buf);
119 if (atol(buf) == 500)
120 { /* upsie. maybe the server is not running as daemon? */
122 safestrncpy(WC->ImportantMessage,
124 sizeof WC->ImportantMessage);
127 output_headers(1, 0, 0, 0, 1, 0);
128 DoTemplate(HKEY("aide_display_serverrestart"), NULL, &NoCtx);
130 lingering_close(WC->Hdr->http_sock);
135 else if (strcmp(when, "page") == 0) {
138 message = bstr("message");
139 if ((message == NULL) || (IsEmptyStr(message)))
142 output_headers(1, 0, 0, 0, 1, 0);
143 DoTemplate(HKEY("aide_display_serverrestart_page"), NULL, &NoCtx);
148 serv_printf("SEXP broadcast|%s", message);
149 serv_getln(buf, sizeof buf); /* TODO: should we care? */
151 output_headers(1, 0, 0, 0, 1, 0);
152 DoTemplate(HKEY("aide_display_serverrestart_page"), NULL, &NoCtx);
156 else if (!strcmp(when, "idle")) {
157 serv_printf("SCDN 3");
158 serv_getln(buf, sizeof buf);
160 if (atol(buf) == 500)
161 { /* upsie. maybe the server is not running as daemon? */
162 safestrncpy(WC->ImportantMessage,
164 sizeof WC->ImportantMessage);
167 output_headers(1, 0, 0, 0, 1, 0);
168 DoTemplate(HKEY("aide_display_menu"), NULL, &NoCtx);
177 WebcitAddUrlHandler(HKEY("display_aide_menu"), "", 0, display_aide_menu, 0);
178 WebcitAddUrlHandler(HKEY("server_shutdown"), "", 0, display_shutdown, 0);
179 WebcitAddUrlHandler(HKEY("display_main_menu"), "", 0, display_main_menu, 0);
180 WebcitAddUrlHandler(HKEY("do_generic"), "", 0, do_generic, 0);