Выпонить запросы в базу
ALTER TABLE `bb_topics` ADD `descr` varchar(200) NOT NULL DEFAULT '', ADD `keywords` text NOT NULL, ADD `topic_image` VARCHAR( 255 ) NOT NULL DEFAULT '';
INSERT INTO `bb_config` VALUES ('global_keywords', '');
Если стоит мод постеров Pherum:
ALTER TABLE `bb_topics` ADD `descr` varchar(200) NOT NULL DEFAULT '', ADD `keywords` text NOT NULL;
INSERT INTO `bb_config` VALUES ('global_keywords', '');
Открыть viewtopic.php
Найти
// Does this topic contain DL-List?
Выше добавить
if (function_exists('seo_url')) $url_meta = make_url(seo_url(TOPIC_URL . $topic_id, $topic_title));
else $url_meta = make_url(TOPIC_URL . $topic_id);
meta_search($url_meta, $topic_title, $t_data['topic_image'], $t_data['descr'], $t_data['keywords']);
Открыть posting.php
Найти
if (defined('TORRENT_ATTACH_ID') && $bb_cfg['bt_newtopic_auto_reg'] && !$error_msg)
Выше добавить (если стоит мод постеров ферум это не трогаем!!!)
if ($mode == 'newtopic' && defined('TORRENT_ATTACH_ID') || defined('TORRENT_ATTACH_ID') && $bb_cfg['bt_newtopic_auto_reg'] && !$error_msg)
{
$row = DB()->fetch_row("SELECT post_text FROM ". BB_POSTS_TEXT ." WHERE post_id = $post_id");
preg_match_all('/\[poster\](.*?)\[\/poster\]/i', $row['post_text'], $poster4, PREG_SET_ORDER);
preg_match_all('/\[img=right\](.*?)\[\/img\]/i', $row['post_text'], $poster3, PREG_SET_ORDER);
preg_match_all('/\[img=left\](.*?)\[\/img\]/i', $row['post_text'], $poster2, PREG_SET_ORDER);
preg_match_all('/\[img\](.*?)\[\/img\]/i', $row['post_text'], $poster1, PREG_SET_ORDER);
$url = '';
if (isset($poster3[0][1])) $url = $poster3[0][1];
elseif (isset($poster4[0][1])) $url = $poster4[0][1];
elseif (isset($poster2[0][1])) $url = $poster2[0][1];
elseif (isset($poster1[0][1])) $url = $poster1[0][1];
DB()->query("UPDATE ". BB_TOPICS ." SET topic_image = '$url' WHERE topic_id = $topic_id ");
}
Открыть includes/page_header.php
Найти
if (!empty($page_cfg['show_torhelp'][BB_SCRIPT]) && !empty($userdata['torhelp']))
Выше вставить
$template->assign_vars(array(
'PAGE_DESCRIPTION' => $bb_cfg['site_desc'],
'PAGE_KEYWORDS' => $bb_cfg['global_keywords'],
));
Открыть 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
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,
keywords = '$keywords',
descr = '$description'
WHERE
topic_id = $topic_id
";
Найти
$sql_insert = "
INSERT INTO
" . BB_TOPICS . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_dl_type)
VALUES
('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_dl_type)
";
Заменить на
$sql_insert = "
INSERT INTO
" . BB_TOPICS . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_dl_type, keywords, descr)
VALUES
('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_dl_type, '$keywords', '$description')
";
Открыть 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}
Открыть admin/admin_board.php
Найти
'CONFIG_SITE_DESCRIPTION' => htmlCHR($new['site_desc']),
Ниже добавить
'CONFIG_SITE_KEYSWORDS' => htmlCHR($new['global_keywords']),
Открыть templates/admin/admin_board.tpl
Найти