_e('The update process may take a little while, so please be patient.');
            ?>
</p>
            <p class="step"><a class="button button-large"
                               href="upgrade.php?step=1&amp;backto=<?php 
            echo $goback;
            ?>
"><?php 
            _e('Update WordPress Database');
            ?>
</a>
            </p>
            <?php 
            break;
        case 1:
            wp_upgrade();
            $backto = !empty($_GET['backto']) ? wp_unslash(urldecode($_GET['backto'])) : __get_option('home') . '/';
            $backto = esc_url($backto);
            $backto = wp_validate_redirect($backto, __get_option('home') . '/');
            ?>
            <h2><?php 
            _e('Update Complete');
            ?>
</h2>
            <p><?php 
            _e('Your WordPress database has been successfully updated!');
            ?>
</p>
            <p class="step"><a class="button button-large" href="<?php 
            echo $backto;
            ?>
Exemple #2
0
 /**
  * Update the WordPress database.
  *
  * @subcommand update-db
  */
 function update_db()
 {
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     wp_upgrade();
     WP_CLI::success('WordPress database upgraded successfully.');
 }
Exemple #3
0
 /**
  * Update the WordPress database.
  *
  * [--network]
  * : Update databases for all sites on a network
  *
  * [--dry-run]
  * : Compare database versions without performing the update.
  *
  * @subcommand update-db
  */
 function update_db($_, $assoc_args)
 {
     global $wpdb, $wp_db_version, $wp_current_db_version;
     $network = Utils\get_flag_value($assoc_args, 'network');
     if ($network && !is_multisite()) {
         WP_CLI::error('This is not a multisite install.');
     }
     $dry_run = Utils\get_flag_value($assoc_args, 'dry-run');
     if ($dry_run) {
         WP_CLI::log('Performing a dry run, with no database modification.');
     }
     if ($network) {
         $iterator_args = array('table' => $wpdb->blogs, 'where' => array('spam' => 0, 'deleted' => 0, 'archived' => 0));
         $it = new \WP_CLI\Iterators\Table($iterator_args);
         $success = $total = 0;
         foreach ($it as $blog) {
             $total++;
             $url = $blog->domain . $blog->path;
             $process = WP_CLI::launch_self('core update-db', array(), array(), false, true, array('url' => $url, 'dry-run' => $dry_run));
             if (0 == $process->return_code) {
                 // See if we can parse the stdout
                 if (preg_match('#Success: (.+)#', $process->stdout, $matches)) {
                     $message = "{$matches[1]} on {$url}";
                 } else {
                     $message = "Database upgraded successfully on {$url}";
                 }
                 WP_CLI::log($message);
                 $success++;
             } else {
                 WP_CLI::warning("Database failed to upgrade on {$url}");
             }
         }
         if (!$dry_run && $total && $success == $total) {
             update_site_option('wpmu_upgrade_site', $wp_db_version);
         }
         WP_CLI::success(sprintf('WordPress database upgraded on %d/%d sites', $success, $total));
     } else {
         require_once ABSPATH . 'wp-admin/includes/upgrade.php';
         $wp_current_db_version = __get_option('db_version');
         if ($wp_db_version != $wp_current_db_version) {
             if (!$dry_run) {
                 wp_upgrade();
             }
             WP_CLI::success("WordPress database upgraded successfully from db version {$wp_current_db_version} to {$wp_db_version}");
         } else {
             WP_CLI::success("WordPress database already at latest db version {$wp_db_version}");
         }
     }
 }
 public static function upgradeWordpressDB(Event $e)
 {
     $io = $e->getIO();
     $_SERVER = array("HTTP_HOST" => 'localhost', "SCRIPT_FILENAME" => realpath(__DIR__ . '/../../../web/wp/wp-admin/includes/upgrade.php'), "SCRIPT_NAME" => '/wp/wp-admin/includes/upgrade.php', "PHP_SELF" => '/wp/wp-admin/includes/upgrade.php', "REQUEST_URI" => "/", "REQUEST_METHOD" => "GET");
     include_once __DIR__ . '/../../../web/wp/wp-load.php';
     include_once __DIR__ . '/../../../web/wp/wp-admin/includes/upgrade.php';
     $io->write('<info>Starting to upgrade WordPress Database</info>');
     try {
         \wp_upgrade();
     } catch (\Exception $e) {
         $io->write('<error>Unable to upgrade wordpress</error>');
         return;
     }
     $io->write('<info>WordPress Upgrade Complete!</info>');
 }
 /**
  * Import sample data action.
  *
  * @return  mixed  Either an array of skipped plugins or null.
  */
 protected function import_data_action()
 {
     global $wpdb, $table_prefix;
     try {
         // Get current home and site URL
         $siteurl = call_user_func('get_option', 'siteurl');
         $home = call_user_func('get_option', 'home');
         // Get session tokens of current user
         $session_tokens = get_user_meta(get_current_user_id(), 'session_tokens', true);
         // Get path to sample data XML declaration file
         $xml = $this->_extract_package();
         // Parse sample data package
         $xml = $this->_parse_sample_data();
         // Get all tables in database
         $existing_tables = $wpdb->get_results('SHOW TABLES;', ARRAY_N);
         foreach ($existing_tables as &$existing_table) {
             $existing_table = $existing_table[0];
         }
         // Pre-define database backup queries
         $backups = array();
         foreach ($xml->xpath('//product/extension') as $plugin) {
             // Check plugin installation state
             if ('wordpress' != $plugin['name'] && isset($plugin['downloadurl'])) {
                 $pluginAttrs = (array) $plugin->attributes();
                 $pluginAttrs = $pluginAttrs['@attributes'];
                 $pluginAttrs['version'] = isset($pluginAttrs['version']) ? $pluginAttrs['version'] : '';
                 $pluginAttrs['state'] = $this->_get_plugin_state((string) $pluginAttrs['name'], (string) $pluginAttrs['version']);
                 if ('installed' != $pluginAttrs['state']) {
                     $skipped_plugins[] = $pluginAttrs;
                     continue;
                 }
                 // Store installed plugins
                 $installed_plugins[(string) $pluginAttrs['name']] = $pluginAttrs;
             }
             // Backup current plugin data
             $tables = $plugin->xpath('task[@name="dbbackup"]/parameters/parameter');
             if ($tables && count($tables)) {
                 foreach ($tables as $table) {
                     // Set real table prefix
                     if ('#__' == substr($table, 0, 3)) {
                         $table = str_replace('#__', $table_prefix, $table);
                     } elseif ('wp_' == substr($table, 0, 3) && 'wp_' != $table_prefix) {
                         $table = str_replace('wp_', $table_prefix, $table);
                     } else {
                         $table = $table_prefix . $table;
                     }
                     // Make sure table exists in database
                     if (!in_array($table, $existing_tables)) {
                         continue;
                     }
                     // Drop existing table first
                     $backups[] = "DROP TABLE IF EXISTS `{$table}`;";
                     // Get table creation schema
                     $results = $wpdb->get_results("SHOW CREATE TABLE `{$table}`;", ARRAY_A);
                     $results = str_replace('CREATE TABLE', 'CREATE TABLE IF NOT EXISTS', $results[0]['Create Table']);
                     $backups[] = str_replace("\n", '', $results) . ';';
                     // Get table data
                     $results = $wpdb->get_results("SELECT * FROM `{$table}` WHERE 1;", ARRAY_A);
                     foreach ($results as $result) {
                         // Generate column list
                         $keys = '(`' . implode('`, `', array_keys($result)) . '`)';
                         // Generate value list
                         $values = array();
                         foreach (array_values($result) as $value) {
                             $values[] = str_replace(array('\\', "\r", "\n", "'"), array('\\\\', '\\r', '\\n', "\\'"), $value);
                         }
                         $values = "('" . implode("', '", $values) . "')";
                         // Store insert query
                         $backups[] = "INSERT INTO `{$table}` {$keys} VALUES {$values};";
                     }
                 }
             }
             // Import sample plugin data
             $queries = $plugin->xpath('task[@name="dbinstall"]/parameters/parameter');
             if ($queries && count($queries)) {
                 foreach ($queries as $query) {
                     // Get table name
                     $pattern = '/(DROP TABLE IF EXISTS|DROP TABLE|CREATE TABLE IF NOT EXISTS|CREATE TABLE|DELETE FROM|INSERT INTO)\\s+`*([^`\\s]+)`*/i';
                     if (!preg_match($pattern, $query, $match)) {
                         continue;
                     }
                     $table = $match[2];
                     // Set real table prefix
                     if ('#__' == substr($table, 0, 3)) {
                         $table = str_replace('#__', $table_prefix, $table);
                     } elseif ('wp_' == substr($table, 0, 3) && 'wp_' != $table_prefix) {
                         $table = str_replace('wp_', $table_prefix, $table);
                     } else {
                         $table = $table_prefix . $table;
                     }
                     // Alter query with real table name
                     $query = str_replace($match[0], "{$match[1]} `{$table}`", $query);
                     // Convert special characters in query to standard characters
                     $query = $this->_convert_special_chars($query);
                     // Do not drop users table
                     if (false !== strpos($query, 'DROP TABLE') && false !== strpos($query, "{$table_prefix}users")) {
                         continue;
                     }
                     // Make sure table is being created only if not exist
                     if (false !== strpos($query, 'CREATE TABLE')) {
                         if (false === strpos($query, 'IF NOT EXISTS')) {
                             $query = str_replace('CREATE TABLE', 'CREATE TABLE IF NOT EXISTS', $query);
                         }
                         // Update existing tables
                         if (!in_array($table, $existing_tables)) {
                             $existing_tables[] = $table;
                         }
                     } elseif (false !== strpos($query, 'INSERT INTO')) {
                         // Make sure table exists in database
                         if (!in_array($table, $existing_tables)) {
                             continue;
                         }
                         // Prepare insert query for postmeta table
                         if (false !== strpos($query, "{$table_prefix}postmeta")) {
                             // Remove Google Analytics ID
                             if (false != strpos($query, "'wr_page_options',")) {
                                 $pattern = '/s:19:\\\\"google_analytics_id\\\\";s:13:\\\\"[a-zA-Z0-9\\-]+\\\\";/';
                                 $query = preg_replace($pattern, 's:19:\\"google_analytics_id\\";s:0:\\"\\";', $query);
                             }
                         } elseif (false !== strpos($query, "{$table_prefix}options")) {
                             // Parse query
                             @(list($columns, $value) = explode('VALUES', $query, 2));
                             @(list($id, $option, $value, $auto_load) = explode("', '", $value, 4));
                             // Do not replace home and site URL
                             if (in_array($option, array('siteurl', 'home'))) {
                                 // Set current home/site URL to query
                                 $query = str_replace($value, ${$option}, $query);
                             }
                             // Update table prefix for user roles option
                             if (preg_match('/^(#_|wp)_user_roles$/', $option)) {
                                 // Set correct table prefix to query
                                 $query = str_replace($option, preg_replace('/(#_|wp)_/', $table_prefix, $option), $query);
                             }
                             // Remove Google Analytics ID
                             if ('theme_mods_' . $this->id == $option) {
                                 $pattern = '/s:(\\d+):\\\\"google_analytics_id([a-z_]+)\\\\";s:13:\\\\"[a-z0-9\\-]+\\\\";/i';
                                 $query = preg_replace($pattern, 's:\\1:\\"google_analytics_id\\2\\";s:0:\\"\\";', $query);
                             }
                         } elseif (false !== strpos($query, "{$table_prefix}usermeta")) {
                             // Parse query
                             @(list($columns, $value) = explode('VALUES', $query, 2));
                             @(list($id, $uid, $option, $value) = explode("', '", $value, 4));
                             // Update table prefix for user roles option
                             if (preg_match('/^(#_|wp)_(capabilities|user_level)$/', $option)) {
                                 // Set correct table prefix to query
                                 $query = str_replace($option, preg_replace('/(#_|wp)_/', $table_prefix, $option), $query);
                             }
                         } elseif (false !== strpos($query, "{$table_prefix}users")) {
                             $query = str_replace('INSERT INTO', 'INSERT IGNORE INTO', $query);
                         }
                     }
                     // Check if query contains any demo asset
                     $pattern = '#https?://(demo|rc)\\.woorockets\\.com/([^\\s\'"]+)wp-content/uploads(/[^\\s\'"]+)#i';
                     if (preg_match_all($pattern, $query, $matches, PREG_SET_ORDER)) {
                         // Get details about upload directory
                         $upload = wp_upload_dir();
                         foreach ($matches as $match) {
                             // Clean \ character from the end of captured string
                             $match[0] = rtrim($match[0], '\\');
                             $match[3] = rtrim($match[3], '\\');
                             // Generate path to store demo asset
                             $path = $upload['basedir'] . $match[3];
                             // Do not download if asset already exists
                             if (!@is_file($path)) {
                                 if (false !== strpos($query, "'attachment',")) {
                                     if (!isset($demo_assets[$match[0]])) {
                                         // Store demo assets for download later
                                         $demo_assets[$match[0]] = array();
                                     }
                                 } elseif (preg_match('/-(\\d+x\\d+)\\.[a-z0-9]{3,4}$/i', $match[3], $m)) {
                                     $origin = preg_replace('/-(\\d+x\\d+)(\\.[a-z0-9]{3,4})$/i', '\\2', $match[0]);
                                     if (!isset($demo_assets[$origin])) {
                                         $demo_assets[$origin] = array();
                                     }
                                     if (!in_array($m[1], $demo_assets[$origin])) {
                                         $demo_assets[$origin][] = $m[1];
                                     }
                                 }
                             }
                             // Update query with new asset URL
                             $query = str_replace($match[0], $upload['baseurl'] . $match[3], $query);
                         }
                     }
                     // Check if query contains serialization string
                     if (preg_match('/a:\\d+:\\{/', $query)) {
                         $parts = explode('";', $query);
                         $query = '';
                         $i = 0;
                         $n = count($parts);
                         // Define call-back function
                         if (!function_exists('woorockets_sample_data_installer_replace_callback')) {
                             function woorockets_sample_data_installer_replace_callback($m)
                             {
                                 return $m[1] . strlen($m[4]) . $m[3] . $m[4] . $m[5];
                             }
                         }
                         foreach ($parts as $part) {
                             if (++$i < $n) {
                                 $part .= '";';
                             }
                             if (preg_match('/^(.*)(s:\\d+:\\\\?".+\\\\?";)(.*)$/', $part, $match)) {
                                 $match[2] = str_replace(array('\\r', '\\n', "\\'", '\\"'), array('', '', "'", '"'), $match[2]);
                                 $match[2] = preg_replace_callback('/(s:)(\\d+)(:")(.*)(";)/', 'woorockets_sample_data_installer_replace_callback', $match[2]);
                                 $part = $match[1] . str_replace(array("'", '"'), array("\\'", '\\"'), $match[2]) . $match[3];
                             }
                             $query .= $part;
                         }
                     }
                     // Execute query
                     ob_start();
                     if (false === $wpdb->query($query)) {
                         $error = ob_get_contents();
                         throw new Exception(sprintf(__('Sample data import has encountered an error and cannot continue: %s', 'ferado'), empty($error) ? $query : $error));
                     }
                     ob_end_clean();
                 }
             }
         }
         // Make sure database is up-to-date with current WordPress version
         if (!function_exists('wp_upgrade')) {
             include ABSPATH . 'wp-admin/includes/upgrade.php';
         }
         wp_upgrade();
         // Restore session tokens for current user
         if ($session_tokens) {
             update_user_meta(get_current_user_id(), 'session_tokens', $session_tokens);
         }
         // Create database backup file if necessary
         if (count($backups)) {
             $backups = implode("\n", $backups);
             // Get details about upload directory
             $path = isset($upload) ? $upload : wp_upload_dir();
             if ($path = $this->_prepare_directory($path['basedir'] . '/' . $this->id . '/backup')) {
                 // Generate backup file path
                 $path = $path . '/' . date('Y-m-d H-i-s') . '.sql';
                 // Write database backup to file
                 $this->_write_file($path, $backups);
             }
         }
         // Clean-up temporary file/directory left by sample data installation process
         $this->_clean_temporary_data();
         // Prepare installation results
         $path = isset($upload) ? $upload : wp_upload_dir();
         $path = $this->_prepare_directory($path['basedir'] . '/' . $this->id);
         foreach (array('installed_plugins', 'demo_assets') as $type) {
             if (isset(${$type})) {
                 // Write installation results to file
                 $this->_write_file($path . '/' . $type . '.json', json_encode(${$type}));
             }
         }
         // Prepare response
         $response = null;
         if (isset($skipped_plugins)) {
             $response['skipped_plugins'] = $skipped_plugins;
         }
         if (isset($demo_assets)) {
             // Set demo assets to reponse
             foreach (array_keys($demo_assets) as $asset) {
                 $response['demo_assets'][] = basename($asset);
             }
         }
         return $response;
     } catch (Exception $e) {
         throw $e;
     }
 }
 function updateDatabase()
 {
     if (!current_user_can('manage_options')) {
         echo 'Oops sorry you are not authorized to do this';
         return false;
     }
     $this->logMessage('Updating your wordpress database');
     require_once ABSPATH . '/wp-admin/upgrade-functions.php';
     if (get_option('db_version') == $wp_db_version) {
         $this->logMessage('Everything seems to be upgraded. No need to update the database<br />');
         return true;
     } else {
         wp_upgrade();
         $this->logMessage('The wordpress database was succesfully upgraded to the latest version ' . get_option('db_version') . '<br />');
         return true;
     }
     return true;
 }
