Example #1
0
function wp_bb_get_discuss_sidebar()
{
    global $table_prefix, $wpdb;
    $forum_slimit = get_option('wpbb_limit');
    $filter = bbld_filter_forums();
    if (get_option('wpbb_exdb')) {
        $exbbdb = new wpdb(get_option('wpbb_dbuser'), get_option('wpbb_dbpass'), get_option('wpbb_dbname'), get_option('wpbb_dbhost'));
        $bbtopic = $exbbdb->get_results("SELECT * FROM " . get_option('wpbb_bbprefix') . "topics " . $filter . " ORDER BY topic_time DESC LIMIT {$forum_slimit}");
    } else {
        $bbtopic = $wpdb->get_results("SELECT * FROM " . get_option('wpbb_bbprefix') . "topics " . $filter . " ORDER BY topic_time DESC LIMIT {$forum_slimit}");
    }
    if ($bbtopic) {
        echo '
			<h2>' . sprintf(__("Forum Last %d Discussions", 'bbpress'), $forum_slimit) . '</h2>
			<ul>
		';
        foreach ($bbtopic as $bbtopic) {
            $title_text = wpbb_trim($bbtopic->topic_title, get_option('wpbb_slimit'));
            if (get_option('wpbb_exdb')) {
                $bbforum = $exbbdb->get_row("SELECT * FROM " . get_option('wpbb_bbprefix') . "forums WHERE forum_id = '{$bbtopic->forum_id}'");
            } else {
                $bbforum = $wpdb->get_row("SELECT * FROM " . get_option('wpbb_bbprefix') . "forums WHERE forum_id = '{$bbtopic->forum_id}'");
            }
            if (get_option('wpbb_permalink')) {
                echo '<li><a href="' . get_option('wpbb_path') . '/topic/' . $bbtopic->topic_id . '">' . __("{$title_text}", 'bbpress') . '</a><br />';
                $forum_url = get_option('wpbb_path') . '/forum/' . $bbtopic->forum_id;
            } else {
                echo '<li><a href="' . get_option('wpbb_path') . '/topic.php?id=' . $bbtopic->topic_id . '">' . __("{$title_text}", 'bbpress') . '</a><br />';
                $forum_url = get_option('wpbb_path') . '/forum.php?id=' . $bbtopic->forum_id;
            }
            if (get_option('wpbb_intergrated')) {
                $wpuid = $wpdb->get_row("SELECT * FROM " . $table_prefix . "users WHERE user_login = '******'");
                if ($wpuid) {
                    $user_forum_data = "{$bbtopic->topic_last_poster_name}";
                    $user_forum_data = get_userdata($wpuid->ID);
                    bbld_extra_info($user_forum_data->display_name, $bbforum->forum_name, $forum_url);
                    echo "</li>";
                } else {
                    bbld_extra_info($bbtopic->topic_last_poster_name, $bbforum->forum_name, $forum_url);
                    echo "</li>";
                }
            } else {
                bbld_extra_info($bbtopic->topic_last_poster_name, $bbforum->forum_name, $forum_url);
                echo "</li>";
            }
        }
        echo "</ul>";
    }
}
Example #2
0
function bbld_getdata($type,$forum_slimit = 0, $exclude = 0) {
	global $wpdb,$exbbdb,$table_prefix;
	$bbld_option = get_option('bbld_option');
	if ($bbld_option['exdb']) {
		$exbbdb = new wpdb($bbld_option['dbuser'], $bbld_option['dbpass'], $bbld_option['dbname'], $bbld_option['dbhost']);
	}
	if ($type == 'topic') {
		if ($exclude != 0) {
			$filter = "AND ".$bbld_option['prefix']."topics.forum_id IN ('$exclude')";
		}
		else {
			$filter = bbld_filter_forums();
		}
		if (!$bbld_option['share']) {
			$bbld_userdata = "JOIN ".$bbld_option['prefix']."users ON ".$bbld_option['prefix']."topics.topic_last_poster = ".$bbld_option['prefix']."users.ID";
		}
		if ($bbld_option['exdb']) {
			$bbtopic = $exbbdb->get_results("SELECT * FROM ".$bbld_option['prefix']."topics JOIN ".$bbld_option['prefix']."forums ON ".$bbld_option['prefix']."topics.topic_status = '0' AND ".$bbld_option['prefix']."topics.forum_id = ".$bbld_option['prefix']."forums.forum_id ".$bbld_userdata." ".$filter." ORDER BY topic_time DESC LIMIT $forum_slimit");
		}
		else {
			$bbtopic = $wpdb->get_results("SELECT * FROM ".$bbld_option['prefix']."topics JOIN ".$bbld_option['prefix']."forums ON ".$bbld_option['prefix']."topics.topic_status = '0' AND ".$bbld_option['prefix']."topics.forum_id = ".$bbld_option['prefix']."forums.forum_id ".$bbld_userdata." ".$filter." ORDER BY topic_time DESC LIMIT $forum_slimit");
		}
	}
	elseif ($type == 'utf8') {
		if ($bbld_option['exdb']) {
			$bbld_var = $exbbdb->get_var("SELECT count(*) FROM ".$bbld_option['prefix']."topics");
			$bbld_random = rand(1,$bbld_var);
			$bbtopic = $exbbdb->get_row("SELECT * FROM ".$bbld_option['prefix']."topics WHERE topic_id = ".$bbld_random." LIMIT 1");
		}
		else {
			$bbld_var = $wpdb->get_var("SELECT count(*) FROM ".$bbld_option['prefix']."topics");
			$bbld_random = rand(1,$bbld_var);
			$bbtopic = $wpdb->get_row("SELECT * FROM ".$bbld_option['prefix']."topics WHERE topic_id = ".$bbld_random." LIMIT 1");
		}
	}
	elseif ($type == 'meta') {
		if ($bbld_option['exdb']) {
			if ($bbld_option['9.0.4']) {
				$bbtopic = $exbbdb->get_row("SELECT * FROM ".$bbld_option['prefix']."topicmeta WHERE ".$bbld_option['prefix']."topicmeta.meta_key = 'page_topics' LIMIT 1");
			}
			else {
				$bbtopic = $exbbdb->get_row("SELECT * FROM ".$bbld_option['prefix']."meta WHERE ".$bbld_option['prefix']."meta.meta_key = 'page_topics' LIMIT 1");
			}
		}
		else {
			if ($bbld_option['9.0.4']) {
				$bbtopic = $wpdb->get_row("SELECT * FROM ".$bbld_option['prefix']."topicmeta WHERE ".$bbld_option['prefix']."topicmeta.meta_key = 'page_topics' LIMIT 1");
			}
			else {
				$bbtopic = $wpdb->get_row("SELECT * FROM ".$bbld_option['prefix']."meta WHERE ".$bbld_option['prefix']."meta.meta_key = 'page_topics' LIMIT 1");
			}
		}
	}
	else {
		if (!is_admin()) {
			$filter = bbld_filter_forums();
			$filter = str_replace("AND", "WHERE", $filter);
			$filter = str_replace("topics", "forums", $filter);
		}
		if ($bbld_option['exdb']) {
			$bbtopic = $exbbdb->get_results("SELECT * FROM ".$bbld_option['prefix']."forums ".$filter." ORDER BY forum_order ASC");
		}
		else {
			$bbtopic = $wpdb->get_results("SELECT * FROM ".$bbld_option['prefix']."forums ".$filter." ORDER BY forum_order ASC");
		}
	}
	return $bbtopic;
}