Moderator: Moderators
(...)
function make_keywords($text) {
global $phpbb_root_path;
static $stop_words = array();
$keywords = '';
$num = 0;
$text = strtolower(preg_replace(array('`&(amp;)?#?[a-z0-9]+;`i', '`[[:punct:]]+`', '`[0-9]+`', '`[\s]+`'), ' ', strip_tags($text)));
$text = explode(' ', trim($text), 50);
// I'm using a "search_stopwords.php" like in phpBB3
include($phpbb_root_path . 'language/lang_german/search_stopwords.php');
$stop_words = & $words;
$text = array_diff($text, $stop_words);
// We take the most used words first
$text = array_count_values($text);
arsort($text);
foreach ($text as $word => $count) {
if ( strlen($word) >= 3 ) {
$keywords .= ', ' . $word;
$num++;
if ( $num >= 15 ) {
break;
}
}
}
return trim($keywords, ', ');
}
/**
* Filter php/html tags and white spaces and returns htmlspecialchared string with limit in words
*/
function meta_filter_txt($text, $bbcode = true) {
if ($bbcode) {
static $RegEx = array();
static $replace = array(' ', ' ', '', ' ');
if (empty($RegEx)) {
$RegEx = array('`<[^>]*>(.*<[^>]*>)?`Usi', // HTML code
'`\[(' . 'img|url|flash|code' . ')[^\[\]]+\].*\[/\1[^\[\]]+\]`Usi', // bbcode to strip
'`\[/?[^\[\]]+\]`mi', // Strip all bbcode tags
'`[\s]+`' // Multiple spaces
);
}
return $this->word_limit(htmlspecialchars(preg_replace($RegEx, $replace, $text), ENT_COMPAT));
}
return $this->word_limit(htmlspecialchars(preg_replace(array('`<[^>]*>(.*<[^>]*>)?`Usi', '`[\s]+`'), ' ', $text), ENT_COMPAT));
}
/**
* Cut the text according to the number of words.
* Borrowed from www.php.net http://www.php.net/preg_replace
*/
function word_limit($string) {
return count($words = preg_split('/\s+/', ltrim($string), 25 + 1)) > 25 ? rtrim(substr($string, 0, strlen($string) - strlen(end($words)))) . '...' : $string;
}
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
(...)
// www.phpBB-SEO.com SEO TOOLKIT BEGIN - META
$phpbb_seo->seo_meta['meta_desc'] = $phpbb_seo->meta_filter_txt($postrow[0]['post_text']);
$m_kewrd = '';
$sql = "SELECT w.word_text
FROM " . TOPICS_TABLE . " t, " . SEARCH_MATCH_TABLE . " m, " . SEARCH_WORD_TABLE . " w
WHERE t.topic_id = $topic_id
AND t.topic_first_post_id = m.post_id
AND m.word_id = w.word_id LIMIT 15";
if( ($result = $db->sql_query($sql)) ) {
while ( $meta_row = $db->sql_fetchrow($result) ) {
$m_kewrd .= " " . $meta_row['word_text'];
}
}
$phpbb_seo->seo_meta['keywords'] = $phpbb_seo->make_keywords("$m_kewrd " . $phpbb_seo->seo_meta['meta_desc']);
// www.phpBB-SEO.com SEO TOOLKIT END - META
// www.phpBB-SEO.com SEO TOOLKIT BEGIN - META
$phpbb_seo->seo_meta['meta_desc'] = $phpbb_seo->meta_filter_txt($postrow[0]['post_text']);
$m_kewrd = '';
$common_sql = true ? '' : 'AND w.word_common = 0';
$sql = "SELECT w.word_text
FROM " . SEARCH_MATCH_TABLE . " m, " . SEARCH_WORD_TABLE . " w
WHERE m.post_id = " . (int) $row['post_id'] . "
AND w.word_id = m.word_id LIMIT 15
$common_sql
ORDER BY w.word_count DESC";
$result = $db->sql_query($sql);
while ( $meta_row = $db->sql_fetchrow($result) ) {
$m_kewrd .= ' ' . $meta_row['word_text'];
}
$db->sql_freeresult($result);
$phpbb_seo->seo_meta['keywords'] = !empty($m_kewrd) ? $phpbb_seo->make_keywords($m_kewrd) : $phpbb_seo->make_keywords($phpbb_seo->seo_meta['meta_desc']);
// www.phpBB-SEO.com SEO TOOLKIT END - META return $this->word_limit(htmlspecialchars(preg_replace($RegEx, $replace, htmlspecialchars_decode($text)), ENT_COMPAT)); return $this->word_limit(htmlspecialchars(preg_replace($RegEx, $replace, $text), ENT_COMPAT));
&quot;hi&quot;Users browsing this forum: Google Feedfetcher and 1 guest