Rev 15518 | Rev 15573 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10 | reyssat | 1 | /* Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis |
2 | * |
||
3 | * This program is free software; you can redistribute it and/or modify |
||
4 | * it under the terms of the GNU General Public License as published by |
||
5 | * the Free Software Foundation; either version 2 of the License, or |
||
6 | * (at your option) any later version. |
||
7 | * |
||
8 | * This program is distributed in the hope that it will be useful, |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
11 | * GNU General Public License for more details. |
||
12 | * |
||
13 | * You should have received a copy of the GNU General Public License |
||
14 | * along with this program; if not, write to the Free Software |
||
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||
16 | */ |
||
17 | |||
8185 | bpr | 18 | /* This file contains various configuration routines for wims. */ |
10 | reyssat | 19 | |
8185 | bpr | 20 | /* Limitations are essentially for security reasons: |
21 | * to curb attacks by resource exhaustion of the server. |
||
22 | */ |
||
10 | reyssat | 23 | |
8185 | bpr | 24 | #include "wims.h" |
15519 | bpr | 25 | /* variables shared with wimslog.c */ |
26 | #include "commun.h" |
||
8185 | bpr | 27 | |
28 | /* maximal length of any module's variable definition file. */ |
||
10 | reyssat | 29 | int VAR_DEF_LENGTH_LIMIT=50000; |
7673 | bpr | 30 | /* Limit for frames in an animation. */ |
10 | reyssat | 31 | int ANIM_LIMIT=400; |
15519 | bpr | 32 | |
33 | |||
7673 | bpr | 34 | /* Resource limits */ |
13730 | obado | 35 | int threshold1=150; /* First load threshold */ |
36 | int threshold2=300; /* Second load threshold */ |
||
7673 | bpr | 37 | int ispriority=0; /* whether the connection is from priority sites */ |
10 | reyssat | 38 | |
7673 | bpr | 39 | int rafalvl=10; /* anti-rapidfire severity */ |
10 | reyssat | 40 | |
13730 | obado | 41 | /* Explanation: two real numbers a,b such as * |a+b|>|a-b|*compare_precision |
7673 | bpr | 42 | * will be considered equal in !ifvalue comparisons. */ |
10 | reyssat | 43 | int DEFAULT_COMPARE_PRECISION=10000; |
7673 | bpr | 44 | /* Precision of printing (hence of all evaluations). */ |
10 | reyssat | 45 | int DEFAULT_PRINT_PRECISION=8; |
7673 | bpr | 46 | /* Defaults for instex, insplot, etc. */ |
10 | reyssat | 47 | char *DEFAULT_INS_FORMAT="gif"; |
48 | char *DEFAULT_ANIM_FORMAT="gif"; |
||
49 | char *DEFAULT_INS_DENSITY="100x100"; |
||
50 | char *DEFAULT_INSPLOT_FONT="small"; |
||
51 | |||
7673 | bpr | 52 | /* gnuplot intermediate graphics format */ |
10 | reyssat | 53 | char *gnuplot_format="gif"; |
54 | |||
8185 | bpr | 55 | /* electronic address of site manager. */ |
10 | reyssat | 56 | char *site_manager="wims@$httpd_HTTP_HOST"; |
8185 | bpr | 57 | /* Main configure file, this name cannot be configured! */ |
10 | reyssat | 58 | char *config_file="../log/wims.conf"; |
59 | char PATH[512]; /* directory settings */ |
||
8191 | bpr | 60 | char *commonpath="/usr/local/bin:/usr/bin:/usr/games:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/texbin:/usr/local/texbin"; |
4331 | bpr | 61 | char *gap_command="gap.sh -T -m 64M"; |
9336 | bpr | 62 | char *maxima_command="maxima -X '--dynamic-space-size 512'"; |
10 | reyssat | 63 | char *pari_command="gp -f -q -p 150000"; |
10875 | obado | 64 | char *octave_command="octave -Hfq --no-line-editing --no-window-system --silent"; |
4417 | bpr | 65 | char *scilab_command="scilab -nwni"; |
6717 | guerimand | 66 | char *QRencode_command="qrencode -o"; |
10 | reyssat | 67 | |
8284 | bpr | 68 | /* default languages */ |
10 | reyssat | 69 | char site_langbuf[]="en fr cn es it nl"; |
70 | char *site_languages=site_langbuf; |
||
8284 | bpr | 71 | /* Statistics shows up? */ |
10 | reyssat | 72 | char *show_stat="no"; |
8284 | bpr | 73 | /* Author names show up in search result? */ |
10 | reyssat | 74 | char *show_author="no"; |
13730 | obado | 75 | /* Show user IP address to supervisor */ |
7079 | bpr | 76 | char *show_ip="yes"; |
8284 | bpr | 77 | /* busy hours definition */ |
10 | reyssat | 78 | char *busyhours=""; |
8284 | bpr | 79 | /* Presentation theme */ |
3048 | bpr | 80 | char *theme="standard"; |
8284 | bpr | 81 | /* directory of session files */ |
10 | reyssat | 82 | char session_dir[MAX_FNAME+1], s2_dir[MAX_FNAME+1]; |
8284 | bpr | 83 | /* standardised header model for modules' output. Will be stored |
84 | * into the variable $wims_html_header. If the theme contains |
||
85 | * a file 'head.phtml', html_header will be defined by the address |
||
86 | * of this file in subroutine define_html_header |
||
87 | */ |
||
10 | reyssat | 88 | char *html_header="html/header.phtml"; |
8284 | bpr | 89 | /* standardised about table for modules */ |
10 | reyssat | 90 | char *module_about_file="html/module_about"; |
8284 | bpr | 91 | /* title definition page */ |
10 | reyssat | 92 | char *title_page="title.phtml"; |
13730 | obado | 93 | /* standardised header menu bar, to be included in module pages |
8284 | bpr | 94 | * via command !headmenu */ |
10 | reyssat | 95 | char *header_menu="headmenu.phtml"; |
96 | char *header_menu_user="headmenu_user.phtml"; |
||
97 | char *header_menu_supervisor="headmenu_supervisor.phtml"; |
||
8284 | bpr | 98 | /* standardised referer to wims home, to be included in |
99 | * module pages via command !homeref */ |
||
10 | reyssat | 100 | char *home_referer="homeref.phtml"; |
101 | char *home_referer_user="homeref_user.phtml"; |
||
102 | char *home_referer_supervisor="homeref_supervisor.phtml"; |
||
8284 | bpr | 103 | /* background color in standard reference tables */ |
3079 | bpr | 104 | char *ref_bgcolor="#777777"; |
12357 | obado | 105 | /* standard link color */ |
14734 | obado | 106 | char *link_color="#1468A0"; |
12357 | obado | 107 | /* visited link color */ |
14734 | obado | 108 | char *vlink_color="#1779BA"; |
12357 | obado | 109 | /* hover link color */ |
110 | char *hlink_color="#004077"; |
||
8284 | bpr | 111 | /* link color in standard reference tables */ |
8696 | obado | 112 | char *ref_menucolor="#FFFFFF"; |
8284 | bpr | 113 | /* background help button color */ |
8696 | obado | 114 | char *ref_button_help_bgcolor="#008f00"; |
8284 | bpr | 115 | /* background help button color */ |
8696 | obado | 116 | char *ref_button_help_color="#FFFFFF"; |
3064 | bpr | 117 | /* button background color */ |
3078 | bpr | 118 | char *ref_button_bgcolor="#666666"; |
3064 | bpr | 119 | /* button color */ |
8696 | obado | 120 | char *ref_button_color="#FFFFFF"; |
12884 | obado | 121 | /* Default colors for activity types */ |
14838 | obado | 122 | char *actcolor="#000000,#CCCCFF,#99CCFF,#9999FF,#6666FF,#FFFFFF,#99CCDD,#AFB31E,#E6A493"; |
8185 | bpr | 123 | /* module log disabled by default */ |
10 | reyssat | 124 | int modlog=0; |
8185 | bpr | 125 | /* name of the variable definition file for every module. |
126 | * It is this file which defines the presence of the module. |
||
127 | * Better do not make it configurable. |
||
128 | */ |
||
10 | reyssat | 129 | char var_def_file[256]; |
8185 | bpr | 130 | /* name of variable init file. Processed only when cmd=new or renew. */ |
10 | reyssat | 131 | char *var_init_file="var.init"; |
8185 | bpr | 132 | /* name of variable calculation file. Parsed at each call. */ |
10 | reyssat | 133 | char *main_var_proc_file="var.proc"; |
8185 | bpr | 134 | /* name of the main (programmable) html file. */ |
10 | reyssat | 135 | char *html_file="main.phtml"; |
8185 | bpr | 136 | /* Introduction page name */ |
10 | reyssat | 137 | char *intro_file="intro.phtml"; |
8185 | bpr | 138 | /* Reference page */ |
10 | reyssat | 139 | char *ref_file="wims_ref.phtml"; |
8185 | bpr | 140 | /* script to process different inserts. |
141 | * The two consecutive points in the name prohibits ordinary |
||
142 | * user execution of the script. |
||
143 | */ |
||
10 | reyssat | 144 | char *insdraw_processor="insdraw..processor"; |
145 | char *insplot_processor="insplot..processor"; |
||
146 | char *tex2gif="bin/tex..gif"; |
||
7673 | bpr | 147 | char *priority=""; /* IPs of priority sites */ |
10 | reyssat | 148 | char *texgif_fontdir="w/texgif"; |
149 | char *texgif_texheader="mathfonts/header"; |
||
14734 | obado | 150 | char *bgcolor="#F6F6F6"; /* page background color */ |
7673 | bpr | 151 | char *bgimg=""; /* page background image file */ |
152 | char *pagecss="-theme-"; /* style sheet file */ |
||
153 | char *theme_icon="default"; /* icon */ |
||
154 | char *usecookie="no"; /* whether to send cookies to anon requests */ |
||
155 | char *mail_opt=""; /* !mailto options */ |
||
156 | char nodeip[256]=""; /* ip of cluster node if relevant */ |
||
157 | char temp_log[MAX_FNAME+1]; /* temp log file name */ |
||
158 | /* 0: low; 1: high; 2: MathML */ |
||
159 | int mathalign_base=0; /* Not use <sup> for middle alignment */ |
||
160 | char *disable_zoom="no"; /* yes/no: default zooming allowed (if enabled via "useropts") */ |
||
15297 | bpr | 161 | |
6178 | bpr | 162 | int spec_font=0; /* choose of some fonts*/ |
163 | /* special font can be configured in log/wims.conf with variable special_font*/ |
||
8909 | bpr | 164 | char *special_font="letter-spacing:0.1em;line-height:2.7em;word-spacing:0.8em;font-family:OpenDyslexic3,OpenDyslexic,sans-serif !important;"; |
7673 | bpr | 165 | int backup_hour=-1; /* Hour for daily backup; -1 means no backup. */ |
166 | int site_accounting=0; /* whether accounting should be activated */ |
||
167 | int examlog_limit=7; /* number of logged exam sessions for each student */ |
||
15331 | obado | 168 | char *site_hostname=""; |
10 | reyssat | 169 | |
8284 | bpr | 170 | /* Automatic module update */ |
10 | reyssat | 171 | char *mu_auto="none"; |
172 | char *mu_cat="all"; |
||
6533 | bpr | 173 | char *mu_delay="3"; |
15331 | obado | 174 | char *mu_site="https://wims.univ-cotedazur.fr/download/modules"; |
10 | reyssat | 175 | char *mu_zone="all"; |
3121 | bpr | 176 | char *mu_download_site="unice,wimsedu"; |
3046 | bpr | 177 | char *mu_publish_site="unice"; |
10 | reyssat | 178 | |
13730 | obado | 179 | /* keywords destined to robots */ |
10 | reyssat | 180 | char *site_keywords="interactive mathematics, interactive math, server side interactivity"; |
181 | char *site_description="interactive exercises, online calculators and plotters, mathematical recreation and games"; |
||
182 | |||
8284 | bpr | 183 | /* class and document authorization */ |
13730 | obado | 184 | int class_quota=150; |
185 | int superclass_quota=150; |
||
10 | reyssat | 186 | int doc_quota=32; |
187 | char *class_regpass="email,email,deny"; |
||
188 | char *doc_regpass=""; |
||
189 | |||
8284 | bpr | 190 | /* Where to find programs; if your httpd sets /bin:/usr/bin in PATH, |
191 | * this should be OK. |
||
192 | */ |
||
10 | reyssat | 193 | char *sed_prog="sed"; |
194 | char *tr_prog="tr"; |
||
195 | char *awk_prog="awk"; |
||
196 | |||
197 | /* myname */ |
||
198 | char *cgi_name="wims.cgi"; |
||
199 | char *aliased_cgi="no"; |
||
200 | char *aliased_getfile="yes"; |
||
201 | |||
202 | /* Limits for classes and participants */ |
||
203 | int class_limit=200; /* limit of number of classes */ |
||
204 | int user_limit=5000; /* limit of total number of registered users */ |
||
205 | int class_user_limit=300; /* limit of users in one class */ |
||
206 | int forum_limit=100; /* Limit of message boards */ |
||
207 | |||
208 | CONFIG_DATA main_config[]={ |
||
12270 | bpr | 209 | {"PATH",0, &commonpath}, |
210 | {"QRencode_command",2, &QRencode_command}, |
||
12884 | obado | 211 | {"actcolor",0, &actcolor}, |
12270 | bpr | 212 | {"aliased_cgi",0, &aliased_cgi}, |
213 | {"aliased_getfile",0, &aliased_getfile}, |
||
214 | {"backup_hour",1, &backup_hour}, |
||
215 | {"busyhours",0, &busyhours}, |
||
216 | {"cgi_name",0, &cgi_name}, |
||
217 | {"class_limit",1, &class_limit}, |
||
218 | {"class_quota",1, &class_quota}, |
||
219 | {"class_regpass",0, &class_regpass}, |
||
220 | {"class_user_limit",1, &class_user_limit}, |
||
221 | {"css",0, &pagecss}, |
||
222 | {"default_anim_format",0, &DEFAULT_ANIM_FORMAT}, |
||
223 | {"default_ins_format",0, &DEFAULT_INS_FORMAT}, |
||
224 | {"default_insplot_font",0, &DEFAULT_INSPLOT_FONT}, |
||
225 | {"default_texposition",1, &mathalign_base}, |
||
226 | {"devel_modules",0, &devel_modules}, |
||
227 | {"doc_quota",1, &doc_quota}, |
||
228 | {"doc_regpass",0, &doc_regpass}, |
||
229 | {"examlog_limit",1, &examlog_limit}, |
||
230 | {"forum_limit",1, &forum_limit}, |
||
231 | {"gap_command",2, &gap_command}, |
||
232 | {"general_log_limit",1, &GEN_LOG_LIMIT}, |
||
233 | {"gnuplot_format",0, &gnuplot_format}, |
||
12357 | obado | 234 | {"hlink_color",0, &hlink_color}, |
12270 | bpr | 235 | {"home_module",0, &home_module}, |
236 | {"idle_time",1, &idle_time}, |
||
237 | {"idle_time2",1, &idle_time2}, |
||
238 | {"idle_time3",1, &idle_time3}, |
||
239 | {"insdraw_processor",0, &insdraw_processor}, |
||
240 | {"link_color",0, &link_color}, |
||
15509 | bpr | 241 | {"log_delete",1,&LOG_DELETE}, |
12270 | bpr | 242 | {"mail_opt",0, &mail_opt}, |
243 | {"manager_https",1, &manager_https}, |
||
244 | {"manager_site",0, &manager_site}, |
||
245 | {"maxima_command",2, &maxima_command}, |
||
246 | {"module_log",1, &modlog}, |
||
247 | {"module_log_limit",1, &MODULE_LOG_LIMIT}, |
||
248 | {"mu_auto",0, &mu_auto}, |
||
249 | {"mu_cat",0, &mu_cat}, |
||
250 | {"mu_delay",0, &mu_delay}, |
||
251 | {"mu_download_site",0, &mu_download_site}, |
||
252 | {"mu_publish_site",0, &mu_publish_site}, |
||
253 | {"mu_site",0, &mu_site}, |
||
254 | {"mu_zone",0, &mu_zone}, |
||
255 | {"octave_command",2, &octave_command}, |
||
256 | {"old_log_files",1, &OLD_LOG_FILES}, |
||
257 | {"page_bgcolor",0, &bgcolor}, |
||
258 | {"page_bgimg",0, &bgimg}, |
||
259 | {"pari_command",2, &pari_command}, |
||
260 | {"priority",0, &priority}, |
||
261 | {"rafale_level",1, &rafalvl}, |
||
262 | {"ref_bgcolor",0, &ref_bgcolor}, |
||
263 | {"ref_button_bgcolor",0, &ref_button_bgcolor}, |
||
264 | {"ref_button_color",0, &ref_button_color}, |
||
265 | {"ref_button_help_bgcolor",0, &ref_button_help_bgcolor}, |
||
266 | {"ref_button_help_color",0, &ref_button_help_color}, |
||
267 | {"ref_menucolor",0, &ref_menucolor}, |
||
268 | {"rlimit_cpu",1, &rlimit_cpu}, |
||
269 | {"scilab_command",2, &scilab_command}, |
||
270 | {"show_author",0, &show_author}, |
||
271 | {"show_ip",0, &show_ip}, |
||
272 | {"show_stat",0, &show_stat}, |
||
273 | {"site_accounting",1, &site_accounting}, |
||
274 | {"site_description",0, &site_description}, |
||
15331 | obado | 275 | {"site_hostname",0, &site_hostname}, |
12270 | bpr | 276 | {"site_keywords",0, &site_keywords}, |
277 | {"site_languages",0, &site_languages}, |
||
278 | {"site_manager",0, &site_manager}, |
||
279 | {"superclass_quota",1, &superclass_quota}, |
||
280 | {"texbasesize",1, &texbasesize}, |
||
281 | {"theme",0, &theme}, |
||
282 | {"theme_icon",0, &theme_icon}, |
||
283 | {"threshold1",1, &threshold1}, |
||
284 | {"threshold2",1, &threshold2}, |
||
285 | {"tmp_debug",0, &tmp_debug}, |
||
286 | {"tmp_debug_var",0, &tmp_debug_var}, |
||
287 | {"trusted_modules",0, &trusted_modules}, |
||
288 | {"usecookie",0, &usecookie}, |
||
289 | {"user_limit",1, &user_limit}, |
||
290 | {"var_def_length_limit",1, &VAR_DEF_LENGTH_LIMIT}, |
||
291 | {"vlink_color",0, &vlink_color}, |
||
292 | {"workfile_limit",1, &WORKFILE_LIMIT} |
||
10 | reyssat | 293 | }; |
8185 | bpr | 294 | int MAIN_CONFIG_NO=(sizeof(main_config)/sizeof(main_config[0])); |
10 | reyssat | 295 | |
8851 | bpr | 296 | /* processes the list of languages supported on the site */ |
10 | reyssat | 297 | void language_list(void) |
298 | { |
||
12239 | bpr | 299 | int i,k; |
300 | char *lbuf[MAX_LANGUAGES]; |
||
301 | calc_tolower(site_languages); items2words(site_languages); |
||
302 | setvar("wims_site_languages",site_languages); |
||
303 | i=cutwords(site_languages,lbuf,MAX_LANGUAGES); |
||
304 | available_lang_no=i; |
||
305 | for(i=k=0;i<available_lang_no;i++) { |
||
306 | if(strlen(lbuf[i])==2) memmove(available_lang[k++],lbuf[i],3); |
||
307 | } |
||
308 | if(k>0) memmove(lang,available_lang[0],3); |
||
10 | reyssat | 309 | } |
310 | |||
311 | char hostname[256]; |
||
312 | int html_call=0; |
||
313 | |||
8851 | bpr | 314 | /* determine the http reference name of the server */ |
10 | reyssat | 315 | void determine_ref_name(void) |
316 | { |
||
12239 | bpr | 317 | char *s1, *s2, *p, *pl; |
318 | char buf[MAX_LINELEN+1]; |
||
319 | int len; |
||
10 | reyssat | 320 | |
12239 | bpr | 321 | hostname[0]=0; |
322 | s1=getvar("httpd_HTTP_HOST");s2=getvar("httpd_SCRIPT_NAME"); |
||
323 | gethostname(hostname,sizeof(hostname)); |
||
324 | if(hostname[0]==0 && s1 && *s1!=0) mystrncpy(hostname,s1,sizeof(hostname)); |
||
325 | if(s1==NULL || *s1==0) s1=hostname; |
||
326 | setvar("wims_myhostname",hostname); |
||
327 | ref_base[0]=0; |
||
328 | if(s2!=NULL) mystrncpy(buf,s2,sizeof(buf)); |
||
329 | else buf[0]=0; |
||
330 | if(s1!=NULL && *buf=='/') { |
||
331 | p=strrchr(buf,'/'); if(p==NULL) p=buf; else *p++=0; |
||
12357 | obado | 332 | /* address of type /wims/fr_H2~algebra~oeffraction.fr.html */ |
12239 | bpr | 333 | if(strcmp(p,cgi_name)!=0 && strlen(p)>4 && |
334 | p[2]=='_' && islower(p[0]) && islower(p[1])) { |
||
335 | pre_language[0]=p[0];pre_language[1]=p[1];pre_language[2]=0; |
||
336 | p[2]=0; setenv("HTTP_ACCEPT_LANGUAGE",p,1); pl=p; p+=3; |
||
12270 | bpr | 337 | s2=strrchr(p,'.'); |
338 | if(s2!=NULL) { |
||
339 | *s2=0; |
||
340 | if(strcasecmp(s2+1,"cgi")!=0) html_call=1; |
||
8851 | bpr | 341 | } |
12239 | bpr | 342 | s2=p; while((s2=strpbrk(s2,"@~"))!=NULL) *s2='/'; |
343 | if(strncmp(p,"doc/",4)==0) { |
||
344 | char *pd, *pb; |
||
345 | pd=p+4; |
||
346 | if(*pd) { |
||
347 | pb=strchr(pd,'/'); |
||
348 | if(pb) *pb++=0; else pb="main"; |
||
349 | setvar("doc",pd); setvar("block",pb); setvar("job","read"); |
||
350 | } |
||
351 | setvar(ro_name[ro_module],mkfname(NULL,"adm/doc.%s",pl)); |
||
8851 | bpr | 352 | } |
12239 | bpr | 353 | else setvar(ro_name[ro_module],p); |
354 | module_defined=1; |
||
10 | reyssat | 355 | } |
12239 | bpr | 356 | p=strchr(buf,'_'); |
357 | if(p!=NULL && p>buf+3 && myislower(*(p-1)) && myislower(*(p-2)) |
||
358 | && *(p-3)=='/' && myisalpha(*(p+1))) { |
||
359 | char *pp; |
||
360 | for(pp=p+1; myisalnum(*pp); pp++){}; |
||
361 | if(*pp=='/') *(p-3)=0; |
||
362 | } |
||
13395 | bpr | 363 | p=getenv("HTTPS"); |
364 | if(p!=NULL && strcmp(p,"on")==0) |
||
365 | snprintf(ref_name,sizeof(ref_name)-2,"https://%s%s/%s",s1,buf,cgi_name); |
||
366 | else |
||
367 | snprintf(ref_name,sizeof(ref_name)-2,"http://%s%s/%s",s1,buf,cgi_name); |
||
12239 | bpr | 368 | mystrncpy(ref_base,ref_name,sizeof(ref_base)-2); |
369 | p=strrchr(ref_base,'/'); |
||
370 | if(p!=NULL) *(p+1)=0; |
||
371 | } |
||
372 | else mystrncpy(ref_name,cgi_name,sizeof(ref_name)-1); |
||
11689 | obado | 373 | |
374 | // XSS PROTECTION (remove unwanted chars to avoid a possible XSS hack) |
||
12270 | bpr | 375 | // Search for a first occurence of forbidden chars |
376 | len = strcspn(ref_name, "<>'\"\\"); |
||
11689 | obado | 377 | // Give only the ref_name before forbidden chars |
12270 | bpr | 378 | ref_name[len]=0; |
11689 | obado | 379 | |
12239 | bpr | 380 | setvar("wims_ref_name",ref_name); |
10 | reyssat | 381 | } |
382 | |||
13730 | obado | 383 | /* Read and interpret wims configuration file. */ |
10 | reyssat | 384 | void main_configure(void) |
385 | { |
||
12239 | bpr | 386 | int i; |
387 | char *conf_buf,*e,*p,*p2,*p3; |
||
388 | char buf[MAX_LINELEN+1]; |
||
7079 | bpr | 389 | |
12239 | bpr | 390 | conf_buf=readfile(config_file,NULL,WORKFILE_LIMIT); |
391 | if(conf_buf==NULL) goto fileend; |
||
392 | e=conf_buf-1; while(e) { |
||
393 | p=e+1; e=strchr(p,'\n'); if(e) *e=0; |
||
394 | p=find_word_start(p); |
||
395 | if(*p==0 || *p==comment_prefix_char) continue; /* empty or comment line */ |
||
396 | p2=strchr(p,'='); |
||
397 | if(p2==NULL) continue; /* syntax error */ |
||
398 | *p2=0; *find_word_end(p)=0; p2=find_word_start(p2+1); |
||
399 | p3=p2+strlen(p2); while(myislspace(p3[-1])) p3--; |
||
400 | while(p3[-1]=='\\') p3--; |
||
401 | *p3=0; |
||
402 | i=search_list(main_config,MAIN_CONFIG_NO,sizeof(main_config[0]),p); |
||
403 | if(i<0) continue; /* name non-defined */ |
||
404 | if(main_config[i].is_integer==1) { |
||
405 | int *ip; |
||
406 | ip=main_config[i].address; |
||
407 | *ip=atoi(p2); if(*ip<0) *ip=0; |
||
10 | reyssat | 408 | } |
409 | else { |
||
12239 | bpr | 410 | char **cp; |
411 | cp=main_config[i].address; |
||
412 | *cp=p2; |
||
10 | reyssat | 413 | } |
12239 | bpr | 414 | } |
415 | fileend: |
||
416 | setenv("session_base_dir",session_dir,1); |
||
417 | determine_ref_name(); |
||
418 | language_list(); |
||
419 | for(i=0;i<MAIN_CONFIG_NO;i++) { |
||
420 | char **pp; |
||
421 | if(main_config[i].is_integer==2) { |
||
422 | pp=main_config[i].address; |
||
423 | setenv(main_config[i].name,*pp,1); |
||
10 | reyssat | 424 | } |
12239 | bpr | 425 | } |
426 | /* check priority */ |
||
427 | if(priority[0] && checkhost(priority)>0) ispriority=1; |
||
428 | (void)getcwd(cwdbuf,sizeof(cwdbuf)); setvar("httpd_PWD",cwdbuf); |
||
429 | setenv("wims_server_base",cwdbuf,1); |
||
430 | p=strrchr(cwdbuf,'/'); |
||
431 | if(p!=NULL && strcmp(p,"/public_html")==0) { |
||
432 | *p=0; snprintf(PATH,sizeof(PATH),"%s/other/bin:%s",cwdbuf,commonpath); |
||
433 | force_setvar("wims_home",cwdbuf); |
||
434 | *p='/'; |
||
435 | } |
||
436 | else { |
||
437 | snprintf(PATH,sizeof(PATH),"%s/../other/bin:%s",cwdbuf,commonpath); |
||
438 | force_setvar("wims_home",cwdbuf); |
||
439 | } |
||
440 | setenv("PATH",PATH,1); |
||
441 | p=getvar("httpd_SERVER_SOFTWARE"); |
||
442 | if(p && (strstr(p,"Apache"))!=NULL && strstr(aliased_getfile,"yes")!=NULL) |
||
443 | good_httpd=1; |
||
444 | accessfile(buf,"r","../tmp/log/myip"); |
||
445 | *find_word_end(buf)=0; |
||
446 | if(buf[0]) { |
||
447 | snprintf(nodeip,sizeof(nodeip),"%s",buf); |
||
448 | snprintf(temp_log,sizeof(temp_log),"%s.%s",TEMP_LOG_FILE,nodeip); |
||
449 | force_setvar("wims_priv_nodeip",nodeip); |
||
450 | } |
||
451 | else { |
||
452 | nodeip[0]=0; |
||
453 | snprintf(temp_log,sizeof(temp_log),"%s",TEMP_LOG_FILE); |
||
454 | } |
||
10 | reyssat | 455 | } |
456 | |||
457 | struct { |
||
12239 | bpr | 458 | int rname; |
459 | int *rval; |
||
10 | reyssat | 460 | } resource_table[]={ |
461 | #ifdef RLIMIT_CPU |
||
12270 | bpr | 462 | {RLIMIT_CPU, &rlimit_cpu}, |
10 | reyssat | 463 | #endif |
464 | #ifdef RLIMIT_FSIZE |
||
12270 | bpr | 465 | {RLIMIT_FSIZE, &rlimit_fsize}, |
10 | reyssat | 466 | #endif |
467 | #ifdef RLIMIT_AS |
||
12270 | bpr | 468 | {RLIMIT_AS, &rlimit_as}, |
10 | reyssat | 469 | #endif |
470 | #ifdef RLIMIT_DATA |
||
12270 | bpr | 471 | {RLIMIT_DATA, &rlimit_data}, |
10 | reyssat | 472 | #endif |
473 | #ifdef RLIMIT_STACK |
||
12270 | bpr | 474 | {RLIMIT_STACK, &rlimit_stack}, |
10 | reyssat | 475 | #endif |
476 | #ifdef RLIMIT_CORE |
||
12270 | bpr | 477 | {RLIMIT_CORE, &rlimit_core}, |
10 | reyssat | 478 | #endif |
479 | #ifdef RLIMIT_RSS |
||
12270 | bpr | 480 | {RLIMIT_RSS, &rlimit_rss}, |
10 | reyssat | 481 | #endif |
482 | #ifdef RLIMIT_NPROC |
||
12270 | bpr | 483 | {RLIMIT_NPROC, &rlimit_nproc}, |
10 | reyssat | 484 | #endif |
485 | #ifdef RLIMIT_NOFILE |
||
12270 | bpr | 486 | {RLIMIT_NOFILE, &rlimit_nofile}, |
10 | reyssat | 487 | #endif |
488 | #ifdef RLIMIT_MEMLOCK |
||
12270 | bpr | 489 | {RLIMIT_MEMLOCK, &rlimit_memlock} |
10 | reyssat | 490 | #endif |
491 | }; |
||
492 | #define RESOURCE_NO (sizeof(resource_table)/sizeof(resource_table[0])) |
||
493 | |||
7673 | bpr | 494 | /* set system resource limits */ |
10 | reyssat | 495 | void set_rlimits(void) |
496 | { |
||
12239 | bpr | 497 | int i; |
498 | struct rlimit rlim; |
||
7079 | bpr | 499 | |
12239 | bpr | 500 | for(i=0;i<RESOURCE_NO;i++) { |
501 | rlim.rlim_cur=rlim.rlim_max=*(resource_table[i].rval); |
||
502 | setrlimit(resource_table[i].rname,&rlim); |
||
503 | if(resource_table[i].rname==RLIMIT_CPU) { |
||
504 | setvar("wims_cpu_limit",int2str(rlim.rlim_max)); |
||
505 | initalarm(); |
||
10 | reyssat | 506 | } |
12239 | bpr | 507 | } |
10 | reyssat | 508 | } |
509 | |||
510 | struct { |
||
12239 | bpr | 511 | char *name; |
512 | int is_integer; |
||
513 | void *default_value; |
||
10 | reyssat | 514 | } module_default[]={ |
12239 | bpr | 515 | {"anim_format",0, &DEFAULT_ANIM_FORMAT}, |
516 | {"gnuplot_format",0, &gnuplot_format}, |
||
517 | {"ins_anim_limit",1, &ANIM_LIMIT}, |
||
518 | {"ins_density",0, &DEFAULT_INS_DENSITY}, |
||
519 | {"ins_format",0, &DEFAULT_INS_FORMAT}, |
||
520 | {"insplot_font",0, &DEFAULT_INSPLOT_FONT}, |
||
521 | {"wims_busyhours",0, &busyhours}, |
||
522 | {"wims_class_limit",1, &class_limit}, |
||
523 | {"wims_class_quota",1, &class_quota}, |
||
524 | {"wims_class_regpass",0, &class_regpass}, |
||
525 | {"wims_class_user_limit",1, &class_user_limit}, |
||
526 | {"wims_compare_precision",1, &DEFAULT_COMPARE_PRECISION}, |
||
527 | {"wims_devel_modules",0, &devel_modules}, |
||
528 | {"wims_doc_quota",1, &doc_quota}, |
||
529 | {"wims_doc_regpass",0, &doc_regpass}, |
||
530 | {"wims_examlog_limit",1, &examlog_limit}, |
||
531 | {"wims_forum_limit",1, &forum_limit}, |
||
532 | {"wims_bgcolor",0, &bgcolor}, |
||
533 | {"wims_bgimg",0, &bgimg}, |
||
534 | {"wims_css",0, &pagecss}, |
||
535 | {"wims_link_color",0, &link_color}, |
||
536 | {"wims_print_precision", 1, &DEFAULT_PRINT_PRECISION}, |
||
537 | {"wims_ref_bgcolor",0, &ref_bgcolor}, |
||
538 | {"wims_ref_button_bgcolor",0, &ref_button_bgcolor}, |
||
539 | {"wims_ref_button_color",0, &ref_button_color}, |
||
540 | {"wims_ref_button_help_bgcolor",0, &ref_button_help_bgcolor}, |
||
541 | {"wims_ref_button_help_color",0, &ref_button_help_color}, |
||
542 | {"wims_ref_menucolor",0, &ref_menucolor}, |
||
543 | {"wims_show_author",0, &show_author}, |
||
544 | {"wims_show_ip",0, &show_ip}, |
||
545 | {"wims_show_stat",0, &show_stat}, |
||
546 | {"wims_site_description",0, &site_description}, |
||
547 | {"wims_site_keywords",0, &site_keywords}, |
||
548 | {"wims_site_manager",0, &site_manager}, |
||
549 | {"wims_texalign",1, &mathalign_base}, |
||
550 | {"wims_texbasesize",1, &texbasesize}, |
||
551 | {"wims_theme",0, &theme}, |
||
552 | {"wims_theme_icon",0, &theme_icon}, |
||
553 | {"wims_tmp_debug",0, &tmp_debug}, |
||
554 | {"wims_usecookie",0, &usecookie}, |
||
555 | {"wims_user_limit",1, &user_limit}, |
||
556 | {"wims_vlink_color",0, &vlink_color}, |
||
12357 | obado | 557 | {"wims_hlink_color",0, &hlink_color}, |
12239 | bpr | 558 | {"wims_superclass_quota", 1, &superclass_quota} |
10 | reyssat | 559 | }; |
560 | #define MODULE_DEFAULT_NO (sizeof(module_default)/sizeof(module_default[0])) |
||
561 | |||
8851 | bpr | 562 | /* Set defaults for module, and set corresponding variables. */ |
10 | reyssat | 563 | void module_configure(void) |
564 | { |
||
12239 | bpr | 565 | int i; |
566 | confset=1; |
||
567 | for(i=0;i<MODULE_DEFAULT_NO;i++) { |
||
568 | if(module_default[i].is_integer) { |
||
569 | int j, *jp; |
||
570 | jp=module_default[i].default_value; |
||
571 | j=*jp; if(j<0) j=0; |
||
572 | setvar(module_default[i].name,int2str(j)); |
||
10 | reyssat | 573 | } |
12239 | bpr | 574 | else { |
575 | char **cp; |
||
576 | cp=module_default[i].default_value; |
||
577 | setvar(module_default[i].name,*cp); |
||
578 | } |
||
579 | } |
||
580 | setenv("texgif_fontdir",texgif_fontdir,1); |
||
581 | setenv("texgif_texheader",texgif_texheader,1); |
||
582 | setvar("wims_texsize","0"); |
||
583 | setvar("disable_zoom","0"); |
||
584 | setvar("disable_mathml","0"); |
||
585 | setvar("force_mathml","0"); |
||
586 | /* if 'force_mathml=yes' , a check should be done on the value of 'disable_mathml'. |
||
587 | so it's not fool-proof. |
||
588 | */ |
||
589 | confset=0; |
||
10 | reyssat | 590 | } |
591 | |||
592 | char *modindex[]={ |
||
12239 | bpr | 593 | "address", |
594 | "author", |
||
595 | "category", |
||
596 | "copyright", |
||
597 | "data", |
||
598 | "description", |
||
599 | "description_ca", |
||
600 | "description_cn", |
||
601 | "description_de", |
||
602 | "description_en", |
||
603 | "description_es", |
||
604 | "description_fr", |
||
605 | "description_it", |
||
606 | "description_nl", |
||
607 | "description_si", |
||
608 | "description_tw", |
||
609 | "domain", |
||
610 | "help", |
||
611 | "keywords", |
||
612 | "keywords_ca", |
||
613 | "keywords_cn", |
||
614 | "keywords_de", |
||
615 | "keywords_en", |
||
616 | "keywords_es", |
||
617 | "keywords_fr", |
||
618 | "keywords_it", |
||
619 | "keywords_nl", |
||
620 | "keywords_si", |
||
621 | "keywords_tw", |
||
622 | "language", |
||
623 | "level", |
||
624 | "maintainer", |
||
625 | "maintainer_address", |
||
626 | "mode", |
||
627 | "require", |
||
628 | "scoring", |
||
629 | "title", |
||
630 | "title_ca", |
||
631 | "title_cn", |
||
632 | "title_de", |
||
633 | "title_en", |
||
634 | "title_es", |
||
635 | "title_fr", |
||
636 | "title_it", |
||
637 | "title_nl", |
||
638 | "title_si", |
||
639 | "title_tw", |
||
640 | "translator", |
||
641 | "translator_address", |
||
642 | "translator_address_ca", |
||
643 | "translator_address_cn", |
||
644 | "translator_address_de", |
||
645 | "translator_address_en", |
||
646 | "translator_address_es", |
||
647 | "translator_address_fr", |
||
648 | "translator_address_it", |
||
649 | "translator_address_nl", |
||
650 | "translator_address_si", |
||
651 | "translator_address_tw", |
||
652 | "translator_ca", |
||
653 | "translator_cn", |
||
654 | "translator_de", |
||
655 | "translator_en", |
||
656 | "translator_es", |
||
657 | "translator_fr", |
||
658 | "translator_it", |
||
659 | "translator_nl", |
||
660 | "translator_si", |
||
661 | "translator_tw", |
||
662 | "vardef", |
||
663 | "version", |
||
664 | "wims_version", |
||
10 | reyssat | 665 | }; |
8185 | bpr | 666 | int MODINDEX_NO=(sizeof(modindex)/sizeof(modindex[0])); |
667 | |||
10 | reyssat | 668 | char *module_special_file[]={ |
12239 | bpr | 669 | "intro","help" |
10 | reyssat | 670 | }; |
671 | #define MODSPEC_NO (sizeof(module_special_file)/sizeof(module_special_file[0])) |
||
672 | |||
8185 | bpr | 673 | /* read and treat module's INDEX file */ |
10 | reyssat | 674 | void module_index(void) |
675 | { |
||
12239 | bpr | 676 | char buf[MAX_NAMELEN+1], ind_buf[MAX_LINELEN+1]; |
677 | char *e, *p, *p2, *ft; |
||
678 | double v1, v2; |
||
679 | int i,l; |
||
680 | long indf_len; |
||
7079 | bpr | 681 | |
12239 | bpr | 682 | memmove(var_def_file,default_var_def,strlen(default_var_def)+1); |
683 | ft=readfile(mkfname(NULL,"%s/INDEX",module_prefix), |
||
684 | ind_buf,sizeof(ind_buf)); |
||
685 | if(ft==NULL) ft=readfile(mkfname(NULL,"%s/index",module_prefix), |
||
686 | ind_buf,sizeof(ind_buf)); |
||
687 | if(ft==NULL) return; |
||
688 | e=ind_buf-1; indf_len=strlen(ind_buf); |
||
689 | for(l=0; e<ind_buf+indf_len && e!=NULL ;l++) { |
||
690 | p=e+1; e=strchr(p,'\n'); if(e!=NULL) *e=0; |
||
691 | strip_trailing_spaces(p); p=find_word_start(p); |
||
692 | if(*p==0 || *p==comment_prefix_char) continue; /* empty or comment line */ |
||
693 | p2=strchr(p,'='); |
||
694 | if(p2==NULL) continue; /* syntax error */ |
||
695 | *p2=0; *find_word_end(p)=0; p2=find_word_start(p2+1); |
||
696 | i=search_list(modindex,MODINDEX_NO,sizeof(modindex[0]),p); |
||
697 | if(i<0) continue; /* name not in list */ |
||
698 | snprintf(buf,sizeof(buf),"module_%s",p); |
||
699 | setvar(buf,p2); |
||
700 | } |
||
701 | if(mode!=mode_default) { |
||
702 | char *s; |
||
703 | s=getvar("module_mode"); |
||
704 | if(s==NULL) { |
||
705 | nomode: mode=mode_default; force_setvar("wims_mode",""); |
||
10 | reyssat | 706 | } |
12239 | bpr | 707 | else switch(mode) { |
708 | case mode_popup: { |
||
709 | if(strstr(s,"popup")==NULL) goto nomode; |
||
710 | else break; |
||
8851 | bpr | 711 | } |
12239 | bpr | 712 | case mode_raw: { |
713 | if(strstr(s,"raw")==NULL) goto nomode; |
||
714 | else break; |
||
715 | } |
||
716 | default: break; |
||
10 | reyssat | 717 | } |
12239 | bpr | 718 | } |
7673 | bpr | 719 | /* test for existence of some special files in module's directory */ |
12239 | bpr | 720 | for(i=0;i<MODSPEC_NO;i++) { |
721 | if(ftest(mkfname(NULL,"%s/%s.phtml",module_prefix,module_special_file[i])) |
||
722 | ==is_file) { |
||
723 | snprintf(buf,sizeof(buf),"module_has_%s",module_special_file[i]); |
||
724 | setvar(buf,"yes"); |
||
10 | reyssat | 725 | } |
12239 | bpr | 726 | } |
727 | p=getvar("module_language"); if(p==NULL || *p==0) setvar("module_language","en"); |
||
728 | setvar("module_has_about","yes"); /* now we have default about.phtml */ |
||
7673 | bpr | 729 | /* Set var_def */ |
12239 | bpr | 730 | p=getvar("module_vardef"); |
731 | if(p!=NULL && *p!=0) mystrncpy(var_def_file,p,sizeof(var_def_file)); |
||
732 | p=getvar("module_wims_version"); if(p!=NULL && *p!=0) { |
||
733 | v1=atof(p); v2=atof(wims_version); |
||
734 | if(isfinite(v1) && isfinite(v2) && |
||
7673 | bpr | 735 | (v1>v2 || (v1==v2 && strcmp(find_word_start(p),wims_version)>0))) { |
12239 | bpr | 736 | setvar("module_wims_version",p); |
737 | setvar("wims_version",wims_version); |
||
738 | module_error("antidated_version"); |
||
10 | reyssat | 739 | } |
12239 | bpr | 740 | } |
741 | if(isdevelmodule) { |
||
742 | p=getvar("module_scoring"); |
||
743 | if(p==NULL || strcasecmp(p,"yes")!=0) isdevelmodule=0; |
||
744 | } |
||
10 | reyssat | 745 | } |
746 | |||
7673 | bpr | 747 | /* Set up a unique job identity as a 4-bytes integer */ |
10 | reyssat | 748 | unsigned long create_job_ident(void) |
749 | { |
||
2348 | czzmrn | 750 | /* unsigned long it; // 64-bit compatibility: take away _long_ */ |
12239 | bpr | 751 | unsigned long it; |
752 | int i; |
||
7673 | bpr | 753 | /* Is this enough to guarantee uniqueness? */ |
7079 | bpr | 754 | |
12239 | bpr | 755 | it=(nowtime<<16)+(getpid()&0xffff); |
7673 | bpr | 756 | /* The encryption is very simple. */ |
12239 | bpr | 757 | it=it^0x5a3c9671; |
758 | for(i=0;i<MAX_SESRANDOM;i++) sesrandomtab[i]=random(); |
||
1679 | bpr | 759 | /* ensure that the result will be a 4-bytes integer gives random problem on 32 bits |
2607 | bpr | 760 | return it;*/ |
12239 | bpr | 761 | return it & 0xffffffff; |
10 | reyssat | 762 | } |
763 | |||
7673 | bpr | 764 | /* Setup a job identifier */ |
10 | reyssat | 765 | void set_job_ident(void) |
766 | { |
||
12239 | bpr | 767 | unsigned long l,r; |
7079 | bpr | 768 | |
12239 | bpr | 769 | l=create_job_ident(); |
770 | /* the last 4 bits always make 0xA. A bug of glibc random()? */ |
||
771 | r=random()>>4; |
||
772 | snprintf(job_identifier,sizeof(job_identifier),"%lX%08lX",r,l); |
||
773 | var_noexport=1; |
||
774 | setvar("job_identifier",job_identifier); |
||
775 | var_noexport=0; |
||
10 | reyssat | 776 | } |
777 | |||
7673 | bpr | 778 | /* define the variable $wims_html_header */ |
10 | reyssat | 779 | void define_html_header(void) |
780 | { |
||
15518 | obado | 781 | char *sp, *cp, *ladirection, *mp, *s2, *wversion; |
12239 | bpr | 782 | char buf[MAX_LINELEN+1]; |
12442 | obado | 783 | int buf_length = 0; |
12239 | bpr | 784 | int noc; |
785 | noc=0; |
||
786 | cp=getvar("wims_expire"); if(cp!=NULL) goto css; |
||
787 | if(!robot_access && cmd_type==cmd_intro && isclassmodule) { |
||
788 | sp=getvar("special_parm"); if(sp==NULL) sp=""; |
||
789 | if(strcmp(sp,".nocache.")==0) { |
||
790 | force_setvar("special_parm",""); noc=1; |
||
10 | reyssat | 791 | } |
12239 | bpr | 792 | if(!noc) { |
793 | mp=getvar(ro_name[ro_module]); |
||
794 | if(mp!=NULL && strncmp(mp,"devel/",strlen("devel/"))==0) noc=1; |
||
795 | } |
||
796 | } |
||
13359 | obado | 797 | if(noc==1){ |
798 | _output_("Cache-Control: no-cache, no-store, must-revalidate\r\n"); |
||
799 | } |
||
12417 | obado | 800 | css: |
801 | setvar("wims_CSS",""); |
||
802 | /* wims_css peut avoir pour valeur "---" ou "-theme-" au niveau du site |
||
803 | + la valeur "class" si une classe décide d'utiliser son propre css à la place du theme |
||
804 | */ |
||
12239 | bpr | 805 | cp=getvar("wims_css"); |
806 | ladirection=getvar("wims_main_dirn"); |
||
807 | if (strcmp(ladirection,"ltr")==0) ladirection=""; |
||
12417 | obado | 808 | |
12239 | bpr | 809 | if(!robot_access && cp!=NULL && *cp!=0 && strstr(cp,"---")==NULL) { |
810 | char *nbuf; |
||
811 | cp=find_word_start(cp); |
||
15518 | obado | 812 | |
12239 | bpr | 813 | if(strchr(cp,'/')==NULL) { |
12417 | obado | 814 | char *pc, *th, *ti; int class_style=0; |
12239 | bpr | 815 | pc=getvar("wims_class"); |
15518 | obado | 816 | wversion=getvar("wims_version"); |
817 | if(wversion==NULL || *wversion==0) wversion="0.0"; |
||
12425 | obado | 818 | |
819 | /* When a class choose its own css instead of theme css */ |
||
12239 | bpr | 820 | if(pc!=NULL && *pc!=0 && strcmp(cp,"class")==0) { |
821 | nbuf=mkfname(NULL,"%s/%s/css",class_base,pc); |
||
822 | th=getvar("class_theme");ti=getvar("class_theme_icon") ; |
||
823 | if(th==NULL || *th==0) th=getvar("wims_theme"); |
||
824 | if(ti==NULL || *ti==0) ti=getvar("wims_theme_icon"); |
||
12417 | obado | 825 | |
826 | // Check content of "nbuf" file. (if file is too heavy (>45Ko), it will raise a user_error) |
||
12425 | obado | 827 | if( readfile(nbuf,tmplbuf,sizeof(tmplbuf)) ){ |
828 | // file exist |
||
829 | //snprintf(buf,sizeof(buf),"<style>%s</style>",tmplbuf); |
||
830 | // The content will be added by scripts/adm/css.phtml |
||
831 | class_style = 1; |
||
12417 | obado | 832 | } |
12239 | bpr | 833 | } |
12425 | obado | 834 | |
835 | if (!class_style) { |
||
12239 | bpr | 836 | th=getvar("wims_theme"); |
12425 | obado | 837 | /* when wims_css is everything but '---' */ |
838 | if(strcmp(cp,"---")!=0 && strchr(th,'.')==NULL) { |
||
839 | if(th==NULL || *th==0) th="standard"; |
||
840 | nbuf=mkfname(NULL,"html/themes/%s/css.css",th); |
||
12417 | obado | 841 | |
12425 | obado | 842 | // Check if theme css file exists (use access from unistd.h) |
843 | if( access( nbuf, F_OK ) != -1 ) { |
||
15518 | obado | 844 | buf_length = snprintf(buf,sizeof(buf),"<link href=\"%s?ver=%s\" rel=\"stylesheet\" />", nbuf, wversion); |
12425 | obado | 845 | } |
12239 | bpr | 846 | } |
847 | } |
||
12425 | obado | 848 | /* icon theme */ |
849 | ti=getvar("wims_theme_icon"); |
||
850 | if(ti==NULL || *ti==0) ti="default"; |
||
15518 | obado | 851 | snprintf(buf+buf_length,sizeof(buf)-buf_length,"<link href=\"gifs/themes/%s/icon-min.css?ver=%s\" rel=\"stylesheet\" />", ti, wversion); |
7673 | bpr | 852 | |
12425 | obado | 853 | setvar("wims_CSS",buf); |
854 | |||
855 | /* case of theme */ |
||
12239 | bpr | 856 | if (th) { |
857 | s2=getvar("module_title"); |
||
858 | if(s2!=NULL && *s2!=0) { |
||
15503 | bpr | 859 | char nbuf[MAX_LINELEN+1]; |
860 | mystrncpy(nbuf,s2,sizeof(nbuf)); calc_detag(nbuf); setvar("module_title2",nbuf); |
||
12239 | bpr | 861 | }; |
862 | nbuf=mkfname(NULL,"html/themes/%s/htmlheader.phtml",th) ; |
||
863 | if (readfile(nbuf,tmplbuf,sizeof(tmplbuf))) html_header=nbuf ; |
||
864 | } |
||
10 | reyssat | 865 | } |
12239 | bpr | 866 | } |
12417 | obado | 867 | if(readfile(html_header,buf,sizeof(buf))) |
868 | setvar("wims_html_header",buf); |
||
10 | reyssat | 869 | } |
870 | |||
10875 | obado | 871 | /* Set Session Dir */ |
10 | reyssat | 872 | void setsesdir(char *d) |
873 | { |
||
12239 | bpr | 874 | char buf[MAX_FNAME+1]; |
875 | if(strstr(d,parent_dir_string)!=NULL) { |
||
876 | force_setvar("wims_session",robot_session); |
||
877 | mystrncpy(buf,robot_session,sizeof(buf)); |
||
878 | mkfname(session_dir,"../tmp"); |
||
879 | mkfname(s2_dir,"../tmp"); |
||
880 | } |
||
881 | else { |
||
882 | force_setvar("wims_session",d); |
||
883 | snprintf(buf,sizeof(buf),"%s/%s",SESSION_BASE,d); |
||
884 | mkfname(session_dir,"../%s",SESSION_BASE); |
||
7673 | bpr | 885 | /* mkfname(s2_dir,"../%s",S2_BASE); */ |
12239 | bpr | 886 | } |
887 | force_setvar("wims_sesdir",buf); |
||
10 | reyssat | 888 | } |