function bb_anon_init()
{
    global $bb_roles;
    $perm_array = array('write_posts' => true, 'read' => true);
    if (bb_get_option('bb_anon_write_topics') == 'Y') {
        $perm_array['write_topics'] = true;
    }
    $bb_roles->add_role('anonymous', 'Anonymous', $perm_array);
    if ('bb-post' == bb_get_location()) {
        bb_anon_spoof_user();
    }
}
Example #2
0
function topic_icons_label($label)
{
    global $topic;
    if (bb_is_front() || bb_is_forum() || bb_is_view() || bb_is_tag()) {
        $icon_set_name = topic_icons_get_active_icon_set();
        $icon_set_url = ICON_SET_URL_BASE . $icon_set_name;
        $status = get_active_status_interpreter()->getStatus(bb_get_location(), $topic);
        $renderer = get_active_status_renderer();
        $image = $renderer->renderStatus($status);
        $tooltip = $renderer->renderStatusTooltip($status);
        $exists = file_exists(dirname(__FILE__) . '/icon-sets/' . $icon_set_name . '/' . $image);
        if (!$exists) {
            return sprintf(__('<div class="topic-icon-image"><a href="%s"><img src="%s" width="%s" height="%s" alt="%s" border="0"></a></div> %s'), get_topic_link($topic->topic_id), ICON_SET_URL_BASE . '/empty.png', ICON_WIDTH, ICON_HEIGHT, $tooltip, $label);
        } else {
            if (strlen($tooltip) > 0) {
                return sprintf(__('<div class="topic-icon-image"><a href="%s"><img src="%s" width="%s" height="%s" alt="%s" border="0"><span>%s</span></a></div> %s'), get_topic_link($topic->topic_id), $icon_set_url . '/' . $image, ICON_WIDTH, ICON_HEIGHT, $tooltip, $tooltip, $label);
            } else {
                return sprintf(__('<div class="topic-icon-image"><a href="%s"><img src="%s" width="%s" height="%s" alt="%s" border="0"></a></div> %s'), get_topic_link($topic->topic_id), $icon_set_url . '/' . $image, ICON_WIDTH, ICON_HEIGHT, $tooltip, $label);
            }
        }
    }
    return $label;
}
Example #3
0
function socialit_get_current_rss_link()
{
    switch (bb_get_location()) {
        case 'profile-page':
            if ($tab = isset($_GET['tab']) ? $_GET['tab'] : bb_get_path(2)) {
                if ($tab != 'favorites') {
                    break;
                }
            }
            $feed = get_favorites_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED);
            break;
        case 'topic-page':
            $feed = get_topic_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED);
            break;
        case 'tag-page':
            if (bb_is_tag()) {
                $feed = bb_get_tag_posts_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED);
            }
            break;
        case 'forum-page':
            $feed = bb_get_forum_posts_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED);
            break;
        case 'front-page':
            $feed = bb_get_posts_rss_link(BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED);
            break;
        case 'view-page':
            global $bb_views, $view;
            if ($bb_views[$view]['feed']) {
                $feed = bb_get_view_rss_link(null, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED);
            }
            break;
        default:
            $feed = bb_get_posts_rss_link(BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED);
            break;
    }
    return $feed;
}
Example #4
0
function bb_repermalink()
{
    global $page;
    $location = bb_get_location();
    $uri = $_SERVER['REQUEST_URI'];
    if (isset($_GET['id'])) {
        $id = $_GET['id'];
    } else {
        $id = bb_get_path();
    }
    $_original_id = $id;
    do_action('pre_permalink', $id);
    $id = apply_filters('bb_repermalink', $id);
    switch ($location) {
        case 'front-page':
            $path = null;
            $querystring = null;
            if ($page > 1) {
                if (bb_get_option('mod_rewrite')) {
                    $path = 'page/' . $page;
                } else {
                    $querystring = array('page' => $page);
                }
            }
            $permalink = bb_get_uri($path, $querystring, BB_URI_CONTEXT_HEADER);
            $issue_404 = true;
            break;
        case 'forum-page':
            if (empty($id)) {
                $permalink = bb_get_uri(null, null, BB_URI_CONTEXT_HEADER);
                break;
            }
            global $forum_id, $forum;
            $forum = bb_get_forum($id);
            $forum_id = $forum->forum_id;
            $permalink = get_forum_link($forum->forum_id, $page);
            break;
        case 'topic-edit-page':
        case 'topic-page':
            if (empty($id)) {
                $permalink = bb_get_uri(null, null, BB_URI_CONTEXT_HEADER);
                break;
            }
            global $topic_id, $topic;
            $topic = get_topic($id);
            $topic_id = $topic->topic_id;
            $permalink = get_topic_link($topic->topic_id, $page);
            break;
        case 'profile-page':
            // This handles the admin side of the profile as well.
            global $user_id, $user, $profile_hooks, $self;
            if (isset($_GET['id'])) {
                $id = $_GET['id'];
            } elseif (isset($_GET['username'])) {
                $id = $_GET['username'];
            } else {
                $id = bb_get_path();
            }
            $_original_id = $id;
            if (!$id) {
                $user = bb_get_current_user();
                // Attempt to go to the current users profile
            } else {
                if (bb_get_option('mod_rewrite') === 'slugs') {
                    if (!($user = bb_get_user_by_nicename($id))) {
                        $user = bb_get_user($id);
                    }
                } else {
                    if (!($user = bb_get_user($id))) {
                        $user = bb_get_user_by_nicename($id);
                    }
                }
            }
            if (!$user || 1 == $user->user_status && !bb_current_user_can('moderate')) {
                bb_die(__('User not found.'), '', 404);
            }
            $user_id = $user->ID;
            bb_global_profile_menu_structure();
            $valid = false;
            if ($tab = isset($_GET['tab']) ? $_GET['tab'] : bb_get_path(2)) {
                foreach ($profile_hooks as $valid_tab => $valid_file) {
                    if ($tab == $valid_tab) {
                        $valid = true;
                        $self = $valid_file;
                    }
                }
            }
            if ($valid) {
                $permalink = get_profile_tab_link($user->ID, $tab, $page);
            } else {
                $permalink = get_user_profile_link($user->ID, $page);
                unset($self, $tab);
            }
            break;
        case 'favorites-page':
            $permalink = get_favorites_link();
            break;
        case 'tag-page':
            // It's not an integer and tags.php pulls double duty.
            $id = isset($_GET['tag']) ? $_GET['tag'] : false;
            if (!$id || !bb_get_tag((string) $id)) {
                $permalink = bb_get_tag_page_link();
            } else {
                global $tag, $tag_name;
                $tag_name = $id;
                $tag = bb_get_tag((string) $id);
                $permalink = bb_get_tag_link(0, $page);
                // 0 => grabs $tag from global.
            }
            break;
        case 'view-page':
            // Not an integer
            if (isset($_GET['view'])) {
                $id = $_GET['view'];
            } else {
                $id = bb_get_path();
            }
            $_original_id = $id;
            global $view;
            $view = $id;
            $permalink = get_view_link($view, $page);
            break;
        default:
            return;
            break;
    }
    nxt_parse_str($_SERVER['QUERY_STRING'], $args);
    $args = urlencode_deep($args);
    if ($args) {
        $permalink = add_query_arg($args, $permalink);
        if (bb_get_option('mod_rewrite')) {
            $pretty_args = array('id', 'page', 'tag', 'tab', 'username');
            // these are already specified in the path
            if ($location == 'view-page') {
                $pretty_args[] = 'view';
            }
            foreach ($pretty_args as $pretty_arg) {
                $permalink = remove_query_arg($pretty_arg, $permalink);
            }
        }
    }
    $permalink = apply_filters('bb_repermalink_result', $permalink, $location);
    $domain = bb_get_option('domain');
    $domain = preg_replace('/^https?/', '', $domain);
    $check = preg_replace('|^.*' . trim($domain, ' /') . '|', '', $permalink, 1);
    $uri = rtrim($uri, " \t\n\r\v?");
    $uri = str_replace('/index.php', '/', $uri);
    global $bb_log;
    $bb_log->debug($uri, 'bb_repermalink() ' . __('REQUEST_URI'));
    $bb_log->debug($check, 'bb_repermalink() ' . __('should be'));
    $bb_log->debug($permalink, 'bb_repermalink() ' . __('full permalink'));
    $bb_log->debug(isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : null, 'bb_repermalink() ' . __('PATH_INFO'));
    if ($check != $uri && $check != str_replace(urlencode($_original_id), $_original_id, $uri)) {
        if ($issue_404 && rtrim($check, " \t\n\r\v/") !== rtrim($uri, " \t\n\r\v/")) {
            status_header(404);
            bb_load_template('404.php');
        } else {
            nxt_redirect($permalink);
        }
        exit;
    }
    do_action('post_permalink', $permalink);
}
function get_bb_location()
{
    bb_log_deprecated('function', __FUNCTION__, 'no alternative');
    $r = bb_get_location();
    if (!$r) {
        $r = apply_filters('get_bb_location', '');
    }
    // Deprecated filter
    return $r;
}
function bb_feed_head()
{
    $feeds = array();
    switch (bb_get_location()) {
        case 'profile-page':
            if ($tab = isset($_GET['tab']) ? $_GET['tab'] : bb_get_path(2)) {
                if ($tab != 'favorites') {
                    break;
                }
            }
            $feeds[] = array('title' => sprintf(__('%1$s &raquo; User Favorites: %2$s'), bb_get_option('name'), get_user_name()), 'href' => get_favorites_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED));
            break;
        case 'topic-page':
            $feeds[] = array('title' => sprintf(__('%1$s &raquo; Topic: %2$s'), bb_get_option('name'), get_topic_title()), 'href' => get_topic_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED));
            break;
        case 'tag-page':
            if (bb_is_tag()) {
                $feeds[] = array('title' => sprintf(__('%1$s &raquo; Tag: %2$s - Recent Posts'), bb_get_option('name'), bb_get_tag_name()), 'href' => bb_get_tag_posts_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED));
                $feeds[] = array('title' => sprintf(__('%1$s &raquo; Tag: %2$s - Recent Topics'), bb_get_option('name'), bb_get_tag_name()), 'href' => bb_get_tag_topics_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED));
            }
            break;
        case 'forum-page':
            $feeds[] = array('title' => sprintf(__('%1$s &raquo; Forum: %2$s - Recent Posts'), bb_get_option('name'), get_forum_name()), 'href' => bb_get_forum_posts_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED));
            $feeds[] = array('title' => sprintf(__('%1$s &raquo; Forum: %2$s - Recent Topics'), bb_get_option('name'), get_forum_name()), 'href' => bb_get_forum_topics_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED));
            break;
        case 'front-page':
            $feeds[] = array('title' => sprintf(__('%1$s &raquo; Recent Posts'), bb_get_option('name')), 'href' => bb_get_posts_rss_link(BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED));
            $feeds[] = array('title' => sprintf(__('%1$s &raquo; Recent Topics'), bb_get_option('name')), 'href' => bb_get_topics_rss_link(BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED));
            break;
        case 'view-page':
            global $bb_views, $view;
            if ($bb_views[$view]['feed']) {
                $feeds[] = array('title' => sprintf(__('%1$s &raquo; View: %2$s'), bb_get_option('name'), get_view_name()), 'href' => bb_get_view_rss_link(null, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED));
            }
            break;
    }
    if (count($feeds)) {
        $feed_links = array();
        foreach ($feeds as $feed) {
            $link = '<link rel="alternate" type="application/rss+xml" ';
            $link .= 'title="' . esc_attr($feed['title']) . '" ';
            $link .= 'href="' . esc_attr($feed['href']) . '" />';
            $feed_links[] = $link;
        }
        $feed_links = join("\n", $feed_links);
    } else {
        $feed_links = '';
    }
    echo apply_filters('bb_feed_head', $feed_links);
}
Example #7
0
"><?php 
bb_option('name');
?>
</a></h1>
			<?php 
