Exemple #1
0
                    bb_fix_password($user->ID);
                }
            }
            foreach ($profile_admin_keys as $key => $label) {
                if (${$key} != '' || isset($user->{$key})) {
                    bb_update_usermeta($user->ID, $key, ${$key});
                }
            }
            foreach ($assignable_caps as $cap => $label) {
                if (!($already = array_key_exists($cap, $user->capabilities)) && ${$cap}) {
                    $user_obj->add_cap($cap);
                } elseif (!${$cap} && $already) {
                    $user_obj->remove_cap($cap);
                }
            }
        }
        if (bb_current_user_can('change_user_password', $user->ID) && !empty($_POST['pass1'])) {
            $_POST['pass1'] = addslashes($_POST['pass1']);
            bb_update_user_password($user->ID, $_POST['pass1']);
            if (bb_get_current_user_info('ID') == $user->ID) {
                bb_clear_auth_cookie();
                bb_set_auth_cookie($user->ID);
            }
        }
        do_action('profile_edited', $user->ID);
        nxt_redirect(add_query_arg('updated', 'true', get_user_profile_link($user->ID)));
        exit;
    }
}
bb_load_template('profile-edit.php', array('profile_info_keys', 'profile_admin_keys', 'assignable_caps', 'user_email', 'bb_roles', 'errors', 'self'));
function topic_tags()
{
    global $tags, $tag, $topic_tag_cache, $user_tags, $other_tags, $topic;
    if (is_array($tags) || bb_current_user_can('edit_tag_by_on', bb_get_current_user_info('id'), $topic->topic_id)) {
        bb_load_template('topic-tags.php', array('user_tags', 'other_tags', 'public_tags'));
    }
}
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);
}
Exemple #4
0
            $posts = array();
            foreach ($topics as $topic) {
                $posts[] = bb_get_first_post($topic->topic_id);
            }
            $title = esc_html(sprintf(__('%1$s » Recent Topics'), bb_get_option('name')));
            $link = bb_get_uri();
            $link_self = bb_get_topics_rss_link();
            break;
            // Get latest posts by default
        // Get latest posts by default
        case 'all-posts':
        default:
            if (!($posts = bb_get_latest_posts(35))) {
                die;
            }
            $title = esc_html(sprintf(__('%1$s » Recent Posts'), bb_get_option('name')));
            $link = bb_get_uri();
            $link_self = bb_get_posts_rss_link();
            break;
    }
}
bb_send_304($posts[0]->post_time);
if (!($description = esc_html(bb_get_option('description')))) {
    $description = $title;
}
$title = apply_filters('bb_title_rss', $title, $feed);
$description = apply_filters('bb_description_rss', $description, $feed);
$posts = apply_filters('bb_posts_rss', $posts, $feed);
$link_self = apply_filters('bb_link_self_rss', $link_self, $feed);
bb_load_template('rss2.php', array('bb_db_override', 'title', 'description', 'link', 'link_self'), $feed);
Exemple #5
0
<?php

require './bb-load.php';
bb_auth('logged_in');
$post_id = (int) $_GET['id'];
$bb_post = bb_get_post($post_id);
if (!$bb_post || !bb_current_user_can('edit_post', $post_id)) {
    wp_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER));
    die;
}
if (0 != $bb_post->post_status && 'all' == $_GET['view']) {
    // We're trying to edit a deleted post
    add_filter('bb_is_first_where', 'bb_no_where');
}
$topic = get_topic($bb_post->topic_id);
if (bb_is_first($bb_post->post_id) && bb_current_user_can('edit_topic', $topic->topic_id)) {
    $topic_title = $topic->topic_title;
} else {
    $topic_title = false;
}
bb_load_template('edit-post.php', array('topic_title'));
Exemple #6
0
<?php

require './bb-load.php';
bb_repermalink();
$bb_db_override = false;
do_action('bb_index.php_pre_db');
if (isset($_GET['new']) && '1' == $_GET['new']) {
    $forums = false;
} elseif (!$bb_db_override) {
    $forums = bb_get_forums();
    // Comment to hide forums
    if ($topics = get_latest_topics(false, $page)) {
        bb_cache_last_posts($topics);
    }
    if ($super_stickies = get_sticky_topics()) {
        bb_cache_last_posts($super_stickies);
    }
}
bb_load_template('front-page.php', array('bb_db_override', 'super_stickies'));
<?php

