]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/config.php
Added SearchHighlight comment
[SourceForge/phpwiki.git] / lib / config.php
1 <?php
2 rcs_id('$Id: config.php,v 1.142 2007-03-04 14:07:17 rurban Exp $');
3 /*
4  * NOTE: The settings here should probably not need to be changed.
5  * The user-configurable settings have been moved to IniConfig.php
6  * The run-time code has been moved to lib/IniConfig.php:fix_configs()
7  */
8  
9 if (!defined("LC_ALL")) {
10     // Backward compatibility (for PHP < 4.0.5)
11     if (!check_php_version(4,0,5)) {
12         define("LC_ALL",   "LC_ALL");
13         define("LC_CTYPE", "LC_CTYPE");
14     } else {
15         define("LC_ALL",   0);
16         define("LC_CTYPE", 2);
17     }
18 }
19 // debug flags: 
20 define ('_DEBUG_VERBOSE',   1); // verbose msgs and add validator links on footer
21 define ('_DEBUG_PAGELINKS', 2); // list the extraced pagelinks at the top of each pages
22 define ('_DEBUG_PARSER',    4); // verbose parsing steps
23 define ('_DEBUG_TRACE',     8); // test php memory usage, prints php debug backtraces
24 define ('_DEBUG_INFO',     16);
25 define ('_DEBUG_APD',      32);
26 define ('_DEBUG_LOGIN',    64); // verbose login debug-msg (settings and reason for failure)
27 define ('_DEBUG_SQL',     128); // force check db, force optimize, print some debugging logs
28 define ('_DEBUG_REMOTE',  256); // remote debug into subrequests (xmlrpc, ajax, wikiwyg, ...) 
29                                 // or test local SearchHighlight.
30                                 // internal links have persistent ?start_debug=1 
31
32 function isCGI() {
33     return (substr(php_sapi_name(),0,3) == 'cgi' and 
34             isset($GLOBALS['HTTP_ENV_VARS']['GATEWAY_INTERFACE']) and
35             @preg_match('/CGI/',$GLOBALS['HTTP_ENV_VARS']['GATEWAY_INTERFACE']));
36 }
37
38 /*
39 // copy some $_ENV vars to $_SERVER for CGI compatibility. php does it automatically since when?
40 if (isCGI()) {
41     foreach (explode(':','SERVER_SOFTWARE:SERVER_NAME:GATEWAY_INTERFACE:SERVER_PROTOCOL:SERVER_PORT:REQUEST_METHOD:HTTP_ACCEPT:PATH_INFO:PATH_TRANSLATED:SCRIPT_NAME:QUERY_STRING:REMOTE_HOST:REMOTE_ADDR:REMOTE_USER:AUTH_TYPE:CONTENT_TYPE:CONTENT_LENGTH') as $key) {
42         $GLOBALS['HTTP_SERVER_VARS'][$key] = &$GLOBALS['HTTP_ENV_VARS'][$key];
43     }
44 }
45 */
46
47 // essential internal stuff
48 set_magic_quotes_runtime(0);
49
50 /** 
51  * Browser Detection Functions
52  *
53  * Current Issues:
54  *  NS/IE < 4.0 doesn't accept < ? xml version="1.0" ? >
55  *  NS/IE < 4.0 cannot display PNG
56  *  NS/IE < 4.0 cannot display all XHTML tags
57  *  NS < 5.0 needs textarea wrap=virtual
58  *  IE55 has problems with transparent PNG's
59  * @author: ReiniUrban
60  */
61 function browserAgent() {
62     static $HTTP_USER_AGENT = false;
63     if ($HTTP_USER_AGENT !== false) return $HTTP_USER_AGENT;
64     if (!$HTTP_USER_AGENT)
65         $HTTP_USER_AGENT = @$GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'];
66     if (!$HTTP_USER_AGENT) // CGI
67         $HTTP_USER_AGENT = @$GLOBALS['HTTP_ENV_VARS']['HTTP_USER_AGENT'];
68     if (!$HTTP_USER_AGENT) // local CGI testing
69         $HTTP_USER_AGENT = 'none';
70     return $HTTP_USER_AGENT;
71 }
72 function browserDetect($match) {
73     return strstr(browserAgent(), $match);
74 }
75 // returns a similar number for Netscape/Mozilla (gecko=5.0)/IE/Opera features.
76 function browserVersion() {
77     if (strstr(browserAgent(),    "Mozilla/4.0 (compatible; MSIE"))
78         return (float) substr(browserAgent(),30);
79     elseif (strstr(browserAgent(),"Mozilla/5.0 (compatible; Konqueror/"))
80         return (float) substr(browserAgent(),36);
81     else
82         return (float) substr(browserAgent(),8);
83 }
84 function isBrowserIE() {
85     return (browserDetect('Mozilla/') and 
86             browserDetect('MSIE'));
87 }
88 // problem with transparent PNG's
89 function isBrowserIE55() {
90     return (isBrowserIE() and 
91             browserVersion() > 5.1 and browserVersion() < 6.0);
92 }
93 // old Netscape prior to Mozilla
94 function isBrowserNetscape($version = false) {
95     $agent = (browserDetect('Mozilla/') and 
96             ! browserDetect('Gecko/') and
97             ! browserDetect('MSIE'));
98     if ($version) return $agent and browserVersion() >= $version; 
99     else return $agent;
100 }
101 // NS3 or less
102 function isBrowserNS3() {
103     return (isBrowserNetscape() and browserVersion() < 4.0);
104 }
105 // NS4 or less
106 function isBrowserNS4() {
107     return (isBrowserNetscape() and browserVersion() < 5.0);
108 }
109 // must omit display alternate stylesheets: konqueror 3.1.4
110 // http://sourceforge.net/tracker/index.php?func=detail&aid=945154&group_id=6121&atid=106121
111 function isBrowserKonqueror($version = false) {
112     if ($version) return browserDetect('Konqueror/') and browserVersion() >= $version; 
113     return browserDetect('Konqueror/');
114 }
115 // MacOSX Safari has certain limitations. Need detection and patches.
116 // * no <object>, only <embed>
117 function isBrowserSafari($version = false) {
118     if ($version) return browserDetect('Safari/') and browserVersion() >= $version; 
119     return browserDetect('Safari/');
120 }
121
122
123 /**
124  * If $LANG is undefined:
125  * Smart client language detection, based on our supported languages
126  * HTTP_ACCEPT_LANGUAGE="de-at,en;q=0.5"
127  *   => "de"
128  * We should really check additionally if the i18n HomePage version is defined.
129  * So must defer this to the request loop.
130  */
131 function guessing_lang ($languages=false) {
132     if (!$languages) {
133         // make this faster
134         $languages = array("en","de","es","fr","it","ja","zh","nl","sv");
135         // ignore possible "_<territory>" and codeset "ja.utf8"
136         /*
137         require_once("lib/Theme.php");
138         $languages = listAvailableLanguages();
139         if (defined('DEFAULT_LANGUAGE') and in_array(DEFAULT_LANGUAGE, $languages))
140         {
141             // remove duplicates
142             if ($i = array_search(DEFAULT_LANGUAGE, $languages) !== false) {
143                 array_splice($languages, $i, 1);
144             }
145             array_unshift($languages, DEFAULT_LANGUAGE);
146             foreach ($languages as $lang) {
147                 $arr = FileFinder::locale_versions($lang);
148                 $languages = array_merge($languages, $arr);
149             }
150         }
151         */
152     }
153
154     $accept = false; 
155     if (isset($GLOBALS['request'])) // in fixup-dynamic-config there's no request yet
156         $accept = $GLOBALS['request']->get('HTTP_ACCEPT_LANGUAGE');
157     elseif (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE']))
158         $accept = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
159
160     if ($accept) {
161         $lang_list = array();
162         $list = explode(",", $accept);
163         for ($i=0; $i<count($list); $i++) {
164             $pos = strchr($list[$i], ";") ;
165             if ($pos === false) {
166                 // No Q it is only a locale...
167                 $lang_list[$list[$i]] = 100;
168             } else {
169                 // Has a Q rating        
170                 $q = explode(";",$list[$i]) ;
171                 $loc = $q[0] ;
172                 $q = explode("=",$q[1]) ;
173                 $lang_list[$loc] = $q[1]*100 ;
174             }
175         }
176
177         // sort by q desc
178         arsort($lang_list);
179
180         // compare with languages, ignoring sublang and charset
181         foreach ($lang_list as $lang => $q) {
182             if (in_array($lang, $languages))
183                 return $lang;
184             // de_DE.iso8859-1@euro => de_DE.iso8859-1, de_DE, de
185             // de-DE => de-DE, de
186             foreach (array('@', '.', '_') as $sep) {
187                 if ( ($tail = strchr($lang, $sep)) ) {
188                     $lang_short = substr($lang, 0, -strlen($tail));
189                     if (in_array($lang_short, $languages))
190                         return $lang_short;
191                 }
192             }
193             if ($pos = strchr($lang, "-") and in_array(substr($lang, 0, $pos), $languages))
194                 return substr($lang, 0, $pos);
195         }
196     }
197     return $languages[0];
198 }
199
200 /**
201  * Smart setlocale().
202  *
203  * This is a version of the builtin setlocale() which is
204  * smart enough to try some alternatives...
205  *
206  * @param mixed $category
207  * @param string $locale
208  * @return string The new locale, or <code>false</code> if unable
209  *  to set the requested locale.
210  * @see setlocale
211  * [56ms]
212  */
213 function guessing_setlocale ($category, $locale) {
214     $alt = array('en' => array('C', 'en_US', 'en_GB', 'en_AU', 'en_CA', 'english'),
215                  'de' => array('de_DE', 'de_DE', 'de_DE@euro', 
216                                'de_AT@euro', 'de_AT', 'German_Austria.1252', 'deutsch', 
217                                'german', 'ge'),
218                  'es' => array('es_ES', 'es_MX', 'es_AR', 'spanish'),
219                  'nl' => array('nl_NL', 'dutch'),
220                  'fr' => array('fr_FR', 'français', 'french'),
221                  'it' => array('it_IT'),
222                  'sv' => array('sv_SE'),
223                  'ja.utf-8'  => array('ja_JP','ja_JP.utf-8','japanese'),
224                  'ja.euc-jp' => array('ja_JP','ja_JP.eucJP','japanese.euc'),
225                  'zh' => array('zh_TW', 'zh_CN'),
226                  );
227     if (!$locale or $locale=='C') { 
228         // do the reverse: return the detected locale collapsed to our LANG
229         $locale = setlocale($category, '');
230         if ($locale) {
231             if (strstr($locale, '_')) list ($lang) = split('_', $locale);
232             else $lang = $locale;
233             if (strlen($lang) > 2) { 
234                 foreach ($alt as $try => $locs) {
235                     if (in_array($locale, $locs) or in_array($lang, $locs)) {
236                         //if (empty($GLOBALS['LANG'])) $GLOBALS['LANG'] = $try;
237                         return $try;
238                     }
239                 }
240             }
241         }
242     }
243     if (strlen($locale) == 2)
244         $lang = $locale;
245     else 
246         list ($lang) = split('_', $locale);
247     if (!isset($alt[$lang]))
248         return false;
249         
250     foreach ($alt[$lang] as $try) {
251         if ($res = setlocale($category, $try))
252             return $res;
253         // Try with charset appended...
254         $try = $try . '.' . $GLOBALS['charset'];
255         if ($res = setlocale($category, $try))
256             return $res;
257         foreach (array(".", '@', '_') as $sep) {
258             if ($i = strpos($try, $sep)) {
259                 $try = substr($try, 0, $i);
260                 if (($res = setlocale($category, $try)))
261                     return $res;
262             }
263         }
264     }
265     return false;
266     // A standard locale name is typically of  the  form
267     // language[_territory][.codeset][@modifier],  where  language is
268     // an ISO 639 language code, territory is an ISO 3166 country code,
269     // and codeset  is  a  character  set or encoding identifier like
270     // ISO-8859-1 or UTF-8.
271 }
272
273 // [99ms]
274 function update_locale($loc) {
275     // $LANG or DEFAULT_LANGUAGE is too less information, at least on unix for
276     // setlocale(), for bindtextdomain() to succeed.
277     $setlocale = guessing_setlocale(LC_ALL, $loc); // [56ms]
278     if (!$setlocale) { // system has no locale for this language, so gettext might fail
279         $setlocale = FileFinder::_get_lang();
280         list ($setlocale,) = split('_', $setlocale, 2);
281         $setlocale = guessing_setlocale(LC_ALL, $setlocale); // try again
282         if (!$setlocale) $setlocale = $loc;
283     }
284     // Try to put new locale into environment (so any
285     // programs we run will get the right locale.)
286     if (!function_exists('bindtextdomain'))  {
287         // Reinitialize translation array.
288         global $locale;
289         $locale = array();
290         // do reinit to purge PHP's static cache [43ms]
291         if ( ($lcfile = FindLocalizedFile("LC_MESSAGES/phpwiki.php", 'missing_ok', 'reinit')) ) {
292             include($lcfile);
293         }
294     } else {
295         // If PHP is in safe mode, this is not allowed,
296         // so hide errors...
297         @putenv("LC_ALL=$setlocale");
298         @putenv("LANG=$loc");
299         @putenv("LANGUAGE=$loc");
300     }
301
302     // To get the POSIX character classes in the PCRE's (e.g.
303     // [[:upper:]]) to match extended characters (e.g. GrüßGott), we have
304     // to set the locale, using setlocale().
305     //
306     // The problem is which locale to set?  We would like to recognize all
307     // upper-case characters in the iso-8859-1 character set as upper-case
308     // characters --- not just the ones which are in the current $LANG.
309     //
310     // As it turns out, at least on my system (Linux/glibc-2.2) as long as
311     // you setlocale() to anything but "C" it works fine.  (I'm not sure
312     // whether this is how it's supposed to be, or whether this is a bug
313     // in the libc...)
314     //
315     // We don't currently use the locale setting for anything else, so for
316     // now, just set the locale to US English.
317     //
318     // FIXME: Not all environments may support en_US?  We should probably
319     // have a list of locales to try.
320     if (setlocale(LC_CTYPE, 0) == 'C') {
321         $x = setlocale(LC_CTYPE, 'en_US.' . $GLOBALS['charset']);
322     } else {
323         $x = setlocale(LC_CTYPE, $setlocale);
324     }
325
326     return $loc;
327 }
328
329 /** string pcre_fix_posix_classes (string $regexp)
330 *
331 * Older version (pre 3.x?) of the PCRE library do not support
332 * POSIX named character classes (e.g. [[:alnum:]]).
333 *
334 * This is a helper function which can be used to convert a regexp
335 * which contains POSIX named character classes to one that doesn't.
336 *
337 * All instances of strings like '[:<class>:]' are replaced by the equivalent
338 * enumerated character class.
339 *
340 * Implementation Notes:
341 *
342 * Currently we use hard-coded values which are valid only for
343 * ISO-8859-1.  Also, currently on the classes [:alpha:], [:alnum:],
344 * [:upper:] and [:lower:] are implemented.  (The missing classes:
345 * [:blank:], [:cntrl:], [:digit:], [:graph:], [:print:], [:punct:],
346 * [:space:], and [:xdigit:] could easily be added if needed.)
347 *
348 * This is a hack.  I tried to generate these classes automatically
349 * using ereg(), but discovered that in my PHP, at least, ereg() is
350 * slightly broken w.r.t. POSIX character classes.  (It includes
351 * "\xaa" and "\xba" in [:alpha:].)
352 *
353 * So for now, this will do.  --Jeff <dairiki@dairiki.org> 14 Mar, 2001
354 */
355 function pcre_fix_posix_classes ($regexp) {
356     global $charset;
357     if (!isset($charset))
358         $charset = CHARSET; // get rid of constant. pref is dynamic and language specific
359     if (in_array($GLOBALS['LANG'], array('zh')))
360         $charset = 'utf-8';
361     if (strstr($GLOBALS['LANG'],'.utf-8'))
362         $charset = 'utf-8';
363     elseif (strstr($GLOBALS['LANG'],'.euc-jp'))
364         $charset = 'euc-jp';
365     elseif (in_array($GLOBALS['LANG'], array('ja')))
366         //$charset = 'utf-8';
367         $charset = 'euc-jp';
368
369     if (strtolower($charset) == 'utf-8') { // thanks to John McPherson
370         // until posix class names/pcre work with utf-8
371         if (preg_match('/[[:upper:]]/', '\xc4\x80'))
372             return $regexp;    
373         // utf-8 non-ascii chars: most common (eg western) latin chars are 0xc380-0xc3bf
374         // we currently ignore other less common non-ascii characters
375         // (eg central/east european) latin chars are 0xc432-0xcdbf and 0xc580-0xc5be
376         // and indian/cyrillic/asian languages
377         
378         // this replaces [[:lower:]] with utf-8 match (Latin only)
379         $regexp = preg_replace('/\[\[\:lower\:\]\]/','(?:[a-z]|\xc3[\x9f-\xbf]|\xc4[\x81\x83\x85\x87])',
380                                $regexp);
381         // this replaces [[:upper:]] with utf-8 match (Latin only)
382         $regexp = preg_replace('/\[\[\:upper\:\]\]/','(?:[A-Z]|\xc3[\x80-\x9e]|\xc4[\x80\x82\x84\x86])',
383                                $regexp);
384     } elseif (preg_match('/[[:upper:]]/', 'Ä')) {
385         // First check to see if our PCRE lib supports POSIX character
386         // classes.  If it does, there's nothing to do.
387         return $regexp;
388     }
389     static $classes = array(
390                             'alnum' => "0-9A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\xff",
391                             'alpha' => "A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\xff",
392                             'upper' => "A-Z\xc0-\xd6\xd8-\xde",
393                             'lower' => "a-z\xdf-\xf6\xf8-\xff"
394                             );
395     $keys = join('|', array_keys($classes));
396     return preg_replace("/\[:($keys):]/e", '$classes["\1"]', $regexp);
397 }
398
399 function deduce_script_name() {
400     $s = &$GLOBALS['HTTP_SERVER_VARS'];
401     $script = @$s['SCRIPT_NAME'];
402     if (empty($script) or $script[0] != '/') {
403         // Some places (e.g. Lycos) only supply a relative name in
404         // SCRIPT_NAME, but give what we really want in SCRIPT_URL.
405         if (!empty($s['SCRIPT_URL']))
406             $script = $s['SCRIPT_URL'];
407     }
408     return $script;
409 }
410
411 function IsProbablyRedirectToIndex () {
412     // This might be a redirect to the DirectoryIndex,
413     // e.g. REQUEST_URI = /dir/?some_action got redirected
414     // to SCRIPT_NAME = /dir/index.php
415
416     // In this case, the proper virtual path is still
417     // $SCRIPT_NAME, since pages appear at
418     // e.g. /dir/index.php/HomePage.
419
420     $requri = preg_replace('/\?.*$/','',$GLOBALS['HTTP_SERVER_VARS']['REQUEST_URI']);
421     $requri = preg_quote($requri, '%');
422     return preg_match("%^${requri}[^/]*$%", $GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);
423 }
424
425 // >= php-4.1.0
426 if (!function_exists('array_key_exists')) { // lib/IniConfig.php, sqlite, adodb, ...
427     function array_key_exists($item, $array) {
428         return isset($array[$item]);
429     }
430 }
431
432 // => php-4.0.5
433 if (!function_exists('is_scalar')) { // lib/stdlib.php:wikihash()
434     function is_scalar($x) {
435         return is_numeric($x) or is_string($x) or is_float($x) or is_bool($x); 
436     }
437 }
438
439 // => php-4.2.0. pear wants to break old php's! DB uses it now.
440 if (!function_exists('is_a')) {
441     function is_a($item,$class) {
442         return isa($item,$class); 
443     }
444 }
445
446 // needed < php5
447 // by bradhuizenga at softhome dot net from the php docs
448 if (!function_exists('str_ireplace')) {
449   function str_ireplace($find, $replace, $string) {
450       if (!is_array($find)) $find = array($find);
451       if (!is_array($replace)) {
452           if (!is_array($find)) 
453               $replace = array($replace);
454           else {
455               // this will duplicate the string into an array the size of $find
456               $c = count($find);
457               $rString = $replace;
458               unset($replace);
459               for ($i = 0; $i < $c; $i++) {
460                   $replace[$i] = $rString;
461               }
462           }
463       }
464       foreach ($find as $fKey => $fItem) {
465           $between = explode(strtolower($fItem),strtolower($string));
466           $pos = 0;
467           foreach ($between as $bKey => $bItem) {
468               $between[$bKey] = substr($string,$pos,strlen($bItem));
469               $pos += strlen($bItem) + strlen($fItem);
470           }
471           $string = implode($replace[$fKey], $between);
472       }
473       return($string);
474   }
475 }
476
477 /**
478  * safe php4 definition for clone.
479  * php5 copies objects by reference, but we need to clone "deep copy" in some places.
480  * (BlockParser)
481  * We need to eval it as workaround for the php5 parser.
482  * See http://www.acko.net/node/54
483  */
484 if (!check_php_version(5)) {
485     eval('
486     function clone($object) {
487       return $object;
488     }
489     ');
490 }
491
492 /**
493  * array_diff_assoc() returns an array containing all the values from array1 that are not
494  * present in any of the other arguments. Note that the keys are used in the comparison 
495  * unlike array_diff(). In core since php-4.3.0
496  * Our fallback here supports only hashes and two args.
497  * $array1 = array("a" => "green", "b" => "brown", "c" => "blue");
498  * $array2 = array("a" => "green", "y" => "yellow", "r" => "red");
499  * => b => brown, c => blue
500  */
501 if (!function_exists('array_diff_assoc')) {
502     function array_diff_assoc($a1, $a2) {
503         $result = array();
504         foreach ($a1 as $k => $v) {
505             if (!isset($a2[$k]) or !$a2[$k])
506                 $result[$k] = $v;       
507         }
508         return $result;
509     }
510 }
511
512 /** 
513  * wordwrap() might crash between 4.1.2 and php-4.3.0RC2, fixed in 4.3.0
514  * See http://bugs.php.net/bug.php?id=20927 and 
515  * http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2002-1396
516  * Improved version of wordwrap2() in the comments at http://www.php.net/wordwrap
517  */
518 function safe_wordwrap($str, $width=80, $break="\n", $cut=false) {
519     if (check_php_version(4,3))
520         return wordwrap($str, $width, $break, $cut);
521     elseif (!check_php_version(4,1,2))
522         return wordwrap($str, $width, $break, $cut);
523     else {
524         $len = strlen($str);
525         $tag = 0; $result = ''; $wordlen = 0;
526         for ($i = 0; $i < $len; $i++) {
527             $chr = $str[$i];
528             // don't break inside xml tags
529             if ($chr == '<') {
530                 $tag++;
531             } elseif ($chr == '>') {
532                 $tag--;
533             } elseif (!$tag) {
534                 if (!function_exists('ctype_space')) {
535                     if (preg_match('/^\s$/', $chr))
536                         $wordlen = 0;
537                     else
538                         $wordlen++;
539                 }
540                 elseif (ctype_space($chr)) {
541                     $wordlen = 0;
542                 } else {
543                     $wordlen++;
544                 }
545             }
546             if ((!$tag) && ($wordlen) && (!($wordlen % $width))) {
547                 $chr .= $break;
548             }
549             $result .= $chr;
550         }
551         return $result;
552         /*
553         if (isset($str) && isset($width)) {
554             $ex = explode(" ", $str); // wrong: must use preg_split \s+
555             $rp = array();
556             for ($i=0; $i<count($ex); $i++) {
557                 // $word_array = preg_split('//', $ex[$i], -1, PREG_SPLIT_NO_EMPTY);
558                 // delete #&& !is_numeric($ex[$i])# if you want force it anyway
559                 if (strlen($ex[$i]) > $width && !is_numeric($ex[$i])) {
560                     $where = 0;
561                     $rp[$i] = "";
562                     for($b=0; $b < (ceil(strlen($ex[$i]) / $width)); $b++) {
563                         $rp[$i] .= substr($ex[$i], $where, $width).$break;
564                         $where += $width;
565                     }
566                 } else {
567                     $rp[$i] = $ex[$i];
568                 }
569             }
570             return implode(" ",$rp);
571         }
572         return $text;
573         */
574     }
575 }
576
577 function getUploadFilePath() {
578     if (defined('UPLOAD_FILE_PATH')) return UPLOAD_FILE_PATH;
579     return defined('PHPWIKI_DIR') 
580         ? PHPWIKI_DIR . "/uploads/" 
581         : realpath(dirname(__FILE__) . "/../uploads/");
582 }
583 function getUploadDataPath() {
584     if (defined('UPLOAD_DATA_PATH')) return UPLOAD_DATA_PATH;
585     return SERVER_URL . ((substr(DATA_PATH,0,1)=='/') ? '' : "/") . DATA_PATH . '/uploads/';
586 }
587
588 /**
589  * htmlspecialchars doesn't support some special 8bit charsets, which we do want to support.
590  * Well it just prints a warning which we could circumvent.
591  * Note: unused, since php htmlspecialchars does the same, just prints a warning which we silence
592  */
593 /*
594 function htmlspecialchars_workaround($str, $quote=ENT_COMPAT, $charset='iso-8859-1') {
595     if (in_array(strtolower($charset), 
596                  array('iso-8859-2', 'iso8859-2', 'latin-2', 'latin2'))) 
597     {
598         if (! ($quote & ENT_NOQUOTES)) {
599             $str = str_replace("\"", "&quot;",
600                                $str);
601         }
602         if ($quote & ENT_QUOTES) {
603             $str = str_replace("\'", "&#039;",
604                                $str);
605         }
606         return str_replace(array("<", ">", "&"),
607                            array("&lt;", "&gt;", "&amp;"), $str);
608     }
609     else {
610         return htmlspecialchars($str, $quote, $charset);
611     }
612 }
613 */
614
615 // $Log: not supported by cvs2svn $
616 // Revision 1.141  2007/01/07 18:41:42  rurban
617 // Add array_diff_assoc() fallback: fixes Blog with php < 4.3.x. Support UPLOAD_FILE_PATH, UPLOAD_DATA_PATH overrides.
618 //
619 // Revision 1.140  2007/01/02 13:21:30  rurban
620 // added _DEBUG_REMOTE flag, omit want_content if not necessary
621 //
622 // Revision 1.139  2006/03/19 14:50:42  rurban
623 // sf.net patch #1438442 by Matt Brown: Unitialised variable reference in config.php
624 //
625 // Revision 1.138  2006/03/07 20:45:43  rurban
626 // wikihash for php-5.1
627 //
628 // Revision 1.137  2005/08/06 14:31:10  rurban
629 // ensure absolute uploads path
630 //
631 // Revision 1.136  2005/05/06 16:49:24  rurban
632 // Safari comment
633 //
634 // Revision 1.135  2005/04/01 15:22:20  rurban
635 // Implement icase and regex options.
636 // Change checkbox case message from "Case-Sensitive" to "Case-Insensitive"
637 //
638 // Revision 1.134  2005/03/27 18:23:39  rurban
639 // compute locale only for setlocale and LC_ALL
640 //
641 // Revision 1.133  2005/02/08 13:26:59  rurban
642 //  improve the locale splitter
643 //
644 // Revision 1.132  2005/02/07 15:39:02  rurban
645 // another locale fix
646 //
647 // Revision 1.131  2005/02/05 15:32:09  rurban
648 // force guessing_setlocale (again)
649 //
650 // Revision 1.130  2005/01/29 20:36:44  rurban
651 // very important php5 fix! clone objects
652 //
653 // Revision 1.129  2005/01/08 22:53:50  rurban
654 // hardcode list of langs (file access is slow)
655 // fix client detection
656 // set proper locale on empty locale
657 //
658 // Revision 1.128  2005/01/04 20:22:46  rurban
659 // guess $LANG based on client
660 //
661 // Revision 1.127  2004/12/26 17:15:32  rurban
662 // new reverse locale detection on DEFAULT_LANGUAGE="", ja default euc-jp again
663 //
664 // Revision 1.126  2004/12/20 16:05:00  rurban
665 // gettext msg unification
666 //
667 // Revision 1.125  2004/11/21 11:59:18  rurban
668 // remove final \n to be ob_cache independent
669 //
670 // Revision 1.124  2004/11/09 17:11:16  rurban
671 // * revert to the wikidb ref passing. there's no memory abuse there.
672 // * use new wikidb->_cache->_id_cache[] instead of wikidb->_iwpcache, to effectively
673 //   store page ids with getPageLinks (GleanDescription) of all existing pages, which
674 //   are also needed at the rendering for linkExistingWikiWord().
675 //   pass options to pageiterator.
676 //   use this cache also for _get_pageid()
677 //   This saves about 8 SELECT count per page (num all pagelinks).
678 // * fix passing of all page fields to the pageiterator.
679 // * fix overlarge session data which got broken with the latest ACCESS_LOG_SQL changes
680 //
681 // Revision 1.123  2004/11/05 21:03:27  rurban
682 // new DEBUG flag: _DEBUG_LOGIN (64)
683 //   verbose login debug-msg (settings and reason for failure)
684 //
685 // Revision 1.122  2004/10/14 17:49:58  rurban
686 // fix warning in safe_wordwrap
687 //
688 // Revision 1.121  2004/10/14 17:48:19  rurban
689 // typo in safe_wordwrap
690 //
691 // Revision 1.120  2004/09/22 13:46:26  rurban
692 // centralize upload paths.
693 // major WikiPluginCached feature enhancement:
694 //   support _STATIC pages in uploads/ instead of dynamic getimg.php? subrequests.
695 //   mainly for debugging, cache problems and action=pdf
696 //
697 // Revision 1.119  2004/09/16 07:50:37  rurban
698 // wordwrap() might crash between 4.1.2 and php-4.3.0RC2, fixed in 4.3.0
699 // See http://bugs.php.net/bug.php?id=20927 and
700 //     http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2002-1396
701 // Improved version of wordwrap2() from the comments at http://www.php.net/wordwrap
702 //
703 // Revision 1.118  2004/07/13 14:03:31  rurban
704 // just some comments
705 //
706 // Revision 1.117  2004/06/21 17:29:17  rurban
707 // pear DB introduced a is_a requirement. so pear lost support for php < 4.2.0
708 //
709 // Revision 1.116  2004/06/21 08:39:37  rurban
710 // pear/Cache update from Cache-1.5.4 (added db and trifile container)
711 // pear/DB update from DB-1.6.1 (mysql bugfixes, php5 compat, DB_PORTABILITY features)
712 //
713 // Revision 1.115  2004/06/20 14:42:54  rurban
714 // various php5 fixes (still broken at blockparser)
715 //
716 // Revision 1.114  2004/06/19 11:48:05  rurban
717 // moved version check forwards: already needed in XmlElement::_quote
718 //
719 // Revision 1.113  2004/06/03 12:59:41  rurban
720 // simplify translation
721 // NS4 wrap=virtual only
722 //
723 // Revision 1.112  2004/06/02 18:01:46  rurban
724 // init global FileFinder to add proper include paths at startup
725 //   adds PHPWIKI_DIR if started from another dir, lib/pear also
726 // fix slashify for Windows
727 // fix USER_AUTH_POLICY=old, use only USER_AUTH_ORDER methods (besides HttpAuth)
728 //
729 // Revision 1.111  2004/05/17 17:43:29  rurban
730 // CGI: no PATH_INFO fix
731 //
732 // Revision 1.110  2004/05/16 23:10:44  rurban
733 // update_locale wrongly resetted LANG, which broke japanese.
734 // japanese now correctly uses EUC_JP, not utf-8.
735 // more charset and lang headers to help the browser.
736 //
737 // Revision 1.109  2004/05/08 14:06:12  rurban
738 // new support for inlined image attributes: [image.jpg size=50x30 align=right]
739 // minor stability and portability fixes
740 //
741 // Revision 1.108  2004/05/08 11:25:16  rurban
742 // php-4.0.4 fixes
743 //
744 // Revision 1.107  2004/05/06 17:30:38  rurban
745 // CategoryGroup: oops, dos2unix eol
746 // improved phpwiki_version:
747 //   pre -= .0001 (1.3.10pre: 1030.099)
748 //   -p1 += .001 (1.3.9-p1: 1030.091)
749 // improved InstallTable for mysql and generic SQL versions and all newer tables so far.
750 // abstracted more ADODB/PearDB methods for action=upgrade stuff:
751 //   backend->backendType(), backend->database(),
752 //   backend->listOfFields(),
753 //   backend->listOfTables(),
754 //
755 // Revision 1.106  2004/05/02 19:12:14  rurban
756 // fix sf.net bug #945154 Konqueror alt css
757 //
758 // Revision 1.105  2004/05/02 15:10:06  rurban
759 // new finally reliable way to detect if /index.php is called directly
760 //   and if to include lib/main.php
761 // new global AllActionPages
762 // SetupWiki now loads all mandatory pages: HOME_PAGE, action pages, and warns if not.
763 // WikiTranslation what=buttons for Carsten to create the missing MacOSX buttons
764 // PageGroupTestOne => subpages
765 // renamed PhpWikiRss to PhpWikiRecentChanges
766 // more docs, default configs, ...
767 //
768 // Revision 1.104  2004/05/01 11:26:37  rurban
769 // php-4.0.x support: array_key_exists (PHP 4 >= 4.1.0)
770 //
771 // Revision 1.103  2004/04/30 00:04:14  rurban
772 // zh (chinese language) support
773 //
774 // Revision 1.102  2004/04/29 23:25:12  rurban
775 // re-ordered locale init (as in 1.3.9)
776 // fixed loadfile with subpages, and merge/restore anyway
777 //   (sf.net bug #844188)
778 //
779 // Revision 1.101  2004/04/26 13:22:32  rurban
780 // calculate bool old or dynamic constants later
781 //
782 // Revision 1.100  2004/04/26 12:15:01  rurban
783 // check default config values
784 //
785 // Revision 1.99  2004/04/21 14:04:24  zorloc
786 // 'Require lib/FileFinder.php' necessary to allow for call to FindLocalizedFile().
787 //
788 // Revision 1.98  2004/04/20 18:10:28  rurban
789 // config refactoring:
790 //   FileFinder is needed for WikiFarm scripts calling index.php
791 //   config run-time calls moved to lib/IniConfig.php:fix_configs()
792 //   added PHPWIKI_DIR smart-detection code (Theme finder)
793 //   moved FileFind to lib/FileFinder.php
794 //   cleaned lib/config.php
795 //
796 // Revision 1.97  2004/04/18 01:11:52  rurban
797 // more numeric pagename fixes.
798 // fixed action=upload with merge conflict warnings.
799 // charset changed from constant to global (dynamic utf-8 switching)
800 //
801
802 // For emacs users
803 // Local Variables:
804 // mode: php
805 // tab-width: 8
806 // c-basic-offset: 4
807 // c-hanging-comment-ender-p: nil
808 // indent-tabs-mode: nil
809 // End:
810 ?>