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