4 * Administrative screen for site-wide configuration
12 HashList
*ZoneHash
= NULL
;
16 void LoadZoneFiles(void)
21 const char *this_zone
;
24 ZoneHash
= NewHash(1, NULL
);
25 ZName
= NewStrBufPlain(HKEY("UTC"));
26 Put(ZoneHash
, HKEY("UTC"), ZName
, HFreeStrBuf
);
27 zones
= icaltimezone_get_builtin_timezones();
28 for (z
= 0; z
< zones
->num_elements
; ++z
) {
29 /* lprintf(9, "Location: %-40s tzid: %s\n",
30 icaltimezone_get_location(icalarray_element_at(zones, z)),
31 icaltimezone_get_tzid(icalarray_element_at(zones, z))
33 this_zone
= icaltimezone_get_location(icalarray_element_at(zones
, z
));
34 len
= strlen(this_zone
);
35 ZName
= NewStrBufPlain(this_zone
, len
);
36 Put(ZoneHash
, this_zone
, len
, ZName
, HFreeStrBuf
);
38 SortByHashKey(ZoneHash
, 0);
42 typedef struct _CfgMapping
{
52 CfgMapping ServerConfig
[] = {
53 {CFG_STR
, HKEY("c_nodename")},
54 {CFG_STR
, HKEY("c_fqdn")},
55 {CFG_STR
, HKEY("c_humannode")},
56 {CFG_STR
, HKEY("c_phonenum")},
57 {CFG_YES
, HKEY("c_creataide")},
58 {CFG_STR
, HKEY("c_sleeping")},
59 {CFG_STR
, HKEY("c_initax")},
60 {CFG_YES
, HKEY("c_regiscall")},
61 {CFG_YES
, HKEY("c_twitdetect")},
62 {CFG_STR
, HKEY("c_twitroom")},
63 {CFG_STR
, HKEY("c_moreprompt")},
64 {CFG_YES
, HKEY("c_restrict")},
65 {CFG_STR
, HKEY("c_bbs_city")},
66 {CFG_STR
, HKEY("c_sysadm")},
67 {CFG_STR
, HKEY("c_maxsessions")},
68 {CFG_STR
, HKEY("reserved1")},
69 {CFG_STR
, HKEY("c_userpurge")},
70 {CFG_STR
, HKEY("c_roompurge")},
71 {CFG_STR
, HKEY("c_logpages")},
72 {CFG_STR
, HKEY("c_createax")},
73 {CFG_STR
, HKEY("c_maxmsglen")},
74 {CFG_STR
, HKEY("c_min_workers")},
75 {CFG_STR
, HKEY("c_max_workers")},
76 {CFG_STR
, HKEY("c_pop3_port")},
77 {CFG_STR
, HKEY("c_smtp_port")},
78 {CFG_NO
, HKEY("c_rfc822_strict_from")}, /* note: reverse bool */
79 {CFG_YES
, HKEY("c_aide_zap")},
80 {CFG_STR
, HKEY("c_imap_port")},
81 {CFG_STR
, HKEY("c_net_freq")},
82 {CFG_YES
, HKEY("c_disable_newu")},
83 {CFG_STR
, HKEY("reserved2")},
84 {CFG_STR
, HKEY("c_purge_hour")},
85 {CFG_STR
, HKEY("c_ldap_host")},
86 {CFG_STR
, HKEY("c_ldap_port")},
87 {CFG_STR
, HKEY("c_ldap_base_dn")},
88 {CFG_STR
, HKEY("c_ldap_bind_dn")},
89 {CFG_STR
, HKEY("c_ldap_bind_pw")},
90 {CFG_STR
, HKEY("c_ip_addr")},
91 {CFG_STR
, HKEY("c_msa_port")},
92 {CFG_STR
, HKEY("c_imaps_port")},
93 {CFG_STR
, HKEY("c_pop3s_port")},
94 {CFG_STR
, HKEY("c_smtps_port")},
95 {CFG_YES
, HKEY("c_enable_fulltext")},
96 {CFG_YES
, HKEY("c_auto_cull")},
97 {CFG_YES
, HKEY("c_instant_expunge")},
98 {CFG_YES
, HKEY("c_allow_spoofing")},
99 {CFG_YES
, HKEY("c_journal_email")},
100 {CFG_YES
, HKEY("c_journal_pubmsgs")},
101 {CFG_STR
, HKEY("c_journal_dest")},
102 {CFG_STR
, HKEY("c_default_cal_zone")},
103 {CFG_STR
, HKEY("c_pftcpdict_port")},
104 {CFG_STR
, HKEY("c_mgesve_port")},
105 {CFG_STR
, HKEY("c_auth_mode")},
106 {CFG_STR
, HKEY("c_funambol_host")},
107 {CFG_STR
, HKEY("c_funambol_port")},
108 {CFG_STR
, HKEY("c_funambol_source")},
109 {CFG_STR
, HKEY("c_funambol_auth")},
110 {CFG_YES
, HKEY("c_rbl_at_greeting")},
111 {CFG_STR
, HKEY("c_master_user")},
112 {CFG_STR
, HKEY("c_master_pass")},
113 {CFG_STR
, HKEY("c_pager_program")},
114 {CFG_YES
, HKEY("c_imap_keep_from")},
115 {CFG_STR
, HKEY("c_xmpp_c2s_port")},
116 {CFG_STR
, HKEY("c_xmpp_s2s_port")},
117 {CFG_STR
, HKEY("c_pop3_fetch")},
118 {CFG_STR
, HKEY("c_pop3_fastest")},
119 {CFG_YES
, HKEY("c_spam_flag_only")}
124 * display all configuration items
126 void load_siteconfig(void)
129 StrBuf
*Buf
, *CfgToken
;
135 if (WCC
->ServCfg
== NULL
)
136 WCC
->ServCfg
= NewHash(1, NULL
);
139 serv_printf("CONF get");
140 serv_getln(buf
, sizeof buf
);
143 while ((sizeof(ServerConfig
) / sizeof(CfgMapping
)) &&
144 (len
= StrBuf_ServGetln(Buf
),
145 strcmp(ChrPtr(Buf
), "000")) &&
146 (i
<= sizeof(ServerConfig
)))
154 if (i
<= sizeof(ServerConfig
) / sizeof(CfgMapping
))
161 serv_puts("GPEX site");
164 StrBuf_ServGetln(Buf
);
165 if (GetServerStatus(Buf
, NULL
) == 2) {
166 StrBufCutLeft(Buf
, 4);
168 CfgToken
= NewStrBuf();
169 StrBufExtract_token(CfgToken
, Buf
, 0, '|');
170 Put(Cfg
, HKEY("sitepolicy"), CfgToken
, HFreeStrBuf
);
172 CfgToken
= NewStrBuf();
173 StrBufExtract_token(CfgToken
, Buf
, 1, '|');
174 Put(Cfg
, HKEY("sitevalue"), CfgToken
, HFreeStrBuf
);
177 serv_puts("GPEX mailboxes");
178 serv_getln(buf
, sizeof buf
);
180 StrBufCutLeft(Buf
, 4);
182 CfgToken
= NewStrBuf();
183 StrBufExtract_token(CfgToken
, Buf
, 0, '|');
184 Put(Cfg
, HKEY("mboxpolicy"), CfgToken
, HFreeStrBuf
);
186 CfgToken
= NewStrBuf();
187 StrBufExtract_token(CfgToken
, Buf
, 1, '|');
188 Put(Cfg
, HKEY("mboxvalue"), CfgToken
, HFreeStrBuf
);
194 * parse siteconfig changes
196 void siteconfig(void)
202 if (strlen(bstr("ok_button")) == 0) {
206 serv_printf("CONF set");
207 serv_getln(buf
, sizeof buf
);
209 safestrncpy(WCC
->ImportantMessage
, &buf
[4], sizeof WCC
->ImportantMessage
);
214 for (i
=0; i
< (sizeof(ServerConfig
) / sizeof(CfgMapping
)); i
++)
216 switch (ServerConfig
[i
].type
) {
219 serv_putbuf(SBstr(ServerConfig
[i
].Key
, ServerConfig
[i
].len
));
222 serv_puts(YesBstr(ServerConfig
[i
].Key
,
223 ServerConfig
[i
].len
) ?
227 serv_puts(YesBstr(ServerConfig
[i
].Key
,
228 ServerConfig
[i
].len
) ?
235 serv_printf("SPEX site|%d|%d", ibstr("sitepolicy"), ibstr("sitevalue"));
236 serv_getln(buf
, sizeof buf
);
237 serv_printf("SPEX mailboxes|%d|%d", ibstr("mboxpolicy"), ibstr("mboxvalue"));
238 serv_getln(buf
, sizeof buf
);
239 FreeStrBuf(&serv_info
.serv_default_cal_zone
);
240 serv_info
.serv_default_cal_zone
= NewStrBufDup(sbstr("c_default_cal_zone"));
242 safestrncpy(WCC
->ImportantMessage
, _("Your system configuration has been updated."),
243 sizeof WCC
->ImportantMessage
);
244 DeleteHash(&WCC
->ServCfg
);
248 void tmplput_servcfg(StrBuf
*Target
, WCTemplputParams
*TP
)
255 if (WCC
->ServCfg
== NULL
)
257 GetHash(WCC
->ServCfg
, TKEY(0), &vBuf
);
258 Buf
= (StrBuf
*) vBuf
;
259 StrBufAppendTemplate(Target
, TP
, Buf
, 1);
263 int ConditionalServCfg(StrBuf
*Target
, WCTemplputParams
*TP
)
270 if (WCC
->ServCfg
== NULL
)
272 GetHash(WCC
->ServCfg
, TKEY(2), &vBuf
);
273 if (vBuf
== NULL
) return 0;
274 Buf
= (StrBuf
*) vBuf
;
275 if (TP
->Tokens
->nParameters
== 3) {
278 else if (TP
->Tokens
->Params
[3]->Type
== TYPE_STR
)
279 return (strcmp(TP
->Tokens
->Params
[3]->Start
, ChrPtr(Buf
)) == 0);
280 else return (StrTol(Buf
) == TP
->Tokens
->Params
[3]->lvalue
);
285 int ConditionalServCfgSubst(StrBuf
*Target
, WCTemplputParams
*TP
)
292 if (WCC
->ServCfg
== NULL
)
294 GetHash(WCC
->ServCfg
, TKEY(2), &vBuf
);
295 if (vBuf
== NULL
) return 0;
296 Buf
= (StrBuf
*) vBuf
;
298 return CompareSubstToStrBuf(Buf
, TP
->Tokens
->Params
[3]);
304 InitModule_SITECONFIG
307 WebcitAddUrlHandler(HKEY("siteconfig"), siteconfig
, CTX_NONE
);
309 RegisterNamespace("SERV:CFG", 1, 2, tmplput_servcfg
, CTX_NONE
);
310 RegisterConditional(HKEY("COND:SERVCFG"), 3, ConditionalServCfg
, CTX_NONE
);
311 RegisterConditional(HKEY("COND:SERVCFG:SUBST"), 4, ConditionalServCfgSubst
, CTX_NONE
);