8889841cclass-ai1wm-notification.php000064400000006332150502251500012061 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Notification { public static function ok( $subject, $message ) { // Enable notifications if ( ! apply_filters( 'ai1wm_notification_ok_toggle', false ) ) { return; } // Set email if ( ! ( $email = apply_filters( 'ai1wm_notification_ok_email', get_option( 'admin_email', false ) ) ) ) { return; } // Set subject if ( ! ( $subject = apply_filters( 'ai1wm_notification_ok_subject', $subject ) ) ) { return; } // Set message if ( ! ( $message = apply_filters( 'ai1wm_notification_ok_message', $message ) ) ) { return; } // Send email if ( ai1wm_is_scheduled_backup() ) { wp_mail( $email, $subject, $message, array( 'Content-Type: text/html; charset=UTF-8' ) ); } } public static function error( $subject, $message ) { // Enable notifications if ( ! apply_filters( 'ai1wm_notification_error_toggle', false ) ) { return; } // Set email if ( ! ( $email = apply_filters( 'ai1wm_notification_error_email', get_option( 'admin_email', false ) ) ) ) { return; } // Set subject if ( ! ( $subject = apply_filters( 'ai1wm_notification_error_subject', $subject ) ) ) { return; } // Set message if ( ! ( $message = apply_filters( 'ai1wm_notification_error_message', $message ) ) ) { return; } // Send email if ( ai1wm_is_scheduled_backup() ) { wp_mail( $email, $subject, $message, array( 'Content-Type: text/html; charset=UTF-8' ) ); } } } class-ai1wm-updater.php000064400000013476150502251500011046 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Updater { /** * Retrieve plugin installer pages from WordPress Plugins API. * * @param mixed $result * @param string $action * @param array|object $args * @return mixed */ public static function plugins_api( $result, $action = null, $args = null ) { if ( empty( $args->slug ) ) { return $result; } // Get extensions $extensions = Ai1wm_Extensions::get(); // View details page if ( isset( $args->slug ) && isset( $extensions[ $args->slug ] ) && $action === 'plugin_information' ) { // Get current updates $updates = get_option( AI1WM_UPDATER, array() ); // Plugin details if ( isset( $updates[ $args->slug ] ) && ( $details = $updates[ $args->slug ] ) ) { return (object) $details; } } return $result; } /** * Update WordPress plugin list page. * * @param object $transient * @return object */ public static function update_plugins( $transient ) { global $wp_version; // Get extensions $extensions = Ai1wm_Extensions::get(); // Get current updates $updates = get_option( AI1WM_UPDATER, array() ); // Get extension updates foreach ( $updates as $slug => $update ) { if ( isset( $extensions[ $slug ] ) && ( $extension = $extensions[ $slug ] ) ) { if ( ( $purchase_id = get_option( $extension['key'] ) ) ) { if ( version_compare( $extension['version'], $update['version'], '<' ) ) { // Get download URL $download_url = add_query_arg( array( 'siteurl' => get_site_url() ), sprintf( '%s/%s', $update['download_link'], $purchase_id ) ); // Set plugin details $transient->response[ $extension['basename'] ] = (object) array( 'slug' => $slug, 'new_version' => $update['version'], 'url' => $update['homepage'], 'plugin' => $extension['basename'], 'package' => $download_url, 'tested' => $wp_version, 'icons' => $update['icons'], ); } } } } return $transient; } /** * Check for extension updates * * @return void */ public static function check_for_updates() { // Get current updates $updates = get_option( AI1WM_UPDATER, array() ); // Get extension updates foreach ( Ai1wm_Extensions::get() as $slug => $extension ) { $response = wp_remote_get( $extension['about'], array( 'timeout' => 15, 'headers' => array( 'Accept' => 'application/json' ), ) ); // Add updates if ( ! is_wp_error( $response ) ) { if ( ( $response = json_decode( $response['body'], true ) ) ) { // Slug is mandatory if ( ! isset( $response['slug'] ) ) { return; } // Version is mandatory if ( ! isset( $response['version'] ) ) { return; } // Homepage is mandatory if ( ! isset( $response['homepage'] ) ) { return; } // Download link is mandatory if ( ! isset( $response['download_link'] ) ) { return; } $updates[ $slug ] = $response; } } } // Set new updates update_option( AI1WM_UPDATER, $updates ); } /** * Add "Check for updates" link * * @param array $links The array having default links for the plugin. * @param string $file The name of the plugin file. * @return array */ public static function plugin_row_meta( $links, $file ) { $modal_index = 0; // Add link for each extension foreach ( Ai1wm_Extensions::get() as $slug => $extension ) { $modal_index++; // Get plugin details if ( $file === $extension['basename'] ) { // Get updater URL $updater_url = add_query_arg( array( 'ai1wm_updater' => 1 ), network_admin_url( 'plugins.php' ) ); // Check Purchase ID if ( get_option( $extension['key'] ) ) { // Add "Check for updates" link $links[] = Ai1wm_Template::get_content( 'updater/check', array( 'url' => $updater_url, ) ); } else { // Add modal $links[] = Ai1wm_Template::get_content( 'updater/modal', array( 'url' => $updater_url, 'modal' => $modal_index, ) ); } } } return $links; } } class-ai1wm-status.php000064400000005517150502251500010722 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Status { public static function error( $title, $message ) { self::log( array( 'type' => 'error', 'title' => $title, 'message' => $message ) ); } public static function info( $message ) { self::log( array( 'type' => 'info', 'message' => $message ) ); } public static function download( $message ) { self::log( array( 'type' => 'download', 'message' => $message ) ); } public static function confirm( $message ) { self::log( array( 'type' => 'confirm', 'message' => $message ) ); } public static function done( $title, $message ) { self::log( array( 'type' => 'done', 'title' => $title, 'message' => $message ) ); } public static function blogs( $title, $message ) { self::log( array( 'type' => 'blogs', 'title' => $title, 'message' => $message ) ); } public static function progress( $percent ) { self::log( array( 'type' => 'progress', 'percent' => $percent ) ); } public static function log( $data ) { if ( ! ai1wm_is_scheduled_backup() ) { update_option( AI1WM_STATUS, $data ); } } } class-ai1wm-template.php000064400000005135150502251500011206 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Template extends Bandar { /** * Renders a file and returns its contents * * @param string $file View to render * @param array $args Set of arguments * * @return string Rendered view */ public static function render( $view, $args = array(), $path = false ) { parent::render( $view, $args, $path ); } /** * Returns link to an asset file * * @param string $asset Asset file * * @return string Asset URL */ public static function asset_link( $asset, $prefix = 'AI1WM' ) { return constant( $prefix . '_URL' ) . '/lib/view/assets/' . $asset . '?v=' . constant( $prefix . '_VERSION' ); } public static function get_content( $template, $args = array(), $path = false ) { return parent::getTemplateContent( $template, $args, $path ); } } class-ai1wm-extensions.php000064400000020161150502251500011566 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Extensions { /** * Get active extensions * * @return array */ public static function get() { $extensions = array(); // Add Microsoft Azure extension if ( defined( 'AI1WMZE_PLUGIN_NAME' ) ) { $extensions[ AI1WMZE_PLUGIN_NAME ] = array( 'key' => AI1WMZE_PLUGIN_KEY, 'title' => AI1WMZE_PLUGIN_TITLE, 'about' => AI1WMZE_PLUGIN_ABOUT, 'basename' => AI1WMZE_PLUGIN_BASENAME, 'version' => AI1WMZE_VERSION, 'requires' => '1.1', 'short' => AI1WMZE_PLUGIN_SHORT, ); } // Add Backblaze B2 extension if ( defined( 'AI1WMAE_PLUGIN_NAME' ) ) { $extensions[ AI1WMAE_PLUGIN_NAME ] = array( 'key' => AI1WMAE_PLUGIN_KEY, 'title' => AI1WMAE_PLUGIN_TITLE, 'about' => AI1WMAE_PLUGIN_ABOUT, 'basename' => AI1WMAE_PLUGIN_BASENAME, 'version' => AI1WMAE_VERSION, 'requires' => '1.3', 'short' => AI1WMAE_PLUGIN_SHORT, ); } // Add Box Extension if ( defined( 'AI1WMBE_PLUGIN_NAME' ) ) { $extensions[ AI1WMBE_PLUGIN_NAME ] = array( 'key' => AI1WMBE_PLUGIN_KEY, 'title' => AI1WMBE_PLUGIN_TITLE, 'about' => AI1WMBE_PLUGIN_ABOUT, 'basename' => AI1WMBE_PLUGIN_BASENAME, 'version' => AI1WMBE_VERSION, 'requires' => '1.13', 'short' => AI1WMBE_PLUGIN_SHORT, ); } // Add DigitalOcean Extension if ( defined( 'AI1WMIE_PLUGIN_NAME' ) ) { $extensions[ AI1WMIE_PLUGIN_NAME ] = array( 'key' => AI1WMIE_PLUGIN_KEY, 'title' => AI1WMIE_PLUGIN_TITLE, 'about' => AI1WMIE_PLUGIN_ABOUT, 'basename' => AI1WMIE_PLUGIN_BASENAME, 'version' => AI1WMIE_VERSION, 'requires' => '1.6', 'short' => AI1WMIE_PLUGIN_SHORT, ); } // Add Dropbox Extension if ( defined( 'AI1WMDE_PLUGIN_NAME' ) ) { $extensions[ AI1WMDE_PLUGIN_NAME ] = array( 'key' => AI1WMDE_PLUGIN_KEY, 'title' => AI1WMDE_PLUGIN_TITLE, 'about' => AI1WMDE_PLUGIN_ABOUT, 'basename' => AI1WMDE_PLUGIN_BASENAME, 'version' => AI1WMDE_VERSION, 'requires' => '3.32', 'short' => AI1WMDE_PLUGIN_SHORT, ); } // Add FTP Extension if ( defined( 'AI1WMFE_PLUGIN_NAME' ) ) { $extensions[ AI1WMFE_PLUGIN_NAME ] = array( 'key' => AI1WMFE_PLUGIN_KEY, 'title' => AI1WMFE_PLUGIN_TITLE, 'about' => AI1WMFE_PLUGIN_ABOUT, 'basename' => AI1WMFE_PLUGIN_BASENAME, 'version' => AI1WMFE_VERSION, 'requires' => '2.37', 'short' => AI1WMFE_PLUGIN_SHORT, ); } // Add Google Cloud Storage Extension if ( defined( 'AI1WMCE_PLUGIN_NAME' ) ) { $extensions[ AI1WMCE_PLUGIN_NAME ] = array( 'key' => AI1WMCE_PLUGIN_KEY, 'title' => AI1WMCE_PLUGIN_TITLE, 'about' => AI1WMCE_PLUGIN_ABOUT, 'basename' => AI1WMCE_PLUGIN_BASENAME, 'version' => AI1WMCE_VERSION, 'requires' => '1.0', 'short' => AI1WMCE_PLUGIN_SHORT, ); } // Add Google Drive Extension if ( defined( 'AI1WMGE_PLUGIN_NAME' ) ) { $extensions[ AI1WMGE_PLUGIN_NAME ] = array( 'key' => AI1WMGE_PLUGIN_KEY, 'title' => AI1WMGE_PLUGIN_TITLE, 'about' => AI1WMGE_PLUGIN_ABOUT, 'basename' => AI1WMGE_PLUGIN_BASENAME, 'version' => AI1WMGE_VERSION, 'requires' => '2.36', 'short' => AI1WMGE_PLUGIN_SHORT, ); } // Add Amazon Glacier extension if ( defined( 'AI1WMRE_PLUGIN_NAME' ) ) { $extensions[ AI1WMRE_PLUGIN_NAME ] = array( 'key' => AI1WMRE_PLUGIN_KEY, 'title' => AI1WMRE_PLUGIN_TITLE, 'about' => AI1WMRE_PLUGIN_ABOUT, 'basename' => AI1WMRE_PLUGIN_BASENAME, 'version' => AI1WMRE_VERSION, 'requires' => '1.0', 'short' => AI1WMRE_PLUGIN_SHORT, ); } // Add Mega Extension if ( defined( 'AI1WMEE_PLUGIN_NAME' ) ) { $extensions[ AI1WMEE_PLUGIN_NAME ] = array( 'key' => AI1WMEE_PLUGIN_KEY, 'title' => AI1WMEE_PLUGIN_TITLE, 'about' => AI1WMEE_PLUGIN_ABOUT, 'basename' => AI1WMEE_PLUGIN_BASENAME, 'version' => AI1WMEE_VERSION, 'requires' => '1.10', 'short' => AI1WMEE_PLUGIN_SHORT, ); } // Add Multisite Extension if ( defined( 'AI1WMME_PLUGIN_NAME' ) ) { $extensions[ AI1WMME_PLUGIN_NAME ] = array( 'key' => AI1WMME_PLUGIN_KEY, 'title' => AI1WMME_PLUGIN_TITLE, 'about' => AI1WMME_PLUGIN_ABOUT, 'basename' => AI1WMME_PLUGIN_BASENAME, 'version' => AI1WMME_VERSION, 'requires' => '3.59', 'short' => AI1WMME_PLUGIN_SHORT, ); } // Add OneDrive Extension if ( defined( 'AI1WMOE_PLUGIN_NAME' ) ) { $extensions[ AI1WMOE_PLUGIN_NAME ] = array( 'key' => AI1WMOE_PLUGIN_KEY, 'title' => AI1WMOE_PLUGIN_TITLE, 'about' => AI1WMOE_PLUGIN_ABOUT, 'basename' => AI1WMOE_PLUGIN_BASENAME, 'version' => AI1WMOE_VERSION, 'requires' => '1.23', 'short' => AI1WMOE_PLUGIN_SHORT, ); } // Add pCloud Extension if ( defined( 'AI1WMPE_PLUGIN_NAME' ) ) { $extensions[ AI1WMPE_PLUGIN_NAME ] = array( 'key' => AI1WMPE_PLUGIN_KEY, 'title' => AI1WMPE_PLUGIN_TITLE, 'about' => AI1WMPE_PLUGIN_ABOUT, 'basename' => AI1WMPE_PLUGIN_BASENAME, 'version' => AI1WMPE_VERSION, 'requires' => '1.0', 'short' => AI1WMPE_PLUGIN_SHORT, ); } // Add Amazon S3 extension if ( defined( 'AI1WMSE_PLUGIN_NAME' ) ) { $extensions[ AI1WMSE_PLUGIN_NAME ] = array( 'key' => AI1WMSE_PLUGIN_KEY, 'title' => AI1WMSE_PLUGIN_TITLE, 'about' => AI1WMSE_PLUGIN_ABOUT, 'basename' => AI1WMSE_PLUGIN_BASENAME, 'version' => AI1WMSE_VERSION, 'requires' => '3.27', 'short' => AI1WMSE_PLUGIN_SHORT, ); } // Add Unlimited Extension if ( defined( 'AI1WMUE_PLUGIN_NAME' ) ) { $extensions[ AI1WMUE_PLUGIN_NAME ] = array( 'key' => AI1WMUE_PLUGIN_KEY, 'title' => AI1WMUE_PLUGIN_TITLE, 'about' => AI1WMUE_PLUGIN_ABOUT, 'basename' => AI1WMUE_PLUGIN_BASENAME, 'version' => AI1WMUE_VERSION, 'requires' => '2.18', 'short' => AI1WMUE_PLUGIN_SHORT, ); } // Add URL Extension if ( defined( 'AI1WMLE_PLUGIN_NAME' ) ) { $extensions[ AI1WMLE_PLUGIN_NAME ] = array( 'key' => AI1WMLE_PLUGIN_KEY, 'title' => AI1WMLE_PLUGIN_TITLE, 'about' => AI1WMLE_PLUGIN_ABOUT, 'basename' => AI1WMLE_PLUGIN_BASENAME, 'version' => AI1WMLE_VERSION, 'requires' => '2.27', 'short' => AI1WMLE_PLUGIN_SHORT, ); } return $extensions; } } class-ai1wm-log.php000064400000005716150502251500010161 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Log { public static function export( $params ) { $data = array(); // Add date $data[] = date( 'M d Y H:i:s' ); // Add params $data[] = json_encode( $params ); // Add empty line $data[] = PHP_EOL; // Write log data if ( $handle = ai1wm_open( ai1wm_export_path( $params ), 'a' ) ) { ai1wm_write( $handle, implode( PHP_EOL, $data ) ); ai1wm_close( $handle ); } } public static function import( $params ) { $data = array(); // Add date $data[] = date( 'M d Y H:i:s' ); // Add params $data[] = json_encode( $params ); // Add empty line $data[] = PHP_EOL; // Write log data if ( $handle = ai1wm_open( ai1wm_import_path( $params ), 'a' ) ) { ai1wm_write( $handle, implode( PHP_EOL, $data ) ); ai1wm_close( $handle ); } } public static function error( $params ) { $data = array(); // Add date $data[] = date( 'M d Y H:i:s' ); // Add params $data[] = json_encode( $params ); // Add empty line $data[] = PHP_EOL; // Write log data if ( $handle = ai1wm_open( ai1wm_error_path(), 'a' ) ) { ai1wm_write( $handle, implode( PHP_EOL, $data ) ); ai1wm_close( $handle ); } } } class-ai1wm-handler.php000064400000004644150502251500011014 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Handler { /** * 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, ) ); } /** * Shutdown handler * * @return void */ public static function shutdown() { if ( ( $error = error_get_last() ) ) { Ai1wm_Log::error( $error ); } } } class-ai1wm-backups.php000064400000007334150502251500011026 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Backups { /** * Get all backup files * * @return array */ public function get_files() { $backups = array(); // Iterate over directory $iterator = new Ai1wm_Recursive_Directory_Iterator( AI1WM_BACKUPS_PATH ); // Filter by extensions $iterator = new Ai1wm_Recursive_Extension_Filter( $iterator, array( 'wpress' ) ); // Recursively iterate over directory $iterator = new Ai1wm_Recursive_Iterator_Iterator( $iterator, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD ); // Get backup files foreach ( $iterator as $item ) { try { if ( ai1wm_is_filesize_supported( $item->getPathname() ) ) { $backups[] = array( 'path' => $iterator->getSubPath(), 'filename' => $iterator->getSubPathname(), 'mtime' => $iterator->getMTime(), 'size' => $iterator->getSize(), ); } else { $backups[] = array( 'path' => $iterator->getSubPath(), 'filename' => $iterator->getSubPathname(), 'mtime' => $iterator->getMTime(), 'size' => null, ); } } catch ( Exception $e ) { $backups[] = array( 'path' => $iterator->getSubPath(), 'filename' => $iterator->getSubPathname(), 'mtime' => null, 'size' => null, ); } } // Sort backups modified date usort( $backups, array( $this, 'compare' ) ); return $backups; } /** * Delete file * * @param string $file File name * @return boolean */ public function delete_file( $file ) { if ( validate_file( $file ) === 0 ) { return @unlink( ai1wm_backup_path( array( 'archive' => $file ) ) ); } } /** * Compare backup files by modified time * * @param array $a File item A * @param array $b File item B * @return integer */ public function compare( $a, $b ) { if ( $a['mtime'] === $b['mtime'] ) { return 0; } return ( $a['mtime'] > $b['mtime'] ) ? - 1 : 1; } } export/class-ai1wm-export-config.php000064400000012667150502251500013510 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Export_Config { public static function execute( $params ) { global $wp_version, $wpdb; // Set progress Ai1wm_Status::info( __( 'Preparing configuration file...', AI1WM_PLUGIN_NAME ) ); // Get options $options = wp_load_alloptions(); // Get database client if ( empty( $wpdb->use_mysqli ) ) { $mysql = new Ai1wm_Database_Mysql( $wpdb ); } else { $mysql = new Ai1wm_Database_Mysqli( $wpdb ); } $config = array(); // Set site URL $config['SiteURL'] = site_url(); // Set home URL $config['HomeURL'] = home_url(); // Set internal site URL if ( isset( $options['siteurl'] ) && ( untrailingslashit( $options['siteurl'] ) !== site_url() ) ) { $config['InternalSiteURL'] = untrailingslashit( $options['siteurl'] ); } // Set internal home URL if ( isset( $options['home'] ) && ( untrailingslashit( $options['home'] ) !== home_url() ) ) { $config['InternalHomeURL'] = untrailingslashit( $options['home'] ); } // Set replace old and new values if ( isset( $params['options']['replace'] ) && ( $replace = $params['options']['replace'] ) ) { for ( $i = 0; $i < count( $replace['old_value'] ); $i++ ) { if ( ! empty( $replace['old_value'][ $i ] ) && ! empty( $replace['new_value'][ $i ] ) ) { $config['Replace']['OldValues'][] = $replace['old_value'][ $i ]; $config['Replace']['NewValues'][] = $replace['new_value'][ $i ]; } } } // Set no spam comments if ( isset( $params['options']['no_spam_comments'] ) ) { $config['NoSpamComments'] = true; } // Set no post revisions if ( isset( $params['options']['no_post_revisions'] ) ) { $config['NoPostRevisions'] = true; } // Set no media if ( isset( $params['options']['no_media'] ) ) { $config['NoMedia'] = true; } // Set no themes if ( isset( $params['options']['no_themes'] ) ) { $config['NoThemes'] = true; } // Set no inactive themes if ( isset( $params['options']['no_inactive_themes'] ) ) { $config['NoInactiveThemes'] = true; } // Set no must-use plugins if ( isset( $params['options']['no_muplugins'] ) ) { $config['NoMustUsePlugins'] = true; } // Set no plugins if ( isset( $params['options']['no_plugins'] ) ) { $config['NoPlugins'] = true; } // Set no inactive plugins if ( isset( $params['options']['no_inactive_plugins'] ) ) { $config['NoInactivePlugins'] = true; } // Set no cache if ( isset( $params['options']['no_cache'] ) ) { $config['NoCache'] = true; } // Set no database if ( isset( $params['options']['no_database'] ) ) { $config['NoDatabase'] = true; } // Set no email replace if ( isset( $params['options']['no_email_replace'] ) ) { $config['NoEmailReplace'] = true; } // Set plugin version $config['Plugin'] = array( 'Version' => AI1WM_VERSION ); // Set WordPress version and content $config['WordPress'] = array( 'Version' => $wp_version, 'Content' => WP_CONTENT_DIR ); // Set database version $config['Database'] = array( 'Version' => $mysql->version() ); // Set PHP version $config['PHP'] = array( 'Version' => PHP_VERSION ); // Set active plugins $config['Plugins'] = array_values( array_diff( ai1wm_active_plugins(), ai1wm_active_servmask_plugins() ) ); // Set active template $config['Template'] = ai1wm_active_template(); // Set active stylesheet $config['Stylesheet'] = ai1wm_active_stylesheet(); // Save package.json file $handle = ai1wm_open( ai1wm_package_path( $params ), 'w' ); ai1wm_write( $handle, json_encode( $config ) ); ai1wm_close( $handle ); // Set progress Ai1wm_Status::info( __( 'Done preparing configuration file.', AI1WM_PLUGIN_NAME ) ); return $params; } } export/class-ai1wm-export-clean.php000064400000003716150502251500013320 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Export_Clean { public static function execute( $params ) { Ai1wm_Directory::delete( ai1wm_storage_path( $params ) ); exit; } } export/class-ai1wm-export-enumerate.php000064400000012577150502251500014230 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Export_Enumerate { public static function execute( $params ) { // Get total files count if ( isset( $params['total_files_count'] ) ) { $total_files_count = (int) $params['total_files_count']; } else { $total_files_count = 0; } // Get total files size if ( isset( $params['total_files_size'] ) ) { $total_files_size = (int) $params['total_files_size']; } else { $total_files_size = 0; } // Set progress Ai1wm_Status::info( __( 'Retrieving a list of all WordPress files...', AI1WM_PLUGIN_NAME ) ); // Set exclude filters $exclude_filters = ai1wm_content_filters(); // Exclude cache if ( isset( $params['options']['no_cache'] ) ) { $exclude_filters[] = 'cache'; } // Exclude themes if ( isset( $params['options']['no_themes'] ) ) { $exclude_filters[] = 'themes'; } else { $inactive_themes = array(); // Exclude inactive themes if ( isset( $params['options']['no_inactive_themes'] ) ) { foreach ( wp_get_themes() as $theme => $info ) { // Exclude current parent and child themes if ( ! in_array( $theme, array( get_template(), get_stylesheet() ) ) ) { $inactive_themes[] = 'themes' . DIRECTORY_SEPARATOR . $theme; } } } // Set exclude filters $exclude_filters = array_merge( $exclude_filters, $inactive_themes ); } // Exclude must-use plugins if ( isset( $params['options']['no_muplugins'] ) ) { $exclude_filters = array_merge( $exclude_filters, array( 'mu-plugins' ) ); } // Exclude plugins if ( isset( $params['options']['no_plugins'] ) ) { $exclude_filters = array_merge( $exclude_filters, array( 'plugins' ) ); } else { $inactive_plugins = array(); // Exclude inactive plugins if ( isset( $params['options']['no_inactive_plugins'] ) ) { foreach ( get_plugins() as $plugin => $info ) { if ( is_plugin_inactive( $plugin ) ) { $inactive_plugins[] = 'plugins' . DIRECTORY_SEPARATOR . ( ( dirname( $plugin ) === '.' ) ? basename( $plugin ) : dirname( $plugin ) ); } } } // Set exclude filters $exclude_filters = array_merge( $exclude_filters, ai1wm_plugin_filters( $inactive_plugins ) ); } // Exclude media if ( isset( $params['options']['no_media'] ) ) { $exclude_filters = array_merge( $exclude_filters, array( 'uploads', 'blogs.dir' ) ); } // Create map file $filemap = ai1wm_open( ai1wm_filemap_path( $params ), 'w' ); // Iterate over content directory $iterator = new Ai1wm_Recursive_Directory_Iterator( WP_CONTENT_DIR ); // Exclude new line file names $iterator = new Ai1wm_Recursive_Newline_Filter( $iterator ); // Exclude uploads, plugins or themes $iterator = new Ai1wm_Recursive_Exclude_Filter( $iterator, apply_filters( 'ai1wm_exclude_content_from_export', $exclude_filters ) ); // Recursively iterate over content directory $iterator = new Ai1wm_Recursive_Iterator_Iterator( $iterator, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD ); // Write path line foreach ( $iterator as $item ) { if ( $item->isFile() ) { if ( ai1wm_write( $filemap, $iterator->getSubPathName() . PHP_EOL ) ) { $total_files_count++; // Add current file size $total_files_size += $iterator->getSize(); } } } // Set progress Ai1wm_Status::info( __( 'Done retrieving a list of all WordPress files.', AI1WM_PLUGIN_NAME ) ); // Set total files count $params['total_files_count'] = $total_files_count; // Set total files size $params['total_files_size'] = $total_files_size; // Close the filemap file ai1wm_close( $filemap ); return $params; } } export/class-ai1wm-export-database-file.php000064400000011007150502251500014707 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Export_Database_File { public static function execute( $params ) { // Set exclude database if ( isset( $params['options']['no_database'] ) ) { return $params; } $database_bytes_written = 0; // Set archive bytes offset if ( isset( $params['archive_bytes_offset'] ) ) { $archive_bytes_offset = (int) $params['archive_bytes_offset']; } else { $archive_bytes_offset = ai1wm_archive_bytes( $params ); } // Set database bytes offset if ( isset( $params['database_bytes_offset'] ) ) { $database_bytes_offset = (int) $params['database_bytes_offset']; } else { $database_bytes_offset = 0; } // Get total database size if ( isset( $params['total_database_size'] ) ) { $total_database_size = (int) $params['total_database_size']; } else { $total_database_size = ai1wm_database_bytes( $params ); } // What percent of database have we processed? $progress = (int) min( ( $database_bytes_offset / $total_database_size ) * 100, 100 ); // Set progress Ai1wm_Status::info( sprintf( __( 'Archiving database...
%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) ); // Open the archive file for writing $archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ) ); // Set the file pointer to the one that we have saved $archive->set_file_pointer( $archive_bytes_offset ); // Add database.sql to archive if ( $archive->add_file( ai1wm_database_path( $params ), AI1WM_DATABASE_NAME, $database_bytes_written, $database_bytes_offset ) ) { // Set progress Ai1wm_Status::info( __( 'Done archiving database.', AI1WM_PLUGIN_NAME ) ); // Unset archive bytes offset unset( $params['archive_bytes_offset'] ); // Unset database bytes offset unset( $params['database_bytes_offset'] ); // Unset total database size unset( $params['total_database_size'] ); // Unset completed flag unset( $params['completed'] ); } else { // Get archive bytes offset $archive_bytes_offset = $archive->get_file_pointer(); // What percent of database have we processed? $progress = (int) min( ( $database_bytes_offset / $total_database_size ) * 100, 100 ); // Set progress Ai1wm_Status::info( sprintf( __( 'Archiving database...
%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) ); // Set archive bytes offset $params['archive_bytes_offset'] = $archive_bytes_offset; // Set database bytes offset $params['database_bytes_offset'] = $database_bytes_offset; // Set total database size $params['total_database_size'] = $total_database_size; // Set completed flag $params['completed'] = false; } // Truncate the archive file $archive->truncate(); // Close the archive file $archive->close(); return $params; } } export/class-ai1wm-export-config-file.php000064400000010633150502251500014414 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Export_Config_File { public static function execute( $params ) { $package_bytes_written = 0; // Set archive bytes offset if ( isset( $params['archive_bytes_offset'] ) ) { $archive_bytes_offset = (int) $params['archive_bytes_offset']; } else { $archive_bytes_offset = ai1wm_archive_bytes( $params ); } // Set package bytes offset if ( isset( $params['package_bytes_offset'] ) ) { $package_bytes_offset = (int) $params['package_bytes_offset']; } else { $package_bytes_offset = 0; } // Get total package size if ( isset( $params['total_package_size'] ) ) { $total_package_size = (int) $params['total_package_size']; } else { $total_package_size = ai1wm_package_bytes( $params ); } // What percent of package have we processed? $progress = (int) min( ( $package_bytes_offset / $total_package_size ) * 100, 100 ); // Set progress Ai1wm_Status::info( sprintf( __( 'Archiving configuration file...
%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) ); // Open the archive file for writing $archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ) ); // Set the file pointer to the one that we have saved $archive->set_file_pointer( $archive_bytes_offset ); // Add package.json to archive if ( $archive->add_file( ai1wm_package_path( $params ), AI1WM_PACKAGE_NAME, $package_bytes_written, $package_bytes_offset ) ) { // Set progress Ai1wm_Status::info( __( 'Done archiving configuration file.', AI1WM_PLUGIN_NAME ) ); // Unset archive bytes offset unset( $params['archive_bytes_offset'] ); // Unset package bytes offset unset( $params['package_bytes_offset'] ); // Unset total package size unset( $params['total_package_size'] ); // Unset completed flag unset( $params['completed'] ); } else { // Get archive bytes offset $archive_bytes_offset = $archive->get_file_pointer(); // What percent of package have we processed? $progress = (int) min( ( $package_bytes_offset / $total_package_size ) * 100, 100 ); // Set progress Ai1wm_Status::info( sprintf( __( 'Archiving configuration file...
%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) ); // Set archive bytes offset $params['archive_bytes_offset'] = $archive_bytes_offset; // Set package bytes offset $params['package_bytes_offset'] = $package_bytes_offset; // Set total package size $params['total_package_size'] = $total_package_size; // Set completed flag $params['completed'] = false; } // Truncate the archive file $archive->truncate(); // Close the archive file $archive->close(); return $params; } } export/class-ai1wm-export-content.php000064400000014347150502251500013712 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Export_Content { public static function execute( $params ) { // Set archive bytes offset if ( isset( $params['archive_bytes_offset'] ) ) { $archive_bytes_offset = (int) $params['archive_bytes_offset']; } else { $archive_bytes_offset = ai1wm_archive_bytes( $params ); } // Set file bytes offset if ( isset( $params['file_bytes_offset'] ) ) { $file_bytes_offset = (int) $params['file_bytes_offset']; } else { $file_bytes_offset = 0; } // Set filemap bytes offset if ( isset( $params['filemap_bytes_offset'] ) ) { $filemap_bytes_offset = (int) $params['filemap_bytes_offset']; } else { $filemap_bytes_offset = 0; } // Get processed files size if ( isset( $params['processed_files_size'] ) ) { $processed_files_size = (int) $params['processed_files_size']; } else { $processed_files_size = 0; } // Get total files size if ( isset( $params['total_files_size'] ) ) { $total_files_size = (int) $params['total_files_size']; } else { $total_files_size = 1; } // Get total files count if ( isset( $params['total_files_count'] ) ) { $total_files_count = (int) $params['total_files_count']; } else { $total_files_count = 1; } // What percent of files have we processed? $progress = (int) min( ( $processed_files_size / $total_files_size ) * 100, 100 ); // Set progress Ai1wm_Status::info( sprintf( __( 'Archiving %d files...
%d%% complete', AI1WM_PLUGIN_NAME ), $total_files_count, $progress ) ); // Flag to hold if file data has been processed $completed = true; // Start time $start = microtime( true ); // Get map file $filemap = ai1wm_open( ai1wm_filemap_path( $params ), 'r' ); // Set filemap pointer at the current index if ( fseek( $filemap, $filemap_bytes_offset ) !== -1 ) { // Open the archive file for writing $archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ) ); // Set the file pointer to the one that we have saved $archive->set_file_pointer( $archive_bytes_offset ); // Loop over files while ( $path = trim( fgets( $filemap ) ) ) { $file_bytes_written = 0; // Add file to archive if ( ( $completed = $archive->add_file( WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $path, $path, $file_bytes_written, $file_bytes_offset ) ) ) { $file_bytes_offset = 0; // Get filemap bytes offset $filemap_bytes_offset = ftell( $filemap ); } // Increment processed files size $processed_files_size += $file_bytes_written; // What percent of files have we processed? $progress = (int) min( ( $processed_files_size / $total_files_size ) * 100, 100 ); // Set progress Ai1wm_Status::info( sprintf( __( 'Archiving %d files...
%d%% complete', AI1WM_PLUGIN_NAME ), $total_files_count, $progress ) ); // More than 10 seconds have passed, break and do another request if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) { if ( ( microtime( true ) - $start ) > $timeout ) { $completed = false; break; } } } // Get archive bytes offset $archive_bytes_offset = $archive->get_file_pointer(); // Truncate the archive file $archive->truncate(); // Close the archive file $archive->close(); } // End of the filemap? if ( feof( $filemap ) ) { // Unset archive bytes offset unset( $params['archive_bytes_offset'] ); // Unset file bytes offset unset( $params['file_bytes_offset'] ); // Unset filemap bytes offset unset( $params['filemap_bytes_offset'] ); // Unset processed files size unset( $params['processed_files_size'] ); // Unset total files size unset( $params['total_files_size'] ); // Unset total files count unset( $params['total_files_count'] ); // Unset completed flag unset( $params['completed'] ); } else { // Set archive bytes offset $params['archive_bytes_offset'] = $archive_bytes_offset; // Set file bytes offset $params['file_bytes_offset'] = $file_bytes_offset; // Set filemap bytes offset $params['filemap_bytes_offset'] = $filemap_bytes_offset; // Set processed files size $params['processed_files_size'] = $processed_files_size; // Set total files size $params['total_files_size'] = $total_files_size; // Set total files count $params['total_files_count'] = $total_files_count; // Set completed flag $params['completed'] = $completed; } // Close the filemap file ai1wm_close( $filemap ); return $params; } } export/class-ai1wm-export-database.php000064400000015520150502251500013776 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Export_Database { public static function execute( $params ) { global $wpdb; // Set exclude database if ( isset( $params['options']['no_database'] ) ) { return $params; } // Set table index if ( isset( $params['table_index'] ) ) { $table_index = (int) $params['table_index']; } else { $table_index = 0; } // Set table offset if ( isset( $params['table_offset'] ) ) { $table_offset = (int) $params['table_offset']; } else { $table_offset = 0; } // Set total tables count if ( isset( $params['total_tables_count'] ) ) { $total_tables_count = (int) $params['total_tables_count']; } else { $total_tables_count = 1; } // What percent of tables have we processed? $progress = (int) ( ( $table_index / $total_tables_count ) * 100 ); // Set progress Ai1wm_Status::info( sprintf( __( 'Exporting database...
%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) ); // Get database client if ( empty( $wpdb->use_mysqli ) ) { $mysql = new Ai1wm_Database_Mysql( $wpdb ); } else { $mysql = new Ai1wm_Database_Mysqli( $wpdb ); } // Exclude spam comments if ( isset( $params['options']['no_spam_comments'] ) ) { $mysql->set_table_where_clauses( ai1wm_table_prefix() . 'comments', array( "`comment_approved` != 'spam'" ) ) ->set_table_where_clauses( ai1wm_table_prefix() . 'commentmeta', array( sprintf( "`comment_ID` IN ( SELECT `comment_ID` FROM `%s` WHERE `comment_approved` != 'spam' )", ai1wm_table_prefix() . 'comments' ) ) ); } // Exclude post revisions if ( isset( $params['options']['no_post_revisions'] ) ) { $mysql->set_table_where_clauses( ai1wm_table_prefix() . 'posts', array( "`post_type` != 'revision'" ) ); } $old_table_prefixes = $old_column_prefixes = array(); $new_table_prefixes = $new_column_prefixes = array(); // Set table prefixes if ( ai1wm_table_prefix() ) { $old_table_prefixes[] = $old_column_prefixes[] = ai1wm_table_prefix(); $new_table_prefixes[] = $new_column_prefixes[] = ai1wm_servmask_prefix(); } else { // Set table prefixes based on table name foreach ( $mysql->get_tables() as $table_name ) { $old_table_prefixes[] = $table_name; $new_table_prefixes[] = ai1wm_servmask_prefix() . $table_name; } // Set table prefixes based on column name foreach ( array( 'user_roles' ) as $option_name ) { $old_column_prefixes[] = $option_name; $new_column_prefixes[] = ai1wm_servmask_prefix() . $option_name; } // Set table prefixes based on column name foreach ( array( 'capabilities', 'user_level', 'dashboard_quick_press_last_post_id', 'user-settings', 'user-settings-time' ) as $meta_key ) { $old_column_prefixes[] = $meta_key; $new_column_prefixes[] = ai1wm_servmask_prefix() . $meta_key; } } $include_table_prefixes = array(); $exclude_table_prefixes = array(); // Include table prefixes if ( ai1wm_table_prefix() ) { $include_table_prefixes[] = ai1wm_table_prefix(); } else { foreach ( $mysql->get_tables() as $table_name ) { $include_table_prefixes[] = $table_name; } } // Set database options $mysql->set_old_table_prefixes( $old_table_prefixes ) ->set_new_table_prefixes( $new_table_prefixes ) ->set_old_column_prefixes( $old_column_prefixes ) ->set_new_column_prefixes( $new_column_prefixes ) ->set_include_table_prefixes( $include_table_prefixes ) ->set_exclude_table_prefixes( $exclude_table_prefixes ); // Exclude site options $mysql->set_table_where_clauses( ai1wm_table_prefix() . 'options', array( sprintf( "`option_name` NOT IN ('%s', '%s', '%s', '%s', '%s', '%s', '%s')", AI1WM_ACTIVE_PLUGINS, AI1WM_ACTIVE_TEMPLATE, AI1WM_ACTIVE_STYLESHEET, AI1WM_STATUS, AI1WM_SECRET_KEY, AI1WM_AUTH_USER, AI1WM_AUTH_PASSWORD ) ) ); // Replace table prefix on columns $mysql->set_table_prefix_columns( ai1wm_table_prefix() . 'options', array( 'option_name' ) ) ->set_table_prefix_columns( ai1wm_table_prefix() . 'usermeta', array( 'meta_key' ) ); // Export database if ( $mysql->export( ai1wm_database_path( $params ), $table_index, $table_offset ) ) { // Set progress Ai1wm_Status::info( __( 'Done exporting database.', AI1WM_PLUGIN_NAME ) ); // Unset table index unset( $params['table_index'] ); // Unset table offset unset( $params['table_offset'] ); // Unset total tables count unset( $params['total_tables_count'] ); // Unset completed flag unset( $params['completed'] ); } else { // Get total tables count $total_tables_count = count( $mysql->get_tables() ); // What percent of tables have we processed? $progress = (int) ( ( $table_index / $total_tables_count ) * 100 ); // Set progress Ai1wm_Status::info( sprintf( __( 'Exporting database...
%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) ); // Set table index $params['table_index'] = $table_index; // Set table offset $params['table_offset'] = $table_offset; // Set total tables count $params['total_tables_count'] = $total_tables_count; // Set completed flag $params['completed'] = false; } return $params; } } export/class-ai1wm-export-download.php000064400000005650150502251500014044 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Export_Download { public static function execute( $params ) { // Set progress Ai1wm_Status::info( __( 'Renaming exported file...', AI1WM_PLUGIN_NAME ) ); // Open the archive file for writing $archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ) ); // Append EOF block $archive->close( true ); // Rename archive file if ( rename( ai1wm_archive_path( $params ), ai1wm_backup_path( $params ) ) ) { $blog_id = null; // Get subsite Blog ID if ( isset( $params['options']['sites'] ) && ( $sites = $params['options']['sites'] ) ) { if ( count( $sites ) === 1 ) { $blog_id = array_shift( $sites ); } } // Set archive details $link = ai1wm_backup_url( $params ); $size = ai1wm_backup_size( $params ); $name = ai1wm_site_name( $blog_id ); // Set progress Ai1wm_Status::download( sprintf( __( '' . 'Download %s' . 'Size: %s' . '', AI1WM_PLUGIN_NAME ), $link, $name, $size ) ); } return $params; } } export/class-ai1wm-export-init.php000064400000004531150502251500013175 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Export_Init { public static function execute( $params ) { $blog_id = null; // Get subsite Blog ID if ( isset( $params['options']['sites'] ) && ( $sites = $params['options']['sites'] ) ) { if ( count( $sites ) === 1 ) { $blog_id = array_shift( $sites ); } } // Set archive if ( empty( $params['archive'] ) ) { $params['archive'] = ai1wm_archive_file( $blog_id ); } // Set storage if ( empty( $params['storage'] ) ) { $params['storage'] = ai1wm_storage_folder(); } return $params; } } export/class-ai1wm-export-archive.php000064400000004343150502251500013654 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Export_Archive { public static function execute( $params ) { // Set progress Ai1wm_Status::info( __( 'Creating an empty archive...', AI1WM_PLUGIN_NAME ) ); // Create empty archive file $archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ) ); $archive->close(); // Set progress Ai1wm_Status::info( __( 'Done creating an empty archive.', AI1WM_PLUGIN_NAME ) ); return $params; } } export/class-ai1wm-export-compatibility.php000064400000004506150502251500015105 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Export_Compatibility { public static function execute( $params ) { // Set progress Ai1wm_Status::info( __( 'Checking extensions compatibility...', AI1WM_PLUGIN_NAME ) ); // Get messages $messages = Ai1wm_Compatibility::get( $params ); // Set messages if ( empty( $messages ) ) { return $params; } // Enable notifications add_filter( 'ai1wm_notification_error_toggle', '__return_true', 20 ); // Error message throw new Ai1wm_Compatibility_Exception( implode( $messages ) ); } } class-ai1wm-compatibility.php000064400000006013150502251500012240 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Compatibility { public static function get( $params ) { $extensions = Ai1wm_Extensions::get(); foreach ( $extensions as $extension_name => $extension_data ) { if ( ! isset( $params[ $extension_data['short'] ] ) ) { unset( $extensions[ $extension_name ] ); } } // Get updater URL $updater_url = add_query_arg( array( 'ai1wm_updater' => 1 ), network_admin_url( 'plugins.php' ) ); // If no extension is used, update everything that is available if ( empty( $extensions ) ) { $extensions = Ai1wm_Extensions::get(); } $messages = array(); foreach ( $extensions as $extension_name => $extension_data ) { if ( ! Ai1wm_Compatibility::check( $extension_data ) ) { $messages[] = sprintf( __( '%s is not the latest version. ' . 'You must update the plugin before you can use it.
', AI1WM_PLUGIN_NAME ), $extension_data['title'], $updater_url ); } } return $messages; } public static function check( $extension ) { if ( $extension['version'] !== 'develop' ) { if ( version_compare( $extension['version'], $extension['requires'], '<' ) ) { return false; } } return true; } } class-ai1wm-deprecated.php000064400000003620150502251500011470 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Export_Abstract {} class Ai1wm_Import_Abstract {} class Ai1wm_Config {} class-ai1wm-message.php000064400000005130150502251500011012 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Message { public static function flash( $type, $message ) { if ( ( $messages = get_option( AI1WM_MESSAGES, array() ) ) !== false ) { return update_option( AI1WM_MESSAGES, array_merge( $messages, array( $type => $message ) ) ); } return false; } public static function has( $type ) { if ( ( $messages = get_option( AI1WM_MESSAGES, array() ) ) ) { if ( isset( $messages[ $type ] ) ) { return true; } } return false; } public static function get( $type ) { $message = null; if ( ( $messages = get_option( AI1WM_MESSAGES, array() ) ) ) { if ( isset( $messages[ $type ] ) && ( $message = $messages[ $type ] ) ) { unset( $messages[ $type ] ); } // Set messages update_option( AI1WM_MESSAGES, $messages ); } return $message; } } class-ai1wm-report.php000064400000005555150502251500010714 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Report { /** * Submit customer report to servmask.com * * @param string $email User e-mail * @param string $message User message * @param integer $terms User accept terms * * @return array */ public function add( $email, $message, $terms ) { $errors = array(); // Submit report to ServMask if ( ! filter_var( $email, FILTER_VALIDATE_EMAIL ) ) { $errors[] = __( 'Your email is not valid.', AI1WM_PLUGIN_NAME ); } elseif ( empty( $message ) ) { $errors[] = __( 'Please enter comments in the text area.', AI1WM_PLUGIN_NAME ); } elseif ( empty( $terms ) ) { $errors[] = __( 'Please accept report term conditions.', AI1WM_PLUGIN_NAME ); } else { $response = wp_remote_post( AI1WM_REPORT_URL, array( 'timeout' => 15, 'body' => array( 'email' => $email, 'message' => $message, ), ) ); if ( is_wp_error( $response ) ) { $errors[] = sprintf( __( 'Something went wrong: %s', AI1WM_PLUGIN_NAME ), $response->get_error_message() ); } } return $errors; } } class-ai1wm-feedback.php000064400000006052150502251500011116 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Feedback { /** * Submit customer feedback to servmask.com * * @param string $type Feedback type * @param string $email User e-mail * @param string $message User message * @param integer $terms User accept terms * * @return array */ public function add( $type, $email, $message, $terms ) { $errors = array(); // Submit feedback to ServMask if ( empty( $type ) ) { $errors[] = __( 'Feedback type is not valid.', AI1WM_PLUGIN_NAME ); } elseif ( ! filter_var( $email, FILTER_VALIDATE_EMAIL ) ) { $errors[] = __( 'Your email is not valid.', AI1WM_PLUGIN_NAME ); } elseif ( empty( $message ) ) { $errors[] = __( 'Please enter comments in the text area.', AI1WM_PLUGIN_NAME ); } elseif ( empty( $terms ) ) { $errors[] = __( 'Please accept feedback term conditions.', AI1WM_PLUGIN_NAME ); } else { $response = wp_remote_post( AI1WM_FEEDBACK_URL, array( 'timeout' => 15, 'body' => array( 'type' => $type, 'email' => $email, 'message' => $message, ), ) ); if ( is_wp_error( $response ) ) { $errors[] = sprintf( __( 'Something went wrong: %s', AI1WM_PLUGIN_NAME ), $response->get_error_message() ); } } return $errors; } } import/class-ai1wm-import-enumerate.php000064400000004744150502251500014207 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Import_Enumerate { public static function execute( $params ) { // Set progress Ai1wm_Status::info( __( 'Retrieving a list of all WordPress files...', AI1WM_PLUGIN_NAME ) ); // Open the archive file for reading $archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ) ); // Get total files count $params['total_files_count'] = $archive->get_total_files_count(); // Get total files size $params['total_files_size'] = $archive->get_total_files_size(); // Close the archive file $archive->close(); // Set progress Ai1wm_Status::info( __( 'Done retrieving a list of all WordPress files.', AI1WM_PLUGIN_NAME ) ); return $params; } } import/class-ai1wm-import-upload.php000064400000010022150502251500013470 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Import_Upload { private static function validate() { if ( ! array_key_exists( 'upload-file', $_FILES ) || ! is_array( $_FILES['upload-file'] ) ) { throw new Ai1wm_Import_Retry_Exception( __( 'Missing upload file.', AI1WM_PLUGIN_NAME ), 400 ); } if ( ! array_key_exists( 'error', $_FILES['upload-file'] ) ) { throw new Ai1wm_Import_Retry_Exception( __( 'Missing error key in upload file.', AI1WM_PLUGIN_NAME ), 400 ); } if ( ! array_key_exists( 'tmp_name', $_FILES['upload-file'] ) ) { throw new Ai1wm_Import_Retry_Exception( __( 'Missing tmp_name in upload file.', AI1WM_PLUGIN_NAME ), 400 ); } } public static function execute( $params ) { self::validate(); $error = $_FILES['upload-file']['error']; $upload = $_FILES['upload-file']['tmp_name']; $archive = ai1wm_archive_path( $params ); switch ( $error ) { case UPLOAD_ERR_OK: try { ai1wm_copy( $upload, $archive ); ai1wm_unlink( $upload ); } catch ( Exception $e ) { throw new Ai1wm_Import_Retry_Exception( sprintf( __( 'Unable to upload the file because %s', AI1WM_PLUGIN_NAME ), $e->getMessage() ), 400 ); } break; case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: case UPLOAD_ERR_PARTIAL: case UPLOAD_ERR_NO_FILE: // File is too large, reduce the size and try again throw new Ai1wm_Import_Retry_Exception( __( 'The file is too large, retrying with smaller size.', AI1WM_PLUGIN_NAME ), 413 ); case UPLOAD_ERR_NO_TMP_DIR: throw new Ai1wm_Import_Retry_Exception( __( 'Missing a temporary folder.', AI1WM_PLUGIN_NAME ), 400 ); case UPLOAD_ERR_CANT_WRITE: throw new Ai1wm_Import_Retry_Exception( __( 'Failed to write file to disk.', AI1WM_PLUGIN_NAME ), 400 ); case UPLOAD_ERR_EXTENSION: throw new Ai1wm_Import_Retry_Exception( __( 'A PHP extension stopped the file upload.', AI1WM_PLUGIN_NAME ), 400 ); default: throw new Ai1wm_Import_Retry_Exception( sprintf( __( 'Unrecognized error %s during upload.', AI1WM_PLUGIN_NAME ), $error ), 400 ); } echo json_encode( array( 'errors' => array() ) ); exit; } } import/class-ai1wm-import-done.php000064400000020307150502251500013140 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Import_Done { public static function execute( $params ) { // Check multisite.json file if ( true === is_file( ai1wm_multisite_path( $params ) ) ) { // Read multisite.json file $handle = ai1wm_open( ai1wm_multisite_path( $params ), 'r' ); // Parse multisite.json file $multisite = ai1wm_read( $handle, filesize( ai1wm_multisite_path( $params ) ) ); $multisite = json_decode( $multisite, true ); // Close handle ai1wm_close( $handle ); // Activate WordPress plugins if ( isset( $multisite['Plugins'] ) && ( $plugins = $multisite['Plugins'] ) ) { ai1wm_activate_plugins( $plugins ); } // Deactivate WordPress SSL plugins if ( ! is_ssl() ) { ai1wm_deactivate_plugins( array( ai1wm_discover_plugin_basename( 'really-simple-ssl/rlrsssl-really-simple-ssl.php' ), ai1wm_discover_plugin_basename( 'wordpress-https/wordpress-https.php' ), ai1wm_discover_plugin_basename( 'wp-force-ssl/wp-force-ssl.php' ), ) ); } // Deactivate WordPress plugins ai1wm_deactivate_plugins( array( ai1wm_discover_plugin_basename( 'invisible-recaptcha/invisible-recaptcha.php' ), ai1wm_discover_plugin_basename( 'wps-hide-login/wps-hide-login.php' ), ai1wm_discover_plugin_basename( 'hide-my-wp/index.php' ), ai1wm_discover_plugin_basename( 'hide-my-wordpress/index.php' ), ai1wm_discover_plugin_basename( 'mycustomwidget/my_custom_widget.php' ), ai1wm_discover_plugin_basename( 'lockdown-wp-admin/lockdown-wp-admin.php' ), ai1wm_discover_plugin_basename( 'rename-wp-login/rename-wp-login.php' ), ) ); // Deactivate Jetpack modules ai1wm_deactivate_jetpack_modules( array( 'photon', 'sso', ) ); } else { // Check package.json file if ( true === is_file( ai1wm_package_path( $params ) ) ) { // Read package.json file $handle = ai1wm_open( ai1wm_package_path( $params ), 'r' ); // Parse package.json file $package = ai1wm_read( $handle, filesize( ai1wm_package_path( $params ) ) ); $package = json_decode( $package, true ); // Close handle ai1wm_close( $handle ); // Activate WordPress plugins if ( isset( $package['Plugins'] ) && ( $plugins = $package['Plugins'] ) ) { ai1wm_activate_plugins( $plugins ); } // Activate WordPress template if ( isset( $package['Template'] ) && ( $template = $package['Template'] ) ) { ai1wm_activate_template( $template ); } // Activate WordPress stylesheet if ( isset( $package['Stylesheet'] ) && ( $stylesheet = $package['Stylesheet'] ) ) { ai1wm_activate_stylesheet( $stylesheet ); } // Deactivate WordPress SSL plugins if ( ! is_ssl() ) { ai1wm_deactivate_plugins( array( ai1wm_discover_plugin_basename( 'really-simple-ssl/rlrsssl-really-simple-ssl.php' ), ai1wm_discover_plugin_basename( 'wordpress-https/wordpress-https.php' ), ai1wm_discover_plugin_basename( 'wp-force-ssl/wp-force-ssl.php' ), ) ); } // Deactivate WordPress plugins ai1wm_deactivate_plugins( array( ai1wm_discover_plugin_basename( 'invisible-recaptcha/invisible-recaptcha.php' ), ai1wm_discover_plugin_basename( 'wps-hide-login/wps-hide-login.php' ), ai1wm_discover_plugin_basename( 'hide-my-wp/index.php' ), ai1wm_discover_plugin_basename( 'hide-my-wordpress/index.php' ), ai1wm_discover_plugin_basename( 'mycustomwidget/my_custom_widget.php' ), ai1wm_discover_plugin_basename( 'lockdown-wp-admin/lockdown-wp-admin.php' ), ai1wm_discover_plugin_basename( 'rename-wp-login/rename-wp-login.php' ), ) ); // Deactivate Jetpack modules ai1wm_deactivate_jetpack_modules( array( 'photon', 'sso', ) ); } } // Check blogs.json file if ( true === is_file( ai1wm_blogs_path( $params ) ) ) { // Read blogs.json file $handle = ai1wm_open( ai1wm_blogs_path( $params ), 'r' ); // Parse blogs.json file $blogs = ai1wm_read( $handle, filesize( ai1wm_blogs_path( $params ) ) ); $blogs = json_decode( $blogs, true ); // Close handle ai1wm_close( $handle ); // Loop over blogs foreach ( $blogs as $blog ) { // Activate WordPress plugins if ( isset( $blog['New']['Plugins'] ) && ( $plugins = $blog['New']['Plugins'] ) ) { ai1wm_activate_plugins( $plugins ); } // Activate WordPress template if ( isset( $blog['New']['Template'] ) && ( $template = $blog['New']['Template'] ) ) { ai1wm_activate_template( $template ); } // Activate WordPress stylesheet if ( isset( $blog['New']['Stylesheet'] ) && ( $stylesheet = $blog['New']['Stylesheet'] ) ) { ai1wm_activate_stylesheet( $stylesheet ); } // Deactivate WordPress SSL plugins if ( ! is_ssl() ) { ai1wm_deactivate_plugins( array( ai1wm_discover_plugin_basename( 'really-simple-ssl/rlrsssl-really-simple-ssl.php' ), ai1wm_discover_plugin_basename( 'wordpress-https/wordpress-https.php' ), ai1wm_discover_plugin_basename( 'wp-force-ssl/wp-force-ssl.php' ), ) ); } // Deactivate WordPress plugins ai1wm_deactivate_plugins( array( ai1wm_discover_plugin_basename( 'invisible-recaptcha/invisible-recaptcha.php' ), ai1wm_discover_plugin_basename( 'wps-hide-login/wps-hide-login.php' ), ai1wm_discover_plugin_basename( 'hide-my-wp/index.php' ), ai1wm_discover_plugin_basename( 'hide-my-wordpress/index.php' ), ai1wm_discover_plugin_basename( 'mycustomwidget/my_custom_widget.php' ), ai1wm_discover_plugin_basename( 'lockdown-wp-admin/lockdown-wp-admin.php' ), ai1wm_discover_plugin_basename( 'rename-wp-login/rename-wp-login.php' ), ) ); // Deactivate Jetpack modules ai1wm_deactivate_jetpack_modules( array( 'photon', 'sso', ) ); } } // Set progress Ai1wm_Status::done( __( 'Your data has been imported successfully!', AI1WM_PLUGIN_NAME ), sprintf( __( 'You need to perform two more steps:
' . '1. You must save your permalinks structure twice. Permalinks Settings (opens a new window)
' . '2. Optionally, review the plugin. (opens a new window)', AI1WM_PLUGIN_NAME ), admin_url( 'options-permalink.php#submit' ) ) ); return $params; } } import/class-ai1wm-import-clean.php000064400000003716150502251500013302 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Import_Clean { public static function execute( $params ) { Ai1wm_Directory::delete( ai1wm_storage_path( $params ) ); exit; } } import/class-ai1wm-import-content.php000064400000017275150502251500013677 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Import_Content { public static function execute( $params ) { // Set archive bytes offset if ( isset( $params['archive_bytes_offset'] ) ) { $archive_bytes_offset = (int) $params['archive_bytes_offset']; } else { $archive_bytes_offset = 0; } // Set file bytes offset if ( isset( $params['file_bytes_offset'] ) ) { $file_bytes_offset = (int) $params['file_bytes_offset']; } else { $file_bytes_offset = 0; } // Get processed files size if ( isset( $params['processed_files_size'] ) ) { $processed_files_size = (int) $params['processed_files_size']; } else { $processed_files_size = 0; } // Get total files size if ( isset( $params['total_files_size'] ) ) { $total_files_size = (int) $params['total_files_size']; } else { $total_files_size = 1; } // Get total files count if ( isset( $params['total_files_count'] ) ) { $total_files_count = (int) $params['total_files_count']; } else { $total_files_count = 1; } // Read blogs.json file $handle = ai1wm_open( ai1wm_blogs_path( $params ), 'r' ); // Parse blogs.json file $blogs = ai1wm_read( $handle, filesize( ai1wm_blogs_path( $params ) ) ); $blogs = json_decode( $blogs, true ); // Close handle ai1wm_close( $handle ); // What percent of files have we processed? $progress = (int) min( ( $processed_files_size / $total_files_size ) * 100, 100 ); // Set progress Ai1wm_Status::info( sprintf( __( 'Restoring %d files...
%d%% complete', AI1WM_PLUGIN_NAME ), $total_files_count, $progress ) ); // Flag to hold if file data has been processed $completed = true; // Start time $start = microtime( true ); // Open the archive file for reading $archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ) ); // Set the file pointer to the one that we have saved $archive->set_file_pointer( $archive_bytes_offset ); $old_paths = array(); $new_paths = array(); // Set extract paths foreach ( $blogs as $blog ) { if ( ai1wm_main_site( $blog['Old']['BlogID'] ) === false ) { if ( defined( 'UPLOADBLOGSDIR' ) ) { // Old sites dir style $old_paths[] = ai1wm_files_path( $blog['Old']['BlogID'] ); $new_paths[] = ai1wm_files_path( $blog['New']['BlogID'] ); // New sites dir style $old_paths[] = ai1wm_sites_path( $blog['Old']['BlogID'] ); $new_paths[] = ai1wm_files_path( $blog['New']['BlogID'] ); } else { // Old sites dir style $old_paths[] = ai1wm_files_path( $blog['Old']['BlogID'] ); $new_paths[] = ai1wm_sites_path( $blog['New']['BlogID'] ); // New sites dir style $old_paths[] = ai1wm_sites_path( $blog['Old']['BlogID'] ); $new_paths[] = ai1wm_sites_path( $blog['New']['BlogID'] ); } } } // Set base site extract paths (should be added at the end of arrays) foreach ( $blogs as $blog ) { if ( ai1wm_main_site( $blog['Old']['BlogID'] ) === true ) { if ( defined( 'UPLOADBLOGSDIR' ) ) { // Old sites dir style $old_paths[] = ai1wm_files_path( $blog['Old']['BlogID'] ); $new_paths[] = ai1wm_files_path( $blog['New']['BlogID'] ); // New sites dir style $old_paths[] = ai1wm_sites_path( $blog['Old']['BlogID'] ); $new_paths[] = ai1wm_files_path( $blog['New']['BlogID'] ); } else { // Old sites dir style $old_paths[] = ai1wm_files_path( $blog['Old']['BlogID'] ); $new_paths[] = ai1wm_sites_path( $blog['New']['BlogID'] ); // New sites dir style $old_paths[] = ai1wm_sites_path( $blog['Old']['BlogID'] ); $new_paths[] = ai1wm_sites_path( $blog['New']['BlogID'] ); } } } while ( $archive->has_not_reached_eof() ) { $file_bytes_written = 0; // Exclude WordPress files $exclude_files = array_keys( _get_dropins() ); // Exclude plugin files $exclude_files = array_merge( $exclude_files, array( AI1WM_PACKAGE_NAME, AI1WM_MULTISITE_NAME, AI1WM_DATABASE_NAME, AI1WM_MUPLUGINS_NAME, ) ); // Extract a file from archive to WP_CONTENT_DIR if ( ( $completed = $archive->extract_one_file_to( WP_CONTENT_DIR, $exclude_files, $old_paths, $new_paths, $file_bytes_written, $file_bytes_offset ) ) ) { $file_bytes_offset = 0; } // Get archive bytes offset $archive_bytes_offset = $archive->get_file_pointer(); // Increment processed files size $processed_files_size += $file_bytes_written; // What percent of files have we processed? $progress = (int) min( ( $processed_files_size / $total_files_size ) * 100, 100 ); // Set progress Ai1wm_Status::info( sprintf( __( 'Restoring %d files...
%d%% complete', AI1WM_PLUGIN_NAME ), $total_files_count, $progress ) ); // More than 10 seconds have passed, break and do another request if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) { if ( ( microtime( true ) - $start ) > $timeout ) { $completed = false; break; } } } // End of the archive? if ( $archive->has_reached_eof() ) { // Unset archive bytes offset unset( $params['archive_bytes_offset'] ); // Unset file bytes offset unset( $params['file_bytes_offset'] ); // Unset processed files size unset( $params['processed_files_size'] ); // Unset total files size unset( $params['total_files_size'] ); // Unset total files count unset( $params['total_files_count'] ); // Unset completed flag unset( $params['completed'] ); } else { // Set archive bytes offset $params['archive_bytes_offset'] = $archive_bytes_offset; // Set file bytes offset $params['file_bytes_offset'] = $file_bytes_offset; // Set processed files size $params['processed_files_size'] = $processed_files_size; // Set total files size $params['total_files_size'] = $total_files_size; // Set total files count $params['total_files_count'] = $total_files_count; // Set completed flag $params['completed'] = $completed; } // Close the archive file $archive->close(); return $params; } } import/class-ai1wm-import-confirm.php000064400000006113150502251500013647 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Import_Confirm { public static function execute( $params ) { $messages = array(); // Read package.json file $handle = ai1wm_open( ai1wm_package_path( $params ), 'r' ); // Parse package.json file $package = ai1wm_read( $handle, filesize( ai1wm_package_path( $params ) ) ); $package = json_decode( $package, true ); // Close handle ai1wm_close( $handle ); // Set message $messages[] = __( 'The import process will overwrite your website including the database, media, plugins, and themes. ' . 'Please ensure that you have a backup of your data before proceeding to the next step.', AI1WM_PLUGIN_NAME ); // Check compatibility of PHP versions if ( isset( $package['PHP']['Version'] ) ) { if ( version_compare( $package['PHP']['Version'], '7.0.0', '<' ) && version_compare( PHP_VERSION, '7.0.0', '>=' ) ) { $messages[] = __( 'Your backup is from a PHP 5 but the site that you are importing to is PHP 7. ' . 'This could cause the import to fail. Technical details', AI1WM_PLUGIN_NAME ); } } // Set progress Ai1wm_Status::confirm( implode( $messages ) ); exit; } } import/class-ai1wm-import-database.php000064400000102405150502251500013757 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Import_Database { public static function execute( $params ) { global $wpdb; // Skip database import if ( ! is_file( ai1wm_database_path( $params ) ) ) { return $params; } // Set query offset if ( isset( $params['query_offset'] ) ) { $query_offset = (int) $params['query_offset']; } else { $query_offset = 0; } // Set total queries size if ( isset( $params['total_queries_size'] ) ) { $total_queries_size = (int) $params['total_queries_size']; } else { $total_queries_size = 1; } // Read blogs.json file $handle = ai1wm_open( ai1wm_blogs_path( $params ), 'r' ); // Parse blogs.json file $blogs = ai1wm_read( $handle, filesize( ai1wm_blogs_path( $params ) ) ); $blogs = json_decode( $blogs, true ); // Close handle ai1wm_close( $handle ); // Read package.json file $handle = ai1wm_open( ai1wm_package_path( $params ), 'r' ); // Parse package.json file $config = ai1wm_read( $handle, filesize( ai1wm_package_path( $params ) ) ); $config = json_decode( $config, true ); // Close handle ai1wm_close( $handle ); // What percent of queries have we processed? $progress = (int) ( ( $query_offset / $total_queries_size ) * 100 ); // Set progress Ai1wm_Status::info( sprintf( __( 'Restoring database...
%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) ); $old_replace_values = $old_replace_raw_values = array(); $new_replace_values = $new_replace_raw_values = array(); // Get Blog URLs foreach ( $blogs as $blog ) { $home_urls = array(); // Add Home URL if ( ! empty( $blog['Old']['HomeURL'] ) ) { $home_urls[] = $blog['Old']['HomeURL']; } // Add Internal Home URL if ( ! empty( $blog['Old']['InternalHomeURL'] ) ) { if ( parse_url( $blog['Old']['InternalHomeURL'], PHP_URL_SCHEME ) && parse_url( $blog['Old']['InternalHomeURL'], PHP_URL_HOST ) ) { $home_urls[] = $blog['Old']['InternalHomeURL']; } } // Get Home URL foreach ( $home_urls as $home_url ) { // Get blogs dir Upload Path if ( ! in_array( sprintf( "'%s'", trim( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' ) ), $old_replace_raw_values ) ) { $old_replace_raw_values[] = sprintf( "'%s'", trim( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' ) ); $new_replace_raw_values[] = sprintf( "'%s'", get_option( 'upload_path' ) ); } // Get sites dir Upload Path if ( ! in_array( sprintf( "'%s'", trim( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' ) ), $old_replace_raw_values ) ) { $old_replace_raw_values[] = sprintf( "'%s'", trim( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' ) ); $new_replace_raw_values[] = sprintf( "'%s'", get_option( 'upload_path' ) ); } // Handle old and new sites dir style if ( defined( 'UPLOADBLOGSDIR' ) ) { // Get plain Upload Path if ( ! in_array( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), $old_replace_values ) ) { $old_replace_values[] = ai1wm_blogsdir_path( $blog['Old']['BlogID'] ); $new_replace_values[] = ai1wm_blogsdir_path( $blog['New']['BlogID'] ); } // Get URL encoded Upload Path if ( ! in_array( urlencode( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ) ), $old_replace_values ) ) { $old_replace_values[] = urlencode( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ) ); $new_replace_values[] = urlencode( ai1wm_blogsdir_path( $blog['New']['BlogID'] ) ); } // Get URL raw encoded Upload Path if ( ! in_array( rawurlencode( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ) ), $old_replace_values ) ) { $old_replace_values[] = rawurlencode( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ) ); $new_replace_values[] = rawurlencode( ai1wm_blogsdir_path( $blog['New']['BlogID'] ) ); } // Get JSON escaped Upload Path if ( ! in_array( addcslashes( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' ), $old_replace_values ) ) { $old_replace_values[] = addcslashes( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' ); $new_replace_values[] = addcslashes( ai1wm_blogsdir_path( $blog['New']['BlogID'] ), '/' ); } // Get plain Upload Path if ( ! in_array( ai1wm_uploads_path( $blog['Old']['BlogID'] ), $old_replace_values ) ) { $old_replace_values[] = ai1wm_uploads_path( $blog['Old']['BlogID'] ); $new_replace_values[] = ai1wm_blogsdir_path( $blog['New']['BlogID'] ); } // Get URL encoded Upload Path if ( ! in_array( urlencode( ai1wm_uploads_path( $blog['Old']['BlogID'] ) ), $old_replace_values ) ) { $old_replace_values[] = urlencode( ai1wm_uploads_path( $blog['Old']['BlogID'] ) ); $new_replace_values[] = urlencode( ai1wm_blogsdir_path( $blog['New']['BlogID'] ) ); } // Get URL raw encoded Upload Path if ( ! in_array( rawurlencode( ai1wm_uploads_path( $blog['Old']['BlogID'] ) ), $old_replace_values ) ) { $old_replace_values[] = rawurlencode( ai1wm_uploads_path( $blog['Old']['BlogID'] ) ); $new_replace_values[] = rawurlencode( ai1wm_blogsdir_path( $blog['New']['BlogID'] ) ); } // Get JSON escaped Upload Path if ( ! in_array( addcslashes( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' ), $old_replace_values ) ) { $old_replace_values[] = addcslashes( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' ); $new_replace_values[] = addcslashes( ai1wm_blogsdir_path( $blog['New']['BlogID'] ), '/' ); } } else { // Get files dir Upload URL if ( ! in_array( sprintf( '%s/%s/', untrailingslashit( $home_url ), 'files' ), $old_replace_values ) ) { $old_replace_values[] = sprintf( '%s/%s/', untrailingslashit( $home_url ), 'files' ); $new_replace_values[] = ai1wm_uploads_url( $blog['New']['BlogID'] ); } // Get plain Upload Path if ( ! in_array( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), $old_replace_values ) ) { $old_replace_values[] = ai1wm_blogsdir_path( $blog['Old']['BlogID'] ); $new_replace_values[] = ai1wm_uploads_path( $blog['New']['BlogID'] ); } // Get URL encoded Upload Path if ( ! in_array( urlencode( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ) ), $old_replace_values ) ) { $old_replace_values[] = urlencode( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ) ); $new_replace_values[] = urlencode( ai1wm_uploads_path( $blog['New']['BlogID'] ) ); } // Get URL raw encoded Upload Path if ( ! in_array( rawurlencode( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ) ), $old_replace_values ) ) { $old_replace_values[] = rawurlencode( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ) ); $new_replace_values[] = rawurlencode( ai1wm_uploads_path( $blog['New']['BlogID'] ) ); } // Get JSON escaped Upload Path if ( ! in_array( addcslashes( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' ), $old_replace_values ) ) { $old_replace_values[] = addcslashes( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' ); $new_replace_values[] = addcslashes( ai1wm_uploads_path( $blog['New']['BlogID'] ), '/' ); } // Get plain Upload Path if ( ! in_array( ai1wm_uploads_path( $blog['Old']['BlogID'] ), $old_replace_values ) ) { $old_replace_values[] = ai1wm_uploads_path( $blog['Old']['BlogID'] ); $new_replace_values[] = ai1wm_uploads_path( $blog['New']['BlogID'] ); } // Get URL encoded Upload Path if ( ! in_array( urlencode( ai1wm_uploads_path( $blog['Old']['BlogID'] ) ), $old_replace_values ) ) { $old_replace_values[] = urlencode( ai1wm_uploads_path( $blog['Old']['BlogID'] ) ); $new_replace_values[] = urlencode( ai1wm_uploads_path( $blog['New']['BlogID'] ) ); } // Get URL raw encoded Upload Path if ( ! in_array( rawurlencode( ai1wm_uploads_path( $blog['Old']['BlogID'] ) ), $old_replace_values ) ) { $old_replace_values[] = rawurlencode( ai1wm_uploads_path( $blog['Old']['BlogID'] ) ); $new_replace_values[] = rawurlencode( ai1wm_uploads_path( $blog['New']['BlogID'] ) ); } // Get JSON escaped Upload Path if ( ! in_array( addcslashes( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' ), $old_replace_values ) ) { $old_replace_values[] = addcslashes( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' ); $new_replace_values[] = addcslashes( ai1wm_uploads_path( $blog['New']['BlogID'] ), '/' ); } } } $site_urls = array(); // Add Site URL if ( ! empty( $blog['Old']['SiteURL'] ) ) { $site_urls[] = $blog['Old']['SiteURL']; } // Add Internal Site URL if ( ! empty( $blog['Old']['InternalSiteURL'] ) ) { if ( parse_url( $blog['Old']['InternalSiteURL'], PHP_URL_SCHEME ) && parse_url( $blog['Old']['InternalSiteURL'], PHP_URL_HOST ) ) { $site_urls[] = $blog['Old']['InternalSiteURL']; } } // Get Site URL foreach ( $site_urls as $site_url ) { // Replace Site URL if ( $site_url !== $blog['New']['SiteURL'] ) { // Get www URL if ( stripos( $site_url, '//www.' ) !== false ) { $site_url_www_inversion = str_ireplace( '//www.', '//', $site_url ); } else { $site_url_www_inversion = str_ireplace( '//', '//www.', $site_url ); } // Replace Site URL foreach ( array( $site_url, $site_url_www_inversion ) as $url ) { // Get domain $old_domain = parse_url( $url, PHP_URL_HOST ); $new_domain = parse_url( $blog['New']['SiteURL'], PHP_URL_HOST ); // Get path $old_path = parse_url( $url, PHP_URL_PATH ); $new_path = parse_url( $blog['New']['SiteURL'], PHP_URL_PATH ); // Get scheme $new_scheme = parse_url( $blog['New']['SiteURL'], PHP_URL_SCHEME ); // Add domain and path if ( ! in_array( sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) ), $old_replace_raw_values ) ) { $old_replace_raw_values[] = sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) ); $new_replace_raw_values[] = sprintf( "'%s','%s'", $new_domain, trailingslashit( $new_path ) ); } // Add domain and path with single quote if ( ! in_array( sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) ), $old_replace_values ) ) { $old_replace_values[] = sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) ); $new_replace_values[] = sprintf( "='%s%s", $new_domain, untrailingslashit( $new_path ) ); } // Add domain and path with double quote if ( ! in_array( sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) ), $old_replace_values ) ) { $old_replace_values[] = sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) ); $new_replace_values[] = sprintf( '="%s%s', $new_domain, untrailingslashit( $new_path ) ); } // Add Site URL scheme $old_schemes = array( 'http', 'https', '' ); $new_schemes = array( $new_scheme, $new_scheme, '' ); // Replace Site URL scheme for ( $i = 0; $i < count( $old_schemes ); $i++ ) { // Add plain Site URL if ( ! in_array( ai1wm_url_scheme( $url, $old_schemes[ $i ] ), $old_replace_values ) ) { $old_replace_values[] = ai1wm_url_scheme( $url, $old_schemes[ $i ] ); $new_replace_values[] = ai1wm_url_scheme( $blog['New']['SiteURL'], $new_schemes[ $i ] ); } // Add URL encoded Site URL if ( ! in_array( urlencode( ai1wm_url_scheme( $url, $old_schemes[ $i ] ) ), $old_replace_values ) ) { $old_replace_values[] = urlencode( ai1wm_url_scheme( $url, $old_schemes[ $i ] ) ); $new_replace_values[] = urlencode( ai1wm_url_scheme( $blog['New']['SiteURL'], $new_schemes[ $i ] ) ); } // Add URL raw encoded Site URL if ( ! in_array( rawurlencode( ai1wm_url_scheme( $url, $old_schemes[ $i ] ) ), $old_replace_values ) ) { $old_replace_values[] = rawurlencode( ai1wm_url_scheme( $url, $old_schemes[ $i ] ) ); $new_replace_values[] = rawurlencode( ai1wm_url_scheme( $blog['New']['SiteURL'], $new_schemes[ $i ] ) ); } // Add JSON escaped Site URL if ( ! in_array( addcslashes( ai1wm_url_scheme( $url, $old_schemes[ $i ] ), '/' ), $old_replace_values ) ) { $old_replace_values[] = addcslashes( ai1wm_url_scheme( $url, $old_schemes[ $i ] ), '/' ); $new_replace_values[] = addcslashes( ai1wm_url_scheme( $blog['New']['SiteURL'], $new_schemes[ $i ] ), '/' ); } } // Add email if ( ! isset( $config['NoEmailReplace'] ) ) { if ( ! in_array( sprintf( '@%s', $old_domain ), $old_replace_values ) ) { $old_replace_values[] = sprintf( '@%s', $old_domain ); $new_replace_values[] = sprintf( '@%s', $new_domain ); } } } } } $home_urls = array(); // Add Home URL if ( ! empty( $blog['Old']['HomeURL'] ) ) { $home_urls[] = $blog['Old']['HomeURL']; } // Add Internal Home URL if ( ! empty( $blog['Old']['InternalHomeURL'] ) ) { if ( parse_url( $blog['Old']['InternalHomeURL'], PHP_URL_SCHEME ) && parse_url( $blog['Old']['InternalHomeURL'], PHP_URL_HOST ) ) { $home_urls[] = $blog['Old']['InternalHomeURL']; } } // Get Home URL foreach ( $home_urls as $home_url ) { // Replace Home URL if ( $home_url !== $blog['New']['HomeURL'] ) { // Get www URL if ( stripos( $home_url, '//www.' ) !== false ) { $home_url_www_inversion = str_ireplace( '//www.', '//', $home_url ); } else { $home_url_www_inversion = str_ireplace( '//', '//www.', $home_url ); } // Replace Home URL foreach ( array( $home_url, $home_url_www_inversion ) as $url ) { // Get domain $old_domain = parse_url( $url, PHP_URL_HOST ); $new_domain = parse_url( $blog['New']['HomeURL'], PHP_URL_HOST ); // Get path $old_path = parse_url( $url, PHP_URL_PATH ); $new_path = parse_url( $blog['New']['HomeURL'], PHP_URL_PATH ); // Get scheme $new_scheme = parse_url( $blog['New']['HomeURL'], PHP_URL_SCHEME ); // Add domain and path if ( ! in_array( sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) ), $old_replace_raw_values ) ) { $old_replace_raw_values[] = sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) ); $new_replace_raw_values[] = sprintf( "'%s','%s'", $new_domain, trailingslashit( $new_path ) ); } // Add domain and path with single quote if ( ! in_array( sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) ), $old_replace_values ) ) { $old_replace_values[] = sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) ); $new_replace_values[] = sprintf( "='%s%s", $new_domain, untrailingslashit( $new_path ) ); } // Add domain and path with double quote if ( ! in_array( sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) ), $old_replace_values ) ) { $old_replace_values[] = sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) ); $new_replace_values[] = sprintf( '="%s%s', $new_domain, untrailingslashit( $new_path ) ); } // Set Home URL scheme $old_schemes = array( 'http', 'https', '' ); $new_schemes = array( $new_scheme, $new_scheme, '' ); // Replace Home URL scheme for ( $i = 0; $i < count( $old_schemes ); $i++ ) { // Add plain Home URL if ( ! in_array( ai1wm_url_scheme( $url, $old_schemes[ $i ] ), $old_replace_values ) ) { $old_replace_values[] = ai1wm_url_scheme( $url, $old_schemes[ $i ] ); $new_replace_values[] = ai1wm_url_scheme( $blog['New']['HomeURL'], $new_schemes[ $i ] ); } // Add URL encoded Home URL if ( ! in_array( urlencode( ai1wm_url_scheme( $url, $old_schemes[ $i ] ) ), $old_replace_values ) ) { $old_replace_values[] = urlencode( ai1wm_url_scheme( $url, $old_schemes[ $i ] ) ); $new_replace_values[] = urlencode( ai1wm_url_scheme( $blog['New']['HomeURL'], $new_schemes[ $i ] ) ); } // Add URL raw encoded Home URL if ( ! in_array( rawurlencode( ai1wm_url_scheme( $url, $old_schemes[ $i ] ) ), $old_replace_values ) ) { $old_replace_values[] = rawurlencode( ai1wm_url_scheme( $url, $old_schemes[ $i ] ) ); $new_replace_values[] = rawurlencode( ai1wm_url_scheme( $blog['New']['HomeURL'], $new_schemes[ $i ] ) ); } // Add JSON escaped Home URL if ( ! in_array( addcslashes( ai1wm_url_scheme( $url, $old_schemes[ $i ] ), '/' ), $old_replace_values ) ) { $old_replace_values[] = addcslashes( ai1wm_url_scheme( $url, $old_schemes[ $i ] ), '/' ); $new_replace_values[] = addcslashes( ai1wm_url_scheme( $blog['New']['HomeURL'], $new_schemes[ $i ] ), '/' ); } } // Add email if ( ! isset( $config['NoEmailReplace'] ) ) { if ( ! in_array( sprintf( '@%s', $old_domain ), $old_replace_values ) ) { $old_replace_values[] = sprintf( '@%s', $old_domain ); $new_replace_values[] = sprintf( '@%s', $new_domain ); } } } } } } $site_urls = array(); // Add Site URL if ( ! empty( $config['SiteURL'] ) ) { $site_urls[] = $config['SiteURL']; } // Add Internal Site URL if ( ! empty( $config['InternalSiteURL'] ) ) { if ( parse_url( $config['InternalSiteURL'], PHP_URL_SCHEME ) && parse_url( $config['InternalSiteURL'], PHP_URL_HOST ) ) { $site_urls[] = $config['InternalSiteURL']; } } // Get Site URL foreach ( $site_urls as $site_url ) { // Replace Site URL if ( $site_url !== site_url() ) { // Get www URL if ( stripos( $site_url, '//www.' ) !== false ) { $site_url_www_inversion = str_ireplace( '//www.', '//', $site_url ); } else { $site_url_www_inversion = str_ireplace( '//', '//www.', $site_url ); } // Replace Site URL foreach ( array( $site_url, $site_url_www_inversion ) as $url ) { // Get domain $old_domain = parse_url( $url, PHP_URL_HOST ); $new_domain = parse_url( site_url(), PHP_URL_HOST ); // Get path $old_path = parse_url( $url, PHP_URL_PATH ); $new_path = parse_url( site_url(), PHP_URL_PATH ); // Get scheme $new_scheme = parse_url( site_url(), PHP_URL_SCHEME ); // Add domain and path if ( ! in_array( sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) ), $old_replace_raw_values ) ) { $old_replace_raw_values[] = sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) ); $new_replace_raw_values[] = sprintf( "'%s','%s'", $new_domain, trailingslashit( $new_path ) ); } // Add domain and path with single quote if ( ! in_array( sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) ), $old_replace_values ) ) { $old_replace_values[] = sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) ); $new_replace_values[] = sprintf( "='%s%s", $new_domain, untrailingslashit( $new_path ) ); } // Add domain and path with double quote if ( ! in_array( sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) ), $old_replace_values ) ) { $old_replace_values[] = sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) ); $new_replace_values[] = sprintf( '="%s%s', $new_domain, untrailingslashit( $new_path ) ); } // Set Site URL scheme $old_schemes = array( 'http', 'https', '' ); $new_schemes = array( $new_scheme, $new_scheme, '' ); // Replace Site URL scheme for ( $i = 0; $i < count( $old_schemes ); $i++ ) { // Add plain Site URL if ( ! in_array( ai1wm_url_scheme( $url, $old_schemes[ $i ] ), $old_replace_values ) ) { $old_replace_values[] = ai1wm_url_scheme( $url, $old_schemes[ $i ] ); $new_replace_values[] = ai1wm_url_scheme( site_url(), $new_schemes[ $i ] ); } // Add URL encoded Site URL if ( ! in_array( urlencode( ai1wm_url_scheme( $url, $old_schemes[ $i ] ) ), $old_replace_values ) ) { $old_replace_values[] = urlencode( ai1wm_url_scheme( $url, $old_schemes[ $i ] ) ); $new_replace_values[] = urlencode( ai1wm_url_scheme( site_url(), $new_schemes[ $i ] ) ); } // Add URL raw encoded Site URL if ( ! in_array( rawurlencode( ai1wm_url_scheme( $url, $old_schemes[ $i ] ) ), $old_replace_values ) ) { $old_replace_values[] = rawurlencode( ai1wm_url_scheme( $url, $old_schemes[ $i ] ) ); $new_replace_values[] = rawurlencode( ai1wm_url_scheme( site_url(), $new_schemes[ $i ] ) ); } // Add JSON escaped Site URL if ( ! in_array( addcslashes( ai1wm_url_scheme( $url, $old_schemes[ $i ] ), '/' ), $old_replace_values ) ) { $old_replace_values[] = addcslashes( ai1wm_url_scheme( $url, $old_schemes[ $i ] ), '/' ); $new_replace_values[] = addcslashes( ai1wm_url_scheme( site_url(), $new_schemes[ $i ] ), '/' ); } } // Add email if ( ! isset( $config['NoEmailReplace'] ) ) { if ( ! in_array( sprintf( '@%s', $old_domain ), $old_replace_values ) ) { $old_replace_values[] = sprintf( '@%s', $old_domain ); $new_replace_values[] = sprintf( '@%s', $new_domain ); } } } } } $home_urls = array(); // Add Home URL if ( ! empty( $config['HomeURL'] ) ) { $home_urls[] = $config['HomeURL']; } // Add Internal Home URL if ( ! empty( $config['InternalHomeURL'] ) ) { if ( parse_url( $config['InternalHomeURL'], PHP_URL_SCHEME ) && parse_url( $config['InternalHomeURL'], PHP_URL_HOST ) ) { $home_urls[] = $config['InternalHomeURL']; } } // Get Home URL foreach ( $home_urls as $home_url ) { // Replace Home URL if ( $home_url !== home_url() ) { // Get www URL if ( stripos( $home_url, '//www.' ) !== false ) { $home_url_www_inversion = str_ireplace( '//www.', '//', $home_url ); } else { $home_url_www_inversion = str_ireplace( '//', '//www.', $home_url ); } // Replace Home URL foreach ( array( $home_url, $home_url_www_inversion ) as $url ) { // Get domain $old_domain = parse_url( $url, PHP_URL_HOST ); $new_domain = parse_url( home_url(), PHP_URL_HOST ); // Get path $old_path = parse_url( $url, PHP_URL_PATH ); $new_path = parse_url( home_url(), PHP_URL_PATH ); // Get scheme $new_scheme = parse_url( home_url(), PHP_URL_SCHEME ); // Add domain and path if ( ! in_array( sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) ), $old_replace_raw_values ) ) { $old_replace_raw_values[] = sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) ); $new_replace_raw_values[] = sprintf( "'%s','%s'", $new_domain, trailingslashit( $new_path ) ); } // Add domain and path with single quote if ( ! in_array( sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) ), $old_replace_values ) ) { $old_replace_values[] = sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) ); $new_replace_values[] = sprintf( "='%s%s", $new_domain, untrailingslashit( $new_path ) ); } // Add domain and path with double quote if ( ! in_array( sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) ), $old_replace_values ) ) { $old_replace_values[] = sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) ); $new_replace_values[] = sprintf( '="%s%s', $new_domain, untrailingslashit( $new_path ) ); } // Add Home URL scheme $old_schemes = array( 'http', 'https', '' ); $new_schemes = array( $new_scheme, $new_scheme, '' ); // Replace Home URL scheme for ( $i = 0; $i < count( $old_schemes ); $i++ ) { // Add plain Home URL if ( ! in_array( ai1wm_url_scheme( $url, $old_schemes[ $i ] ), $old_replace_values ) ) { $old_replace_values[] = ai1wm_url_scheme( $url, $old_schemes[ $i ] ); $new_replace_values[] = ai1wm_url_scheme( home_url(), $new_schemes[ $i ] ); } // Add URL encoded Home URL if ( ! in_array( urlencode( ai1wm_url_scheme( $url, $old_schemes[ $i ] ) ), $old_replace_values ) ) { $old_replace_values[] = urlencode( ai1wm_url_scheme( $url, $old_schemes[ $i ] ) ); $new_replace_values[] = urlencode( ai1wm_url_scheme( home_url(), $new_schemes[ $i ] ) ); } // Add URL raw encoded Home URL if ( ! in_array( rawurlencode( ai1wm_url_scheme( $url, $old_schemes[ $i ] ) ), $old_replace_values ) ) { $old_replace_values[] = rawurlencode( ai1wm_url_scheme( $url, $old_schemes[ $i ] ) ); $new_replace_values[] = rawurlencode( ai1wm_url_scheme( home_url(), $new_schemes[ $i ] ) ); } // Add JSON escaped Home URL if ( ! in_array( addcslashes( ai1wm_url_scheme( $url, $old_schemes[ $i ] ), '/' ), $old_replace_values ) ) { $old_replace_values[] = addcslashes( ai1wm_url_scheme( $url, $old_schemes[ $i ] ), '/' ); $new_replace_values[] = addcslashes( ai1wm_url_scheme( home_url(), $new_schemes[ $i ] ), '/' ); } } // Add email if ( ! isset( $config['NoEmailReplace'] ) ) { if ( ! in_array( sprintf( '@%s', $old_domain ), $old_replace_values ) ) { $old_replace_values[] = sprintf( '@%s', $old_domain ); $new_replace_values[] = sprintf( '@%s', $new_domain ); } } } } } // Get WordPress Content Dir if ( isset( $config['WordPress']['Content'] ) && ( $content_dir = $config['WordPress']['Content'] ) ) { // Replace WordPress Content Dir if ( $content_dir !== WP_CONTENT_DIR ) { // Add plain WordPress Content if ( ! in_array( $content_dir, $old_replace_values ) ) { $old_replace_values[] = $content_dir; $new_replace_values[] = WP_CONTENT_DIR; } // Add URL encoded WordPress Content if ( ! in_array( urlencode( $content_dir ), $old_replace_values ) ) { $old_replace_values[] = urlencode( $content_dir ); $new_replace_values[] = urlencode( WP_CONTENT_DIR ); } // Add URL raw encoded WordPress Content if ( ! in_array( rawurlencode( $content_dir ), $old_replace_values ) ) { $old_replace_values[] = rawurlencode( $content_dir ); $new_replace_values[] = rawurlencode( WP_CONTENT_DIR ); } // Add JSON escaped WordPress Content if ( ! in_array( addcslashes( $content_dir, '/' ), $old_replace_values ) ) { $old_replace_values[] = addcslashes( $content_dir, '/' ); $new_replace_values[] = addcslashes( WP_CONTENT_DIR, '/' ); } } } // Get replace old and new values if ( isset( $config['Replace'] ) && ( $replace = $config['Replace'] ) ) { for ( $i = 0; $i < count( $replace['OldValues'] ); $i++ ) { if ( ! empty( $replace['OldValues'][ $i ] ) && ! empty( $replace['NewValues'][ $i ] ) ) { // Add plain replace values if ( ! in_array( $replace['OldValues'][ $i ], $old_replace_values ) ) { $old_replace_values[] = $replace['OldValues'][ $i ]; $new_replace_values[] = $replace['NewValues'][ $i ]; } // Add URL encoded replace values if ( ! in_array( urlencode( $replace['OldValues'][ $i ] ), $old_replace_values ) ) { $old_replace_values[] = urlencode( $replace['OldValues'][ $i ] ); $new_replace_values[] = urlencode( $replace['NewValues'][ $i ] ); } // Add URL raw encoded replace values if ( ! in_array( rawurlencode( $replace['OldValues'][ $i ] ), $old_replace_values ) ) { $old_replace_values[] = rawurlencode( $replace['OldValues'][ $i ] ); $new_replace_values[] = rawurlencode( $replace['NewValues'][ $i ] ); } // Add JSON Escaped replace values if ( ! in_array( addcslashes( $replace['OldValues'][ $i ], '/' ), $old_replace_values ) ) { $old_replace_values[] = addcslashes( $replace['OldValues'][ $i ], '/' ); $new_replace_values[] = addcslashes( $replace['NewValues'][ $i ], '/' ); } } } } // Get site URL $site_url = get_option( AI1WM_SITE_URL ); // Get home URL $home_url = get_option( AI1WM_HOME_URL ); // Get secret key $secret_key = get_option( AI1WM_SECRET_KEY ); // Get HTTP user $auth_user = get_option( AI1WM_AUTH_USER ); // Get HTTP password $auth_password = get_option( AI1WM_AUTH_PASSWORD ); $old_table_prefixes = array(); $new_table_prefixes = array(); // Set main table prefixes $old_table_prefixes[] = ai1wm_servmask_prefix( 'mainsite' ); $new_table_prefixes[] = ai1wm_table_prefix(); // Set site table prefixes foreach ( $blogs as $blog ) { if ( ai1wm_main_site( $blog['Old']['BlogID'] ) === false ) { $old_table_prefixes[] = ai1wm_servmask_prefix( $blog['Old']['BlogID'] ); $new_table_prefixes[] = ai1wm_table_prefix( $blog['New']['BlogID'] ); } } // Set base table prefixes foreach ( $blogs as $blog ) { if ( ai1wm_main_site( $blog['Old']['BlogID'] ) === true ) { $old_table_prefixes[] = ai1wm_servmask_prefix( 'basesite' ); $new_table_prefixes[] = ai1wm_table_prefix( $blog['New']['BlogID'] ); } } // Set site table prefixes foreach ( $blogs as $blog ) { if ( ai1wm_main_site( $blog['Old']['BlogID'] ) === true ) { $old_table_prefixes[] = ai1wm_servmask_prefix( $blog['Old']['BlogID'] ); $new_table_prefixes[] = ai1wm_table_prefix( $blog['New']['BlogID'] ); } } // Set table prefixes $old_table_prefixes[] = ai1wm_servmask_prefix(); $new_table_prefixes[] = ai1wm_table_prefix(); // Get database client if ( empty( $wpdb->use_mysqli ) ) { $mysql = new Ai1wm_Database_Mysql( $wpdb ); } else { $mysql = new Ai1wm_Database_Mysqli( $wpdb ); } // Set database options $mysql->set_old_table_prefixes( $old_table_prefixes ) ->set_new_table_prefixes( $new_table_prefixes ) ->set_old_replace_values( $old_replace_values ) ->set_new_replace_values( $new_replace_values ) ->set_old_replace_raw_values( $old_replace_raw_values ) ->set_new_replace_raw_values( $new_replace_raw_values ); // Flush database if ( isset( $config['Plugin']['Version'] ) && ( $version = $config['Plugin']['Version'] ) ) { if ( $version !== 'develop' && version_compare( $version, '4.10', '<' ) ) { $mysql->set_include_table_prefixes( array( ai1wm_table_prefix() ) ); $mysql->flush(); } } // Set atomic tables (do not stop the current request for all listed tables if timeout has been exceeded) $mysql->set_atomic_tables( array( ai1wm_table_prefix() . 'options' ) ); // Set Visual Composer $mysql->set_visual_composer( ai1wm_validate_plugin_basename( 'js_composer/js_composer.php' ) ); // Set BeTheme Responsive $mysql->set_betheme_responsive( ai1wm_validate_theme_basename( 'betheme/style.css' ) ); // Import database if ( $mysql->import( ai1wm_database_path( $params ), $query_offset ) ) { // Set progress Ai1wm_Status::info( __( 'Done restoring database.', AI1WM_PLUGIN_NAME ) ); // Unset query offset unset( $params['query_offset'] ); // Unset total queries size unset( $params['total_queries_size'] ); // Unset completed flag unset( $params['completed'] ); } else { // Get total queries size $total_queries_size = ai1wm_database_bytes( $params ); // What percent of queries have we processed? $progress = (int) ( ( $query_offset / $total_queries_size ) * 100 ); // Set progress Ai1wm_Status::info( sprintf( __( 'Restoring database...
%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) ); // Set query offset $params['query_offset'] = $query_offset; // Set total queries size $params['total_queries_size'] = $total_queries_size; // Set completed flag $params['completed'] = false; } // Flush WP cache ai1wm_cache_flush(); // Activate plugins ai1wm_activate_plugins( ai1wm_active_servmask_plugins() ); // Set the new site URL update_option( AI1WM_SITE_URL, $site_url ); // Set the new home URL update_option( AI1WM_HOME_URL, $home_url ); // Set the new secret key value update_option( AI1WM_SECRET_KEY, $secret_key ); // Set the new HTTP user update_option( AI1WM_AUTH_USER, $auth_user ); // Set the new HTTP password update_option( AI1WM_AUTH_PASSWORD, $auth_password ); return $params; } } import/class-ai1wm-import-blogs.php000064400000012057150502251500013324 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Import_Blogs { public static function execute( $params ) { // Set progress Ai1wm_Status::info( __( 'Preparing blogs...', AI1WM_PLUGIN_NAME ) ); $blogs = array(); // Check multisite.json file if ( true === is_file( ai1wm_multisite_path( $params ) ) ) { // Read multisite.json file $handle = ai1wm_open( ai1wm_multisite_path( $params ), 'r' ); // Parse multisite.json file $multisite = ai1wm_read( $handle, filesize( ai1wm_multisite_path( $params ) ) ); $multisite = json_decode( $multisite, true ); // Close handle ai1wm_close( $handle ); // Validate if ( empty( $multisite['Network'] ) ) { if ( isset( $multisite['Sites'] ) && ( $sites = $multisite['Sites'] ) ) { if ( count( $sites ) === 1 && ( $subsite = current( $sites ) ) ) { // Set internal Site URL (backward compatibility) if ( empty( $subsite['InternalSiteURL'] ) ) { $subsite['InternalSiteURL'] = null; } // Set internal Home URL (backward compatibility) if ( empty( $subsite['InternalHomeURL'] ) ) { $subsite['InternalHomeURL'] = null; } // Set active plugins (backward compatibility) if ( empty( $subsite['Plugins'] ) ) { $subsite['Plugins'] = array(); } // Set active template (backward compatibility) if ( empty( $subsite['Template'] ) ) { $subsite['Template'] = null; } // Set active stylesheet (backward compatibility) if ( empty( $subsite['Stylesheet'] ) ) { $subsite['Stylesheet'] = null; } // Set blog items $blogs[] = array( 'Old' => array( 'BlogID' => $subsite['BlogID'], 'SiteURL' => $subsite['SiteURL'], 'HomeURL' => $subsite['HomeURL'], 'InternalSiteURL' => $subsite['InternalSiteURL'], 'InternalHomeURL' => $subsite['InternalHomeURL'], 'Plugins' => $subsite['Plugins'], 'Template' => $subsite['Template'], 'Stylesheet' => $subsite['Stylesheet'], ), 'New' => array( 'BlogID' => null, 'SiteURL' => site_url(), 'HomeURL' => home_url(), 'InternalSiteURL' => site_url(), 'InternalHomeURL' => home_url(), 'Plugins' => $subsite['Plugins'], 'Template' => $subsite['Template'], 'Stylesheet' => $subsite['Stylesheet'], ), ); } else { throw new Ai1wm_Import_Exception( __( 'The archive should contain Single WordPress site! Please revisit your export settings.', AI1WM_PLUGIN_NAME ) ); } } else { throw new Ai1wm_Import_Exception( __( 'At least one WordPress site should be presented in the archive.', AI1WM_PLUGIN_NAME ) ); } } else { throw new Ai1wm_Import_Exception( __( 'Unable to import WordPress Network into WordPress Single site.', AI1WM_PLUGIN_NAME ) ); } } // Write blogs.json file $handle = ai1wm_open( ai1wm_blogs_path( $params ), 'w' ); ai1wm_write( $handle, json_encode( $blogs ) ); ai1wm_close( $handle ); // Set progress Ai1wm_Status::info( __( 'Done preparing blogs.', AI1WM_PLUGIN_NAME ) ); return $params; } } import/class-ai1wm-import-mu-plugins.php000064400000005346150502251500014321 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Import_Mu_Plugins { public static function execute( $params ) { // Set progress Ai1wm_Status::info( __( 'Activating mu-plugins...', AI1WM_PLUGIN_NAME ) ); $exclude_files = array( AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_ENDURANCE_PAGE_CACHE_NAME, AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_ENDURANCE_PHP_EDGE_NAME, AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_ENDURANCE_BROWSER_CACHE_NAME, AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_GD_SYSTEM_PLUGIN_NAME, ); // Open the archive file for reading $archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ) ); // Unpack mu-plugins files $archive->extract_by_files_array( WP_CONTENT_DIR, array( AI1WM_MUPLUGINS_NAME ), $exclude_files ); // Close the archive file $archive->close(); // Set progress Ai1wm_Status::info( __( 'Done activating mu-plugins.', AI1WM_PLUGIN_NAME ) ); return $params; } } import/class-ai1wm-import-validate.php000064400000014637150502251500014015 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Import_Validate { public static function execute( $params ) { // Verify file if size > 2GB and PHP = 32-bit if ( ! ai1wm_is_filesize_supported( ai1wm_archive_path( $params ) ) ) { throw new Ai1wm_Import_Exception( __( 'Your PHP is 32-bit. In order to import your file, please change your PHP version to 64-bit and try again. ' . 'Technical details', AI1WM_PLUGIN_NAME ) ); } // Set archive bytes offset if ( isset( $params['archive_bytes_offset'] ) ) { $archive_bytes_offset = (int) $params['archive_bytes_offset']; } else { $archive_bytes_offset = 0; } // Set file bytes offset if ( isset( $params['file_bytes_offset'] ) ) { $file_bytes_offset = (int) $params['file_bytes_offset']; } else { $file_bytes_offset = 0; } // Get total archive size if ( isset( $params['total_archive_size'] ) ) { $total_archive_size = (int) $params['total_archive_size']; } else { $total_archive_size = ai1wm_archive_bytes( $params ); } // What percent of archive have we processed? $progress = (int) min( ( $archive_bytes_offset / $total_archive_size ) * 100, 100 ); // Set progress Ai1wm_Status::info( sprintf( __( 'Unpacking archive...
%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) ); // Open the archive file for reading $archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ) ); // Set the file pointer to the one that we have saved $archive->set_file_pointer( $archive_bytes_offset ); // Validate the archive file consistency if ( ! $archive->is_valid() ) { throw new Ai1wm_Import_Exception( __( 'The archive file is corrupted. Follow ' . 'this article to resolve the problem.', AI1WM_PLUGIN_NAME ) ); } $allowed_size = apply_filters( 'ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE ); // Let's check the size of the file to make sure it is less than the maximum allowed if ( ( $allowed_size > 0 ) && ( $total_archive_size > $allowed_size ) ) { throw new Ai1wm_Import_Exception( sprintf( __( 'The file that you are trying to import is over the maximum upload file size limit of %s.
' . 'You can remove this restriction by purchasing our ' . 'Unlimited Extension.', AI1WM_PLUGIN_NAME ), size_format( $allowed_size ) ) ); } // Flag to hold if file data has been processed $completed = true; if ( $archive->has_not_reached_eof() ) { $file_bytes_written = 0; // Unpack package.json, multisite.json and database.sql files if ( ( $completed = $archive->extract_by_files_array( ai1wm_storage_path( $params ), array( AI1WM_PACKAGE_NAME, AI1WM_MULTISITE_NAME, AI1WM_DATABASE_NAME ), array(), $file_bytes_written, $file_bytes_offset ) ) ) { $file_bytes_offset = 0; } // Get archive bytes offset $archive_bytes_offset = $archive->get_file_pointer(); } // End of the archive? if ( $archive->has_reached_eof() ) { // Check package.json file if ( false === is_file( ai1wm_package_path( $params ) ) ) { throw new Ai1wm_Import_Exception( __( 'Please make sure that your file was exported using All-in-One WP Migration plugin. ' . 'Technical details', AI1WM_PLUGIN_NAME ) ); } // Set progress Ai1wm_Status::info( __( 'Done unpacking archive.', AI1WM_PLUGIN_NAME ) ); // Unset archive bytes offset unset( $params['archive_bytes_offset'] ); // Unset file bytes offset unset( $params['file_bytes_offset'] ); // Unset total archive size unset( $params['total_archive_size'] ); // Unset completed flag unset( $params['completed'] ); } else { // What percent of archive have we processed? $progress = (int) min( ( $archive_bytes_offset / $total_archive_size ) * 100, 100 ); // Set progress Ai1wm_Status::info( sprintf( __( 'Unpacking archive...
%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) ); // Set archive bytes offset $params['archive_bytes_offset'] = $archive_bytes_offset; // Set file bytes offset $params['file_bytes_offset'] = $file_bytes_offset; // Set total archive size $params['total_archive_size'] = $total_archive_size; // Set completed flag $params['completed'] = $completed; } // Close the archive file $archive->close(); return $params; } } import/class-ai1wm-import-compatibility.php000064400000004506150502251500015067 0ustar00. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Import_Compatibility { public static function execute( $params ) { // Set progress Ai1wm_Status::info( __( 'Checking extensions compatibility...', AI1WM_PLUGIN_NAME ) ); // Get messages $messages = Ai1wm_Compatibility::get( $params ); // Set messages if ( empty( $messages ) ) { return $params; } // Enable notifications add_filter( 'ai1wm_notification_error_toggle', '__return_true', 20 ); // Error message throw new Ai1wm_Compatibility_Exception( implode( $messages ) ); } }