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