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 StrBuf_ServGetln(Buf
);
179 if (GetServerStatus(Buf
, NULL
) == 2) {
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
);
195 * parse siteconfig changes
197 void siteconfig(void)
203 if (strlen(bstr("ok_button")) == 0) {
207 serv_printf("CONF set");
208 serv_getln(buf
, sizeof buf
);
210 safestrncpy(WCC
->ImportantMessage
, &buf
[4], sizeof WCC
->ImportantMessage
);
215 for (i
=0; i
< (sizeof(ServerConfig
) / sizeof(CfgMapping
)); i
++)
217 switch (ServerConfig
[i
].type
) {
220 serv_putbuf(SBstr(ServerConfig
[i
].Key
, ServerConfig
[i
].len
));
223 serv_puts(YesBstr(ServerConfig
[i
].Key
,
224 ServerConfig
[i
].len
) ?
228 serv_puts(YesBstr(ServerConfig
[i
].Key
,
229 ServerConfig
[i
].len
) ?
236 serv_printf("SPEX site|%d|%d", ibstr("sitepolicy"), ibstr("sitevalue"));
237 serv_getln(buf
, sizeof buf
);
238 serv_printf("SPEX mailboxes|%d|%d", ibstr("mboxpolicy"), ibstr("mboxvalue"));
239 serv_getln(buf
, sizeof buf
);
240 FreeStrBuf(&WCC
->serv_info
->serv_default_cal_zone
);
241 WCC
->serv_info
->serv_default_cal_zone
= NewStrBufDup(sbstr("c_default_cal_zone"));
243 safestrncpy(WCC
->ImportantMessage
, _("Your system configuration has been updated."),
244 sizeof WCC
->ImportantMessage
);
245 DeleteHash(&WCC
->ServCfg
);
249 void tmplput_servcfg(StrBuf
*Target
, WCTemplputParams
*TP
)
256 if (WCC
->ServCfg
== NULL
)
258 GetHash(WCC
->ServCfg
, TKEY(0), &vBuf
);
259 Buf
= (StrBuf
*) vBuf
;
260 StrBufAppendTemplate(Target
, TP
, Buf
, 1);
264 int ConditionalServCfg(StrBuf
*Target
, WCTemplputParams
*TP
)
271 if (WCC
->ServCfg
== NULL
)
273 GetHash(WCC
->ServCfg
, TKEY(2), &vBuf
);
274 if (vBuf
== NULL
) return 0;
275 Buf
= (StrBuf
*) vBuf
;
276 if (TP
->Tokens
->nParameters
== 3) {
279 else if (TP
->Tokens
->Params
[3]->Type
== TYPE_STR
)
280 return (strcmp(TP
->Tokens
->Params
[3]->Start
, ChrPtr(Buf
)) == 0);
281 else return (StrTol(Buf
) == TP
->Tokens
->Params
[3]->lvalue
);
286 int ConditionalServCfgSubst(StrBuf
*Target
, WCTemplputParams
*TP
)
293 if (WCC
->ServCfg
== NULL
)
295 GetHash(WCC
->ServCfg
, TKEY(2), &vBuf
);
296 if (vBuf
== NULL
) return 0;
297 Buf
= (StrBuf
*) vBuf
;
299 return CompareSubstToStrBuf(Buf
, TP
->Tokens
->Params
[3]);
305 InitModule_SITECONFIG
308 WebcitAddUrlHandler(HKEY("siteconfig"), siteconfig
, CTX_NONE
);
310 RegisterNamespace("SERV:CFG", 1, 2, tmplput_servcfg
, CTX_NONE
);
311 RegisterConditional(HKEY("COND:SERVCFG"), 3, ConditionalServCfg
, CTX_NONE
);
312 RegisterConditional(HKEY("COND:SERVCFG:SUBST"), 4, ConditionalServCfgSubst
, CTX_NONE
);