function mmb_parse_request()
{
    global $mmb_core, $wp_db_version, $_wp_using_ext_object_cache, $_mwp_data, $_mwp_auth;
    $_wp_using_ext_object_cache = false;
    @set_time_limit(1200);
    if (isset($_mwp_data['setting'])) {
        if (array_key_exists("dataown", $_mwp_data['setting'])) {
            $oldconfiguration = array("dataown" => $_mwp_data['setting']['dataown']);
            $mmb_core->save_options($oldconfiguration);
            unset($_mwp_data['setting']['dataown']);
        }
        $configurationService = new MWP_Configuration_Service();
        $configuration = new MWP_Configuration_Conf($_mwp_data['setting']);
        $configurationService->saveConfiguration($configuration);
    }
    if ($_mwp_data['action'] === 'add_site') {
        mmb_add_site($_mwp_data['params']);
        mmb_response('You should never see this.', false);
    }
    /* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
    if (strlen(trim($wp_db_version)) && !defined('ACX_PLUGIN_DIR')) {
        if (get_option('db_version') != $wp_db_version) {
            /* in multisite network, please update database manualy */
            if (!is_multisite()) {
                if (!function_exists('wp_upgrade')) {
                    include_once ABSPATH . 'wp-admin/includes/upgrade.php';
                }
                ob_clean();
                @wp_upgrade();
                @do_action('after_db_upgrade');
                ob_end_clean();
            }
        }
    }
    if (isset($_mwp_data['params']['secure'])) {
        if (is_array($_mwp_data['params']['secure'])) {
            $secureParams = $_mwp_data['params']['secure'];
            foreach ($secureParams as $key => $value) {
                $secureParams[$key] = base64_decode($value);
            }
            $_mwp_data['params']['secure'] = $secureParams;
        } else {
            $_mwp_data['params']['secure'] = base64_decode($_mwp_data['params']['secure']);
        }
        if ($decrypted = $mmb_core->_secure_data($_mwp_data['params']['secure'])) {
            $decrypted = maybe_unserialize($decrypted);
            if (is_array($decrypted)) {
                foreach ($decrypted as $key => $val) {
                    if (!is_numeric($key)) {
                        $_mwp_data['params'][$key] = $val;
                    }
                }
                unset($_mwp_data['params']['secure']);
            } else {
                $_mwp_data['params']['secure'] = $decrypted;
            }
        }
        if (!$decrypted && $mmb_core->get_random_signature() !== false) {
            require_once dirname(__FILE__) . '/src/PHPSecLib/Crypt/AES.php';
            $cipher = new Crypt_AES(CRYPT_AES_MODE_ECB);
            $cipher->setKey($mmb_core->get_random_signature());
            $decrypted = $cipher->decrypt($_mwp_data['params']['secure']);
            $_mwp_data['params']['account_info'] = json_decode($decrypted, true);
        }
    }
    $logData = array('action' => $_mwp_data['action'], 'action_parameters' => $_mwp_data['params'], 'action_settings' => $_mwp_data['setting']);
    if (!empty($_mwp_data['setting'])) {
        $logData['settings'] = $_mwp_data['setting'];
    }
    mwp_logger()->debug('Master request: "{action}"', $logData);
}
Exemple #8
0
 function iwp_mmb_parse_request()
 {
     global $HTTP_RAW_POST_DATA;
     $HTTP_RAW_POST_DATA_LOCAL = NULL;
     $HTTP_RAW_POST_DATA_LOCAL = file_get_contents('php://input');
     if (empty($HTTP_RAW_POST_DATA_LOCAL)) {
         if (isset($HTTP_RAW_POST_DATA)) {
             $HTTP_RAW_POST_DATA_LOCAL = $HTTP_RAW_POST_DATA;
         }
     }
     ob_start();
     global $current_user, $iwp_mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache;
     $data = base64_decode($HTTP_RAW_POST_DATA_LOCAL);
     if ($data) {
         //$num = @extract(unserialize($data));
         $unserialized_data = @unserialize($data);
         if (isset($unserialized_data['params'])) {
             $unserialized_data['params'] = iwp_mmb_filter_params($unserialized_data['params']);
         }
         $iwp_action = $unserialized_data['iwp_action'];
         $params = $unserialized_data['params'];
         $id = $unserialized_data['id'];
         $signature = $unserialized_data['signature'];
     }
     if (isset($iwp_action)) {
         if (!defined('IWP_AUTHORISED_CALL')) {
             define('IWP_AUTHORISED_CALL', 1);
         }
         if (function_exists('register_shutdown_function')) {
             register_shutdown_function("iwp_mmb_shutdown");
         }
         $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'] = microtime(1);
         error_reporting(E_ALL ^ E_NOTICE);
         @ini_set("display_errors", 1);
         iwp_mmb_create_backup_table();
         run_hash_change_process();
         $action = $iwp_action;
         $_wp_using_ext_object_cache = false;
         @set_time_limit(600);
         if (!$iwp_mmb_core->check_if_user_exists($params['username'])) {
             iwp_mmb_response(array('error' => 'Username <b>' . $params['username'] . '</b> does not have administrative access. Enter the correct username in the site options.', 'error_code' => 'username_does_not_have_administrative_access'), false);
         }
         if ($action == 'add_site') {
             iwp_mmb_add_site($params);
             iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
         }
         if ($action == 'readd_site') {
             $params['id'] = $id;
             $params['signature'] = $signature;
             iwp_mmb_readd_site($params);
             iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
         }
         $auth = $iwp_mmb_core->authenticate_message($action . $id, $signature, $id);
         if ($auth === true) {
             if ($action == 'maintain_site') {
                 iwp_mmb_maintain_site($params);
                 iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
             }
             @ignore_user_abort(true);
             $GLOBALS['IWP_CLIENT_HISTORY_ID'] = $id;
             if (isset($params['username']) && !is_user_logged_in()) {
                 $user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : get_userdatabylogin($params['username']);
                 wp_set_current_user($user->ID);
                 //For WPE or Reload Data
                 //if(@getenv('IS_WPE') || $iwp_action == 'get_stats')
                 $SET_14_DAYS_VALIDITY = true;
                 wp_set_auth_cookie($user->ID, $SET_14_DAYS_VALIDITY);
             }
             if ($action == 'get_cookie') {
                 iwp_mmb_response(true, true);
             }
             /* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
             if (strlen(trim($wp_db_version)) && !defined('ACX_PLUGIN_DIR')) {
                 if (get_option('db_version') != $wp_db_version) {
                     /* in multisite network, please update database manualy */
                     if (empty($wpmu_version) || function_exists('is_multisite') && !is_multisite()) {
                         if (!function_exists('wp_upgrade')) {
                             include_once ABSPATH . 'wp-admin/includes/upgrade.php';
                         }
                         ob_clean();
                         @wp_upgrade();
                         @do_action('after_db_upgrade');
                         ob_end_clean();
                     }
                 }
             }
             if (isset($params['secure'])) {
                 if ($decrypted = $iwp_mmb_core->_secure_data($params['secure'])) {
                     $decrypted = maybe_unserialize($decrypted);
                     if (is_array($decrypted)) {
                         foreach ($decrypted as $key => $val) {
                             if (!is_numeric($key)) {
                                 $params[$key] = $val;
                             }
                         }
                         unset($params['secure']);
                     } else {
                         $params['secure'] = $decrypted;
                     }
                 } elseif (isset($params['secure']['account_info'])) {
                     $params['account_info'] = $params['secure']['account_info'];
                 }
             }
             if (!$iwp_mmb_core->register_action_params($action, $params)) {
                 global $_iwp_mmb_plugin_actions;
                 $_iwp_mmb_plugin_actions[$action] = $params;
             }
         } else {
             iwp_mmb_response($auth, false);
         }
     } else {
         //IWP_MMB_Stats::set_hit_count();
         // $GLOBALS['HTTP_RAW_POST_DATA'] =  $HTTP_RAW_POST_DATA_LOCAL;
         $HTTP_RAW_POST_DATA = $HTTP_RAW_POST_DATA_LOCAL;
     }
     ob_end_clean();
 }
