i am using MyBB SEO 1.1 Beta 1
problem in this line
// remote custom tags
$custom_mycode = $cache->read("mycode");
if (is_array($custom_mycode)) {
foreach ($custom_mycode as $key => $mycode)
{
$message = preg_replace("#".$mycode['regex']."#si", '', $message);
}
}
// remove smilies
$smilies = $cache->read("smilies");
if (is_array($smilies)) {
foreach($smilies as $sid => $smilie)
{
$message = str_replace($smilie['find'], '', $message);
}
}
// remove more un-needed data here
// -- we can decode html entities if we have PHP 5
if (version_compare(PHP_VERSION, '5.1.0', '>=')) {
$message = html_entity_decode($message, ENT_QUOTES, 'UTF-8');
} else {
$message = preg_replace("/&([a-z]+);/", "", $message);
}
$message = str_replace("\r", "", $message);
$message = str_replace("\n", " ", $message);
$message = str_replace(array('"', "[", "]", "<", ">", "\\", "/", "=", "+"), "", $message);
$message = preg_replace("#\s{2,}#", " ", $message);
// there has to be a limit to the description
if (($msg_len = strlen($message)) > MAX_DESCRIPTION_LEN) {
// try stripping on a space somewhere near the limit
$substr_begin = substr($message, 0, MAX_DESCRIPTION_LEN+5);
$substr = substr($message, 0, strrpos($substr_begin, ' '));
// caused a change more than 20%, that isn't acceptable!
if (((MAX_DESCRIPTION_LEN+5) - strlen($substr)) > (0.20*MAX_DESCRIPTION_LEN)) {
$message = substr($message, 0, MAX_DESCRIPTION_LEN) . "...";
} else {
$message = $substr . "...";
}
}
return $message;
}
/**
* Clean the title strings to be used as file names in
* links, where required.
*
* @access private
*/
function seo_clean_title($title, $title_type = 't')
{
global $lang;
// maybe we don't need keywords at all!
if (NO_KEYWORDS == 1) {
switch ($title_type) {
case 't':
$title = 'thread';
break;
case 'f':
$title = 'forum';
break;
case 'a':
$title = 'announcement';
break;
case 'u':
$title = 'user';
break;
}
return $title;
}
// do the replacements and return encoded url
$title = str_replace("&", "&", $title);
$title = preg_replace("/&([a-z]+);/", "", $title); // remove html entities such as & " etc..
$title = preg_replace("/&#([0-9]+);/", "", $title); // remove entities like !
// added in BETA 9, to fix issues with some latin characters
if (stristr($lang->settings['charset'], 'iso')) {
$title = utf8_encode($title);
$is_utf8 = 1;
}
$title = utf8_trans_unaccent($title);
// translate accents -- and maybe remove few non-ascii characters too, while on it..
$title = preg_replace('#&([a-zA-Z])(circ|uml|grave|tilde|acute|cedil|ring|th);#', '\\1', htmlentities($title, null, 'utf-8'));
$title = preg_replace("/&([a-z]+);/", "", $title);
if ($is_utf8 == 1) {
$title = utf8_decode($title);
}
// might be something like jackal's, we don't want it to be jackal-s
$title = str_replace("'", '', $title);
$title = str_replace(
array(":", "?", ".", "!", "$", "^", "*", ",", ";", '"', "%", "~", "@", "#", "[", "]", "<", ">", "\\", "/", "=", "+", "(", ")"),
"-", $title);
$title = str_replace(array('_', " ", "&"), array("-", "-", "and"), $title);
// remove multiple separators
$title = preg_replace("#-{2,}#", "-", $title);
// remove ending - if needed
if (substr($title, -1) == '-') {
$title = substr($title, 0, -1);
}
// convert to lowercase?
if (FORCE_LOWERCASE == 1) {
$title = strtolower($title);
}
// limit number of keywords in the url?
if (MAX_KEYWORDS > 0)
{
$words = explode("-", $title);
// if we have more words than allowed..
if (count($words) > MAX_KEYWORDS)
{
// common words, which can be stripped out if enabled
$common_words = array('is', 'you', 'are', 'in', 'at', 'the', 'and', 'to', 'of', 'or', 'from', 'when', 'where', 'be', 'you');
$i = 0;
foreach ($words as $word)
{
if ($i >= MAX_KEYWORDS) {
break;
}
$length = strlen($word);
// strip the keyword, if it has less length than defined, or if it's a common word -- if enabled!
if ( ($length < LEN_FOR_KEYWORD && STRIP_LESS_LEN == 1) OR (STRIP_COMMON_WORDS == 1 && in_array($word, $common_words)) ) {
continue;
}
// it has the number of characters to be counted as a keyword?
if (LEN_FOR_KEYWORD == 0 OR $length >= LEN_FOR_KEYWORD) {
$i++;
}
$new_title[] = $word;
}
// in some cases, due to less intelligence of the automatic keyword stripper there
// might be no keywords left to show, in that case, just display the original!
if (count($new_title) > 0) {
$title = implode("-", $new_title);
}
}
}
return rawurlencode($title);
}