5 * \defgroup InetCfg Functions which handle Internet domain configuration etc.
6 * \ingroup CitadelConfig
13 * \brief display the inet config dialog
15 void display_inetconf(void)
33 char *ic_spec[ic_max];
35 char *ic_keyword[ic_max];
36 char *ic_boxtitle[ic_max];
37 char *ic_desc[ic_max];
39 /* DON'T NEVER EVER AGAIN TRANSLATE CITADEL COMMANDS! */
40 ic_keyword[0] = "localhost";
41 ic_keyword[1] = "directory";
42 ic_keyword[2] = "gatewaydomain";
43 ic_keyword[3] = "smarthost";
44 ic_keyword[4] = "rbl";
45 ic_keyword[5] = "spamassassin";
46 ic_keyword[6] = "masqdomain";
49 ic_boxtitle[0] = _("Local host aliases");
50 ic_boxtitle[1] = _("Directory domains");
51 ic_boxtitle[2] = _("Gateway domains");
52 ic_boxtitle[3] = _("Smart hosts");
53 ic_boxtitle[4] = _("RBL hosts");
54 ic_boxtitle[5] = _("SpamAssassin hosts");
55 ic_boxtitle[6] = _("Masqueradable domains");
57 ic_desc[0] = _("(domains for which this host receives mail)");
58 ic_desc[1] = _("(domains mapped with the Global Address Book)");
59 ic_desc[2] = _("(domains whose subdomains match Citadel hosts)");
60 ic_desc[3] = _("(if present, forward all outbound mail to one of these hosts)");
61 ic_desc[4] = _("(hosts running a Realtime Blackhole List)");
62 ic_desc[5] = _("(hosts running the SpamAssassin service)");
63 ic_desc[6] = _("(Domains as which users are allowed to masquerade)");
65 for (i=0; i<ic_max; ++i) {
66 ic_spec[i] = strdup("");
70 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
71 serv_getln(buf, sizeof buf);
72 if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
74 extract_token(ename, buf, 0, '|', sizeof ename);
75 extract_token(etype, buf, 1, '|', sizeof etype);
77 for (i=0; i<ic_max; ++i) {
78 if (!strcasecmp(etype, ic_keyword[i])) {
84 ic_spec[which] = realloc(ic_spec[which], strlen(ic_spec[which]) + strlen(ename) + 2);
85 if (!IsEmptyStr(ic_spec[which])) strcat(ic_spec[which], "\n");
86 strcat(ic_spec[which], ename);
89 ic_misc = realloc(ic_misc, strlen(ic_misc) + strlen(buf) + 2);
90 if (!IsEmptyStr(ic_misc)) strcat(ic_misc, "\n");
96 output_headers(1, 1, 2, 0, 0, 0);
97 wprintf("<div id=\"banner\">\n");
99 wprintf(_("Internet configuration"));
103 wprintf("<div id=\"content\" class=\"service\">\n");
105 wprintf("<div class=\"fix_scrollbar_bug\">"
106 "<table border=0 width=100%% cellspacing=\"10px\" cellpadding=\"10px\"> "
107 "<tr><td valign=top width=50%%>\n");
108 for (which=0; which<ic_max; ++which) {
109 if (which == (ic_max / 2)) {
110 wprintf("</td><td valign=top>");
112 svprintf("BOXTITLE", WCS_STRING, ic_boxtitle[which]);
113 do_template("beginbox");
114 wprintf("<span class=\"menudesc\">");
115 escputs(ic_desc[which]);
116 wprintf("</span><br />");
117 wprintf("<table border=0 cellspacing=\"2px\" cellpadding=\"2px\" width=94%%>\n");
118 if (!IsEmptyStr(ic_spec[which])) {
119 for (i=0; i<num_tokens(ic_spec[which], '\n'); ++i) {
120 wprintf("<tr><td align=left>");
121 extract_token(buf, ic_spec[which], i, '\n', sizeof buf);
123 wprintf("</td><td align=left>"
124 "<span class=\"button_link\">"
125 "<a href=\"save_inetconf?oper=delete&ename=");
127 wprintf("&etype=%s\" ", ic_keyword[which]);
128 wprintf("onClick=\"return confirm('%s');\">",
129 _("Delete this entry?"));
130 wprintf(_("Delete"));
131 wprintf("</a></span></td></tr>\n");
134 wprintf("<form method=\"post\" action=\"save_inetconf\">\n");
135 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
137 "<input type=\"text\" name=\"ename\" maxlength=\"64\">"
138 "<input type=\"hidden\" name=\"etype\" VALUE=\"%s\">", ic_keyword[which]);
139 wprintf("</td><td align=left>"
140 "<input type=\"submit\" name=\"oper\" value=\"Add\">"
141 "</td></tr></table></form>\n");
142 do_template("endbox");
145 wprintf("</td></tr></table></div>\n");
148 for (i=0; i<ic_max; ++i) {
156 * \brief save changes to the inet config
158 void save_inetconf(void) {
167 newconfig = malloc(65536);
169 strcpy(newconfig, "");
170 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
171 serv_getln(buf, SIZ);
172 if (buf[0] == '1') while (serv_getln(buf, SIZ), strcmp(buf, "000")) {
173 extract_token(ename, buf, 0, '|', SIZ);
174 extract_token(etype, buf, 1, '|', SIZ);
175 if (IsEmptyStr(buf)) {
176 /** skip blank lines */
178 else if ((!strcasecmp(ename, bstr("ename")))
179 && (!strcasecmp(etype, bstr("etype")))
180 && (!strcasecmp(bstr("oper"), "delete"))
182 sprintf(WC->ImportantMessage, _("%s has been deleted."), ename);
185 if (!IsEmptyStr(newconfig)) strcat(newconfig, "\n");
186 strcat(newconfig, buf);
190 serv_printf("CONF PUTSYS|application/x-citadel-internet-config");
191 serv_getln(buf, SIZ);
193 serv_puts(newconfig);
194 if (!strcasecmp(bstr("oper"), "add")) {
195 serv_printf("%s|%s", bstr("ename"), bstr("etype") );
196 sprintf(WC->ImportantMessage, "%s added.", bstr("ename"));