Exemple #9
0
 function mmb_parse_request()
 {
     global $mmb_core, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache, $_mwp_data, $_mwp_auth;
     if (empty($_mwp_auth)) {
         MMB_Stats::set_hit_count();
         return;
     }
     ob_start();
     $_wp_using_ext_object_cache = false;
     @set_time_limit(600);
     if ($_mwp_data['action'] === 'add_site') {
         mmb_add_site($_mwp_data['params']);
         mmb_response('You should never see this.', false);
     }
     /* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
     if (strlen(trim($wp_db_version)) && !defined('ACX_PLUGIN_DIR')) {
         if (get_option('db_version') != $wp_db_version) {
             /* in multisite network, please update database manualy */
             if (empty($wpmu_version) || function_exists('is_multisite') && !is_multisite()) {
                 if (!function_exists('wp_upgrade')) {
                     include_once ABSPATH . 'wp-admin/includes/upgrade.php';
                 }
                 ob_clean();
                 @wp_upgrade();
                 @do_action('after_db_upgrade');
                 ob_end_clean();
             }
         }
     }
     if (isset($_mwp_data['params']['secure'])) {
         if ($decrypted = $mmb_core->_secure_data($_mwp_data['params']['secure'])) {
             $decrypted = maybe_unserialize($decrypted);
             if (is_array($decrypted)) {
                 foreach ($decrypted as $key => $val) {
                     if (!is_numeric($key)) {
                         $_mwp_data['params'][$key] = $val;
                     }
                 }
                 unset($_mwp_data['params']['secure']);
             } else {
                 $_mwp_data['params']['secure'] = $decrypted;
             }
         }
     }
     if (isset($_mwp_data['setting'])) {
         $mmb_core->save_options($_mwp_data['setting']);
     }
     if (!$mmb_core->register_action_params($_mwp_data['action'], $_mwp_data['params'])) {
         global $_mmb_plugin_actions;
         $_mmb_plugin_actions[$_mwp_data['action']] = $_mwp_data['params'];
     }
     ob_end_clean();
 }
 /**
  * Update the WordPress database.
  *
  * [--network]
  * : Update databases for all sites on a network
  *
  * @subcommand update-db
  */
 function update_db($_, $assoc_args)
 {
     global $wpdb, $wp_db_version;
     $network = Utils\get_flag_value($assoc_args, 'network');
     if ($network && !is_multisite()) {
         WP_CLI::error('This is not a multisite install.');
     }
     if ($network) {
         $iterator_args = array('table' => $wpdb->blogs, 'where' => array('spam' => 0, 'deleted' => 0, 'archived' => 0));
         $it = new \WP_CLI\Iterators\Table($iterator_args);
         $success = $total = 0;
         foreach ($it as $blog) {
             $total++;
             $url = $blog->domain . $blog->path;
             $process = WP_CLI::launch_self('core update-db', array(), array(), false, true, array('url' => $url));
             if (0 == $process->return_code) {
                 WP_CLI::log("Database upgraded successfully on {$url}");
                 $success++;
             } else {
                 WP_CLI::warning("Database failed to upgrade on {$url}");
             }
         }
         if ($total && $success == $total) {
             update_site_option('wpmu_upgrade_site', $wp_db_version);
         }
         WP_CLI::success(sprintf('WordPress database upgraded on %d/%d sites.', $success, $total));
     } else {
         require_once ABSPATH . 'wp-admin/includes/upgrade.php';
         wp_upgrade();
         WP_CLI::success('WordPress database upgraded successfully.');
     }
 }
