| A Complete Solution to Turkish Char Problem in Pligg
Hi all,
I want to explain how I overcame with Turkish char problem in Pligg 9.9.0.
I warn you these changes may not be optimum way of solving Turkish char problems and I don't guarantee that these changes definitely solve your problems and don't accept any responsibility. At least these solved my problems and I hope these solve your problems too. I advice you to backup your current files before changing them.
Firstly, I had special char problems in sef urls. I changed these special chars with the safe one.
For example: http://mysite.com/Türkçe_Karakter_Problemi
is changed with http://mysite.com/turkce-karakter-problemi
1)change libs/utils.php's encoding to UTF-8
2)in libs/utils.php line 249 find and replace PHP Code: function makeUrlFriendly($input) { global $db;
//$input = remove_error_creating_chars($input); $output = utf8_substr($input, 0, 240); $output = trim($output); $output = html_entity_decode(htmlentities($output, ENT_COMPAT, 'UTF-8'));
$output = preg_replace("/\s/e" , "_" , $output); // Replace spaces with underscores $output = str_replace("--", "-", $output); $output = str_replace("/", "", $output); $output = str_replace("\\", "", $output); $output = str_replace("'", "", $output); $output = str_replace(",", "", $output); $output = str_replace(";", "", $output); $output = str_replace(":", "", $output); $output = str_replace(".", "-", $output); $output = str_replace("?", "", $output); $output = str_replace("=", "-", $output); $output = str_replace("+", "", $output); $output = str_replace("$", "", $output); $output = str_replace("&", "", $output); $output = str_replace("!", "", $output); $output = str_replace(">>", "-", $output); $output = str_replace(">", "-", $output); $output = str_replace("<<", "-", $output); $output = str_replace("<", "-", $output); $output = str_replace("*", "", $output); $output = str_replace(")", "", $output); $output = str_replace("(", "", $output); $output = str_replace("[", "", $output); $output = str_replace("]", "", $output); $output = str_replace("^", "", $output); $output = str_replace("%", "", $output); $output = str_replace("»", "-", $output); $output = str_replace("|", "", $output); $output = str_replace("#", "", $output); $output = str_replace("@", "", $output); $output = str_replace("`", "", $output); $output = str_replace("”", "", $output); $output = str_replace("“", "", $output); $output = str_replace("\"", "", $output);
if(function_exists('utils_makeUrlFriendly')) { $output = utils_makeUrlFriendly($output); } // check to see if the story title already exists. If so, add an integer to the end of the title $n = $db->get_var("SELECT count(*) FROM " . table_links . " WHERE link_title_url like '$output%'"); if ($n > 0) { return $output . "-$n";} else { return $output; } }
change with: PHP Code: function makeUrlFriendly($input) { global $db;
//$input = remove_error_creating_chars($input); $input = utf8_strtolower($input, 0, 240); $output = trim($input); //$output = html_entity_decode(htmlentities($output, ENT_COMPAT, 'UTF-8'));
$output = preg_replace("/\s/e" , "_" , $output); // Replace spaces with underscores $output = str_replace("--", "-", $output); $output = str_replace("/", "", $output); $output = str_replace("\\", "", $output); $output = str_replace("'", "", $output); $output = str_replace(",", "", $output); $output = str_replace(";", "", $output); $output = str_replace(":", "", $output); $output = str_replace(".", "-", $output); $output = str_replace("?", "", $output); $output = str_replace("=", "-", $output); $output = str_replace("+", "", $output); $output = str_replace("$", "", $output); $output = str_replace("&", "", $output); $output = str_replace("!", "", $output); $output = str_replace(">>", "-", $output); $output = str_replace(">", "-", $output); $output = str_replace("<<", "-", $output); $output = str_replace("<", "-", $output); $output = str_replace("*", "", $output); $output = str_replace(")", "", $output); $output = str_replace("(", "", $output); $output = str_replace("[", "", $output); $output = str_replace("]", "", $output); $output = str_replace("^", "", $output); $output = str_replace("%", "", $output); $output = str_replace("»", "-", $output); $output = str_replace("|", "", $output); $output = str_replace("#", "", $output); $output = str_replace("@", "", $output); $output = str_replace("`", "", $output); $output = str_replace("”", "", $output); $output = str_replace("“", "", $output); $output = str_replace(" - ", "-", $output); $output = str_replace("_", "-", $output); $output = str_replace("---", "-", $output); $output = str_replace("\"", "", $output); $output = str_replace("--", "-", $output); $output = str_replace("ç", "c", $output); $output = str_replace("ğ", "g", $output); $output = str_replace("ı", "i", $output); $output = str_replace("ö", "o", $output); $output = str_replace("ş", "s", $output); $output = str_replace("ü", "u", $output); $output = str_replace("Ç", "c", $output); $output = str_replace("Ğ", "g", $output); $output = str_replace("İ", "i", $output); $output = str_replace("Ö", "o", $output); $output = str_replace("Ş", "s", $output); $output = str_replace("Ü", "u", $output); $output = str_replace("ç", "c", $output); $output = str_replace("ğ", "g", $output); $output = str_replace("ı", "i", $output); $output = str_replace("ö", "o", $output); $output = str_replace("ş", "s", $output); $output = str_replace("ü", "u", $output); $output = str_replace("Ç", "c", $output); $output = str_replace("Ğ", "g", $output); $output = str_replace("İ", "i", $output); $output = str_replace("Ö", "o", $output); $output = str_replace("Ş", "s", $output); $output = str_replace("Ü", "u", $output); if(function_exists('utils_makeUrlFriendly')) { $output = utils_makeUrlFriendly($output); } // check to see if the story title already exists. If so, add an integer to the end of the title $n = $db->get_var("SELECT count(*) FROM " . table_links . " WHERE link_title_url like '$output%'"); if ($n > 0) { return $output . "-$n";} else { return $output; } }
3)in libs/utils.php line 335 find and replace: PHP Code: function makeCategoryFriendly($input) {
$input = utf8_substr($input, 0, 240);
$output = trim($input);
$output = preg_replace("/\s/e", "", $output); // remove spaces $output = str_replace("_", "", $output); $output = str_replace("--", "", $output); $output = str_replace("'", "", $output); $output = str_replace('"', '', $output); $output = str_replace('&', '_', $output); $output = str_replace('/', '_', $output); $output = str_replace('!', '', $output); $output = str_replace('?', '', $output); $output = str_replace('$', '', $output); if(function_exists('utils_makeUrlFriendly')) { $output = utils_makeUrlFriendly($output); } return urlencode($output); }
with: PHP Code: function makeCategoryFriendly($input) {
$input = utf8_strtolower($input, 0, 240);
$output = trim($input);
$output = preg_replace("/\s/e", "", $output); // remove spaces $output = str_replace("_", "", $output); $output = str_replace("--", "", $output); $output = str_replace("'", "", $output); $output = str_replace('"', '', $output); $output = str_replace('&', '_', $output); $output = str_replace('/', '_', $output); $output = str_replace('!', '', $output); $output = str_replace('?', '', $output); $output = str_replace('$', '', $output); $output = str_replace("ç", "c", $output); $output = str_replace("ğ", "g", $output); $output = str_replace("ı", "i", $output); $output = str_replace("ö", "o", $output); $output = str_replace("ş", "s", $output); $output = str_replace("ü", "u", $output); $output = str_replace("Ç", "c", $output); $output = str_replace("Ğ", "g", $output); $output = str_replace("İ", "i", $output); $output = str_replace("Ö", "o", $output); $output = str_replace("Ş", "s", $output); $output = str_replace("Ü", "u", $output); $output = str_replace("ç", "c", $output); $output = str_replace("ğ", "g", $output); $output = str_replace("ı", "i", $output); $output = str_replace("ö", "o", $output); $output = str_replace("ş", "s", $output); $output = str_replace("ü", "u", $output); $output = str_replace("Ç", "c", $output); $output = str_replace("Ğ", "g", $output); $output = str_replace("İ", "i", $output); $output = str_replace("Ö", "o", $output); $output = str_replace("Ş", "s", $output); $output = str_replace("Ü", "u", $output); if(function_exists('utils_makeUrlFriendly')) { $output = utils_makeUrlFriendly($output); } return $output; }
These changes should change urls that have turkish chars with the safe one. I did these changes about 4 months ago, so I may not remember all things I did. Your feedbacks would help me to complete changes if there are any incompletion.
Last edited by ozlegolas; 09-12-2008 at 08:52 AM..
|