if ($bbcode_bitfield !== '') { $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) { if (!isset($rowset[$post_list[$i]])) { continue; } $row =& $rowset[$post_list[$i]]; // Size the message to max length if ($max_announce_item_length != 0 && strlen($row['post_text']) > $max_announce_item_length) { $row['post_text'] = sgp_truncate_message($row['post_text'], $max_announce_item_length); $row['post_text'] .= ' <a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . ($row['forum_id'] ? $row['forum_id'] : $forum_id) . '&t=' . $row['topic_id']) . '"><strong>[' . $user->lang['VIEW_FULL_ARTICLE'] . ']</strong></a>'; } // Parse the message $message = censor_text($row['post_text']); $message = acronym_pass($message); // Second parse bbcode here if ($row['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message); if (!empty($attachments[$row['post_id']])) { parse_attachments($row['forum_id'], $message, $attachments[$row['post_id']], $update_count); } $postrow = array('ALLOW_REPLY' => $auth->acl_get('f_reply', $row['forum_id']) && $row['topic_status'] != '1' ? TRUE : FALSE, 'ALLOW_POST' => $auth->acl_get('f_post', $row['forum_id']) && $row['topic_status'] != '1' ? TRUE : FALSE, 'POSTER' => '<span style="color:#' . $row['user_colour'] . ';">' . $row['username'] . '</span>', 'TIME' => $row['post_time'], 'TITLE' => $row['topic_title'], 'MESSAGE' => $message, 'U_POSTER' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour']), 'U_VIEW' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . ($row['forum_id'] ? $row['forum_id'] : $forum_id) . '&t=' . $row['topic_id']), 'U_REPLY' => append_sid("{$phpbb_root_path}posting.{$phpEx}", 'mode=reply&t=' . $row['topic_id'] . '&f=' . $row['forum_id']), 'U_PRINT' => $auth->acl_get('f_print', $row['forum_id']) ? append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f=" . $row['forum_id'] . "&t=" . $row['topic_id'] . "&view=print") : '', 'U_REPLY_IMG' => '<img src="' . $phpbb_root_path . 'styles/' . $user->theme['imageset_path'] . '/imageset/portal/post_comment.png' . '" title="' . $user->lang['POST_COMMENTS'] . '" alt="' . $user->lang['POST_COMMENTS'] . '" />', 'U_PRINT_IMG' => '<img src="' . $phpbb_root_path . 'styles/' . $user->theme['imageset_path'] . '/imageset/portal/post_print.png' . '" title="' . $user->lang['PRINT_IT'] . '" alt="' . $user->lang['PRINT_IT'] . '" />', 'U_VIEW_IMG' => '<img src="' . $phpbb_root_path . 'styles/' . $user->theme['imageset_path'] . '/imageset/portal/post_view.png' . '" title="' . $user->lang['VIEW_FULL_ARTICLE'] . '" alt="' . $user->lang['VIEW_FULL_ARTICLE'] . '" />', 'S_TOPIC_TYPE' => $row['topic_type'], 'S_NOT_LAST' => $i < sizeof($posts) - 1 ? true : false, 'S_ROW_COUNT' => $i, 'S_POST_UNAPPROVED' => $row['post_approved'] ? false : true, 'S_DISPLAY_NOTICE' => $display_notice, 'S_HAS_ATTACHMENTS' => !empty($attachments[$row['post_id']]) ? true : false, 'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment']); $template->assign_block_vars('announce_row', $postrow); // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments[$row['post_id']])) { foreach ($attachments[$row['post_id']] as $attachment) { $template->assign_block_vars('announce_row.attachment', array('DISPLAY_ATTACHMENT' => $attachment));
/** * Fetch news processing */ function phpbb_fetch_news($forum_from, $number_of_posts, $text_length, $time, $type, $start = 0) { global $db, $config, $portal_config, $phpbb_root_path, $auth, $user, $bbcode_bitfield, $mode, $forum_id, $forum_status; $posts = array(); $post_time = $time == 0 ? '' : 'AND t.topic_time > ' . (time() - $time * 86400); $forum_from = strpos($forum_from, ',') !== FALSE ? explode(',', $forum_from) : ($forum_from != '' ? array($forum_from) : array()); $str_where = ''; $topic_icons = array(0); $have_icons = 0; $allow_access = array_unique(array_keys($auth->acl_getf('f_read', true))); if (sizeof($allow_access)) { if (sizeof($forum_from)) { foreach ($allow_access as $acc_id) { if (in_array($acc_id, $forum_from)) { $str_where .= "t.forum_id = {$acc_id} OR "; if (!isset($gobal_f)) { $global_f = $acc_id; } } } } else { foreach ($allow_access as $acc_id) { $str_where .= "t.forum_id = {$acc_id} OR "; if (!isset($gobal_f)) { $global_f = $acc_id; } } } if (utf8_strlen($str_where) > 0) { switch ($type) { case "announcements": $topic_type = '(( t.topic_type = ' . POST_ANNOUNCE . ') OR ( t.topic_type = ' . POST_GLOBAL . '))'; $str_where = utf8_strlen($str_where) > 0 ? 'AND (t.forum_id = 0 OR ' . substr($str_where, 0, -4) . ')' : ''; $user_link = 't.topic_poster = u.user_id'; $post_link = 't.topic_first_post_id = p.post_id'; $topic_order = 't.topic_time DESC'; break; case "news": $topic_type = '(( t.topic_type = ' . POST_NORMAL . ') OR ( t.topic_type = ' . POST_STICKY . '))'; $str_where = strlen($str_where) > 0 ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : ''; if ($portal_config['portal_news_show_last_post'] == true) { $user_link = 't.topic_last_poster_id = u.user_id'; $post_link = 't.topic_last_post_id = p.post_id'; $topic_order = 't.topic_last_post_id DESC'; } else { $user_link = 't.topic_poster = u.user_id'; $post_link = 't.topic_first_post_id = p.post_id'; $topic_order = 't.topic_time DESC'; } break; case "news_all": $topic_type = '( t.topic_type <> ' . POST_ANNOUNCE . ' ) AND ( t.topic_type <> ' . POST_GLOBAL . ')'; $str_where = strlen($str_where) > 0 ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : ''; if ($portal_config['portal_news_show_last_post'] == true) { $user_link = 't.topic_last_poster_id = u.user_id'; $post_link = 't.topic_last_post_id = p.post_id'; $topic_order = 't.topic_last_post_id DESC'; } else { $user_link = 't.topic_poster = u.user_id'; $post_link = 't.topic_first_post_id = p.post_id'; $topic_order = 't.topic_time DESC'; } break; } $sql_array = array('SELECT' => 't.forum_id, t.poll_title, t.topic_approved, t.topic_attachment, t.topic_id, t.topic_last_post_id, t.topic_last_post_time, t.topic_last_poster_name, t.topic_last_poster_id, t.topic_last_poster_colour, t.topic_moved_id, t.icon_id, t.topic_poster, t.topic_replies, t.topic_replies_real, t.topic_status, t.topic_time, t.topic_title, t.topic_type, t.topic_views, t.topic_first_post_id, u.user_colour, u.user_id, u.user_rank, u.user_type, u.username, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_magic_url, p.enable_smilies, p.post_approved, p.post_attachment, p.post_id, p.post_subject, p.post_text, p.post_time, f.enable_icons, f.forum_name', 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => $user_link), array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 't.forum_id=f.forum_id'), array('FROM' => array(POSTS_TABLE => 'p'), 'ON' => $post_link)), 'WHERE' => $topic_type . ' ' . $post_time . ' AND t.topic_status <> ' . ITEM_MOVED . ' AND t.topic_approved = 1 AND t.topic_moved_id = 0 ' . $str_where, 'ORDER_BY' => $topic_order); $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 'tp.topic_id = t.topic_id AND tp.user_id = ' . $user->data['user_id']); $sql_array['SELECT'] .= ', tp.topic_posted'; $sql = $db->sql_build_query('SELECT', $sql_array); if ($number_of_posts != 0) { $result = $db->sql_query_limit($sql, $number_of_posts, $start); } else { $result = $db->sql_query($sql); } // Instantiate BBCode if need be if ($bbcode_bitfield !== '') { $phpEx = substr(strrchr(__FILE__, '.'), 1); include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } $i = 0; while ($row = $db->sql_fetchrow($result)) { $attachments = array(); if ($config['allow_attachments']) { // Pull attachment data $sql2 = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE post_msg_id = ' . $row['post_id'] . ' AND in_message = 0 ORDER BY filetime DESC'; $result2 = $db->sql_query($sql2); while ($row2 = $db->sql_fetchrow($result2)) { $attachments[] = $row2; } $db->sql_freeresult($result2); } if ($row['user_id'] != ANONYMOUS && $row['user_colour']) { $row['username'] = '******' . $row['user_colour'] . '">' . $row['username'] . '</b> '; } $posts[$i]['bbcode_uid'] = $row['bbcode_uid']; $len_check = $row['post_text']; if ($text_length != 0 && utf8_strlen($len_check) > $text_length) { $message = utf8_substr($len_check, 0, $text_length); $message = str_replace("\n", '<br/> ', $message); $message .= ' ...'; $posts[$i]['striped'] = true; } else { $message = censor_text(str_replace("\n", '<br/> ', $row['post_text'])); } if ($auth->acl_get('f_html', $row['forum_id'])) { $message = preg_replace('#<!\\-\\-(.*?)\\-\\->#is', '', $message); // Remove Comments from post content } // Second parse bbcode here if ($row['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); } if (!empty($attachments)) { parse_attachments($row['forum_id'], $message, $attachments, $update_count); } if ($portal_config['portal_acronyms_allow'] = 1) { $phpEx = substr(strrchr(__FILE__, '.'), 1); include_once $phpbb_root_path . 'portal/includes/functions_acronym.' . $phpEx; $message = acronym_pass($message); } // dgTopic Thumb MOD - Added --> if ($row['topic_attachment']) { $sql2 = 'SELECT topic_first_post_id FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . $row['topic_id']; $dgresult_one_check_postid = $db->sql_query_limit($sql2, 1); $dgrow_one_check_postid = (int) $db->sql_fetchfield('topic_first_post_id'); $db->sql_freeresult($dgresult_one_check_postid); $sql2 = 'SELECT post_attachment FROM ' . POSTS_TABLE . ' WHERE post_id = ' . $dgrow_one_check_postid; $dgresult_one_postid_confirmed = $db->sql_query_limit($sql2, 1); $dgrow_one_postid_confirmed = (int) $db->sql_fetchfield('post_attachment'); $db->sql_freeresult($dgresult_one_postid_confirmed); $sql2 = 'SELECT post_attachment FROM ' . POSTS_TABLE . ' WHERE post_id = ' . $dgrow_one_check_postid; $dgresult_one = $db->sql_query_limit($sql2, 1); $dgrow_one = (int) $db->sql_fetchfield('post_attachment'); $db->sql_freeresult($dgresult_one); $sql2 = 'SELECT forum_topics_thumb_choice FROM ' . FORUMS_TABLE . ' WHERE forum_id =' . $row['forum_id']; $result2 = $db->sql_query_limit($sql2, 1); $rowchoice = (int) $db->sql_fetchfield('forum_topics_thumb_choice'); $topic_thumb_choice = $rowchoice; $db->sql_freeresult($result2); if ($dgrow_one == 1 && $topic_thumb_choice == 1) { $dgrow_one = 1; } else { $dgrow_one = 0; } if ($dgrow_one) { $posts[$i]['dgrow_one'] = 1; $sql2 = 'SELECT physical_filename FROM ' . ATTACHMENTS_TABLE . ' WHERE topic_id = ' . $row['topic_id']; $dgresult_two = $db->sql_query_limit($sql2, 1); $physical_thumb_name = $db->sql_fetchfield('physical_filename'); $db->sql_freeresult($dgresult_two); $sql2 = 'SELECT extension FROM ' . ATTACHMENTS_TABLE . ' WHERE topic_id =' . $row['topic_id']; $dgresult_last = $db->sql_query_limit($sql2, 1); $extension_name = $db->sql_fetchfield('extension'); $db->sql_freeresult($dgresult_last); $sql2 = 'SELECT attach_id FROM ' . ATTACHMENTS_TABLE . ' WHERE topic_id =' . $row['topic_id']; $dgresult_last = $db->sql_query_limit($sql2, 1); $attach_id = $db->sql_fetchfield('attach_id'); $db->sql_freeresult($dgresult_last); $topic_thumb_filename = $phpbb_root_path . 'download/file.php' . '?id=' . $attach_id . '&t=' . 2 . '&sid=' . $physical_thumb_name; } else { $posts[$i]['dgrow_one'] = 0; } } // dgTopic Thumb MOD - END --> $posts[$i]['topic_thumb_filename'] = $topic_thumb_filename; $message = smiley_text($message); // Always process smilies after parsing bbcodes $posts[$i] = array_merge($posts[$i], array('attachment' => $row['topic_attachment'] ? true : false, 'attachments' => !empty($attachments) ? $attachments : array(), 'bbcode_bitfield' => $row['bbcode_bitfield'], 'bbcode_uid' => $row['bbcode_uid'], 'enable_bbcode' => $row['enable_bbcode'], 'enable_magic_url' => $row['enable_magic_url'], 'enable_smilies' => $row['enable_smilies'], 'forum_id' => $row['forum_id'], 'forum_name' => $row['forum_name'], 'icon_id' => $row['icon_id'], 'poll_title' => $row['poll_title'] != '' ? true : false, 'post_approved' => $row['post_approved'], 'post_attachment' => !empty($attachments) ? $attachments : array(), 'post_id' => $row['post_id'], 'post_msg_id' => $row['post_msg_id'], 'post_subject' => $row['post_subject'], 'post_text' => $message, 'post_time' => $user->format_date($row['post_time']), 'real_filename' => $row['real_filename'], 'topic_approved' => $row['topic_approved'], 'topic_attachment' => $row['topic_attachment'], 'topic_first_post_id' => $row['topic_first_post_id'], 'topic_id' => $row['topic_id'], 'topic_last_post_id' => $row['topic_last_post_id'], 'topic_last_post_time' => $row['topic_last_post_time'], 'topic_poster' => $row['topic_poster'], 'topic_posted' => isset($row['topic_posted']) && $row['topic_posted'] ? true : false, 'topic_replies' => $row['topic_replies'], 'topic_replies_real' => $row['topic_replies_real'], 'topic_status' => $row['topic_status'], 'topic_time' => $user->format_date($row['post_time']), 'topic_title' => $row['topic_title'], 'topic_type' => $row['topic_type'], 'topic_views' => $row['topic_views'], 'user_colour' => $row['user_colour'], 'user_id' => $row['user_id'], 'user_rank' => $row['user_rank'], 'user_type' => $row['user_type'], 'username' => $row['username'], 'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $row['post_username']), 'username_full_last' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour'], $row['topic_last_poster_name']))); $posts[$i]['global_id'] = $global_f; $i++; } } } return $posts; }
function sgp_build_minimods() { global $phpbb_root_path, $user, $template, $db, $k_config, $config, $k_config, $phpEx; $block_cache_time = $k_config['block_cache_time_default']; $queries = $cached_queries = $i = $j = 0; $same_mod_count = 1; $stored_mod_type = $mod_type = ''; $mod_bbcode_bitfield = ''; $filename = ''; $select_allow = $config['override_user_style'] ? false : true; $sql = "SELECT * FROM " . K_MODULES_TABLE . "\n\t\t\tWHERE mod_status > 0\n\t\t\t\tORDER BY mod_type, mod_origin DESC "; if (!($result1 = $db->sql_query($sql, $block_cache_time))) { trigger_error($user->lang['ERROR_PORTAL_MENUS'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__); } $mod = array(); while ($row = $db->sql_fetchrow($result1)) { $mods[] = $row; } foreach ($mods as $mod) { $mod_type = $mod['mod_type']; switch ($mod['mod_download_count']) { case 0: $mod['mod_download_count'] = sprintf($user->lang['DOWNLOAD_COUNT_NONE'], $mod['mod_download_count']); break; case 1: $mod['mod_download_count'] = sprintf($user->lang['DOWNLOAD_COUNT'], $mod['mod_download_count']); break; default: $mod['mod_download_count'] = sprintf($user->lang['DOWNLOAD_COUNTS'], $mod['mod_download_count']); break; } if ($mod_type == $stored_mod_type) { $same_mod_count++; } else { $same_mod_count = 1; } $info = process_for_vars(htmlspecialchars_decode($mod['mod_details'])); $info = acronym_pass($info); $mod_bbcode_bitfield = $mod_bbcode_bitfield | base64_decode($mod['mod_bbcode_bitfield']); // Instantiate BBCode class if (!isset($bbcode) && $mod_bbcode_bitfield !== '') { if (!class_exists('bbcode')) { include $phpbb_root_path . 'includes/bbcode.' . $phpEx; } $bbcode = new bbcode(base64_encode($mod_bbcode_bitfield)); } if ($mod['mod_bbcode_bitfield']) { $bbcode->bbcode_second_pass($info, $mod['mod_bbcode_uid'], $mod['mod_bbcode_bitfield']); } $info = bbcode_nl2br($info); $info = smiley_text($info); $filename = $phpbb_root_path . 'download/file.php?name=' . $mod['mod_filename'] . '.zip'; // separate out our mods // if ($mod['mod_origin']) { $template->assign_block_vars('our_mod_' . $mod['mod_type'] . '_row', array('MOD_NAME' => $mod['mod_name'], 'MOD_TYPE' => $mod['mod_type'], 'MOD_ORIGIN' => $mod['mod_origin'], 'MOD_VERSION' => $mod['mod_version'], 'MOD_IMG' => $phpbb_root_path . 'images/style_thumbs/' . $mod['mod_thumb'], 'MOD_THUMB' => $phpbb_root_path . 'images/style_thumbs/thumbs/' . $mod['mod_thumb'], 'MOD_UPDATED' => $mod['mod_last_update'], 'MOD_AUTHOR' => $mod['mod_author'], 'MOD_AUTHOR_CO' => $mod['mod_author_co'], 'MOD_DETAILS' => $info, 'MOD_THIS' => $i++, 'MOD_COUNT' => $mod['mod_type'] == 'style' ? $j++ : $j, 'MOD_DOWNLOAD_COUNT' => $mod['mod_download_count'], 'MOD_STATUS' => k_progress_bar($mod['mod_status']), 'MOD_COUNT' => $same_mod_count, 'U_MOD_FILENAME' => $filename, 'U_MOD_LINK' => htmlspecialchars_decode($mod['mod_link']), 'U_MOD_SUPPORT' => htmlspecialchars_decode($mod['mod_support_link']), 'U_MOD_TEST_IT' => $mod['mod_link_id'] && $select_allow ? $phpbb_root_path . 'portal.php?style=' . $mod['mod_link_id'] : '')); } else { $template->assign_block_vars('mod_' . $mod['mod_type'] . '_row', array('MOD_NAME' => $mod['mod_name'], 'MOD_TYPE' => $mod['mod_type'], 'MOD_ORIGIN' => $mod['mod_origin'], 'MOD_VERSION' => $mod['mod_version'], 'MOD_IMG' => $phpbb_root_path . 'images/style_thumbs/' . $mod['mod_thumb'], 'MOD_THUMB' => $phpbb_root_path . 'images/style_thumbs/thumbs/' . $mod['mod_thumb'], 'MOD_UPDATED' => $mod['mod_last_update'], 'MOD_AUTHOR' => $mod['mod_author'], 'MOD_AUTHOR_CO' => $mod['mod_author_co'], 'MOD_DETAILS' => $info, 'MOD_THIS' => $i++, 'MOD_COUNT' => $mod['mod_type'] == 'style' ? $j++ : $j, 'MOD_DOWNLOAD_COUNT' => $mod['mod_download_count'], 'MOD_STATUS' => k_progress_bar($mod['mod_status']), 'MOD_COUNT' => $same_mod_count, 'U_MOD_FILENAME' => $filename, 'U_MOD_LINK' => htmlspecialchars_decode($mod['mod_link']), 'U_MOD_SUPPORT' => htmlspecialchars_decode($mod['mod_support_link']), 'U_MOD_TEST_IT' => $mod['mod_link_id'] && $select_allow ? $phpbb_root_path . 'portal.php?style=' . $mod['mod_link_id'] : '')); } $stored_mod_type = $mod['mod_type']; } $template->assign_vars(array('DOWNLOAD_IMG' => '<img src="' . $phpbb_root_path . 'images/2download-box-32.png" title="Download" alt="" />', 'TEST_IT_IMG' => '<img src="' . $phpbb_root_path . 'images/gnome-view-fullscreen-32.png" title="Check it out!" alt="" />', 'PINFO_IMG' => '<img src="' . $phpbb_root_path . 'images/information-32.png" title="Info" alt="" />')); }