function bb_upgrade_1130()
{
    if ($dbv = bb_get_option_from_db('bb_db_version') && $dbv >= 2471) {
        return;
    }
    // If the option is already there, then return
    if (bb_get_option('enable_subscriptions')) {
        return;
    }
    bb_update_option('enable_subscriptions', 1);
    bb_update_option('bb_db_version', 2471);
    return 'Added subscriptions option and set its value to true: ' . __FUNCTION__;
}
Esempio n. 2
0
    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';
        } else {
            $step = 'error';
        }
        nxt_cache_flush();
    }
}
bb_install_header(__('bbPress database upgrade'), false, true);
?>
		<script type="text/javascript" charset="utf-8">
			function toggleAdvanced(toggle, target) {
				var toggleObj = document.getElementById(toggle);
				var targetObj = document.getElementById(target);
				if (toggleObj.checked) {
					targetObj.style.display = 'block';
Esempio n. 3
0
<?php

define('BB_IS_ADMIN', true);
require_once '../bb-load.php';
bb_ssl_redirect();
bb_auth();
if (bb_get_option('bb_db_version') > bb_get_option_from_db('bb_db_version')) {
    bb_safe_redirect('upgrade.php');
    die;
}
require_once BB_PATH . 'bb-admin/includes/functions.bb-admin.php';
$bb_admin_page = bb_find_filename($_SERVER['PHP_SELF']);
$_check_callback = false;
if ($bb_admin_page == 'admin-base.php') {
    $bb_admin_page = (string) @$_GET['plugin'];
    $_check_callback = true;
}
wp_enqueue_script('common');
bb_user_settings();
if (isset($_GET['foldmenu'])) {
    if ($_GET['foldmenu']) {
        bb_update_user_setting('fm', 'f');
    } else {
        bb_delete_user_setting('fm');
    }
    bb_safe_redirect(remove_query_arg('foldmenu', stripslashes($_SERVER['REQUEST_URI'])));
    die;
}
bb_admin_menu_generator();
bb_get_current_admin_menu();
if ($_check_callback) {
function bb_upgrade_1120()
{
    if (($dbv = bb_get_option_from_db('bb_db_version')) && $dbv >= 2078) {
        return;
    }
    // No matter what happens, update the db version
    bb_update_option('bb_db_version', 2078);
    if (!defined('BB_THEME_DIR')) {
        return;
    }
    if (!BB_THEME_DIR) {
        return;
    }
    if (file_exists(BB_THEME_DIR)) {
        return;
    }
    // Just suppress errors as this is not critical
    if (@mkdir(BB_THEME_DIR, 0755)) {
        return 'Making theme directory at ' . BB_THEME_DIR . ': ' . __FUNCTION__;
    }
    return;
}
Esempio n. 5
0
/**
 * Returns the requested bbPress option from the meta table or the $bb object
 *
 * @param string The option to be echoed
 * @return mixed The value of the option
 */
function bb_get_option($option)
{
    // Allow plugins to short-circuit options.
    if (false !== ($r = apply_filters('bb_pre_get_option_' . $option, false, $option))) {
        return $r;
    }
    global $bb;
    switch ($option) {
        case 'site_id':
            if (isset($bb->site_id) && is_numeric($bb->site_id)) {
                $r = (int) $bb->site_id;
            } else {
                $r = 1;
            }
            break;
        case 'language':
            $r = str_replace('_', '-', bb_get_locale());
            break;
        case 'text_direction':
            global $bb_locale;
            $r = $bb_locale->text_direction;
            break;
        case 'version':
            return '1.1';
            // Don't filter
            break;
        case 'bb_db_version':
            return '2471';
            // Don't filter
            break;
        case 'html_type':
            $r = 'text/html';
            break;
        case 'charset':
            $r = 'UTF-8';
            break;
        case 'bb_table_prefix':
        case 'table_prefix':
            global $bbdb;
            return $bbdb->prefix;
            // Don't filter;
            break;
        case 'url':
            $option = 'uri';
        default:
            if (isset($bb->{$option})) {
                $r = $bb->{$option};
                if ($option === 'mod_rewrite') {
                    if (is_bool($r)) {
                        $r = (int) $r;
                    }
                }
                break;
            }
            $r = bb_get_option_from_db($option);
            if (!$r) {
                switch ($option) {
                    case 'name':
                        $r = __('Please give me a name!');
                        break;
                    case 'nxt_table_prefix':
                        global $nxt_table_prefix;
                        // This global is deprecated
                        return $nxt_table_prefix;
                        // Don't filter;
                        break;
                    case 'mod_rewrite':
                        $r = 0;
                        break;
                    case 'page_topics':
                        $r = 30;
                        break;
                    case 'edit_lock':
                        $r = 60;
                        break;
                    case 'gmt_offset':
                        $r = 0;
                        break;
                    case 'uri_ssl':
                        $r = preg_replace('|^http://|i', 'https://', bb_get_option('uri'));
                        break;
                    case 'throttle_time':
                        $r = 30;
                        break;
                    case 'email_login':
                        $r = false;
                        break;
                }
            }
            break;
    }
    return apply_filters('bb_get_option_' . $option, $r, $option);
}
Esempio n. 6
0
 /**
  * Checks for configs and sets variables describing current install state
  *
  * @return integer The current step we should be on based on the existence of the config file
  */
 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'] && !$this->configs['bb-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 <code>config.php</code> file has been detected in your installation. You should remove it and run the <a href="install.php">installer</a> 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'] = __('&laquo; 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 <code>bb-config.php</code><br />You may continue to the next step.');
                 return $this->step;
             }
         } else {
             // Invalid config files on any step cause us to exit to step 0
             $this->strings[-1]['messages']['error'][] = __('An invalid configuration file was found at <code>bb-config.php</code><br />The installation cannot continue.');
             $this->strings[-1]['messages'][0][] = __('Usually this is caused by one of the database connection settings being incorrect. Make sure that the specified user has appropriate permission to access the database.');
             $this->step = -1;
         }
         // If we have made it this far, then we can check if the database tables exist and have content
         if ($this->is_installed()) {
             // The database is installed
             // The following standard functions should be available
             if (bb_get_option('bb_db_version') > bb_get_option_from_db('bb_db_version')) {
                 // The database needs upgrading
                 $this->strings[-1]['messages'][0][] = __('bbPress is already installed, but appears to require an upgrade.');
             } else {
                 $this->strings[-1]['messages'][0][] = __('bbPress is already installed.');
             }
             $this->strings[-1]['messages'][0][] = sprintf(__('Perhaps you meant to run the <a href="%s">upgrade script</a> instead?'), bb_get_uri('bb-admin/upgrade.php', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN));
             $this->step = -1;
         }
     } else {
         if (2 > $this->step && !file_exists(BB_PATH . 'bb-config-sample.php')) {
             // There is no sample config file
             $this->strings[0]['messages']['error'][] = __('I could not find the file <code>bb-config-sample.php</code><br />Please upload it to the root directory of your bbPress installation.');
             $this->step = 0;
         }
         if (1 !== $this->step) {
             // There is no config file, go back to the beginning
             $this->strings[0]['messages']['message'][] = __('There doesn\'t seem to be a <code>bb-config.php</code> 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;
 }