/** * Makes a settings page for the plugin * * @uses bb_option_form_element() to generate the page */ function em_options() { global $em_plugopts; if ($_POST['em_opts_submit'] == 1) { /* Settings have been received, now save them! */ bb_check_admin_referer('em-save-chk'); /* Security Check */ /* Checks on options, and then save them */ $em_plugopts['link-tags'] = intval($_POST['link-tags']) == 1 ? 1 : 0; $em_plugopts['link-users'] = intval($_POST['link-users']) == 1 ? 1 : 0; $em_plugopts['link-user-to'] = $_POST['link-user-to'] == 'website' ? 'website' : 'profile'; $em_plugopts['reply-link'] = intval($_POST['reply-link']) == 1 ? 1 : 0; $em_plugopts['reply-text'] = esc_attr($_POST['reply-text']); bb_update_option(EM_OPTIONS, $em_plugopts); bb_admin_notice(__('The options were successfully saved!', 'easy-mentions')); } if ($ver = em_update_check()) { /* Check for Updates and if available, then notify */ bb_admin_notice(sprintf(__('New version (%1$s) of Easy Mentions is available! Please download the latest version from <a href="%2$s">here</a>.', 'easy-mentions'), $ver, 'http://bbpress.org/plugins/topic/easy-mentions/')); } /* Options in an array to be printed */ $options = array('link-tags' => array('title' => __('Link the Tags?', 'easy-mentions'), 'type' => 'checkbox', 'value' => $em_plugopts['link-tags'] == 1 ? '1' : '0', 'note' => sprintf(__('Check this option if you want the tags to be linked (by using %s) in the posts.', 'easy-mentions'), '<code>#tag</code>'), 'options' => array('1' => __('Yes', 'easy-mentions'))), 'link-users' => array('title' => __('Link the Users?', 'easy-mentions'), 'type' => 'checkbox', 'value' => $em_plugopts['link-users'] == 1 ? '1' : '0', 'note' => sprintf(__('Check this option if you want the users to be linked (by using %s) in the posts.', 'easy-mentions'), '<code>@user</code>'), 'options' => array('1' => __('Yes', 'easy-mentions'))), 'link-user-to' => array('title' => __('Link the user to profile or website?', 'easy-mentions'), 'type' => 'radio', 'value' => $em_plugopts['link-user-to'] == 'website' ? 'website' : 'profile', 'note' => __('If you selected the website option and the user\'s website does not exist, then the user will be linked to his or her profile page.', 'easy-mentions'), 'options' => array('profile' => __('Profile', 'easy-mentions'), 'website' => __('Website', 'easy-mentions'))), 'reply-link' => array('title' => __('Add a reply link below each post?', 'easy-mentions'), 'type' => 'checkbox', 'value' => $em_plugopts['reply-link'] == 1 ? '1' : '0', 'note' => sprintf(__('Before checking this option, please verify that there is a post form below the topic on each page. (<a href="%s">Help</a>)', 'easy-mentions'), 'http://bbpress.org/plugins/topic/easy-mentions/faq/'), 'options' => array('1' => __('Yes', 'easy-mentions'))), 'reply-text' => array('title' => __('Reply Text', 'easy-mentions'), 'class' => array('long'), 'value' => $em_plugopts['reply-text'] ? stripslashes($em_plugopts['reply-text']) : '<em>Replying to @%%USERNAME%%\'s <a href="%%POSTLINK%%">post</a>:</em>', 'after' => '<div style="clear:both;"></div>' . sprintf(__('Some HTML is allowed. The following keys can also be used:%1$s - Post\'s author\'s name%2$s - Post\'s link', 'after-the-deadline'), '<br /><strong>%%USERNAME%%</strong>', '<br /><strong>%%POSTLINK%%</strong>') . '<br />')); if ($em_plugopts['link-users'] != 1) { $options['link-user-to']['attributes'] = array('disabled' => 'disabled'); } if ($em_plugopts['reply-link'] != 1) { $options['reply-text']['attributes'] = array('disabled' => 'disabled'); } ?> <h2><?php _e('Easy Mentions', 'easy-mentions'); ?> </h2> <?php do_action('bb_admin_notices'); ?> <form method="post" class="settings options"> <fieldset> <?php foreach ($options as $option => $args) { bb_option_form_element($option, $args); } ?> </fieldset> <fieldset class="submit"> <?php bb_nonce_field('em-save-chk'); ?> <input type="hidden" name="em_opts_submit" value="1"></input> <input class="submit" type="submit" name="submit" value="Save Changes" /> </fieldset> <p><?php printf(__('Happy with the plugin? Why not <a href="%1$s">buy the author a cup of coffee or two</a> or get him something from his <a href="%2$s">wishlist</a>?', 'easy-mentions'), 'http://gaut.am/donate/EM/', 'http://gaut.am/wishlist/'); ?> </p> </form> <?php }
<?php require 'admin-action.php'; $post_id = (int) $_GET['id']; if (!bb_current_user_can('delete_post', $post_id)) { wp_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER)); exit; } bb_check_admin_referer('delete-post_' . $post_id); $status = (int) $_GET['status']; $bb_post = bb_get_post($post_id); $old_status = (int) $bb_post->post_status; if (!$bb_post) { bb_die(__('There is a problem with that post, pardner.')); } if (0 == $status && 0 != $bb_post->post_status) { // We're undeleting add_filter('bb_delete_post', 'bb_topics_replied_on_undelete_post'); } bb_delete_post($post_id, $status); $message = ''; switch ($old_status) { case 0: switch ($status) { case 0: break; case 1: $message = 'deleted'; break; default: $message = 'spammed';
require BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php'; $step = 'unrequired'; $forced = false; if (isset($_POST['force']) && 1 == $_POST['force']) { $forced = true; } elseif (isset($_GET['force']) && 1 == $_GET['force']) { $forced = true; } if (bb_get_option('bb_db_version') > bb_get_option_from_db('bb_db_version') || $forced) { $forced_input = ''; if ($forced) { $forced_input = '<input type="hidden" name="force" value="1" />'; } $step = 'required'; if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') { bb_check_admin_referer('bbpress-upgrader'); define('BB_UPGRADING', true); $bbdb->hide_errors(); $messages = bb_upgrade_all(); $bbdb->show_errors(); $upgrade_log = array(__('Beginning upgrade…')); if (is_array($messages['messages'])) { $upgrade_log = array_merge($upgrade_log, $messages['messages']); } $upgrade_log[] = '>>> ' . __('Done'); $error_log = array(); if (is_array($messages['errors'])) { $error_log = $messages['errors']; } if (bb_get_option('bb_db_version') === bb_get_option_from_db('bb_db_version') && !count($error_log)) { $step = 'complete';
function bb_manage_user_fields($edit_user = '') { global $nxt_roles, $nxt_users_object, $bbdb; // Cap checks $user_roles = $nxt_roles->role_names; $can_keep_gate = bb_current_user_can('keep_gate'); if ('post' == strtolower($_SERVER['REQUEST_METHOD'])) { bb_check_admin_referer('user-manage'); // Instantiate required vars $_POST = stripslashes_deep($_POST); $create_user_errors = new nxt_Error(); // User login $trimmed_user_login = str_replace(' ', '', $_POST['user_login']); $user_login = sanitize_user($_POST['user_login'], true); $user_meta['first_name'] = $_POST['first_name']; $user_meta['last_name'] = $_POST['last_name']; $user_display_name = $_POST['display_name']; $user_email = $_POST['user_email']; $user_url = $_POST['user_url']; $user_meta['from'] = $_POST['from']; $user_meta['occ'] = $_POST['occ']; $user_meta['interest'] = $_POST['interest']; $user_role = $_POST['userrole']; $user_meta['throttle'] = $_POST['throttle']; $user_pass1 = $_POST['pass1']; $user_pass2 = $_POST['pass2']; $user_status = 0; $user_pass = false; $user_url = $user_url ? bb_fix_link($user_url) : ''; // Check user_login if (!isset($_GET['action']) && empty($user_login)) { $create_user_errors->add('user_login', __('Username is a required field.')); } else { if ($user_login !== $trimmed_user_login) { $create_user_errors->add('user_login', sprintf(__('%s is an invalid username. How\'s this one?'), esc_html($_POST['user_login']))); $user_login = $trimmed_user_login; } } // Check email if (isset($user_email) && empty($user_email)) { $create_user_errors->add('user_email', __('Email address is a required field.')); } // Password Sanity Check if ((!empty($user_pass1) || !empty($user_pass2)) && $user_pass1 !== $user_pass2) { $create_user_errors->add('pass', __('You must enter the same password twice.')); } elseif (!isset($_GET['action']) && (empty($user_pass1) && empty($user_pass2))) { $create_user_errors->add('pass', __('You must enter a password.')); } elseif (isset($_GET['action']) && (empty($user_pass1) && empty($user_pass2))) { $user_pass = ''; } else { $user_pass = $user_pass1; } // No errors if (!$create_user_errors->get_error_messages()) { // Create or udpate switch ($_POST['action']) { case 'create': $goback = bb_get_uri('bb-admin/users.php', array('created' => 'true'), BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); $user = $nxt_users_object->new_user(compact('user_login', 'user_email', 'user_url', 'user_nicename', 'user_status', 'user_pass')); // Error handler if (is_nxt_error($user)) { bb_admin_notice($user); unset($goback); // Update additional user data } else { // Update caps bb_update_usermeta($user['ID'], $bbdb->prefix . 'capabilities', array($user_role => true)); // Update all user meta foreach ($user_meta as $key => $value) { bb_update_usermeta($user['ID'], $key, $value); } // Don't send email if empty if (!empty($user_pass)) { bb_send_pass($user['ID'], $user_pass); } do_action('bb_new_user', $user['ID'], $user_pass); } break; case 'update': $goback = bb_get_uri('bb-admin/users.php', array('updated' => 'true'), BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); $user = $nxt_users_object->get_user($_GET['user_id'], array('output' => ARRAY_A)); bb_update_user($user['ID'], $user_email, $user_url, $user_display_name); // Don't change PW if empty if (!empty($user_pass)) { bb_update_user_password($user['ID'], $user_pass); } // Error handler if (is_nxt_error($user)) { bb_admin_notice($user); unset($goback); // Update additional user data } else { // Update caps bb_update_usermeta($user['ID'], $bbdb->prefix . 'capabilities', array($user_role => true)); // Update all user meta foreach ($user_meta as $key => $value) { bb_update_usermeta($user['ID'], $key, $value); } // Don't send email if empty if (!empty($user_pass)) { bb_send_pass($user['ID'], $user_pass); } do_action('bb_update_user', $user['ID'], $user_pass); } break; } // Redirect if (isset($goback) && !empty($goback)) { bb_safe_redirect($goback); } // Error handler } else { bb_admin_notice($create_user_errors); } } elseif (isset($_GET['action']) && $_GET['action'] == 'edit') { if (isset($_GET['user_id']) && is_numeric($_GET['user_id'])) { $disabled = true; // Get the user if (empty($edit_user)) { $edit_user = bb_get_user(bb_get_user_id($_GET['user_id'])); } // Instantiate required vars $user_login = $edit_user->user_login; $user_meta['first_name'] = $edit_user->first_name; $user_meta['last_name'] = $edit_user->last_name; $user_display_name = $edit_user->display_name; $user_email = $edit_user->user_email; $user_url = $edit_user->user_url; $user_meta['from'] = $edit_user->from; $user_meta['occ'] = $edit_user->occ; $user_meta['interest'] = $edit_user->interest; $user_role = array_search('true', $edit_user->capabilities); $user_meta['throttle'] = $edit_user->throttle; // Keymasters can't demote themselves if ($edit_user->ID == bb_get_current_user_info('id') && $can_keep_gate || isset($edit_user->capabilities) && is_array($edit_user->capabilities) && array_key_exists('keymaster', $edit_user->capabilities) && !$can_keep_gate) { $user_roles = array('keymaster' => $user_roles['keymaster']); } elseif (!$can_keep_gate) { unset($user_roles['keymaster']); } } } // Load password strength checker nxt_enqueue_script('password-strength-meter'); nxt_enqueue_script('profile-edit'); // Generate a few PW hints $some_pass_hints = ''; for ($l = 3; $l != 0; $l--) { $some_pass_hints .= '<p>' . bb_generate_password() . '</p>'; } // Create the user fields $user_fields = array('user_login' => array('title' => __('Username'), 'note' => __('Required! Unique identifier for new user.'), 'value' => $user_login, 'disabled' => $disabled), 'first_name' => array('title' => __('First Name'), 'value' => $user_meta['first_name']), 'last_name' => array('title' => __('Last Name'), 'value' => $user_meta['last_name']), 'display_name' => array('title' => __('Display Name'), 'value' => $user_display_name), 'user_email' => array('title' => __('Email'), 'note' => __('Required! Will be used for notifications and profile settings changes.'), 'value' => $user_email), 'user_url' => array('title' => __('Website'), 'class' => array('long', 'code'), 'note' => __('The full URL of user\'s homepage or blog.'), 'value' => $user_url), 'from' => array('title' => __('Location'), 'class' => array('long'), 'value' => $user_meta['from']), 'occ' => array('title' => __('Occupation'), 'class' => array('long'), 'value' => $user_meta['occ']), 'interest' => array('title' => __('Interests'), 'class' => array('long'), 'value' => $user_meta['interest']), 'userrole' => array('title' => __('User Role'), 'type' => 'select', 'options' => $user_roles, 'note' => __('Allow user the above privileges.'), 'value' => $user_role), 'pass1' => array('title' => __('New Password'), 'type' => 'password', 'class' => array('short', 'text', 'code'), 'note' => __('Hints: ') . $some_pass_hints, 'value' => $user_pass1), 'pass2' => array('title' => __('Repeat New Password'), 'type' => 'password', 'class' => array('short', 'text', 'code'), 'note' => __('If you ignore hints, remember: the password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ & ).'), 'value' => $user_pass2), 'email_pass' => array('title' => '', 'type' => 'checkbox', 'options' => array('1' => array('label' => __('Email the new password.'), 'attributes' => array('checked' => true)))), 'pass-strength-fake-input' => array('title' => __('Password Strength'), 'type' => 'hidden')); return apply_filters('bb_manage_user_fields', $user_fields); }
// Set some low capabilities if the current user has none if (!isset($user->capabilities)) { $user->capabilities = array('inactive' => true); } // Store the profile info keys $profile_info_keys = bb_get_profile_info_keys('profile-edit'); // Store additional keys if the current user has access to them if (bb_current_user_can('edit_users')) { $profile_admin_keys = bb_get_profile_admin_keys('profile-edit'); $assignable_caps = bb_get_assignable_caps(); } // Instantiate the error object $errors = new nxt_Error(); if ('post' == strtolower($_SERVER['REQUEST_METHOD'])) { $_POST = stripslashes_deep($_POST); bb_check_admin_referer('edit-profile_' . $user_id); // Fix the URL before sanitizing it $user_url = bb_fix_link($_POST['user_url']); // Sanitize the profile info keys and check for missing required data foreach ($profile_info_keys as $key => $label) { ${$key} = apply_filters('sanitize_profile_info', $_POST[$key], $key, $_POST[$key]); if (!${$key} && $label[0] == 1) { $errors->add($key, sprintf(__('%s is required.'), esc_html($label[1]))); ${$key} = false; } } // Find out if we have a valid email address if (isset($user_email) && !($user_email = is_email($user_email))) { $errors->add('user_email', __('Invalid email address'), array('data' => $_POST['user_email'])); } // Deal with errors for users who can edit others data
function bb_ksd_configuration_page_process() { if ('post' == strtolower($_SERVER['REQUEST_METHOD']) && $_POST['action'] == 'update-akismet-settings') { bb_check_admin_referer('options-akismet-update'); $goback = remove_query_arg(array('invalid-akismet', 'updated-akismet'), wp_get_referer()); if (!isset($_POST['akismet_stats'])) { $_POST['akismet_stats'] = false; } if (true === (bool) $_POST['akismet_stats']) { bb_update_option('akismet_stats', 1); } else { bb_delete_option('akismet_stats'); } if ($_POST['akismet_key']) { $value = stripslashes_deep(trim($_POST['akismet_key'])); if ($value) { if (bb_akismet_verify_key($value)) { bb_update_option('akismet_key', $value); } else { $goback = add_query_arg('invalid-akismet', 'true', $goback); bb_safe_redirect($goback); exit; } } else { bb_delete_option('akismet_key'); } } else { bb_delete_option('akismet_key'); } $goback = add_query_arg('updated-akismet', 'true', $goback); bb_safe_redirect($goback); exit; } if (!empty($_GET['updated-akismet'])) { bb_admin_notice(__('<strong>Settings saved.</strong>')); } if (!empty($_GET['invalid-akismet'])) { bb_admin_notice(__('<strong>The key you attempted to enter is invalid. Reverting to previous setting.</strong>'), 'error'); } global $bb_admin_body_class; $bb_admin_body_class = ' bb-admin-settings'; }
<?php require_once 'admin.php'; $file_source = BB_PATH . 'bb-admin/includes/defaults.bb-htaccess.php'; $file_target = BB_PATH . '.htaccess'; include $file_source; $file_source_rules = $_rules; // This is a string if ('post' == strtolower($_SERVER['REQUEST_METHOD']) && $_POST['action'] == 'update') { bb_check_admin_referer('options-permalinks-update'); foreach ((array) $_POST as $option => $value) { if (!in_array($option, array('_wpnonce', '_wp_http_referer', 'action', 'submit'))) { $option = trim($option); $value = is_array($value) ? $value : trim($value); $value = stripslashes_deep($value); if ($value) { bb_update_option($option, $value); } else { bb_delete_option($option); } } } $mod_rewrite = (string) bb_get_option('mod_rewrite'); $goback = remove_query_arg(array('updated', 'notapache', 'notmodrewrite'), wp_get_referer()); // Make sure mod_rewrite is possible on the server if (!$is_apache) { bb_delete_option('mod_rewrite_writable'); $goback = add_query_arg('notapache', 'true', $goback); bb_safe_redirect($goback); exit; } elseif ('0' !== $mod_rewrite && !apache_mod_loaded('mod_rewrite', true)) {
bb_die(__('You are not allowed to write new topics.')); } bb_check_admin_referer('create-topic'); $topic = trim($_POST['topic']); $tags = trim($_POST['tags']); if ('' == $topic) { bb_die(__('Please enter a topic title')); } $args = array(); if (isset($post_author)) { $args['topic_poster_name'] = $args['topic_last_poster_name'] = $post_author; } $topic_id = bb_new_topic($topic, $forum_id, $tags, $args); } elseif (isset($_POST['topic_id'])) { $topic_id = (int) $_POST['topic_id']; bb_check_admin_referer('create-post_' . $topic_id); } if (bb_is_login_required() && !bb_current_user_can('write_post', $topic_id)) { bb_die(__('You are not allowed to post. Are you logged in?')); } if (!topic_is_open($topic_id)) { bb_die(__('This topic has been closed')); } $post_data = array('post_text' => stripslashes($_POST['post_content']), 'topic_id' => $topic_id); foreach (array('post_author', 'post_email', 'post_url') as $field) { if (!empty(${$field})) { $post_data[$field] = ${$field}; } } $post_id = bb_insert_post($post_data); $tags = trim($_POST['tags']);
<?php require_once 'admin.php'; if ('post' == strtolower($_SERVER['REQUEST_METHOD'])) { $action = @$_POST['action']; } else { $action = false; } if (in_array($action, array('update-users', 'update-options'))) { bb_check_admin_referer('options-wordpress-' . $action); // Deal with advanced user database checkbox when it isn't checked if (!isset($_POST['user_bbdb_advanced'])) { $_POST['user_bbdb_advanced'] = false; } foreach ((array) $_POST as $option => $value) { if (!in_array($option, array('_wpnonce', '_wp_http_referer', 'action', 'submit'))) { $option = trim($option); $value = is_array($value) ? $value : trim($value); $value = stripslashes_deep($value); if (($option == 'wp_siteurl' || $option == 'wp_home') && !empty($value)) { $value = rtrim($value, " \t\n\r\v/") . '/'; } if ($value) { bb_update_option($option, $value); } else { bb_delete_option($option); } } } if ($action == 'update-users') { bb_apply_wp_role_map_to_orphans();
<?php require_once 'admin.php'; if ('post' == strtolower($_SERVER['REQUEST_METHOD'])) { bb_check_admin_referer('post-bulk'); $post_ids = array_map('absint', $_POST['post']); $count = 0; $action = trim($_POST['action']); switch ($action) { case 'delete': foreach ($post_ids as $post_id) { $count += (int) (bool) bb_delete_post($post_id, 1); } $query_vars = array('message' => 'deleted', 'count' => $count); break; case 'undelete': foreach ($post_ids as $post_id) { $count += (int) (bool) bb_delete_post($post_id, 0); } $query_vars = array('message' => 'undeleted', 'count' => $count); break; default: if ($action) { $query_vars = apply_filters("bulk_post__{$action}", array(), $post_ids, $action); } break; } bb_safe_redirect(add_query_arg($query_vars)); exit; } if (!empty($_GET['message'])) {
<?php require 'admin.php'; if (!bb_current_user_can('manage_tags')) { bb_die(__('You are not allowed to manage tags.')); } $old_id = (int) $_POST['id']; $tag = $_POST['tag']; bb_check_admin_referer('merge-tag_' . $old_id); if (!($tag = bb_get_tag($tag))) { bb_die(__('The destination tag you specified could not be found.')); } if (!bb_get_tag($old_id)) { bb_die(__('The original tag could not be found.')); } if ($merged = bb_merge_tags($old_id, $tag->tag_id)) { bb_die(sprintf(__("Number of topics from which the old tag was removed: %d <br />\n"), $merged['old_count']) . sprintf(__("Number of topics to which the new tag was added: %d <br />\n"), $merged['diff_count']) . sprintf(__("Number of rows deleted from tags table:%d <br />\n"), $merged['destroyed']['tags']) . sprintf(__('<a href="%s">View Results of Merge</a>'), bb_get_tag_link())); } else { bb_die(printf(__("Something odd happened when attempting to merge those tags.<br />\n<a href=\"%s\">Try Again?</a>"), nxt_get_referer())); }
<?php if (!isset($_GET['doit']) || 'bb-subscribe' != $_GET['doit']) { // sanity check bb_die(__('What are you trying to do, exactly?')); } if (!bb_is_subscriptions_active()) { bb_die(__('You can not subscribe to topics.')); } if (!isset($_GET['topic_id'])) { bb_die(__('Missing topic ID!')); } bb_auth('logged_in'); $topic_id = (int) $_GET['topic_id']; $topic = get_topic($topic_id); if (!$topic) { bb_die(__('Topic not found! What are you subscribing to?')); } bb_check_admin_referer('toggle-subscribe_' . $topic_id); // Okay, we should be covered now if (in_array($_GET['and'], array('add', 'remove'))) { bb_subscription_management($topic->topic_id, $_GET['and']); } nxt_redirect(get_topic_link($topic_id, 1)); exit;
<?php require_once 'admin.php'; if ('post' == strtolower($_SERVER['REQUEST_METHOD']) && $_POST['action'] == 'update') { bb_check_admin_referer('options-writing-update'); // Deal with xmlrpc checkbox when it isn't checked if (!isset($_POST['enable_xmlrpc'])) { $_POST['enable_xmlrpc'] = false; } foreach ((array) $_POST as $option => $value) { if (!in_array($option, array('_nxtnonce', '_nxt_http_referer', 'action', 'submit'))) { $option = trim($option); $value = is_array($value) ? $value : trim($value); $value = stripslashes_deep($value); if ($value) { bb_update_option($option, $value); } else { bb_delete_option($option); } } } $goback = add_query_arg('updated', 'true', nxt_get_referer()); bb_safe_redirect($goback); exit; } if (!empty($_GET['updated'])) { bb_admin_notice(__('<strong>Settings saved.</strong>')); } $general_options = array('edit_lock' => array('title' => __('Lock post editing after'), 'class' => 'short', 'after' => __('minutes'), 'note' => __('A user can edit a post for this many minutes after submitting.')), 'throttle_time' => array('title' => __('Throttle time'), 'class' => 'short', 'after' => __('seconds'), 'note' => __('Users must wait this many seconds between posts. By default, moderators, administrators and keymasters are not throttled.'))); $remote_options = array('enable_xmlrpc' => array('title' => __('XML-RPC'), 'type' => 'checkbox', 'options' => array(1 => __('Enable the bbPress XML-RPC publishing protocol.')))); $bb_admin_body_class = ' bb-admin-settings';
<?php require './bb-load.php'; bb_auth('logged_in'); $tag_id = (int) @$_GET['tag']; $user_id = (int) @$_GET['user']; $topic_id = (int) @$_GET['topic']; bb_check_admin_referer('remove-tag_' . $tag_id . '|' . $topic_id); $tag = bb_get_tag($tag_id); $topic = get_topic($topic_id); $user = bb_get_user($user_id); if (!$tag || !$topic) { bb_die(__('Invalid tag or topic.')); } if (false !== bb_remove_topic_tag($tag_id, $user_id, $topic_id)) { if (!($redirect = wp_get_referer())) { $redirect = get_topic_link($topic_id); } bb_safe_redirect($redirect); } else { bb_die(__('The tag was not removed.')); } exit;
<?php require_once 'admin.php'; if ('post' == strtolower($_SERVER['REQUEST_METHOD'])) { bb_check_admin_referer('topic-bulk'); $topic_ids = array_map('absint', $_POST['topic']); $affected = 0; $action = trim($_POST['action']); switch ($action) { case 'close': foreach ($topic_ids as $topic_id) { $affected += bb_close_topic($topic_id); } $query_vars = array('message' => 'closed', 'count' => $affected); break; case 'open': foreach ($topic_ids as $topic_id) { $affected += bb_open_topic($topic_id); } $query_vars = array('message' => 'opened', 'count' => $affected); break; case 'delete': foreach ($topic_ids as $topic_id) { $affected += (int) (bool) bb_delete_topic($topic_id, 1); } $query_vars = array('message' => 'deleted', 'count' => $affected); break; case 'undelete': foreach ($topic_ids as $topic_id) { $affected += (int) (bool) bb_delete_topic($topic_id, 0); }
<?php require_once 'admin-action.php'; $topic_id = absint($_POST['topic_id']); $forum_id = absint($_POST['forum_id']); if (!is_numeric($topic_id) || !is_numeric($forum_id)) { bb_die(__('Invalid topic or forum.')); } if (!bb_current_user_can('move_topic', $topic_id, $forum_id)) { nxt_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER)); exit; } bb_check_admin_referer('move-topic_' . $topic_id); $topic = get_topic($topic_id); $forum = bb_get_forum($forum_id); if (!$topic || !$forum) { bb_die(__('Your topic or forum caused all manner of confusion')); } bb_move_topic($topic_id, $forum_id); if (!($redirect = nxt_get_referer())) { $redirect = get_topic_link($topic_id); } bb_safe_redirect($redirect); exit;
<?php require 'admin-action.php'; $topic_id = (int) $_GET['id']; $topic = get_topic($topic_id); $super = isset($_GET['super']) && 1 == (int) $_GET['super'] ? 1 : 0; if (!$topic) { bb_die(__('There is a problem with that topic, pardner.')); } if (!bb_current_user_can('stick_topic', $topic_id)) { wp_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER)); exit; } bb_check_admin_referer('stick-topic_' . $topic_id); if (topic_is_sticky($topic_id)) { bb_unstick_topic($topic_id); } else { bb_stick_topic($topic_id, $super); } if (!($redirect = wp_get_referer())) { $redirect = get_topic_link($topic_id); } bb_safe_redirect($redirect); exit;
bb_die($result); } // Overrides the ?message=error one above wp_redirect('plugins.php?plugin_request=' . $plugin_request . '&message=activate&plugin=' . urlencode($plugin)); break; case 'deactivate': // Deactivation bb_check_admin_referer('deactivate-plugin_' . $plugin); // Remove the deactivated plugin bb_deactivate_plugins($plugin); // Redirect wp_redirect('plugins.php?plugin_request=' . $plugin_request . '&message=deactivate&plugin=' . urlencode($plugin)); break; case 'scrape': // Scrape php errors from the plugin bb_check_admin_referer('scrape-plugin_' . $plugin); $valid_path = bb_validate_plugin($plugin); if (is_wp_error($valid_path)) { bb_die($valid_path); } // Pump up the errors and output them to screen error_reporting(E_ALL ^ E_NOTICE); @ini_set('display_errors', true); include $valid_path; break; } // Stop processing exit; } // Display notices if (isset($_GET['message'])) {
<?php require './bb-load.php'; bb_auth('logged_in'); $post_id = (int) $_POST['post_id']; $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
<?php require_once 'admin.php'; if ('post' == strtolower($_SERVER['REQUEST_METHOD']) && $_POST['action'] == 'update') { bb_check_admin_referer('options-general-update'); foreach ((array) $_POST as $option => $value) { if (!in_array($option, array('_wpnonce', '_wp_http_referer', 'action', 'submit'))) { $option = trim($option); $value = is_array($value) ? $value : trim($value); $value = stripslashes_deep($value); if ($option == 'uri' && !empty($value)) { $value = rtrim($value, " \t\n\r\v/") . '/'; } if ($value) { bb_update_option($option, $value); } else { bb_delete_option($option); } } } $goback = add_query_arg('updated', 'true', wp_get_referer()); bb_safe_redirect($goback); exit; } if (!empty($_GET['updated'])) { bb_admin_notice(__('<strong>Settings saved.</strong>')); } $general_options = array('name' => array('title' => __('Site title'), 'class' => 'long'), 'description' => array('title' => __('Tagline'), 'class' => 'long', 'note' => __('In a few words, explain what this site is about.')), 'uri' => array('title' => __('bbPress address (URL)'), 'class' => array('long', 'code'), 'note' => __('The full URL of your bbPress install.')), 'from_email' => array('title' => __('E-mail address'), 'note' => __('This address is used for admin purposes, like new user notification.'))); $time_options = array('gmt_offset' => array('title' => __('Time zone'), 'type' => 'select', 'options' => array('-12' => '-12:00', '-11.5' => '-11:30', '-11' => '-11:00', '-10.5' => '-10:30', '-10' => '-10:00', '-9.5' => '-9:30', '-9' => '-9:00', '-8.5' => '-8:30', '-8' => '-8:00', '-7.5' => '-7:30', '-7' => '-7:00', '-6.5' => '-6:30', '-6' => '-6:00', '-5.5' => '-5:30', '-5' => '-5:00', '-4.5' => '-4:30', '-4' => '-4:00', '-3.5' => '-3:30', '-3' => '-3:00', '-2.5' => '-2:30', '-2' => '-2:00', '-1.5' => '-1:30', '-1' => '-1:00', '-0.5' => '-0:30', '0' => '', '0.5' => '+0:30', '1' => '+1:00', '1.5' => '+1:30', '2' => '+2:00', '2.5' => '+2:30', '3' => '+3:00', '3.5' => '+3:30', '4' => '+4:00', '4.5' => '+4:30', '5' => '+5:00', '5.5' => '+5:30', '5.75' => '+5:45', '6' => '+6:00', '6.5' => '+6:30', '7' => '+7:00', '7.5' => '+7:30', '8' => '+8:00', '8.5' => '+8:30', '8.75' => '+8:45', '9' => '+9:00', '9.5' => '+9:30', '10' => '+10:00', '10.5' => '+10:30', '11' => '+11:00', '11.5' => '+11:30', '12' => '+12:00', '12.75' => '+12:45', '13' => '+13:00', '13.75' => '+13:45', '14' => '+14:00'), 'after' => __('hours')), 'datetime_format' => array('title' => __('Date and time format'), 'class' => 'short', 'value' => bb_get_datetime_formatstring_i18n(), 'after' => bb_datetime_format_i18n(bb_current_time()), 'note' => array(__('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>.'), __('Click "Save Changes" to update sample output.'))), 'date_format' => array('title' => __('Date format'), 'class' => 'short', 'value' => bb_get_datetime_formatstring_i18n('date'), 'after' => bb_datetime_format_i18n(bb_current_time(), 'date'))); if (!($gmt_offset = bb_get_option('gmt_offset'))) { $gmt_offset = 0;
<?php require_once 'admin.php'; if ('post' == strtolower($_SERVER['REQUEST_METHOD'])) { $action = @$_POST['action']; } else { $action = false; } if (in_array($action, array('update-users', 'update-options'))) { bb_check_admin_referer('options-nxtclass-' . $action); // Deal with advanced user database checkbox when it isn't checked if (!isset($_POST['user_bbdb_advanced'])) { $_POST['user_bbdb_advanced'] = false; } foreach ((array) $_POST as $option => $value) { if (!in_array($option, array('_nxtnonce', '_nxt_http_referer', 'action', 'submit'))) { $option = trim($option); $value = is_array($value) ? $value : trim($value); $value = stripslashes_deep($value); if (($option == 'nxt_siteurl' || $option == 'nxt_home') && !empty($value)) { $value = rtrim($value, " \t\n\r\v/") . '/'; } if ($value) { bb_update_option($option, $value); } else { bb_delete_option($option); } } } if ($action == 'update-users') { bb_apply_nxt_role_map_to_orphans();
<?php require 'admin.php'; if (!bb_current_user_can('manage_tags')) { bb_die(__('You are not allowed to manage tags.')); } $tag_id = (int) $_POST['id']; bb_check_admin_referer('destroy-tag_' . $tag_id); if (!($old_tag = bb_get_tag($tag_id))) { bb_die(__('Tag not found.')); } if (bb_destroy_tag($tag_id)) { bb_die(__('That tag was successfully destroyed')); } else { bb_die(printf(__("Something odd happened when attempting to destroy that tag.<br />\n<a href=\"%s\">Try Again?</a>"), wp_get_referer())); }
<?php require './bb-load.php'; bb_auth('logged_in'); if (!bb_is_user_logged_in()) { bb_die(__('You need to be logged in to add a tag.')); } $topic_id = (int) @$_POST['id']; $page = (int) @$_POST['page']; $tag = @$_POST['tag']; $tag = stripslashes($tag); bb_check_admin_referer('add-tag_' . $topic_id); $topic = get_topic($topic_id); if (!$topic) { bb_die(__('Topic not found.')); } if (bb_add_topic_tags($topic_id, $tag)) { wp_redirect(get_topic_link($topic_id, $page)); } else { bb_die(__('The tag was not added. Either the tag name was invalid or the topic is closed.')); } exit;
<?php require_once 'admin.php'; require_once 'includes/functions.bb-recount.php'; if ('post' == strtolower($_SERVER['REQUEST_METHOD'])) { bb_check_admin_referer('do-counts'); // Stores messages $messages = array(); if (!empty($_POST['topic-posts'])) { $message = bb_recount_topic_posts(); $messages[] = $message[1]; } if (!empty($_POST['topic-voices'])) { $message = bb_recount_topic_voices(); $messages[] = $message[1]; } if (!empty($_POST['topic-deleted-posts'])) { $message = bb_recount_topic_deleted_posts(); $messages[] = $message[1]; } if (!empty($_POST['forums'])) { $message = bb_recount_forum_topics(); $messages[] = $message[1]; $message = bb_recount_forum_posts(); $messages[] = $message[1]; } if (!empty($_POST['topics-replied'])) { $message = bb_recount_user_topics_replied(); $messages[] = $message[1]; } if (!empty($_POST['topic-tag-count'])) {
case 'update': bb_check_admin_referer('update-forum'); if (!($forums = bb_get_forums())) { bb_die(__('No forums to update!')); } if ((int) $_POST['forum_id'] && isset($_POST['forum_name']) && '' !== $_POST['forum_name']) { bb_update_forum($_POST); } foreach (array('action', 'id') as $arg) { $sent_from = remove_query_arg($arg, $sent_from); } bb_safe_redirect(add_query_arg('message', 'updated', $sent_from)); exit; break; case 'delete': bb_check_admin_referer('delete-forums'); $forum_id = (int) $_POST['forum_id']; $move_topics_forum = (int) $_POST['move_topics_forum']; if (!bb_current_user_can('delete_forum', $forum_id)) { bb_die(__("You don't have the authority to kill off the forums.")); } if (isset($_POST['move_topics']) && $_POST['move_topics'] != 'delete') { bb_move_forum_topics($forum_id, $move_topics_forum); } if (!bb_delete_forum($forum_id)) { bb_die(__('Error occured while trying to delete forum')); } foreach (array('action', 'id') as $arg) { $sent_from = remove_query_arg($arg, $sent_from); } bb_safe_redirect(add_query_arg('message', 'deleted', $sent_from));
/** * 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'; }
<?php require 'admin-action.php'; $topic_id = (int) $_GET['id']; $topic = get_topic($topic_id); if (!$topic) { bb_die(__('There is a problem with that topic, pardner.')); } if (!bb_current_user_can('close_topic', $topic_id)) { nxt_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER)); exit; } bb_check_admin_referer('close-topic_' . $topic_id); if (topic_is_open($topic_id)) { bb_close_topic($topic_id); $message = 'closed'; } else { bb_open_topic($topic_id); $message = 'opened'; } if ($sendto = nxt_get_referer()) { $sendto = remove_query_arg('message', $sendto); $sendto = add_query_arg('message', $message, $sendto); } else { $sendto = get_topic_link($topic_id); } bb_safe_redirect($sendto); exit;
<?php require 'admin-action.php'; $topic_id = (int) $_GET['id']; if (!bb_current_user_can('delete_topic', $topic_id)) { wp_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER)); exit; } bb_check_admin_referer('delete-topic_' . $topic_id); $topic = get_topic($topic_id); $old_status = (int) $topic->topic_status; if (!$topic) { bb_die(__('There is a problem with that topic, pardner.')); } $status = $topic->topic_status ? 0 : 1; bb_delete_topic($topic->topic_id, $status); $message = ''; switch ($old_status) { case 0: switch ($status) { case 0: break; case 1: $message = 'deleted'; break; } break; case 1: switch ($status) { case 0: $message = 'undeleted';
<?php require 'admin.php'; if (!bb_current_user_can('manage_tags')) { bb_die(__('You are not allowed to manage tags.')); } $tag_id = (int) $_POST['id']; $tag = stripslashes($_POST['tag']); bb_check_admin_referer('rename-tag_' . $tag_id); if (!($old_tag = bb_get_tag($tag_id))) { bb_die(__('Tag not found.')); } if ($tag = bb_rename_tag($tag_id, $tag)) { wp_redirect(bb_get_tag_link()); } else { bb_die(printf(__('There already exists a tag by that name or the name is invalid. <a href="%s">Try Again</a>'), wp_get_referer())); } exit;
<?php require_once 'admin.php'; if ('post' == strtolower($_SERVER['REQUEST_METHOD']) && $_POST['action'] == 'update') { bb_check_admin_referer('options-reading-update'); foreach ((array) $_POST as $option => $value) { if (!in_array($option, array('_wpnonce', '_wp_http_referer', 'action', 'submit'))) { $option = trim($option); $value = is_array($value) ? $value : trim($value); $value = stripslashes_deep($value); if ($value) { bb_update_option($option, $value); } else { bb_delete_option($option); } } } $goback = add_query_arg('updated', 'true', wp_get_referer()); bb_safe_redirect($goback); exit; } if (!empty($_GET['updated'])) { bb_admin_notice(__('<strong>Settings saved.</strong>')); } $reading_options = array('page_topics' => array('title' => __('Items per page'), 'class' => 'short', 'note' => __('Number of topics, posts or tags to show per page.'))); $bb_admin_body_class = ' bb-admin-settings'; bb_get_admin_header(); ?> <div class="wrap">