--- inc/global.php 2001/08/27 09:17:40 1.6 +++ inc/global.php 2001/09/03 15:52:15 1.8 @@ -1,45 +1,99 @@ [^\>]*\>)/e", - "array_search(strtoupper('\\2'),\$allowed,false)?'\\1':HTMLSpecialChars('\\1')", + "array_search(MyUpper('\\2'),\$allowed,false)?'\\1':HTMLSpecialChars('\\1')", $str); $str = preg_replace("/(^\s+|\s+$)/", "", $str); $str = ereg_replace("\"", """, $str); return $str; } - function ParseNewline($str) { + + function ParseNewline($str, $paragraphs = false) { if (!$str) return $str; - $str = preg_replace('/\s*(\r\n\r\n|\n\r\n\r|\n\n|\r\r)/m', '
', $str);
- $str = preg_replace('/\s*(\r\n|\n\r|\r|\n)/m', '
', $str);
+ if ($paragraphs) $str = preg_replace('/\s*(\r\n\r\n|\n\r\n\r|\n\n|\r\r)/m', '
', $str);
+ $str = ereg_replace("[ \t]*(\r\n?|\n\r?)", '
', $str);
return $str;
}
- function MyQuote($str) {
- global $dbh;
- if (!$dbh) return "'$str'";
- return $dbh->quote($str);
- }
- function MyMove($src, $dest) {
- $cmd = "mv -f '".EscapeShellCmd($src)."' '".EscapeShellCmd($dest)."'";
- return exec($cmd);
- }
- function MyDelete($src) {
- @unlink($src);
- }
+
function error($msg) {
if (is_array($msg)) $msg = implode(" ", $msg);
- echo "
\n[".HTMLSpecialChars($msg).
- "]
\n";
+ echo "
\n[".HTMLSpecialChars($msg)."]
\n";
}
- function PicSize($pic) {
- global $syspicdir;
- $ret = array(0, 0);
- if ($pic) {
- @$size = GetImageSize($syspicdir."/".$pic);
- $ret = array($size[0], $size[1]);
- }
- return $ret;
+
+ function convert_html($str) {
+ $entities = array(
+ "nbsp" => " ", "#160" => " ", # nbsp
+ "amp" => " ", "#38" => " ", # amp
+ "quot" => "\"", "#34" => "\"", # quot
+ "lt" => "<", "#60" => "<", # lt
+ "gt" => ">", "#62" => ">", # gt
+ "Scaron" => "©", "#352" => "©",
+ "scaron" => "¹", "#353" => "¹",
+ "Ccaron" => "È", "#268" => "È", "#268" => "È",
+ "ccaron" => "è", "#232" => "è", "#269" => "è",
+ "Cgrave" => "Æ", "#262" => "Æ", "#" => "Æ",
+ "cgrave" => "æ", "#230" => "æ", "#263" => "æ",
+ "???" => "Ð", "#272" => "Ð", "#" => "Ð",
+ "???" => "ð", "#273" => "ð",
+ "Zcaron" => "®", "#381" => "®",
+ "zcaron" => "¾", "#382" => "¾",
+ );
+ $t = intval($str);
+ # Skip if not a scalar
+ if (!is_scalar($str)) return $str;
+ # If a number, don't touch it
+ if (strcmp(intval($str), $str) == 0) return $str;
+ # Replace "
" with "\n"
+ $str = preg_replace("/\
/m", "\n", $str);
+ # Replace "<...>\n" with "<...>"
+ $str = preg_replace("/(\<[^\/][^\>]*\>)\s*(\r\n?|\n\r?)\s*/m", '$1', $str);
+ # Replace "\n" with "\n"
+ $str = preg_replace("/\s*(\r\n?|\n\r?)\s*(\<\/[^\>]+\>)/m", '$2$1', $str);
+ # Remove "
" and "BR" tags, along with their pairs + $str = preg_replace("/\<\/?\s*(HTML|HEAD|BODY|FONT|P|BR)[^\>]*\>/im", '', $str); + # Replace "\n