/**
	 * Get all backup files
	 *
	 * @return array
	 */
	public function get_files() {
		$backups  = array();

		try {
			$iterator = new RegexIterator(
				new DirectoryIterator( AI1WM_BACKUPS_PATH ),
				'/^(.+)-(\d+)-(\d+)-(\d+)\.wpress$/',
				RegexIterator::GET_MATCH
			);

			foreach ( $iterator as $item ) {
				try {
					$backup = new Ai1wm_File;
					$backup->setFile( $item[0] );
					$backup->setName( $item[1] );
					$backup->setSize( $iterator->getSize() );
					$backup->setCreatedAt( strtotime( "{$item[2]} {$item[3]}" ) );

					// Add backup file
					$backups[] = $backup;
				} catch ( Exception $e ) {
					// Log the error
					Ai1wm_Log::error( 'Exception while listing backup file: ' . $e->getMessage() );
				}
			}
		} catch ( Exception $e ) {
			$backups = array();
		}

		// Sort backups by most recent first
		usort( $backups, array( $this, 'compare' ) );

		return $backups;
	}
	/**
	 * Error handler
	 *
	 * @param  integer $errno   Error level
	 * @param  string  $errstr  Error message
	 * @param  string  $errfile Error file
	 * @param  integer $errline Error line
	 * @return void
	 */
	public static function error( $errno, $errstr, $errfile, $errline ) {
		Ai1wm_Log::error( array(
			'Number'  => $errno,
			'Message' => $errstr,
			'File'    => $errfile,
			'Line'    => $errline,
		) );
	}
 public static function import($params = array())
 {
     global $wp_filter;
     // Set error handler
     @set_error_handler('Ai1wm_Handler::error');
     // Set params
     if (empty($params)) {
         $params = ai1wm_urldecode($_REQUEST);
     }
     // Set priority
     $priority = 10;
     if (isset($params['priority'])) {
         $priority = (int) $params['priority'];
     }
     // Set secret key
     $secret_key = null;
     if (isset($params['secret_key'])) {
         $secret_key = $params['secret_key'];
     }
     // Verify secret key by using the value in the database, not in cache
     if ($secret_key !== get_option(AI1WM_SECRET_KEY)) {
         Ai1wm_Status::error(sprintf(__('Unable to authenticate your request with secret_key = "%s"', AI1WM_PLUGIN_NAME), $secret_key), __('Unable to import', AI1WM_PLUGIN_NAME));
         exit;
     }
     // Get hook
     if (isset($wp_filter['ai1wm_import']) && ($filters = $wp_filter['ai1wm_import']) && ksort($filters)) {
         while ($hooks = current($filters)) {
             if ($priority == key($filters)) {
                 foreach ($hooks as $hook) {
                     try {
                         $params = call_user_func_array($hook['function'], array($params));
                     } catch (Ai1wm_Import_Retry_Exception $exception) {
                         status_header($exception->getCode());
                         echo json_encode(array('message' => $exception->getMessage()));
                         exit;
                     } catch (Exception $e) {
                         Ai1wm_Status::error($e->getMessage(), __('Unable to import', AI1WM_PLUGIN_NAME));
                         exit;
                     }
                 }
                 // Set completed
                 $completed = true;
                 if (isset($params['completed'])) {
                     $completed = (bool) $params['completed'];
                 }
                 // Log request
                 if (empty($params['priority']) || is_file(ai1wm_import_path($params))) {
                     Ai1wm_Log::import($params);
                 }
                 // Do request
                 if ($completed === false || ($next = next($filters)) && ($params['priority'] = key($filters))) {
                     return Ai1wm_Http::get(admin_url('admin-ajax.php?action=ai1wm_import'), $params);
                 }
             }
             next($filters);
         }
     }
 }
 public static function import($args = array())
 {
     // Set error handler
     @set_error_handler('Ai1wm_Log::error_handler');
     try {
         // Set arguments
         if (empty($args)) {
             $args = ai1wm_urldecode($_REQUEST);
         }
         // Set storage path
         if (empty($args['storage'])) {
             $args['storage'] = uniqid();
         }
         // Set secret key
         $secret_key = null;
         if (isset($args['secret_key'])) {
             $secret_key = $args['secret_key'];
         }
         // Verify secret key by using the value in the database, not in cache
         if ($secret_key !== get_site_option(AI1WM_SECRET_KEY, false, false)) {
             throw new Ai1wm_Import_Exception(sprintf(__('Unable to authenticate your request with secret_key = <strong>"%s"</strong>', AI1WM_PLUGIN_NAME), $secret_key));
         }
         // Set provider
         $provider = null;
         if (isset($args['provider'])) {
             $provider = $args['provider'];
         }
         $class = "Ai1wm_Import_{$provider}";
         if (!class_exists($class)) {
             throw new Ai1wm_Import_Exception(sprintf(__('Unknown provider: <strong>"%s"</strong>', AI1WM_PLUGIN_NAME), $class));
         }
         // Set method
         $method = null;
         if (isset($args['method'])) {
             $method = $args['method'];
         }
         // Initialize provider
         $provider = new $class($args);
         if (!method_exists($provider, $method)) {
             throw new Ai1wm_Import_Exception(sprintf(__('Unknown method: <strong>"%s"</strong>', AI1WM_PLUGIN_NAME), $method));
         }
         // Invoke method
         echo json_encode($provider->{$method}());
         exit;
     } catch (Exception $e) {
         // Log the error
         Ai1wm_Log::error('Exception while importing: ' . $e->getMessage());
         // Set the status to failed
         Ai1wm_Status::set(array('type' => 'error', 'title' => __('Unable to import', AI1WM_PLUGIN_NAME), 'message' => $e->getMessage()));
         // End the process
         wp_die('Exception while importing: ' . $e->getMessage());
     }
 }
 /**
  * Import database from file
  *
  * @param  string $fileName Name of file
  * @return bool
  */
 public function import($fileName)
 {
     // Set collation name
     $collation = $this->getCollation('utf8mb4_general_ci');
     // Set max allowed packet
     $maxAllowedPacket = $this->getMaxAllowedPacket();
     // Set file handler
     $fileHandler = fopen($fileName, 'r');
     if ($fileHandler === false) {
         throw new Exception('Unable to open database file');
     }
     $passed = 0;
     $failed = 0;
     $query = null;
     // Read database file line by line
     while (($line = fgets($fileHandler)) !== false) {
         $query .= $line;
         // End of query
         if (preg_match('/;\\s*$/', $query)) {
             // Check max allowed packet
             if (strlen($query) <= $maxAllowedPacket) {
                 // Replace table prefix
                 $query = $this->replaceTablePrefix($query);
                 // Replace table values
                 $query = $this->replaceTableValues($query, true);
                 // Replace table collation
                 if (empty($collation)) {
                     $query = $this->replaceTableCollation($query);
                 }
                 // Run SQL query
                 $result = mysql_unbuffered_query($query, $this->getConnection());
                 if ($result === false) {
                     $failed++;
                     // Log the error
                     Ai1wm_Log::error(sprintf('Exception while importing: %s with query: %s', mysql_error($this->getConnection()), $query));
                 } else {
                     $passed++;
                 }
             } else {
                 $failed++;
             }
             $query = null;
         }
     }
     // Close file handler
     fclose($fileHandler);
     // Check failed queries
     if ($failed / $passed * 100 > 2) {
         return false;
     }
     return true;
 }
