Quote from: Xpresskonami on February 29, 2020, 04:29:36 AMQuote from: digger on March 15, 2018, 07:35:18 AM
vbgamer45, update characterHash array to support cyrillic, please.
// Do you know your ABCs?
$characterHash = array (
'a' => array ('a', 'A', 'à', 'À', 'á', 'Á', 'â', 'Â', 'ã', 'Ã', 'ä', 'Ä', 'å', 'Å', 'ª', 'ą', 'Ą', 'а', 'А', 'ạ', 'Ạ', 'ả', 'Ả', 'Ầ', 'ầ', 'Ấ', 'ấ', 'Ậ', 'ậ', 'Ẩ', 'ẩ', 'Ẫ', 'ẫ', 'Ă', 'ă', 'Ắ', 'ắ', 'Ẵ', 'ẵ', 'Ặ', 'ặ', 'Ằ', 'ằ', 'Ẳ', 'ẳ', 'а', 'А'),
'ae' => array ('æ', 'Æ'),
'b' => array ('b', 'B', 'б', 'Б'),
'c' => array ('c', 'C', 'ç', 'Ç', 'ć', 'Ć', 'č', 'Č', 'ц', 'Ц'),
'd' => array ('d', 'D', 'Ð', 'đ', 'Đ', 'ď', 'Ď', 'д', 'Д'),
'e' => array ('e', 'E', 'è', 'È', 'é', 'É', 'ê', 'Ê', 'ë', 'Ë', 'ę', 'Ę', 'е', 'Е', 'ё', 'Ё', 'э', 'Э', 'Ẹ', 'ẹ', 'Ẻ', 'ẻ', 'Ẽ', 'ẽ', 'Ề', 'ề', 'Ế', 'ế', 'Ệ', 'ệ', 'Ể', 'ể', 'Ễ', 'ễ', 'ε', 'Ε', 'ě', 'Ě', 'е', 'Е'),
'f' => array ('f', 'F', 'ф', 'Ф'),
'g' => array ('g', 'G', 'ğ', 'Ğ', 'г', 'Г'),
'h' => array ('h', 'H', 'х', 'Х'),
'i' => array ('i', 'I', 'ì', 'Ì', 'í', 'Í', 'î', 'Î', 'ï', 'Ï', 'ı', 'İ', 'Ị', 'ị', 'Ỉ', 'ỉ', 'Ĩ', 'ĩ', 'Ι', 'ι', 'и', 'И'),
'j' => array ('j', 'J', 'й', 'Й'),
'k' => array ('k', 'K', 'к', 'К', 'κ', 'Κ', 'к', 'К'),
'l' => array ('l', 'L', 'ł', 'Ł', 'л', 'Л'),
'm' => array ('m', 'M', 'м', 'М', 'Μ', 'м', 'М'),
'n' => array ('n', 'N', 'ñ', 'Ñ', 'ń', 'Ń', 'ň', 'Ň', 'н', 'Н'),
'o' => array ('o', 'O', 'ò', 'Ò', 'ó', 'Ó', 'ô', 'Ô', 'õ', 'Õ', 'ö', 'Ö', 'ø', 'Ø', 'º', 'о', 'О', 'Ọ', 'ọ', 'Ỏ', 'ỏ', 'Ộ', 'ộ', 'Ố', 'ố', 'Ỗ', 'ỗ', 'Ồ', 'ồ', 'Ổ', 'ổ', 'Ơ', 'ơ', 'Ờ', 'ờ', 'Ớ', 'ớ', 'Ợ', 'ợ', 'Ở', 'ở', 'Ỡ', 'ỡ', 'ο', 'Ο', 'о', 'О'),
'p' => array ('p', 'P', 'п', 'П'),
'q' => array ('q', 'Q'),
'r' => array ('r', 'R', 'ř', 'Ř', 'р', 'Р'),
's' => array ('s', 'S', 'ş', 'Ş', 'ś', 'Ś', 'š', 'Š', 'с', 'С'),
'ss' => array ('ß'),
't' => array ('t', 'T', 'т', 'Т', 'τ', 'Τ', 'ţ', 'Ţ', 'ť', 'Ť', 'т', 'Т'),
'u' => array ('u', 'U', 'ù', 'Ù', 'ú', 'Ú', 'û', 'Û', 'ü', 'Ü', 'Ụ', 'ụ', 'Ủ', 'ủ', 'Ũ', 'ũ', 'Ư', 'ư', 'Ừ', 'ừ', 'Ứ', 'ứ', 'Ự', 'ự', 'Ử', 'ử', 'Ữ', 'ữ', 'ů', 'Ů', 'у', 'У'),
'v' => array ('v', 'V', 'в', 'В'),
'w' => array ('w', 'W'),
'x' => array ('x', 'X', '×'),
'y' => array ('y', 'Y', 'ý', 'Ý', 'ÿ', 'Ỳ', 'ỳ', 'Ỵ', 'ỵ', 'Ỷ', 'ỷ', 'Ỹ', 'ỹ', 'ы', 'Ы'),
'z' => array ('z', 'Z', 'ż', 'Ż', 'ź', 'Ź', 'ž', 'Ž', 'Ζ', 'з', 'З'),
'jo' => array ('ё', 'Ё'),
'zh' => array ('ж', 'Ж'),
'ch' => array ('ч', 'Ч'),
'sh' => array ('ш', 'Ш'),
'sch' => array ('щ', 'Щ'),
'eh' => array ('э', 'Э'),
'yu' => array ('ю', 'Ю'),
'ya' => array ('я', 'Я'),
'' => array ('ъ', 'Ъ', 'ь', 'Ь', '?', '«', '»', ':', '&', '+', '@', '%', '^', '№', '#'),
'-' => array ('-', ' ', '.', ','),
'_' => array ('_'),
'!' => array ('!'),
'~' => array ('~'),
'*' => array ('*'),
"\x12" => array ("'", '"'),
'(' => array ('(', '{', '['),
')' => array (')', '}', ']'),
'$' => array ('$'),
'0' => array ('0'),
'1' => array ('1', '¹'),
'2' => array ('2', '²'),
'3' => array ('3', '³'),
'4' => array ('4'),
'5' => array ('5'),
'6' => array ('6'),
'7' => array ('7'),
'8' => array ('8'),
'9' => array ('9'),
);
Please this has stop working on my forum... The symbols () , " , ' are now showing in my pretty-url link. and i check my Subs-Prettyurl.php all this code is in the file
Quote from: digger on March 15, 2018, 07:35:18 AM
vbgamer45, update characterHash array to support cyrillic, please.
// Do you know your ABCs?
$characterHash = array (
'a' => array ('a', 'A', 'à', 'À', 'á', 'Á', 'â', 'Â', 'ã', 'Ã', 'ä', 'Ä', 'å', 'Å', 'ª', 'ą', 'Ą', 'а', 'А', 'ạ', 'Ạ', 'ả', 'Ả', 'Ầ', 'ầ', 'Ấ', 'ấ', 'Ậ', 'ậ', 'Ẩ', 'ẩ', 'Ẫ', 'ẫ', 'Ă', 'ă', 'Ắ', 'ắ', 'Ẵ', 'ẵ', 'Ặ', 'ặ', 'Ằ', 'ằ', 'Ẳ', 'ẳ', 'а', 'А'),
'ae' => array ('æ', 'Æ'),
'b' => array ('b', 'B', 'б', 'Б'),
'c' => array ('c', 'C', 'ç', 'Ç', 'ć', 'Ć', 'č', 'Č', 'ц', 'Ц'),
'd' => array ('d', 'D', 'Ð', 'đ', 'Đ', 'ď', 'Ď', 'д', 'Д'),
'e' => array ('e', 'E', 'è', 'È', 'é', 'É', 'ê', 'Ê', 'ë', 'Ë', 'ę', 'Ę', 'е', 'Е', 'ё', 'Ё', 'э', 'Э', 'Ẹ', 'ẹ', 'Ẻ', 'ẻ', 'Ẽ', 'ẽ', 'Ề', 'ề', 'Ế', 'ế', 'Ệ', 'ệ', 'Ể', 'ể', 'Ễ', 'ễ', 'ε', 'Ε', 'ě', 'Ě', 'е', 'Е'),
'f' => array ('f', 'F', 'ф', 'Ф'),
'g' => array ('g', 'G', 'ğ', 'Ğ', 'г', 'Г'),
'h' => array ('h', 'H', 'х', 'Х'),
'i' => array ('i', 'I', 'ì', 'Ì', 'í', 'Í', 'î', 'Î', 'ï', 'Ï', 'ı', 'İ', 'Ị', 'ị', 'Ỉ', 'ỉ', 'Ĩ', 'ĩ', 'Ι', 'ι', 'и', 'И'),
'j' => array ('j', 'J', 'й', 'Й'),
'k' => array ('k', 'K', 'к', 'К', 'κ', 'Κ', 'к', 'К'),
'l' => array ('l', 'L', 'ł', 'Ł', 'л', 'Л'),
'm' => array ('m', 'M', 'м', 'М', 'Μ', 'м', 'М'),
'n' => array ('n', 'N', 'ñ', 'Ñ', 'ń', 'Ń', 'ň', 'Ň', 'н', 'Н'),
'o' => array ('o', 'O', 'ò', 'Ò', 'ó', 'Ó', 'ô', 'Ô', 'õ', 'Õ', 'ö', 'Ö', 'ø', 'Ø', 'º', 'о', 'О', 'Ọ', 'ọ', 'Ỏ', 'ỏ', 'Ộ', 'ộ', 'Ố', 'ố', 'Ỗ', 'ỗ', 'Ồ', 'ồ', 'Ổ', 'ổ', 'Ơ', 'ơ', 'Ờ', 'ờ', 'Ớ', 'ớ', 'Ợ', 'ợ', 'Ở', 'ở', 'Ỡ', 'ỡ', 'ο', 'Ο', 'о', 'О'),
'p' => array ('p', 'P', 'п', 'П'),
'q' => array ('q', 'Q'),
'r' => array ('r', 'R', 'ř', 'Ř', 'р', 'Р'),
's' => array ('s', 'S', 'ş', 'Ş', 'ś', 'Ś', 'š', 'Š', 'с', 'С'),
'ss' => array ('ß'),
't' => array ('t', 'T', 'т', 'Т', 'τ', 'Τ', 'ţ', 'Ţ', 'ť', 'Ť', 'т', 'Т'),
'u' => array ('u', 'U', 'ù', 'Ù', 'ú', 'Ú', 'û', 'Û', 'ü', 'Ü', 'Ụ', 'ụ', 'Ủ', 'ủ', 'Ũ', 'ũ', 'Ư', 'ư', 'Ừ', 'ừ', 'Ứ', 'ứ', 'Ự', 'ự', 'Ử', 'ử', 'Ữ', 'ữ', 'ů', 'Ů', 'у', 'У'),
'v' => array ('v', 'V', 'в', 'В'),
'w' => array ('w', 'W'),
'x' => array ('x', 'X', '×'),
'y' => array ('y', 'Y', 'ý', 'Ý', 'ÿ', 'Ỳ', 'ỳ', 'Ỵ', 'ỵ', 'Ỷ', 'ỷ', 'Ỹ', 'ỹ', 'ы', 'Ы'),
'z' => array ('z', 'Z', 'ż', 'Ż', 'ź', 'Ź', 'ž', 'Ž', 'Ζ', 'з', 'З'),
'jo' => array ('ё', 'Ё'),
'zh' => array ('ж', 'Ж'),
'ch' => array ('ч', 'Ч'),
'sh' => array ('ш', 'Ш'),
'sch' => array ('щ', 'Щ'),
'eh' => array ('э', 'Э'),
'yu' => array ('ю', 'Ю'),
'ya' => array ('я', 'Я'),
'' => array ('ъ', 'Ъ', 'ь', 'Ь', '?', '«', '»', ':', '&', '+', '@', '%', '^', '№', '#'),
'-' => array ('-', ' ', '.', ','),
'_' => array ('_'),
'!' => array ('!'),
'~' => array ('~'),
'*' => array ('*'),
"\x12" => array ("'", '"'),
'(' => array ('(', '{', '['),
')' => array (')', '}', ']'),
'$' => array ('$'),
'0' => array ('0'),
'1' => array ('1', '¹'),
'2' => array ('2', '²'),
'3' => array ('3', '³'),
'4' => array ('4'),
'5' => array ('5'),
'6' => array ('6'),
'7' => array ('7'),
'8' => array ('8'),
'9' => array ('9'),
);
Quote from: SMFHacks.com Team on March 15, 2018, 10:31:21 AM
Update 1.1.5
+Added support for cyrillic thanks to digger
// Query the database with these topic IDs
// Fix for issue with non latin characters in topics if mysql default-character-set is not utf8
global $db_character_set;
if (!empty($db_character_set))
$smcFunc['db_query']('set_character_set', '
SET NAMES ' . $db_character_set,
array()
);
// Do you know your ABCs?
$characterHash = array (
'a' => array ('a', 'A', 'à', 'À', 'á', 'Á', 'â', 'Â', 'ã', 'Ã', 'ä', 'Ä', 'å', 'Å', 'ª', 'ą', 'Ą', 'а', 'А', 'ạ', 'Ạ', 'ả', 'Ả', 'Ầ', 'ầ', 'Ấ', 'ấ', 'Ậ', 'ậ', 'Ẩ', 'ẩ', 'Ẫ', 'ẫ', 'Ă', 'ă', 'Ắ', 'ắ', 'Ẵ', 'ẵ', 'Ặ', 'ặ', 'Ằ', 'ằ', 'Ẳ', 'ẳ', 'а', 'А'),
'ae' => array ('æ', 'Æ'),
'b' => array ('b', 'B', 'б', 'Б'),
'c' => array ('c', 'C', 'ç', 'Ç', 'ć', 'Ć', 'č', 'Č', 'ц', 'Ц'),
'd' => array ('d', 'D', 'Ð', 'đ', 'Đ', 'ď', 'Ď', 'д', 'Д'),
'e' => array ('e', 'E', 'è', 'È', 'é', 'É', 'ê', 'Ê', 'ë', 'Ë', 'ę', 'Ę', 'е', 'Е', 'ё', 'Ё', 'э', 'Э', 'Ẹ', 'ẹ', 'Ẻ', 'ẻ', 'Ẽ', 'ẽ', 'Ề', 'ề', 'Ế', 'ế', 'Ệ', 'ệ', 'Ể', 'ể', 'Ễ', 'ễ', 'ε', 'Ε', 'ě', 'Ě', 'е', 'Е'),
'f' => array ('f', 'F', 'ф', 'Ф'),
'g' => array ('g', 'G', 'ğ', 'Ğ', 'г', 'Г'),
'h' => array ('h', 'H', 'х', 'Х'),
'i' => array ('i', 'I', 'ì', 'Ì', 'í', 'Í', 'î', 'Î', 'ï', 'Ï', 'ı', 'İ', 'Ị', 'ị', 'Ỉ', 'ỉ', 'Ĩ', 'ĩ', 'Ι', 'ι', 'и', 'И'),
'j' => array ('j', 'J', 'й', 'Й'),
'k' => array ('k', 'K', 'к', 'К', 'κ', 'Κ', 'к', 'К'),
'l' => array ('l', 'L', 'ł', 'Ł', 'л', 'Л'),
'm' => array ('m', 'M', 'м', 'М', 'Μ', 'м', 'М'),
'n' => array ('n', 'N', 'ñ', 'Ñ', 'ń', 'Ń', 'ň', 'Ň', 'н', 'Н'),
'o' => array ('o', 'O', 'ò', 'Ò', 'ó', 'Ó', 'ô', 'Ô', 'õ', 'Õ', 'ö', 'Ö', 'ø', 'Ø', 'º', 'о', 'О', 'Ọ', 'ọ', 'Ỏ', 'ỏ', 'Ộ', 'ộ', 'Ố', 'ố', 'Ỗ', 'ỗ', 'Ồ', 'ồ', 'Ổ', 'ổ', 'Ơ', 'ơ', 'Ờ', 'ờ', 'Ớ', 'ớ', 'Ợ', 'ợ', 'Ở', 'ở', 'Ỡ', 'ỡ', 'ο', 'Ο', 'о', 'О'),
'p' => array ('p', 'P', 'п', 'П'),
'q' => array ('q', 'Q'),
'r' => array ('r', 'R', 'ř', 'Ř', 'р', 'Р'),
's' => array ('s', 'S', 'ş', 'Ş', 'ś', 'Ś', 'š', 'Š', 'с', 'С'),
'ss' => array ('ß'),
't' => array ('t', 'T', 'т', 'Т', 'τ', 'Τ', 'ţ', 'Ţ', 'ť', 'Ť', 'т', 'Т'),
'u' => array ('u', 'U', 'ù', 'Ù', 'ú', 'Ú', 'û', 'Û', 'ü', 'Ü', 'Ụ', 'ụ', 'Ủ', 'ủ', 'Ũ', 'ũ', 'Ư', 'ư', 'Ừ', 'ừ', 'Ứ', 'ứ', 'Ự', 'ự', 'Ử', 'ử', 'Ữ', 'ữ', 'ů', 'Ů', 'у', 'У'),
'v' => array ('v', 'V', 'в', 'В'),
'w' => array ('w', 'W'),
'x' => array ('x', 'X', '×'),
'y' => array ('y', 'Y', 'ý', 'Ý', 'ÿ', 'Ỳ', 'ỳ', 'Ỵ', 'ỵ', 'Ỷ', 'ỷ', 'Ỹ', 'ỹ', 'ы', 'Ы'),
'z' => array ('z', 'Z', 'ż', 'Ż', 'ź', 'Ź', 'ž', 'Ž', 'Ζ', 'з', 'З'),
'jo' => array ('ё', 'Ё'),
'zh' => array ('ж', 'Ж'),
'ch' => array ('ч', 'Ч'),
'sh' => array ('ш', 'Ш'),
'sch' => array ('щ', 'Щ'),
'eh' => array ('э', 'Э'),
'yu' => array ('ю', 'Ю'),
'ya' => array ('я', 'Я'),
'' => array ('ъ', 'Ъ', 'ь', 'Ь', '?', '«', '»', ':', '&', '+', '@', '%', '^', '№', '#'),
'-' => array ('-', ' ', '.', ','),
'_' => array ('_'),
'!' => array ('!'),
'~' => array ('~'),
'*' => array ('*'),
"\x12" => array ("'", '"'),
'(' => array ('(', '{', '['),
')' => array (')', '}', ']'),
'$' => array ('$'),
'0' => array ('0'),
'1' => array ('1', '¹'),
'2' => array ('2', '²'),
'3' => array ('3', '³'),
'4' => array ('4'),
'5' => array ('5'),
'6' => array ('6'),
'7' => array ('7'),
'8' => array ('8'),
'9' => array ('9'),
);
Quote from: vbgamer45 on June 29, 2017, 05:24:21 PM
Did you change your database characterset?
<?php
// Version: 1.0RC; Subs-PrettyUrls
if (!defined('SMF'))
die('Hacking attempt...');
// Generate a pretty URL from a given text
function pretty_generate_url($text)
{
global $modSettings, $txt;
// Do you know your ABCs?
$characterHash = array (
'a' => array ('a', 'A', 'à', 'À', 'á', 'Á', 'â', 'Â', 'ã', 'Ã', 'ä', 'Ä', 'å', 'Å', 'ª', 'ą', 'Ą', 'а', 'А', 'ạ', 'Ạ', 'ả', 'Ả', 'Ầ', 'ầ', 'Ấ', 'ấ', 'Ậ', 'ậ', 'Ẩ', 'ẩ', 'Ẫ', 'ẫ', 'Ă', 'ă', 'Ắ', 'ắ', 'Ẵ', 'ẵ', 'Ặ', 'ặ', 'Ằ', 'ằ', 'Ẳ', 'ẳ'),
'ae' => array ('æ', 'Æ'),
'b' => array ('b', 'B'),
'c' => array ('c', 'C', 'ç', 'Ç', 'ć', 'Ć', 'č', 'Č'),
'd' => array ('d', 'D', 'Ð', 'đ', 'Đ', 'ď', 'Ď'),
'e' => array ('e', 'E', 'è', 'È', 'é', 'É', 'ê', 'Ê', 'ë', 'Ë', 'ę', 'Ę', 'е', 'Е', 'ё', 'Ё', 'э', 'Э', 'Ẹ', 'ẹ', 'Ẻ', 'ẻ', 'Ẽ', 'ẽ', 'Ề', 'ề', 'Ế', 'ế', 'Ệ', 'ệ', 'Ể', 'ể', 'Ễ', 'ễ', 'ε', 'Ε', 'ě', 'Ě'),
'f' => array ('f', 'F'),
'g' => array ('g', 'G', 'ğ', 'Ğ'),
'h' => array ('h', 'H'),
'i' => array ('i', 'I', 'ì', 'Ì', 'í', 'Í', 'î', 'Î', 'ï', 'Ï', 'ı', 'İ', 'Ị', 'ị', 'Ỉ', 'ỉ', 'Ĩ', 'ĩ', 'Ι', 'ι'),
'j' => array ('j', 'J'),
'k' => array ('k', 'K', 'к', 'К', 'κ', 'Κ'),
'l' => array ('l', 'L', 'ł', 'Ł'),
'm' => array ('m', 'M', 'м', 'М', 'Μ'),
'n' => array ('n', 'N', 'ñ', 'Ñ', 'ń', 'Ń', 'ň', 'Ň'),
'o' => array ('o', 'O', 'ò', 'Ò', 'ó', 'Ó', 'ô', 'Ô', 'õ', 'Õ', 'ö', 'Ö', 'ø', 'Ø', 'º', 'о', 'О', 'Ọ', 'ọ', 'Ỏ', 'ỏ', 'Ộ', 'ộ', 'Ố', 'ố', 'Ỗ', 'ỗ', 'Ồ', 'ồ', 'Ổ', 'ổ', 'Ơ', 'ơ', 'Ờ', 'ờ', 'Ớ', 'ớ', 'Ợ', 'ợ', 'Ở', 'ở', 'Ỡ', 'ỡ', 'ο', 'Ο'),
'p' => array ('p', 'P'),
'q' => array ('q', 'Q'),
'r' => array ('r', 'R', 'ř', 'Ř'),
's' => array ('s', 'S', 'ş', 'Ş', 'ś', 'Ś', 'š', 'Š'),
'ss' => array ('ß'),
't' => array ('t', 'T', 'т', 'Т', 'τ', 'Τ', 'ţ', 'Ţ', 'ť', 'Ť'),
'u' => array ('u', 'U', 'ù', 'Ù', 'ú', 'Ú', 'û', 'Û', 'ü', 'Ü', 'Ụ', 'ụ', 'Ủ', 'ủ', 'Ũ', 'ũ', 'Ư', 'ư', 'Ừ', 'ừ', 'Ứ', 'ứ', 'Ự', 'ự', 'Ử', 'ử', 'Ữ', 'ữ', 'ů', 'Ů'),
'v' => array ('v', 'V'),
'w' => array ('w', 'W'),
'x' => array ('x', 'X', '×'),
'y' => array ('y', 'Y', 'ý', 'Ý', 'ÿ', 'Ỳ', 'ỳ', 'Ỵ', 'ỵ', 'Ỷ', 'ỷ', 'Ỹ', 'ỹ'),
'z' => array ('z', 'Z', 'ż', 'Ż', 'ź', 'Ź', 'ž', 'Ž', 'Ζ'),
'-' => array ('-', ' ', '.', ','),
'_' => array ('_'),
'!' => array ('!'),
'~' => array ('~'),
'*' => array ('*'),
"\x12" => array ("'", '"'),
'(' => array ('(', '{', '['),
')' => array (')', '}', ']'),
'$' => array ('$'),
'0' => array ('0'),
'1' => array ('1', '¹'),
'2' => array ('2', '²'),
'3' => array ('3', '³'),
'4' => array ('4'),
'5' => array ('5'),
'6' => array ('6'),
'7' => array ('7'),
'8' => array ('8'),
'9' => array ('9'),
);
// Pretty URLs RUS
$characterHash = array(
'' => array ('ъ', 'Ъ', 'ь', 'Ь', '!', '?', '«', '»', ':', '&', '+', '*', '~', '@', '%', '^'),
'-' => array('-', '№', '#', '$', '_', ' ', '.', ','),
'(' => array ('(', '{', '['),
')' => array (')', '}', ']'),
"\x12" => array ("'", '"'),
'0' => array ('0'),
'1' => array ('1', '¹'),
'2' => array ('2', '²'),
'3' => array ('3', '³'),
'4' => array ('4'),
'5' => array ('5'),
'6' => array ('6'),
'7' => array ('7'),
'8' => array ('8'),
'9' => array ('9'),
'a' => array ('a', 'A', 'а', 'А'),
'b' => array ('b', 'B', 'б', 'Б'),
'c' => array ('c', 'C', 'ц', 'Ц'),
'd' => array ('d', 'D', 'д', 'Д'),
'e' => array ('e', 'E', 'е', 'Е'),
'f' => array ('f', 'F', 'ф', 'Ф'),
'g' => array ('g', 'G', 'г', 'Г'),
'h' => array ('h', 'H', 'х', 'Х'),
'i' => array ('i', 'I', 'и', 'И'),
'j' => array ('j', 'J', 'й', 'Й'),
'k' => array ('k', 'K', 'к', 'К'),
'l' => array ('l', 'L', 'л', 'Л'),
'm' => array ('m', 'M', 'м', 'М'),
'n' => array ('n', 'N', 'н', 'Н'),
'o' => array ('o', 'O', 'о', 'О'),
'p' => array ('p', 'P', 'п', 'П'),
'q' => array ('q', 'Q'),
'r' => array ('r', 'R', 'р', 'Р'),
's' => array ('s', 'S', 'с', 'С'),
't' => array ('t', 'T', 'т', 'Т'),
'u' => array ('u', 'U', 'у', 'У'),
'v' => array ('v', 'V', 'в', 'В'),
'w' => array ('w', 'W'),
'x' => array ('x', 'X'),
'y' => array ('y', 'Y', 'ы', 'Ы'),
'z' => array ('z', 'Z', 'з', 'З'),
'jo' => array ('ё', 'Ё'),
'zh' => array ('ж', 'Ж'),
'ch' => array ('ч', 'Ч'),
'sh' => array ('ш', 'Ш'),
'sch' => array ('щ', 'Щ'),
'je' => array ('э', 'Э'),
'ju' => array ('ю', 'Ю'),
'ja' => array ('я', 'Я')
);
// Get or detect the database encoding, firstly from the settings or language files
if (isset($modSettings['global_character_set']))
$encoding = strtoupper($modSettings['global_character_set']);
else if (isset($txt['lang_character_set']))
$encoding = strtoupper($txt['lang_character_set']);
// or try checking UTF-8 conformance
else if (preg_match('~.~su', $text))
$encoding = 'UTF-8';
// or sadly... we may have to assume Latin-1
else
$encoding = 'ISO-8859-1';
// If the database encoding isn't UTF-8 and multibyte string functions are available, try converting the text to UTF-8
if ($encoding != 'UTF-8' && function_exists('mb_convert_encoding'))
$text = mb_convert_encoding($text, 'UTF-8', $encoding);
// Or maybe we can convert with iconv
else if ($encoding != 'UTF-8' && function_exists('iconv'))
$text = iconv($encoding, 'UTF-8', $text);
// Fix Turkish
else if ($encoding == 'ISO-8859-9')
{
$text = str_replace(array("\xD0", "\xDD", "\xDE", "\xF0", "\xFD", "\xFE"), array('g', 'i', 's', 'g', 'i', 's'), $text);
$text = utf8_encode($text);
}
// Latin-1 can be converted easily
else if ($encoding == 'ISO-8859-1')
$text = utf8_encode($text);
// Change the entities back to normal characters
$text = str_replace(array('&', '"'), array('&', '"'), $text);
$prettytext = '';
// Split up $text into UTF-8 letters
preg_match_all("~.~su", $text, $characters);
foreach ($characters[0] as $aLetter)
{
foreach ($characterHash as $replace => $search)
{
// Found a character? Replace it!
if (in_array($aLetter, $search))
{
$prettytext .= $replace;
break;
}
}
}
// Remove unwanted '-'s
$prettytext = preg_replace(array('~^-+|-+$~', '~-+~'), array('', '-'), $prettytext);
return $prettytext;
}
// URL maintenance
function pretty_run_maintenance($installing = false)
{
global $boarddir, $context, $modSettings, $smcFunc;
$context['pretty']['maintenance_tasks'] = array();
// Get the array of actions
$indexphp = file_get_contents($boarddir . '/index.php');
preg_match('~actionArray\\s*=\\s*array[^;]+~', $indexphp, $actionArrayText);
preg_match_all('~\'([^\']+)\'\\s*=>~', $actionArrayText[0], $actionArray, PREG_PATTERN_ORDER);
$context['pretty']['action_array'] = $actionArray[1];
if (function_exists('call_integration_hook'))
{
$dummy = array();
call_integration_hook('integrate_actions', array(&$dummy));
$context['pretty']['action_array'] += array_keys($dummy);
}
// Pretty URLs RUS
global $txt;
$context['pretty']['maintenance_tasks'][] = $txt['pretty_task_actons'];
// Update the list of boards
// Get the current pretty board urls, or make new arrays if there are none
$pretty_board_urls = isset($modSettings['pretty_board_urls']) ? unserialize($modSettings['pretty_board_urls']) : array();
$pretty_board_lookup_old = isset($modSettings['pretty_board_lookup']) ? unserialize($modSettings['pretty_board_lookup']) : array();
// Fix old boards by replacing ' with \x12
$pretty_board_urls = str_replace("'", "\x12", $pretty_board_urls);
$pretty_board_lookup = array();
foreach ($pretty_board_lookup_old as $board => $id)
$pretty_board_lookup[str_replace("'", "\x12", $board)] = $id;
// Fix old topics too
$smcFunc['db_query']('', '
UPDATE {db_prefix}pretty_topic_urls
SET pretty_url = REPLACE(pretty_url, {string:old_quote}, {string:new_quote})',
array(
'old_quote' => "'",
'new_quote' => "\x12",
'db_error_skip' => true,
));
// Pretty URLs RUS
$context['pretty']['maintenance_tasks'][] = $txt['pretty_task_old'];
// Get the board names
$query = $smcFunc['db_query']('', "
SELECT id_board, name
FROM {db_prefix}boards");
// Process each board
while ($row = $smcFunc['db_fetch_assoc']($query))
{
// Don't replace the board urls if they already exist
if (!isset($pretty_board_urls[$row['id_board']]) || $pretty_board_urls[$row['id_board']] == '' || in_array($row['id_board'], $pretty_board_lookup) === false)
{
$pretty_text = pretty_generate_url($row['name']);
// We need to have something to refer to this board by...
if ($pretty_text == '')
// ... so use 'bID_BOARD'
$pretty_text = 'b' . $row['id_board'];
// Numerical or duplicate URLs aren't allowed!
if (is_numeric($pretty_text) || isset($pretty_board_lookup[$pretty_text]) || in_array($pretty_text, $context['pretty']['action_array']))
// Add suffix '-ID_BOARD' to the pretty url
$pretty_text .= ($pretty_text != '' ? '-' : 'b') . $row['id_board'];
// Update the arrays
$pretty_board_urls[$row['id_board']] = $pretty_text;
$pretty_board_lookup[$pretty_text] = $row['id_board'];
}
// Current board URL is the same as an action
elseif (in_array($pretty_board_urls[$row['id_board']], $context['pretty']['action_array']))
{
$pretty_text = $pretty_board_urls[$row['id_board']] . '-' . $row['id_board'];
$pretty_board_urls[$row['id_board']] = $pretty_text;
$pretty_board_lookup[$pretty_text] = $row['id_board'];
}
}
$smcFunc['db_free_result']($query);
// Pretty URLs RUS
$context['pretty']['maintenance_tasks'][] = $txt['pretty_task_urls'];
// Update the database
updateSettings(array(
'pretty_action_array' => serialize($context['pretty']['action_array']),
'pretty_board_lookup' => serialize($pretty_board_lookup),
'pretty_board_urls' => serialize($pretty_board_urls),
));
// Update the filter callbacks
pretty_update_filters($installing);
// Pretty URLs RUS
$context['pretty']['maintenance_tasks'][] = $txt['pretty_task_filters'];
}
// Update the database based on the installed filters and build the .htaccess file
function pretty_update_filters($installing = false)
{
global $boarddir, $boardurl, $context, $modSettings, $smcFunc;
// Get the settings
$prettyFilters = unserialize($modSettings['pretty_filters']);
$filterSettings = array();
$rewrites = array();
foreach ($prettyFilters as $id => $filter)
// Get the important data from enabled filters
if ($filter['enabled'])
{
if (isset($filter['filter']))
$filterSettings[$filter['filter']['priority']] = $filter['filter']['callback'];
if (isset($filter['rewrite']))
$rewrites[$filter['rewrite']['priority']] = array(
'id' => $id,
'rule' => $filter['rewrite']['rule'],
);
}
// Build the new .htaccess file
$htaccess = '# PRETTYURLS MOD BEGINS
# Pretty URLs mod
# http://code.google.com/p/prettyurls/
# .htaccess file generated automatically on: ' . date('F j, Y, G:i') . '
RewriteEngine on';
// Check if we'll need a RewriteBase rule
// Thanks heaps to Silverstripe!
// http://open.silverstripe.com/ticket/2903
$base = dirname($_SERVER['SCRIPT_NAME']);
if (defined('DIRECTORY_SEPARATOR'))
$base = str_replace(DIRECTORY_SEPARATOR, '/', $base);
else
$base = str_replace("\\", '/', $base);
if ($base != '.')
$htaccess .= "\nRewriteBase " . $base;
// Output the rules
ksort($rewrites);
foreach ($rewrites as $rule)
{
$htaccess .= "\n\n# Rules for: " . $rule['id'] . "\n";
if (is_array($rule['rule']))
$htaccess .= implode("\n", $rule['rule']);
else
$htaccess .= $rule['rule'];
}
$htaccess .= "\n\n# PRETTYURLS MOD ENDS";
// Fix the Root URL
if (preg_match('`' . $boardurl . '/(.*)`', $modSettings['pretty_root_url'], $match))
$htaccess = str_replace('ROOTURL', $match[1] . '/', $htaccess);
else
$htaccess = str_replace('ROOTURL', '', $htaccess);
// Actions
if (strpos($htaccess, '#ACTIONS') !== false)
{
// Put them in groups of 8
$action_array = str_replace('.', '\\.', $context['pretty']['action_array']);
$groups = array_chunk($action_array, 8);
// Construct the rewrite rules
$lines = array();
foreach ($groups as $group)
$lines[] = 'RewriteRule ^('. implode('|', $group) .')/?$ ./index.php?pretty;action=$1 [L,QSA]';
$actions_rewrite = implode("\n", $lines);
$htaccess = str_replace('#ACTIONS', $actions_rewrite, $htaccess);
}
// Check if there is already a .htaccess file
if (file_exists($boarddir . '/.htaccess'))
{
// If we can't write to it, disable the filters!
if (!is_writable($boarddir . '/.htaccess'))
{
unset($context['template_layers']['pretty_chrome']);
updateSettings(array('pretty_enable_filters' => '0'));
if ($installing)
return;
else
fatal_lang_error('pretty_cant_write_htaccess', false);
}
// Backup the old .htaccess file
@copy($boarddir . '/.htaccess', $boarddir . '/.htaccess.backup');
// Replace the old with the new, if we can
$oldHtaccess = file_get_contents($boarddir . '/.htaccess');
$pattern = '~# PRETTYURLS MOD BEGINS.+# PRETTYURLS MOD ENDS~s';
if (preg_match($pattern, $oldHtaccess, $match))
$htaccess = str_replace($match[0], $htaccess, $oldHtaccess);
}
// Output the new .htaccess file
$handle = fopen($boarddir . '/.htaccess', 'w');
fwrite($handle, $htaccess);
fclose($handle);
// Update the settings table
ksort($filterSettings);
updateSettings(array('pretty_filter_callbacks' => serialize($filterSettings)));
// Clear the URLs cache
$smcFunc['db_query']('truncate_table', "
TRUNCATE {db_prefix}pretty_urls_cache");
// Don't rewrite anything for this page
$modSettings['pretty_enable_filters'] = false;
}
// Format a JSON string
// From http://au2.php.net/manual/en/function.json-encode.php#80339
function pretty_json($json)
{
$tab = " ";
$new_json = "";
$indent_level = 0;
$in_string = false;
$len = strlen($json);
for($c = 0; $c < $len; $c++)
{
$char = $json[$c];
if ($char == '"')
{
if($c > 0 && $json[$c - 1] != '\\')
$in_string = !$in_string;
$new_json .= $char;
}
else if ($in_string)
$new_json .= $char;
else if ($char == '{' || $char == '[')
{
$indent_level++;
$new_json .= $char . "\n" . str_repeat($tab, $indent_level);
}
else if ($char == '}' || $char == ']')
{
$indent_level--;
$new_json .= "\n" . str_repeat($tab, $indent_level) . $char;
}
else if ($char == ',')
$new_json .= ",\n" . str_repeat($tab, $indent_level);
else if ($char == ':')
$new_json .= ": ";
else
$new_json .= $char;
}
return $new_json;
}
?>
Quote from: waruna on July 23, 2010, 10:28:32 AMQuote from: Tair on July 23, 2010, 06:33:23 AM
I'm using it on rc3
Possible yes, but modern search engines are ok with common, not sef, urls
Thanks Tair. You mean this mod might not increase the search results?
Does anybody tried this mod on RC2? Because I have no idea how to upgrade the version even I follow the instruction given.
Quote from: AbuFahim⎝⏠⏝⏠⎠ on July 23, 2010, 11:08:57 AMQuote from: waruna on July 23, 2010, 10:28:32 AMOn the contrary, I think it might. I think the search engine will also search for urls and not only body. So it does increase a bit. That is why urls are also part of SEO.
Thanks Tair. You mean this mod might not increase the search results?
Quote from: Boby_ on January 13, 2010, 01:10:57 PMQuote from: Dannii on January 12, 2010, 09:12:09 PM
Boby_, you can add extra characters to your Subs-PrettyUrls.php if you want.
Thanks! I'll give it a try.
Quote from: Dannii on September 23, 2009, 11:58:45 PM
zaks_bg, sorry but I won't be able to do anything for non latin characters for a long time.
<?php
/*
Plugin Name: Cyr-Cho
Version: 0.1
Plugin URI: http://kaloyan.info/blog/wp-cyr-cho
Description: Converts slugs with Cyrillic characters into Latin ones
Author: Kaloyan K. Tsvetkov
Author URI: http://kaloyan.info/
*/
/////////////////////////////////////////////////////////////////////////////
/**
* @internal prevent from direct calls
*/
if (!defined('ABSPATH')) {
return ;
}
/**
* The directory path to the plugin
*/
define('WP_CYRCHO_DIR', dirname( __FILE__ ));
/**
* @internal prevent from second inclusion
*/
if (!isset($wp_cyrcho)) {
/**
* Initiating the plugin...
* @see wp_cyrcho
*/
$wp_cyrcho = new wp_cyrcho;
}
/////////////////////////////////////////////////////////////////////////////
/**
* Cyr-Cho (Cyrillic Slugs)
*
* Original idea by Loshia: http://loshia.com/2007/05/17/cyrillic-slugs
*
* @author Kaloyan K. Tsvetkov <[email protected]>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
Class wp_cyrcho {
/**
* Transliteration map
* @var array
*/
var $transliteration = array(
192 => 'a',
193 => 'b',
194 => 'v',
195 => 'g',
196 => 'd',
197 => 'e',
198 => 'zh',
199 => 'z',
200 => 'i',
201 => 'y',
202 => 'k',
203 => 'l',
204 => 'm',
205 => 'n',
206 => 'o',
207 => 'p',
208 => 'r',
209 => 's',
210 => 't',
211 => 'u',
212 => 'f',
213 => 'h',
214 => 'ts',
215 => 'tch',
216 => 'sh',
217 => 'sht',
218 => 'a',
220 => 'y',
222 => 'yu',
223 => 'ya',
224 => 'a',
225 => 'b',
226 => 'v',
227 => 'g',
228 => 'd',
229 => 'e',
230 => 'zh',
231 => 'z',
232 => 'i',
233 => 'y',
234 => 'k',
235 => 'l',
236 => 'm',
237 => 'n',
238 => 'o',
239 => 'p',
240 => 'r',
241 => 's',
242 => 't',
243 => 'u',
244 => 'f',
245 => 'h',
246 => 'ts',
247 => 'tch',
248 => 'sh',
249 => 'sht',
250 => 'a',
252 => 'y',
254 => 'yu',
255 => 'ya'
);
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
/**
* Constructor
*
* Places the plugin hooks, and initiates the admin if necessary
*/
Function wp_cyrcho() {
// attach the hooks
//
add_filter('sanitize_title', array($this, 'convert'), 0);
// start the admin pages ...
//
if (is_admin()) {
require_once(
WP_CYRCHO_DIR . '/wp-admin/wp-admin.php'
);
new wp_cyrcho_admin(1);
}
}
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
/**
* Converts the Cyrillic chars to their latin equivalent.
*
* @param string $value
* @return string
*/
Function convert($value) {
$string = $this->utf2win1251($value);
$result = '';
for($i = 0; $i < strlen($string); $i++) {
if (ord($string[$i]) > 128) {
$result .= $this->transliteration[ord($string[$i])];
} else {
$result .= $string[$i];
}
}
return $result;
}
/**
* Converts a UTF-encoded string into a Win1251-encoded one
*
* @param string $string
* @return string
*/
Function utf2win1251($string) {
$out = '';
for ($i=0; $i<strlen($string); $i++) {
$c1 = substr ($string, $i, 1);
$byte1 = ord ($c1);
if ($byte1>>5 == 6) { /* 110x xxxx, 110 prefix for 2 bytes unicode */
$i++;
$c2 = substr ($string, $i, 1);
$byte2 = ord ($c2);
$byte1 &= 31; /* remove the 3 bit two bytes prefix */
$byte2 &= 63; /* remove the 2 bit trailing byte prefix */
$byte2 |= (($byte1 & 3) << 6); /* last 2 bits of c1 become first 2 of c2 */
$byte1 >>= 2; /* c1 shifts 2 to the right */
$word = ($byte1<<8) + $byte2;
if ($word==1025) $out .= chr(168); // ?
elseif ($word==1105) $out .= chr(184); // ?
elseif ($word>=0x0410 && $word<=0x044F) $out .= chr($word-848); // ?-? ?-?
else {
$a = dechex($byte1);
$a = str_pad($a, 2, '0', STR_PAD_LEFT);
$b = dechex($byte2);
$b = str_pad($b, 2, '0', STR_PAD_LEFT);
$out .= "&#x".$a.$b.";";
}
} else {
$out .= $c1;
}
}
return $out;
}
//--end-of-class--
}
Quote from: Dannii on March 23, 2009, 08:49:09 AMQuote from: ivo2296 on March 22, 2009, 05:20:48 PMI used to have Cyrillic conversion, look back through old versions of Subs-PrettyUrls.php
Hi Dannii,
What do you think about this?:When you want to perform a case-insensitive replace,
you use the following code to do it:
<?php
preg_replace("/word/i","<b>word</b>",$string);
?>
However, there is a problem if you use cyrillic characters
and your host server is Linux - no matter that you use
the "i" parameter after the filter. This is really bad for
Russians and Bulgarians, but there is a solution:
<?php
// Firstly, we need to define some functions which will convert
// our cyrillic string to uppercase or lowercase - strtolower()
// and strtoupper() do not work if your string contains cyrillic
// characters and your server is Linux.
function cstrtolower($str) {
return strtr($str, "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЬЮЯ", "абвгдежзийклмнопрстуфхцчшщъьюя");
}
function cstrtoupper($str) {
return strtr($str, "абвгдежзийклмнопрстуфхцчшщъьюя", "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЬЮЯ");
}
// Now we have to define a function which will break apart
// the word for which we are searching in the string in
// groups - lowercase and uppercase in a group, for example
// if we are searching for "word", our filter must looks like
// this: "/[Ww][Oo][Rr][Dd]/"
function createFilter ($string) {
$string = cstrtolower($string);
for ($i=0;$i<strlen($string);$i++) {
$letter_small = substr($string,$i,1);
$letter_big = cstrtoupper($letter_small);
$newstr .= '['.$letter_small.$letter_big.']';
}
return $newstr;
}
// This is cyrillic text. And we are ready to perform the match:
$string = "Това е ТексТ на кирилица";
$word = "текст";
$newstring = preg_replace("/".createFilter($word)."/",
"<b>\\0</b>",$string));
echo $newstring;
?>
It is a row example about converting the Cyrillic characters to the Latin ones.
I haven't installed your mod yet cause my forum is based on windows-1251.
Quote from: ivo2296 on March 22, 2009, 05:20:48 PMI used to have Cyrillic conversion, look back through old versions of Subs-PrettyUrls.php
Hi Dannii,
What do you think about this?:When you want to perform a case-insensitive replace,
you use the following code to do it:
<?php
preg_replace("/word/i","<b>word</b>",$string);
?>
However, there is a problem if you use cyrillic characters
and your host server is Linux - no matter that you use
the "i" parameter after the filter. This is really bad for
Russians and Bulgarians, but there is a solution:
<?php
// Firstly, we need to define some functions which will convert
// our cyrillic string to uppercase or lowercase - strtolower()
// and strtoupper() do not work if your string contains cyrillic
// characters and your server is Linux.
function cstrtolower($str) {
return strtr($str, "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЬЮЯ", "абвгдежзийклмнопрстуфхцчшщъьюя");
}
function cstrtoupper($str) {
return strtr($str, "абвгдежзийклмнопрстуфхцчшщъьюя", "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЬЮЯ");
}
// Now we have to define a function which will break apart
// the word for which we are searching in the string in
// groups - lowercase and uppercase in a group, for example
// if we are searching for "word", our filter must looks like
// this: "/[Ww][Oo][Rr][Dd]/"
function createFilter ($string) {
$string = cstrtolower($string);
for ($i=0;$i<strlen($string);$i++) {
$letter_small = substr($string,$i,1);
$letter_big = cstrtoupper($letter_small);
$newstr .= '['.$letter_small.$letter_big.']';
}
return $newstr;
}
// This is cyrillic text. And we are ready to perform the match:
$string = "Това е ТексТ на кирилица";
$word = "текст";
$newstring = preg_replace("/".createFilter($word)."/",
"<b>\\0</b>",$string));
echo $newstring;
?>
It is a row example about converting the Cyrillic characters to the Latin ones.
I haven't installed your mod yet cause my forum is based on windows-1251.
Quote from: MRDJ on March 22, 2009, 11:57:53 PMI think the shoutbox mod needs to use full non-relative URLs... ask the author about it.
hey danni from the time i have installed pretty urls the shout box(i am using neenones Advanced AJAX Shoutbox 1.22 ) is geeting closed after like 10-15 sec of the full page being load
take a look at this screeny you'll get what i mean.
http://img22.imageshack.us/img22/3582/dfsadasda.jpg
but i refresh or type the command /return normal sb comes back but it returns to position shown in the above pichelppp