if (bb_get_option('description')) {
    ?>
<p class="description"><?php 
    bb_option('description');
    ?>
</p><?php 
}
?>

<?php 
if (!in_array(bb_get_location(), array('login-page', 'register-page'))) {
    login_form();
}
?>

			<div class="search">
<?php 
search_form();
?>
			</div>
		</div>
		<div id="main">

<?php 
if (bb_is_profile()) {
    profile_menu();
Example #8
0
function oid_register()
{
    global $bbdb, $user_id, $openid_options;
    if (!bb_get_location() == "register-page") {
        return;
    }
    if (bb_is_user_logged_in()) {
        return;
    }
    /*
    echo "<p>Session:<br />";
    print_r($_SESSION);
    echo "</p>";
    */
    echo '<fieldset><legend>' . $openid_options['profile_text'] . '</legend>';
    if (!empty($_SESSION['OPENID']) && 0) {
        openid_session();
        $url = $_SESSION['OPENID'];
        $instructions = $openid_options['approved_text'];
        echo '<p>' . $instructions . '</p><table><tr class="form-field"><th scope="row" style="padding-left:20px;background: url(' . $openid_options['icon'] . ') no-repeat  50% 50%;">
		<label>[<a title="' . $openid_options['remove_text'] . '" href="' . add_query_arg('remove_openid', urlencode($url)) . '"><strong>x</strong></a>]</label></th><td> ' . $url . ' </td></tr>';
    } else {
        $value = "";
        $instructions = $openid_options['register_text'];
        if (isset($_GET['openid_error'])) {
            echo "<div  style='color:#000;width:75%;overflow:hidden;padding:3px 10px;background:#FFF6BF;border:1px solid #FFD324;'>" . substr(addslashes(strip_tags($_GET['openid_error'], "<br>")), 0, 200) . "</div>";
        }
        echo '<p>' . $instructions . '</p><table><tr class="form-field"><th scope="row"><label for="openid_url">OpenID</label></th>';
        echo '<td><input value="' . $value . '"  name="openid_identity" id="openid_identity"  style="padding-left:20px;  background: #fff url(' . $openid_options['icon'] . ') no-repeat center left;" type="text" />';
        if ($session_id = session_id()) {
            $session_name = session_name();
            echo '<input tabindex="0" type="hidden" name = "' . $session_name . '" value = "' . $session_id . '" />';
        }
        echo '</td></tr>';
    }
    // session else
    echo '</table></fieldset>';
}
Example #9
0
<?php

/*
Plugin Name: Terms of Service
Plugin URI:  http://bbpress.org/plugins/topic/117
Description:  Adds a "Terms of Service" (aka TOS) agreement to your registration page (and can optionally be linked to directly).
Version: 0.0.3
Author: _ck_
Author URI: http://bbshowcase.org

License: CC-GNU-GPL http://creativecommons.org/licenses/GPL/2.0/

Donate: http://bbshowcase.org/donate/
*/
if (bb_get_location() == "register-page") {
    // determines if we're actually on register.php and only hooks in that case
    add_action('extra_profile_info', 'terms_of_service', 20);
    // attach to register.php via extended profile info
    add_action('bb_send_headers', 'terms_of_service_check');
    // check before headers finish sending
}
if (isset($_GET['terms_of_service']) || isset($_GET['terms-of-service'])) {
    // check for direct link
    add_action('bb_init', 'terms_of_service_get');
}
function terms_of_service()
{
    // show the form
    echo '<fieldset><legend>' . __("Terms of Service") . '</legend>' . '<div id="terms_of_service" style="padding:0.5em 1em 1em 1em; margin:0em 3em; background: #eee; color: #000; overflow:auto; height:7em;">';
    @readfile(rtrim(dirname(__FILE__), ' /\\') . '/terms-of-service.html');
    echo '</div><table width="100%"><tr class="required"><th scope="row" nowrap><sup class="required" style="color:red;">*</sup> ' . __("I understand and agree:") . '</th><td width="72%">' . '<input name="terms_of_service" type="checkbox" id="terms_of_service" value="agree" />' . '</td></tr></table></fieldset>';
Example #10
0
<?php

if (in_array(bb_get_location(), array('search-page', 'profile-page', 'tag-page'))) {
    ?>
<div class="header-button ask-link"><a href="/answers/?new=1">Ask a Question</a></div>
<?php 
} else {
    ?>
<div class="header-button ask-link"><?php 
    bb_new_topic_link('Ask a Question');
    ?>
</div>
<?php 
}
?>
<!-- <div class="header-button profile-link"><?php 
bb_profile_link('My Profile');
?>
</div> -->
Example #11
0
        nospamuser_check('email', $email);
    }
    return $r;
}
function nospamuser_check_username($username)
{
    if ($username) {
        nospamuser_check('username', $username);
    }
    return $username;
}
function nospamuser_check_ip()
{
    nospamuser_check('ip', $_SERVER['REMOTE_ADDR']);
}
if (bb_get_location() == 'register-page') {
    nospamuser_check_ip();
    add_filter('sanitize_user', 'nospamuser_check_username');
    add_filter('is_email', 'nospamuser_check_email', 10, 3);
}
function nospamuser_check_bozo($user_id)
{
    // Most of this function is taken from Akismet
    $settings = bb_get_option('nospamuser-settings');
    if (empty($settings['api_key'])) {
        return;
    }
    global $bb_current_user, $user_obj;
    $bb_current_id = bb_get_current_user_info('id');
    bb_set_current_user($user_id);
    if ($bb_current_id && $bb_current_id != $user_id) {
Example #12
0
 function breadcrumbs()
 {
     $page = '';
     if (bb_get_location() == 'login-page') {
         $page = __('Log in', 'guangzhou');
     } elseif (is_forum()) {
         $page = get_forum_name();
     } elseif (is_bb_tags() && get_tag_name() != '') {
         $page = '<a href="' . bb_get_tag_page_link() . '">' . __('Tags') . '</a> &raquo; ' . get_tag_name();
     } elseif (is_topic()) {
         if (get_forum_name()) {
             $page = '<a href="' . get_forum_link() . '">' . get_forum_name() . '</a>';
         }
     }
     if ($page) {
         $page = '| ' . $page;
     }
     return '<a href="' . bb_get_option('uri') . '">' . bb_get_option('name') . '</a> ' . $page;
 }