Plugin Directory

Changeset 2248180


Ignore:
Timestamp:
02/21/2020 01:29:26 PM (6 years ago)
Author:
localsync
Message:

release 1.0.2

Location:
local-sync/trunk
Files:
13 edited

Legend:

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

    r2245466 r2248180  
    55Requires at least: 3.0.1
    66Tested up to: 5.3.2
    7 Stable tag: 1.0.1
     7Stable tag: 1.0.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Clone live site to local site and vice versa.
     11Clone live site to the local site and vice versa.
    1212
    1313== Description ==
    1414
    15 Local Sync allows you to clone live site to the local site and live site to the local site, in the click of a button (The local site can even be setup on your local computer).
    16 The cloning process will be very fast, since it transfers only the files that are different.
     15Local Sync allows you to clone live site to the local site and live site to the local site, in the click of a button.<br>
     16The local site can even be setup on your local computer.<br>
     17The cloning process will be very fast, since it transfers only the files that are different.<br>
    1718
    1819== Installation ==
     
    4445== Changelog ==
    4546
     47= 1.0.2 =
     48*Release Date - 21 Feb 2020*
     49
     50* Fix : Pages built with elementor collapsed after cloning, in some cases.
     51* Fix : Replacing site URL failed, in some cases.
     52* Fix : Syncing on Windows OS failed.
     53
     54* Improvement : Excluding few unnecessary DB tables by default.
     55
    4656= 1.0.1 =
    4757*Release Date - 17 Feb 2020*
  • local-sync/trunk/admin/class-local-sync-admin.php

    r2245393 r2248180  
    120120            $this->app_functions->set_fresh_install_flags();
    121121
     122            $this->exclude_option = new Local_Sync_Exclude_Option();
     123            $this->exclude_option->exclude_default_tables();
     124
    122125            // $this->app_functions->prepare_and_set_prod_key();
    123126
     
    151154   
    152155            $this->app_functions->prepare_and_set_prod_key();
    153             $this->local_sync_options->set_option('local_sync_version', '1.0.1');
     156        }
     157    }
     158
     159    public function update_1_0_2_handle() {
     160
     161        $is_table_exist = $this->wpdb->query('SHOW TABLES LIKE "%'.$this->wpdb->base_prefix.'local_sync_options%"');
     162
     163        if(!$is_table_exist){
     164
     165            return;
     166        }
     167
     168        $site_type = $this->local_sync_options->get_option('site_type');
     169
     170        if(empty($site_type)){
     171
     172            return;
     173        }
     174
     175
     176        $local_sync_version_in_options_table = $this->local_sync_options->get_option('local_sync_version');
     177
     178        if( $local_sync_version_in_options_table == '1.0.1'
     179            || $local_sync_version_in_options_table == '1.0.0' ){
     180
     181            local_sync_log($local_sync_version_in_options_table, "-----running---update_1_0_2_handle--------");
     182   
     183            $this->exclude_option = new Local_Sync_Exclude_Option();
     184            $this->exclude_option->exclude_default_tables();
    154185        }
    155186    }
     
    738769            $post_body['load_images_from_live_site_settings'] = $this->local_sync_options->get_option('load_images_from_live_site_settings');
    739770
    740             $post_body['away_site_abspath'] = ABSPATH;
     771            $post_body['away_site_abspath'] = wp_normalize_path(ABSPATH);
    741772            $post_body['away_site_db_prefix'] = $this->wpdb->base_prefix;
    742773            $post_body['is_away_site_multisite'] = defined('MULTISITE') ? MULTISITE : false;
  • local-sync/trunk/admin/class-local-sync-app-functions.php

    r2245393 r2248180  
    220220            'prod_uploads_url_enc' => $this->local_sync_options->get_option('local_uploads_url_enc'),
    221221            'load_images_from_live_site_settings' => $this->local_sync_options->get_option('load_images_from_live_site_settings'),
    222             'away_site_abspath' => ABSPATH,
     222            'away_site_abspath' => wp_normalize_path(ABSPATH),
    223223            'is_away_site_multisite' => defined('MULTISITE') ? MULTISITE : false,
    224224            'away_site_id_current_site' => defined('SITE_ID_CURRENT_SITE') ? SITE_ID_CURRENT_SITE : false,
     
    734734        $response = $this->wp_remote_post_local_sync($url, $post_body);
    735735
    736         if( !empty($response) && !empty($response['success'])){
     736        if( !empty($response) && !empty($response['success']) ){
    737737            local_sync_log($response, "--------away_post_call_get_file_size--success------");
    738738
     
    740740        }
    741741
    742         if( !empty($response) && !empty($response['error']) ){
     742        if( empty($response) ||
     743            ( !empty($response) && !empty($response['error']) ) ){
    743744            local_sync_log($response, "--------away_post_call_get_file_size--error------");
    744745
     
    991992        $file_list_dump_file = rtrim($this->local_sync_options->get_backup_dir(), '/') . '/' . "local_sync_file_list_dump-$current_sync_unique_id.sql.gz";
    992993
    993         if( $start_range == 0 && file_exists($file_list_dump_file) ){
    994             @unlink($file_list_dump_file);
    995             // file_put_contents($file_list_dump_file, '');
    996         }
    997 
    998         file_put_contents($file_list_dump_file, hex2bin($file_data), FILE_APPEND);
     994        if( $start_range == 0 ){
     995            file_put_contents($file_list_dump_file, '');
     996        }
     997
     998        $fp = fopen($file_list_dump_file, 'rb+');
     999        fseek($fp, $start_range);
     1000        fwrite($fp, hex2bin($file_data));
     1001
     1002        // file_put_contents($file_list_dump_file, hex2bin($file_data), FILE_APPEND);
    9991003
    10001004        if(!file_exists($file_list_dump_file)){
     
    10281032        $full_zip_file = rtrim($this->local_sync_options->get_backup_dir(), '/') . '/' . "local_sync_files-$current_sync_unique_id.zip";
    10291033
    1030         if( $start_range == 0 && file_exists($full_zip_file) ){
    1031             // @unlink($full_zip_file);
     1034        if( $start_range == 0 ){
    10321035            file_put_contents($full_zip_file, '');
    10331036        }
    10341037
    1035         file_put_contents($full_zip_file, hex2bin($file_data), FILE_APPEND);
     1038        $fp = fopen($full_zip_file, 'rb+');
     1039        fseek($fp, $start_range);
     1040        fwrite($fp, hex2bin($file_data));
     1041
     1042        // file_put_contents($full_zip_file, hex2bin($file_data), FILE_APPEND);
    10361043
    10371044        if(!file_exists($full_zip_file)){
     
    12661273                    $is_site_connected_to_some_account = true;
    12671274
     1275                    $this->local_sync_options->set_option('site_added_once', 1);
     1276
    12681277                    // local_sync_die_with_json_encode_simple(array(
    12691278                    //  'error' =>  'Site already added'
     
    13171326
    13181327                local_sync_die_with_json_encode_simple(array(
    1319                     'error' =>  'Site is not added yet'
     1328                    'error' =>  'Site is not added yet, or connected to another Local Sync account.'
    13201329                ));
    13211330            }
  • local-sync/trunk/admin/class-local-sync-exclude-option.php

    r2245393 r2248180  
    4646                        'wponlinebackup_generations',
    4747                        'wysija_email_user_stat',
     48                        'wfknownfilelist',
     49                        'wfhits',
     50                        'wffilemods',
     51                        'wffilechanges'
    4852                    );
    4953
     
    993997    }
    994998
     999    public function exclude_default_tables()    {
     1000        $this->load_saved_keys_manually();
     1001
     1002        if (!$this->local_sync_options->get_option('non_wp_tables_excluded')) {
     1003            $tables = $this->get_all_tables();
     1004            $this->exclude_non_wp_tabes($tables);
     1005            $this->exclude_content_for_default_log_tables($tables);
     1006            $this->local_sync_options->set_option('non_wp_tables_excluded', true);
     1007        }
     1008    }
     1009
    9951010    public function get_tables($exc_wp_tables = false) {
    9961011        $this->load_saved_keys_manually();
  • local-sync/trunk/admin/class-local-sync-files-op.php

    r2245393 r2248180  
    210210
    211211        if (!$iterator->isReadable()) {
     212
     213            local_sync_log($file, "--------not readable file--------");
     214
    212215            return ;
    213216        }
  • local-sync/trunk/admin/class-local-sync-restore-op.php

    r2245393 r2248180  
    533533    }
    534534
     535    public function set_local_sync_sql_mode_variables() {
     536        local_sync_log('', "--------altering foreign key mode--------");
     537        // $this->wpdb->query("SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0");
     538        $this->wpdb->query("SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=OFF;");
     539        local_sync_log($this->wpdb->last_error,'-----------$last_error----set_local_sync_sql_mode_variables------------');
     540        $this->wpdb->query("SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO';");
     541
     542    }
     543
     544    public function reset_local_sync_sql_mode_variables() {
     545        local_sync_log('', "--------resetting foreign key mode--------");
     546        // $this->wpdb->query("SET UNIQUE_CHECKS=@@OLD_UNIQUE_CHECKS");
     547        $this->wpdb->query("SET FOREIGN_KEY_CHECKS=@@OLD_FOREIGN_KEY_CHECKS");
     548        $this->wpdb->query("SET SQL_MODE=@@OLD_SQL_MODE");
     549    }
     550
    535551    public function import_sql_file($file_name, $prev_index, $replace_collation = false, $is_local_file_list_dump = false){
    536552        local_sync_log(func_get_args(), "--------------" . __FUNCTION__ . "------------------");
     
    608624
    609625            if(!empty($replaceQuery['prevExec']) && !empty($tempQuery)) {
     626
     627                local_sync_log('', "--------prevExec---coming-----");
    610628
    611629                // local_sync_log(strlen($tempQuery), "--------tempQuery--length---exec---");
     
    744762                    $urlPort = '';
    745763                    $urlPath = '';
    746                     if (isset($fromURL['port']) && $fromURL['port'] != '')
     764
     765                    // $url2Port = '';
     766                    // $url2Path = '';
     767
     768                    if (isset($fromURL['port']) && $fromURL['port'] != ''){
    747769                        $urlPort = ":".$fromURL['port'];
    748                     if (isset($fromURL['path']) && $fromURL['path'] != '')
     770                    }
     771                    if (isset($fromURL['path']) && $fromURL['path'] != ''){
    749772                        $urlPath = $fromURL['path'];
     773                    }
     774
     775                    // if (isset($toURL['port']) && $toURL['port'] != ''){
     776                    //  $url2Port = ":".$toURL['port'];
     777                    // }
     778                    // if (isset($toURL['path']) && $toURL['path'] != ''){
     779                    //  $url2Path = $toURL['path'];
     780                    // }
     781
    750782                    $fromHTTPS = "https://".$fromURL['host'].$urlPort.$urlPath;
    751783                    $fromHTTP = "http://".$fromURL['host'].$urlPort.$urlPath;
    752                     $withoutProtocolFrom = "//".$fromURL['host'].$urlPort.$urlPath;
    753                     $replace = $this->findAndReplace(array($fromHTTPS, $fromHTTP, $withoutProtocolFrom), $to, $val);
     784
     785                    // $withoutProtocolFrom = "//".$fromURL['host'].$urlPort.$urlPath;
     786
     787                    if(empty($urlPath)){
     788                        $urlPathEsc = $urlPath;
     789                    } else {
     790                        $urlPathEsc = "\\" . $urlPath;
     791                    }
     792                    $withoutProtocolFrom = "https:\\/\\/".$fromURL['host'].$urlPort.$urlPathEsc;
     793                    $withoutProtocolFrom2 = "http:\\/\\/".$fromURL['host'].$urlPort.$urlPathEsc;
     794
     795                    // $new_from = $fromURL['host'].$urlPort.$urlPath;
     796                    // $new_to = $toURL['host'].$url2Port.$url2Path;
     797
     798                    // $replace = $this->findAndReplace($new_from, $new_to, $val);
     799
     800                    $replace = $this->findAndReplace(array($fromHTTPS, $fromHTTP, $withoutProtocolFrom, $withoutProtocolFrom2), $to, $val);
    754801                }
    755802
     
    796843            // }
    797844
     845            // local_sync_log($from, "-----search_and_replace_urls_new---fromURL--------");
     846            // local_sync_log($to, "--------toURL--------");
     847
    798848            $retArray['q'] = $haystack;
    799849            $retArray['exec'] = 1;
     
    827877
    828878    public function stripallslashes($string) {
    829         $string = str_ireplace(array('\"',"\'",'\r','\n',"\\\\"),array('"',"'","\r","\n","\\"),$string);
     879        $string = str_ireplace( array('\"', "\'", '\\\\n', '\\\\r', '\r', '\n', '\\\\', '##nn', '##rr'),
     880                                array('"',  "'",   '##nn',  '##rr', "\r", "\n",   "\\",  '\\n',  '\\r'),
     881                                $string );
    830882
    831883        return $string;
     
    15521604            }
    15531605
     1606            if ($file == '/wp-config.php') {
     1607
     1608                local_sync_log('', "--------ignoring wp config file in delete list table----");
     1609
     1610                continue;
     1611            }
     1612
    15541613            // local_sync_log($file, "--------adding file--prepare_delete_list_table------");
    15551614
     
    17301789        foreach ($selected_files as $key => $value) {
    17311790            if(!empty($value) && $value != 'false'){
     1791                if($key == '/wp-config.php'){
     1792                   
     1793                    continue;
     1794                }
    17321795                $selected_files_str .= ',"'.$key.'"';
    17331796            }
  • local-sync/trunk/admin/js/local-sync-admin.js

    r2245393 r2248180  
    33var SELECTED_MODIFIED_FILES = {};
    44var USER_SELECTION_MODIFIED_FILES = {};
     5var SHOW_FS_METHOD_ERROR_LOSY = false;
    56
    67function import_steps_losy(steps_parent){
     
    5758        jQuery('.steps-result-losy').html(stepsHTML);
    5859
     60        if(SHOW_FS_METHOD_ERROR_LOSY){
     61
     62            jQuery('.bridge_error_losy').html(SHOW_FS_METHOD_ERROR_LOSY).show();
     63
     64            SHOW_FS_METHOD_ERROR_LOSY = false;
     65
     66            return;
     67        }
     68
    5969        jQuery('.steps-result-losy p:nth-child(2)').removeClass().addClass('processing');
    6070    });
     
    237247
    238248function parse_local_sync_response_from_raw_data(raw_response){
     249
     250    if(raw_response.indexOf('Please enter your FTP credentials to proceed') > 0){
     251
     252        SHOW_FS_METHOD_ERROR_LOSY = 'Please enter <strong>define("FS_METHOD", "direct");</strong> <br> in wp-config.php file and try again.';
     253    }
     254
    239255    return raw_response.split('<LOCAL_SYNC_START>').pop().split('<LOCAL_SYNC_END>').shift();
    240256}
     
    473489
    474490            if(typeof response.error != 'undefined' || typeof response.success == 'undefined' || !response.success ){
     491                SHOW_FS_METHOD_ERROR_LOSY = response.error || "Error";
    475492                jQuery('.bridge_error_losy').text(response.error).show();
    476493
     
    541558
    542559            if(typeof response.error != 'undefined' || typeof response.success == 'undefined' || !response.success ){
     560                SHOW_FS_METHOD_ERROR_LOSY = response.error || "Error";
    543561                jQuery('.bridge_error_losy').text(response.error).show();
    544562
  • local-sync/trunk/includes/class-local-sync-options.php

    r2245393 r2248180  
    251251        $folder_name = trailingslashit($folder_name);
    252252
    253         // local_sync_log($folder_name, "----deleting----folder_name--------");
    254 
    255         if(strlen($folder_name) < 10 || strlen(ABSPATH) < 10){
     253        local_sync_log($folder_name, "----deleting----folder_name--------");
     254
     255        $normalized_abspath = wp_normalize_path(ABSPATH);
     256
     257        if(strlen($folder_name) < 10 || strlen($normalized_abspath) < 10){
    256258
    257259            return;
    258260        }
    259261
    260         if(stripos($folder_name, ABSPATH) === false){
     262        if(stripos($folder_name, $normalized_abspath) === false){
     263
     264            return;
     265        }
     266
     267        if(stripos($folder_name, $normalized_abspath . 'wp-config.php') !== false){
    261268
    262269            return;
     
    288295                    continue;
    289296                }
     297
     298                local_sync_log($folder_name . $filename, "------deleting----------");
    290299
    291300                $this->fs->delete($folder_name . $filename);
  • local-sync/trunk/includes/class-local-sync.php

    r2245393 r2248180  
    173173
    174174        $plugin_admin->update_1_0_1_handle();
     175        $plugin_admin->update_1_0_2_handle();
    175176
    176177        $plugin_admin->check_db_upgrade();
  • local-sync/trunk/local-sync-bridge/class-local-sync-file-system.php

    r2245393 r2248180  
    4848        // local_sync_log($response, "-----wp_remote_post_local_sync_for_download---response-----$url---");
    4949
    50         return json_decode($response, true);
     50        $json_decoded_response = json_decode($response, true);
     51
     52        if(empty($json_decoded_response)){
     53            local_sync_log($post_body, "--------post_body--wp_remote_post_local_sync_for_download--false----");
     54        }
     55
     56        return $json_decoded_response;
    5157    }
    5258
     
    5561        local_sync_log($file_name, "--------away_post_call_get_file_data--------");
    5662
    57         $file_name_from_abspath = str_replace(ABSPATH, '', $file_name);
     63        $dir_separator_replaced_abspath = wp_normalize_path(ABSPATH);
     64        $file_name_from_abspath = str_replace($dir_separator_replaced_abspath, '', $file_name);
    5865
    5966        $post_body = array(
     
    6774        $response = $this->wp_remote_post_local_sync_for_download($url, $post_body);
    6875
    69         if( !empty($response) && !empty($response['error']) ){
    70             local_sync_log($response, "--------away_post_call_get_file_size--error------");
     76        if( empty($response) ||
     77            ( !empty($response) && !empty($response['error']) ) ){
     78            local_sync_log($response, "--------away_post_call_get_file_data--error------");
    7179
    7280            local_sync_die_with_json_encode(array(
     
    101109        }
    102110
    103         local_sync_log($call_again, "-----away_post_call_get_file_data---call_again-----$file_name-$startRange-$endRange--");
     111        local_sync_log($call_again, "-----away_post_call_get_file_data---call_again-----$file_name-$startRange-$endRange------$file_name_from_abspath------");
     112        local_sync_log($dir_separator_replaced_abspath, "-----abspath is-----");
    104113
    105114        return array(
     
    305314        );
    306315
    307         local_sync_log($response, "--------wp_remote_post_local_sync_for_upload-full_response-------");
     316        // local_sync_log($response, "--------wp_remote_post_local_sync_for_upload-full_response-------");
    308317
    309318        $response = wp_remote_retrieve_body( $response );
     
    359368
    360369        $current_sync_unique_id = $this->local_sync_options->get_option('current_sync_unique_id');
     370
     371        $false_break = false;
    361372
    362373        do{
     
    410421                // local_sync_log('', "--------http_code is 206 ya--------");
    411422
     423                if(!empty($callResponse['file_size']) && $callResponse['file_size'] > $total_file_size){
     424                    $this->last_error = 'Upload process corrupted.';
     425
     426                    $isBreak = true;
     427                    $false_break = true;
     428                }
     429
    412430                //multiCallDownloadUsingCURL($URL, $file, $uploadResponseHeaders);
    413431                $isMultiPart = true;
    414432                $startRange = ftell($fp);
     433                // $startRange = $callResponse['file_size'];
    415434                $endRange = ($startRange + $this->UPLOAD_CHUNK_SIZE);
    416435                if($endRange >= $total_file_size){
     
    422441            } else {
    423442                local_sync_log($callResponse, "--------multicall upload response error--------");
     443                $this->last_error = 'Upload process failed.';
     444
     445                $isBreak = true;
     446                $false_break = true;
    424447            }
    425448
    426449            $rangeVariable = $startRange . '-' . $endRange;
    427             $isBreak = is_local_sync_timeout_cut();
     450            if(!$isBreak){
     451                $isBreak = is_local_sync_timeout_cut();
     452            }
    428453        }
    429454        while(!($isBreak) && $isMultiPart);
    430455
    431456        fclose($fp);
     457
     458        if($false_break){
     459
     460            return false;
     461        }
    432462       
    433463        $currentResult = array();
    434464
    435         $this->initialize_response_array($currentResult);
    436        
    437465        $currentResult['file'] = $file;
    438466        $currentResult['startRange'] = $startRange;
  • local-sync/trunk/local-sync-bridge/index.php

    r2245393 r2248180  
    402402            $prev_index = $this->local_sync_options->get_option('restore_db_index');
    403403
     404            $this->restore_app_functions->set_local_sync_sql_mode_variables();
    404405            $response = $this->restore_app_functions->import_sql_file($file_name, $prev_index);
     406            $this->restore_app_functions->reset_local_sync_sql_mode_variables();
    405407
    406408            local_sync_log($response, '--------database_restore response--------');
  • local-sync/trunk/local-sync-constants.php

    r2245393 r2248180  
    7575
    7676    public function versions(){
    77         $this->define( 'LOCAL_SYNC_VERSION', '1.0.1' );
     77        $this->define( 'LOCAL_SYNC_VERSION', '1.0.2' );
    7878        $this->define( 'LOCAL_SYNC_DATABASE_VERSION', '1.0' );
    7979    }
  • local-sync/trunk/local-sync.php

    r2245393 r2248180  
    1212 * Plugin URI:        https://localsync.io
    1313 * Description:       Clone live site to the local site and vice versa.
    14  * Version:           1.0.1
    15  * Author:            Local Sync
     14 * Version:           1.0.2
     15 * Author:            Revmakx
    1616 * Author URI:        https://revmakx.com
    1717 * License:           GPL-2.0+
Note: See TracChangeset for help on using the changeset viewer.