require './bb-load.php';
require_once BB_PATH . BB_INC . 'functions.bb-statistics.php';
$popular = get_popular_topics();
$bb->static_title = __('Statistics');
bb_load_template('stats.php', array('popular'));
<?php

require_once './bb-load.php';
$user_id = bb_get_current_user_info('id');
if (!bb_is_profile()) {
    $sendto = get_profile_tab_link($user_id, 'edit');
    nxt_redirect($sendto);
    exit;
}
do_action($self . '_pre_head');
if (is_callable($self)) {
    bb_load_template('profile-base.php', array('self'), $user_id);
}
exit;
Exemple #9
0
<?php

require_once './bb-load.php';
$forum_id = 0;
bb_repermalink();
if (!$forum) {
    bb_die(__('Forum not found.'));
}
$bb_db_override = false;
do_action('bb_forum.php_pre_db', $forum_id);
if (!$bb_db_override) {
    if ($topics = get_latest_topics($forum_id, $page)) {
        bb_cache_last_posts($topics);
    }
    if ($stickies = get_sticky_topics($forum_id, $page)) {
        bb_cache_last_posts($stickies);
    }
}
bb_load_template('forum.php', array('bb_db_override', 'stickies'), $forum_id);
Exemple #10
0
    if (!$bad_input) {
        $user_id = bb_new_user($user_login, $_POST['user_email'], $_POST['user_url']);
        if (is_wp_error($user_id)) {
            // error
            foreach ($user_id->get_error_codes() as $code) {
                $bb_register_error->add($code, $user_id->get_error_message($code));
            }
            if ($bb_register_error->get_error_message('user_login')) {
                $user_safe = false;
            }
        } elseif ($user_id) {
            // success
            foreach ($profile_info_keys as $key => $label) {
                if (strpos($key, 'user_') !== 0 && ${$key} !== '') {
                    bb_update_usermeta($user_id, $key, ${$key});
                }
            }
            do_action('register_user', $user_id);
            bb_load_template('register-success.php', $_globals);
            exit;
        }
        // else failure
    }
}
if (isset($_GET['user'])) {
    $user_login = sanitize_user($_GET['user'], true);
} elseif (isset($_POST['user_login']) && !is_string($user_login)) {
    $user_login = '';
}
bb_load_template('register.php', $_globals);
Exemple #11
0
}
// Check for errors on post method
if ('post' == strtolower($_SERVER['REQUEST_METHOD'])) {
    // If the user doesn't exist then add that error
    if (empty($user_exists)) {
        if (!empty($_POST['log'])) {
            $bb_login_error->add('user_login', __('User does not exist.'));
        } else {
            $bb_login_error->add('user_login', $email_login ? __('Enter a username or email address.') : __('Enter a username.'));
        }
    }
    // If the password was wrong then add that error
    if (!$bb_login_error->get_error_code()) {
        $bb_login_error->add('password', __('Incorrect password.'));
    }
}
/**
 * If trying to log in with email address, don't leak whether or not email
 * address exists in the db. is_email() is not perfect. Usernames can be
 * valid email addresses potentially.
 */
if (!empty($email_login) && $bb_login_error->get_error_codes() && false !== is_email(@$_POST['log'])) {
    $bb_login_error = new WP_Error('user_login', __('Username and Password do not match.'));
}
/** Prepare for display *******************************************************/
// Sanitze variables for display
$remember_checked = @$_POST['rememberme'] ? ' checked="checked"' : '';
$user_login = esc_attr(sanitize_user(@$_POST['log'], true));
// Load the template
bb_load_template('login.php', array('user_exists', 'user_login', 'remember_checked', 'redirect_to', 're', 'bb_login_error'));
exit;
Exemple #12
0
<?php

require_once './bb-load.php';
bb_repermalink();
$view = bb_slug_sanitize($view);
$sticky_count = $topic_count = 0;
$stickies = $topics = $view_count = false;
if (isset($bb_views[$view])) {
    if ($bb_views[$view]['sticky']) {
        $sticky_query = bb_view_query($view, array('sticky' => '-no'));
        // -no = yes
        $stickies = $sticky_query->results;
        $sticky_count = $sticky_query->found_rows;
    }
    $topic_query = bb_view_query($view, array('count' => true));
    $topics = $topic_query->results;
    $topic_count = $topic_query->found_rows;
    $view_count = max($sticky_count, $topic_count);
}
do_action('bb_custom_view', $view, $page);
bb_load_template('view.php', array('view_count', 'stickies'), $view);
Exemple #13
0
<?php

