Example #1
0
					$bbcode->allow_html = $config['allow_html'] && $searchset[$i]['enable_html'];
					$bbcode->allow_bbcode = $config['allow_bbcode'] && $searchset[$i]['enable_bbcode'];
					$bbcode->allow_smilies = $config['allow_smilies'] && $searchset[$i]['enable_smilies'];
					$bbcode->code_post_id = $searchset[$i]['post_id'];
					$message = $bbcode->parse($message, '', false, $clean_tags);
					$bbcode->code_post_id = 0;
				}
				else
				{
					$message = $message_compiled;
				}

				if ($return_chars != -1)
				{
					//$message = (strlen($message) > $return_chars) ? substr($message, 0, $return_chars) . ' ...' : $message;
					$message = truncate_html_string($message, $return_chars);
				}

				if ($highlight_active)
				{
					// Replaced by MG: creation of $highlight_match_string
					$message = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match_string . ')(?!\w|[^<>]*>)#i', '<span class="highlight-w"><b>\1</b></span>', $message);
				}

				$post_subject = !empty($searchset[$i]['post_subject']) ? censor_text($searchset[$i]['post_subject']) : $topic_title;
				$message = censor_text($message);

				$poster = ($searchset[$i]['user_id'] != ANONYMOUS) ? colorize_username($searchset[$i]['user_id'], $searchset[$i]['username'], $searchset[$i]['user_color'], $searchset[$i]['user_active']) : (($searchset[$i]['post_username'] != '') ? $searchset[$i]['post_username'] : $lang['Guest']);
				//$poster .= ($searchset[$i]['user_id'] != ANONYMOUS) ? $searchset[$i]['username'] : (($searchset[$i]['post_username'] != "") ? $searchset[$i]['post_username'] : $lang['Guest']);

				if (($user->data['user_level'] != ADMIN) && !empty($searchset[$i]['user_mask']) && empty($searchset[$i]['user_active']))
