Plugin Directory

Changeset 2749602


Ignore:
Timestamp:
06/29/2022 11:11:11 AM (4 years ago)
Author:
localsync
Message:

release 1.1.0

Location:
local-sync/trunk
Files:
2 added
19 edited

Legend:

Unmodified
Added
Removed
  • local-sync/trunk/README.txt

    r2519732 r2749602  
    1 === Plugin Name ===
     1=== WP Duplicate - WordPress Migration Plugin ===
    22Contributors: localsync, dark-prince
    33Donate link: https://revmakx.com
    4 Tags: clone, migrate, local sync, local site, dev site, duplicate site, duplicator, cloning, migration, simple cloning, easiest cloning, free cloning
     4Tags: clone, migrate, wp duplicate, wpduplicate, copy site, local sync, local site, dev site, duplicate site, duplicator, cloning, migration, simple cloning, easiest cloning, free cloning
    55Requires at least: 3.0.1
    6 Tested up to: 5.7
    7 Stable tag: 1.0.5
     6Tested up to: 6.0
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Clone live site to the local site and vice versa.
     11Easily migrate or clone your WordPress Site from one host to another.
    1212
    1313== Description ==
    1414
    15 LocalSync provides you the easiest way to clone or migrate a site from one server to another in the click of a button.<br>
     15WP Duplicate (Formerly LocalSync) provides you with the easiest and the fastest way to clone or migrate a site from one server to another with the click of a button.<br>
     16The migration process is highly reliable and is proven to migrate bigger sites without any errors.<br>
    1617
    17 == Why LocalSync? ==
     18== Why WP Duplicate? ==
    1819
    19 <h2><strong>Simplest Cloning Tool</strong></h2>Just install the LocalSync plugin on the destination site and the live site and start syncing, no need to enter FTP details.<br><br>
     20<h2><strong>Simplest Cloning Tool</strong></h2>Just install the WP Duplicate plugin on the destination site and the live site and start syncing, no need to enter FTP details.<br><br>
    2021<h2><strong>Incremental Cloning</strong></h2>Only the changed files are cloned from the source site to the destination site. So the cloning process is faster.<br><br>
    21 <h2><strong>Load Images From Live Site</strong></h2>With LocalSync you can directly load the images of Live site, so that you do not need to copy media files which will save a lot of time during the cloning process.<br><br>
    22 <h2><strong>Clone Live Site To Local Computer</strong></h2>With LocalSync you can clone any production site to your Local Computer (MAMP, LAMP, XAMP, etc..).
     22<h2><strong>Load Images From Live Site</strong></h2>With WP Duplicate you can directly load the images of Live site, so that you do not need to copy media files which will save a lot of time during the cloning process.<br><br>
     23<h2><strong>Clone Live Site To Local Computer</strong></h2>With WP Duplicate you can clone any production site to your Local Computer (MAMP, LAMP, XAMP, etc..).
    2324
    2425== Installation ==
    2526
    26 1. Spin off a WP site on the local server or any online servers.
    27 2. Install "Local Sync Plugin" on the WP site created as mentioned above and activate it.
    28 3. Go to "Local Sync Settings" and select "This is local site" button.
    29 4. Install Local Sync Plugin on the live WP site.
    30 5. Go to "Local Sync Settings" and select "This is prod site" button.
    31 6. Login with your Local Sync account (created on https://localsync.io) on the live WP site.
    32 7. Copy the prod key and go to the Local Sync Settings on the local WP site.
     271. Spin off a WP site on the destination server.
     282. Install and activate the "WP Duplicate Plugin" on the WP site created as mentioned above.
     293. Go to "WP admin dashboard -> WP Duplicate" and select "This is duplicate site" button.
     304. Install and activate "WP Duplicate Plugin" on the live WP site.
     315. Go to "WP admin dashboard -> WP Duplicate" and select "This is prod site" button.
     326. Login with your WP Duplicate account (created on https://localsync.io) on the live WP site.
     337. Copy the prod key and go to the "WP admin dashboard -> WP Duplicate" on the local WP site.
    33348. Paste the prod key, and Add Site.
    34 9. Now you are ready to perform the sync operations from the Local Site.
     359. Now you are ready to copy the live site to the duplicate site.
    3536
    3637== Screenshots ==
    3738
    38 1. Local Site settings page.
     391. Duplicate Site settings page.
     402. Live Site settings page.
    3941
    4042== Frequently Asked Questions ==
    4143
    42 = Can I clone the site to any server instead of the local server? =
     44= Can I clone the site to the local Computer? =
    4345
    44 Yes you can clone the live site to any proper WP site setup in any servers.
     46Yes, you can clone the live site to the WP site on your local desktop server.
    4547
    4648= Where is the documentation for your plugin? =
     
    4951
    5052== Changelog ==
     53= 1.1.0 =
     54*Release Date - 29 Jun 2022*
     55
     56* Improvement : The migration process is revamped to increase reliability and prevent errors in bigger sites.
     57* Improvement : Renamed the plugin to WP Duplicate.
    5158
    5259= 1.0.5 =
    5360*Release Date - 22 Apr 2021*
    5461
    55 * Fix : Not able to install LocalSync plugin on WPTimeCapsule's staging site.
    56 * Fix : Not able to include, exclude Files/Folders on WPTimeCapsule plugin settings page when LocalSync plugin is active.
     62* Fix : Not able to install WP Duplicate plugin on WPTimeCapsule's staging site.
     63* Fix : Not able to include, exclude Files/Folders on WPTimeCapsule plugin settings page when WP Duplicate plugin is active.
    5764
    5865* Improvement : LOCAL_SYNC_DOWNLOAD_CHUNK_SIZE constant is introduced.
  • local-sync/trunk/admin/class-local-sync-admin.php

    r2519732 r2749602  
    186186    }
    187187
     188    public function update_1_1_0_handle() {
     189
     190        $is_table_exist = $this->wpdb->query('SHOW TABLES LIKE "'.$this->wpdb->base_prefix.'local_sync_options%"');
     191
     192        if(!$is_table_exist){
     193
     194            return;
     195        }
     196
     197        $site_type = $this->local_sync_options->get_option('site_type');
     198
     199        if(empty($site_type)){
     200
     201            return;
     202        }
     203
     204
     205        $local_sync_version_in_options_table = $this->local_sync_options->get_option('local_sync_version');
     206
     207        if(empty($local_sync_version_in_options_table)){
     208
     209            return;
     210        }
     211
     212        if (version_compare($local_sync_version_in_options_table, '1.1.0', '<')) {
     213            $table_name = $this->wpdb->base_prefix . 'local_sync_current_process';
     214            $this->wpdb->query("ALTER TABLE `$table_name` ADD `prev_uploaded_size` int(30) NULL;");
     215
     216            local_sync_log($table_name,'----running-----update_1_1_0_handle-----------------');
     217        }
     218    }
    188219    public function create_fresh_tables() {
    189220        $cachecollation = $this->local_sync_get_collation();
     
    212243            `processed_time` varchar(30) NOT NULL,
    213244            `file_hash` varchar(128) DEFAULT NULL,
     245            `prev_uploaded_size` int(30) NULL,
    214246            PRIMARY KEY (`id`),
    215247            INDEX `file_path` (`file_path`(191))
     
    338370        add_menu_page(
    339371            'Local Sync',
    340             'Local Sync Settings',
     372            'WP Duplicate',
    341373            'activate_plugins',
    342374            plugin_dir_path(__FILE__) . 'views/local-sync-settings-display.php',
     
    602634                'import_local_file_list_dump' => 'waiting',
    603635                'process_file_list_difference' => 'waiting',
    604                 'zip_creation' => 'waiting',
    605                 'zip_download' => 'waiting',
    606                 'initiate_zip_extract' => 'waiting',
    607                 'continue_extract_from_bridge' => 'waiting',
     636                'send_batch_download_requests' => 'waiting',
     637                'copy_files_from_bridge' => 'waiting',
    608638                'prepare_delete_list_table' => 'waiting',
    609639                'db_dump_restore' => 'waiting',
     
    645675                    $this->app_functions->do_zip_download();
    646676                    break;
     677                case 'send_batch_download_requests':
     678                    $this->batch_download_obj = new Local_Sync_Batch_Download();
     679                    $response = $this->batch_download_obj->send_batch_download_requests();
     680                    break;
     681                case 'initiate_bridge_files':
     682                    $this->app_functions->initiate_bridge_files();
     683                    break;
    647684                case 'initiate_zip_extract':
    648685                    $this->away_post_call_dont_handle_response('clear_temp_files_local_sync', $url);
     
    702739        if( $sync_current_action == 'file_list_preparation_for_local_dump'
    703740            || $sync_current_action == 'start_db_dump_local_file_list'
    704             || $sync_current_action == 'initiate_zip_extract' ){
     741            || $sync_current_action == 'initiate_zip_extract'
     742            || $sync_current_action == 'initiate_bridge_files' ){
    705743
    706744            $is_away_action = true;
     
    725763                case 'process_file_list_difference':
    726764                    $this->app_functions->process_file_list_difference();
     765                    break;
     766                case 'batch_upload_files':
     767                    $this->batch_upload_obj = new Local_Sync_Batch_Upload();
     768                    $response = $this->batch_upload_obj->batch_upload_files();
    727769                    break;
    728770                case 'zip_creation':
     
    757799        );
    758800
     801        $post_body['load_images_from_live_site_settings'] = $this->local_sync_options->get_option('load_images_from_live_site_settings');
    759802        if($away_action_first_call){
    760803            $post_body['current_sync_unique_id'] = $this->local_sync_options->get_option('current_sync_unique_id');
    761804            $post_body['prod_site_url'] = $this->local_sync_options->get_option('local_site_url');
    762805            $post_body['away_sync_type_db_or_files'] = $this->local_sync_options->get_option('sync_type_db_or_files');
    763             $post_body['load_images_from_live_site_settings'] = $this->local_sync_options->get_option('load_images_from_live_site_settings');
    764806
    765807            $post_body['away_site_abspath'] = wp_normalize_path(ABSPATH);
     
    798840                $this->local_sync_options->set_option('away_site_id_current_site', $response['away_site_id_current_site']);
    799841                $this->local_sync_options->set_option('away_blog_id_current_site', $response['away_blog_id_current_site']);
    800                 $this->local_sync_options->set_option('load_images_from_live_site_settings', $response['load_images_from_live_site_settings']);
    801842            }
    802843
     
    852893
    853894        $this->app_functions->process_features_from_response($response);
     895        if(!empty($response['prod_site_url_enc'])){
     896            $this->local_sync_options->set_option('prod_site_url_enc', $response['prod_site_url_enc']);
     897            $this->local_sync_options->set_option('prod_admin_url_enc', $response['prod_admin_url_enc']);
     898            $this->local_sync_options->set_option('prod_uploads_url_enc', $response['prod_uploads_url_enc']);
     899            $this->local_sync_options->set_option('away_site_abspath', $response['away_site_abspath']);
     900            $this->local_sync_options->set_option('away_site_db_prefix', $response['away_site_db_prefix']);
     901            $this->local_sync_options->set_option('is_away_site_multisite', $response['is_away_site_multisite']);
     902            $this->local_sync_options->set_option('away_site_id_current_site', $response['away_site_id_current_site']);
     903            $this->local_sync_options->set_option('away_blog_id_current_site', $response['away_blog_id_current_site']);
     904        }
    854905
    855906        if( !empty($response) && !empty($response['success'])){
  • local-sync/trunk/admin/class-local-sync-app-functions.php

    r2248180 r2749602  
    157157        $post_body['prod_key_random_id'] = $this->local_sync_options->get_option('prod_key_random_id');
    158158
     159        $timeout = 30;
     160        if(!empty($post_body) && !empty($post_body['action']) && $post_body['action'] == 'check_validity'){
     161            $timeout = 60;
     162        }
    159163        $response = wp_remote_post( $url, array(
    160164            'method' => 'POST',
    161             'timeout' => 30,
     165            'timeout' => $timeout,
    162166            'redirection' => 5,
    163             'httpversion' => '1.0',
     167            'sslverify' => false,
    164168            'blocking' => true,
    165169            'headers' => array(),
     
    169173        );
    170174
    171         $response = wp_remote_retrieve_body( $response );
    172 
    173         $response = parse_local_sync_response_from_raw_data_php($response);
     175        $raw_response = wp_remote_retrieve_body( $response );
     176
     177        $response = parse_local_sync_response_from_raw_data_php($raw_response);
    174178
    175179        local_sync_log($response, "-----wp_remote_post_local_sync---response-----$url---");
     180       
     181        if(empty($response)){
     182            local_sync_log($raw_response, "-----wp_remote_post_local_sync---raw_response-----$url---");
     183        }
    176184
    177185        return json_decode($response, true);
     
    386394
    387395            $this->local_sync_files_op->add_full_db_file_to_current_process();
    388             $this->local_sync_options->set_option('sync_current_action', 'zip_creation');
     396            $next_action = 'batch_upload_files';
     397            $site_type = $this->local_sync_options->get_option('site_type');
     398            if($site_type == 'production'){
     399                $next_action = 'send_batch_download_requests';
     400            }
     401            $this->local_sync_options->set_option('sync_current_action', $next_action);
    389402
    390403            $this->local_sync_options->set_this_current_action_step('processing');
     
    941954            $this->local_sync_options->set_option('sync_current_action', 'continue_extract_from_live_bridge');
    942955            $this->local_sync_options->set_option('sync_sub_action', 'continue_extract_from_live_bridge');
     956            $this->local_sync_options->set_this_current_action_step( 'processing');
     957        }
     958
     959        $this->local_sync_options->set_option('is_bridge_process', true);
     960
     961        local_sync_die_with_json_encode(array(
     962            'success' =>  true,
     963            'sync_sub_action' => $this->local_sync_options->get_option('sync_sub_action'),
     964            'sync_current_action' => $this->local_sync_options->get_option('sync_current_action'),
     965            'requires_next_call' => false
     966        ));
     967    }
     968
     969    public function initiate_bridge_files() {
     970        $this->local_sync_options->set_option('sync_sub_action', 'creating_bridge_files');
     971
     972        $restore_app_functions = new Local_Sync_Restore_Op();
     973        $download_result = $restore_app_functions->prepare();
     974
     975        $restore_app_functions->reset_bridge_constants();
     976
     977        $site_type = $this->local_sync_options->get_option('site_type');
     978
     979        $this->local_sync_options->set_this_current_action_step('done');
     980
     981        if(empty($site_type) || $site_type == 'local'){
     982            $this->local_sync_options->set_option('sync_current_action', 'copy_files_from_bridge');
     983            $this->local_sync_options->set_option('sync_sub_action', 'copy_files_from_bridge');
     984            $this->local_sync_options->set_this_current_action_step( 'processing');
     985        } elseif($site_type == 'production'){
     986            $this->local_sync_options->set_option('sync_current_action', 'copy_files_from_live_bridge');
     987            $this->local_sync_options->set_option('sync_sub_action', 'copy_files_from_live_bridge');
    943988            $this->local_sync_options->set_this_current_action_step( 'processing');
    944989        }
     
    10001045        fwrite($fp, hex2bin($file_data));
    10011046
    1002         // file_put_contents($file_list_dump_file, hex2bin($file_data), FILE_APPEND);
     1047       
    10031048
    10041049        if(!file_exists($file_list_dump_file)){
     
    10381083        $fp = fopen($full_zip_file, 'rb+');
    10391084        fseek($fp, $start_range);
    1040         fwrite($fp, hex2bin($file_data));
    1041 
    1042         // file_put_contents($full_zip_file, hex2bin($file_data), FILE_APPEND);
     1085        fwrite( $fp, gzuncompress(hex2bin($file_data)) );
     1086
    10431087
    10441088        if(!file_exists($full_zip_file)){
     
    11491193            $modified_files = array();
    11501194            $modified_files_count = 0;
     1195            $site_type = $this->local_sync_options->get_option('site_type');
     1196
     1197            $next_action = 'batch_upload_files';
     1198            if($site_type == 'production'){
     1199                //hackish
     1200                $next_action = 'send_batch_download_requests';
     1201            }
    11511202
    11521203            if( !$this->local_sync_options->is_feature_valid('filesDiff') ){
    1153                 $this->local_sync_options->set_option('sync_current_action', 'zip_creation');
    1154                 $this->local_sync_options->set_option('sync_sub_action', 'zip_creation');
     1204                $this->local_sync_options->set_option('sync_current_action', $next_action);
     1205                $this->local_sync_options->set_option('sync_sub_action', $next_action);
    11551206            } elseif($diff_result['is_completed']){
    1156                 $this->local_sync_options->set_option('sync_current_action', 'zip_creation');
    1157                 $this->local_sync_options->set_option('sync_sub_action', 'zip_creation');
     1207                $this->local_sync_options->set_option('sync_current_action', $next_action);
     1208                $this->local_sync_options->set_option('sync_sub_action', $next_action);
    11581209
    11591210                $this->local_sync_files_op = new Local_Sync_Files_Op();
     
    13541405            local_sync_die_with_json_encode_simple(array(
    13551406                'success' =>  true,
    1356                 'features' => $response['features']
     1407                'features' => $response['features'],
     1408                'prod_site_url_enc' => $this->local_sync_options->get_option('local_site_url_enc'),
     1409                'prod_admin_url_enc' => $this->local_sync_options->get_option('local_admin_url_enc'),
     1410                'prod_uploads_url_enc' => $this->local_sync_options->get_option('local_uploads_url_enc'),
     1411                'load_images_from_live_site_settings' => $this->local_sync_options->get_option('load_images_from_live_site_settings'),
     1412                'away_site_abspath' => wp_normalize_path(ABSPATH),
     1413                'is_away_site_multisite' => defined('MULTISITE') ? MULTISITE : false,
     1414                'away_site_id_current_site' => defined('SITE_ID_CURRENT_SITE') ? SITE_ID_CURRENT_SITE : false,
     1415                'away_blog_id_current_site' => defined('BLOG_ID_CURRENT_SITE') ? BLOG_ID_CURRENT_SITE : false,
     1416                'away_site_db_prefix' => $this->wpdb->base_prefix,
    13571417            ));
    13581418        }
     
    13831443        $post_body['URL'] = $post_body['url'];
    13841444
    1385         local_sync_log($post_body, "--------service_post_call-----post_body---");
     1445        local_sync_log($post_body, "--------service_post_call---$main_action--post_body---");
    13861446
    13871447        if(empty($post_body['email']) || empty($post_body['pass']) || empty($post_body['URL'])){
     
    14011461        $response = wp_remote_post( $service_url, array(
    14021462            'method' => 'POST',
    1403             'timeout' => 30,
     1463            'timeout' => 60,
    14041464            'redirection' => 5,
    1405             'httpversion' => '1.0',
     1465            'sslverify' => false,
    14061466            'blocking' => true,
    14071467            'headers' => array(
     
    14171477        $response = parse_wp_merge_response_from_raw_data_php($response);
    14181478
    1419         local_sync_log($response, "-----service_post_call---response--------");
     1479        local_sync_log($response, "-----service_post_call-$main_action--response--------");
    14201480
    14211481        $response = json_decode($response, true);
     
    14251485
    14261486    public function process_features_from_response($response=null) {
     1487        if(empty($response)){
     1488
     1489            return;
     1490        }
    14271491        if( !empty($response) && !empty($response['success']) && !empty($response['features'])){
    14281492            $this->local_sync_options->set_option('prod_site_features', json_encode($response['features'], true));
    1429 
    14301493            return;
    14311494        }
    14321495
     1496        //to handle temp live site timeout
     1497        if(!empty($response) && !empty($response['error']) && $response['error'] == 'Invalid Response.'){
     1498
     1499            return;
     1500        }
     1501
    14331502        $this->local_sync_options->set_option('prod_site_features', array());
    14341503    }
  • local-sync/trunk/admin/class-local-sync-db-op.php

    r2245393 r2749602  
    337337        $columns = $this->wpdb->get_results("SHOW COLUMNS IN `$table`", OBJECT_K);
    338338
    339         local_sync_log($this->select_query_limit, "--------select_query_limit--------");
     339        // local_sync_log($this->select_query_limit, "--------select_query_limit--------");
    340340
    341341        if ($table_count != 0) {
  • local-sync/trunk/admin/class-local-sync-exclude-option.php

    r2248180 r2749602  
    255255    }
    256256
    257     private function get_keys($type = 'file' , $action, $category = 'backup'){
     257    private function get_keys($type = 'file' , $action = '', $category = 'backup'){
    258258
    259259        $sql = "SELECT * FROM {$this->db->base_prefix}local_sync_inc_exc_contents WHERE `type` = '$type' AND `action` = '$action' AND `category` = '$category'";
  • local-sync/trunk/admin/class-local-sync-files-op.php

    r2251904 r2749602  
    381381
    382382        if(!$is_skip){
    383             $files_count_check = 10000;
     383            $files_count_check = 3000;
    384384            if(defined('ITERATOR_FILES_COUNT_CHECK')){
    385385                $files_count_check = ITERATOR_FILES_COUNT_CHECK;
     
    463463    }
    464464
    465     public function get_limited_files_to_zip($limit = 10) {
     465    public function get_prev_uploaded_size($file) {
     466        $sql = "SELECT prev_uploaded_size FROM `{$this->wpdb->base_prefix}local_sync_current_process` WHERE file_path='$file'";
     467        $response = $this->wpdb->get_var($sql);
     468
     469        if($response === false){
     470            local_sync_log($sql, "--------get_limited_files_to_zip---error-----");
     471
     472            return 0;
     473        }
     474
     475        return $response;
     476    }
     477
     478    public function update_current_process_prev_uploaded_size($file_path, $file_size) {
     479       
     480        $sql = "UPDATE `{$this->wpdb->base_prefix}local_sync_current_process` SET prev_uploaded_size=$file_size WHERE file_path='$file_path'";
     481        $response = $this->wpdb->query($sql);
     482
     483        if($response === false){
     484            local_sync_log($sql, "--------update_current_process_prev_uploaded_size---error-----");
     485        }
     486
     487        return $response;
     488    }
     489
     490    public function update_current_file_status($file_path, $status) {
     491       
     492        $sql = "UPDATE `{$this->wpdb->base_prefix}local_sync_current_process` SET status='$status' WHERE file_path='$file_path'";
     493        $response = $this->wpdb->query($sql);
     494
     495        if($response === false){
     496            local_sync_log($sql, "--------update_current_file_status---error-----");
     497        }
     498
     499        return $response;
     500    }
     501
     502    public function get_limited_files_to_zip($limit = 50) {
    466503        $sql = "SELECT file_path FROM `{$this->wpdb->base_prefix}local_sync_current_process` WHERE STATUS='Q' LIMIT $limit";
    467504        $response = $this->wpdb->get_results($sql);
     
    480517        if($response === false){
    481518            local_sync_log($sql, "--------get_limited_files_to_zip---error-----");
     519        }
     520
     521        return $response;
     522    }
     523
     524    public function get_processed_files_count() {
     525        $sql = "SELECT COUNT(id) FROM `{$this->wpdb->base_prefix}local_sync_current_process` WHERE status='P'";
     526        $response = $this->wpdb->get_var($sql);
     527
     528        if($response === false){
     529            local_sync_log($sql, "--------get_processed_files_count---error-----");
     530        }
     531
     532        return $response;
     533    }
     534
     535    public function get_queued_files_count() {
     536        $sql = "SELECT COUNT(id) FROM `{$this->wpdb->base_prefix}local_sync_current_process` WHERE status='Q'";
     537        $response = $this->wpdb->get_var($sql);
     538
     539        if($response === false){
     540            local_sync_log($sql, "--------get_processed_files_count---error-----");
    482541        }
    483542
     
    715774
    716775    }
     776
     777    public function save_files_batch($files_post_obj, $start_range = 0) {
     778        try {
     779           
     780            $current_sync_unique_id = $this->local_sync_options->get_option('current_sync_unique_id');
     781
     782            foreach($files_post_obj as $kk => $vv){
     783                $this->save_single_batch_file([
     784                    'file_name' => base64_decode($kk),
     785                    'file_data' => $vv,
     786                ], $start_range);
     787            }
     788        } catch (Exception $e) {
     789            local_sync_die_with_json_encode(array(
     790                'success' =>  false,
     791                'msg' =>  'save_files_batch_error' . $e->getMessage(),
     792                'sync_sub_action' => $this->local_sync_options->get_option('sync_sub_action'),
     793                'sync_current_action' => $this->local_sync_options->get_option('sync_current_action'),
     794                'requires_next_call' => false
     795            ));
     796        }
     797    }
     798
     799    public function save_single_batch_file($file_obj = null, $start_range = 0) {
     800        $full_file_name = rtrim($this->local_sync_options->get_backup_dir(), '/') . '/' . $file_obj['file_name'];
     801
     802        // local_sync_log($full_file_name, "--------save_single_batch_file--------");
     803
     804        $this->recursive_mk_directory_of_this_file($full_file_name);
     805
     806        if( $start_range == 0 ){
     807            file_put_contents($full_file_name, '');
     808        }
     809
     810        $file_data = $file_obj['file_data'];
     811        if(!empty($file_data)){
     812            $file_data = gzuncompress(hex2bin($file_data));
     813        }
     814
     815        $fp = fopen($full_file_name, 'rb+');
     816        fseek($fp, $start_range);
     817        fwrite( $fp, $file_data);
     818
     819        if(!empty($fp)){
     820            fclose($fp);
     821        } else {
     822            local_sync_log($full_file_name, "--------save_full_file_name---failed-----");
     823        }
     824
     825        return true;
     826    }
     827
     828    public function recursive_mk_directory_of_this_file($full_file_name) {
     829        $this_dir_name = dirname($full_file_name);
     830
     831        if(!is_dir($this_dir_name)){
     832            $this->recursive_mk_directory_of_this_file($this_dir_name);
     833        } else {
     834            return;
     835        }
     836
     837        mkdir($this_dir_name, 0755);
     838    }
     839
     840    public function save_single_big_file($file_name, $file_data = null, $start_range = 0, $end_range = 0) {
     841        $current_sync_unique_id = $this->local_sync_options->get_option('current_sync_unique_id');
     842
     843        $full_file_name = rtrim($this->local_sync_options->get_backup_dir(), '/') . '/' . $file_name;
     844
     845        $this->recursive_mk_directory_of_this_file($full_file_name);
     846
     847        if( $start_range == 0 ){
     848            file_put_contents($full_file_name, '');
     849        }
     850
     851        $fp = fopen($full_file_name, 'rb+');
     852        fseek($fp, $start_range);
     853        fwrite( $fp, gzuncompress(hex2bin($file_data)) );
     854
     855        fclose($fp);
     856
     857        if(!file_exists($full_file_name)){
     858            local_sync_log($full_file_name, "--------save_single_big_file---failed-----");
     859
     860            local_sync_die_with_json_encode(array(
     861                'error' =>  'Cannot create full zip file',
     862                'msg' =>  'save_single_big_file_failed',
     863                'sync_sub_action' => $this->local_sync_options->get_option('sync_sub_action'),
     864                'sync_current_action' => $this->local_sync_options->get_option('sync_current_action'),
     865                'requires_next_call' => false
     866            ));
     867        }
     868
     869        // local_sync_log(filesize($full_file_name), "--------file zise---save_single_big_file-----");
     870
     871        local_sync_die_with_json_encode(array(
     872            'success' =>  true,
     873            'msg' =>  'save_single_big_file_success',
     874            'file_size' => filesize($full_file_name),
     875            'sync_sub_action' => $this->local_sync_options->get_option('sync_sub_action'),
     876            'sync_current_action' => $this->local_sync_options->get_option('sync_current_action'),
     877            'requires_next_call' => true
     878        ));
     879
     880        // return filesize($file_list_dump_file);
     881    }
    717882}
  • local-sync/trunk/admin/class-local-sync-replace-db-links.php

    r2245393 r2749602  
    115115    }
    116116
    117     public function prepare_replace_list_for_staging($replace_list = array(), $table_prefix, $old_url, $new_url, $type = '')
     117    public function prepare_replace_list_for_staging($replace_list = array(), $table_prefix = '', $old_url = '', $new_url = '', $type = '')
    118118    {
    119119        local_sync_log($table_prefix, "--------prepare_replace_list_for_staging--------");
     
    515515            } else if (is_object($data)) {
    516516
    517                 $_tmp = $data;
    518                 $props = get_object_vars( $data );
    519                 foreach ($props as $key => $value) {
    520                     //If some objects has \0 in the key it creates the fatal error so skip such contents
    521                     if (strstr($key, "\0") !== false ) {
    522                         continue;
     517                if( get_class($data) != '__PHP_Incomplete_Class' ){
     518
     519                    $_tmp = $data;
     520                    $props = get_object_vars( $data );
     521                    foreach ($props as $key => $value) {
     522                        //If some objects has \0 in the key it creates the fatal error so skip such contents
     523                        if (is_string($key) && strstr($key, "\0") !== false ) {
     524                            continue;
     525                        }
     526                        if (is_string($value) && strstr($value, "\0") !== false ) {
     527                            continue;
     528                        }
     529                        $_tmp->$key = $this->recursive_unserialize_replace( $from, $to, $value, false );
    523530                    }
    524                     $_tmp->$key = $this->recursive_unserialize_replace( $from, $to, $value, false );
    525                 }
    526                 $data = $_tmp;
    527                 unset($_tmp);
     531                    $data = $_tmp;
     532                    unset($_tmp);
     533                   
     534                }
     535               
    528536            } else {
    529537                if (is_string($data)) {
  • local-sync/trunk/admin/class-local-sync-restore-op.php

    r2251904 r2749602  
    613613            if ( $this->is_migration ) {
    614614                $current_query = $this->search_and_replace_db_name($current_query);
    615                 $current_query = $this->search_and_replace_prefix($current_query);
     615                // $current_query = $this->search_and_replace_prefix($current_query);
    616616                $replaceQuery = $this->search_and_replace_urls_new($current_query, $this->old_url, $this->new_url, $this->live_db_prefix);
    617617            }
     
    625625            if(!empty($replaceQuery['prevExec']) && !empty($tempQuery)) {
    626626
    627                 local_sync_log('', "--------prevExec---coming-----");
     627                // local_sync_log('', "--------prevExec---coming-----");
    628628
    629629                // local_sync_log(strlen($tempQuery), "--------tempQuery--length---exec---");
     
    10351035            local_sync_log('', "--------search_and_replace_db_name--1--success----");
    10361036
    1037             return 'CREATE DATABASE IF NOT EXISTS `' . DB_NAME . '`';
     1037            $this_query = 'CREATE DATABASE IF NOT EXISTS `' . DB_NAME . '`';
     1038
     1039            return '';
    10381040        }
    10391041
     
    10421044            local_sync_log('', "--------search_and_replace_db_name--2--success----");
    10431045
    1044             return 'USE `' . DB_NAME . '`';
     1046            $this_query =  'USE `' . DB_NAME . '`';
     1047
     1048            return '';
    10451049        }
    10461050
     
    11801184
    11811185    public function search_and_replace_prefix($query){
     1186        if(stripos($query, 'USE ') === 0){
     1187            local_sync_log($query, "--------use query man------");
     1188
     1189            return $query; //revisit
     1190        }
    11821191
    11831192        // return $query; //revisit
     
    14651474            local_sync_wait_for_sometime();
    14661475
    1467             local_sync_log($file, "--------deleting state file--delete_files_from_table_records------");
     1476            // local_sync_log($file, "--------deleting state file--delete_files_from_table_records------");
    14681477
    14691478            $result = $this->fs->delete($file);
     
    14791488            }
    14801489
    1481             $updated_files_str = ltrim($updated_files_str, ',');
    1482             $this->update_delete_list_table_status($updated_files_str, 'D');
    14831490
    14841491            return array(
     
    14881495        }
    14891496
    1490         // local_sync_log($updated_files_str, "--------updated_files_str----D----");
     1497        local_sync_log($updated_files_str, "--------deleted files str----D----");
    14911498
    14921499        $updated_files_str = ltrim($updated_files_str, ',');
  • local-sync/trunk/admin/js/local-sync-admin.js

    r2248180 r2749602  
    44var USER_SELECTION_MODIFIED_FILES = {};
    55var SHOW_FS_METHOD_ERROR_LOSY = false;
     6var LOCAL_SYNC_AJAX_RUNNING = false;
    67
    78function import_steps_losy(steps_parent){
     
    8586
    8687function continue_sync_from_live_losy(){
    87     if(typeof chosen_action_local_sync == 'undefined' || chosen_action_local_sync == ''){
     88    if(typeof chosen_action_local_sync == 'undefined' || chosen_action_local_sync == '' || LOCAL_SYNC_AJAX_RUNNING){
    8889        return;
    8990    }
     91    LOCAL_SYNC_AJAX_RUNNING = true;
    9092
    9193    var data = {
     
    103105
    104106        console.log('continuing sync response', response);
     107        LOCAL_SYNC_AJAX_RUNNING = false;
    105108
    106109        if(typeof response == 'undefined' || !response){
     
    179182        }
    180183
     184        if(typeof response.queued_files_count != 'undefined'){
     185            if(jQuery('#send_batch_download_requests_losy').length){
     186                jQuery('#send_batch_download_requests_losy').text(`Downloading ${response.queued_files_count} files...`);
     187            } else if(jQuery('#batch_upload_files_losy').length){
     188                jQuery('#batch_upload_files_losy').text(`Uploading ${response.queued_files_count} files...`);
     189            }
     190        }
     191
    181192        if(response.sync_current_action == 'continue_extract_from_bridge'){
    182193            transfer_flow_to_bridge_losy();
    183         }else if(response.sync_current_action == 'continue_extract_from_live_bridge'){
     194        } else if(response.sync_current_action == 'continue_extract_from_live_bridge'){
    184195            transfer_flow_to_live_bridge_losy();
     196        } else if(response.sync_current_action == 'copy_files_from_live_bridge'){
     197            transfer_flow_to_live_bridge_losy();
     198        } else if(response.sync_current_action == 'copy_files_from_bridge'){
     199            transfer_flow_to_bridge_losy();
    185200        }
    186201
     
    196211
    197212function stop_and_re_init_continue_sync_from_live_losy(){
    198     if( (typeof continue_sync_interval_started != 'undefined' && continue_sync_interval_started) ){stop_continuing_sync_process_losy(true);
     213    if( (typeof continue_sync_interval_started != 'undefined' && continue_sync_interval_started) ){
     214        stop_continuing_sync_process_losy(true);
    199215
    200216        continue_sync_interval_started = true;
     
    352368
    353369function save_settings_losy(isAlert, pullSteps){
     370    jQuery('.save_settings_local_sync').val('Saving...');
    354371    var ls_settings = {};
    355372    // ls_settings['prod_key'] = jQuery('.prod_key_losy').val();
     
    373390
    374391    jQuery.post(ajaxurl, data, function(response) {
    375 
    376         console.log('save_settings_losy');
    377 
    378         response = parse_local_sync_response_from_raw_data(response);
    379 
    380392        try{
     393            console.log('save_settings_losy');
     394
     395            jQuery('.save_settings_local_sync').val('Save Changes');
     396
     397            response = parse_local_sync_response_from_raw_data(response);
     398
    381399            response = JSON.parse(response);
     400           
     401            console.log(response);
     402           
     403            if( typeof response != 'undefined'
     404            && typeof response.prod_site_url != 'undefined'
     405            && response.prod_site_url ){
     406                jQuery('.prod_site_url_losy').val(response.prod_site_url);
     407            }
     408           
     409            if(isAlert){
     410                alert('Success');
     411            }
     412            if(pullSteps){
     413                import_steps_losy(chosen_action_local_sync);
     414            }
     415
    382416        }catch(err){
    383417            console.log('json parse error', response);
    384         }
    385        
    386         console.log(response);
    387 
    388         if( typeof response != 'undefined'
    389             && typeof response.prod_site_url != 'undefined'
    390             && response.prod_site_url ){
    391             jQuery('.prod_site_url_losy').val(response.prod_site_url);
    392         }
    393 
    394         if(isAlert){
    395             alert('Success');
    396         }
    397         if(pullSteps){
    398             import_steps_losy(chosen_action_local_sync);
    399418        }
    400419    });
  • local-sync/trunk/admin/views/local-sync-settings-display.php

    r2519732 r2749602  
    9898    <div class="main-cols-losy">
    9999        <div class="m-box-losy">
    100             <h2 class="hd">Login to your LocalSync account <a href="https://localsync.io" target="_blank" style="float: right; text-decoration: none;">Signup</a></h2>
     100            <h2 class="hd">Login to your WP Duplicate account <a href="https://localsync.io" target="_blank" style="float: right; text-decoration: none;">Signup</a></h2>
    101101            <div class="pad">
    102102                <div class="losy_login_error losy_login_erorr_success_flaps error-box-losy" style="display: none;"></div>
     
    131131            <div class="main-cols-losy">
    132132                <div class="m-box-losy">
    133                     <h2 class="hd">Is this the production site or local site?</h2>
     133                    <h2 class="hd">Is this the production site or duplicate site?</h2>
    134134                    <div class="pad">
    135                         <em>Click <strong>"This is local site"</strong> if you wish to set this site as the local site, or , click <strong>"This is live site"</strong> if you wish to set this site as the production site. <a href="https://docs.localsync.io" target="_blank">help?</a></em>
     135                        <em>Click <strong>"This is duplicate site"</strong> if you wish to set this site as the duplicate site, or , click <strong>"This is live site"</strong> if you wish to set this site as the production site. <a href="https://docs.localsync.io" target="_blank">help?</a></em>
    136136                    </div>
    137137                    <div class="pad cf" style="padding-top: 0;">
    138138                        <div class="col col50">
    139                             <button class="button set_as_local_site_losy" style="float: left; margin: 5px 0 4px;" >This is local site</button>
     139                            <button class="button set_as_local_site_losy" style="float: left; margin: 5px 0 4px;" >This is duplicate site</button>
    140140                        </div>
    141141                        <div class="col col50">
     
    157157                                Enter the Prod Key copied from the live site.
    158158                                <br>
    159                                 (Live site WP admin -> Local Sync Settings)
     159                                (Live site WP admin -> WP Duplicate)
    160160                            </em>
    161161                        </div>
     
    242242            <?php if($show_prod_site_options) : ?>
    243243            <div class="m-box-losy">
    244                 <h2 class="hd">Connect Dev & Prod Local Sync plugins <a href="https://docs.localsync.io" target="_blank">help?</a> </h2>
     244                <h2 class="hd">Connect Live site & Duplicate site <a href="https://docs.localsync.io" target="_blank">help?</a> </h2>
    245245                <div class="pad">
    246                     Copy and paste this key on the local site, you want to clone.
     246                    Copy and paste this key on the duplicate site, you want to clone.
    247247                </div>
    248248                <div class="pad">
     
    253253                        </div>
    254254                    </div>
    255                     <div style="font-size: 11px; padding-top: 5px;">Copy &amp; Paste this key in the Dev site's WP Admin Dashboard -> Local Sync Settings.</div>
     255                    <div style="font-size: 11px; padding-top: 5px;">Copy &amp; Paste this key in the Dev site's WP Admin Dashboard -> WP Duplicate.</div>
    256256                </div>
    257257            </div>
     
    263263                    <div class="all-caps-heading" style="margin-bottom:5px;">INCLUDE/EXCLUDE CONTENT FOR PUSHING TO LOCAL</div>
    264264                                <em>These settings apply when pulling this live site from the dev site. For include/exclude
    265                                     settings for pulling from dev site, go to the Dev site's <strong>Local Sync Plugin</strong> settings</em><br><br>
     265                                    settings for pulling from dev site, go to the Dev site's <strong>WP Duplicate Plugin</strong> settings</em><br><br>
    266266                    <div class="form-row">
    267267                        <label>Select folders, files or DB tables to include</label>
  • local-sync/trunk/includes/class-local-sync-handle-server-requests.php

    r2519732 r2749602  
    7979                   
    8080                    break;
     81                case 'handle_batch_upload_files':
     82                    $this->handle_batch_upload_files();
     83                   
     84                    break;
     85                case 'handle_upload_single_big_file':
     86                    $this->handle_upload_single_big_file();
     87                   
     88                    break;
    8189                case 'handle_upload_zip_file':
    8290                    $this->handle_upload_zip_file();
     91                   
     92                    break;
     93                case 'handle_batch_download_files':
     94                    $this->handle_batch_download_files();
    8395                   
    8496                    break;
     
    345357                $this->app_functions->initiate_zip_extract();
    346358                break;
     359            case 'initiate_bridge_files':
     360                $this->app_functions->initiate_bridge_files();
     361                break;
    347362           
    348363            default:
     
    369384
    370385        $this->app_functions->save_full_zip_file($this->request_data['file_data'], $this->request_data['start_range'], $this->request_data['end_range']);
     386    }
     387
     388    public function handle_upload_single_big_file() {
     389        $this->local_sync_options->set_option('sync_current_action', 'handle_upload_single_big_file');
     390        $this->local_sync_options->set_option('sync_sub_action', 'handle_upload_single_big_file');
     391
     392        $this->local_sync_options->create_local_sync_files();
     393
     394        $this->local_sync_files_op = new Local_Sync_Files_Op();
     395        $this->local_sync_files_op->save_single_big_file($this->request_data['file_name'], $this->request_data['file_data'], $this->request_data['start_range'], $this->request_data['end_range']);
     396
     397    }
     398
     399    public function handle_batch_upload_files() {
     400        $this->local_sync_options->set_option('sync_current_action', 'handle_batch_upload_files');
     401        $this->local_sync_options->set_option('sync_sub_action', 'handle_batch_upload_files');
     402
     403        $this->local_sync_options->create_local_sync_files();
     404
     405        $this->local_sync_files_op = new Local_Sync_Files_Op();
     406        $this->local_sync_files_op->save_files_batch($this->request_data['files_data']);
     407
     408    }
     409
     410    public function handle_batch_download_files()   {
     411        $this->local_sync_options->set_option('sync_current_action', 'handle_batch_download_files');
     412        $this->local_sync_options->set_option('sync_sub_action', 'handle_batch_download_files');
     413
     414        $this->local_sync_options->create_local_sync_files();
     415
     416        $this->batch_download_obj = new Local_Sync_Batch_Download();
     417        $response = $this->batch_download_obj->batch_download_files();
    371418
    372419    }
  • local-sync/trunk/includes/class-local-sync-options.php

    r2248180 r2749602  
    44
    55    public $all_configs;
     6    public $files_to_be_skipped_during_full_copy;
    67
    78    public function __construct() {
     
    1112        $this->all_configs = array();
    1213
     14        $this->files_to_be_skipped_during_full_copy = [
     15            'local_sync_deleted_files.txt',
     16            'local_sync_file_list_dump',
     17            'test.php',
     18        ];
    1319        $options_table_name = $this->wpdb->base_prefix . 'local_sync_options';
    1420        $this->options_table_name = $options_table_name;
     
    3440        if($result === false){
    3541            local_sync_log($name, "--------update_option-failed-------");
     42            local_sync_log($this->wpdb->last_error, "--------update_option-failed----last_error---");
     43            local_sync_log($this->wpdb->last_query, "--------update_option-failed----last_query---");
    3644        } else {
    3745            $this->all_configs[$name] = $value;
     
    251259        $folder_name = trailingslashit($folder_name);
    252260
    253         local_sync_log($folder_name, "----deleting----folder_name--------");
     261        // local_sync_log($folder_name, "----deleting----folder_name--------");
    254262
    255263        $normalized_abspath = wp_normalize_path(ABSPATH);
     
    296304                }
    297305
    298                 local_sync_log($folder_name . $filename, "------deleting----------");
     306                // local_sync_log($folder_name . $filename, "------deleting----------");
    299307
    300308                $this->fs->delete($folder_name . $filename);
     
    340348
    341349        foreach ((array) $dirlist as $filename => $fileinfo) {
    342             if ('f' == $fileinfo['type'] && $filename != '.htaccess') {
     350            if (!empty($fileinfo) && 'f' == $fileinfo['type'] && $filename != '.htaccess') {
    343351                if (!$this->tc_file_system_copy($from . $filename, $to . $filename, false, FS_CHMOD_FILE)) {
    344352                    $this->fs->chmod($to . $filename, 0644);
     
    357365                    }
    358366                }
    359             } elseif ('d' == $fileinfo['type']) {
     367            } elseif (!empty($fileinfo) && 'd' == $fileinfo['type']) {
    360368                if (!$this->fs->is_dir($to . $filename)) {
    361369                    if (!$this->fs->mkdir($to . $filename, FS_CHMOD_DIR)) {
     
    372380    }
    373381
     382    public function tc_file_system_move_dir($from, $to = '', $action = array('multicall_exit' => false)) {
     383
     384        $from = trailingslashit($from);
     385        $to = trailingslashit($to);
     386
     387        $this->init_fs();
     388        $dirlist = $this->fs->dirlist($from);
     389
     390        foreach ((array) $dirlist as $filename => $fileinfo) {
     391            if ('f' == $fileinfo['type'] && $filename != '.htaccess') {
     392
     393                // local_sync_log($filename, "----moving----filename--------");
     394
     395                if (!$this->tc_file_system_move($from . $filename, $to . $filename, true, FS_CHMOD_FILE)) {
     396
     397                    local_sync_log($filename, "----moving----false--------");
     398
     399                    $this->fs->chmod($to . $filename, 0644);
     400                    if (!$this->tc_file_system_move($from . $filename, $to . $filename, true, FS_CHMOD_FILE)) {
     401                        return true;
     402                    }
     403                }
     404                if ($action['multicall_exit'] == true) {
     405                    if(is_local_sync_timeout_cut()){
     406                        die(json_encode([
     407                            'success' =>  true,
     408                            'sync_sub_action' => 'tc_file_system_move_dir',
     409                            'sync_current_action' => $this->get_option('sync_current_action'),
     410                            'requires_next_call' => true
     411                        ]));
     412                    }
     413                }
     414            } elseif ('d' == $fileinfo['type']) {
     415                // local_sync_log($filename, "----moving----dirname--------");
     416
     417                if (!$this->fs->is_dir($to . $filename)) {
     418                    if (!$this->fs->mkdir($to . $filename, FS_CHMOD_DIR)) {
     419
     420                        local_sync_log($filename, "----moving----false----mkdir----");
     421
     422                        return true;
     423                    }
     424                }
     425                $result = $this->tc_file_system_move_dir($from . $filename, $to . $filename, $action);
     426                if (!$result) {
     427
     428                    local_sync_log($filename, "----moving----false----recdir----");
     429
     430                    return true;
     431                }
     432            }
     433        }
     434        return true;
     435    }
     436
    374437    public function tc_file_system_copy($source, $destination, $overwrite = false, $mode = 0644) {
    375438        $this->init_fs();
     
    383446    }
    384447
     448    public function tc_file_system_move($source, $destination, $overwrite = false, $mode = 0644) {
     449        if(empty($this->backup_dir)){
     450            $this->backup_dir = rtrim($this->get_backup_dir(), '/');
     451        }
     452
     453        $is_file_to_be_skipped = false;
     454        foreach($this->files_to_be_skipped_during_full_copy as $vv){
     455            if(stripos($source, $this->backup_dir . '/' . $vv) !== false){
     456                $is_file_to_be_skipped = true;
     457                break;
     458            }
     459        }
     460
     461        if($is_file_to_be_skipped){
     462            return true;
     463        }
     464
     465        if(stripos($source, $this->backup_dir . '/' . 'wp-config.php' !== false)){
     466            $current_sync_type = $this->get_option('sync_type_db_or_files');
     467            if(!empty($current_sync_type) && $current_sync_type == 'files_alone'){
     468                return true;
     469            }
     470        }
     471       
     472        local_sync_manual_debug('', 'during_moving_files', 500);
     473
     474        $this->init_fs();
     475
     476        $copy_result = $this->fs->move($source, $destination, $overwrite);
     477
     478        if (!$copy_result && !$overwrite) {
     479            return true;
     480        }
     481
     482        $copy_result = true;
     483
     484        return $copy_result;
     485    }
    385486    public function remove_garbage_files($options = array('is_restore' => false), $hard_reset = false) {
    386487        try {
     
    534635        $settings = $this->get_user_excluded_files_more_than_size();
    535636
    536         local_sync_log($settings, "--------get_user_excluded_files_more_than_size_for_echo--------");
    537637
    538638        $yes = !empty($settings['status']) ? 'checked' : '';
     
    630730                        'start_file_list_preparation' => 'Preparing files list of the live site...',
    631731                        'import_local_file_list_dump' => 'Import this site\'s files list on the live site...',
    632                         'process_file_list_difference' => 'Calculating modified files...',
    633                         'zip_creation' => 'Creating full zip of the live site...',
    634                         'zip_download' => 'Downloading the live site zip...',
    635                         'initiate_zip_extract' => 'Initiating live site zip extact...',
    636                         'continue_extract_from_bridge' => 'Extracting live zip...',
     732                        'process_file_list_difference' => 'Finding modified files...',
     733                        'send_batch_download_requests' => 'Downloading modified files...',
     734                        'copy_files_from_bridge' => 'Copying Modified Files...',
    637735                        'prepare_delete_list_table' => 'Preparing the list of files to be deleted...',
    638736                        'db_dump_restore' => 'Restoring the DB...',
     
    644742                            'header' => 'Pulling from Live Site ',
    645743                            'start_db_dump' => 'Preparing DB dump of the live site...',
    646                             'zip_creation' => 'Creating zip of the live site DB dump...',
    647                             'zip_download' => 'Downloading the live site zip...',
    648                             'initiate_zip_extract' => 'Initiating live site zip extact...',
    649                             'continue_extract_from_bridge' => 'Extracting live zip...',
     744                            'send_batch_download_requests' => 'Downloading DB dump...',
     745                            'copy_files_from_bridge' => 'Copying DB dump file...',
    650746                            'db_dump_restore' => 'Restoring the DB...',
    651747                        );
     
    658754                            'start_file_list_preparation' => 'Preparing files list of the live site...',
    659755                            'import_local_file_list_dump' => 'Import this site\'s files list on the live site...',
    660                             'process_file_list_difference' => 'Calculating modified files...',
    661                             'zip_creation' => 'Creating full zip of the live site...',
    662                             'zip_download' => 'Downloading the live site zip...',
    663                             'initiate_zip_extract' => 'Initiating live site zip extact...',
    664                             'continue_extract_from_bridge' => 'Extracting live zip...',
     756                            'process_file_list_difference' => 'Finding modified files...',
     757                            'send_batch_download_requests' => 'Downloading modified files...',
     758                            'copy_files_from_bridge' => 'Copying Modified Files...',
    665759                            'prepare_delete_list_table' => 'Preparing the list of files to be deleted...',
    666760                            'delete_files_during_restore' => 'Deleting the selected files...',
     
    690784                        'start_file_list_preparation' => 'Preparing files list of this site...',
    691785                        'import_local_file_list_dump' => 'Import live site\'s files list on this site...',
    692                         'process_file_list_difference' => 'Calculating modified files...',
    693                         'zip_creation' => 'Creating full zip of this site...',
    694                         'zip_upload' => 'Uploading this site zip...',
    695                         'initiate_zip_extract' => 'Initiating this site zip extact...',
    696                         'continue_extract_from_bridge' => 'Extracting this site zip on the live site...',
     786                        'process_file_list_difference' => 'Finding modified files...',
     787                        'batch_upload_files' => 'Uploading modified files...',
     788                        'copy_files_from_live_bridge' => 'Copying modified files...',
    697789                        'prepare_delete_list_table' => 'Preparing the list of files to be deleted...',
    698790                        'db_dump_restore' => 'Restoring the DB...',
     
    704796                            'header' => 'Pushing to Live Site ',
    705797                            'start_db_dump' => 'Preparing DB dump of this site...',
    706                             'zip_creation' => 'Creating zip of this site DB dump...',
    707                             'zip_upload' => 'Uploading this site zip...',
    708                             'initiate_zip_extract' => 'Initiating this site zip extact...',
    709                             'continue_extract_from_bridge' => 'Extracting this site zip on the live site...',
     798                            'batch_upload_files' => 'Uploading DB dump...',
     799                            'copy_files_from_live_bridge' => 'Copying DB dump file...',
    710800                            'db_dump_restore' => 'Restoring the DB...',
    711801                        );
     
    718808                            'start_file_list_preparation' => 'Preparing files list of this site...',
    719809                            'import_local_file_list_dump' => 'Import live site\'s files list on this site...',
    720                             'process_file_list_difference' => 'Calculating modified files...',
    721                             'zip_creation' => 'Creating full zip of this site...',
    722                             'zip_upload' => 'Uploading this site zip...',
    723                             'initiate_zip_extract' => 'Initiating this site zip extact...',
    724                             'continue_extract_from_bridge' => 'Extracting this site zip on the live site...',
     810                            'process_file_list_difference' => 'Finding modified files...',
     811                            'batch_upload_files' => 'Uploading modified files...',
     812                            'copy_files_from_live_bridge' => 'Copying modified files...',
    725813                            'prepare_delete_list_table' => 'Preparing the list of files to be deleted...',
    726814                            'delete_files_during_restore' => 'Deleting the selected files...',
  • local-sync/trunk/includes/class-local-sync.php

    r2248180 r2749602  
    114114        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-local-sync-restore-op.php';
    115115        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-local-sync-replace-db-links.php';
     116        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-local-sync-batch-upload.php';
     117        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-local-sync-batch-download.php';
    116118        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'local-sync-bridge/wp-modified-functions.php';
    117119        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'local-sync-bridge/class-local-sync-file-system.php';
     
    174176        $plugin_admin->update_1_0_1_handle();
    175177        $plugin_admin->update_1_0_2_handle();
     178        $plugin_admin->update_1_1_0_handle();
    176179
    177180        $plugin_admin->check_db_upgrade();
  • local-sync/trunk/local-sync-bridge/class-local-sync-file-system.php

    r2519732 r2749602  
    2828            'timeout' => 60,
    2929            'redirection' => 5,
    30             'httpversion' => '1.0',
     30            'sslverify' => false,
    3131            'blocking' => true,
    3232            'headers'     => array(
     
    304304            'timeout' => 30,
    305305            'redirection' => 5,
    306             'httpversion' => '1.0',
     306            'sslverify' => false,
    307307            'blocking' => true,
    308308            'headers'     => array(
     
    329329            return false;
    330330        }
     331        local_sync_log($file, "----multi_call_upload_using_curl----file--------");
    331332
    332333        if(!file_exists($file)){
     
    384385            $upload_action = 'handle_upload_file';
    385386
     387            // exit;
    386388            if( $file_list_or_full == 'full' ){
    387389                $upload_action = 'handle_upload_zip_file';
     
    480482        $uploadResponseHeaders[] = "HTTP/1.1 ".$info['http_code']." SOMETHING";
    481483        $uploadResponseHeaders[] = "Content-Type: ".$info['content_type'];
    482 
    483484        return $currentResult;
    484485    }
     486
     487    public function single_big_file_upload_using_curl($URL, $file_obj, &$uploadResponseHeaders, $prev_uploaded_size = 0, $wpContentURL= false, $file_list_or_full = 'full'){
     488        if (!function_exists('curl_init') || !function_exists('curl_exec')){
     489            return false;
     490        }
     491       
     492        $file = $file_obj->file_full_path;
     493
     494        local_sync_log($file, "----single_big_file_upload_using_curl----file--------");
     495
     496        if(empty($prev_uploaded_size)){
     497            $fp = fopen ($file, 'rb');
     498        } else{
     499            $fp = fopen ($file, 'rb');
     500            fseek($fp, $prev_uploaded_size);
     501        }
     502
     503        if(!$fp){
     504            $this->last_error = "Could not open zip file for upload ($file)";
     505
     506            return false;
     507        }
     508
     509        $isBreak = false;
     510        $isMultiPart = false;
     511
     512        $total_file_size = filesize($file);
     513
     514        $startRange = (empty($prev_uploaded_size)) ? 0 : $prev_uploaded_size;
     515
     516        $newEndRange = $startRange + $this->UPLOAD_CHUNK_SIZE;
     517        $endRange = ($newEndRange > $total_file_size) ? $total_file_size : $newEndRange;
     518       
     519        status_losy("Uploading Big file ".$file, $success=true, $return=false);
     520        status_losy("Total size of the file ".$total_file_size, $success=true, $return=false);
     521        status_losy("Upload start from ".$startRange, $success=true, $return=false);
     522
     523        $current_sync_unique_id = $this->local_sync_options->get_option('current_sync_unique_id');
     524
     525        $false_break = false;
     526
     527        do{
     528
     529            //read from file
     530            $currentOffest = (empty($startRange)) ? 0 : $startRange;
     531            @fseek($fp, $currentOffest, SEEK_SET);
     532            $file_data = @fread($fp, $this->UPLOAD_CHUNK_SIZE);
     533
     534            $gz_encoded_file_data = gzcompress($file_data, 9);
     535            $file_data_enc = bin2hex($gz_encoded_file_data);
     536
     537            $upload_action = 'handle_upload_single_big_file';
     538
     539            $post_arr = array(
     540                'is_local_sync' => true,
     541                'start_range' => $startRange,
     542                'end_range' => $endRange,
     543                'action' => $upload_action,
     544                'file_name' => $file_obj->add_as,
     545                'file_data' => $file_data_enc,
     546                'current_sync_unique_id' => $current_sync_unique_id,
     547            );
     548
     549            $post_arr['prod_key_random_id'] = $this->local_sync_options->get_option('prod_key_random_id');
     550
     551            $post_arr_copy = array(
     552                'is_local_sync' => true,
     553                'file_name' => $file_obj->add_as,
     554                'start_range' => $startRange,
     555                'end_range' => $endRange,
     556                'action' => $upload_action,
     557            );
     558
     559            local_sync_log($post_arr_copy, "--------post_arr_copy--------");
     560
     561            $callResponse = $this->wp_remote_post_local_sync_for_upload($URL, $post_arr);
     562
     563            $info = array(
     564                'http_code' => 200,
     565                'content_type' => 'something'
     566            );
     567
     568            // local_sync_log($info, "--------info--------");
     569
     570            if( !empty($callResponse['success']) ){
     571
     572                // local_sync_log('', "--------http_code is 206 ya--------");
     573
     574                if(!empty($callResponse['file_size']) && $callResponse['file_size'] > $total_file_size){
     575                    $this->last_error = 'Upload process corrupted.';
     576
     577                    $isBreak = true;
     578                    $false_break = true;
     579                }
     580
     581                //multiCallDownloadUsingCURL($URL, $file, $uploadResponseHeaders);
     582                $isMultiPart = true;
     583                $startRange = ftell($fp);
     584                // $startRange = $callResponse['file_size'];
     585                $endRange = ($startRange + $this->UPLOAD_CHUNK_SIZE);
     586                if($endRange >= $total_file_size){
     587                    $endRange = $total_file_size;
     588                }
     589                if($startRange == $endRange){
     590                    $isMultiPart = false;
     591                }
     592            } else {
     593                local_sync_log($callResponse, "--------multicall upload response error--------");
     594                $this->last_error = 'Upload process failed.';
     595
     596                $isBreak = true;
     597                $false_break = true;
     598            }
     599
     600            $rangeVariable = $startRange . '-' . $endRange;
     601            if(!$isBreak){
     602                $isBreak = is_local_sync_timeout_cut();
     603            }
     604        }
     605        while(!$isBreak && $isMultiPart);
     606
     607        fclose($fp);
     608
     609        if($false_break){
     610
     611            return false;
     612        }
     613       
     614        $currentResult = array();
     615
     616        $currentResult['file'] = $file;
     617        $currentResult['startRange'] = $startRange;
     618        $currentResult['endRange'] = $endRange;
     619
     620        status_losy("File Uploaded size:".$endRange, $success=true, $return=false);
     621
     622        if($isBreak == true){
     623            $currentResult['status'] = 'partiallyCompleted';
     624            $currentResult['is_upload_multi_call'] = true;
     625        }
     626
     627        if(!$isMultiPart){
     628            $currentResult['is_upload_multi_call'] = false;
     629        }
     630
     631        $uploadResponseHeaders[] = "HTTP/1.1 ".$info['http_code']." SOMETHING";
     632        $uploadResponseHeaders[] = "Content-Type: ".$info['content_type'];
     633
     634        return $currentResult;
     635    }
     636
     637    public function batch_files_upload_using_curl($URL, $files_this_batch, &$uploadResponseHeaders, $prevResult = array(), $wpContentURL= false, $file_list_or_full = 'full'){
     638        if (!function_exists('curl_init') || !function_exists('curl_exec')){
     639            return false;
     640        }
     641
     642        local_sync_log(count($files_this_batch), "----batch_upload_using_curl----file--------");
     643
     644        status_losy("Uploading batch of files ");
     645
     646        $this_files_data_to_upload = [];
     647
     648        foreach($files_this_batch as $vv){
     649
     650            // $file = '/Applications/MAMP/htdocs/wp-site/vid-2.mp4';
     651           
     652            $file = $vv->file_full_path;
     653            $fp = fopen ($file, 'rb');
     654            $this_start_range = 0;
     655            fseek($fp, $this_start_range);
     656
     657            if(!$fp){
     658                status_losy("Not able to open file for uploading ".$file, $success=true, $return=false);
     659            }
     660
     661            $isBreak = false;
     662            $isMultiPart = false;
     663
     664            $startRange = 0;
     665            $total_file_size = filesize($file);
     666            $endRange = $total_file_size;
     667
     668            $current_sync_unique_id = $this->local_sync_options->get_option('current_sync_unique_id');
     669
     670            $false_break = false;
     671
     672            //read from file
     673            $currentOffest = (empty($startRange)) ? 0 : $startRange;
     674            @fseek($fp, $currentOffest, SEEK_SET);
     675            $file_data = @fread($fp, $this->UPLOAD_CHUNK_SIZE);
     676
     677            $gz_encoded_file_data = gzcompress($file_data, 9);
     678            $file_data_enc = bin2hex($gz_encoded_file_data);
     679
     680            $file_name_base_64 = base64_encode($vv->add_as);
     681            $this_files_data_to_upload[$file_name_base_64] = $file_data_enc;
     682
     683            fclose($fp);
     684
     685            if($false_break){
     686
     687                return false;
     688            }
     689           
     690        }
     691
     692        $upload_action = 'handle_batch_upload_files';
     693
     694        $post_arr = array(
     695            'is_local_sync' => true,
     696            'start_range' => 1,
     697            'end_range' => 1,
     698            'action' => $upload_action,
     699            'files_data' => $this_files_data_to_upload,
     700            'current_sync_unique_id' => $current_sync_unique_id,
     701        );
     702
     703        $post_arr['prod_key_random_id'] = $this->local_sync_options->get_option('prod_key_random_id');
     704
     705        $post_arr_copy = array(
     706            'is_local_sync' => true,
     707            'start_range' => 1,
     708            'end_range' => 1,
     709            'action' => $upload_action,
     710        );
     711
     712        local_sync_log($post_arr_copy, "--------post_arr_copy--------");
     713
     714        $callResponse = $this->wp_remote_post_local_sync_for_upload($URL, $post_arr);
     715
     716        $info = array(
     717            'http_code' => 200,
     718            'content_type' => 'something'
     719        );
     720
     721        // local_sync_log($info, "--------info--------");
     722
     723        if( !empty($callResponse['success']) ){
     724
     725            // local_sync_log('', "--------http_code is 206 ya--------");
     726
     727            if(false){
     728                $this->last_error = 'Upload process corrupted.';
     729
     730                $isBreak = true;
     731                $false_break = true;
     732            }
     733           
     734        } else {
     735            local_sync_log($callResponse, "--------multicall upload response error--------");
     736            $this->last_error = 'Upload process failed.';
     737
     738            $isBreak = true;
     739            $false_break = true;
     740        }
     741
     742        $rangeVariable = $startRange . '-' . $endRange;
     743        if(!$isBreak){
     744            $isBreak = is_local_sync_timeout_cut();
     745        }
     746
     747        $currentResult = array();
     748
     749        $currentResult['file'] = $file;
     750        $currentResult['startRange'] = $startRange;
     751        $currentResult['endRange'] = $endRange;
     752
     753        status_losy("File Uploaded size:".$endRange, $success=true, $return=false);
     754
     755        if($isBreak == true){
     756            $currentResult['status'] = 'partiallyCompleted';
     757            $currentResult['is_upload_multi_call'] = true;
     758        }
     759
     760        if(!$isMultiPart){
     761            $currentResult['is_upload_multi_call'] = false;
     762        }
     763
     764        $uploadResponseHeaders[] = "HTTP/1.1 ".$info['http_code']." SOMETHING";
     765        $uploadResponseHeaders[] = "Content-Type: ".$info['content_type'];
     766
     767        return $currentResult;
     768    }
     769
     770    public function batch_files_download_using_curl($URL, &$uploadResponseHeaders, $wpContentURL= false, $file_list_or_full = 'full'){
     771        if (!function_exists('curl_init') || !function_exists('curl_exec')){
     772            return false;
     773        }
     774
     775        local_sync_log($files_this_batch, "----batch_files_download_using_curl----file--------");
     776
     777        status_losy("Downloading batch of files ");
     778
     779        $this_files_data_to_upload = [];
     780
     781        foreach($files_this_batch as $vv){
     782
     783            // $file = '/Applications/MAMP/htdocs/wp-site/vid-2.mp4';
     784           
     785            $file = $vv->file_full_path;
     786            $fp = fopen ($file, 'rb');
     787            $this_start_range = 0;
     788            fseek($fp, $this_start_range);
     789
     790            if(!$fp){
     791                status_losy("Not able to open file for uploading ".$file, $success=true, $return=false);
     792            }
     793
     794            $isBreak = false;
     795            $isMultiPart = false;
     796
     797            $startRange = 0;
     798            $total_file_size = filesize($file);
     799            $endRange = $total_file_size;
     800
     801            $current_sync_unique_id = $this->local_sync_options->get_option('current_sync_unique_id');
     802
     803            $false_break = false;
     804
     805            //read from file
     806            $currentOffest = (empty($startRange)) ? 0 : $startRange;
     807            @fseek($fp, $currentOffest, SEEK_SET);
     808            $file_data = @fread($fp, $this->UPLOAD_CHUNK_SIZE);
     809
     810            $gz_encoded_file_data = gzcompress($file_data, 9);
     811            $file_data_enc = bin2hex($gz_encoded_file_data);
     812
     813            $file_name_base_64 = base64_encode($vv->add_as);
     814            $this_files_data_to_upload[$file_name_base_64] = $file_data_enc;
     815
     816            fclose($fp);
     817
     818            if($false_break){
     819
     820                return false;
     821            }
     822           
     823        }
     824
     825        $upload_action = 'handle_batch_upload_files';
     826
     827        $post_arr = array(
     828            'is_local_sync' => true,
     829            'start_range' => 1,
     830            'end_range' => 1,
     831            'action' => $upload_action,
     832            'files_data' => $this_files_data_to_upload,
     833            'current_sync_unique_id' => $current_sync_unique_id,
     834        );
     835
     836        $post_arr['prod_key_random_id'] = $this->local_sync_options->get_option('prod_key_random_id');
     837
     838        $post_arr_copy = array(
     839            'is_local_sync' => true,
     840            'start_range' => 1,
     841            'end_range' => 1,
     842            'action' => $upload_action,
     843        );
     844
     845        local_sync_log($post_arr_copy, "--------post_arr_copy--------");
     846
     847        $callResponse = $this->wp_remote_post_local_sync_for_download($URL, $post_arr);
     848
     849        $info = array(
     850            'http_code' => 200,
     851            'content_type' => 'something'
     852        );
     853
     854        // local_sync_log($info, "--------info--------");
     855
     856        if( !empty($callResponse['success']) ){
     857
     858            // local_sync_log('', "--------http_code is 206 ya--------");
     859
     860            if(false){
     861                $this->last_error = 'Upload process corrupted.';
     862
     863                $isBreak = true;
     864                $false_break = true;
     865            }
     866           
     867        } else {
     868            local_sync_log($callResponse, "--------multicall upload response error--------");
     869            $this->last_error = 'Upload process failed.';
     870
     871            $isBreak = true;
     872            $false_break = true;
     873        }
     874
     875        $rangeVariable = $startRange . '-' . $endRange;
     876        if(!$isBreak){
     877            $isBreak = is_local_sync_timeout_cut();
     878        }
     879
     880        $currentResult = array();
     881
     882        $currentResult['file'] = $file;
     883        $currentResult['startRange'] = $startRange;
     884        $currentResult['endRange'] = $endRange;
     885
     886        status_losy("File Uploaded size:".$endRange, $success=true, $return=false);
     887
     888        if($isBreak == true){
     889            $currentResult['status'] = 'partiallyCompleted';
     890            $currentResult['is_upload_multi_call'] = true;
     891        }
     892
     893        if(!$isMultiPart){
     894            $currentResult['is_upload_multi_call'] = false;
     895        }
     896
     897        $uploadResponseHeaders[] = "HTTP/1.1 ".$info['http_code']." SOMETHING";
     898        $uploadResponseHeaders[] = "Content-Type: ".$info['content_type'];
     899
     900        return $currentResult;
     901    }
     902
     903    public function download_files_using_curl($URL){
     904        $current_sync_unique_id = $this->local_sync_options->get_option('current_sync_unique_id');
     905
     906        $upload_action = 'handle_batch_download_files';
     907
     908        $post_arr = array(
     909            'is_local_sync' => true,
     910            'start_range' => 1,
     911            'end_range' => 1,
     912            'action' => $upload_action,
     913            'current_sync_unique_id' => $current_sync_unique_id,
     914        );
     915
     916        $post_arr['prod_key_random_id'] = $this->local_sync_options->get_option('prod_key_random_id');
     917
     918        $post_arr_copy = array(
     919            'is_local_sync' => true,
     920            'start_range' => 1,
     921            'end_range' => 1,
     922            'action' => $upload_action,
     923        );
     924
     925        local_sync_log($post_arr_copy, "--------post_arr_copy--------");
     926
     927        $callResponse = $this->wp_remote_post_local_sync_for_download($URL, $post_arr);
     928
     929        // local_sync_log($callResponse, "--------callResponse---download_files_using_curl-----");
     930
     931        // local_sync_log('', "--------exiting by me 5--------");
     932        // exit;
     933
     934        return $callResponse;
     935    }
     936
     937    public function save_single_batch_file_during_download($URL, &$downloadResponseHeaders, $wpContentURL= false){
     938        if (!function_exists('curl_init') || !function_exists('curl_exec')){
     939            return false;
     940        }
     941
     942        if(!file_exists($file)){
     943            touch($file);
     944        }
     945
     946        if(!file_exists($file)){
     947
     948            local_sync_log($file, "--------not able to touch file 22--------");
     949
     950            $this->last_error = "Could not touch download file ($file)";
     951
     952            return false;
     953        }
     954
     955        if(empty($prevResult['file'])){
     956            $fp = fopen ($file, 'wb');
     957        } else{
     958            $file = $prevResult['file'];
     959            $fp = fopen ($file, 'rb+');
     960            fseek($fp, $prevResult['startRange']);
     961        }
     962        if(!$fp){
     963            $this->last_error = "Could not open download file ($file)";
     964
     965            local_sync_log('', "--------Could not open download file--------");
     966
     967            return false;
     968        }
     969
     970        $isBreak = false;
     971        $isMultiPart = false;
     972
     973        $startRange = (empty($prevResult['startRange']) && empty($prevResult['file']))? 0 : $prevResult['startRange'];
     974        $endRange = (empty($prevResult['endRange']) && empty($prevResult['file']))? $this->DOWNLOAD_CHUNK_SIZE : $prevResult['endRange'];
     975
     976        status_losy("Downloading file ".$URL, $success=true, $return=false);
     977        status_losy("Total size of the file ".$total_file_size, $success=true, $return=false);
     978        status_losy("Download start from ".$startRange, $success=true, $return=false);
     979
     980        do{
     981            local_sync_log('', "--------sleeping  during download--------");
     982
     983            $info = $this->away_post_call_get_file_data($URL, $fp, $startRange, $endRange, $file);
     984
     985            if($info['call_again']){
     986                //multiCallDownloadUsingCURL($URL, $file, $downloadResponseHeaders);
     987                $isMultiPart = true;
     988                $startRange = ftell($fp);
     989                $endRange = ($startRange + $this->DOWNLOAD_CHUNK_SIZE);
     990                if($endRange >= $total_file_size){
     991                    $endRange = $total_file_size;
     992                }
     993                if($startRange == $endRange){
     994                    $isMultiPart = false;
     995                }
     996            }
     997            $rangeVariable = $startRange . '-' . $endRange;
     998            $isBreak = is_local_sync_timeout_cut();
     999        }
     1000        while(!($isBreak) && $isMultiPart);
     1001
     1002        fclose($fp);
     1003       
     1004        $currentResult = array();
     1005
     1006        $this->initialize_response_array($currentResult);
     1007       
     1008        $currentResult['file'] = $file;
     1009        $currentResult['startRange'] = $startRange;
     1010        $currentResult['endRange'] = $endRange;
     1011
     1012        status_losy("File Downloaded size:".$startRange, $success=true, $return=false);
     1013
     1014        if($isBreak == true){
     1015            $currentResult['status'] = 'partiallyCompleted';
     1016            $currentResult['is_download_multi_call'] = true;
     1017        }
     1018
     1019        if(!$isMultiPart){
     1020            $currentResult['is_download_multi_call'] = false;
     1021        }
     1022
     1023        $downloadResponseHeaders[] = "HTTP/1.1 ".$info['http_code']." SOMETHING";
     1024        $downloadResponseHeaders[] = "Content-Type: ".$info['content_type'];
     1025
     1026        return $currentResult;
     1027    }
    4851028}
  • local-sync/trunk/local-sync-bridge/index.js

    r2245393 r2749602  
    33var USER_SELECTION_FILES_FOR_DELETE = {};
    44var RETRIES_LOCAL_SYNC = 0;
     5var LOCAL_SYNC_AJAX_RUNNING = false;
    56
    67function import_steps_losy(steps_parent){
     
    136137
    137138function continue_sync_from_live_losy(){
     139    if(LOCAL_SYNC_AJAX_RUNNING){
     140
     141        return;
     142    }
     143
     144    LOCAL_SYNC_AJAX_RUNNING = true;
    138145    var data = {
    139146        'action': 'sync_from_live_site',
     
    147154
    148155    jQuery.post(ajaxurl, data, function(fullResponse) {
     156        LOCAL_SYNC_AJAX_RUNNING = false;
    149157
    150158        console.log('continuing sync fullResponse', fullResponse);
  • local-sync/trunk/local-sync-bridge/index.php

    r2248180 r2749602  
    134134                    break;
    135135
     136                case 'copy_files_from_live_bridge':
     137
     138                    $this->local_sync_options->set_this_step_by_name('start_db_dump', 'done'); //hack
     139                    $this->local_sync_options->set_this_step_by_name('download_local_file_list_dump', 'done'); //hack
     140                    $this->local_sync_options->set_this_step_by_name('batch_upload_files', 'done'); //hack
     141
     142                    $this->copy_files_from_live_bridge();
     143
     144                    break;
     145
     146                case 'copy_files_from_bridge':
     147
     148                    $this->copy_files_from_live_bridge();
     149
     150                    break;
    136151                case 'prepare_delete_list_table':
    137152
     
    276291
    277292            // unlink($single_backup_file);
     293            $this->local_sync_options->set_this_current_action_step('done');
     294
     295            $this->local_sync_options->set_option('sync_sub_action', 'prepare_delete_list_table');
     296            $this->local_sync_options->set_option('sync_current_action', 'prepare_delete_list_table');
     297
     298            $this->local_sync_options->set_this_current_action_step('processing');
     299
     300            die_with_ls_signature(array(
     301                'success' =>  true,
     302                'sync_sub_action' => $this->local_sync_options->get_option('sync_sub_action'),
     303                'sync_current_action' => $this->local_sync_options->get_option('sync_current_action'),
     304                'requires_next_call' => true
     305            ));
     306        }
     307
     308        public function copy_files_from_live_bridge()   {
     309
     310            $unzip_dir = ABSPATH;
     311            // $unzip_dir = dirname(__FILE__) . '/restore_result';
     312
     313            $current_sync_unique_id = $this->local_sync_options->get_option('current_sync_unique_id');
     314           
     315            $backup_dir = WP_CONTENT_DIR . "/uploads/local_sync/backups/";
     316           
     317            local_sync_log($backup_dir, "--------backup_dir--------");
     318           
     319            $move_result = $this->local_sync_options->tc_file_system_move_dir($backup_dir, $unzip_dir);
     320
     321            local_sync_log($move_result, "--------move_result--------");
     322
     323            // if ( !empty($extracted) && !empty($extracted['break']) ) {
     324
     325            //  local_sync_log('', "--------extraction in multicall--------");
     326
     327            //  $this->local_sync_options->set_option('extract_multi_call_flags_losy', json_encode($extracted));
     328
     329            //  die_with_ls_signature(array(
     330            //      'success' =>  true,
     331            //      'sync_sub_action' => $this->local_sync_options->get_option('sync_sub_action'),
     332            //      'sync_current_action' => $this->local_sync_options->get_option('sync_current_action'),
     333            //      'requires_next_call' => true
     334            //  ));
     335            // }
     336
     337            // $this->local_sync_options->remove_tmp_dir();
     338
     339            // unlink($single_backup_file);
     340
     341            // local_sync_log($move_result, "--------exciting by me----after files copy----");
     342            // local_sync_log($move_result, "--------exciting by me--------");
     343
     344            // exit;
    278345
    279346            $this->local_sync_options->set_this_current_action_step('done');
  • local-sync/trunk/local-sync-constants.php

    r2519732 r2749602  
    7575
    7676    public function versions(){
    77         $this->define( 'LOCAL_SYNC_VERSION', '1.0.5' );
     77        $this->define( 'LOCAL_SYNC_VERSION', '1.1.0' );
    7878        $this->define( 'LOCAL_SYNC_DATABASE_VERSION', '1.0' );
    7979    }
  • local-sync/trunk/local-sync-generic-functions.php

    r2245393 r2749602  
    400400    $msg['site_type'] = $local_sync_options->get_option('site_type');
    401401
    402     local_sync_log($msg, "--------msg--------");
     402    // local_sync_log($msg, "--------msg--------");
    403403
    404404    reset_last_request_local_sync();
  • local-sync/trunk/local-sync.php

    r2519732 r2749602  
    22
    33/**
    4  * Local Sync
     4 * WP Duplicate - WordPress Migration Plugin
    55 *
    66 * @link              https://revmakx.com
     
    99 *
    1010 * @wordpress-plugin
    11  * Plugin Name:       Local Sync
     11 * Plugin Name:       WP Duplicate - WordPress Migration Plugin
    1212 * Plugin URI:        https://localsync.io
    13  * Description:       Clone live site to the local site and vice versa.
    14  * Version:           1.0.5
     13 * Description:       Easily migrate your WordPress Site from one host to another.
     14 * Version:           1.1.0
    1515 * Author:            Revmakx
    1616 * Author URI:        https://revmakx.com
Note: See TracChangeset for help on using the changeset viewer.