Пример #1
0
 public function __construct($skin = null, $info = null, $shortinit = false)
 {
     global $wpdb;
     // Line up a wpdb-like object to use
     $this->use_wpdb = !function_exists('mysql_query') && !function_exists('mysqli_query') || !$wpdb->is_mysql || !$wpdb->ready ? true : false;
     $this->our_siteurl = untrailingslashit(site_url());
     if (false == $this->use_wpdb) {
         // We have our own extension which drops lots of the overhead on the query
         $wpdb_obj = new UpdraftPlus_WPDB(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
         // Was that successful?
         if (!$wpdb_obj->is_mysql || !$wpdb_obj->ready) {
             $this->use_wpdb = true;
         } else {
             $this->wpdb_obj = $wpdb_obj;
             $this->mysql_dbh = $wpdb_obj->updraftplus_getdbh();
             $this->use_mysqli = $wpdb_obj->updraftplus_use_mysqli();
         }
     }
     if ($shortinit) {
         return;
     }
     $this->ud_backup_info = $info;
     $this->ud_foreign = empty($info['meta_foreign']) ? false : $info['meta_foreign'];
     parent::__construct($skin);
     $this->init();
     $this->backup_strings();
     $this->is_multisite = is_multisite();
 }
Пример #2
0
 public function __construct($skin = null, $info = null, $shortinit = false, $restore_options = array())
 {
     global $wpdb;
     // Line up a wpdb-like object
     $this->use_wpdb = !function_exists('mysql_query') && !function_exists('mysqli_query') || !$wpdb->is_mysql || !$wpdb->ready ? true : false;
     $this->our_siteurl = untrailingslashit(site_url());
     if (false == $this->use_wpdb) {
         // We have our own extension which drops lots of the overhead on the query
         $wpdb_obj = new UpdraftPlus_WPDB(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
         // Was that successful?
         if (!$wpdb_obj->is_mysql || !$wpdb_obj->ready) {
             $this->use_wpdb = true;
         } else {
             $this->wpdb_obj = $wpdb_obj;
             $this->mysql_dbh = $wpdb_obj->updraftplus_getdbh();
             $this->use_mysqli = $wpdb_obj->updraftplus_use_mysqli();
         }
     }
     if ($shortinit) {
         return;
     }
     $this->ud_backup_info = $info;
     do_action('updraftplus_restorer_restore_options', $restore_options);
     $this->ud_multisite_selective_restore = is_array($restore_options) && !empty($restore_options['updraft_restore_ms_whichsites']) && $restore_options['updraft_restore_ms_whichsites'] > 0 ? $restore_options['updraft_restore_ms_whichsites'] : false;
     $this->ud_restore_options = $restore_options;
     $this->ud_foreign = empty($info['meta_foreign']) ? false : $info['meta_foreign'];
     if (isset($info['is_multisite'])) {
         $this->ud_backup_is_multisite = $info['is_multisite'];
     }
     if (isset($info['created_by_version'])) {
         $this->created_by_version = $info['created_by_version'];
     }
     add_filter('updraftplus_logline', array($this, 'updraftplus_logline'), 10, 5);
     parent::__construct($skin);
     $this->init();
     $this->backup_strings();
     $this->is_multisite = is_multisite();
 }
Пример #3
0
 public function updraftplus_restore_db_pre()
 {
     global $wpdb, $updraftplus;
     $this->siteurl = untrailingslashit(site_url());
     $this->home = untrailingslashit(home_url());
     $this->content = untrailingslashit(content_url());
     $this->use_wpdb = !function_exists('mysql_query') && !function_exists('mysqli_query') || !$wpdb->is_mysql || !$wpdb->ready ? true : false;
     $this->base_prefix = $updraftplus->get_table_prefix(false);
     $mysql_dbh = false;
     if (false == $this->use_wpdb) {
         // We have our own extension which drops lots of the overhead on the query
         // This class is defined in updraft-restorer.php, which has been included if we get here
         $wpdb_obj = new UpdraftPlus_WPDB(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
         // Was that successful?
         if (!$wpdb_obj->is_mysql || !$wpdb_obj->ready) {
             $this->use_wpdb = true;
         } else {
             $this->wpdb_obj = $wpdb_obj;
             $mysql_dbh = $wpdb_obj->updraftplus_getdbh();
             $use_mysqli = $wpdb_obj->updraftplus_use_mysqli();
         }
     }
     $this->mysql_dbh = $mysql_dbh;
     $this->use_mysqli = $use_mysqli;
     if (true == $this->use_wpdb) {
         $updraftplus->log_e('Database access: Direct MySQL access is not available, so we are falling back to wpdb (this will be considerably slower)');
     }
     if (is_multisite()) {
         $sites = $wpdb->get_results('SELECT id, domain, path FROM ' . esc_sql($this->base_prefix) . 'site', ARRAY_N);
         if (is_array($sites)) {
             $nsites = array();
             foreach ($sites as $site) {
                 $nsites[$site[0]] = array($site[1], $site[2]);
             }
             $this->original_sites = $nsites;
         }
     }
     $this->report = array('tables' => 0, 'rows' => 0, 'change' => 0, 'updates' => 0, 'timetaken' => 0, 'errors' => array());
 }