/** * Import site * * @return StorageFile */ public function import() { global $wp_version; $storage = StorageArea::getInstance(); // Create import file $import_file = $storage->makeFile($this->options['import']['file']); // Extract archive try { try { $zip = ZipFactory::makeZipArchiver($import_file->getName(), !class_exists('ZipArchive')); $zip->extractTo($storage->getRootPath()); $zip->close(); } catch (Exception $e) { $zip = ZipFactory::makeZipArchiver($import_file->getName(), true); $zip->extractTo($storage->getRootPath()); $zip->close(); } } catch (Exception $e) { throw new Ai1wm_Import_Exception(_('Site could not be imported!<br />' . 'Archive file is broken or is not compatible with the plugin! Please verify your archive file.')); } // Verify package if ($this->should_import_package()) { // Enable maintenance mode Ai1wm_Maintenance::enable(); // Database if ($this->should_import_database()) { $service = new Ai1wm_Service_Database($this->options); $service->import(); } // Media if ($this->should_import_media()) { $service = new Ai1wm_Service_Media($this->options); $service->import(); } // Sites (Network mode) if ($this->should_import_sites()) { $service = new Ai1wm_Service_Sites($this->options); $service->import(); } // Themes if ($this->should_import_themes()) { $service = new Ai1wm_Service_Themes($this->options); $service->import(); } // Plugins if ($this->should_import_plugins()) { $service = new Ai1wm_Service_Plugins($this->options); $service->import(); } // Disable maintenance mode Ai1wm_Maintenance::disable(); } else { throw new Ai1wm_Import_Exception(_('Site could not be imported!<br />' . 'Archive file is not compatible with the plugin! Please verify your archive file.')); } return $import_file; }
/** * Export site * * @return StorageFile */ public function export() { $storage = StorageArea::getInstance(); // Enable maintenance mode Ai1wm_Maintenance::enable(); // Create export file $export_file = $storage->makeFile(); // Make archive file try { $zip = ZipFactory::makeZipArchiver($export_file->getName(), !class_exists('ZipArchive'), true); } catch (Exception $e) { $zip = ZipFactory::makeZipArchiver($export_file->getName(), true, true); } // Package if ($this->should_export_package()) { $service = new Ai1wm_Service_Package($this->options); $zip->addFromString(AI1WM_PACKAGE_NAME, $service->export()); } // Database if ($this->should_export_database()) { $service = new Ai1wm_Service_Database($this->options); // Add database to archive $zip->addFile($service->export(), AI1WM_DATABASE_NAME); } // Media if ($this->should_export_media()) { $service = new Ai1wm_Service_Media($this->options); // Add media to archive $zip->addDir($service->export(), AI1WM_MEDIA_NAME); // Sites (Network mode) $service = new Ai1wm_Service_Sites($this->options); if ($sites = $service->export()) { // Add sites to archive $zip->addDir($sites, AI1WM_SITES_NAME); } } // Themes if ($this->should_export_themes()) { $service = new Ai1wm_Service_Themes($this->options); // Add themes to archive $zip->addDir($service->export(), AI1WM_THEMES_NAME); } // Plugins if ($this->should_export_plugins()) { $service = new Ai1wm_Service_Plugins($this->options); // Add plugins to archive if ($plugins = $service->get_installed_plugins()) { $zip->addDir($service->export(), AI1WM_PLUGINS_NAME, $plugins); } } // Disable maintenance mode Ai1wm_Maintenance::disable(); return $export_file; }
/** * Truncate content files and directories * * @return void */ public function truncate() { // Enable maintenance mode Ai1wm_Maintenance::enable(); // Redirect $this->route_to('content'); }
/** * Enumerate content files and directories * * @return void */ public function enumerate() { // Set progress Ai1wm_Status::set( array( 'message' => __( 'Retrieving a list of all WordPress files...', AI1WM_PLUGIN_NAME ) ) ); // Enable maintenance mode if ( $this->should_enable_maintenance() ) { Ai1wm_Maintenance::enable(); } $filters = array( 'managewp' ); // Exclude media if ( $this->should_exclude_media() ) { $filters = array_merge( $filters, array( 'uploads' ) ); } // Exclude themes if ( $this->should_exclude_themes() ) { $filters = array_merge( $filters, array( 'themes' ) ); } // Exclude plugins if ( $this->should_exclude_plugins() ) { $filters = array_merge( $filters, array( 'plugins' ) ); } else { $filters = array_merge( $filters, array( 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration', 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-dropbox-extension', 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-gdrive-extension', 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-s3-extension', 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-multisite-extension', 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-unlimited-extension', 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-pro-extension', 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-ftp-extension', ) ); } // Create map file $filemap = fopen( $this->storage()->filemap(), 'a+' ); // Total files $total = 0; // Iterate over WP_CONTENT_DIR directory $iterator = new RecursiveIteratorIterator( new Ai1wm_Recursive_Exclude_Filter( new Ai1wm_Recursive_Directory_Iterator( WP_CONTENT_DIR ), apply_filters( 'ai1wm_exclude_content_from_export', $filters ) ), RecursiveIteratorIterator::SELF_FIRST ); foreach ( $iterator as $item ) { if ( $item->isFile() ) { // Write path line if ( fwrite( $filemap, $iterator->getSubPathName() . PHP_EOL ) ) { $total++; } } } fclose( $filemap ); // Set progress Ai1wm_Status::set( array( 'total' => $total, 'message' => __( 'Done retrieving a list of all WordPress files.', AI1WM_PLUGIN_NAME ) ) ); // Redirect $this->route_to( 'content' ); }