Example #2
0
 function fetch_posts($forum_sql, $number_of_posts, $text_length, $show_portal = false, $sort_mode = 0, $single_post = false, $only_auth_view = true)
 {
     global $db, $cache, $config, $user, $bbcode, $lofi;
     if (!class_exists('bbcode') || empty($bbcode)) {
         @(include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
     }
     $except_forums = build_exclusion_forums_list($only_auth_view);
     $add_to_sql = '';
     if (empty($single_post) && !empty($forum_sql)) {
         $except_forums_exp = explode(',', str_replace(' ', '', $except_forums));
         $allowed_forums_exp = explode(',', str_replace(' ', '', $forum_sql));
         $except_forums = '';
         for ($e = 0; $e < sizeof($except_forums_exp); $e++) {
             if (!in_array($except_forums_exp[$e], $allowed_forums_exp)) {
                 $except_forums .= $except_forums == '' ? $except_forums_exp[$e] : ', ' . $except_forums_exp[$e];
             }
         }
         $add_to_sql .= ' AND t.forum_id IN (' . $forum_sql . ')';
         $add_to_sql .= ' AND t.forum_id NOT IN (' . $except_forums . ')';
     } else {
         $add_to_sql .= ' AND t.forum_id NOT IN (' . $except_forums . ')';
     }
     if (!empty($show_portal)) {
         $add_to_sql .= ' AND t.topic_show_portal = 1';
     }
     if ($sort_mode == 1) {
         // Random
         $order_sql = 'RAND()';
     } elseif ($sort_mode == 2) {
         // Alphabetical
         $order_sql = 't.topic_title ASC';
     } else {
         // Recent
         $order_sql = 't.topic_time DESC';
     }
     if ($number_of_posts != 0) {
         $limit_sql = ' LIMIT 0,' . $number_of_posts;
     } else {
         $limit_sql = '';
     }
     if (!empty($single_post)) {
         $single_post_id = $forum_sql;
         $sql = "SELECT p.post_id, p.topic_id, p.forum_id, p.enable_html, p.enable_bbcode, p.enable_smilies, p.post_attachment, p.enable_autolinks_acronyms, p.post_text, p.post_text_compiled, t.forum_id, t.topic_time, t.topic_title, t.topic_first_post_id, t.topic_attachment, t.topic_views, t.topic_replies, u.username, u.user_id, u.user_active, u.user_color\n\t\t\t\t\tFROM " . POSTS_TABLE . " AS p, " . TOPICS_TABLE . " AS t, " . USERS_TABLE . " AS u\n\t\t\t\t\tWHERE p.post_id = '" . $single_post_id . "'\n\t\t\t\t\t\t" . $add_to_sql . "\n\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\tAND p.poster_id = u.user_id";
     } else {
         $sql = "SELECT t.topic_id, t.topic_time, t.topic_title, t.forum_id, t.topic_poster, t.topic_first_post_id, t.topic_status, t.topic_show_portal, t.topic_attachment, t.topic_views, t.topic_replies, u.username, u.user_id, u.user_active, u.user_color, p.post_id, p.enable_html, p.enable_bbcode, p.enable_smilies, p.post_attachment, p.enable_autolinks_acronyms, p.post_text, p.post_text_compiled\n\t\t\t\t\tFROM " . TOPICS_TABLE . " AS t, " . USERS_TABLE . " AS u, " . POSTS_TABLE . " AS p\n\t\t\t\t\tWHERE t.topic_time <= " . time() . "\n\t\t\t\t\t\t" . $add_to_sql . "\n\t\t\t\t\t\tAND t.topic_poster = u.user_id\n\t\t\t\t\t\tAND t.topic_first_post_id = p.post_id\n\t\t\t\t\t\tAND t.topic_status <> 2\n\t\t\t\t\tORDER BY " . $order_sql . $limit_sql;
     }
     // query the database
     $result = $db->sql_query($sql);
     // fetch all postings
     $posts = array();
     if ($row = $db->sql_fetchrow($result)) {
         $i = 0;
         do {
             $posts[$i]['enable_bbcode'] = $row['enable_bbcode'];
             $posts[$i]['enable_html'] = $row['enable_html'];
             $posts[$i]['enable_smilies'] = $row['enable_smilies'];
             $posts[$i]['enable_autolinks_acronyms'] = $row['enable_autolinks_acronyms'];
             $posts[$i]['post_text'] = $row['post_text'];
             $posts[$i]['forum_id'] = $row['forum_id'];
             $posts[$i]['topic_id'] = $row['topic_id'];
             $posts[$i]['topic_first_post_id'] = $row['topic_first_post_id'];
             $posts[$i]['topic_views'] = $row['topic_views'];
             $posts[$i]['topic_replies'] = $row['topic_replies'];
             $posts[$i]['topic_time'] = create_date_ip($config['default_dateformat'], $row['topic_time'], $config['board_timezone']);
             $posts[$i]['topic_title'] = $row['topic_title'];
             $posts[$i]['user_id'] = $row['user_id'];
             $posts[$i]['username'] = $row['username'];
             $posts[$i]['user_active'] = $row['user_active'];
             $posts[$i]['user_color'] = $row['user_color'];
             $posts[$i]['topic_attachment'] = $row['topic_attachment'];
             $posts[$i]['post_id'] = $row['post_id'];
             $posts[$i]['post_attachment'] = $row['post_attachment'];
             if ($text_length >= 0) {
                 $message = $posts[$i]['post_text'];
                 $message_compiled = empty($posts[$i]['post_text_compiled']) || !empty($user->data['session_logged_in']) || !empty($config['posts_precompiled']) ? false : $posts[$i]['post_text_compiled'];
                 $bbcode->allow_bbcode = $config['allow_bbcode'] && $user->data['user_allowbbcode'] && $posts[$i]['enable_bbcode'] ? true : false;
                 $bbcode->allow_html = ($config['allow_html'] && $user->data['user_allowhtml'] || $config['allow_html_only_for_admins']) && $posts[$i]['enable_html'] ? true : false;
                 $bbcode->allow_smilies = $config['allow_smilies'] && $posts[$i]['enable_smilies'] && !$lofi ? true : false;
                 $clean_tags = false;
                 if (strlen($posts[$i]['post_text']) > $text_length && $text_length > 0) {
                     $clean_tags = true;
                     $posts[$i]['striped'] = 1;
                 }
                 $posts[$i]['post_text'] = $message_compiled === false ? $bbcode->parse($posts[$i]['post_text'], '', false, $clean_tags) : $message_compiled;
                 if (!empty($clean_tags)) {
                     $posts[$i]['post_text'] = strlen($posts[$i]['post_text']) > $text_length ? truncate_html_string($posts[$i]['post_text'], $text_length) : $posts[$i]['post_text'];
                 }
                 $posts[$i]['post_text'] = censor_text($posts[$i]['post_text']);
                 //Acronyms, AutoLinks - BEGIN
                 if ($posts[$i]['enable_autolinks_acronyms']) {
                     $posts[$i]['post_text'] = $bbcode->acronym_pass($posts[$i]['post_text']);
                     $posts[$i]['post_text'] = $bbcode->autolink_text($posts[$i]['post_text'], '999999');
                 }
                 //Acronyms, AutoLinks - END
             }
             $posts[$i]['topic_title'] = censor_text($posts[$i]['topic_title']);
             $i++;
         } while ($row = $db->sql_fetchrow($result));
     }
     $db->sql_freeresult($result);
     // return the result
     return $posts;
 }