示例#1
0
function bbld_widget($args)
{
    global $table_prefix, $wpdb;
    $forum_slimit = get_option('wpbb_limit');
    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 WHERE topic_status = 0 ORDER BY topic_time DESC LIMIT {$forum_slimit}");
    } else {
        $bbtopic = $wpdb->get_results("SELECT * FROM " . get_option('wpbb_bbprefix') . "topics WHERE topic_status = 0 ORDER BY topic_time DESC LIMIT {$forum_slimit}");
    }
    if ($bbtopic) {
        extract($args);
        echo $before_widget;
        echo $before_title . sprintf(__("Forum Last %d Discussions", 'bbpress'), $forum_slimit) . $after_title;
        echo '<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>";
        echo $after_widget;
    }
}
示例#2
0
function bbld_getside() {
	global $table_prefix,$wpdb,$user_data,$bbld_unwanted;
	$bbld_option = get_option('bbld_option');
	$bbtopic = bbld_getdata('topic',$bbld_option['limit']);
	$bb_meta = bbld_getdata('meta');
	$meta_value = $bb_meta->meta_value;
	if (!$meta_value) { $meta_value = 30;	}
	$bbld_template = get_option('bbld_template');
	if ($bbtopic) {
		foreach ( $bbtopic as $bbtopic ) {
			$title_text = strtr($bbtopic->topic_title, $bbld_unwanted);
			$title_text = wpbb_trim($title_text, $bbld_option['trim']);
			$forum_url = wpbb_permalink('forum',$bbtopic->forum_id,$bbtopic->forum_slug);
			$user_data = bbld_intergrated($bbtopic->topic_last_poster,$bbtopic->topic_last_poster_name,$bbtopic->user_email,$bbtopic->display_name);
			$template_data_sidebar = stripslashes($bbld_template['sidedisplay']);
			// Filter function
			$template_data_sidebar = apply_filters('bbld_sidebar', $template_data_sidebar);
			// Filter function
			$template_data_sidebar = str_replace("%BBLD_URL%", wpbb_permalink('topic',$bbtopic->topic_id,$bbtopic->topic_slug,$bbtopic->topic_posts,$meta_value,$bbtopic->forum_slug).'#post-'.$bbtopic->topic_last_post_id, $template_data_sidebar);
			$template_data_sidebar = str_replace("%BBLD_TOPIC%", $title_text, $template_data_sidebar);
			$template_data_sidebar = str_replace("%BBLD_POST%", $bbtopic->topic_posts, $template_data_sidebar);
			$template_data_sidebar = str_replace("%BBLD_FURL%", $forum_url, $template_data_sidebar);
			if ($user_data['email']) {
				$template_data_sidebar = str_replace("%GRAVATAR%", get_avatar($user_data['email'],32), $template_data_sidebar);
			}
			$forum_name = strtr($bbtopic->forum_name, $bbld_unwanted);
			$template_data_sidebar = str_replace("%BBLD_FORUM%", $forum_name, $template_data_sidebar);
			$template_data_sidebar = str_replace("%BBLD_LPOSTER%", $user_data['name'], $template_data_sidebar);
			echo $template_data_sidebar;
		}
	}
	else {
		echo '<p style="background: #ffebe8; border: 1px solid #c00; padding: 5px;">It Seem There Is Something Wrong With BBLD Configuration, Please Check It.</p>';
	}
}