   

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', '');

 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



// 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'    => "<meta name=\"description\" content=\"".$bb_cfg['site_desc']."\" />\n",
    'PAGE_KEYWORDS'       => "<meta name=\"keywords\" content=\"".$bb_cfg['global_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('&quot;', '', $title);
	
	$description = "<meta name=\"description\" content=\"$description\" />\n";
	$keywords 	 = "<meta name=\"keywords\" content=\"$keywords\" />\n";
	$article 	 = (isset($description) || isset($keywords)) ? "<meta property=\"og:type\" content=\"article\" />\n" : "";
	$generator	 = (isset($title) || isset($url) || isset($images)) ? "<meta name=\"generator\" content=\"".$bb_cfg['sitename']." (http://".$bb_cfg['server_name']."/)\" />\n" : "";
	$site_name	 = (isset($title) || isset($url) || isset($images)) ? "<meta property=\"og:site_name\" content=\"".$bb_cfg['sitename']."\" />\n" : "";
	$title 		 = (isset($title)) ? "<meta property=\"og:title\" content=\"".strip_tags($title)."\" />\n" : "";
	$url 		 = (isset($url)) ? "<meta property=\"og:url\" content=\"$url\" />\n" : "";
	$images 	 = (isset($images)) ? "<meta property=\"og:image\" content=\"$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( "&nbsp;", " ", $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( '<br />', ' ', $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}

 

<!-- IF META_TAGS_HEAD -->{META_TAGS_HEAD}<!-- ELSE -->{PAGE_DESCRIPTION}{PAGE_KEYWORDS}<!-- ENDIF -->

 admin/admin_board.php



'CONFIG_SITE_DESCRIPTION' => htmlCHR($new['site_desc']),

 

'CONFIG_SITE_KEYSWORDS' => htmlCHR($new['global_keywords']),

 templates/admin/admin_board.tpl



<tr>
	<td><h4>{L_SITE_DESC}</h4></td>
	<td><input class="post" type="text" size="40" maxlength="255" name="site_desc" value="{CONFIG_SITE_DESCRIPTION}" /></td>
</tr>

 

<tr>
    <td><h4>{L_GLOBAL_KEYWORDS}</h4></td>
    <td><input class="post" type="text" size="40" maxlength="255" name="config_site_keywords" value="{CONFIG_SITE_KEYSWORDS}" /></td>
</tr>

 language/lang_english/lang_admin.php

    

$lang['GLOBAL_KEYWORDS'] = 'Global keywords';

 language/lang_russian/lang_admin.php

    

$lang['GLOBAL_KEYWORDS'] = '  ';