--- inc/global.php 2001/08/27 09:17:40 1.6 +++ inc/global.php 2001/08/30 16:35:36 1.7 @@ -8,38 +8,75 @@ $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 Slova() { + return array("@", "A", "B", "C", "È", "Æ", "D", "Ð", "E", "F", + "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", + "R", "S", "©", "T", "U", "V", "W", "X", "Y", "Z", "®"); } + 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" => "È", + "ccaron" => "è", "#232" => "è", "#269" => "è", + "Cgrave" => "Æ", "#" => "Æ", "#" => "Æ", + "cgrave" => "æ", "#230" => "æ", "#263" => "æ", + "?" => "Ð", "#" => "Ð", "#" => "Ð", + "?" => "ð", "#" => "ð", "#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 anything in between. + $str = preg_replace("/\<\s*HEAD[^\>]*\>.*\<\/\s*HEAD\s*\>(\r\n?|\n\r?)*/ims", '', $str); + # Remove all "", "", "", "" and "

" tags + $str = preg_replace("/(\<\s*(HTML|HEAD|BODY|FONT|P)[^\>]*\>|\<\/\s*(HTML|HEAD|BODY|FONT|P)\s*\>)/im", '', $str); + # Replace "\n

  • " or "
  • \n" with "
  • " + $str = preg_replace("/(\s*(\r\n?|\n\r?))*(\<\/\s*LI\s*\>)(\s*(\r\n?|\n\r?))*/m", '$3', $str); + # Replace "" or "", respectively + $str = preg_replace("/(\s*(\r\n?|\n\r?))+(\<\/\s*(UL|OL)\s*\>)/m", '$3', $str); + # Replace "``" and "''" with """ (a single double quote) + $str = str_replace("“", '"', $str); + $str = str_replace("”", '"', $str); + # Replace "-" with "-" + $str = str_replace("—", '-', $str); + # Replace character references ("&...;" and "&#...;") with its value + $str = preg_replace("/\&([^;]+);/em", '$entities["$1"]?$entities["$1"]:"?"', $str); + # Remove all whitespace at beginning or ending of a line + $str = preg_replace("/(^\s+|\s+$)/", '', $str); + # Convert Win1250 to ISO8859-2 + $str = strtr($str, "ŠÐÈÆŽšðèæž", "©ÐÈÆ®¹ðèæ¾"); + return $str; } - $isEdit = stristr($PHP_SELF, "/edit/") ? true : false; - $isMed = false; /* */ ?>