]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/config.php
Chrome does not display the addInfobox
[SourceForge/phpwiki.git] / lib / config.php
1 <?php
2 rcs_id('$Id$');
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); // APD tracing/profiling
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 (strpos(strtolower(browserAgent()), strtolower($match)) !== false);
74 }
75 // returns a similar number for Netscape/Mozilla (gecko=5.0)/IE/Opera features.
76 function browserVersion() {
77     $agent = browserAgent();
78     if (strstr($agent, "Mozilla/4.0 (compatible; MSIE"))
79         return (float) substr($agent, 30);
80     elseif (strstr($agent, "Mozilla/5.0 (compatible; Konqueror/"))
81         return (float) substr($agent, 36);
82     else
83         return (float) substr($agent, 8);
84 }
85 function isBrowserIE() {
86     return (browserDetect('Mozilla/') and 
87             browserDetect('MSIE'));
88 }
89 // problem with transparent PNG's
90 function isBrowserIE55() {
91     return (isBrowserIE() and 
92             browserVersion() > 5.1 and browserVersion() < 6.0);
93 }
94 // old Netscape prior to Mozilla
95 function isBrowserNetscape($version = false) {
96     $agent = (browserDetect('Mozilla/') and 
97             ! browserDetect('Gecko/') and
98             ! browserDetect('MSIE'));
99     if ($version) return $agent and browserVersion() >= $version; 
100     else return $agent;
101 }
102 // must omit display alternate stylesheets: konqueror 3.1.4
103 // http://sourceforge.net/tracker/index.php?func=detail&aid=945154&group_id=6121&atid=106121
104 function isBrowserKonqueror($version = false) {
105     if ($version) return browserDetect('Konqueror/') and browserVersion() >= $version; 
106     return browserDetect('Konqueror/');
107 }
108 // MacOSX Safari has certain limitations. Need detection and patches.
109 // * no <object>, only <embed>
110 function isBrowserSafari($version = false) {
111     $found = browserDetect('Spoofer/');
112     $found = browserDetect('AppleWebKit/') or $found;
113     if ($version) return $found and browserVersion() >= $version; 
114     return $found;
115 }
116 function isBrowserOpera($version = false) {
117     if ($version) return browserDetect('Opera/') and browserVersion() >= $version; 
118     return browserDetect('Opera/');
119 }
120
121
122 /**
123  * If $LANG is undefined:
124  * Smart client language detection, based on our supported languages
125  * HTTP_ACCEPT_LANGUAGE="de-at,en;q=0.5"
126  *   => "de"
127  * We should really check additionally if the i18n HomePage version is defined.
128  * So must defer this to the request loop.
129  */
130 function guessing_lang ($languages=false) {
131     if (!$languages) {
132         // make this faster
133         $languages = array("en","de","es","fr","it","ja","zh","nl","sv");
134         // ignore possible "_<territory>" and codeset "ja.utf8"
135         /*
136         require_once("lib/WikiTheme.php");
137         $languages = listAvailableLanguages();
138         if (defined('DEFAULT_LANGUAGE') and in_array(DEFAULT_LANGUAGE, $languages))
139         {
140             // remove duplicates
141             if ($i = array_search(DEFAULT_LANGUAGE, $languages) !== false) {
142                 array_splice($languages, $i, 1);
143             }
144             array_unshift($languages, DEFAULT_LANGUAGE);
145             foreach ($languages as $lang) {
146                 $arr = FileFinder::locale_versions($lang);
147                 $languages = array_merge($languages, $arr);
148             }
149         }
150         */
151     }
152
153     $accept = false; 
154     if (isset($GLOBALS['request'])) // in fixup-dynamic-config there's no request yet
155         $accept = $GLOBALS['request']->get('HTTP_ACCEPT_LANGUAGE');
156     elseif (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE']))
157         $accept = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
158
159     if ($accept) {
160         $lang_list = array();
161         $list = explode(",", $accept);
162         for ($i=0; $i<count($list); $i++) {
163             $pos = strchr($list[$i], ";") ;
164             if ($pos === false) {
165                 // No Q it is only a locale...
166                 $lang_list[$list[$i]] = 100;
167             } else {
168                 // Has a Q rating        
169                 $q = explode(";",$list[$i]) ;
170                 $loc = $q[0] ;
171                 $q = explode("=",$q[1]) ;
172                 $lang_list[$loc] = $q[1]*100 ;
173             }
174         }
175
176         // sort by q desc
177         arsort($lang_list);
178
179         // compare with languages, ignoring sublang and charset
180         foreach ($lang_list as $lang => $q) {
181             if (in_array($lang, $languages))
182                 return $lang;
183             // de_DE.iso8859-1@euro => de_DE.iso8859-1, de_DE, de
184             // de-DE => de-DE, de
185             foreach (array('@', '.', '_') as $sep) {
186                 if ( ($tail = strchr($lang, $sep)) ) {
187                     $lang_short = substr($lang, 0, -strlen($tail));
188                     if (in_array($lang_short, $languages))
189                         return $lang_short;
190                 }
191             }
192             if ($pos = strchr($lang, "-") and in_array(substr($lang, 0, $pos), $languages))
193                 return substr($lang, 0, $pos);
194         }
195     }
196     return $languages[0];
197 }
198
199 /**
200  * Smart setlocale().
201  *
202  * This is a version of the builtin setlocale() which is
203  * smart enough to try some alternatives...
204  *
205  * @param mixed $category
206  * @param string $locale
207  * @return string The new locale, or <code>false</code> if unable
208  *  to set the requested locale.
209  * @see setlocale
210  * [56ms]
211  */
212 function guessing_setlocale ($category, $locale) {
213     $alt = array('en' => array('C', 'en_US', 'en_GB', 'en_AU', 'en_CA', 'english'),
214                  'de' => array('de_DE', 'de_DE', 'de_DE@euro', 
215                                'de_AT@euro', 'de_AT', 'German_Austria.1252', 'deutsch', 
216                                'german', 'ge'),
217                  'es' => array('es_ES', 'es_MX', 'es_AR', 'spanish'),
218                  'nl' => array('nl_NL', 'dutch'),
219                  'fr' => array('fr_FR', 'français', 'french'),
220                  'it' => array('it_IT'),
221                  'sv' => array('sv_SE'),
222                  'ja.utf-8'  => array('ja_JP','ja_JP.utf-8','japanese'),
223                  'ja.euc-jp' => array('ja_JP','ja_JP.eucJP','japanese.euc'),
224                  'zh' => array('zh_TW', 'zh_CN'),
225                  );
226     if (!$locale or $locale=='C') { 
227         // do the reverse: return the detected locale collapsed to our LANG
228         $locale = setlocale($category, '');
229         if ($locale) {
230             if (strstr($locale, '_')) list ($lang) = split('_', $locale);
231             else $lang = $locale;
232             if (strlen($lang) > 2) { 
233                 foreach ($alt as $try => $locs) {
234                     if (in_array($locale, $locs) or in_array($lang, $locs)) {
235                         //if (empty($GLOBALS['LANG'])) $GLOBALS['LANG'] = $try;
236                         return $try;
237                     }
238                 }
239             }
240         }
241     }
242     if (strlen($locale) == 2)
243         $lang = $locale;
244     else 
245         list ($lang) = split('_', $locale);
246     if (!isset($alt[$lang]))
247         return false;
248         
249     foreach ($alt[$lang] as $try) {
250         if ($res = setlocale($category, $try))
251             return $res;
252         // Try with charset appended...
253         $try = $try . '.' . $GLOBALS['charset'];
254         if ($res = setlocale($category, $try))
255             return $res;
256         foreach (array(".", '@', '_') as $sep) {
257             if ($i = strpos($try, $sep)) {
258                 $try = substr($try, 0, $i);
259                 if (($res = setlocale($category, $try)))
260                     return $res;
261             }
262         }
263     }
264     return false;
265     // A standard locale name is typically of  the  form
266     // language[_territory][.codeset][@modifier],  where  language is
267     // an ISO 639 language code, territory is an ISO 3166 country code,
268     // and codeset  is  a  character  set or encoding identifier like
269     // ISO-8859-1 or UTF-8.
270 }
271
272 // [99ms]
273 function update_locale($loc) {
274     // $LANG or DEFAULT_LANGUAGE is too less information, at least on unix for
275     // setlocale(), for bindtextdomain() to succeed.
276     $setlocale = guessing_setlocale(LC_ALL, $loc); // [56ms]
277     if (!$setlocale) { // system has no locale for this language, so gettext might fail
278         $setlocale = FileFinder::_get_lang();
279         list ($setlocale,) = split('_', $setlocale, 2);
280         $setlocale = guessing_setlocale(LC_ALL, $setlocale); // try again
281         if (!$setlocale) $setlocale = $loc;
282     }
283     // Try to put new locale into environment (so any
284     // programs we run will get the right locale.)
285     if (!function_exists('bindtextdomain'))  {
286         // Reinitialize translation array.
287         global $locale;
288         $locale = array();
289         // do reinit to purge PHP's static cache [43ms]
290         if ( ($lcfile = FindLocalizedFile("LC_MESSAGES/phpwiki.php", 'missing_ok', 'reinit')) ) {
291             include($lcfile);
292         }
293     } else {
294         // If PHP is in safe mode, this is not allowed,
295         // so hide errors...
296         @putenv("LC_ALL=$setlocale");
297         @putenv("LANG=$loc");
298         @putenv("LANGUAGE=$loc");
299     }
300
301     // To get the POSIX character classes in the PCRE's (e.g.
302     // [[:upper:]]) to match extended characters (e.g. GrüßGott), we have
303     // to set the locale, using setlocale().
304     //
305     // The problem is which locale to set?  We would like to recognize all
306     // upper-case characters in the iso-8859-1 character set as upper-case
307     // characters --- not just the ones which are in the current $LANG.
308     //
309     // As it turns out, at least on my system (Linux/glibc-2.2) as long as
310     // you setlocale() to anything but "C" it works fine.  (I'm not sure
311     // whether this is how it's supposed to be, or whether this is a bug
312     // in the libc...)
313     //
314     // We don't currently use the locale setting for anything else, so for
315     // now, just set the locale to US English.
316     //
317     // FIXME: Not all environments may support en_US?  We should probably
318     // have a list of locales to try.
319     if (setlocale(LC_CTYPE, 0) == 'C') {
320         $x = setlocale(LC_CTYPE, 'en_US.' . $GLOBALS['charset']);
321     } else {
322         $x = setlocale(LC_CTYPE, $setlocale);
323     }
324
325     return $loc;
326 }
327
328 /** string pcre_fix_posix_classes (string $regexp)
329 *
330 * Older version (pre 3.x?) of the PCRE library do not support
331 * POSIX named character classes (e.g. [[:alnum:]]).
332 *
333 * This is a helper function which can be used to convert a regexp
334 * which contains POSIX named character classes to one that doesn't.
335 *
336 * All instances of strings like '[:<class>:]' are replaced by the equivalent
337 * enumerated character class.
338 *
339 * Implementation Notes:
340 *
341 * Currently we use hard-coded values which are valid only for
342 * ISO-8859-1.  Also, currently on the classes [:alpha:], [:alnum:],
343 * [:upper:] and [:lower:] are implemented.  (The missing classes:
344 * [:blank:], [:cntrl:], [:digit:], [:graph:], [:print:], [:punct:],
345 * [:space:], and [:xdigit:] could easily be added if needed.)
346 *
347 * This is a hack.  I tried to generate these classes automatically
348 * using ereg(), but discovered that in my PHP, at least, ereg() is
349 * slightly broken w.r.t. POSIX character classes.  (It includes
350 * "\xaa" and "\xba" in [:alpha:].)
351 *
352 * So for now, this will do.  --Jeff <dairiki@dairiki.org> 14 Mar, 2001
353 */
354 function pcre_fix_posix_classes ($regexp) {
355     return $regexp;
356 }
357
358 function deduce_script_name() {
359     $s = &$GLOBALS['HTTP_SERVER_VARS'];
360     $script = @$s['SCRIPT_NAME'];
361     if (empty($script) or $script[0] != '/') {
362         // Some places (e.g. Lycos) only supply a relative name in
363         // SCRIPT_NAME, but give what we really want in SCRIPT_URL.
364         if (!empty($s['SCRIPT_URL']))
365             $script = $s['SCRIPT_URL'];
366     }
367     return $script;
368 }
369
370 function IsProbablyRedirectToIndex () {
371     // This might be a redirect to the DirectoryIndex,
372     // e.g. REQUEST_URI = /dir/?some_action got redirected
373     // to SCRIPT_NAME = /dir/index.php
374
375     // In this case, the proper virtual path is still
376     // $SCRIPT_NAME, since pages appear at
377     // e.g. /dir/index.php/HomePage.
378
379     $requri = preg_replace('/\?.*$/','',$GLOBALS['HTTP_SERVER_VARS']['REQUEST_URI']);
380     $requri = preg_quote($requri, '%');
381     return preg_match("%^${requri}[^/]*$%", $GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);
382 }
383
384 // >= php-4.1.0
385 if (!function_exists('array_key_exists')) { // lib/IniConfig.php, sqlite, adodb, ...
386     function array_key_exists($item, $array) {
387         return isset($array[$item]);
388     }
389 }
390
391 // => php-4.0.5
392 if (!function_exists('is_scalar')) { // lib/stdlib.php:wikihash()
393     function is_scalar($x) {
394         return is_numeric($x) or is_string($x) or is_float($x) or is_bool($x); 
395     }
396 }
397
398 // => php-4.2.0. pear wants to break old php's! DB uses it now.
399 if (!function_exists('is_a')) {
400     function is_a($item,$class) {
401         return isa($item,$class); 
402     }
403 }
404
405 // needed < php5
406 // by bradhuizenga at softhome dot net from the php docs
407 if (!function_exists('str_ireplace')) {
408   function str_ireplace($find, $replace, $string) {
409       if (!is_array($find)) $find = array($find);
410       if (!is_array($replace)) {
411           if (!is_array($find)) 
412               $replace = array($replace);
413           else {
414               // this will duplicate the string into an array the size of $find
415               $c = count($find);
416               $rString = $replace;
417               unset($replace);
418               for ($i = 0; $i < $c; $i++) {
419                   $replace[$i] = $rString;
420               }
421           }
422       }
423       foreach ($find as $fKey => $fItem) {
424           $between = explode(strtolower($fItem),strtolower($string));
425           $pos = 0;
426           foreach ($between as $bKey => $bItem) {
427               $between[$bKey] = substr($string,$pos,strlen($bItem));
428               $pos += strlen($bItem) + strlen($fItem);
429           }
430           $string = implode($replace[$fKey], $between);
431       }
432       return($string);
433   }
434 }
435
436 /**
437  * safe php4 definition for clone.
438  * php5 copies objects by reference, but we need to clone "deep copy" in some places.
439  * (BlockParser)
440  * We need to eval it as workaround for the php5 parser.
441  * See http://www.acko.net/node/54
442  */
443 if (!check_php_version(5)) {
444     eval('
445     function clone($object) {
446       return $object;
447     }
448     ');
449 }
450
451 /**
452  * array_diff_assoc() returns an array containing all the values from array1 that are not
453  * present in any of the other arguments. Note that the keys are used in the comparison 
454  * unlike array_diff(). In core since php-4.3.0
455  * Our fallback here supports only hashes and two args.
456  * $array1 = array("a" => "green", "b" => "brown", "c" => "blue");
457  * $array2 = array("a" => "green", "y" => "yellow", "r" => "red");
458  * => b => brown, c => blue
459  */
460 if (!function_exists('array_diff_assoc')) {
461     function array_diff_assoc($a1, $a2) {
462         $result = array();
463         foreach ($a1 as $k => $v) {
464             if (!isset($a2[$k]) or !$a2[$k])
465                 $result[$k] = $v;       
466         }
467         return $result;
468     }
469 }
470
471 /** 
472  * wordwrap() might crash between 4.1.2 and php-4.3.0RC2, fixed in 4.3.0
473  * See http://bugs.php.net/bug.php?id=20927 and 
474  * http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2002-1396
475  * Improved version of wordwrap2() in the comments at http://www.php.net/wordwrap
476  */
477 function safe_wordwrap($str, $width=80, $break="\n", $cut=false) {
478     if (check_php_version(4,3))
479         return wordwrap($str, $width, $break, $cut);
480     elseif (!check_php_version(4,1,2))
481         return wordwrap($str, $width, $break, $cut);
482     else {
483         $len = strlen($str);
484         $tag = 0; $result = ''; $wordlen = 0;
485         for ($i = 0; $i < $len; $i++) {
486             $chr = $str[$i];
487             // don't break inside xml tags
488             if ($chr == '<') {
489                 $tag++;
490             } elseif ($chr == '>') {
491                 $tag--;
492             } elseif (!$tag) {
493                 if (!function_exists('ctype_space')) {
494                     if (preg_match('/^\s$/', $chr))
495                         $wordlen = 0;
496                     else
497                         $wordlen++;
498                 }
499                 elseif (ctype_space($chr)) {
500                     $wordlen = 0;
501                 } else {
502                     $wordlen++;
503                 }
504             }
505             if ((!$tag) && ($wordlen) && (!($wordlen % $width))) {
506                 $chr .= $break;
507             }
508             $result .= $chr;
509         }
510         return $result;
511         /*
512         if (isset($str) && isset($width)) {
513             $ex = explode(" ", $str); // wrong: must use preg_split \s+
514             $rp = array();
515             for ($i=0; $i<count($ex); $i++) {
516                 // $word_array = preg_split('//', $ex[$i], -1, PREG_SPLIT_NO_EMPTY);
517                 // delete #&& !is_numeric($ex[$i])# if you want force it anyway
518                 if (strlen($ex[$i]) > $width && !is_numeric($ex[$i])) {
519                     $where = 0;
520                     $rp[$i] = "";
521                     for($b=0; $b < (ceil(strlen($ex[$i]) / $width)); $b++) {
522                         $rp[$i] .= substr($ex[$i], $where, $width).$break;
523                         $where += $width;
524                     }
525                 } else {
526                     $rp[$i] = $ex[$i];
527                 }
528             }
529             return implode(" ",$rp);
530         }
531         return $text;
532         */
533     }
534 }
535
536 function getUploadFilePath() {
537
538     if (defined('UPLOAD_FILE_PATH')) {
539         // Force creation of the returned directory if it does not exist.
540         if (!file_exists(UPLOAD_FILE_PATH)) {
541             mkdir(UPLOAD_FILE_PATH, 0775);
542         }
543         if (string_ends_with(UPLOAD_FILE_PATH, "/") 
544             or string_ends_with(UPLOAD_FILE_PATH, "\\")) {
545             return UPLOAD_FILE_PATH;
546         } else {
547             return UPLOAD_FILE_PATH."/";
548         }
549     }
550     return defined('PHPWIKI_DIR') 
551         ? PHPWIKI_DIR . "/uploads/" 
552         : realpath(dirname(__FILE__) . "/../uploads/");
553 }
554 function getUploadDataPath() {
555     if (defined('UPLOAD_DATA_PATH')) {
556         return string_ends_with(UPLOAD_DATA_PATH, "/") 
557             ? UPLOAD_DATA_PATH : UPLOAD_DATA_PATH."/";
558     }
559     return SERVER_URL . (string_ends_with(DATA_PATH, "/") ? '' : "/") 
560          . DATA_PATH . '/uploads/';
561 }
562
563 /**
564  * htmlspecialchars doesn't support some special 8bit charsets, which we do want to support.
565  * Well it just prints a warning which we could circumvent.
566  * Note: unused, since php htmlspecialchars does the same, just prints a warning which we silence
567  */
568 /*
569 function htmlspecialchars_workaround($str, $quote=ENT_COMPAT, $charset='iso-8859-1') {
570     if (in_array(strtolower($charset), 
571                  array('iso-8859-2', 'iso8859-2', 'latin-2', 'latin2'))) 
572     {
573         if (! ($quote & ENT_NOQUOTES)) {
574             $str = str_replace("\"", "&quot;",
575                                $str);
576         }
577         if ($quote & ENT_QUOTES) {
578             $str = str_replace("\'", "&#039;",
579                                $str);
580         }
581         return str_replace(array("<", ">", "&"),
582                            array("&lt;", "&gt;", "&amp;"), $str);
583     }
584     else {
585         return htmlspecialchars($str, $quote, $charset);
586     }
587 }
588 */
589
590 /**
591  * htmlspecialchars doesn't support some special 8bit charsets, which we do want to support.
592  * Well it just prints a warning which we could circumvent.
593  * Note: unused, since php htmlspecialchars does the same, just prints a warning which we silence
594  */
595 /*
596 function htmlspecialchars_workaround($str, $quote=ENT_COMPAT, $charset='iso-8859-1') {
597     if (in_array(strtolower($charset), 
598                  array('iso-8859-2', 'iso8859-2', 'latin-2', 'latin2'))) 
599     {
600         if (! ($quote & ENT_NOQUOTES)) {
601             $str = str_replace("\"", "&quot;",
602                                $str);
603         }
604         if ($quote & ENT_QUOTES) {
605             $str = str_replace("\'", "&#039;",
606                                $str);
607         }
608         return str_replace(array("<", ">", "&"),
609                            array("&lt;", "&gt;", "&amp;"), $str);
610     }
611     else {
612         return htmlspecialchars($str, $quote, $charset);
613     }
614 }
615 */
616
617 // For emacs users
618 // Local Variables:
619 // mode: php
620 // tab-width: 8
621 // c-basic-offset: 4
622 // c-hanging-comment-ender-p: nil
623 // indent-tabs-mode: nil
624 // End:
625 ?>