function notification_is_activated($user_id) { $user = bb_get_user($user_id); if ($user->favorite_notification) { return true; } else { return false; } }
function mod_notification_is_activated($user_id) { $user = bb_get_user($user_id); if (!empty($user->mod_notification)) { return true; } else { return false; } }
function icon($comment) { if (bb_get_option('avatars_show')) { echo '<div class="gravatar">'; $user = bb_get_user($comment->poster_id); if ($user->user_url) { echo '<a href="' . $user->user_url . '">'; } echo bb_get_avatar($user->user_email, 40); if ($user->user_url) { echo '</a>'; } echo '</div>'; } }
/** * Links the users & tags in posts * * @see bp_activity_at_name_filter() BuddyPress Function * * @param $content The content to be parsed */ function em_do_linking($content) { global $em_plugopts; if ($em_plugopts['link-tags'] == 1) { preg_match_all('/[#]+([A-Za-z0-9-_]+)/', $content, $tags); $tags = $tags[1]; foreach ((array) $tags as $tag) { if (!($t = bb_get_tag($tag))) { continue; } if ($link = bb_get_tag_link($t)) { $content = str_replace("#{$tag}", "#<a href='" . $link . "'>{$tag}</a>", $content); } //should we add rel='nofollow'? } } if ($em_plugopts['link-users'] == 1) { preg_match_all('/[@]+([A-Za-z0-9-_]+)/', $content, $usernames); $usernames = $usernames[1]; foreach ((array) $usernames as $username) { if (!($user = bb_get_user($username, array('by' => 'login')))) { //check #1, by username if (!($user = bb_get_user($username, array('by' => 'nicename')))) { //check #2, by nicename continue; } } /* Increase the number of new @ mentions for the user - maybe later */ /*$new_mention_count = (int)bb_get_usermeta( $user_id, 'em_mention_count' ); bb_update_usermeta( $user_id, 'em_mention_count', $new_mention_count + 1 );*/ if ('website' == $em_plugopts['link-user-to']) { if (!($link = $user->user_url)) { $link = get_user_profile_link($user->ID); } } else { $link = get_user_profile_link($user->ID); } if ($link) { $content = str_replace("@{$username}", "@<a href='" . $link . "'>{$username}</a>", $content); } //should we add rel='nofollow'? } } return $content; }
function add_twitter_to_profile_edit() { global $user_id, $bb_current_user, $bb_twitter; if (bb_current_user_can('edit_profile', $user->ID) && bb_is_user_logged_in()) { $twitter = fetch_user_twitter($user_id); $user = bb_get_user($user_id); $tweets_on = $user->twitter_on; $tweets_on_post = $user->twitter_on_post; ?> <fieldset> <legend><?php _e('Twitter'); ?> </legend> <table border=0> <tr> <th>Twitter username : </th><td><input type="text" name="twitter" value="<?php echo $twitter; ?> " size="25"/></td> </tr> <?php if (false) { ?> <tr> <td>Show your latest <em>tweet</em> in your profile?</td><td> <input name="show_tweets" value="tweets_on" type="checkbox" checked="checked"/></td> <input name="show_tweets" value="tweets_on" type="checkbox"/></td> </tr> <tr> <td>Show your latest <em>tweet</em> under each post?</td><td> <input name="show_tweets_post" value="tweets_on_post" type="checkbox" checked="checked"/></td> <input name="show_tweets_post" value="tweets_on_post" type="checkbox"/></td> <?php } ?> </tr> </table> </fieldset> <?php } }
function thanks_output_details($post_id, $uid, $logged_in = true) { $out = ""; $meta = bb_get_post_meta("thanks", $post_id); $report_length = 0; if (isset($meta)) { $vote_count = count($meta); $msg_type = $vote_count == 0 ? "none" : ($vote_count == 1 ? "one" : "many"); $msg = thanks_get_voting_phrase("thanks_output_" . $msg_type); $report_length = strlen($msg); $out .= str_replace("#", "" . $vote_count, $msg); $should_show_voters = thanks_get_voting_phrase("thanks_voters"); if ($should_show_voters == "yes") { $out .= ' ' . thanks_get_voting_phrase("thanks_voters_prefix"); for ($i = 0; $i < count($meta); $i++) { $link = get_user_profile_link($meta[$i]); $voter = bb_get_user($meta[$i]); if ($i > 0) { $out .= ", "; } $out .= '<a href="' . $link . '">' . $voter->display_name . '</a>'; } $out .= thanks_get_voting_phrase("thanks_voters_suffix"); } } if ($logged_in) { if (!in_array($uid, $meta)) { if (isset($meta) && $report_length > 0) { $out .= " | "; } $msg = thanks_get_voting_phrase("thanks_voting"); $out .= "<a class=\"thanks-vote\" user=\"" . $uid . "\" id=\"" . $post_id . "\">" . $msg . "</a>"; } } return $out; }
function auto_add_favorit_profile() { global $user_id; if (bb_is_user_logged_in()) { $checked = ""; $user = bb_get_user($user_id); if (!empty($user->auto_add_favorit)) { $checked = ' checked="checked"'; } echo ' <fieldset> <legend>Add my threads automatically to my favorites</legend> <p>Check this option to add all your threads or threads where you have posted something to your favorite list.</p> <table width="100%"> <tr> <th width="21%" scope="row">Activate:</th> <td width="79%"> <input name="edit_auto_add_favorit" id="edit_auto_add_favorit" type="checkbox" value="1"' . $checked . ' /> </td> </tr> </table> </fieldset>'; } }
function bb_export_user($user_id) { global $bbdb; if (!($_user = bb_get_user($user_id))) { return; } $_user = get_object_vars($_user); $atts = array('type' => 'user', 'id' => $_user['ID']); // ?url means url is optional. Only include it in the export if it exists // !title means the title should be wrapped in CDATA // ?! is the correct order, not !? $translate = array('user_login' => 'login', 'user_pass' => 'pass', 'user_email' => 'email', 'user_url' => '?url', 'user_registered' => 'incept', 'display_name' => '?!title', 'user_nicename' => '?nicename', 'user_status' => '?status', 'ID' => false); $user = _bb_translate_for_export($translate, $_user); $meta = array(); foreach ($_user as $k => $v) { if (0 !== strpos($k, $bbdb->prefix) && isset($_user[$bbdb->prefix . $k])) { continue; } $meta[$k] = maybe_serialize($v); } unset($_user, $k, $v); $user['meta'] = $meta; return _bb_export_object($atts, $user); }
function get_user($user_id, $use_cache = true) { bb_log_deprecated('class::function', __CLASS__ . '::' . __FUNCTION__, 'bb_get_user'); return bb_get_user($user_id); }
function get_favorites_rss_link($id = 0, $context = 0) { $user = bb_get_user(bb_get_user_id($id)); if (!$context || !is_integer($context)) { $context = BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_FEED; } $rewrite = bb_get_option('mod_rewrite'); if ($rewrite) { if ($rewrite === 'slugs') { $column = 'user_nicename'; } else { $column = 'ID'; } $link = bb_get_uri('rss/profile/' . $user->{$column}, null, $context); } else { $link = bb_get_uri('rss.php', array('profile' => $user->ID), $context); } return apply_filters('get_favorites_rss_link', $link, $user->ID, $context); }
$bb_post = bb_get_post($post_id); if (!$bb_post) { nxt_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER)); die; } if (!bb_current_user_can('edit_post', $post_id)) { bb_die(__('Sorry, post is too old.')); } bb_check_admin_referer('edit-post_' . $post_id); 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'); } // Check possible anonymous user data $post_author = $post_email = $post_url = ''; if (!bb_get_user(get_post_author_id($post_id))) { if (!($post_author = sanitize_user(trim($_POST['author'])))) { bb_die(__('Every post needs an author name!')); } elseif (!($post_email = sanitize_email(trim($_POST['email'])))) { bb_die(__('Every post needs a valid email address!')); } if (!empty($_POST['url'])) { $post_url = esc_url(trim($_POST['url'])); } } // Loop through possible anonymous post data foreach (array('post_author', 'post_email', 'post_url') as $field) { if (!empty(${$field})) { $post_data[$field] = ${$field}; } }
case 'topic': if (!($topic = get_topic($feed_id))) { die; } if (!($posts = get_thread($feed_id, 0, 1))) { die; } $title = esc_html(sprintf(__('%1$s » Topic: %2$s'), bb_get_option('name'), get_topic_title())); $link = get_topic_link($feed_id); $link_self = get_topic_rss_link($feed_id); break; case 'profile': if (bb_get_option('mod_rewrite') === 'slugs') { $user = bb_get_user_by_nicename($feed_id); } else { $user = bb_get_user($feed_id); } if (!$user) { die; } if (!($posts = get_user_favorites($user->ID))) { die; } $title = esc_html(sprintf(__('%1$s » User Favorites: %2$s'), bb_get_option('name'), $user->user_login)); $link = bb_get_profile_link($feed_id); $link_self = get_favorites_rss_link($feed_id); break; case 'tag-topics': if (!($tag = bb_get_tag($feed_id))) { die; }
function blocklist_check($post_id = 0, $wall = false) { if (bb_current_user_can('moderate') || bb_current_user_can('throttle')) { return; } if ($wall) { $bb_post = user_wall_get_post($post_id); } else { $bb_post = bb_get_post($post_id); } if (empty($post_id) || empty($bb_post) || !empty($bb_post->post_status)) { return; } global $blocklist, $bbdb; blocklist_initialize(); if (empty($blocklist['data'])) { return; } (array) ($data = explode("\r\n", $blocklist['data'])); $user = bb_get_user($bb_post->poster_id); foreach ($data as $item) { if (empty($item) || strlen($item) < 4 || ord($item) == 35) { continue; } if (preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/', $item)) { // is IP if (strpos($bb_post->poster_ip, $item) === 0) { $found = "IP address"; $bad = $item; break; } } else { // is word $qitem = preg_quote($item); if (preg_match('/\\b' . $qitem . '/simU', $user->user_email)) { $found = "email"; $bad = $item; break; } if (preg_match('/\\b' . $qitem . '/simU', $user->user_login)) { $found = "username"; $bad = $item; break; } if (preg_match('/\\b' . $qitem . '/simU', $bb_post->post_text)) { $found = "post text"; $bad = $item; break; } elseif (!$wall && $bb_post->post_position == 1) { if (empty($topic)) { $topic = get_topic($bb_post->topic_id); } if (!empty($topic->topic_title) && preg_match('/\\b' . $qitem . '/simU', $topic->topic_title)) { $found = "topic title"; $bad = $item; break; } } } if (!empty($bad)) { break; } } if (!empty($bad)) { if ($wall) { user_wall_delete_post($post_id, 2); $uri = bb_get_option('uri') . "bb-admin/admin-base.php?post_status=2&plugin=user_wall_admin&user-wall-recent=1"; } else { bb_delete_post($post_id, 2); if (empty($topic)) { $topic = get_topic($bb_post->topic_id); } if (empty($topic->topic_posts)) { bb_delete_topic($topic->topic_id, 2); } // if no posts in topic, also set topic to spam $uri = bb_get_option('uri') . 'bb-admin/' . (defined('BACKPRESS_PATH') ? '' : 'content-') . 'posts.php?post_status=2'; } if (empty($blocklist['email'])) { return; } (array) ($email = explode("\r\n", $blocklist['email'])); $message = "The blocklist has been triggered... \r\n\r\n"; $message .= "Matching entry " . '"' . $bad . '"' . " found in {$found}.\r\n"; $message .= "{$uri}\r\n\r\n"; $message .= sprintf(__('Username: %s'), stripslashes($user->user_login)) . "\r\n"; $message .= sprintf(__('Profile: %s'), get_user_profile_link($user->ID)) . "\r\n"; $message .= sprintf(__('Email: %s'), stripslashes($user->user_email)) . "\r\n"; $message .= sprintf(__('IP address: %s'), $_SERVER['REMOTE_ADDR']) . "\r\n"; $message .= sprintf(__('Agent: %s'), substr(stripslashes($_SERVER["HTTP_USER_AGENT"]), 0, 255)) . "\r\n\r\n"; foreach ($email as $to) { if (empty($to) || strlen($to) < 8) { continue; } @bb_mail($to, "[" . bb_get_option('name') . "] blocklist triggered", $message); } } }
<?php require_once 'admin.php'; $edit_user = bb_get_user(bb_get_user_id($_GET['user_id'])); $user_fields = bb_manage_user_fields($edit_user); // Let it rip! // Header $bb_admin_body_class = 'bb-admin-user-manage'; bb_get_admin_header(); ?> <div class="wrap"> <h2><?php _e('Add a new user'); ?> </h2> <?php do_action('bb_admin_notices'); ?> <form class="settings" method="post" action=""> <fieldset> <?php foreach ($user_fields as $field => $args) { bb_option_form_element($field, $args); } ?> <noscript> <?php _e('Disabled (requires JavaScript)');
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 generate_post_sql($_part_of_topic_query = false) { global $bbdb; $q =& $this->query_vars; $distinct = ''; $sql_calc_found_rows = 'found_rows' === $q['count'] ? 'SQL_CALC_FOUND_ROWS' : ''; // unfiltered $fields = 'p.*'; $index_hint = ''; $join = ''; $where = ''; $group_by = ''; $having = ''; $order_by = ''; $topic_where = ''; $topic_queries = array('topic_author_id', 'topic_author', 'topic_status', 'post_count', 'tag_count', 'started', 'updated', 'open', 'sticky', 'meta_key', 'meta_value', 'topic_title'); if (!$_part_of_topic_query && array_diff($topic_queries, $this->not_set)) { $join .= " JOIN {$bbdb->topics} as t ON ( t.topic_id = p.topic_id )"; $topic_where = $this->generate_topic_sql(true); } if (!$_part_of_topic_query) { if ($q['post_id']) { $where .= $this->parse_value('p.post_id', $q['post_id']); } if ($q['topic_id']) { $where .= $this->parse_value('p.topic_id', $q['topic_id']); } elseif ($q['topic']) { if (!($q['topic_id'] = bb_get_id_from_slug('topic', $q['topic']))) { $this->error('query_var:topic', 'No topic by that name'); } $where .= " AND p.topic_id = " . $q['topic_id']; } if ($q['forum_id']) { $where .= $this->parse_value('p.forum_id', $q['forum_id']); } elseif ($q['forum']) { if (!($q['forum_id'] = bb_get_id_from_slug('forum', $q['forum']))) { $this->error('query_var:forum', 'No forum by that name'); } $where .= " AND p.forum_id = " . $q['forum_id']; } if ($q['tag'] && !is_int($q['tag_id'])) { $q['tag_id'] = (int) bb_get_tag_id($q['tag']); } if (is_numeric($q['tag_id'])) { $join .= " JOIN `{$bbdb->term_relationships}` AS tr ON ( p.`topic_id` = tr.`object_id` AND tr.`term_taxonomy_id` = {$q['tag_id']} )"; } if (is_numeric($q['favorites']) && ($f_user = bb_get_user($q['favorites']))) { $where .= $this->parse_value('p.topic_id', $f_user->favorites); } } // !_part_of_topic_query if ($q['post_text']) { $where .= ' AND ' . $this->generate_post_text_sql($q['post_text']); if ($this->match_query) { $fields .= ", {$this->match_query} AS search_score"; if (!$q['order_by']) { $q['order_by'] = 'search_score'; } } else { $fields .= ', 0 AS search_score'; } } if ($q['posted']) { $where .= $this->date('p.post_time', $q['posted']); } if ($q['post_author_id']) { $where .= $this->parse_value('p.poster_id', $q['post_author_id']); } elseif ($q['post_author']) { $user = bb_get_user($q['post_author'], array('by' => 'login')); if (!($q['post_author_id'] = (int) $user->ID)) { $this->error('query_var:user', 'No user by that name'); } $where .= " AND p.poster_id = {$q['post_author_id']}"; } if (!$q['post_status']) { $where .= " AND p.post_status = '0'"; } elseif (false === strpos($q['post_status'], 'all')) { $stati = array('normal' => 0, 'deleted' => 1); $q['post_status'] = str_replace(array_keys($stati), array_values($stati), $q['post_status']); $where .= $this->parse_value('p.post_status', $q['post_status']); } if (false !== $q['position']) { $where .= $this->parse_value('p.post_position', $q['position']); } if (false !== $q['poster_ip']) { $where .= " AND poster_ip = '" . $q['poster_ip'] . "'"; } // Just getting post part for inclusion in topic query if ($_part_of_topic_query) { return $where; } $where .= $topic_where; if ($where) { // Get rid of initial " AND " (this is pre-filters) $where = substr($where, 5); } if ($q['index_hint']) { $index_hint = $q['index_hint']; } if ($q['order_by']) { $order_by = $q['order_by']; } else { $order_by = 'p.post_time'; } $bits = compact(array('distinct', 'sql_calc_found_rows', 'fields', 'index_hint', 'join', 'where', 'group_by', 'having', 'order_by')); $this->request = $this->_filter_sql($bits, "{$bbdb->posts} AS p"); return $this->request; }
/** * Finalises the installation by creating the database and writing all the supplied data to the database. * * @return void **/ function process_form_finalise_installation() { require_once BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php'; require_once BB_PATH . 'bb-admin/includes/functions.bb-admin.php'; $this->inject_form_values_into_data(2); $this->inject_form_values_into_data(3); $data2 =& $this->data[2]['form']; $data3 =& $this->data[3]['form']; $data4 =& $this->data[4]['form']; $error_log = array(); $installation_log = array(); // Check the referer bb_check_admin_referer('bbpress-installer'); $installation_log[] = __('Referrer is OK, beginning installation…'); global $bbdb; // Setup user table variables and constants if available if ($data2['toggle_2_2']['value']) { $installation_log[] = '>>> ' . __('Setting up custom user table constants'); global $bb; global $bb_table_prefix; if (!empty($data2['wp_table_prefix']['value'])) { $bb->wp_table_prefix = $data2['wp_table_prefix']['value']; } if (!empty($data2['user_bbdb_name']['value'])) { $bb->user_bbdb_name = $data2['user_bbdb_name']['value']; } if (!empty($data2['user_bbdb_user']['value'])) { $bb->user_bbdb_user = $data2['user_bbdb_user']['value']; } if (!empty($data2['user_bbdb_password']['value'])) { $bb->user_bbdb_password = $data2['user_bbdb_password']['value']; } if (!empty($data2['user_bbdb_host']['value'])) { $bb->user_bbdb_host = $data2['user_bbdb_host']['value']; } if (!empty($data2['user_bbdb_charset']['value'])) { $bb->user_bbdb_charset = preg_replace('/[^a-z0-9_-]/i', '', $data2['user_bbdb_charset']['value']); } if (!empty($data2['user_bbdb_collate']['value'])) { $bb->user_bbdb_collate = preg_replace('/[^a-z0-9_-]/i', '', $data2['user_bbdb_collate']['value']); } bb_set_custom_user_tables(); // Add custom user database if required if (isset($bb->custom_databases['user'])) { $bbdb->add_db_server('user', $bb->custom_databases['user']); } // Add custom tables if required if (isset($bb->custom_tables)) { $bbdb->tables = array_merge($bbdb->tables, $bb->custom_tables); if (is_wp_error($bbdb->set_prefix($bb_table_prefix))) { die(__('Your user table prefix may only contain letters, numbers and underscores.')); } } } // Create the database $installation_log[] = "\n" . __('Step 1 - Creating database tables'); if (!$this->database_tables_are_installed()) { // Hide db errors $bbdb->hide_errors(); // Install the database $alterations = bb_install(); // Show db errors $bbdb->show_errors(); if (isset($alterations['errors']) && is_array($alterations['errors'])) { $error_log = array_merge($error_log, $alterations['errors']); } if (isset($alterations['messages']) && is_array($alterations['messages'])) { $installation_log = array_merge($installation_log, $alterations['messages']); } if (!$this->database_tables_are_installed()) { $installation_log[] = '>>> ' . __('Database installation failed!!!'); $installation_log[] = '>>>>>> ' . __('Halting installation!'); $error_log[] = __('Database installation failed!!!'); $this->step_status[4] = 'incomplete'; $this->strings[4]['h2'] = __('Installation failed!'); $this->strings[4]['messages']['error'][] = __('The database failed to install. You may need to replace bbPress with a fresh copy and start again.'); $data4['installation_log']['value'] = join("\n", $installation_log); $data4['error_log']['value'] = join("\n", $error_log); return 'incomplete'; } } else { $installation_log[] = '>>> ' . __('Database is already installed!!!'); } // Integration settings passed from step 2 // These are already validated provided that the referer checks out $installation_log[] = "\n" . __('Step 2 - WordPress integration (optional)'); if ($data2['toggle_2_0']['value']) { if ($data2['toggle_2_1']['value']) { bb_update_option('wp_siteurl', $data2['wp_siteurl']['value']); $installation_log[] = '>>> ' . __('WordPress address (URL):') . ' ' . $data2['wp_siteurl']['value']; bb_update_option('wp_home', $data2['wp_home']['value']); $installation_log[] = '>>> ' . __('Blog address (URL):') . ' ' . $data2['wp_home']['value']; $config_result = $this->write_lines_to_file(BB_PATH . 'bb-config.php', false, array("define( 'BB_AUTH_KEY" => array("'" . BB_AUTH_KEY . "'", "'" . $data2['wp_auth_key']['value'] . "'"), "define( 'BB_SECURE_A" => array("'" . BB_SECURE_AUTH_KEY . "'", "'" . $data2['wp_secure_auth_key']['value'] . "'"), "define( 'BB_LOGGED_I" => array("'" . BB_LOGGED_IN_KEY . "'", "'" . $data2['wp_logged_in_key']['value'] . "'"))); switch ($config_result) { case 1: $installation_log[] = '>>> ' . __('WordPress cookie keys set.'); break; default: $error_log[] = '>>> ' . __('WordPress cookie keys not set.'); $error_log[] = '>>>>>> ' . __('Your "bb-config.php" file was not writable.'); $error_log[] = '>>>>>> ' . __('You will need to manually re-define "BB_AUTH_KEY", "BB_SECURE_AUTH_KEY" and "BB_LOGGED_IN_KEY" in your "bb-config.php" file.'); $installation_log[] = '>>> ' . __('WordPress cookie keys not set.'); break; } if (!empty($data2['wp_auth_salt']['value'])) { bb_update_option('bb_auth_salt', $data2['wp_auth_salt']['value']); $installation_log[] = '>>> ' . __('WordPress "auth" cookie salt set from input.'); } if (!empty($data2['wp_secure_auth_salt']['value'])) { bb_update_option('bb_secure_auth_salt', $data2['wp_secure_auth_salt']['value']); $installation_log[] = '>>> ' . __('WordPress "secure auth" cookie salt set from input.'); } if (!empty($data2['wp_logged_in_salt']['value'])) { bb_update_option('bb_logged_in_salt', $data2['wp_logged_in_salt']['value']); $installation_log[] = '>>> ' . __('WordPress "logged in" cookie salt set from input.'); } } if ($data2['toggle_2_2']['value']) { if (!bb_get_option('bb_auth_salt') || !bb_get_option('bb_secure_auth_salt') || !bb_get_option('bb_logged_in_salt')) { $installation_log[] = '>>> ' . __('Fetching missing WordPress cookie salts.'); $_prefix = $bb->wp_table_prefix; if (!empty($data2['wordpress_mu_primary_blog_id']['value'])) { $_prefix .= $data2['wordpress_mu_primary_blog_id']['value'] . '_'; } if (isset($bb->custom_databases['user'])) { $bbdb->tables['options'] = array('user', $_prefix . 'options'); } else { $bbdb->tables['options'] = $_prefix . 'options'; } unset($_prefix); $bbdb->set_prefix($bb_table_prefix); if (!bb_get_option('bb_auth_salt')) { $wp_auth_salt = $bbdb->get_var("SELECT `option_value` FROM {$bbdb->options} WHERE `option_name` = 'auth_salt' LIMIT 1"); if ($wp_auth_salt) { bb_update_option('bb_auth_salt', $wp_auth_salt); $installation_log[] = '>>>>>> ' . __('WordPress "auth" cookie salt set.'); } else { $error_log[] = '>>> ' . __('WordPress "auth" cookie salt not set.'); $error_log[] = '>>>>>> ' . __('Could not fetch "auth" cookie salt from the WordPress options table.'); $error_log[] = '>>>>>> ' . __('You will need to manually define the "auth" cookie salt in your database.'); $installation_log[] = '>>>>>> ' . __('WordPress "auth" cookie salt not set.'); } } if (!bb_get_option('bb_secure_auth_salt')) { $wp_secure_auth_salt = $bbdb->get_var("SELECT `option_value` FROM {$bbdb->options} WHERE `option_name` = 'secure_auth_salt' LIMIT 1"); if ($wp_secure_auth_salt) { bb_update_option('bb_secure_auth_salt', $wp_secure_auth_salt); $installation_log[] = '>>>>>> ' . __('WordPress "secure auth" cookie salt set.'); } else { // This cookie salt is sometimes empty so don't error $installation_log[] = '>>>>>> ' . __('WordPress "secure auth" cookie salt not set.'); } } if (!bb_get_option('bb_logged_in_salt')) { $wp_logged_in_salt = $bbdb->get_var("SELECT `option_value` FROM {$bbdb->options} WHERE `option_name` = 'logged_in_salt' LIMIT 1"); if ($wp_logged_in_salt) { bb_update_option('bb_logged_in_salt', $wp_logged_in_salt); $installation_log[] = '>>>>>> ' . __('WordPress "logged in" cookie salt set.'); } else { $error_log[] = '>>> ' . __('WordPress "logged in" cookie salt not set.'); $error_log[] = '>>>>>> ' . __('Could not fetch "logged in" cookie salt from the WordPress options table.'); $error_log[] = '>>>>>> ' . __('You will need to manually define the "logged in" cookie salt in your database.'); $installation_log[] = '>>>>>> ' . __('WordPress "logged in" cookie salt not set.'); } } } if (!empty($data2['wp_table_prefix']['value'])) { bb_update_option('wp_table_prefix', $data2['wp_table_prefix']['value']); $installation_log[] = '>>> ' . __('User database table prefix:') . ' ' . $data2['wp_table_prefix']['value']; } if (!empty($data2['wordpress_mu_primary_blog_id']['value'])) { bb_update_option('wordpress_mu_primary_blog_id', $data2['wordpress_mu_primary_blog_id']['value']); $installation_log[] = '>>> ' . __('WordPress MU primary blog ID:') . ' ' . $data2['wordpress_mu_primary_blog_id']['value']; } if ($data2['toggle_2_3']['value']) { if (!empty($data2['user_bbdb_name']['value'])) { bb_update_option('user_bbdb_name', $data2['user_bbdb_name']['value']); $installation_log[] = '>>> ' . __('User database name:') . ' ' . $data2['user_bbdb_name']['value']; } if (!empty($data2['user_bbdb_user']['value'])) { bb_update_option('user_bbdb_user', $data2['user_bbdb_user']['value']); $installation_log[] = '>>> ' . __('User database user:'******' ' . $data2['user_bbdb_user']['value']; } if (!empty($data2['user_bbdb_password']['value'])) { bb_update_option('user_bbdb_password', $data2['user_bbdb_password']['value']); $installation_log[] = '>>> ' . __('User database password:'******' ' . $data2['user_bbdb_password']['value']; } if (!empty($data2['user_bbdb_host']['value'])) { bb_update_option('user_bbdb_host', $data2['user_bbdb_host']['value']); $installation_log[] = '>>> ' . __('User database host:') . ' ' . $data2['user_bbdb_host']['value']; } if (!empty($data2['user_bbdb_charset']['value'])) { bb_update_option('user_bbdb_charset', $data2['user_bbdb_charset']['value']); $installation_log[] = '>>> ' . __('User database character set:') . ' ' . $data2['user_bbdb_charset']['value']; } if (!empty($data2['user_bbdb_collate']['value'])) { bb_update_option('user_bbdb_collate', $data2['user_bbdb_collate']['value']); $installation_log[] = '>>> ' . __('User database collation:') . ' ' . $data2['user_bbdb_collate']['value']; } if (!empty($data2['custom_user_table']['value'])) { bb_update_option('custom_user_table', $data2['custom_user_table']['value']); $installation_log[] = '>>> ' . __('User database "user" table:') . ' ' . $data2['custom_user_table']['value']; } if (!empty($data2['custom_user_meta_table']['value'])) { bb_update_option('custom_user_meta_table', $data2['custom_user_meta_table']['value']); $installation_log[] = '>>> ' . __('User database "user meta" table:') . ' ' . $data2['custom_user_meta_table']['value']; } } } } else { $installation_log[] = '>>> ' . __('Integration not enabled'); } // Site settings passed from step 3 // These are already validated provided that the referer checks out $installation_log[] = "\n" . __('Step 3 - Site settings'); bb_update_option('name', $data3['name']['value']); $installation_log[] = '>>> ' . __('Site name:') . ' ' . $data3['name']['value']; bb_update_option('uri', $data3['uri']['value']); $installation_log[] = '>>> ' . __('Site address (URL):') . ' ' . $data3['uri']['value']; bb_update_option('from_email', $data3['keymaster_user_email']['value']); $installation_log[] = '>>> ' . __('From email address:') . ' ' . $data3['keymaster_user_email']['value']; // Create the key master $keymaster_created = false; switch ($data3['keymaster_user_type']['value']) { case 'new': // Check to see if the user login already exists if ($keymaster_user = bb_get_user($data3['keymaster_user_login']['value'], array('by' => 'login'))) { // The keymaster is an existing bbPress user $installation_log[] = '>>> ' . __('Key master could not be created!'); $installation_log[] = '>>>>>> ' . __('That login is already taken!'); $error_log[] = __('Key master could not be created!'); if ($keymaster_user->bb_capabilities['keymaster']) { // The existing user is a key master - continue $bb_current_user = bb_set_current_user($keymaster_user->ID); $installation_log[] = '>>>>>> ' . __('Existing key master entered!'); $data4['keymaster_user_password']['value'] = __('Your bbPress password'); $data3['keymaster_user_email']['value'] = $keymaster_user->user_email; bb_update_option('from_email', $keymaster_user->user_email); $installation_log[] = '>>>>>> ' . __('Re-setting admin email address.'); $keymaster_created = true; } else { // The existing user is a non-key master user - halt installation $installation_log[] = '>>>>>> ' . __('Existing user without key master role entered!'); $installation_log[] = '>>>>>>>>> ' . __('Halting installation!'); $this->step_status[4] = 'incomplete'; $this->strings[4]['h2'] = __('Installation failed!'); $this->strings[4]['messages']['error'][] = __('The key master could not be created. An existing user was found with that user login.'); $data4['installation_log']['value'] = join("\n", $installation_log); $data4['error_log']['value'] = join("\n", $error_log); return 'incomplete'; } break; } // Helper function to let us know the password that was created global $keymaster_password; function bb_get_keymaster_password($user_id, $pass) { global $keymaster_password; $keymaster_password = $pass; } add_action('bb_new_user', 'bb_get_keymaster_password', 10, 2); // Create the new user (automattically given key master role when BB_INSTALLING is true) if ($keymaster_user_id = bb_new_user($data3['keymaster_user_login']['value'], $data3['keymaster_user_email']['value'], '')) { $bb_current_user = bb_set_current_user($keymaster_user_id); $data4['keymaster_user_password']['value'] = $keymaster_password; $installation_log[] = '>>> ' . __('Key master created'); $installation_log[] = '>>>>>> ' . __('Username:'******' ' . $data3['keymaster_user_login']['value']; $installation_log[] = '>>>>>> ' . __('Email address:') . ' ' . $data3['keymaster_user_email']['value']; $installation_log[] = '>>>>>> ' . __('Password:'******' ' . $data4['keymaster_user_password']['value']; $keymaster_created = true; } else { $installation_log[] = '>>> ' . __('Key master could not be created!'); $installation_log[] = '>>>>>> ' . __('Halting installation!'); $error_log[] = __('Key master could not be created!'); $this->step_status[4] = 'incomplete'; $this->strings[4]['h2'] = __('Installation failed!'); $this->strings[4]['messages']['error'][] = __('The key master could not be created. You may need to replace bbPress with a fresh copy and start again.'); $data4['installation_log']['value'] = join("\n", $installation_log); $data4['error_log']['value'] = join("\n", $error_log); return 'incomplete'; } break; case 'old': if ($keymaster_user = bb_get_user($data3['keymaster_user_login']['value'], array('by' => 'login'))) { // The keymaster is an existing bbPress or WordPress user $bb_current_user = bb_set_current_user($keymaster_user->ID); $bb_current_user->set_role('keymaster'); $data4['keymaster_user_password']['value'] = __('Your existing password'); $installation_log[] = '>>> ' . __('Key master role assigned to existing user'); $installation_log[] = '>>>>>> ' . __('Username:'******' ' . $data3['keymaster_user_login']['value']; $installation_log[] = '>>>>>> ' . __('Email address:') . ' ' . $data3['keymaster_user_email']['value']; $installation_log[] = '>>>>>> ' . __('Password:'******' ' . $data4['keymaster_user_password']['value']; $keymaster_created = true; } else { $installation_log[] = '>>> ' . __('Key master role could not be assigned to existing user!'); $installation_log[] = '>>>>>> ' . __('Halting installation!'); $error_log[] = __('Key master could not be created!'); $this->step_status[4] = 'incomplete'; $this->strings[4]['h2'] = __('Installation failed!'); $this->strings[4]['messages']['error'][] = __('The key master could not be assigned. You may need to replace bbPress with a fresh copy and start again.'); $data4['installation_log']['value'] = join("\n", $installation_log); $data4['error_log']['value'] = join("\n", $error_log); return 'incomplete'; } break; } // Don't create an initial forum if any forums already exist if (!$bbdb->get_results('SELECT `forum_id` FROM `' . $bbdb->forums . '` LIMIT 1;')) { if ($this->language != BB_LANG) { global $locale, $l10n; $locale = BB_LANG; unset($l10n['default']); bb_load_default_textdomain(); } $description = __('Just another bbPress community'); bb_update_option('description', $description); if ($this->language != BB_LANG) { $locale = $this->language; unset($l10n['default']); bb_load_default_textdomain(); } $installation_log[] = '>>> ' . __('Description:') . ' ' . $description; if ($forum_id = bb_new_forum(array('forum_name' => $data3['forum_name']['value']))) { $installation_log[] = '>>> ' . __('Forum name:') . ' ' . $data3['forum_name']['value']; if ($this->language != BB_LANG) { $locale = BB_LANG; unset($l10n['default']); bb_load_default_textdomain(); } $topic_title = __('Your first topic'); $topic_id = bb_insert_topic(array('topic_title' => $topic_title, 'forum_id' => $forum_id, 'tags' => 'bbPress')); $post_text = __('First Post! w00t.'); bb_insert_post(array('topic_id' => $topic_id, 'post_text' => $post_text)); if ($this->language != BB_LANG) { $locale = $this->language; unset($l10n['default']); bb_load_default_textdomain(); } $installation_log[] = '>>>>>> ' . __('Topic:') . ' ' . $topic_title; $installation_log[] = '>>>>>>>>> ' . __('Post:') . ' ' . $post_text; } else { $installation_log[] = '>>> ' . __('Forum could not be created!'); $error_log[] = __('Forum could not be created!'); } } else { $installation_log[] = '>>> ' . __('There are existing forums in this database.'); $installation_log[] = '>>>>>> ' . __('No new forum created.'); $error_log[] = __('Forums already exist!'); } if (defined('BB_PLUGIN_DIR') && BB_PLUGIN_DIR && !file_exists(BB_PLUGIN_DIR)) { // Just suppress errors as this is not critical if (@mkdir(BB_PLUGIN_DIR, 0750)) { $installation_log[] = '>>> ' . sprintf(__('Making plugin directory at %s.'), BB_PLUGIN_DIR); } } if (defined('BB_THEME_DIR') && BB_THEME_DIR && !file_exists(BB_THEME_DIR)) { // Just suppress errors as this is not critical if (@mkdir(BB_THEME_DIR, 0750)) { $installation_log[] = '>>> ' . sprintf(__('Making theme directory at %s.'), BB_THEME_DIR); } } if ($keymaster_created) { $keymaster_email_message = sprintf(__("Your new bbPress site has been successfully set up at:\n\n%1\$s\n\nYou can log in to the key master account with the following information:\n\nUsername: %2\$s\nPassword: %3\$s\n\nWe hope you enjoy your new forums. Thanks!\n\n--The bbPress Team\nhttp://bbpress.org/"), bb_get_uri(null, null, BB_URI_CONTEXT_TEXT), $data3['keymaster_user_login']['value'], $data4['keymaster_user_password']['value']); if (bb_mail($data3['keymaster_user_email']['value'], __('New bbPress installation'), $keymaster_email_message)) { $installation_log[] = '>>> ' . __('Key master email sent'); } else { $installation_log[] = '>>> ' . __('Key master email not sent!'); $error_log[] = __('Key master email not sent!'); } } if (count($error_log)) { $this->strings[4]['h2'] = __('Installation completed with some errors!'); $this->strings[4]['messages']['error'][] = __('Your installation completed with some minor errors. See the error log below for more specific information.'); $installation_log[] = "\n" . __('There were some errors encountered during installation!'); } else { $this->strings[4]['messages']['message'][] = __('Your installation completed successfully.'); $installation_log[] = "\n" . __('Installation complete!'); } $this->step_status[4] = 'complete'; $data4['installation_log']['value'] = join("\n", $installation_log); $data4['error_log']['value'] = join("\n", $error_log); return 'complete'; }
function bb_remove_user_favorite($user_id, $topic_id) { global $bbdb; $user_id = (int) $user_id; $topic_id = (int) $topic_id; $user = bb_get_user($user_id); if (!$user) { return false; } $favorites_key = $bbdb->prefix . 'favorites'; $fav = explode(',', $user->{$favorites_key}); if (is_int($pos = array_search($topic_id, $fav))) { array_splice($fav, $pos, 1); $fav = implode(',', $fav); bb_update_usermeta($user->ID, $favorites_key, $fav); } do_action('bb_remove_user_favorite', $user_id, $topic_id); return true; }
} if (!($posts = get_thread($feed_id, 0, 1))) { die; } /* Should die here, as the topic posts aren't there, so the topic is most probably deleted/empty */ $title = sprintf(__('%1$s » Topic: %2$s'), bb_get_option('name'), get_topic_title()); $link = get_topic_link($feed_id); $link_self = get_topic_rss_link($feed_id); break; case 'profile': if (bb_get_option('mod_rewrite') === 'slugs') { if (!($user = bb_get_user_by_nicename($feed_id))) { $user = bb_get_user($feed_id); } } else { if (!($user = bb_get_user($feed_id))) { $user = bb_get_user_by_nicename($feed_id); } } if (!$user) { die; } $posts = get_user_favorites($user->ID); $title = sprintf(__('%1$s » User Favorites: %2$s'), bb_get_option('name'), $user->user_nicename); $link = get_user_profile_link($feed_id); $link_self = get_favorites_rss_link($feed_id); break; case 'tag-topics': if (!($tag = bb_get_tag($feed_id))) { die; }
exit; } else { $bb_login_error =& $user; } // No login so prepare the error } else { $bb_login_error = new WP_Error(); } /** Handle errors *************************************************************/ // Get error data so we can provide feedback $error_data = $bb_login_error->get_error_data(); // Does user actually exist if (isset($error_data['unique']) && false === $error_data['unique']) { $user_exists = true; } else { $user_exists = !empty($_POST['log']) && (bool) bb_get_user($_POST['log'], array('by' => 'login')); } // 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.')); }
/** * Switches the currently active user for incognito actions * * @since 1.0 * @return integer|boolean The user id if the user is valid, otherwise false * @param string $user_login The users login * @param string $capability The capability to check (optional) * @param string $message The message to pass back in the error if the capability check fails (optional) */ function switch_user($user_login, $capability = 'read', $message = false) { // Just get the user, authentication has already been established by the $user = bb_get_user($user_login, array('by' => 'login')); if (!$user || is_nxt_error($user)) { $this->error = new IXR_Error(400, __('User switching failed, the requested user does not exist.')); return false; } // Set the current user $user = bb_set_current_user($user->ID); // Make sure they are allowed to do this if (!bb_current_user_can($capability)) { if (!$message) { $message = __('You do not have permission to read this.'); } $this->error = new IXR_Error(403, $message); return false; } return $user; }
$x->add(array('what' => 'tag', 'id' => $tag_id_val, 'data' => _bb_list_tag_item($tag, array('list_id' => 'tags-list', 'format' => 'list')))); } $x->send(); break; case 'delete-tag': list($tag_id, $user_id) = explode('_', $_POST['id']); $tag_id = (int) $tag_id; $user_id = (int) $user_id; $topic_id = (int) $_POST['topic_id']; if (!bb_current_user_can('edit_tag_by_on', $user_id, $topic_id)) { die('-1'); } bb_check_ajax_referer("remove-tag_{$tag_id}|{$topic_id}"); add_action('bb_rpe_tag_removed', 'bb_grab_results', 10, 3); $tag = bb_get_tag($tag_id); $user = bb_get_user($user_id); $topic = get_topic($topic_id); if (!$tag || !$topic) { die('0'); } if (false !== bb_remove_topic_tag($tag_id, $user_id, $topic_id)) { die('1'); } break; case 'dim-favorite': $user_id = bb_get_current_user_info('id'); if (!($topic = get_topic($id))) { die('0'); } if (!bb_current_user_can('edit_favorites_of', $user_id)) { die('-1');
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_usermeta($user_id, $meta_key) { if (!($user = bb_get_user($user_id))) { return; } $meta_key = bb_sanitize_meta_key($meta_key); if (!isset($user->{$meta_key})) { return; } return $user->{$meta_key}; }
function bb_has_broken_pass($user_id = 0) { global $bb_current_user; if (!$user_id) { $user =& $bb_current_user->data; } else { $user = bb_get_user($user_id); } return false !== strpos($user->user_pass, '---'); }
?> <p> <label for="post_content"><?php _e('Post:'); ?> <br /> <textarea name="post_content" cols="50" rows="8" tabindex="32" id="post_content"><?php echo apply_filters('edit_text', get_post_text()); ?> </textarea> </label> </p> <?php if (bb_get_user(get_post_author_id()) && bb_is_subscriptions_active()) { ?> <p id="post-form-subscription-container" class="left"> <?php bb_user_subscribe_checkbox('tab=33'); ?> </p> <?php } ?> <p class="submit"> <input type="submit" name="Submit" value="<?php esc_attr_e('Edit Post »'); ?> " tabindex="34" />
function query() { if ($_results = bb_get_ids_by_role($this->role, 0, $this->page, $this->users_per_page)) { $this->results = bb_get_user($_results); $this->total_users_for_query = bb_count_last_query(); } else { $this->search_errors = new nxt_Error('no_matching_users_found', __('<strong>No matching users were found!</strong>')); } if (is_nxt_error($this->search_errors)) { bb_admin_notice($this->search_errors); } }
/** * Sends notification emails for new posts. * * Gets new post's ID and check if there are subscribed * user to that topic, and if there are, send notifications * * @since 1.1 * * @param int $post_id ID of new post */ function bb_notify_subscribers($post_id) { global $bbdb, $bb_ksd_pre_post_status; if (!empty($bb_ksd_pre_post_status)) { return false; } if (!($post = bb_get_post($post_id))) { return false; } if (!($topic = get_topic($post->topic_id))) { return false; } $post_id = $post->post_id; $topic_id = $topic->topic_id; if (!($poster_name = get_post_author($post_id))) { return false; } do_action('bb_pre_notify_subscribers', $post_id, $topic_id); if (!($user_ids = $bbdb->get_col($bbdb->prepare("SELECT `{$bbdb->term_relationships}`.`object_id`\n\t\tFROM {$bbdb->term_relationships}, {$bbdb->term_taxonomy}, {$bbdb->terms}\n\t\tWHERE `{$bbdb->term_relationships}`.`term_taxonomy_id` = `{$bbdb->term_taxonomy}`.`term_taxonomy_id`\n\t\tAND `{$bbdb->term_taxonomy}`.`term_id` = `{$bbdb->terms}`.`term_id`\n\t\tAND `{$bbdb->term_taxonomy}`.`taxonomy` = 'bb_subscribe'\n\t\tAND `{$bbdb->terms}`.`slug` = 'topic-%d'", $topic_id)))) { return false; } foreach ((array) $user_ids as $user_id) { if ($user_id == $post->poster_id) { continue; } // don't send notifications to the person who made the post $user = bb_get_user($user_id); if (!($message = apply_filters('bb_subscription_mail_message', __("%1\$s wrote:\n\n%2\$s\n\nRead this post on the forums: %3\$s\n\nYou're getting this email because you subscribed to '%4\$s.'\nPlease click the link above, login, and click 'Unsubscribe' at the top of the page to stop receiving emails from this topic."), $post_id, $topic_id))) { continue; } /* For plugins */ bb_mail($user->user_email, apply_filters('bb_subscription_mail_title', '[' . bb_get_option('name') . '] ' . $topic->topic_title, $post_id, $topic_id), sprintf($message, $poster_name, strip_tags($post->post_text), get_post_link($post_id), strip_tags($topic->topic_title))); } do_action('bb_post_notify_subscribers', $post_id, $topic_id); }
function bb_topic_set_last_post($topic_id) { global $bbdb; $topic_id = (int) $topic_id; $old_post = $bbdb->get_row($bbdb->prepare("SELECT post_id, poster_id, post_time FROM {$bbdb->posts} WHERE topic_id = %d AND post_status = 0 ORDER BY post_time DESC LIMIT 1", $topic_id)); $old_poster = bb_get_user($old_post->poster_id); wp_cache_delete($topic_id, 'bb_topic'); return $bbdb->update($bbdb->topics, array('topic_time' => $old_post->post_time, 'topic_last_poster' => $old_post->poster_id, 'topic_last_poster_name' => $old_poster->login_name, 'topic_last_post_id' => $old_post->post_id), compact('topic_id')); }
function bb_fermion($user_id, $topic_id = 0) { global $bbdb; $user_id = (int) $user_id; $topic_id = (int) $topic_id; if (!$topic_id) { bb_delete_usermeta($user_id, 'is_bozo'); } else { $topic = get_topic($topic_id); $user = bb_get_user($user_id); if (--$topic->bozos[$user_id] < 1) { unset($topic->bozos[$user_id]); } bb_update_topicmeta($topic_id, 'bozos', $topic->bozos); if (--$user->bozo_topics[$topic_id] < 1) { unset($user->bozo_topics[$topic_id]); } bb_update_usermeta($user_id, $bbdb->prefix . 'bozo_topics', $user->bozo_topics); } }