bookboard/bb-admin/bb-do-counts.php 0000644 0005225 0005225 00000014211 11127561242 017656 0 ustar juliecar juliecar
\n\t" . __('Done recounting. The process took') . "\n\t"; printf(__('%1$d queries and %2$s seconds.'), $bbdb->num_queries, bb_timer_stop(0)); echo "\n
"; $bb_cache->flush_all(); endif; bb_get_admin_footer(); ?> bookboard/bb-admin/tag-rename.php 0000644 0005225 0005225 00000001067 11127561242 017407 0 ustar juliecar juliecar Try Again'), wp_get_referer())); ?> bookboard/bb-admin/class-install.php 0000644 0005225 0005225 00000234504 11127561242 020144 0 ustar juliecar juliecar 'en_US'); /** * The currently selected language for the installer * * @var string **/ var $language = 'en_US'; /** * The current step in the install process * * @var integer **/ var $step; /** * Info about config files and their locations * * @var array **/ var $configs = array( 'writable' => false, 'bb-config.php' => false, 'config.php' => false ); /** * An array of the current status of each step * * @var array **/ var $step_status = array( 0 => 'incomplete', 1 => 'incomplete', 2 => 'incomplete', 3 => 'incomplete', 4 => 'incomplete' ); /** * An array of most strings in use, including errors * * @var array **/ var $strings = array(); /** * The data being manipulated as we go through the forms * * @var array **/ var $data = array(); /** * A boolean that can get flagged to stop posting of a form getting processed * * @var boolean **/ var $stop_process = false; /** * BB_Install() - Constructor * * Just sets up a few initial values * * @param string $caller The full path of the file that instantiated the class * @return boolean **/ function BB_Install($caller) { $this->caller = $caller; $this->set_initial_step(); $this->define_paths(); return true; } /** * set_initial_step() - Set initial step * * Sets the step from the querystring and keeps it within range * * @return integer The calculated step **/ function set_initial_step() { // Set the step based on the $_GET value or 0 $this->step = $_GET['step'] ? (integer) $_GET['step'] : 0; // Make sure the requested step is from 0-4 if ($this->step < 0 || $this->step > 4) { $this->step = 0; } return $this->step; } /** * prepare_strings() - Prepare text strings * * Sets up many of the strings to be used by the class that may * be later subject to change due to processing of the forms **/ function prepare_strings() { $this->strings = array( -1 => array( 'title' => __('bbPress › Error'), 'h1' => __('Oh dear!'), 'messages' => array() ), 0 => array( 'title' => sprintf(__('%1$s › %2$s'), __('bbPress installer'), __('Welcome')), 'h1' => __('Welcome to the bbPress installer'), 'messages' => array(), 'intro' => array( __('We\'re now going to go through a few steps to get you up and running.'), $this->get_language_selector(), sprintf(__('Ready? Then let\'s get started!'), 'install.php?step=1') ) ), 1 => array( 'title' => sprintf(__('%1$s › %2$s'), __('bbPress installer'), __('Step 1')), 'h1' => __('Welcome to the bbPress installer'), 'h2' => sprintf(__('%1$s - %2$s'), __('Step 1'), __('Database configuration')), 'status' => '', 'intro' => array( __('Here you need to enter your database connection details. The installer will attempt to create a file calledbb-config.php
in the root directory of your bbPress installation.'),
__('If you\'re not sure what to put here, contact your web hosting provider.')
),
'messages' => array()
),
2 => array(
'title' => sprintf(__('%1$s › %2$s'), __('bbPress installer'), __('Step 2')),
'h1' => __('Welcome to the bbPress installer'),
'h2' => sprintf(__('%1$s - %2$s'), __('Step 2'), __('WordPress integration (optional)')),
'status' => __('« skipped'),
'intro' => array(
__('bbPress can integrate login and user data seamlessly with WordPress. You can safely skip this section if you do not wish to integrate with an existing WordPress install.')
),
'messages' => array(),
'form_errors' => array()
),
3 => array(
'title' => sprintf(__('%1$s › %2$s'), __('bbPress installer'), __('Step 3')),
'h1' => __('Welcome to the bbPress installer'),
'h2' => sprintf(__('%1$s - %2$s'), __('Step 3'), __('Site settings')),
'status' => '',
'intro' => array(
__('Finalize your installation by adding a name, your first user and your first forum.')
),
'messages' => array(),
'form_errors' => array(),
'scripts' => array()
),
4 => array(
'title' => sprintf(__('%1$s › %2$s'), __('bbPress installer'), __('Finished')),
'h1' => __('Welcome to the bbPress installer'),
'h2' => __('Installation complete!'),
'messages' => array()
)
);
}
/**
* check_prerequisites() - Check installation pre-requisites
*
* Checks for appropriate PHP version and MySQL extensions, also
* sets the BBDB_EXTENSION constant along the way if necessary.
*
* @return boolean False if any pre-requisites are not met, otherwise true
**/
function check_prerequisites()
{
if (version_compare(PHP_VERSION, '4.3', '<')) {
$this->strings[-1]['messages']['error'][] = sprintf(__('Your server is running PHP version %s but bbPress requires at least 4.3'), PHP_VERSION);
$this->step = -1;
}
if (!extension_loaded('mysql')) {
if (!extension_loaded('mysqli')) {
$this->strings[-1]['messages']['error'][] = __('Your PHP installation appears to be missing the MySQL extension which is required for bbPress');
$this->step = -1;
} else {
if (!defined('BBDB_EXTENSION')) {
define('BBDB_EXTENSION', 'mysqli');
}
}
}
if (defined('DB_NAME') || defined('WP_BB') && WP_BB) {
$this->strings[-1]['messages']['error'][] = __('Please complete your installation before attempting to include WordPress within bbPress');
$this->step = -1;
}
if ($this->step === -1) {
return false;
}
return true;
}
/**
* define_paths() - Define path constants
*
* Sets some bbPress constants if they are not otherwise available based
* on the classes initiating file path.
*
* @return boolean False if no path was supplied, otherwise always true
**/
function define_paths()
{
if (!$this->caller) {
return false;
}
if (!defined('BB_PATH')) {
// Determine the base path of the installation
// The caller must be in bb-admin or the base path of the installation
$bbpath = preg_replace('|(/bb-admin)?/[^/]+?$|', '/', $this->caller);
if (!$bbpath) {
echo 'Could not determine base path.';
die();
}
define('BB_PATH', $bbpath);
}
if (!defined('BB_INC')) {
// Define BB_INC
// Tell us to load includes because bb-settings.php was not loaded
// bb-settings.php is generally not loaded on steps -1, 0 and 1 but
// there are exceptions, so this is safer than just reading the step
$this->load_includes = true;
define('BB_INC', 'bb-includes/');
}
// Define the language file directory
if ( !defined('BB_LANG_DIR') )
define('BB_LANG_DIR', BB_PATH . BB_INC . 'languages/'); // absolute path with trailing slash
return true;
}
/**
* Gets an array of available languages form the language directory
*
* @return array
**/
function get_languages()
{
foreach (bb_glob(BB_LANG_DIR . '*.mo') as $language) {
$language = str_replace('.mo', '', basename($language));
$this->languages[$language] = $language;
}
return $this->languages;
}
/**
* Returns a language selector for switching installation languages
*
* @return string|false Either the html for the selector or false if there are no languages
**/
function get_language_selector()
{
// Don't provide a selection if there is only english
if (count($this->languages) < 2) {
return false;
}
$r = '' . "\n";
$r .= '' . "\n";
return $r;
}
/**
* Sets the current installation language
*
* @return string The currently set language
**/
function set_language()
{
if (isset($_COOKIE['bb_install_language']) && count($this->languages) > 1) {
if (in_array($_COOKIE['bb_install_language'], $this->languages)) {
$this->language = $_COOKIE['bb_install_language'];
}
}
if ($_GET['language'] && count($this->languages) > 1) {
if (in_array($_GET['language'], $this->languages)) {
$this->language = $_GET['language'];
setcookie('bb_install_language', $this->language);
}
}
if (!$this->language || $this->language == 'en_US') {
$this->language = 'en_US';
setcookie('bb_install_language', ' ', time() - 31536000);
}
return $this->language;
}
/**
* database_tables_are_installed() - Tests whether database tables exist
*
* Checks for the existence of the forum table in the database that is
* currently configured.
*
* @return boolean False if the table isn't found, otherwise true
**/
function database_tables_are_installed()
{
if ($this->load_includes) {
require_once(BB_PATH . BB_INC . 'db.php');
} else {
global $bbdb;
}
$bbdb->hide_errors();
$installed = (boolean) $bbdb->get_var("SELECT forum_id FROM $bbdb->forums LIMIT 1");
$bbdb->show_errors();
return $installed;
}
function bb_options_are_set()
{
if (!$this->load_includes) {
if (bb_get_option('uri')) {
return true;
}
}
return false;
}
function is_installed()
{
if ($this->database_tables_are_installed()) {
if ($this->bb_options_are_set()) {
return true;
}
}
return false;
}
function check_configs()
{
// Check for a config file
if (file_exists(BB_PATH . 'bb-config.php')) {
$this->configs['bb-config.php'] = BB_PATH . 'bb-config.php';
} elseif (file_exists(dirname(BB_PATH) . '/bb-config.php')) {
$this->configs['bb-config.php'] = dirname(BB_PATH) . '/bb-config.php';
}
// Check for an old config file
if (file_exists(BB_PATH . 'config.php')) {
$this->configs['config.php'] = BB_PATH . 'config.php';
} elseif (file_exists(dirname(BB_PATH) . '/config.php')) {
$this->configs['config.php'] = dirname(BB_PATH) . '/config.php';
}
if ($this->configs['config.php']) {
// There is an old school config file
// Step -1 is where we send fatal errors from any screen
$this->strings[-1]['messages']['error'][] = __('An old config.php
file has been detected in your installation. You should remove it and run the installer again. You can use the same database connection details if you do.');
$this->step = -1;
return $this->step;
}
// Check if bbPress is already installed
// Is there a current config file
if ($this->configs['bb-config.php']) {
// Is it valid
if ($this->validate_current_config()) {
// Step 1 is complete
$this->step_status[1] = 'complete';
$this->strings[1]['status'] = __('« completed');
// On step 1 we want to report that the file is good and allow the user to continue
if ($this->step === 1) {
// Stop form processing if it is posted
$this->stop_process = true;
// Display a nice message saying the config file exists
$this->strings[1]['messages']['message'][] = __('A valid configuration file was found at bb-config.php
bb-config.php
bb-config-sample.php
bb-config.php
file. This usually means that you want to install bbPress.');
$this->step = 0;
}
}
// Check if the config file path is writable
if ( file_exists($this->configs['bb-config.php']) ) {
if ( is_writable($this->configs['bb-config.php']) ) {
$this->configs['writable'] = true;
}
} elseif ( is_writable(BB_PATH) ) {
$this->configs['writable'] = true;
}
return $this->step;
}
function validate_current_config()
{
// If we are validating then the config file has already been included
// So we can just check for valid constants
// The required constants for a valid config file
$required_constants = array(
'BBDB_NAME',
'BBDB_USER',
'BBDB_PASSWORD',
'BBDB_HOST'
);
// Check the required constants are defined
foreach ($required_constants as $required_constant) {
if (!defined($required_constant)) {
return false;
}
}
global $bb_table_prefix;
if (!isset($bb_table_prefix)) {
return false;
}
// Everthing is OK so far, validate the connection as well
return $this->validate_current_database();
}
function validate_current_database()
{
if ($this->load_includes) {
require_once(BB_PATH . BB_INC . 'db.php');
} else {
global $bbdb;
}
if (!is_resource($bbdb->dbh_local)) {
return false;
}
return true;
}
function prepare_data()
{
$this->data = array(
1 => array(
'form' => array(
'bbdb_name' => array(
'value' => '',
'label' => __('Database name:'),
'note' => __('The name of the database in which you want to run bbPress.')
),
'bbdb_user' => array(
'value' => '',
'label' => __('Database user:'),
'note' => __('The database user that has access to that database.')
),
'bbdb_password' => array(
'type' => 'password',
'value' => '',
'label' => __('Database password:'),
'note' => __('That database user\'s password.')
),
'bb_lang' => array(
'value' => '',
'label' => __('Language'),
'note' => sprintf(__('The language which bbPress will be presented in once installed. Your current language choice (%s) will remain for the rest of the install process.'), $this->language)
),
'toggle_1' => array(
'value' => 0,
'label' => __('Show advanced settings:'),
'note' => __('99% of the time these settings will not have to be changed.'),
'checked' => '',
'display' => 'none'
),
'bbdb_host' => array(
'value' => 'localhost',
'label' => __('Database host:'),
'note' => __('The domain name or IP address of the server where the database is located. If the database is on the same server as the web site, then this probably should remain localhost.'),
'prerequisite' => 'toggle_1'
),
'bbdb_charset' => array(
'value' => 'utf8',
'label' => __('Database character set:'),
'note' => __('The best choice is utf8, but you will need to match the character set which you created the database with.'),
'prerequisite' => 'toggle_1'
),
'bbdb_collate' => array(
'value' => '',
'label' => __('Database character collation:'),
'note' => __('The character collation value set when the database was created.'),
'prerequisite' => 'toggle_1'
),
'bb_secret_key' => array(
'value' => '',
'label' => __('bbPress cookie secret key:'),
'note' => __('This should be a unique and secret phrase, it will be used to make your bbPress cookies unique and harder for an attacker to decipher.'),
'prerequisite' => 'toggle_1'
),
'bb_table_prefix' => array(
'value' => 'bb_',
'label' => __('Table name prefix:'),
'note' => __('If you are running multiple bbPress installations in a single database, you will probably want to change this.'),
'prerequisite' => 'toggle_1'
),
'config' => array(
'value' => '',
'label' => __('Contents for bb-config.php
:'),
'note' => __('Once you have created the configuration file, you can check for it below.')
),
'forward_1_0' => array(
'value' => __('Save database configuration file »')
),
'back_1_1' => array(
'value' => __('« Go back')
),
'forward_1_1' => array(
'value' => __('Check for configuration file »')
),
'forward_1_2' => array(
'value' => __('Go to step 2 »')
)
)
),
2 => array(
'form' => array(
'toggle_2_0' => array(
'value' => 0,
'label' => __('Add integration settings:'),
'note' => __('If you want to integrate bbPress with an existing WordPress installation.'),
'checked' => '',
'display' => 'none',
'toggle_value' => array(
'target' => 'forward_2_0',
'off_value' => __('Skip WordPress integration »'),
'on_value' => __('Save WordPress integration settings »')
)
),
'toggle_2_1' => array(
'value' => 0,
'label' => __('Add cookie integration settings:'),
'note' => __('If you want to allow shared logins with an existing WordPress installation.'),
'checked' => '',
'display' => 'none',
'prerequisite' => 'toggle_2_0'
),
'wp_siteurl' => array(
'value' => '',
'label' => __('WordPress address (URL):'),
'note' => __('This value should exactly match the WordPress address (URL) setting in your WordPress general settings.'),
'prerequisite' => 'toggle_2_1'
),
'wp_home' => array(
'value' => '',
'label' => __('Blog address (URL):'),
'note' => __('This value should exactly match the Blog address (URL) setting in your WordPress general settings.'),
'prerequisite' => 'toggle_2_1'
),
'wp_secret_key' => array(
'value' => '',
'label' => __('WordPress cookie secret key:'),
'note' => __('This value must match the value of the constant named "SECRET_KEY" in your WordPress wp-config.php
file. This will replace the bbPress cookie secret key set in the first step.'),
'prerequisite' => 'toggle_2_1'
),
'wp_secret' => array(
'value' => '',
'label' => __('WordPress database secret:'),
'note' => __('This must match the value of the WordPress setting named "secret" in your WordPress installation. Look for the option labeled "secret" in this WordPress admin page. If you leave this blank the installer will try to fetch the value based on your WordPress database integration settings.'),
'prerequisite' => 'toggle_2_1'
),
'toggle_2_2' => array(
'value' => 0,
'label' => __('Add user database integration settings:'),
'note' => __('If you want to share user data with an existing WordPress installation.'),
'checked' => '',
'display' => 'none',
'prerequisite' => 'toggle_2_0'
),
'wp_table_prefix' => array(
'value' => 'wp_',
'label' => __('User database table prefix:'),
'note' => __('If your bbPress and WordPress installations share the same database, then this is the same value as $wp_table_prefix
in your WordPress wp-config.php
file. It is usually wp_.'),
'prerequisite' => 'toggle_2_2'
),
'toggle_2_3' => array(
'value' => 0,
'label' => __('Show advanced database settings:'),
'note' => __('If your bbPress and WordPress installation do not share the same database, then you will need to add advanced settings.'),
'checked' => '',
'display' => 'none',
'prerequisite' => 'toggle_2_2'
),
'user_bbdb_name' => array(
'value' => '',
'label' => __('User database name:'),
'note' => __('The name of the database in which your user tables reside.'),
'prerequisite' => 'toggle_2_3'
),
'user_bbdb_user' => array(
'value' => '',
'label' => __('User database user:'),
'note' => __('The database user that has access to that database.'),
'prerequisite' => 'toggle_2_3'
),
'user_bbdb_password' => array(
'type' => 'password',
'value' => '',
'label' => __('User database password:'),
'note' => __('That database user\'s password.'),
'prerequisite' => 'toggle_2_3'
),
'user_bbdb_host' => array(
'value' => '',
'label' => __('User database host:'),
'note' => __('The domain name or IP address of the server where the database is located. If the database is on the same server as the web site, then this probably should be localhost.'),
'prerequisite' => 'toggle_2_3'
),
'user_bbdb_charset' => array(
'value' => '',
'label' => __('User database character set:'),
'note' => __('The best choice is utf8, but you will need to match the character set which you created the database with.'),
'prerequisite' => 'toggle_2_3'
),
'custom_user_table' => array(
'value' => '',
'label' => __('User database "user" table:'),
'note' => __('The complete table name, including any prefix.'),
'prerequisite' => 'toggle_2_3'
),
'custom_user_meta_table' => array(
'value' => '',
'label' => __('User database "user meta" table:'),
'note' => __('The complete table name, including any prefix.'),
'prerequisite' => 'toggle_2_3'
),
'forward_2_0' => array(
'value' => __('Skip WordPress integration »')
),
'back_2_1' => array(
'value' => __('« Go back')
),
'forward_2_1' => array(
'value' => __('Go to step 3 »')
)
)
),
3 => array(
'form' => array(
'name' => array(
'value' => '',
'label' => __('Site name:'),
'note' => __('This is what you are going to call your bbPress installation.')
),
'uri' => array(
'value' => $this->guess_uri(),
'label' => __('Site address (URL):'),
'note' => __('We have attempted to guess this, it\'s usually correct, but change it here if you wish.')
),
'keymaster_user_login' => array(
'value' => '',
'maxlength' => 60,
'label' => __('Username:'),
'note' => __('This is the user login for the initial bbPress administrator (known as a "key master").')
),
'keymaster_user_email' => array(
'value' => '',
'maxlength' => 100,
'label' => __('Email address:'),
'note' => __('The login details will be emailed to this address.')
),
'keymaster_user_type' => array(
'value' => 'new'
),
'forum_name' => array(
'value' => '',
'maxlength' => 150,
'label' => __('Forum name:'),
'note' => __('This can be changed after installation, so don\'t worry about it too much.')
),
'forward_3_0' => array(
'value' => __('Save site settings »')
),
'back_3_1' => array(
'value' => __('« Go back')
),
'forward_3_1' => array(
'value' => __('Complete the installation »')
)
)
),
4 => array(
'form' => array(
'toggle_4' => array(
'value' => 0,
'label' => __('Show installation messages:')
),
'error_log' => array(
'value' => '',
'label' => __('Installation errors:')
),
'installation_log' => array(
'value' => '',
'label' => __('Installation log:')
)
)
)
);
}
function guess_uri()
{
global $bb;
if ($bb->uri) {
$uri = $bb->uri;
} else {
$schema = 'http://';
if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
$schema = 'https://';
}
$uri = preg_replace('|/bb-admin/.*|i', '/', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
return rtrim($uri, '/') . '/';
}
function is_posted()
{
if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
return true;
}
return false;
}
function set_step()
{
if ($this->is_posted()) {
switch ($this->step) {
case 2:
if ($_POST['forward_1_2']) {
$this->stop_process = 1;
}
break;
case 3:
// If this is actually a request to go back to step 2
if ($_POST['back_2_1']) {
$this->step = 2;
break;
}
// If we have come forward from step 2 then don't process form 3
if ($_POST['forward_2_1']) {
$this->stop_process = true;
}
// Determine what the status of the previous step was based on input
if ($_POST['toggle_2_0']) {
$this->strings[2]['status'] = __('« completed');
$this->step_status[2] = 'complete';
}
break;
case 4:
// Determine what the status of the previous step was based on input
if ($_POST['toggle_2_0']) {
$this->strings[2]['status'] = __('« completed');
$this->step_status[2] = 'complete';
}
// If this is actually a request to go back to step 3
if ($_POST['back_3_1']) {
$this->step = 3;
break;
}
// We have to have come forward from step 3
if ($_POST['forward_3_1']) {
$this->strings[3]['status'] = __('« completed');
$this->step_status[3] = 'complete';
} else {
$this->step = 2;
}
break;
}
}
}
function sanitize_form_data()
{
foreach ($this->data as $step => $data) {
if (isset($data['form']) && is_array($data['form'])) {
foreach ($data['form'] as $key => $value) {
$this->data[$step]['form'][$key]['value'] = attribute_escape($value['value']);
}
}
}
return true;
}
function process_form()
{
if ($this->is_posted() && !$this->stop_process) {
switch ($this->step) {
case 1:
$this->process_form_config_file();
break;
case 2:
$this->process_form_wordpress_integration();
break;
case 3:
$this->process_form_site_options();
break;
case 4:
$this->process_form_finalise_installation();
break;
}
}
}
function inject_form_values_into_data($step)
{
$data =& $this->data[$step]['form'];
foreach ($data as $key => $value) {
if (substr($key, 0, 8) !== 'forward_' && substr($key, 0, 5) !== 'back_') {
$data[$key]['value'] = stripslashes_deep(trim($_POST[$key]));
if (isset($data[$key]['prerequisite']) && !$_POST[$data[$key]['prerequisite']]) {
$data[$key]['value'] = '';
}
}
}
return true;
}
function process_form_config_file()
{
$this->inject_form_values_into_data(1);
$data =& $this->data[1]['form'];
if ($data['bb_lang']['value'] == 'en_US') {
$data['bb_lang']['value'] = '';
}
$data['bb_table_prefix']['value'] = preg_replace('/[^0-9a-zA-Z_]/', '', $data['bb_table_prefix']['value']);
if (empty($data['bb_table_prefix']['value'])) {
$data['bb_table_prefix']['value'] = 'bb_';
}
if ($data['toggle_1']['value']) {
$data['toggle_1']['checked'] = 'checked="checked"';
$data['toggle_1']['display'] = 'block';
// A backslash at the end of the secret key could escape the closing quotation mark in the define
$data['bb_secret_key']['value'] = rtrim($data['bb_secret_key']['value'], "\\");
// Replace any single quotes with nothing
$data['bb_secret_key']['value'] = str_replace("'", '', $data['bb_secret_key']['value']);
}
// Stop here if we are going backwards
if ($_POST['back_1_1']) {
$this->step_status[1] = 'incomplete';
return 'incomplete';
}
// Read the contents of the sample config
if (file_exists(BB_PATH . 'bb-config-sample.php')) {
$sample_config = file(BB_PATH . 'bb-config-sample.php');
} else {
$this->step_status[1] = 'error';
$this->strings[1]['messages']['error'][] = __('I could not find the file bb-config-sample.php
bb-config.php
bb-config.php
in the root directory of your bbPress installation before you can continue.');
}
}
function process_form_wordpress_integration()
{
// Check the referer
bb_check_admin_referer('bbpress-installer');
$this->inject_form_values_into_data(2);
$data =& $this->data[2]['form'];
// If there are no settings then goto step 3
if (!$data['toggle_2_0']['value'] && !$_POST['back_2_1']) {
$this->step_status[2] = 'complete';
$this->strings[2]['messages']['message'][] = __('You have chosen to skip the WordPress integration step. You can always integrate WordPress later from within the admin area of bbPress.');
return 'complete';
}
// If integration is selected
if ($data['toggle_2_0']['value']) {
$data['toggle_2_0']['checked'] = 'checked="checked"';
$data['toggle_2_0']['display'] = 'block';
$data['forward_2_0']['value'] = $data['toggle_2_0']['toggle_value']['on_value'];
if ($data['toggle_2_1']['value']) {
$data['toggle_2_1']['checked'] = 'checked="checked"';
$data['toggle_2_1']['display'] = 'block';
// Check the wp_siteurl URL for errors
$data['wp_siteurl']['value'] = $data['wp_siteurl']['value'] ? rtrim($data['wp_siteurl']['value'], '/') . '/' : '';
$this->strings[2]['form_errors']['wp_siteurl'][] = empty($data['wp_siteurl']['value']) ? 'empty' : false;
if ($parsed = parse_url($data['wp_siteurl']['value'])) {
$this->strings[2]['form_errors']['wp_siteurl'][] = preg_match('/https?/i', $parsed['scheme']) ? false : 'urlscheme';
$this->strings[2]['form_errors']['wp_siteurl'][] = empty($parsed['host']) ? 'urlhost' : false;
} else {
$this->strings[2]['form_errors']['wp_siteurl'][] = 'urlparse';
}
// Check the wp_home URL for errors
$data['wp_home']['value'] = $data['wp_home']['value'] ? rtrim($data['wp_home']['value'], '/') . '/' : '';
$this->strings[2]['form_errors']['wp_home'][] = empty($data['wp_home']['value']) ? 'empty' : false;
if ($parsed = parse_url($data['wp_home']['value'])) {
$this->strings[2]['form_errors']['wp_home'][] = preg_match('/https?/i', $parsed['scheme']) ? false : 'urlscheme';
$this->strings[2]['form_errors']['wp_home'][] = empty($parsed['host']) ? 'urlhost' : false;
} else {
$this->strings[2]['form_errors']['wp_home'][] = 'urlparse';
}
// A backslash at the end of the secret key could escape the closing quotation mark in the define
$data['wp_secret_key']['value'] = rtrim($data['wp_secret_key']['value'], "\\");
// Replace any single quotes with nothing
$data['wp_secret_key']['value'] = str_replace("'", '', $data['wp_secret_key']['value']);
// Check the secret key for errors
$this->strings[2]['form_errors']['wp_secret_key'][] = empty($data['wp_secret_key']['value']) ? 'empty' : false;
}
// If database integration is selected
if ($data['toggle_2_2']['value']) {
$data['toggle_2_2']['checked'] = 'checked="checked"';
$data['toggle_2_2']['display'] = 'block';
// Make the wp_table_prefix valid
$data['wp_table_prefix']['value'] = preg_replace('/[^0-9a-zA-Z_]/', '', $data['wp_table_prefix']['value']);
$data['wp_table_prefix']['value'] = empty($data['wp_table_prefix']['value']) ? 'wp_' : $data['wp_table_prefix']['value'];
// If advanced database integration is selected
if ($data['toggle_2_3']['value']) {
$data['toggle_2_3']['checked'] = 'checked="checked"';
$data['toggle_2_3']['display'] = 'block';
}
}
if (!$data['toggle_2_1']['value'] && !$data['toggle_2_2']['value']) {
$this->step_status[2] = 'incomplete';
$this->strings[2]['messages']['error'][] = __('You must enter your settings for integration setup to complete. Choose which integration settings you wish to enter from the options below.');
$this->strings[2]['form_errors']['toggle_2_1'][] = true;
$this->strings[2]['form_errors']['toggle_2_2'][] = true;
return 'incomplete';
}
// Remove empty values from the error array
foreach ($this->strings[2]['form_errors'] as $input => $types) {
$types = array_filter($types);
if (!count($types)) {
unset($this->strings[2]['form_errors'][$input]);
}
}
// Check for errors and build error messages
if ( count($this->strings[2]['form_errors']) ) {
$this->step_status[2] = 'incomplete';
$this->strings[2]['messages']['error'][] = __('Your integration settings have not been processed due to errors with the items marked below.');
foreach ($this->strings[2]['form_errors'] as $input => $types) {
$errors = array();
foreach ($types as $type) {
switch ($type) {
case 'empty':
// Only return this error when empty
$errors = array(__('• This value is required to continue.'));
break(2);
case 'urlparse':
$errors[] = __('• This does not appear to be a valid URL.');
break;
case 'urlscheme':
$errors[] = __('• The URL must begin with "http" or "https".');
break;
case 'urlhost':
$errors[] = __('• The URL does not contain a host name.');
break;
}
}
$this->strings[2]['form_errors'][$input] = $errors;
}
return 'incomplete';
}
// If database integration is selected
if ($data['toggle_2_2']['value']) {
// Test the db connection.
// Setup variables and constants if available
global $bb;
$bb->wp_table_prefix = $data['wp_table_prefix']['value'];
if ($data['toggle_2_3']['value']) {
// These may be empty at this particular stage
if ( !empty($data['user_bbdb_name']['value']) )
$bb->user_bbdb_name = $data['user_bbdb_name']['value'];
if ( !empty($data['user_bbdb_user']['value']) )
$bb->user_bbdb_user = $data['user_bbdb_user']['value'];
if ( !empty($data['user_bbdb_password']['value']) )
$bb->user_bbdb_password = $data['user_bbdb_password']['value'];
if ( !empty($data['user_bbdb_host']['value']) )
$bb->user_bbdb_host = $data['user_bbdb_host']['value'];
if ( !empty($data['user_bbdb_charset']['value']) )
$bb->user_bbdb_charset = preg_replace( '/[^a-z0-9_-]/i', '', $data['user_bbdb_charset']['value'] );
if ( !empty($data['custom_user_table']['value']) )
$bb->custom_user_table = preg_replace( '/[^a-z0-9_-]/i', '', $data['custom_user_table']['value'] );
if ( !empty($data['custom_user_meta_table']['value']) )
$bb->custom_user_meta_table = preg_replace( '/[^a-z0-9_-]/i', '', $data['custom_user_meta_table']['value'] );
}
// Bring in the database object
global $bbdb;
// Set the new prefix for user tables
$bbdb->set_prefix( $bb->wp_table_prefix, array('users', 'usermeta') );
// Set the user table's character set if defined
if ( isset($bb->user_bbdb_charset) && $bb->user_bbdb_charset )
$bbdb->user_charset = $bb->user_bbdb_charset;
// Set the user table's custom name if defined
if ( isset($bb->custom_user_table) && $bb->custom_user_table )
$bbdb->users = $bb->custom_user_table;
// Set the usermeta table's custom name if defined
if ( isset($bb->custom_user_meta_table) && $bb->custom_user_meta_table )
$bbdb->usermeta = $bb->custom_user_meta_table;
// Hide errors for the test
$bbdb->return_errors();
// Select from the user table (may fail if there are no records in the table)
if (!$result = $bbdb->query('DESCRIBE ' . $bbdb->users . ';')) {
// We couldn't connect to the database at all
// Turn errors back on
$bbdb->show_errors();
// Set the status
$this->step_status[2] = 'incomplete';
if ( !empty($data['user_bbdb_name']['value']) )
$this->strings[2]['form_errors']['user_bbdb_name'][] = true;
if ( !empty($data['user_bbdb_user']['value']) )
$this->strings[2]['form_errors']['user_bbdb_user'][] = true;
if ( !empty($data['user_bbdb_password']['value']) )
$this->strings[2]['form_errors']['user_bbdb_password'][] = true;
if ( !empty($data['user_bbdb_host']['value']) )
$this->strings[2]['form_errors']['user_bbdb_host'][] = true;
if ( !empty($data['custom_user_table']['value']) )
$this->strings[2]['form_errors']['custom_user_table'][] = true;
if ( !empty($data['custom_user_meta_table']['value']) )
$this->strings[2]['form_errors']['custom_user_meta_table'][] = true;
$this->strings[2]['messages']['error'][] = __('There was a problem connecting to the WordPress user database you specified. Please check the settings, then try again.');
return 'incomplete';
}
if (is_array($result)) {
// The result is an error, presumably telling us the table doesn't exist
// Turn errors back on
$bbdb->show_errors();
// Set the status
$this->step_status[2] = 'incomplete';
if ($data['toggle_2_3']['value']) {
$this->strings[2]['messages']['error'][] = __('Existing WordPress user tables could not be found in the WordPress database you specified.');
} else {
$this->strings[2]['messages']['error'][] = __('Existing WordPress user tables could not be found in the bbPress database you specified in step 1.' . $data['note'] . '
' . "\n"; } echo $r; } function input_hidden($key) { $r = '' . "\n"; echo $r; } function textarea($key, $direction = false) { $data = $this->data[$this->step]['form'][$key]; $r = '' . "\n"; if (isset($data['note'])) { $r .= '' . $data['note'] . '
' . "\n"; } echo $r; } function select($key) { $data = $this->data[$this->step]['form'][$key]; $r = '' . "\n"; if (isset($data['note'])) { $r .= '' . $data['note'] . '
' . "\n"; } echo $r; } function select_language() { if (count($this->languages) > 1) { $this->data[1]['form']['bb_lang']['value'] = $this->language; $this->data[1]['form']['bb_lang']['options'] = $this->languages; $this->select('bb_lang'); } else { $this->data[1]['form']['bb_lang']['value'] = 'en_US'; $this->input_hidden('bb_lang'); } } function input_toggle($key) { $data = $this->data[$this->step]['form'][$key]; $onclick = 'toggleBlock(this, \'' . $key . '_target\');'; if (isset($data['toggle_value'])) { $onclick .= ' toggleValue(this, \'' . $data['toggle_value']['target'] . '\', \'' . $data['toggle_value']['off_value'] . '\', \'' . $data['toggle_value']['on_value'] . '\');'; } $checked = $data['checked'] ? ' ' . trim($data['checked']) : ''; if (isset($this->strings[$this->step]['form_errors'][$key])) { $class = ' class="error"'; } $r = '' . "\n"; if (isset($data['note'])) { $r .= '' . $data['note'] . '
' . "\n"; } echo $r; } function input_buttons($forward, $back = false) { $data_back = $back ? $this->data[$this->step]['form'][$back] : false; $data_forward = $this->data[$this->step]['form'][$forward]; $r = '' . "\n"; echo $r; } function hidden_step_inputs($step = false) { if (!$step) { $step = $this->step; } elseif ($step !== $this->step) { $this->inject_form_values_into_data($step); } $data = $this->data[$step]['form']; $r = '' . "\n"; echo $r; } function populate_keymaster_user_login_from_user_tables() { $data =& $this->data[3]['form']['keymaster_user_login']; // Get the existing WordPress admin users // Setup variables and constants if available global $bb; if ( !empty($this->data[2]['form']['wp_table_prefix']['value']) ) $bb->wp_table_prefix = $this->data[2]['form']['wp_table_prefix']['value']; if ( !empty($this->data[2]['form']['user_bbdb_name']['value']) ) $bb->user_bbdb_name = $this->data[2]['form']['user_bbdb_name']['value']; if ( !empty($this->data[2]['form']['user_bbdb_user']['value']) ) $bb->user_bbdb_user = $this->data[2]['form']['user_bbdb_user']['value']; if ( !empty($this->data[2]['form']['user_bbdb_password']['value']) ) $bb->user_bbdb_password = $this->data[2]['form']['user_bbdb_password']['value']; if ( !empty($this->data[2]['form']['user_bbdb_host']['value']) ) $bb->user_bbdb_host = $this->data[2]['form']['user_bbdb_host']['value']; if ( !empty($this->data[2]['form']['user_bbdb_charset']['value']) ) $bb->user_bbdb_charset = preg_replace( '/[^a-z0-9_-]/i', '', $this->data[2]['form']['user_bbdb_charset']['value'] ); if ( !empty($this->data[2]['form']['custom_user_table']['value']) ) $bb->custom_user_table = preg_replace( '/[^a-z0-9_-]/i', '', $this->data[2]['form']['custom_user_table']['value'] ); if ( !empty($this->data[2]['form']['custom_user_meta_table']['value']) ) $bb->custom_user_meta_table = preg_replace( '/[^a-z0-9_-]/i', '', $this->data[2]['form']['custom_user_meta_table']['value'] ); global $bbdb; // Set the new prefix for user tables $bbdb->set_prefix( $bb->wp_table_prefix, array('users', 'usermeta') ); // Set the user table's character set if defined if ( isset($bb->user_bbdb_charset) && $bb->user_bbdb_charset ) $bbdb->user_charset = $bb->user_bbdb_charset; // Set the user table's custom name if defined if ( isset($bb->custom_user_table) && $bb->custom_user_table ) $bbdb->users = $bb->custom_user_table; // Set the usermeta table's custom name if defined if ( isset($bb->custom_user_meta_table) && $bb->custom_user_meta_table ) $bbdb->usermeta = $bb->custom_user_meta_table; global $bb_table_prefix; $bb_keymaster_meta_key = $bbdb->escape( $bb_table_prefix . 'capabilities' ); $wp_administrator_meta_key = $bbdb->escape( $bb->wp_table_prefix . 'capabilities' ); $keymaster_query = <<' . "\n"; if ($type) { $r .= '' . $first_character . '' . "\n"; } $r .= $paragraph . "\n"; $r .= '
' . "\n"; } } echo $r; } } function intro() { if ($this->step_status[$this->step] == 'incomplete' && isset($this->strings[$this->step]['intro'])) { $messages = $this->strings[$this->step]['intro']; $count = count($messages); $i = 0; $r = ''; foreach ($messages as $paragraph) { $i++; $class = ($i === $count) ? 'intro last' : 'intro'; $r .= '' . $paragraph . '
' . "\n"; } echo $r; } } function step_header($step) { $class = ($step == $this->step) ? 'open' : 'closed'; $r = '' . $this->strings[$step]['status'] . '
' . "\n"; } echo $r; if ($step == $this->step) { $this->intro(); $this->messages(); } } function step_footer() { $r = '\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."
{$table}:\n"; } //else echo "
Found index:".$index_string."
{$table}:\n"; } } // For every remaining index specified for the table foreach($indices as $index) { // Push a query line into $cqueries that adds the index to that table $cqueries[] = "ALTER TABLE {$table} ADD $index"; $for_update[$table.'.'.$fieldname] = 'Added index '.$table.' '.$index; } // Remove the original table creation query from processing unset($cqueries[strtolower($table)]); unset($for_update[strtolower($table)]); } else { // This table exists in the database, but not in the creation queries? } } } $allqueries = array_merge($cqueries, $iqueries); if($execute) { foreach($allqueries as $query_index => $query) { //echo "
Did not find index:".$index_string."
".print_r($indices, true)."
".print_r($query, true)."\n"; $result = $bbdb->query($query); if ( is_array($result) ) { // There was an error and $bbdb->show_errors = 2 $for_update[$query_index] = array( 'original' => array( 'message' => $for_update[$query_index], 'query' => $query ), 'error' => array( 'message' => $result['error_str'], 'query' => $result['query'] ) ); } } } return $for_update; } /** ** bb_maybe_add_column() ** Add column to db table if it doesn't exist. ** Returns: true if already exists or on successful completion ** false on error */ function bb_maybe_add_column( $table_name, $column_name, $create_ddl ) { global $bbdb, $debug; foreach ($bbdb->get_col("DESC $table_name", 0) as $column ) { if ($debug) echo("checking $column == $column_name
Get back to work!'), bb_get_option( 'uri' ) . 'bb-admin/' ); ?>
! You can update it here.'); ?>
! back to your forums.
Attempting to go to the admin area will launch the database upgrader again.'), bb_get_option('uri')); ?>
{$errors[0]}
"; break; default : $message = "\n\t" . __('« Back to All Users') . "\n
\n\n"; $r .= '" . __('ID') . " | \n"; if ( $show_email ) { $r .= "\t\t" . __('Username') . " | \n"; $r .= "\t\t" . __('Email') . " | \n"; } else { $r .= "\t\t" . __('Username') . " | \n"; } $r .= "\t\t" . __('Registered Since') . " | \n"; $r .= "\t\t" . __('Actions') . " | \n"; $r .= "\t
---|
Note: updating these settings may cause you to be logged out!'); ?>
' . "\n"; $roles .= '' . "\n"; global $bb_roles; foreach ($bb_roles->get_names() as $key => $value) { if ($key == $set) { $selected = ' selected="selected"'; } else { $selected = ''; } $roles .= '' . "\n"; } $roles .= '' . "\n"; return $roles; } $wpRoles = array( 'administrator' => 'Administrator', 'editor' => 'Editor', 'author' => 'Author', 'contributor' => 'Contributor', 'subscriber' => 'Subscriber' ); $wpRolesMap = bb_get_option('wp_roles_map'); ?>