예제 #1
0
/**
 * Check to make sure that a user is not making too many posts in a short amount of time.
 */
function bb_check_post_flood()
{
    global $bbdb;
    $user_id = (int) $user_id;
    $throttle_time = bb_get_option('throttle_time');
    if (bb_current_user_can('manage_options') || empty($throttle_time)) {
        return;
    }
    if (bb_is_user_logged_in()) {
        $bb_current_user = bb_get_current_user();
        if (isset($bb_current_user->data->last_posted) && time() < $bb_current_user->data->last_posted + $throttle_time && !bb_current_user_can('throttle')) {
            if (defined('DOING_AJAX') && DOING_AJAX) {
                die(__('Slow down; you move too fast.'));
            } else {
                bb_die(__('Slow down; you move too fast.'));
            }
        }
    } else {
        if (($last_posted = bb_get_transient($_SERVER['REMOTE_ADDR'] . '_last_posted')) && time() < $last_posted + $throttle_time) {
            if (defined('DOING_AJAX') && DOING_AJAX) {
                die(__('Slow down; you move too fast.'));
            } else {
                bb_die(__('Slow down; you move too fast.'));
            }
        }
    }
}
예제 #2
0
function thanks_output()
{
    global $bb_post, $DEFAULTS;
    $logged_in = bb_is_user_logged_in();
    $post_id = $bb_post->post_id;
    $user = bb_get_current_user();
    $uid = $logged_in ? (int) $user->ID : false;
    echo "<div class=\"thanks-output\" id=\"thanks-" . $post_id . "\">";
    echo thanks_output_details($post_id, $uid, $logged_in);
    echo "</div>";
}
 /**
  * Creates a random, one time use token.
  *
  * @since 2.0.4
  *
  * @param string|int $action Scalar value to add context to the nonce.
  * @return string The one use form token
  */
 function bb_create_nonce($action = -1)
 {
     $user = bb_get_current_user();
     $uid = (int) $user->ID;
     $i = bb_nonce_tick();
     return substr(bb_hash($i . $action . $uid, 'nonce'), -12, 10);
 }
예제 #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);
}
예제 #5
0
function bb_ksd_submit($submit, $type = false)
{
    global $bb_ksd_api_host;
    global $bb_ksd_api_port;
    switch ($type) {
        case 'ham':
        case 'spam':
            $path = '/1.1/submit-' . $type;
            $bb_post = bb_get_post($submit);
            if (!$bb_post) {
                return;
            }
            $user = bb_get_user($bb_post->poster_id);
            if (bb_is_trusted_user($user->ID)) {
                return;
            }
            $_submit = array('blog' => bb_get_uri(null, null, BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_AKISMET), 'user_ip' => $bb_post->poster_ip, 'permalink' => get_topic_link($bb_post->topic_id), 'comment_type' => 'forum', 'comment_author' => get_user_name($user->ID), 'comment_author_email' => bb_get_user_email($user->ID), 'comment_author_url' => get_user_link($user->ID), 'comment_content' => $bb_post->post_text, 'comment_date_gmt' => $bb_post->post_time);
            break;
        case 'hammer':
        case 'spammer':
            $path = '/1.1/submit-' . substr($type, 0, -3);
            $user = bb_get_user($submit);
            if (!$user) {
                return;
            }
            if (bb_is_trusted_user($user->ID)) {
                return;
            }
            $_submit = array('blog' => bb_get_uri(null, null, BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_AKISMET), 'permalink' => get_user_profile_link($user->ID), 'comment_type' => 'profile', 'comment_author' => get_user_name($user->ID), 'comment_author_email' => bb_get_user_email($user->ID), 'comment_author_url' => get_user_link($user->ID), 'comment_content' => $user->occ . ' ' . $user->interests, 'comment_date_gmt' => $user->user_registered);
            break;
        default:
            if (bb_is_trusted_user(bb_get_current_user())) {
                return;
            }
            $path = '/1.1/comment-check';
            $_submit = array('blog' => bb_get_uri(null, null, BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_AKISMET), 'user_ip' => preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']), 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'referrer' => $_SERVER['HTTP_REFERER'], 'comment_type' => isset($_POST['topic_id']) ? 'forum' : 'profile', 'comment_author' => bb_get_current_user_info('name'), 'comment_author_email' => bb_get_current_user_info('email'), 'comment_author_url' => bb_get_current_user_info('url'), 'comment_content' => $submit);
            if (isset($_POST['topic_id'])) {
                $_submit['permalink'] = get_topic_link($_POST['topic_id']);
                // First page
            }
            break;
    }
    $query_string = '';
    foreach ($_submit as $key => $data) {
        $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
    }
    return bb_ksd_http_post($query_string, $bb_ksd_api_host, $path, $bb_ksd_api_port);
}
function bb_get_current_user_info($key = '')
{
    if (!is_string($key)) {
        return;
    }
    if (!($user = bb_get_current_user())) {
        // Not globalized
        return false;
    }
    switch ($key) {
        case '':
            return $user;
            break;
        case 'id':
        case 'ID':
            return (int) $user->ID;
            break;
        case 'name':
            return get_user_display_name($user->ID);
            break;
        case 'login':
        case 'user_login':
            return get_user_name($user->ID);
            break;
        case 'email':
        case 'user_email':
            return bb_get_user_email($user->ID);
            break;
        case 'url':
        case 'uri':
        case 'user_url':
            return get_user_link($user->ID);
            break;
    }
}
예제 #7
0
/**
 * Delete the user settings of the current user.
 *
 * @package bbPress
 * @subpackage Meta
 * @since 1.0
 */
function bb_delete_all_user_settings()
{
    if (!($user = bb_get_current_user())) {
        return;
    }
    bb_delete_usermeta($user->ID, 'bb_user_settings');
    setcookie('bb-user-settings-' . $user->ID, ' ', time() - 31536000, $bb->cookiepath);
}
예제 #8
0
	ul#bbAdminMenu{ margin: 15px 5px 15px -85px; } body.bb-menu-folded div#bbBody{ margin-left: 110px; }
	</style>
	<![endif]-->
	<link rel="shortcut icon" type="image/ico" href="<?php 
bb_uri('bb-admin/images/favicon.ico', null, BB_URI_CONTEXT_BB_ADMIN);
?>
" />
	<script type="text/javascript">
		//<![CDATA[
		addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof nxtOnload!='function'){nxtOnload=func;}else{var oldonload=nxtOnload;nxtOnload=function(){oldonload();func();}}};
		var userSettings = {'url':'<?php 
echo $bb->cookie_path;
?>
','uid':'<?php 
if (!isset($bb_current_user)) {
    $bb_current_user = bb_get_current_user();
}
echo $bb_current_user->ID;
?>
','time':'<?php 
echo time();
?>
'};
		//]]>
	</script>
<?php 
do_action('bb_admin_head');
?>
</head>

<?php