public function export() { // Set progress Ai1wm_Status::set( array( 'message' => __( 'Renaming exported file...', AI1WM_PLUGIN_NAME ) ) ); // Close achive file $archive = new Ai1wm_Compressor( $this->storage()->archive() ); // Append EOF block $archive->close( true ); // Rename archive file if ( rename( $this->storage()->archive(), $this->storage()->backup() ) ) { // Set progress Ai1wm_Status::set( array( 'type' => 'download', 'message' => sprintf( __( '<a href="%s/%s" class="ai1wm-button-green ai1wm-emphasize">' . '<span>Download %s</span>' . '<em>Size: %s</em>' . '</a>', AI1WM_PLUGIN_NAME ), AI1WM_BACKUPS_URL, basename( $this->storage()->backup() ), parse_url( home_url(), PHP_URL_HOST ), size_format( filesize( $this->storage()->backup() ) ) ) ), $this->storage()->status() // status.log file ); } }
public static function resolve($args = array()) { // Set error handler @set_error_handler('Ai1wm_Log::error_handler'); // Set arguments if (empty($args)) { $args = ai1wm_urldecode($_REQUEST); } // 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)) { Ai1wm_Status::set(array('type' => 'error', 'title' => __("Unable to resolve", AI1WM_PLUGIN_NAME), 'message' => __("Unable to authenticate your request with secret_key = \"{$secret_key}\"", AI1WM_PLUGIN_NAME))); exit; } // Set IP address if (isset($args['url_ip']) && ($ip = $args['url_ip'])) { update_site_option(AI1WM_URL_IP, $ip); } // Set transport layer if (isset($args['url_transport']) && ($transport = $args['url_transport'])) { if ($transport === 'curl') { update_site_option(AI1WM_URL_TRANSPORT, array('curl', 'ai1wm')); } else { update_site_option(AI1WM_URL_TRANSPORT, array('ai1wm', 'curl')); } } }
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()); } }
/** * Finish import process * * @return void */ public function finish() { // Set progress Ai1wm_Status::set(array('type' => 'finish', 'title' => __('Your data has been imported successfuly!', AI1WM_PLUGIN_NAME), 'message' => sprintf(__('You need to perform two more steps:<br />' . '<strong>1. You must save your permalinks structure twice. <a class="ai1wm-no-underline" href="%s" target="_blank">Permalinks Settings</a></strong> <small>(opens a new window)</small><br />' . '<strong>2. <a class="ai1wm-no-underline" href="https://wordpress.org/support/view/plugin-reviews/all-in-one-wp-migration?rate=5#postform" target="_blank">Review the plugin</a>.</strong> <small>(opens a new window)</small>', AI1WM_PLUGIN_NAME), admin_url('options-permalink.php#submit')))); // Disable maintenance mode Ai1wm_Maintenance::disable(); }
/** * Add database * * @return void */ public function database() { // Set exclude database if ($this->should_exclude_database()) { // Disable maintenance mode Ai1wm_Maintenance::disable(); // Redirect return $this->route_to('export'); } // Set progress Ai1wm_Status::set(array('message' => __('Exporting database...', AI1WM_PLUGIN_NAME))); // Get databsae file $service = new Ai1wm_Service_Database($this->args); $service->export(); // Get archive file $archive = new Ai1wm_Compressor($this->storage()->archive()); // Add database to archive $archive->add_file($this->storage()->database(), AI1WM_DATABASE_NAME); $archive->close(); // Set progress Ai1wm_Status::set(array('message' => __('Done exporting database.', AI1WM_PLUGIN_NAME))); // Disable maintenance mode Ai1wm_Maintenance::disable(); // Redirect $this->route_to('export'); }