1 |
<?php |
<?php |
2 |
|
function MyUpper($str) { |
3 |
|
return strtr(strtoupper($str), "¹ðèæ¾", "©ÐÈÆ®"); |
4 |
|
} |
5 |
|
|
6 |
|
function MyLower($str) { |
7 |
|
return strtr(strtolower($str), "©ÐÈÆ®", "¹ðèæ¾"); |
8 |
|
} |
9 |
|
|
10 |
|
function Letters() { return "ABCÈÆDÐEFGHIJKLMNOPQRS©TUVWXYZ®"; } |
11 |
|
|
12 |
|
function Slova($alpha_only = false) { |
13 |
|
$sl = preg_split('//', Letters()); |
14 |
|
array_pop($sl); // The final element is empty. |
15 |
|
if (!$alpha_only) array_unshift($sl, "@"); |
16 |
|
return $sl; |
17 |
|
} |
18 |
|
|
19 |
|
function MyCompare($a, $b) { |
20 |
|
$slova = Letters(); |
21 |
|
$weights = "\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32"; |
22 |
|
return strcasecmp(strtr(MyUpper($a), $slova, $weights), |
23 |
|
strtr(MyUpper($b), $slova, $weights)); |
24 |
|
} |
25 |
|
|
26 |
function MyEscape($str) { |
function MyEscape($str) { |
27 |
$allowed = array("", "B", "I", "U", "UL", "OL", "LI"); |
return $str; |
28 |
$str = preg_replace("/(\<\/?\s*(\w+)>[^\>]*\>)/e", |
$allowed = array("", "A", "B", "I", "U", "UL", "OL", "LI"); |
29 |
"array_search(strtoupper('\\2'),\$allowed,false)?'\\1':HTMLSpecialChars('\\1')", |
$str = preg_replace("/(^\\s+|\\s+$)/", "", $str); |
30 |
$str); |
$str = preg_replace("/(\\<\\/?\\s*(\\w+)\\b[^\\>]*\\>)/e", "array_search(MyUpper('\\2'),". |
31 |
$str = preg_replace("/(^\s+|\s+$)/", "", $str); |
"\$allowed,false)?'\\1':HTMLSpecialChars('\\1')", $str); |
32 |
|
$str = preg_replace("/(\\<\\s*[aA]\\b)/", '\\1 target=_blank class=more', $str); |
33 |
$str = ereg_replace("\"", """, $str); |
$str = ereg_replace("\"", """, $str); |
34 |
return $str; |
return $str; |
35 |
} |
} |
41 |
return $str; |
return $str; |
42 |
} |
} |
43 |
|
|
|
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", "®"); |
|
|
} |
|
|
|
|
44 |
function error($msg) { |
function error($msg) { |
45 |
if (is_array($msg)) $msg = implode(" ", $msg); |
if (is_array($msg)) $msg = implode(" ", $msg); |
46 |
echo "<BR>\n<FONT COLOR=\"#FF0000\">[".HTMLSpecialChars($msg)."]</FONT><BR>\n"; |
echo "<BR>\n<FONT COLOR=\"#FF0000\">[".HTMLSpecialChars($msg)."]</FONT><BR>\n"; |
55 |
"gt" => ">", "#62" => ">", # gt |
"gt" => ">", "#62" => ">", # gt |
56 |
"Scaron" => "©", "#352" => "©", |
"Scaron" => "©", "#352" => "©", |
57 |
"scaron" => "¹", "#353" => "¹", |
"scaron" => "¹", "#353" => "¹", |
58 |
"Ccaron" => "È", "#" => "È", "#268" => "È", |
"Ccaron" => "È", "#268" => "È", "#268" => "È", |
59 |
"ccaron" => "è", "#232" => "è", "#269" => "è", |
"ccaron" => "è", "#232" => "è", "#269" => "è", |
60 |
"Cgrave" => "Æ", "#" => "Æ", "#" => "Æ", |
"Cgrave" => "Æ", "#262" => "Æ", "#" => "Æ", |
61 |
"cgrave" => "æ", "#230" => "æ", "#263" => "æ", |
"cgrave" => "æ", "#230" => "æ", "#263" => "æ", |
62 |
"?" => "Ð", "#" => "Ð", "#" => "Ð", |
"???" => "Ð", "#272" => "Ð", "#" => "Ð", |
63 |
"?" => "ð", "#" => "ð", "#273" => "ð", |
"???" => "ð", "#273" => "ð", |
64 |
"Zcaron" => "®", "#" => "®", "#381" => "®", |
"Zcaron" => "®", "#381" => "®", |
65 |
"zcaron" => "¾", "#" => "¾", "#382" => "¾" |
"zcaron" => "¾", "#382" => "¾", |
66 |
); |
); |
67 |
$t = intval($str); |
$t = intval($str); |
68 |
# Skip if not a scalar |
# Skip if not a scalar |
77 |
$str = preg_replace("/\s*(\r\n?|\n\r?)\s*(\<\/[^\>]+\>)/m", '$2$1', $str); |
$str = preg_replace("/\s*(\r\n?|\n\r?)\s*(\<\/[^\>]+\>)/m", '$2$1', $str); |
78 |
# Remove "<HEAD>"/"</HEAD>", and anything in between. |
# Remove "<HEAD>"/"</HEAD>", and anything in between. |
79 |
$str = preg_replace("/\<\s*HEAD[^\>]*\>.*\<\/\s*HEAD\s*\>(\r\n?|\n\r?)*/ims", '', $str); |
$str = preg_replace("/\<\s*HEAD[^\>]*\>.*\<\/\s*HEAD\s*\>(\r\n?|\n\r?)*/ims", '', $str); |
80 |
# Remove all "<HTML>", "<HEAD>", "<BODY>", "<FONT>" and "<P>" tags |
# Remove all "<HTML>", "<HEAD>", "<BODY>", "<FONT>", "<P>" and "BR" tags, along with their pairs |
81 |
$str = preg_replace("/(\<\s*(HTML|HEAD|BODY|FONT|P)[^\>]*\>|\<\/\s*(HTML|HEAD|BODY|FONT|P)\s*\>)/im", '', $str); |
$str = preg_replace("/\<\/?\s*(HTML|HEAD|BODY|FONT|P|BR)[^\>]*\>/im", '', $str); |
82 |
# Replace "\n<LI>" or "<LI>\n" with "<LI>" |
# Replace "\n<LI>" or "<LI>\n" with "<LI>" |
83 |
$str = preg_replace("/(\s*(\r\n?|\n\r?))*(\<\/\s*LI\s*\>)(\s*(\r\n?|\n\r?))*/m", '$3', $str); |
$str = preg_replace("/(\s*(\r\n?|\n\r?))*(\<\/\s*LI\s*\>)(\s*(\r\n?|\n\r?))*/m", '$3', $str); |
84 |
# Replace "<UL>\n" or "<OL>\n" with "<UL>" or "<OL>", respectively |
# Replace "<UL>\n" or "<OL>\n" with "<UL>" or "<OL>", respectively |