Example #6
0
	/**
	 * Import database from file
	 *
	 * @param  string $fileName Name of file
	 * @return bool
	 */
	public function import($fileName)
	{
		// Set collation name
		$collation = $this->getCollation('utf8mb4_unicode_ci');

		$fileHandler = fopen($fileName, 'r');
		if ($fileHandler) {
			$query = null;

			// Read database file line by line
			while (($line = fgets($fileHandler)) !== false) {
				// Replace create table prefix
				$line = $this->replaceCreateTablePrefix($line);

				// Replace insert into prefix
				$line = $this->replaceInsertIntoPrefix($line);

				// Replace table values
				$line = $this->replaceTableValues($line);

				// Replace table collation
				if (empty($collation)) {
					$line = $this->replaceTableCollation($line);
				}

				$query .= $line;
				if (preg_match('/;\s*$/', $line)) {
					// Run SQL query
					$result = mysql_unbuffered_query($query, $this->getConnection());
					if ($result === false) {
						// Log the error
						Ai1wm_Log::error(
							sprintf(
								'Exception while importing: %s with query: %s',
								 mysql_error($this->getConnection()),
								 $query
							 )
						);
					}

					// Empty query
					$query = null;
				}
			}

			return true;
		}
	}
Example #7
0
 /**
  * Import database from file
  *
  * @param  string $fileName Name of file
  * @return bool
  */
 public function import($fileName)
 {
     $fileHandler = fopen($fileName, 'r');
     if ($fileHandler) {
         $query = null;
         // Read database file line by line
         while (($line = fgets($fileHandler)) !== false) {
             // Replace create table prefix
             $line = $this->replaceCreateTablePrefix($line);
             // Replace insert into prefix
             $line = $this->replaceInsertIntoPrefix($line);
             // Replace table values
             $line = $this->replaceTableValues($line);
             $query .= $line;
             if (preg_match('/;\\s*$/', $line)) {
                 try {
                     // Run SQL query
                     $result = $this->getConnection()->query($query);
                     if ($result === false) {
                         throw new PDOException(var_export($this->getConnection()->errorinfo(), true));
                     }
                 } catch (PDOException $e) {
                     // Log the error
                     Ai1wm_Log::error(sprintf('Exception while importing: %s with query: %s', $e->getMessage(), $query));
                 }
                 // Empty query
                 $query = null;
             }
         }
         return true;
     }
 }
	/**
	 * Import database
	 *
	 * @return string
	 */
	public function import() {
		global $wpdb;

		// Get configuration
		$service = new Ai1wm_Service_Package( $this->args );
		$config  = $service->import();

		$old_values = array();
		$new_values = array();

		// Get Site URL
		if ( isset( $config['SiteURL'] ) && ( $config['SiteURL'] !== site_url() ) ) {
			$old_values[] = $config['SiteURL'];
			$new_values[] = site_url();

			// Get Domain
			$old_domain = parse_url( $config['SiteURL'] );
			$new_domain = parse_url( site_url() );

			// Replace Domain
			$old_values[] = sprintf( '%s://%s', $old_domain['scheme'], $old_domain['host'] );
			$new_values[] = sprintf( '%s://%s', $new_domain['scheme'], $new_domain['host'] );

			// Replace Host
			if ( stripos( site_url(), $old_domain['host'] ) === false && stripos( home_url(), $old_domain['host'] ) === false ) {
				$old_values[] = $old_domain['host'];
				$new_values[] = $new_domain['host'];
			}

			// Replace Path
			$old_values[] = isset( $old_domain['path'] ) && ( $old_domain['path'] !== '/' ) ? trailingslashit( $old_domain['path'] ) : null;
			$new_values[] = isset( $new_domain['path'] ) ? trailingslashit( $new_domain['path'] ) : '/';
		}

		// Get Home URL
		if ( isset( $config['HomeURL'] ) && ( $config['HomeURL'] !== home_url() ) ) {
			$old_values[] = $config['HomeURL'];
			$new_values[] = home_url();
		}

		// Get WordPress Content
		if ( isset( $config['WordPress']['Content'] ) && ( $config['WordPress']['Content'] !== WP_CONTENT_DIR ) ) {
			$old_values[] = $config['WordPress']['Content'];
			$new_values[] = WP_CONTENT_DIR;
		}

		// Get user details
		if ( isset( $config['Import']['User']['Id'] ) && ( $id = $config['Import']['User']['Id'] ) ) {
			$meta = get_userdata( $id );
			$user = array(
				'user_login'           => $meta->user_login,
				'user_pass'            => $meta->user_pass,
				'user_nicename'        => $meta->user_nicename,
				'user_url'             => $meta->user_url,
				'user_email'           => $meta->user_email,
				'display_name'         => $meta->display_name,
				'nickname'             => $meta->nickname,
				'first_name'           => $meta->first_name,
				'last_name'            => $meta->last_name,
				'description'          => $meta->description,
				'rich_editing'         => $meta->rich_editing,
				'user_registered'      => $meta->user_registered,
				'jabber'               => $meta->jabber,
				'aim'                  => $meta->aim,
				'yim'                  => $meta->yim,
				'show_admin_bar_front' => $meta->show_admin_bar_front,
			);
		} else {
			$user = array();
		}

		// Get HTTP user
		$auth_user = get_site_option( AI1WM_AUTH_USER, false, false );

		// Get HTTP password
		$auth_password = get_site_option( AI1WM_AUTH_PASSWORD, false, false );

		// Get secret key
		$secret_key = get_site_option( AI1WM_SECRET_KEY, false, false );

		// Flush database
		$this->connection->flush();

		// Import database
		$this->connection->setOldTablePrefix( AI1WM_TABLE_PREFIX )
						 ->setNewTablePrefix( $wpdb->prefix )
						 ->setOldReplaceValues( $old_values )
						 ->setNewReplaceValues( $new_values )
						 ->import( $this->storage()->database() );

		// Clear WP options cache
		wp_cache_flush();

		// Set new user identity
		if ( isset( $config['Export']['User']['Id'] ) && ( $id = $config['Export']['User']['Id'] ) ) {

			// Update user login and password
			if ( isset( $user['user_login'] ) && isset( $user['user_pass'] ) ) {
				$wpdb->update(
					$wpdb->users,
					array( 'user_login' => $user['user_login'], 'user_pass' => $user['user_pass'] ),
					array( 'ID' => $id ),
					array( '%s', '%s' ),
					array( '%d' )
				);

				// Unset user login
				unset( $user['user_login'] );

				// Unset user password
				unset( $user['user_pass'] );
			}

			// Update user details
			$result = wp_update_user( array( 'ID' => $id ) + $user );

			// Log the error
			if ( is_wp_error( $result ) ) {
				Ai1wm_Log::error( 'Exception while importing user identity: ' . $result->get_error_message() );
			}
		}

		// Set the new HTTP user
		update_site_option( AI1WM_AUTH_USER, $auth_user );

		// Set the new HTTP password
		update_site_option( AI1WM_AUTH_PASSWORD, $auth_password );

		// Set the new secret key value
		update_site_option( AI1WM_SECRET_KEY, $secret_key );
	}
 /**
  * Import database
  *
  * @return void
  */
 public function import()
 {
     global $wpdb;
     // Get configuration
     $service = new Ai1wm_Service_Package($this->args);
     $config = $service->import();
     $old_values = array();
     $new_values = array();
     // Get Site URL
     if (isset($config['SiteURL']) && $config['SiteURL'] !== site_url()) {
         $old_values[] = $config['SiteURL'];
         $new_values[] = site_url();
     }
     // Get Home URL
     if (isset($config['HomeURL']) && $config['HomeURL'] !== home_url()) {
         $old_values[] = $config['HomeURL'];
         $new_values[] = home_url();
     }
     // Get WordPress Content
     if (isset($config['WordPress']['Content']) && $config['WordPress']['Content'] !== WP_CONTENT_DIR) {
         $old_values[] = $config['WordPress']['Content'];
         $new_values[] = WP_CONTENT_DIR;
     }
     // Get user details
     if (isset($config['Import']['User']['Id']) && ($id = $config['Import']['User']['Id'])) {
         $meta = get_userdata($id);
         $user = array('user_login' => $meta->user_login, 'user_pass' => $meta->user_pass, 'user_nicename' => $meta->user_nicename, 'user_url' => $meta->user_url, 'user_email' => $meta->user_email, 'display_name' => $meta->display_name, 'nickname' => $meta->nickname, 'first_name' => $meta->first_name, 'last_name' => $meta->last_name, 'description' => $meta->description, 'rich_editing' => $meta->rich_editing, 'user_registered' => $meta->user_registered, 'jabber' => $meta->jabber, 'aim' => $meta->aim, 'yim' => $meta->yim, 'show_admin_bar_front' => $meta->show_admin_bar_front);
     } else {
         $user = array();
     }
     // Get HTTP user
     $auth_user = get_site_option(AI1WM_AUTH_USER, false, false);
     // Get HTTP password
     $auth_password = get_site_option(AI1WM_AUTH_PASSWORD, false, false);
     // Get secret key
     $secret_key = get_site_option(AI1WM_SECRET_KEY, false, false);
     // Flush database
     $this->connection->flush();
     // Import database
     $this->connection->setOldTablePrefix(AI1WM_TABLE_PREFIX)->setNewTablePrefix($wpdb->prefix)->setOldReplaceValues($old_values)->setNewReplaceValues($new_values)->import($this->storage()->database());
     // Clear WP options cache
     wp_cache_flush();
     // WP Migration
     if (is_plugin_active(AI1WM_PLUGIN_BASENAME)) {
         activate_plugin(AI1WM_PLUGIN_BASENAME);
     }
     // Dropbox Extension
     if (is_plugin_active(AI1WMDE_PLUGIN_BASENAME)) {
         activate_plugin(AI1WMDE_PLUGIN_BASENAME);
     }
     // Google Drive Extension
     if (is_plugin_active(AI1WMGE_PLUGIN_BASENAME)) {
         activate_plugin(AI1WMGE_PLUGIN_BASENAME);
     }
     // Amazon S3 Extension
     if (is_plugin_active(AI1WMSE_PLUGIN_BASENAME)) {
         activate_plugin(AI1WMSE_PLUGIN_BASENAME);
     }
     // Multisite Extension
     if (is_plugin_active(AI1WMME_PLUGIN_BASENAME)) {
         activate_plugin(AI1WMME_PLUGIN_BASENAME);
     }
     // Unlimited Extension
     if (is_plugin_active(AI1WMUE_PLUGIN_BASENAME)) {
         activate_plugin(AI1WMUE_PLUGIN_BASENAME);
     }
     // FTP Extension
     if (is_plugin_active(AI1WMFE_PLUGIN_BASENAME)) {
         activate_plugin(AI1WMFE_PLUGIN_BASENAME);
     }
     // Set new user identity
     if (isset($config['Export']['User']['Id']) && ($id = $config['Export']['User']['Id'])) {
         // Update user login and password
         if (isset($user['user_login']) && isset($user['user_pass'])) {
             $wpdb->update($wpdb->users, array('user_login' => $user['user_login'], 'user_pass' => $user['user_pass']), array('ID' => $id), array('%s', '%s'), array('%d'));
             // Unset user login
             unset($user['user_login']);
             // Unset user password
             unset($user['user_pass']);
         }
         // Update user details
         $result = wp_update_user(array('ID' => $id) + $user);
         // Log the error
         if (is_wp_error($result)) {
             Ai1wm_Log::error('Exception while importing user identity: ' . $result->get_error_message());
         }
     }
     // Set the new HTTP user
     update_site_option(AI1WM_AUTH_USER, $auth_user);
     // Set the new HTTP password
     update_site_option(AI1WM_AUTH_PASSWORD, $auth_password);
     // Set the new secret key value
     update_site_option(AI1WM_SECRET_KEY, $secret_key);
 }
 /**
  * Import database
  *
  * @return void
  */
 public function import()
 {
     global $wpdb;
     // Get configuration
     $service = new Ai1wm_Service_Package($this->args);
     $config = $service->import();
     $old_values = array();
     $new_values = array();
     // Get Site URL
     if (isset($config['SiteURL']) && $config['SiteURL'] !== site_url()) {
         // Get domain
         $old_domain = parse_url($config['SiteURL'], PHP_URL_HOST);
         $new_domain = parse_url(site_url(), PHP_URL_HOST);
         // Add plain Site URL
         $old_values[] = set_url_scheme($config['SiteURL'], 'http');
         $new_values[] = set_url_scheme(site_url());
         // Add plain Site URL SSL
         $old_values[] = set_url_scheme($config['SiteURL'], 'https');
         $new_values[] = set_url_scheme(site_url());
         // Add encoded Site URL
         $old_values[] = urlencode(set_url_scheme($config['SiteURL'], 'http'));
         $new_values[] = urlencode(set_url_scheme(site_url()));
         // Add encoded Site URL SSL
         $old_values[] = urlencode(set_url_scheme($config['SiteURL'], 'https'));
         $new_values[] = urlencode(set_url_scheme(site_url()));
         // Add escaped Site URL
         $old_values[] = addslashes(addcslashes(set_url_scheme($config['SiteURL'], 'http'), '/'));
         $new_values[] = addslashes(addcslashes(set_url_scheme(site_url()), '/'));
         // Add escaped Site URL SSL
         $old_values[] = addslashes(addcslashes(set_url_scheme($config['SiteURL'], 'https'), '/'));
         $new_values[] = addslashes(addcslashes(set_url_scheme(site_url()), '/'));
         // Add email
         $old_values[] = sprintf("@%s", $old_domain);
         $new_values[] = sprintf("@%s", $new_domain);
     }
     // Get Home URL
     if (isset($config['HomeURL']) && $config['HomeURL'] !== home_url()) {
         // Add plain Home URL
         $old_values[] = set_url_scheme($config['HomeURL'], 'http');
         $new_values[] = set_url_scheme(home_url());
         // Add plain Home URL SSL
         $old_values[] = set_url_scheme($config['HomeURL'], 'https');
         $new_values[] = set_url_scheme(home_url());
         // Add encoded Home URL
         $old_values[] = urlencode(set_url_scheme($config['HomeURL'], 'http'));
         $new_values[] = urlencode(set_url_scheme(home_url()));
         // Add encoded Home URL SSL
         $old_values[] = urlencode(set_url_scheme($config['HomeURL'], 'https'));
         $new_values[] = urlencode(set_url_scheme(home_url()));
         // Add escaped Home URL
         $old_values[] = addslashes(addcslashes(set_url_scheme($config['HomeURL'], 'http'), '/'));
         $new_values[] = addslashes(addcslashes(set_url_scheme(home_url()), '/'));
         // Add escaped Home URL SSL
         $old_values[] = addslashes(addcslashes(set_url_scheme($config['HomeURL'], 'https'), '/'));
         $new_values[] = addslashes(addcslashes(set_url_scheme(home_url()), '/'));
     }
     // Get WordPress Content
     if (isset($config['WordPress']['Content']) && $config['WordPress']['Content'] !== WP_CONTENT_DIR) {
         // Add plain WordPress Content
         $old_values[] = $config['WordPress']['Content'];
         $new_values[] = WP_CONTENT_DIR;
         // Get escaped WordPress Content
         $old_values[] = addslashes(addcslashes($config['WordPress']['Content'], '\\/'));
         $new_values[] = addslashes(addcslashes(WP_CONTENT_DIR, '\\/'));
     }
     // Get user details
     if (isset($config['Import']['User']['Id']) && ($id = $config['Import']['User']['Id'])) {
         $meta = get_userdata($id);
         $user = array('user_login' => $meta->user_login, 'user_pass' => $meta->user_pass, 'user_nicename' => $meta->user_nicename, 'user_url' => $meta->user_url, 'user_email' => $meta->user_email, 'display_name' => $meta->display_name, 'nickname' => $meta->nickname, 'first_name' => $meta->first_name, 'last_name' => $meta->last_name, 'description' => $meta->description, 'rich_editing' => $meta->rich_editing, 'user_registered' => $meta->user_registered, 'jabber' => $meta->jabber, 'aim' => $meta->aim, 'yim' => $meta->yim, 'show_admin_bar_front' => $meta->show_admin_bar_front);
     } else {
         $user = array();
     }
     // Get URL IP
     $url_ip = get_site_option(AI1WM_URL_IP, false, false);
     // Get URL transport
     $url_transport = get_site_option(AI1WM_URL_TRANSPORT, false, false);
     // Get secret key
     $secret_key = get_site_option(AI1WM_SECRET_KEY, false, false);
     // Get HTTP user
     $auth_user = get_site_option(AI1WM_AUTH_USER, false, false);
     // Get HTTP password
     $auth_password = get_site_option(AI1WM_AUTH_PASSWORD, false, false);
     // Get active plugins
     $active_plugins = get_site_option(AI1WM_ACTIVE_PLUGINS, array(), false);
     // Get database client
     $client = MysqlDumpFactory::makeMysqlDump(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
     // Set database options
     $client->setOldTablePrefixes(array(AI1WM_TABLE_PREFIX))->setNewTablePrefixes(array($wpdb->prefix))->setOldReplaceValues($old_values)->setNewReplaceValues($new_values);
     // Flush database
     if ($version = $config['Plugin']['Version']) {
         if ($version !== 'develop' && version_compare($version, '4.9', '<')) {
             $client->setIncludeTablePrefixes(array($wpdb->prefix));
             $client->flush();
         }
     }
     // Import database
     $client->import($this->storage()->database());
     // Clear WP options cache
     wp_cache_flush();
     // Activate plugins
     foreach ($active_plugins as $plugin) {
         if (in_array($plugin, ai1wm_active_plugins())) {
             activate_plugin($plugin);
         }
     }
     // Set new user identity
     if (isset($config['Export']['User']['Id']) && ($id = $config['Export']['User']['Id'])) {
         // Update user login and password
         if (isset($user['user_login']) && isset($user['user_pass'])) {
             $wpdb->update($wpdb->users, array('user_login' => $user['user_login'], 'user_pass' => $user['user_pass']), array('ID' => $id), array('%s', '%s'), array('%d'));
             // Unset user login
             unset($user['user_login']);
             // Unset user password
             unset($user['user_pass']);
         }
         // Update user details
         $result = wp_update_user(array('ID' => $id) + $user);
         // Log the error
         if (is_wp_error($result)) {
             Ai1wm_Log::error('Exception while importing user identity: ' . $result->get_error_message());
         }
     }
     // Set the new URL IP
     update_site_option(AI1WM_URL_IP, $url_ip);
     // Set the new URL transport
     update_site_option(AI1WM_URL_TRANSPORT, $url_transport);
     // Set the new secret key value
     update_site_option(AI1WM_SECRET_KEY, $secret_key);
     // Set the new HTTP user
     update_site_option(AI1WM_AUTH_USER, $auth_user);
     // Set the new HTTP password
     update_site_option(AI1WM_AUTH_PASSWORD, $auth_password);
 }