require_once './bb-load.php';
if (!($q = trim(@$_GET['search']))) {
    $q = trim(@$_GET['q']);
}
$bb_query_form = new BB_Query_Form();
if ($q = stripslashes($q)) {
    add_filter('bb_recent_search_fields', create_function('$f', 'return $f . ", MAX(post_time) AS post_time";'));
    add_filter('bb_recent_search_group_by', create_function('', 'return "t.topic_id";'));
    $bb_query_form->BB_Query_Form('post', array(), array('per_page' => 5, 'post_status' => 0, 'topic_status' => 0, 'post_text' => $q, 'forum_id', 'tag', 'topic_author', 'post_author'), 'bb_recent_search');
    $recent = $bb_query_form->results;
    $bb_query_form->BB_Query_Form('topic', array('search' => $q), array('post_status' => 0, 'topic_status' => 0, 'search', 'forum_id', 'tag', 'topic_author', 'post_author'), 'bb_relevant_search');
    $relevant = $bb_query_form->results;
    $q = $bb_query_form->get('search');
}
do_action('do_search', $q);
// Cache topics
// NOT bbdb::prepared
if ($recent) {
    $topic_ids = array();
    foreach ($recent as $bb_post) {
        $topic_ids[] = (int) $bb_post->topic_id;
    }
    $topic_ids = join($topic_ids);
    if ($topics = $bbdb->get_results("SELECT * FROM {$bbdb->topics} WHERE topic_id IN ({$topic_ids})")) {
        $topics = bb_append_meta($topics, 'topic');
    }
}
bb_load_template('search.php', array('q', 'recent', 'relevant'), $q);
Exemple #14
0
bb_repermalink();
if (!$topic) {
    bb_die(__('Topic not found.'));
}
if ($view_deleted) {
    add_filter('get_thread_where', create_function('', 'return "p.topic_id = ' . $topic_id . '";'));
    add_filter('get_thread_post_ids', create_function('', 'return "p.topic_id = ' . $topic_id . '";'));
    add_filter('post_edit_uri', 'bb_make_link_view_all');
}
$bb_db_override = false;
do_action('bb_topic.php_pre_db', $topic_id);
if (!$bb_db_override) {
    $posts = get_thread($topic_id, $page);
    $forum = bb_get_forum($topic->forum_id);
    $tags = bb_get_topic_tags($topic_id);
    if ($tags && ($bb_current_id = bb_get_current_user_info('id'))) {
        $user_tags = bb_get_user_tags($topic_id, $bb_current_id);
        $other_tags = bb_get_other_tags($topic_id, $bb_current_id);
        $public_tags = bb_get_public_tags($topic_id);
    } elseif (is_array($tags)) {
        $user_tags = false;
        $other_tags = bb_get_public_tags($topic_id);
        $public_tags =& $other_tags;
    } else {
        $user_tags = $other_tags = $public_tags = false;
    }
    $list_start = ($page - 1) * bb_get_option('page_topics') + 1;
    bb_post_author_cache($posts);
}
bb_load_template('topic.php', array('bb_db_override', 'user_tags', 'other_tags', 'list_start'), $topic_id);
Exemple #15
0
<?php

require_once './bb-load.php';
bb_repermalink();
// Temporary, refactor this!
if (!$tag && $tag_name) {
    bb_die(__('Tag not found'));
}
if ($tag_name && $tag) {
    if ($topics = get_tagged_topics($tag->tag_id, $page)) {
        bb_cache_last_posts($topics);
    }
    bb_load_template('tag-single.php', array('tag', 'tag_name', 'topics'), $tag->tag_id);
} else {
    bb_load_template('tags.php');
}
<?php

require './bb-load.php';
$error = false;
if ($_POST) {
    $action = 'send_key';
    $user_login = sanitize_user($_POST['user_login'], true);
    if (empty($user_login)) {
        $error = __('No username specified');
    } else {
        $send_key_result = bb_reset_email($user_login);
        if (is_nxt_error($send_key_result)) {
            $error = $send_key_result->get_error_message();
        }
    }
} elseif (isset($_GET['key'])) {
    $action = 'reset_password';
    $reset_pasword_result = bb_reset_password($_GET['key']);
    if (is_nxt_error($reset_pasword_result)) {
        $error = $reset_pasword_result->get_error_message();
    }
}
bb_load_template('password-reset.php', array('action', 'error'));
Exemple #17
0
<?php

