Выпонить запросы в базу
ALTER TABLE `bb_topics` ADD `descr` varchar(200) NOT NULL DEFAULT '', ADD `keywords` text NOT NULL;
INSERT INTO `bb_config` VALUES ('global_keywords', '');
Открыть includes/page_header.php
Найти
// FOR SEO
$template->assign_vars(array(
'SEO_LINK_INDEX_PAGE' => seo_link_header('index'),
'SEO_LINK_TRACKER_PAGE' => seo_link_header('tracker'),
'SEO_LINK_GALLERY_PAGE' => seo_link_header('gallery'),
'SEO_LINK_SEARCH_PAGE' => seo_link_header('search'),
'SEO_LINK_FAQ_PAGE' => seo_link_header('faq'),
'SEO_LINK_GROUP_PAGE' => seo_link_header('groupcp'),
'SEO_LINK_MEMEBERLIST_PAGE' => seo_link_header('memberlist'),
));
Ниже вставить
$template->assign_vars(array(
'PAGE_DESCRIPTION' => "\n",
'PAGE_KEYWORDS' => "\n",
));
Открыть includes/functions_post.php
Найти
$topic_dl_type = (isset($_POST['topic_dl_type']) && ($post_info['allow_reg_tracker'] || $is_auth['auth_mod'])) ? TOPIC_DL_TYPE_DL : TOPIC_DL_TYPE_NORMAL;
Ниже вставить
$meta = create_metatags ($post_message);
$description = $meta['description'];
$keywords = $meta['keywords'];
Найти
$sql_update = "
UPDATE
" . BB_TOPICS . "
SET
topic_title = '$post_subject',
topic_type = $topic_type,
topic_dl_type = $topic_dl_type " . ((@$post_data['edit_vote'] || !empty($poll_title)) ? ",
topic_vote = " . $topic_vote : "") . ",
is_draft = $to_draft
WHERE
topic_id = $topic_id
";
Заменить на
$sql_update = "
UPDATE
" . BB_TOPICS . "
SET
topic_title = '$post_subject',
topic_type = $topic_type,
topic_dl_type = $topic_dl_type " . ((@$post_data['edit_vote'] || !empty($poll_title)) ? ",
topic_vote = " . $topic_vote : "") . ",
is_draft = $to_draft,
keywords = '$keywords',
descr = '$description'
WHERE
topic_id = $topic_id
";
Найти
$sql = ($mode != "editpost") ? "INSERT INTO " . BB_TOPICS . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_dl_type, topic_vote, is_draft) VALUES ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_dl_type, $topic_vote, $to_draft)" : $sql_update;
Заменить на
$sql = ($mode != "editpost") ? "INSERT INTO " . BB_TOPICS . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_dl_type, topic_vote, is_draft, keywords, descr) VALUES ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_dl_type, $topic_vote, $to_draft, '$keywords', '$description')" : $sql_update;
Открыть includes/functions.php
В самый конец файла вставить
function meta_search ($url = false, $title = false, $images = false, $description = false, $keywords = false)
{
global $template, $bb_cfg;
$title = str_replace('"', '', $title);
$description = "\n";
$keywords = "\n";
$article = (isset($description) || isset($keywords)) ? "\n" : "";
$generator = (isset($title) || isset($url) || isset($images)) ? "\n" : "";
$site_name = (isset($title) || isset($url) || isset($images)) ? "\n" : "";
$title = (isset($title)) ? "\n" : "";
$url = (isset($url)) ? "\n" : "";
$images = (isset($images)) ? "\n" : "";
$meta_tags = $description.$keywords.$generator.$site_name.$article.$title.$url.$images;
$template->assign_vars(array('META_TAGS_HEAD' => $meta_tags));
}
function bb_substr($str, $start, $length, $charset ) {
if ( strtolower($charset) == "utf-8") return iconv_substr($str, $start, $length, "utf-8");
else return substr($str, $start, $length);
}
function bb_strlen($value, $charset ) {
if ( strtolower($charset) == "utf-8") return iconv_strlen($value, "utf-8");
else return strlen($value);
}
function create_metatags ($text)
{
$keyword_count = 20;
$newarr = array ();
$meta['description'] = $meta['keywords'] = array();
$quotes = array ("\x22", "\x60", "\t", '\n', '\r', "\n", "\r", '\\', ",", ".", "/", "¬", "#", ";", ":", "@", "~", "[", "]", "{", "}", "=", "-", "+", ")", "(", "*", "^", "%", "$", "<", ">", "?", "!", '"');
$fastquotes = array ("\x22", "\x60", "\t", "\n", "\r", '"', '\r', '\n', "$", "{", "}", "[", "]", "<", ">");
$text = str_replace( " ", " ", $text);
$text = preg_replace('#\[img=(left|right)\].*?\[/img\]\s*#isu', '', $text);
$text = preg_replace('#\[img\].*?\[/img\]#isu', '', $text);
$text = preg_replace('#http://.*? #isu', '', $text);
$text = preg_replace('#\[.*?\]#isu', ' ', $text);
$text = str_replace( '
', ' ', $text);
$text = strip_tags($text);
$text = preg_replace( "#&(.+?);#", "", $text);
$text = trim(str_replace( " ,", "", $text));
$search_word = array("Описание", "О фильме", "Сюжет фильма");
$i= array_count_values($search_word);
if (preg_match('#Описание#is', $text) || preg_match('#О фильме#is', $text) || preg_match('#Сюжет фильма#is', $text))
{
$pos = strpos($text, 'Сюжет фильма');
$pos .= strpos($text, 'О фильме');
$pos .= strpos($text, 'Описание');
$text_d = substr($text, $pos);
}
else{ $text_d = '';}
if($text_d = ($text_d != '') ? $text_d : $text)
{
$description = str_replace($fastquotes, '', $text_d);
$description = str_replace(":", '', $description);
$description = preg_replace("/(\s){2,}/",' ',$description);
$description = str_replace($search_word, '', trim($description));
$meta['description'] = trim(bb_substr( stripslashes($description), 0, 190, 'utf-8' ));
} else { $meta['description'] = ''; }
if( trim($text) != "" ) {
$text = str_replace($quotes, ' ', $text);
$arr = explode(" ", $text);
foreach ( $arr as $word ) {
if( bb_strlen( $word, 'utf-8' ) > 4 ) $newarr[] = $word;
}
$arr = array_count_values( $newarr );
arsort( $arr );
$arr = array_keys( $arr );
$total = count( $arr );
$offset = 0;
$arr = array_slice( $arr, $offset, $keyword_count );
$meta['keywords'] = implode( ", ", $arr );
} else { $meta['keywords'] = ''; }
return $meta;
}
Открыть templates/default/page_header.tpl
Найти
{META}
Выше добавить
{META_TAGS_HEAD}{PAGE_DESCRIPTION}{PAGE_KEYWORDS}
Открыть admin/admin_board.php
Найти
'CONFIG_SITE_DESCRIPTION' => htmlCHR($new['site_desc']),
Ниже добавить
'CONFIG_SITE_KEYSWORDS' => htmlCHR($new['global_keywords']),
Открыть templates/admin/admin_board.tpl
Найти