Changeset 2248180
- Timestamp:
- 02/21/2020 01:29:26 PM (6 years ago)
- Location:
- local-sync/trunk
- Files:
-
- 13 edited
-
README.txt (modified) (2 diffs)
-
admin/class-local-sync-admin.php (modified) (3 diffs)
-
admin/class-local-sync-app-functions.php (modified) (7 diffs)
-
admin/class-local-sync-exclude-option.php (modified) (2 diffs)
-
admin/class-local-sync-files-op.php (modified) (1 diff)
-
admin/class-local-sync-restore-op.php (modified) (7 diffs)
-
admin/js/local-sync-admin.js (modified) (5 diffs)
-
includes/class-local-sync-options.php (modified) (2 diffs)
-
includes/class-local-sync.php (modified) (1 diff)
-
local-sync-bridge/class-local-sync-file-system.php (modified) (8 diffs)
-
local-sync-bridge/index.php (modified) (1 diff)
-
local-sync-constants.php (modified) (1 diff)
-
local-sync.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
local-sync/trunk/README.txt
r2245466 r2248180 5 5 Requires at least: 3.0.1 6 6 Tested up to: 5.3.2 7 Stable tag: 1.0. 17 Stable tag: 1.0.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 11 Clone live site to local site and vice versa.11 Clone live site to the local site and vice versa. 12 12 13 13 == Description == 14 14 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. 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.<br> 16 The local site can even be setup on your local computer.<br> 17 The cloning process will be very fast, since it transfers only the files that are different.<br> 17 18 18 19 == Installation == … … 44 45 == Changelog == 45 46 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 46 56 = 1.0.1 = 47 57 *Release Date - 17 Feb 2020* -
local-sync/trunk/admin/class-local-sync-admin.php
r2245393 r2248180 120 120 $this->app_functions->set_fresh_install_flags(); 121 121 122 $this->exclude_option = new Local_Sync_Exclude_Option(); 123 $this->exclude_option->exclude_default_tables(); 124 122 125 // $this->app_functions->prepare_and_set_prod_key(); 123 126 … … 151 154 152 155 $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(); 154 185 } 155 186 } … … 738 769 $post_body['load_images_from_live_site_settings'] = $this->local_sync_options->get_option('load_images_from_live_site_settings'); 739 770 740 $post_body['away_site_abspath'] = ABSPATH;771 $post_body['away_site_abspath'] = wp_normalize_path(ABSPATH); 741 772 $post_body['away_site_db_prefix'] = $this->wpdb->base_prefix; 742 773 $post_body['is_away_site_multisite'] = defined('MULTISITE') ? MULTISITE : false; -
local-sync/trunk/admin/class-local-sync-app-functions.php
r2245393 r2248180 220 220 'prod_uploads_url_enc' => $this->local_sync_options->get_option('local_uploads_url_enc'), 221 221 '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), 223 223 'is_away_site_multisite' => defined('MULTISITE') ? MULTISITE : false, 224 224 'away_site_id_current_site' => defined('SITE_ID_CURRENT_SITE') ? SITE_ID_CURRENT_SITE : false, … … 734 734 $response = $this->wp_remote_post_local_sync($url, $post_body); 735 735 736 if( !empty($response) && !empty($response['success']) ){736 if( !empty($response) && !empty($response['success']) ){ 737 737 local_sync_log($response, "--------away_post_call_get_file_size--success------"); 738 738 … … 740 740 } 741 741 742 if( !empty($response) && !empty($response['error']) ){ 742 if( empty($response) || 743 ( !empty($response) && !empty($response['error']) ) ){ 743 744 local_sync_log($response, "--------away_post_call_get_file_size--error------"); 744 745 … … 991 992 $file_list_dump_file = rtrim($this->local_sync_options->get_backup_dir(), '/') . '/' . "local_sync_file_list_dump-$current_sync_unique_id.sql.gz"; 992 993 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); 999 1003 1000 1004 if(!file_exists($file_list_dump_file)){ … … 1028 1032 $full_zip_file = rtrim($this->local_sync_options->get_backup_dir(), '/') . '/' . "local_sync_files-$current_sync_unique_id.zip"; 1029 1033 1030 if( $start_range == 0 && file_exists($full_zip_file) ){ 1031 // @unlink($full_zip_file); 1034 if( $start_range == 0 ){ 1032 1035 file_put_contents($full_zip_file, ''); 1033 1036 } 1034 1037 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); 1036 1043 1037 1044 if(!file_exists($full_zip_file)){ … … 1266 1273 $is_site_connected_to_some_account = true; 1267 1274 1275 $this->local_sync_options->set_option('site_added_once', 1); 1276 1268 1277 // local_sync_die_with_json_encode_simple(array( 1269 1278 // 'error' => 'Site already added' … … 1317 1326 1318 1327 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.' 1320 1329 )); 1321 1330 } -
local-sync/trunk/admin/class-local-sync-exclude-option.php
r2245393 r2248180 46 46 'wponlinebackup_generations', 47 47 'wysija_email_user_stat', 48 'wfknownfilelist', 49 'wfhits', 50 'wffilemods', 51 'wffilechanges' 48 52 ); 49 53 … … 993 997 } 994 998 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 995 1010 public function get_tables($exc_wp_tables = false) { 996 1011 $this->load_saved_keys_manually(); -
local-sync/trunk/admin/class-local-sync-files-op.php
r2245393 r2248180 210 210 211 211 if (!$iterator->isReadable()) { 212 213 local_sync_log($file, "--------not readable file--------"); 214 212 215 return ; 213 216 } -
local-sync/trunk/admin/class-local-sync-restore-op.php
r2245393 r2248180 533 533 } 534 534 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 535 551 public function import_sql_file($file_name, $prev_index, $replace_collation = false, $is_local_file_list_dump = false){ 536 552 local_sync_log(func_get_args(), "--------------" . __FUNCTION__ . "------------------"); … … 608 624 609 625 if(!empty($replaceQuery['prevExec']) && !empty($tempQuery)) { 626 627 local_sync_log('', "--------prevExec---coming-----"); 610 628 611 629 // local_sync_log(strlen($tempQuery), "--------tempQuery--length---exec---"); … … 744 762 $urlPort = ''; 745 763 $urlPath = ''; 746 if (isset($fromURL['port']) && $fromURL['port'] != '') 764 765 // $url2Port = ''; 766 // $url2Path = ''; 767 768 if (isset($fromURL['port']) && $fromURL['port'] != ''){ 747 769 $urlPort = ":".$fromURL['port']; 748 if (isset($fromURL['path']) && $fromURL['path'] != '') 770 } 771 if (isset($fromURL['path']) && $fromURL['path'] != ''){ 749 772 $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 750 782 $fromHTTPS = "https://".$fromURL['host'].$urlPort.$urlPath; 751 783 $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); 754 801 } 755 802 … … 796 843 // } 797 844 845 // local_sync_log($from, "-----search_and_replace_urls_new---fromURL--------"); 846 // local_sync_log($to, "--------toURL--------"); 847 798 848 $retArray['q'] = $haystack; 799 849 $retArray['exec'] = 1; … … 827 877 828 878 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 ); 830 882 831 883 return $string; … … 1552 1604 } 1553 1605 1606 if ($file == '/wp-config.php') { 1607 1608 local_sync_log('', "--------ignoring wp config file in delete list table----"); 1609 1610 continue; 1611 } 1612 1554 1613 // local_sync_log($file, "--------adding file--prepare_delete_list_table------"); 1555 1614 … … 1730 1789 foreach ($selected_files as $key => $value) { 1731 1790 if(!empty($value) && $value != 'false'){ 1791 if($key == '/wp-config.php'){ 1792 1793 continue; 1794 } 1732 1795 $selected_files_str .= ',"'.$key.'"'; 1733 1796 } -
local-sync/trunk/admin/js/local-sync-admin.js
r2245393 r2248180 3 3 var SELECTED_MODIFIED_FILES = {}; 4 4 var USER_SELECTION_MODIFIED_FILES = {}; 5 var SHOW_FS_METHOD_ERROR_LOSY = false; 5 6 6 7 function import_steps_losy(steps_parent){ … … 57 58 jQuery('.steps-result-losy').html(stepsHTML); 58 59 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 59 69 jQuery('.steps-result-losy p:nth-child(2)').removeClass().addClass('processing'); 60 70 }); … … 237 247 238 248 function 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 239 255 return raw_response.split('<LOCAL_SYNC_START>').pop().split('<LOCAL_SYNC_END>').shift(); 240 256 } … … 473 489 474 490 if(typeof response.error != 'undefined' || typeof response.success == 'undefined' || !response.success ){ 491 SHOW_FS_METHOD_ERROR_LOSY = response.error || "Error"; 475 492 jQuery('.bridge_error_losy').text(response.error).show(); 476 493 … … 541 558 542 559 if(typeof response.error != 'undefined' || typeof response.success == 'undefined' || !response.success ){ 560 SHOW_FS_METHOD_ERROR_LOSY = response.error || "Error"; 543 561 jQuery('.bridge_error_losy').text(response.error).show(); 544 562 -
local-sync/trunk/includes/class-local-sync-options.php
r2245393 r2248180 251 251 $folder_name = trailingslashit($folder_name); 252 252 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){ 256 258 257 259 return; 258 260 } 259 261 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){ 261 268 262 269 return; … … 288 295 continue; 289 296 } 297 298 local_sync_log($folder_name . $filename, "------deleting----------"); 290 299 291 300 $this->fs->delete($folder_name . $filename); -
local-sync/trunk/includes/class-local-sync.php
r2245393 r2248180 173 173 174 174 $plugin_admin->update_1_0_1_handle(); 175 $plugin_admin->update_1_0_2_handle(); 175 176 176 177 $plugin_admin->check_db_upgrade(); -
local-sync/trunk/local-sync-bridge/class-local-sync-file-system.php
r2245393 r2248180 48 48 // local_sync_log($response, "-----wp_remote_post_local_sync_for_download---response-----$url---"); 49 49 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; 51 57 } 52 58 … … 55 61 local_sync_log($file_name, "--------away_post_call_get_file_data--------"); 56 62 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); 58 65 59 66 $post_body = array( … … 67 74 $response = $this->wp_remote_post_local_sync_for_download($url, $post_body); 68 75 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------"); 71 79 72 80 local_sync_die_with_json_encode(array( … … 101 109 } 102 110 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-----"); 104 113 105 114 return array( … … 305 314 ); 306 315 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-------"); 308 317 309 318 $response = wp_remote_retrieve_body( $response ); … … 359 368 360 369 $current_sync_unique_id = $this->local_sync_options->get_option('current_sync_unique_id'); 370 371 $false_break = false; 361 372 362 373 do{ … … 410 421 // local_sync_log('', "--------http_code is 206 ya--------"); 411 422 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 412 430 //multiCallDownloadUsingCURL($URL, $file, $uploadResponseHeaders); 413 431 $isMultiPart = true; 414 432 $startRange = ftell($fp); 433 // $startRange = $callResponse['file_size']; 415 434 $endRange = ($startRange + $this->UPLOAD_CHUNK_SIZE); 416 435 if($endRange >= $total_file_size){ … … 422 441 } else { 423 442 local_sync_log($callResponse, "--------multicall upload response error--------"); 443 $this->last_error = 'Upload process failed.'; 444 445 $isBreak = true; 446 $false_break = true; 424 447 } 425 448 426 449 $rangeVariable = $startRange . '-' . $endRange; 427 $isBreak = is_local_sync_timeout_cut(); 450 if(!$isBreak){ 451 $isBreak = is_local_sync_timeout_cut(); 452 } 428 453 } 429 454 while(!($isBreak) && $isMultiPart); 430 455 431 456 fclose($fp); 457 458 if($false_break){ 459 460 return false; 461 } 432 462 433 463 $currentResult = array(); 434 464 435 $this->initialize_response_array($currentResult);436 437 465 $currentResult['file'] = $file; 438 466 $currentResult['startRange'] = $startRange; -
local-sync/trunk/local-sync-bridge/index.php
r2245393 r2248180 402 402 $prev_index = $this->local_sync_options->get_option('restore_db_index'); 403 403 404 $this->restore_app_functions->set_local_sync_sql_mode_variables(); 404 405 $response = $this->restore_app_functions->import_sql_file($file_name, $prev_index); 406 $this->restore_app_functions->reset_local_sync_sql_mode_variables(); 405 407 406 408 local_sync_log($response, '--------database_restore response--------'); -
local-sync/trunk/local-sync-constants.php
r2245393 r2248180 75 75 76 76 public function versions(){ 77 $this->define( 'LOCAL_SYNC_VERSION', '1.0. 1' );77 $this->define( 'LOCAL_SYNC_VERSION', '1.0.2' ); 78 78 $this->define( 'LOCAL_SYNC_DATABASE_VERSION', '1.0' ); 79 79 } -
local-sync/trunk/local-sync.php
r2245393 r2248180 12 12 * Plugin URI: https://localsync.io 13 13 * Description: Clone live site to the local site and vice versa. 14 * Version: 1.0. 115 * Author: Local Sync14 * Version: 1.0.2 15 * Author: Revmakx 16 16 * Author URI: https://revmakx.com 17 17 * License: GPL-2.0+
Note: See TracChangeset
for help on using the changeset viewer.