require_once './bb-load.php';
bb_repermalink();
// The magic happens here.
if ($self) {
    if (strpos($self, '.php') !== false) {
        require $self;
    } else {
        require BB_PATH . 'profile-base.php';
    }
    return;
}
$reg_time = bb_gmtstrtotime($user->user_registered);
$profile_info_keys = bb_get_profile_info_keys();
if (!isset($_GET['updated'])) {
    $updated = false;
} else {
    $updated = true;
}
do_action('bb_profile.php_pre_db', $user_id);
if (isset($user->is_bozo) && $user->is_bozo && $user->ID != bb_get_current_user_info('id') && !bb_current_user_can('moderate')) {
    $profile_info_keys = array();
}
$posts = bb_get_recent_user_replies($user_id);
$topics = get_recent_user_threads($user_id);
bb_load_template('profile.php', array('reg_time', 'profile_info_keys', 'updated', 'threads'), $user_id);
<?php

if (!bb_get_user(get_post_author_id())) {
    ?>

	<?php 
    bb_load_template('post-form-anonymous.php');
    ?>

<?php 
}
?>

<?php 
if ($topic_title) {
    ?>
<p role="main">
	<label for="topic"><?php 
    _e('Topic:');
    ?>
<br />
		<input name="topic" type="text" id="topic" size="50" maxlength="80" tabindex="31" value="<?php 
    echo esc_attr(get_topic_title());
    ?>
" />
	</label>
</p>
<?php 
}
do_action('edit_form_pre_post');
?>
Exemple #19
0
$bb_query_form = new BB_Query_Form();
if ($q = stripslashes($q)) {
    $per_page = ceil((int) bb_get_option('page_topics') / 2);
    /* Recent */
    add_filter('bb_recent_search_fields', create_function('$f', 'return $f . ", MAX(post_time) AS post_time";'));
    add_filter('bb_recent_search_group_by', create_function('', 'return "t.topic_id";'));
    $bb_query_form->BB_Query_Form('post', array(), array('order_by' => 'p.post_time', 'count' => true, 'per_page' => $per_page, 'post_status' => 0, 'topic_status' => 0, 'post_text' => $q, 'forum_id', 'tag', 'topic_author', 'post_author'), 'bb_recent_search');
    $recent = $bb_query_form->results;
    $recent_count = $recent ? $bb_query_form->found_rows : 0;
    /* Relevant */
    $bb_query_form->BB_Query_Form('topic', array('search' => $q), array('per_page' => $per_page, 'count' => true, 'post_status' => 0, 'topic_status' => 0, 'search', 'forum_id', 'tag', 'topic_author', 'post_author'), 'bb_relevant_search');
    $relevant = $bb_query_form->results;
    $relevant_count = $relevant ? $bb_query_form->found_rows : 0;
    $search_count = max($recent_count, $relevant_count);
    $q = $bb_query_form->get('search');
}
do_action('do_search', $q);
// Cache topics
// NOT bbdb::prepared
if ($recent) {
    $topic_ids = array();
    foreach ($recent as $bb_post) {
        $topic_ids[] = (int) $bb_post->topic_id;
    }
    $topic_ids = join($topic_ids);
    if ($topics = $bbdb->get_results("SELECT * FROM {$bbdb->topics} WHERE topic_id IN ({$topic_ids})")) {
        $topics = bb_append_meta($topics, 'topic');
    }
}
bb_load_template('search.php', array('q', 'recent', 'relevant', 'per_page', 'search_count'), $q);
Exemple #20
0
    $fav = (int) $_GET['fav'];
    $topic_id = (int) $_GET['topic_id'];
    bb_check_admin_referer('toggle-favorite_' . $topic_id);
    $topic = get_topic($topic_id);
    if (!$topic || 0 != $topic->topic_status) {
        exit;
    }
    if ($fav) {
        bb_add_user_favorite($user_id, $topic_id);
    } else {
        bb_remove_user_favorite($user_id, $topic_id);
    }
    $ref = wp_get_referer();
    if (false !== strpos($ref, bb_get_uri(null, null, BB_URI_CONTEXT_TEXT))) {
        bb_safe_redirect($ref);
    } else {
        wp_redirect(get_topic_link($topic_id));
    }
    exit;
}
if (!bb_is_profile()) {
    $sendto = get_profile_tab_link($user->ID, 'favorites');
    wp_redirect($sendto);
    exit;
}
if ($topics = get_user_favorites($user->ID, true)) {
    bb_cache_last_posts($topics);
}
$favorites_total = isset($user->favorites) ? count(explode(',', $user->favorites)) : 0;
bb_load_template('favorites.php', array('favorites_total', 'self'));