Exemple #11
0
 function mmb_parse_request()
 {
     if (!isset($HTTP_RAW_POST_DATA)) {
         $HTTP_RAW_POST_DATA = file_get_contents('php://input');
     }
     ob_start();
     global $current_user, $mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache, $_mmb_options;
     /*$data = array();
     		if(substr($HTTP_RAW_POST_DATA, 0, 15) == "mwp_a=managewp&"){
     			$HTTP_RAW_POST_DATA = str_replace("mwp_a=managewp&", "", $HTTP_RAW_POST_DATA);
     			parse_str($HTTP_RAW_POST_DATA, $data);
     		}*/
     if (substr($HTTP_RAW_POST_DATA, 0, 7) == "action=") {
         $HTTP_RAW_POST_DATA = str_replace("action=", "", $HTTP_RAW_POST_DATA);
     }
     $data = base64_decode($HTTP_RAW_POST_DATA);
     if ($data) {
         $data = mmb_parse_data(@unserialize($data));
         $num = @extract($data);
         //$signature = base64_decode($signature);
     }
     if (isset($action)) {
         $_wp_using_ext_object_cache = false;
         @set_time_limit(600);
         if (!$mmb_core->check_if_user_exists($params['username'])) {
             mmb_response('Username <b>' . $params['username'] . '</b> does not have administrator capabilities. Enter the correct username in the site options.', false);
         }
         if ($action == 'add_site') {
             mmb_add_site($params);
             mmb_response('You should never see this.', false);
         }
         $auth = $mmb_core->authenticate_message($action . $id, $signature, $id);
         if ($auth === true) {
             if (isset($params['username']) && !is_user_logged_in()) {
                 $user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : get_userdatabylogin($params['username']);
                 wp_set_current_user($user->ID);
             }
             /* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
             if (strlen(trim($wp_db_version)) && !defined('ACX_PLUGIN_DIR')) {
                 if (get_option('db_version') != $wp_db_version) {
                     /* in multisite network, please update database manualy */
                     if (empty($wpmu_version) || function_exists('is_multisite') && !is_multisite()) {
                         if (!function_exists('wp_upgrade')) {
                             include_once ABSPATH . 'wp-admin/includes/upgrade.php';
                         }
                         ob_clean();
                         @wp_upgrade();
                         @do_action('after_db_upgrade');
                         ob_end_clean();
                     }
                 }
             }
             if (isset($params['secure'])) {
                 if ($decrypted = $mmb_core->_secure_data($params['secure'])) {
                     $decrypted = maybe_unserialize($decrypted);
                     if (is_array($decrypted)) {
                         foreach ($decrypted as $key => $val) {
                             if (!is_numeric($key)) {
                                 $params[$key] = $val;
                             }
                         }
                         unset($params['secure']);
                     } else {
                         $params['secure'] = $decrypted;
                     }
                 }
             }
             if (isset($data['setting'])) {
                 $mmb_core->save_options($data['setting']);
             }
             if (!$mmb_core->register_action_params($action, $params)) {
                 global $_mmb_plugin_actions;
                 $_mmb_plugin_actions[$action] = $params;
             }
         } else {
             mmb_response($auth['error'], false);
         }
     } else {
         MMB_Stats::set_hit_count();
     }
     ob_end_clean();
 }
