function get_wpu_latest_blogposts($args = '') { global $wpuAbs, $wpdb; $defaults = array('limit' => '20', 'before' => '<li>', 'after' => '</li>'); extract(_wpu_process_args($args, $defaults)); if ('' != $limit) { $limit = (int) $limit; $limit_sql = ' LIMIT ' . $limit; } $orderby_sql = "post_date DESC "; $posts = $wpdb->get_results("SELECT ID, post_author, post_title FROM {$wpdb->posts} \n\t\tWHERE post_type = 'post' \n\t\tAND post_author <> 1\n\t\tAND post_status = 'publish' \n\t\tORDER BY {$orderby_sql} \n\t\t{$limit_sql}"); if ($posts) { $htmlOut = ''; foreach ($posts as $post) { $lastPostTitle = wpu_censor(strip_tags($post->post_title)); $blogTitle = wpu_censor(strip_tags(get_usermeta($post->post_author, 'blog_title'))); $blogTitle = $blogTitle == '' ? $wpuAbs->lang('default_blogname') : $blogTitle; $lastPostURL = get_permalink($post->ID); if (function_exists('get_author_posts_url')) { //WP >= 2.1 branch $blogPath = get_author_posts_url($post->post_author); } else { //deprecated branch $blogPath = get_author_link(false, $author->post_author); } $postLink = get_archives_link($lastPostURL, $lastPostTitle, '', $before, ''); $blogLink = get_archives_link($blogPath, $blogTitle, '', '', $after); $htmlOut .= sprintf(__('%s, in %s'), trim($postLink), $blogLink); } return $htmlOut; } }
function wpu_content_parse_check($postContent) { if (!defined('PHPBB_CONTENT_ONLY')) { if (!(strpos($postContent, "<!--wp-united-home-->") === FALSE)) { $postContent = get_wpu_blogs_home(); } else { $postContent = wpu_censor($postContent); } } else { global $pfContent, $phpbb_preString, $phpbb_postString; $postContent = $phpbb_preString . $pfContent . $phpbb_postString; $GLOBALS['pfContent'] = null; } return $postContent; }
function get_recent_topics($forum_list = '', $limit = 50) { global $db, $auth; $GLOBALS['wpUtdInt']->switch_db('TO_P'); if ($this->ver == 'PHPBB2') { $forum_sql = $forum_list == '' ? '' : 't.forum_id IN (' . $forum_list . ') AND '; $sql = 'SELECT t.topic_id, t.topic_time, t.topic_title, u.username, u.user_id, t.topic_replies, t.forum_id, t.topic_poster, t.topic_status, f.forum_name FROM ' . TOPICS_TABLE . ' AS t, ' . USERS_TABLE . ' AS u, ' . FORUMS_TABLE . ' AS f WHERE ' . $forum_sql . ' t.topic_poster = u.user_id AND f.auth_read = 0 AND t.forum_id = f.forum_id AND t.topic_status <> 2 ORDER BY t.topic_time DESC LIMIT 0,' . $limit; if (!($result = $db->sql_query($sql))) { $this->err_msg(GENERAL_ERROR, 'Could not query phpbb database', '', __LINE__, __FILE__, $sql); } } else { //PHPBB3 version $forum_list = empty($forum_list) ? array() : explode(',', $forum_list); //forums to explicitly check $forums_check = array_unique(array_keys($auth->acl_getf('f_read', true))); //forums authorised to read posts in if (sizeof($forum_list)) { $forums_check = array_intersect($forums_check, $forum_list); } if (!sizeof($forums_check)) { return FALSE; } $sql = 'SELECT t.topic_id, t.topic_time, t.topic_title, u.username, u.user_id, t.topic_replies, t.forum_id, t.topic_poster, t.topic_status, f.forum_name FROM ' . TOPICS_TABLE . ' AS t, ' . USERS_TABLE . ' AS u, ' . FORUMS_TABLE . ' AS f WHERE ' . $db->sql_in_set('f.forum_id', $forums_check) . ' AND t.topic_poster = u.user_id AND t.forum_id = f.forum_id AND t.topic_status <> 2 ORDER BY t.topic_time DESC'; if (!($result = $db->sql_query_limit($sql, $limit, 0))) { $this->err_msg(GENERAL_ERROR, 'Could not query phpbb database', '', __LINE__, __FILE__, $sql); } } // The rest is the same for both versions: $posts = array(); $i = 0; while ($row = $db->sql_fetchrow($result)) { $posts[$i] = array('topic_id' => $row['topic_id'], 'topic_replies' => $row['topic_replies'], 'topic_title' => wpu_censor($row['topic_title']), 'user_id' => $row['user_id'], 'username' => $row['username'], 'forum_id' => $row['forum_id'], 'forum_name' => $row['forum_name']); $i++; } $db->sql_freeresult($result); $GLOBALS['wpUtdInt']->switch_db('TO_W'); return $posts; }