Beispiel #1
0
function create_meta_content()
{
    global $db, $cache, $config, $lang;
    global $meta_content;
    if (!empty($meta_content['post_id']) && $meta_content['post_id'] > 0 || !empty($meta_content['topic_id']) && $meta_content['topic_id'] > 0) {
        if (!empty($meta_content['post_id']) && $meta_content['post_id'] > 0) {
            $sql = "SELECT f.forum_name, f.forum_name_clean, t.topic_title, t.topic_title_clean, t.topic_tags, t.title_compl_infos, p.topic_id, p.forum_id\n\t\t\t\t\t\t\tFROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f\n\t\t\t\t\t\t\tWHERE p.post_id = '" . $meta_content['post_id'] . "'\n\t\t\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\t\t\tAND f.forum_id = p.forum_id\n\t\t\t\t\t\t\tLIMIT 1";
            // Mighty Gorgon: shall we cache this as well? Maybe too many files... better avoid...
            //$result = $db->sql_query($sql, 0, 'posts_meta_', TOPICS_CACHE_FOLDER);
            $db->sql_return_on_error(true);
            $result = $db->sql_query($sql);
            $db->sql_return_on_error(false);
        } else {
            $sql = "SELECT f.forum_name, f.forum_name_clean, t.forum_id, t.topic_id, t.topic_title, t.topic_title_clean, t.topic_tags, t.title_compl_infos\n\t\t\t\t\t\t\tFROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f\n\t\t\t\t\t\t\tWHERE t.topic_id = '" . $meta_content['topic_id'] . "'\n\t\t\t\t\t\t\t\tAND f.forum_id = t.forum_id\n\t\t\t\t\t\t\tLIMIT 1";
            $db->sql_return_on_error(true);
            $result = CACHE_TOPICS_META ? $db->sql_query($sql, 0, 'topics_meta_', TOPICS_CACHE_FOLDER) : $db->sql_query($sql);
            $db->sql_return_on_error(false);
        }
        if ($result) {
            while ($meta_row = $db->sql_fetchrow($result)) {
                $meta_content['forum_id'] = $meta_row['forum_id'];
                $meta_content['forum_name'] = strip_tags(stripslashes($meta_row['forum_name']));
                $meta_content['forum_name_clean'] = $meta_row['forum_name_clean'];
                $meta_content['topic_id'] = $meta_row['topic_id'];
                $meta_content['topic_title'] = strip_tags(stripslashes($meta_row['topic_title']));
                $meta_content['topic_title_clean'] = $meta_row['topic_title_clean'];
                $meta_content['topic_tags'] = $meta_row['topic_tags'];
                $meta_content['title_compl_infos'] = $meta_row['title_compl_infos'];
                $meta_content['keywords'] = $meta_content['topic_tags'];
                $meta_content['keywords'] = empty($meta_content['keywords']) ? str_replace(array(' ', ',, '), array(', ', ', '), ip_clean_string($meta_content['topic_title'], $lang['ENCODING'], true)) : $meta_content['keywords'];
                $meta_content['description'] = $meta_content['forum_name'] . ' - ' . $meta_content['topic_title'];
                $meta_content['page_title'] = $meta_content['forum_name'] . ' :: ' . $meta_content['page_title'];
            }
            $db->sql_freeresult($result);
        }
    } elseif (!empty($meta_content['forum_id']) && $meta_content['forum_id'] > 0) {
        $sql = "SELECT f.forum_name, f.forum_name_clean, f.forum_desc\n\t\t\t\t\t\tFROM " . FORUMS_TABLE . " f\n\t\t\t\t\t\tWHERE f.forum_id = '" . $meta_content['forum_id'] . "'\n\t\t\t\t\t\t\tAND f.forum_type = " . FORUM_POST . "\n\t\t\t\t\t\tLIMIT 1";
        $db->sql_return_on_error(true);
        $result = $db->sql_query($sql);
        $db->sql_return_on_error(false);
        if ($result) {
            while ($meta_row = $db->sql_fetchrow($result)) {
                $meta_content['forum_name'] = strip_tags(stripslashes($meta_row['forum_name']));
                $meta_content['forum_name_clean'] = $meta_row['forum_name_clean'];
                $meta_content['description'] = $meta_content['forum_name'] . (empty($meta_row['forum_desc']) ? '' : ' - ' . strip_tags(stripslashes($meta_row['forum_desc'])));
                $meta_content['keywords'] = $meta_content['forum_name'] . ', ';
            }
            $db->sql_freeresult($result);
        }
    } elseif (!empty($meta_content['cat_id']) && $meta_content['cat_id'] > 0) {
        $sql = "SELECT c.forum_name AS cat_name, c.forum_name_clean AS cat_name_clean, c.forum_desc\n\t\t\t\t\t\tFROM " . FORUMS_TABLE . " c\n\t\t\t\t\t\tWHERE c.forum_id = " . $meta_content['cat_id'] . "\n\t\t\t\t\t\t\tAND f.forum_type = " . FORUM_CAT . "\n\t\t\t\t\t\tLIMIT 1";
        $db->sql_return_on_error(true);
        $result = $db->sql_query($sql);
        $db->sql_return_on_error(false);
        if ($result) {
            while ($meta_row = $db->sql_fetchrow($result)) {
                $meta_content['cat_name'] = strip_tags(stripslashes($meta_row['cat_name']));
                $meta_content['cat_name_clean'] = $meta_row['cat_name_clean'];
                $meta_content['description'] = $meta_content['cat_name'] . (empty($meta_row['cat_desc']) ? '' : ' - ' . strip_tags(stripslashes($meta_row['cat_desc'])));
                $meta_content['keywords'] = $meta_content['cat_name'] . ', ';
            }
            $db->sql_freeresult($result);
        }
    } else {
        /*
        $meta_content['description'] = '';
        $meta_content['keywords'] = '';
        */
    }
    if (!empty($meta_content['cat_id']) && !empty($meta_content['cat_title']) && empty($meta_content['cat_title_clean'])) {
        $meta_content['cat_title_clean'] = ip_clean_string($meta_row['cat_title'], $lang['ENCODING']);
        if (!function_exists('update_clean_cat_title')) {
            @(include_once IP_ROOT_PATH . 'includes/functions_admin_forums.' . PHP_EXT);
        }
        update_clean_cat_title($meta_content['cat_id'], $meta_content['cat_title_clean']);
    }
    if (!empty($meta_content['forum_id']) && !empty($meta_content['forum_name']) && empty($meta_content['forum_name_clean'])) {
        $meta_content['forum_name_clean'] = ip_clean_string($meta_row['forum_name'], $lang['ENCODING']);
        if (!function_exists('update_clean_forum_name')) {
            @(include_once IP_ROOT_PATH . 'includes/functions_admin_forums.' . PHP_EXT);
        }
        update_clean_forum_name($meta_content['forum_id'], $meta_content['forum_name_clean']);
    }
    if (!empty($meta_content['topic_id']) && !empty($meta_content['topic_title']) && empty($meta_content['topic_title_clean'])) {
        $meta_content['topic_title_clean'] = ip_clean_string($meta_row['topic_title'], $lang['ENCODING']);
        if (!function_exists('update_clean_topic_title')) {
            @(include_once IP_ROOT_PATH . 'includes/functions_topics.' . PHP_EXT);
        }
        update_clean_topic_title($meta_content['topic_id'], $meta_content['topic_title_clean']);
    }
    // Mighty Gorgon: shall we UTF8 decode also page_title and meta?
    /*
    $meta_content['page_title'] = ip_utf8_decode($meta_content['page_title']);
    $meta_content['description'] = ip_utf8_decode($meta_content['description']);
    $meta_content['keywords'] = ip_utf8_decode($meta_content['keywords']);
    */
    return true;
}
// Okay, lets dump out the page...
if($total_topics)
{
	for($i = 0; $i < $total_topics; $i++)
	{
		$forum_id = $topic_rowset[$i]['forum_id'];
		$forum_id_append = (!empty($forum_id) ? (POST_FORUM_URL . '=' . $forum_id) : '');
		$topic_id = $topic_rowset[$i]['topic_id'];
		$topic_id_append = (!empty($topic_id) ? (POST_TOPIC_URL . '=' . $topic_id) : '');

		$topic_title = censor_text($topic_rowset[$i]['topic_title']);
		$topic_title_clean = (empty($topic_rowset[$i]['topic_title_clean'])) ? substr(ip_clean_string($topic_title, $lang['ENCODING']), 0, 254) : $topic_rowset[$i]['topic_title_clean'];
		if (empty($topic_rowset[$i]['topic_title_clean']))
		{
			update_clean_topic_title($topic_id, $topic_title_clean);
		}
		$topic_title_prefix = (empty($topic_rowset[$i]['title_compl_infos'])) ? '' : $topic_rowset[$i]['title_compl_infos'] . ' ';
		$topic_title = $topic_title_prefix . $topic_title;
		// Convert and clean special chars!
		$topic_title = htmlspecialchars_clean($topic_title);
		$topic_title_plain = htmlspecialchars($topic_title);

		if (($config['url_rw'] == '1') || (($config['url_rw_guests'] == '1') && ($user->data['user_id'] == ANONYMOUS)))
		{
			$view_topic_url = append_sid(str_replace ('--', '-', make_url_friendly($topic_title) . '-vt' . $topic_id . '.html'));
		}
		else
		{
			$view_topic_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&amp;' . $topic_id_append . $kb_mode_append);
		}
Beispiel #3
0
 function generate_topic_title($topic_id, $topic_data, $max_title_length)
 {
     global $config, $bbcode, $lang, $lofi;
     $max_title_length = (int) $max_title_length > 255 || $max_title_length < 15 ? 255 : $max_title_length;
     $topic_title = censor_text($topic_data['topic_title']);
     $topic_title_clean = empty($topic_data['topic_title_clean']) ? substr(ip_clean_string($topic_title, $lang['ENCODING']), 0, 254) : $topic_data['topic_title_clean'];
     if (empty($topic_data['topic_title_clean'])) {
         if (!function_exists('update_clean_topic_title')) {
             @(include_once IP_ROOT_PATH . 'includes/functions_topics.' . PHP_EXT);
         }
         update_clean_topic_title($topic_id, $topic_title_clean);
     }
     $topic_title_prefix = empty($topic_data['title_compl_infos']) ? '' : trim($topic_data['title_compl_infos']) . ' ';
     // Convert and clean special chars!
     $topic_title = htmlspecialchars_clean($topic_title);
     // SMILEYS IN TITLE - BEGIN
     if ($config['smilies_topic_title'] == true && !$lofi) {
         if (!class_exists('bbcode')) {
             include IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT;
         }
         if (empty($bbcode)) {
             $bbcode = new bbcode();
         }
         $bbcode->allow_smilies = $config['allow_smilies'] && $topic_data['enable_smilies'] ? true : false;
         $topic_title = $bbcode->parse_only_smilies($topic_title);
     }
     // SMILEYS IN TITLE - END
     $topic_title = $topic_title_prefix . $topic_title;
     $topic_title_plain = htmlspecialchars(strip_tags($topic_title));
     $topic_title_short = $topic_title;
     if (strlen($topic_title) > $max_title_length - 3) {
         // remove tags from the short version, in case a smiley or a quick title prefix is in there
         $topic_title_short = substr(strip_tags($topic_title), 0, intval($max_title_length)) . '...';
     }
     $topic_title_data = array('title' => $topic_title, 'title_clean' => $topic_title_clean, 'title_plain' => $topic_title_plain, 'title_prefix' => $topic_title_prefix, 'title_short' => $topic_title_short);
     return $topic_title_data;
 }