* summary.c: summary screen is now updated using ajax instead of refreshing
[citadel.git] / webcit / siteconfig.c
1 /*
2  * $Id$
3  *
4  * Administrative screen for site-wide configuration
5  *
6  */
7
8
9 #include "webcit.h"
10
11
12 void display_siteconfig(void)
13 {
14         char buf[SIZ];
15         char *whichmenu;
16         int i, j;
17
18         /* expire policy settings */
19         int sitepolicy = 0;
20         int sitevalue = 0;
21         int mboxpolicy = 0;
22         int mboxvalue = 0;
23
24         output_headers(1, 1, 2, 0, 0, 0);
25         wprintf("<div id=\"banner\">\n"
26                 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
27                 "<SPAN CLASS=\"titlebar\">");
28         wprintf(_("Site configuration"));
29         wprintf("</SPAN>"
30                 "</TD></TR></TABLE>\n"
31                 "</div>\n<div id=\"content\">\n"
32         );
33
34         wprintf("<div id=\"fix_scrollbar_bug\">"
35                 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>");
36
37         whichmenu = bstr("whichmenu");
38
39         if (!strcmp(whichmenu, "")) {
40                 wprintf("<TABLE border=0 cellspacing=0 cellpadding=3 width=100%%>\n");
41
42                 wprintf("<TR BGCOLOR=\"#CCCCCC\"><TD>"
43                         "<A HREF=\"/display_siteconfig?whichmenu=general\">"
44                         "<IMG BORDER=\"0\" WIDTH=\"48\" HEIGHT=\"48\" "
45                         "SRC=\"/static/advanpage2_48x.gif\" ALT=\"&nbsp;\">"
46                         "</TD><TD>"
47                         "<A HREF=\"/display_siteconfig?whichmenu=general\">"
48                         "<B>%s</B><br />"
49                         "%s"
50                         "</A></TD></TR>\n",
51                         _("General"),
52                         _("General site configuration items")
53                 );
54
55                 wprintf("<TR><TD>"
56                         "<A HREF=\"/display_siteconfig?whichmenu=access\">"
57                         "<IMG BORDER=\"0\" WIDTH=\"48\" HEIGHT=\"48\" "
58                         "SRC=\"/static/advanpage2_48x.gif\" ALT=\"&nbsp;\">"
59                         "</TD><TD>"
60                         "<A HREF=\"/display_siteconfig?whichmenu=access\">"
61                         "<B>%s</B><br />"
62                         "%s"
63                         "</A></TD></TR>\n",
64                         _("Access"),
65                         _("Access controls and site policy settings")
66                 );
67
68                 wprintf("<TR BGCOLOR=\"#CCCCCC\"><TD>"
69                         "<A HREF=\"/display_siteconfig?whichmenu=network\">"
70                         "<IMG BORDER=\"0\" WIDTH=\"48\" HEIGHT=\"48\" "
71                         "SRC=\"/static/advanpage2_48x.gif\" ALT=\"&nbsp;\">"
72                         "</TD><TD>"
73                         "<A HREF=\"/display_siteconfig?whichmenu=network\">"
74                         "<B>%s</B><br />"
75                         "%s"
76                         "</A></TD></TR>\n",
77                         _("Network"),
78                         _("Network services")
79                 );
80
81                 wprintf("<TR><TD>"
82                         "<A HREF=\"/display_siteconfig?whichmenu=tuning\">"
83                         "<IMG BORDER=\"0\" WIDTH=\"48\" HEIGHT=\"48\" "
84                         "SRC=\"/static/advanpage2_48x.gif\" ALT=\"&nbsp;\">"
85                         "</TD><TD>"
86                         "<A HREF=\"/display_siteconfig?whichmenu=tuning\">"
87                         "<B>%s</B><br />"
88                         "%s"
89                         "</A></TD></TR>\n",
90                         _("Tuning"),
91                         _("Advanced server fine-tuning controls")
92                 );
93
94                 wprintf("<TR BGCOLOR=\"#CCCCCC\"><TD>"
95                         "<A HREF=\"/display_siteconfig?whichmenu=ldap\">"
96                         "<IMG BORDER=\"0\" WIDTH=\"48\" HEIGHT=\"48\" "
97                         "SRC=\"/static/advanpage2_48x.gif\" ALT=\"&nbsp;\">"
98                         "</TD><TD>"
99                         "<A HREF=\"/display_siteconfig?whichmenu=ldap\">"
100                         "<B>%s</B><br />"
101                         "%s"
102                         "</A></TD></TR>\n",
103                         _("Directory"),
104                         _("Configure the LDAP connector for Citadel")
105                 );
106
107                 wprintf("<TR><TD>"
108                         "<A HREF=\"/display_siteconfig?whichmenu=purger\">"
109                         "<IMG BORDER=\"0\" WIDTH=\"48\" HEIGHT=\"48\" "
110                         "SRC=\"/static/advanpage2_48x.gif\" ALT=\"&nbsp;\">"
111                         "</TD><TD>"
112                         "<A HREF=\"/display_siteconfig?whichmenu=purger\">"
113                         "<B>%s</B><br />"
114                         "%s"
115                         "</A></TD></TR>\n",
116                         _("Auto-purger"),
117                         _("Configure automatic expiry of old messages")
118                 );
119
120                 wprintf("</TABLE>");
121                 wprintf("</td></tr></table></center>\n");
122                 wDumpContent(1);
123                 return;
124         }
125
126         if (!strcasecmp(whichmenu, "general")) {
127                 wprintf("<div align=\"center\"><h2>");
128                 wprintf(_("General site configuration items"));
129                 wprintf("</h2></div>\n");
130         }
131
132         if (!strcasecmp(whichmenu, "access")) {
133                 wprintf("<div align=\"center\"><h2>");
134                 wprintf(_("Access controls and site policy settings"));
135                 wprintf("</h2></div>\n");
136         }
137
138         if (!strcasecmp(whichmenu, "network")) {
139                 wprintf("<div align=\"center\"><h2>");
140                 wprintf(_("Network services"));
141                 wprintf("</h2>");
142                 wprintf(_("Changes made on this screen will not take effect "
143                         "until you restart the Citadel server."));
144                 wprintf("</div>\n");
145         }
146
147         if (!strcasecmp(whichmenu, "tuning")) {
148                 wprintf("<div align=\"center\"><h2>");
149                 wprintf(_("Advanced server fine-tuning controls"));
150                 wprintf("</h2></div>\n");
151         }
152
153         if (!strcasecmp(whichmenu, "ldap")) {
154                 wprintf("<div align=\"center\"><h2>");
155                 wprintf(_("Citadel LDAP connector configuration"));
156                 wprintf("</h2>");
157                 wprintf(_("Changes made on this screen will not take effect "
158                         "until you restart the Citadel server."));
159                 wprintf("</div>\n");
160         }
161
162         if (!strcasecmp(whichmenu, "purger")) {
163                 wprintf("<div align=\"center\"><h2>");
164                 wprintf(_("Message auto-purger settings"));
165                 wprintf("</h2>");
166                 wprintf(_("These settings may be overridden on a per-floor or per-room basis."));
167                 wprintf("</div>\n");
168         }
169
170         serv_printf("CONF get");
171         serv_getln(buf, sizeof buf);
172         if (buf[0] != '1') {
173                 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
174                 wprintf("<SPAN CLASS=\"titlebar\">");
175                 wprintf(_("Error"));
176                 wprintf("</SPAN>\n");
177                 wprintf("</TD></TR></TABLE><br />\n");
178                 wprintf("%s<br />\n", &buf[4]);
179                 do_template("endbox");
180                 wDumpContent(1);
181                 return;
182         }
183
184         wprintf("<FORM METHOD=\"POST\" ACTION=\"/siteconfig\">\n");
185         wprintf("<TABLE border=0>\n");
186
187         i = 0;
188         while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
189                 switch (++i) {
190                 case 1:
191                         if (!strcasecmp(whichmenu, "general")) {
192                                 wprintf("<TR><TD>");
193                                 wprintf(_("Node name"));
194                                 wprintf("</TD><TD>");
195                                 wprintf("<input type=\"text\" NAME=\"c_nodename\" MAXLENGTH=\"15\" VALUE=\"%s\">", buf);
196                                 wprintf("</TD></TR>\n");
197                         }
198                         else {
199                                 wprintf("<input type=\"hidden\" NAME=\"c_nodename\" VALUE=\"%s\">", buf);
200                         }
201                         break;
202                 case 2:
203                         if (!strcasecmp(whichmenu, "general")) {
204                                 wprintf("<TR><TD>");
205                                 wprintf(_("Fully qualified domain name"));
206                                 wprintf("</TD><TD>");
207                                 wprintf("<input type=\"text\" NAME=\"c_fqdn\" MAXLENGTH=\"63\" VALUE=\"%s\">", buf);
208                                 wprintf("</TD></TR>\n");
209                         }
210                         else {
211                                 wprintf("<input type=\"hidden\" NAME=\"c_fqdn\" VALUE=\"%s\">", buf);
212                         }
213                         break;
214                 case 3:
215                         if (!strcasecmp(whichmenu, "general")) {
216                                 wprintf("<TR><TD>");
217                                 wprintf(_("Human-readable node name"));
218                                 wprintf("</TD><TD>");
219                                 wprintf("<input type=\"text\" NAME=\"c_humannode\" MAXLENGTH=\"20\" VALUE=\"%s\">", buf);
220                                 wprintf("</TD></TR>\n");
221                         }
222                         else {
223                                 wprintf("<input type=\"hidden\" NAME=\"c_humannode\" VALUE=\"%s\">", buf);
224                         }
225                         break;
226                 case 4:
227                         if (!strcasecmp(whichmenu, "general")) {
228                                 wprintf("<TR><TD>");
229                                 wprintf(_("Telephone number"));
230                                 wprintf("</TD><TD>");
231                                 wprintf("<input type=\"text\" NAME=\"c_phonenum\" MAXLENGTH=\"15\" VALUE=\"%s\">", buf);
232                                 wprintf("</TD></TR>\n");
233                         }
234                         else {
235                                 wprintf("<input type=\"hidden\" NAME=\"c_phonenum\" VALUE=\"%s\">", buf);
236                         }
237                         break;
238                 case 5:
239                         if (!strcasecmp(whichmenu, "access")) {
240                                 wprintf("<TR><TD>");
241                                 wprintf(_("Automatically grant room-aide status to users who create private rooms"));
242                                 wprintf("</TD><TD>");
243                                 wprintf("<input type=\"checkbox\" NAME=\"c_creataide\" VALUE=\"yes\" %s>",
244                                         ((atoi(buf) != 0) ? "CHECKED" : ""));
245                                 wprintf("</TD></TR>\n");
246                         }
247                         else {
248                                 wprintf("<input type=\"hidden\" NAME=\"c_creataide\" VALUE=\"%s\">", buf);
249                         }
250                         break;
251                 case 6:
252                         if (!strcasecmp(whichmenu, "tuning")) {
253                                 wprintf("<TR><TD>");
254                                 wprintf(_("Server connection idle timeout (in seconds)"));
255                                 wprintf("</TD><TD>");
256                                 wprintf("<input type=\"text\" NAME=\"c_sleeping\" MAXLENGTH=\"15\" VALUE=\"%s\">", buf);
257                                 wprintf("</TD></TR>\n");
258                         }
259                         else {
260                                 wprintf("<input type=\"hidden\" NAME=\"c_sleeping\" VALUE=\"%s\">", buf);
261                         }
262                         break;
263                 case 7:
264                         if (!strcasecmp(whichmenu, "access")) {
265                                 wprintf("<TR><TD>");
266                                 wprintf(_("Initial access level for new users"));
267                                 wprintf("</TD><TD>");
268                                 wprintf("<SELECT NAME=\"c_initax\" SIZE=\"1\">\n");
269                                 for (j=0; j<=6; ++j) {
270                                         wprintf("<OPTION %s VALUE=\"%d\">%d - %s</OPTION>\n",
271                                                 ((atoi(buf) == j) ? "SELECTED" : ""),
272                                                 j, j, axdefs[j]
273                                         );
274                                 }
275                                 wprintf("</SELECT>");
276                                 wprintf("</TD></TR>\n");
277                         }
278                         else {
279                                 wprintf("<input type=\"hidden\" NAME=\"c_initax\" VALUE=\"%s\">", buf);
280                         }
281                         break;
282                 case 8:
283                         if (!strcasecmp(whichmenu, "access")) {
284                                 wprintf("<TR><TD>");
285                                 wprintf(_("Require registration for new users"));
286                                 wprintf("</TD><TD>");
287                                 wprintf("<input type=\"checkbox\" NAME=\"c_regiscall\" VALUE=\"yes\" %s>",
288                                         ((atoi(buf) != 0) ? "CHECKED" : ""));
289                                 wprintf("</TD></TR>\n");
290                         }
291                         else {
292                                 wprintf("<input type=\"hidden\" NAME=\"c_regiscall\" VALUE=\"%s\">", buf);
293                         }
294                         break;
295                 case 9:
296                         if (!strcasecmp(whichmenu, "access")) {
297                                 wprintf("<TR><TD>");
298                                 wprintf(_("Quarantine messages from problem users"));
299                                 wprintf("</TD><TD>");
300                                 wprintf("<input type=\"checkbox\" NAME=\"c_twitdetect\" VALUE=\"yes\" %s>",
301                                         ((atoi(buf) != 0) ? "CHECKED" : ""));
302                                 wprintf("</TD></TR>\n");
303                         }
304                         else {
305                                 wprintf("<input type=\"hidden\" NAME=\"c_twitdetect\" VALUE=\"%s\">", buf);
306                         }
307                         break;
308                 case 10:
309                         if (!strcasecmp(whichmenu, "access")) {
310                                 wprintf("<TR><TD>");
311                                 wprintf(_("Name of quarantine room"));
312                                 wprintf("</TD><TD>");
313                                 wprintf("<input type=\"text\" NAME=\"c_twitroom\" MAXLENGTH=\"63\" VALUE=\"%s\">", buf);
314                                 wprintf("</TD></TR>\n");
315                         }
316                         else {
317                                 wprintf("<input type=\"hidden\" NAME=\"c_twitroom\" VALUE=\"%s\">", buf);
318                         }
319                         break;
320                 case 11:
321                         if (!strcasecmp(whichmenu, "general")) {
322                                 wprintf("<TR><TD>");
323                                 wprintf(_("Paginator prompt (for text mode clients)"));
324                                 wprintf("</TD><TD>");
325                                 wprintf("<input type=\"text\" NAME=\"c_moreprompt\" MAXLENGTH=\"79\" VALUE=\"%s\">", buf);
326                                 wprintf("</TD></TR>\n");
327                         }
328                         else {
329                                 wprintf("<input type=\"hidden\" NAME=\"c_moreprompt\" VALUE=\"%s\">", buf);
330                         }
331                         break;
332                 case 12:
333                         if (!strcasecmp(whichmenu, "access")) {
334                                 wprintf("<TR><TD>");
335                                 wprintf(_("Restrict access to Internet mail"));
336                                 wprintf("</TD><TD>");
337                                 wprintf("<input type=\"checkbox\" NAME=\"c_restrict\" VALUE=\"yes\" %s>",
338                                         ((atoi(buf) != 0) ? "CHECKED" : ""));
339                                 wprintf("</TD></TR>\n");
340                         }
341                         else {
342                                 wprintf("<input type=\"hidden\" NAME=\"c_restrict\" VALUE=\"%s\">", buf);
343                         }
344                         break;
345                 case 13:
346                         if (!strcasecmp(whichmenu, "general")) {
347                                 wprintf("<TR><TD>");
348                                 wprintf(_("Geographic location of this system"));
349                                 wprintf("</TD><TD>");
350                                 wprintf("<input type=\"text\" NAME=\"c_bbs_city\" MAXLENGTH=\"31\" VALUE=\"%s\">", buf);
351                                 wprintf("</TD></TR>\n");
352                         }
353                         else {
354                                 wprintf("<input type=\"hidden\" NAME=\"c_bbs_city\" VALUE=\"%s\">", buf);
355                         }
356                         break;
357                 case 14:
358                         if (!strcasecmp(whichmenu, "general")) {
359                                 wprintf("<TR><TD>");
360                                 wprintf(_("Name of system administrator"));
361                                 wprintf("</TD><TD>");
362                                 wprintf("<input type=\"text\" NAME=\"c_sysadm\" MAXLENGTH=\"25\" VALUE=\"%s\">", buf);
363                                 wprintf("</TD></TR>\n");
364                         }
365                         else {
366                                 wprintf("<input type=\"hidden\" NAME=\"c_sysadm\" VALUE=\"%s\">", buf);
367                         }
368                         break;
369                 case 15:
370                         if (!strcasecmp(whichmenu, "tuning")) {
371                                 wprintf("<TR><TD>");
372                                 wprintf(_("Maximum concurrent sessions (0 = no limit)"));
373                                 wprintf("</TD><TD>");
374                                 wprintf("<input type=\"text\" NAME=\"c_maxsessions\" MAXLENGTH=\"5\" VALUE=\"%s\">", buf);
375                                 wprintf("</TD></TR>\n");
376                         }
377                         else {
378                                 wprintf("<input type=\"hidden\" NAME=\"c_maxsessions\" VALUE=\"%s\">", buf);
379                         }
380                         break;
381                 case 17:
382                         if (!strcasecmp(whichmenu, "tuning")) {
383                                 wprintf("<TR><TD>");
384                                 wprintf(_("Default user purge time (days)"));
385                                 wprintf("</TD><TD>");
386                                 wprintf("<input type=\"text\" NAME=\"c_userpurge\" MAXLENGTH=\"5\" VALUE=\"%s\">", buf);
387                                 wprintf("</TD></TR>\n");
388                         }
389                         else {
390                                 wprintf("<input type=\"hidden\" NAME=\"c_userpurge\" VALUE=\"%s\">", buf);
391                         }
392                         break;
393                 case 18:
394                         if (!strcasecmp(whichmenu, "tuning")) {
395                                 wprintf("<TR><TD>");
396                                 wprintf(_("Default room purge time (days)"));
397                                 wprintf("</TD><TD>");
398                                 wprintf("<input type=\"text\" NAME=\"c_roompurge\" MAXLENGTH=\"5\" VALUE=\"%s\">", buf);
399                                 wprintf("</TD></TR>\n");
400                         }
401                         else {
402                                 wprintf("<input type=\"hidden\" NAME=\"c_roompurge\" VALUE=\"%s\">", buf);
403                         }
404                         break;
405                 case 19:
406                         if (!strcasecmp(whichmenu, "access")) {
407                                 wprintf("<TR><TD>");
408                                 wprintf(_("Name of room to log pages"));
409                                 wprintf("</TD><TD>");
410                                 wprintf("<input type=\"text\" NAME=\"c_logpages\" MAXLENGTH=\"63\" VALUE=\"%s\">", buf);
411                                 wprintf("</TD></TR>\n");
412                         }
413                         else {
414                                 wprintf("<input type=\"hidden\" NAME=\"c_logpages\" VALUE=\"%s\">", buf);
415                         }
416                         break;
417                 case 20:
418                         if (!strcasecmp(whichmenu, "access")) {
419                                 wprintf("<TR><TD>");
420                                 wprintf(_("Access level required to create rooms"));
421                                 wprintf("</TD><TD>");
422                                 wprintf("<SELECT NAME=\"c_createax\" SIZE=\"1\">\n");
423                                 for (j=0; j<=6; ++j) {
424                                         wprintf("<OPTION %s VALUE=\"%d\">%d - %s</OPTION>\n",
425                                                 ((atoi(buf) == j) ? "SELECTED" : ""),
426                                                 j, j, axdefs[j]
427                                         );
428                                 }
429                                 wprintf("</SELECT>");
430                                 wprintf("</TD></TR>\n");
431                         }
432                         else {
433                                 wprintf("<input type=\"hidden\" NAME=\"c_createax\" VALUE=\"%s\">", buf);
434                         }
435                         break;
436                 case 21:
437                         if (!strcasecmp(whichmenu, "tuning")) {
438                                 wprintf("<TR><TD>");
439                                 wprintf(_("Maximum message length"));
440                                 wprintf("</TD><TD>");
441                                 wprintf("<input type=\"text\" NAME=\"c_maxmsglen\" MAXLENGTH=\"20\" VALUE=\"%s\">", buf);
442                                 wprintf("</TD></TR>\n");
443                         }
444                         else {
445                                 wprintf("<input type=\"hidden\" NAME=\"c_maxmsglen\" VALUE=\"%s\">", buf);
446                         }
447                         break;
448                 case 22:
449                         if (!strcasecmp(whichmenu, "tuning")) {
450                                 wprintf("<TR><TD>");
451                                 wprintf(_("Minimum number of worker threads"));
452                                 wprintf("</TD><TD>");
453                                 wprintf("<input type=\"text\" NAME=\"c_min_workers\" MAXLENGTH=\"5\" VALUE=\"%s\">", buf);
454                                 wprintf("</TD></TR>\n");
455                         }
456                         else {
457                                 wprintf("<input type=\"hidden\" NAME=\"c_min_workers\" VALUE=\"%s\">", buf);
458                         }
459                         break;
460                 case 23:
461                         if (!strcasecmp(whichmenu, "tuning")) {
462                                 wprintf("<TR><TD>");
463                                 wprintf(_("Maximum number of worker threads"));
464                                 wprintf("</TD><TD>");
465                                 wprintf("<input type=\"text\" NAME=\"c_max_workers\" MAXLENGTH=\"5\" VALUE=\"%s\">", buf);
466                                 wprintf("</TD></TR>\n");
467                         }
468                         else {
469                                 wprintf("<input type=\"hidden\" NAME=\"c_max_workers\" VALUE=\"%s\">", buf);
470                         }
471                         break;
472                 case 24:
473                         if (!strcasecmp(whichmenu, "network")) {
474                                 wprintf("<TR><TD>");
475                                 wprintf(_("POP3 listener port (-1 to disable)"));
476                                 wprintf("</TD><TD>");
477                                 wprintf("<input type=\"text\" NAME=\"c_pop3_port\" MAXLENGTH=\"5\" VALUE=\"%s\">", buf);
478                                 wprintf("</TD></TR>\n");
479                         }
480                         else {
481                                 wprintf("<input type=\"hidden\" NAME=\"c_pop3_port\" VALUE=\"%s\">", buf);
482                         }
483                         break;
484                 case 25:
485                         if (!strcasecmp(whichmenu, "network")) {
486                                 wprintf("<TR><TD>");
487                                 wprintf(_("SMTP MTA port (-1 to disable)"));
488                                 wprintf("</TD><TD>");
489                                 wprintf("<input type=\"text\" NAME=\"c_smtp_port\" MAXLENGTH=\"5\" VALUE=\"%s\">", buf);
490                                 wprintf("</TD></TR>\n");
491                         }
492                         else {
493                                 wprintf("<input type=\"hidden\" NAME=\"c_smtp_port\" VALUE=\"%s\">", buf);
494                         }
495                         break;
496                 case 27:
497                         if (!strcasecmp(whichmenu, "access")) {
498                                 wprintf("<TR><TD>");
499                                 wprintf(_("Allow aides to zap (forget) rooms"));
500                                 wprintf("</TD><TD>");
501                                 wprintf("<input type=\"checkbox\" NAME=\"c_aide_zap\" VALUE=\"yes\" %s>",
502                                         ((atoi(buf) != 0) ? "CHECKED" : ""));
503                                 wprintf("</TD></TR>\n");
504                         }
505                         else {
506                                 wprintf("<input type=\"hidden\" NAME=\"c_aide_zap\" VALUE=\"%s\">", buf);
507                         }
508                         break;
509                 case 28:
510                         if (!strcasecmp(whichmenu, "network")) {
511                                 wprintf("<TR><TD>");
512                                 wprintf(_("IMAP listener port (-1 to disable)"));
513                                 wprintf("</TD><TD>");
514                                 wprintf("<input type=\"text\" NAME=\"c_imap_port\" MAXLENGTH=\"5\" VALUE=\"%s\">", buf);
515                                 wprintf("</TD></TR>\n");
516                         }
517                         else {
518                                 wprintf("<input type=\"hidden\" NAME=\"c_imap_port\" VALUE=\"%s\">", buf);
519                         }
520                         break;
521                 case 29:
522                         if (!strcasecmp(whichmenu, "network")) {
523                                 wprintf("<TR><TD>");
524                                 wprintf(_("Network run frequency (in seconds)"));
525                                 wprintf("</TD><TD>");
526                                 wprintf("<input type=\"text\" NAME=\"c_net_freq\" MAXLENGTH=\"5\" VALUE=\"%s\">", buf);
527                                 wprintf("</TD></TR>\n");
528                         }
529                         else {
530                                 wprintf("<input type=\"hidden\" NAME=\"c_net_freq\" VALUE=\"%s\">", buf);
531                         }
532                         break;
533                 case 30:
534                         if (!strcasecmp(whichmenu, "access")) {
535                                 wprintf("<TR><TD>");
536                                 wprintf(_("Disable self-service user account creation"));
537                                 wprintf("</TD><TD>");
538                                 wprintf("<input type=\"checkbox\" NAME=\"c_disable_newu\" VALUE=\"yes\" %s>",
539                                         ((atoi(buf) != 0) ? "CHECKED" : ""));
540                                 wprintf("</TD></TR>\n");
541                         }
542                         else {
543                                 wprintf("<input type=\"hidden\" NAME=\"c_disable_newu\" VALUE=\"%s\">", buf);
544                         }
545                         break;
546                 case 31:
547                         /* position 31 is no longer in use */
548                         break;
549                 case 32:
550                         if (!strcasecmp(whichmenu, "purger")) {
551                                 wprintf("<TR><TD>");
552                                 wprintf(_("Hour to run database auto-purge"));
553                                 wprintf("</TD><TD>");
554                                 wprintf("<SELECT NAME=\"c_purge_hour\" SIZE=\"1\">\n");
555                                 for (j=0; j<=23; ++j) {
556                                         wprintf("<OPTION %s VALUE=\"%d\">%d:00%s</OPTION>\n",
557                                                 ((atoi(buf) == j) ? "SELECTED" : ""),
558                                                 j,
559                                                 ((j == 0) ? 12 : ((j>12) ? j-12 : j)),
560                                                 ((j >= 12) ? "pm" : "am")
561                                         );
562                                 }
563                                 wprintf("</SELECT>");
564                                 wprintf("</TD></TR>\n");
565                         }
566                         else {
567                                 wprintf("<input type=\"hidden\" NAME=\"c_purge_hour\" VALUE=\"%s\">", buf);
568                         }
569                         break;
570                 case 33:
571                         if ( (serv_info.serv_supports_ldap) && (!strcasecmp(whichmenu, "ldap")) ) {
572                                 wprintf("<TR><TD>");
573                                 wprintf(_("Host name of LDAP server (blank to disable)"));
574                                 wprintf("</TD><TD>");
575                                 wprintf("<input type=\"text\" NAME=\"c_ldap_host\" MAXLENGTH=\"127\" VALUE=\"%s\">", buf);
576                                 wprintf("</TD></TR>\n");
577                         }
578                         else {
579                                 wprintf("<input type=\"hidden\" NAME=\"c_ldap_host\" VALUE=\"%s\">", buf);
580                         }
581                         break;
582                 case 34:
583                         if ( (serv_info.serv_supports_ldap) && (!strcasecmp(whichmenu, "ldap")) ) {
584                                 wprintf("<TR><TD>");
585                                 wprintf(_("Port number of LDAP server (blank to disable)"));
586                                 wprintf("</TD><TD>");
587                                 wprintf("<input type=\"text\" NAME=\"c_ldap_port\" MAXLENGTH=\"127\" VALUE=\"%d\">", atoi(buf));
588                                 wprintf("</TD></TR>\n");
589                         }
590                         else {
591                                 wprintf("<input type=\"hidden\" NAME=\"c_ldap_port\" VALUE=\"%d\">", atoi(buf));
592                         }
593                         break;
594                 case 35:
595                         if ( (serv_info.serv_supports_ldap) && (!strcasecmp(whichmenu, "ldap")) ) {
596                                 wprintf("<TR><TD>");
597                                 wprintf(_("Base DN"));
598                                 wprintf("</TD><TD>");
599                                 wprintf("<input type=\"text\" NAME=\"c_ldap_base_dn\" MAXLENGTH=\"255\" VALUE=\"%s\">", buf);
600                                 wprintf("</TD></TR>\n");
601                         }
602                         else {
603                                 wprintf("<input type=\"hidden\" NAME=\"c_ldap_base_dn\" VALUE=\"%s\">", buf);
604                         }
605                         break;
606                 case 36:
607                         if ( (serv_info.serv_supports_ldap) && (!strcasecmp(whichmenu, "ldap")) ) {
608                                 wprintf("<TR><TD>");
609                                 wprintf(_("Bind DN"));
610                                 wprintf("</TD><TD>");
611                                 wprintf("<input type=\"text\" NAME=\"c_ldap_bind_dn\" MAXLENGTH=\"255\" VALUE=\"%s\">", buf);
612                                 wprintf("</TD></TR>\n");
613                         }
614                         else {
615                                 wprintf("<input type=\"hidden\" NAME=\"c_ldap_bind_dn\" VALUE=\"%s\">", buf);
616                         }
617                         break;
618                 case 37:
619                         if ( (serv_info.serv_supports_ldap) && (!strcasecmp(whichmenu, "ldap")) ) {
620                                 wprintf("<TR><TD>");
621                                 wprintf(_("Password for bind DN"));
622                                 wprintf("</TD><TD>");
623                                 wprintf("<input type=\"password\" NAME=\"c_ldap_bind_pw\" MAXLENGTH=\"255\" VALUE=\"%s\">",
624                                         buf);
625                                 wprintf("</TD></TR>\n");
626                         }
627                         else {
628                                 wprintf("<input type=\"hidden\" NAME=\"c_ldap_bind_pw\" VALUE=\"%s\">", buf);
629                         }
630                         break;
631                 case 38:
632                         if (!strcasecmp(whichmenu, "network")) {
633                                 wprintf("<TR><TD>");
634                                 wprintf(_("Server IP address (0.0.0.0 for 'any')"));
635                                 wprintf("</TD><TD>");
636                                 wprintf("<input type=\"text\" NAME=\"c_ip_addr\" MAXLENGTH=\"15\" VALUE=\"%s\">", buf);
637                                 wprintf("</TD></TR>\n");
638                         }
639                         else {
640                                 wprintf("<input type=\"hidden\" NAME=\"c_ip_addr\" VALUE=\"%s\">", buf);
641                         }
642                         break;
643                 case 39:
644                         if (!strcasecmp(whichmenu, "network")) {
645                                 wprintf("<TR><TD>");
646                                 wprintf(_("SMTP MSA port (-1 to disable)"));
647                                 wprintf("</TD><TD>");
648                                 wprintf("<input type=\"text\" NAME=\"c_msa_port\" MAXLENGTH=\"5\" VALUE=\"%s\">", buf);
649                                 wprintf("</TD></TR>\n");
650                         }
651                         else {
652                                 wprintf("<input type=\"hidden\" NAME=\"c_msa_port\" VALUE=\"%s\">", buf);
653                         }
654                         break;
655                 case 40:
656                         if (!strcasecmp(whichmenu, "network")) {
657                                 wprintf("<TR><TD>");
658                                 wprintf(_("IMAP over SSL port (-1 to disable)"));
659                                 wprintf("</TD><TD>");
660                                 wprintf("<input type=\"text\" NAME=\"c_imaps_port\" MAXLENGTH=\"5\" VALUE=\"%s\">", buf);
661                                 wprintf("</TD></TR>\n");
662                         }
663                         else {
664                                 wprintf("<input type=\"hidden\" NAME=\"c_imaps_port\" VALUE=\"%s\">", buf);
665                         }
666                         break;
667                 case 41:
668                         if (!strcasecmp(whichmenu, "network")) {
669                                 wprintf("<TR><TD>");
670                                 wprintf(_("POP3 over SSL port (-1 to disable)"));
671                                 wprintf("</TD><TD>");
672                                 wprintf("<input type=\"text\" NAME=\"c_pop3s_port\" MAXLENGTH=\"5\" VALUE=\"%s\">", buf);
673                                 wprintf("</TD></TR>\n");
674                         }
675                         else {
676                                 wprintf("<input type=\"hidden\" NAME=\"c_pop3s_port\" VALUE=\"%s\">", buf);
677                         }
678                         break;
679                 case 42:
680                         if (!strcasecmp(whichmenu, "network")) {
681                                 wprintf("<TR><TD>");
682                                 wprintf(_("SMTP over SSL port (-1 to disable)"));
683                                 wprintf("</TD><TD>");
684                                 wprintf("<input type=\"text\" NAME=\"c_smtps_port\" MAXLENGTH=\"5\" VALUE=\"%s\">", buf);
685                                 wprintf("</TD></TR>\n");
686                         }
687                         else {
688                                 wprintf("<input type=\"hidden\" NAME=\"c_smtps_port\" VALUE=\"%s\">", buf);
689                         }
690                         break;
691                 case 43:
692                         if (!strcasecmp(whichmenu, "general")) {
693                                 wprintf("<TR><TD>");
694                                 wprintf(_("Enable full text index (warning: resource intensive)"));
695                                 wprintf("</TD><TD>");
696                                 wprintf("<input type=\"checkbox\" NAME=\"c_enable_fulltext\" VALUE=\"yes\" %s>",
697                                         ((atoi(buf) != 0) ? "CHECKED" : ""));
698                                 wprintf("</TD></TR>\n");
699                         }
700                         else {
701                                 wprintf("<input type=\"hidden\" NAME=\"c_enable_fulltext\" VALUE=\"%s\">", buf);
702                         }
703                         break;
704                 case 44:
705                         if (!strcasecmp(whichmenu, "tuning")) {
706                                 wprintf("<TR><TD>");
707                                 wprintf(_("Automatically delete committed database logs"));
708                                 wprintf("</TD><TD>");
709                                 wprintf("<input type=\"checkbox\" NAME=\"c_auto_cull\" VALUE=\"yes\" %s>",
710                                         ((atoi(buf) != 0) ? "CHECKED" : ""));
711                                 wprintf("</TD></TR>\n");
712                         }
713                         else {
714                                 wprintf("<input type=\"hidden\" NAME=\"c_auto_cull\" VALUE=\"%s\">", buf);
715                         }
716                         break;
717                 case 45:
718                         if (!strcasecmp(whichmenu, "network")) {
719                                 wprintf("<TR><TD>");
720                                 wprintf(_("Instantly expunge deleted messages in IMAP"));
721                                 wprintf("</TD><TD>");
722                                 wprintf("<input type=\"checkbox\" NAME=\"c_instant_expunge\" VALUE=\"yes\" %s>",
723                                         ((atoi(buf) != 0) ? "CHECKED" : ""));
724                                 wprintf("</TD></TR>\n");
725                         }
726                         else {
727                                 wprintf("<input type=\"hidden\" NAME=\"c_instant_expunge\" VALUE=\"%s\">", buf);
728                         }
729                         break;
730                 case 46:
731                         if (!strcasecmp(whichmenu, "network")) {
732                                 wprintf("<TR><TD>");
733                                 wprintf(_("Allow unauthenticated SMTP clients to spoof this site's domains"));
734                                 wprintf("</TD><TD>");
735                                 wprintf("<input type=\"checkbox\" NAME=\"c_allow_spoofing\" VALUE=\"yes\" %s>",
736                                         ((atoi(buf) != 0) ? "CHECKED" : ""));
737                                 wprintf("</TD></TR>\n");
738                         }
739                         else {
740                                 wprintf("<input type=\"hidden\" NAME=\"c_allow_spoofing\" VALUE=\"%s\">", buf);
741                         }
742                         break;
743                 }
744         }
745
746         serv_puts("GPEX site");
747         serv_getln(buf, sizeof buf);
748         if (buf[0] == '2') {
749                 sitepolicy = extract_int(&buf[4], 0);
750                 sitevalue = extract_int(&buf[4], 1);
751         }
752
753         serv_puts("GPEX mailboxes");
754         serv_getln(buf, sizeof buf);
755         if (buf[0] == '2') {
756                 mboxpolicy = extract_int(&buf[4], 0);
757                 mboxvalue = extract_int(&buf[4], 1);
758         }
759
760         if (!strcasecmp(whichmenu, "purger")) {
761
762                 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
763
764                 wprintf("<TR><TD>");
765                 wprintf(_("Default message expire policy for public rooms"));
766                 wprintf("</TD><TD>");
767                 wprintf("<input type=\"radio\" NAME=\"sitepolicy\" VALUE=\"1\" %s>",
768                         ((sitepolicy == 1) ? "CHECKED" : "") );
769                 wprintf(_("Never automatically expire messages"));
770                 wprintf("<br />\n");
771                 wprintf("<input type=\"radio\" NAME=\"sitepolicy\" VALUE=\"2\" %s>",
772                         ((sitepolicy == 2) ? "CHECKED" : "") );
773                 wprintf(_("Expire by message count"));
774                 wprintf("<br />\n");
775                 wprintf("<input type=\"radio\" NAME=\"sitepolicy\" VALUE=\"3\" %s>",
776                         ((sitepolicy == 3) ? "CHECKED" : "") );
777                 wprintf(_("Expire by message age"));
778                 wprintf("<br />");
779                 wprintf(_("Number of messages or days: "));
780                 wprintf("<input type=\"text\" NAME=\"sitevalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", sitevalue);
781                 wprintf("</TD></TR>\n");
782
783                 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
784
785                 wprintf("<TR><TD>");
786                 wprintf(_("Default message expire policy for private mailboxes"));
787                 wprintf("</TD><TD>");
788                 wprintf("<input type=\"radio\" NAME=\"mboxpolicy\" VALUE=\"0\" %s>",
789                         ((mboxpolicy == 0) ? "CHECKED" : "") );
790                 wprintf(_("Same policy as public rooms"));
791                 wprintf("<br />\n");
792                 wprintf("<input type=\"radio\" NAME=\"mboxpolicy\" VALUE=\"1\" %s>",
793                         ((mboxpolicy == 1) ? "CHECKED" : "") );
794                 wprintf(_("Never automatically expire messages"));
795                 wprintf("<br />\n");
796                 wprintf("<input type=\"radio\" NAME=\"mboxpolicy\" VALUE=\"2\" %s>",
797                         ((mboxpolicy == 2) ? "CHECKED" : "") );
798                 wprintf(_("Expire by message count"));
799                 wprintf("<br />\n");
800                 wprintf("<input type=\"radio\" NAME=\"mboxpolicy\" VALUE=\"3\" %s>",
801                         ((mboxpolicy == 3) ? "CHECKED" : "") );
802                 wprintf(_("Expire by message age"));
803                 wprintf("<br />");
804                 wprintf(_("Number of messages or days: "));
805                 wprintf("<input type=\"text\" NAME=\"mboxvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", mboxvalue);
806                 wprintf("</TD></TR>\n");
807
808                 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
809
810         }
811         else {
812                 wprintf("<input type=\"hidden\" NAME=\"sitepolicy\" VALUE=\"%d\">\n", sitepolicy);
813                 wprintf("<input type=\"hidden\" NAME=\"sitevalue\" VALUE=\"%d\">\n", sitevalue);
814                 wprintf("<input type=\"hidden\" NAME=\"mboxpolicy\" VALUE=\"%d\">\n", mboxpolicy);
815                 wprintf("<input type=\"hidden\" NAME=\"mboxvalue\" VALUE=\"%d\">\n", mboxvalue);
816         }
817
818         wprintf("</TABLE><div align=\"center\">");
819         wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
820         wprintf("&nbsp;");
821         wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">\n", _("Cancel"));
822         wprintf("</div></FORM>\n");
823         wprintf("</td></tr></table></div>\n");
824         wDumpContent(1);
825 }
826
827
828 void siteconfig(void)
829 {
830         char buf[256];
831
832         if (strlen(bstr("ok_button")) == 0) {
833                 display_siteconfig();
834                 return;
835         }
836         serv_printf("CONF set");
837         serv_getln(buf, sizeof buf);
838         if (buf[0] != '4') {
839                 safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
840                 display_siteconfig();
841                 return;
842         }
843         serv_printf("%s", bstr("c_nodename"));
844         serv_printf("%s", bstr("c_fqdn"));
845         serv_printf("%s", bstr("c_humannode"));
846         serv_printf("%s", bstr("c_phonenum"));
847         serv_printf("%s", ((!strcasecmp(bstr("c_creataide"), "yes") ? "1" : "0")));
848         serv_printf("%s", bstr("c_sleeping"));
849         serv_printf("%s", bstr("c_initax"));
850         serv_printf("%s", ((!strcasecmp(bstr("c_regiscall"), "yes") ? "1" : "0")));
851         serv_printf("%s", ((!strcasecmp(bstr("c_twitdetect"), "yes") ? "1" : "0")));
852         serv_printf("%s", bstr("c_twitroom"));
853         serv_printf("%s", bstr("c_moreprompt"));
854         serv_printf("%s", ((!strcasecmp(bstr("c_restrict"), "yes") ? "1" : "0")));
855         serv_printf("%s", bstr("c_bbs_city"));
856         serv_printf("%s", bstr("c_sysadm"));
857         serv_printf("%s", bstr("c_maxsessions"));
858         serv_printf("");  /* networking password -- deprecated */
859         serv_printf("%s", bstr("c_userpurge"));
860         serv_printf("%s", bstr("c_roompurge"));
861         serv_printf("%s", bstr("c_logpages"));
862         serv_printf("%s", bstr("c_createax"));
863         serv_printf("%s", bstr("c_maxmsglen"));
864         serv_printf("%s", bstr("c_min_workers"));
865         serv_printf("%s", bstr("c_max_workers"));
866         serv_printf("%s", bstr("c_pop3_port"));
867         serv_printf("%s", bstr("c_smtp_port"));
868         serv_printf("");  /* moderation filter level -- not yet implemented */
869         serv_printf("%s", ((!strcasecmp(bstr("c_aide_zap"), "yes") ? "1" : "0")));
870         serv_printf("%s", bstr("c_imap_port"));
871         serv_printf("%s", bstr("c_net_freq"));
872         serv_printf("%s", ((!strcasecmp(bstr("c_disable_newu"), "yes") ? "1" : "0")));
873         serv_printf("1");
874         serv_printf("%s", bstr("c_purge_hour"));
875         serv_printf("%s", bstr("c_ldap_host"));
876         serv_printf("%s", bstr("c_ldap_port"));
877         serv_printf("%s", bstr("c_ldap_base_dn"));
878         serv_printf("%s", bstr("c_ldap_bind_dn"));
879         serv_printf("%s", bstr("c_ldap_bind_pw"));
880         serv_printf("%s", bstr("c_ip_addr"));
881         serv_printf("%s", bstr("c_msa_port"));
882         serv_printf("%s", bstr("c_imaps_port"));
883         serv_printf("%s", bstr("c_pop3s_port"));
884         serv_printf("%s", bstr("c_smtps_port"));
885         serv_printf("%s", ((!strcasecmp(bstr("c_enable_fulltext"), "yes") ? "1" : "0")));
886         serv_printf("%s", ((!strcasecmp(bstr("c_auto_cull"), "yes") ? "1" : "0")));
887         serv_printf("%s", ((!strcasecmp(bstr("c_instant_expunge"), "yes") ? "1" : "0")));
888         serv_printf("%s", ((!strcasecmp(bstr("c_allow_spoofing"), "yes") ? "1" : "0")));
889         serv_printf("000");
890
891         serv_printf("SPEX site|%d|%d", atoi(bstr("sitepolicy")), atoi(bstr("sitevalue")));
892         serv_getln(buf, sizeof buf);
893         serv_printf("SPEX mailboxes|%d|%d", atoi(bstr("mboxpolicy")), atoi(bstr("mboxvalue")));
894         serv_getln(buf, sizeof buf);
895
896         safestrncpy(WC->ImportantMessage, _("Your system configuration has been updated."),
897                 sizeof WC->ImportantMessage);
898         display_siteconfig();
899 }