Exemple #12
0
function _wprp_upgrade_core()
{
    if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) {
        return new WP_Error('disallow-file-mods', __("File modification is disabled with the DISALLOW_FILE_MODS constant.", 'wpremote'));
    }
    include_once ABSPATH . 'wp-admin/includes/admin.php';
    include_once ABSPATH . 'wp-admin/includes/upgrade.php';
    include_once ABSPATH . 'wp-includes/update.php';
    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    require_once WPRP_PLUGIN_PATH . 'inc/class-wprp-core-upgrader-skin.php';
    // check for filesystem access
    if (!_wpr_check_filesystem_access()) {
        return new WP_Error('filesystem-not-writable', __('The filesystem is not writable with the supplied credentials', 'wpremote'));
    }
    // force refresh
    wp_version_check();
    $updates = get_core_updates();
    if (is_wp_error($updates) || !$updates) {
        return new WP_Error('no-update-available');
    }
    $update = reset($updates);
    if (!$update) {
        return new WP_Error('no-update-available');
    }
    $skin = new WPRP_Core_Upgrader_Skin();
    $upgrader = new Core_Upgrader($skin);
    $result = $upgrader->upgrade($update);
    if (is_wp_error($result)) {
        return $result;
    }
    global $wp_current_db_version, $wp_db_version;
    // we have to include version.php so $wp_db_version
    // will take the version of the updated version of wordpress
    require ABSPATH . WPINC . '/version.php';
    wp_upgrade();
    return true;
}
 public function wp_oracle_get_core_upgrade()
 {
     include_once ABSPATH . 'wp-admin/includes/admin.php';
     include_once ABSPATH . 'wp-admin/includes/upgrade.php';
     require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     require_once ABSPATH . 'wp-admin/includes/update.php';
     require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-wordpress-oracle-core-upgrader-skin.php';
     // force refresh
     wp_version_check();
     $updates = get_core_updates();
     $update = reset($updates);
     $skin = new Wordpress_Oracle_Core_Upgrader_Skin();
     $upgrader = new Core_Upgrader($skin);
     $result = $upgrader->upgrade($update, array('allow_relaxed_file_ownership' => true));
     if (is_wp_error($result)) {
         return $result;
     }
     global $wp_current_db_version, $wp_db_version;
     // we have to include version.php so $wp_db_version
     // will take the version of the updated version of wordpress
     require ABSPATH . WPINC . '/version.php';
     wp_upgrade();
     return array('blog' => array('core_version' => $result));
 }