Changeset 2005302
- Timestamp:
- 01/02/2019 06:13:49 PM (7 years ago)
- Location:
- wps-backup
- Files:
-
- 36 added
- 3 edited
-
tags/0.5.1 (added)
-
tags/0.5.1/LICENSE.txt (added)
-
tags/0.5.1/README.txt (added)
-
tags/0.5.1/includes (added)
-
tags/0.5.1/includes/css (added)
-
tags/0.5.1/includes/css/wpsc_backup_styles.css (added)
-
tags/0.5.1/includes/data_actions (added)
-
tags/0.5.1/includes/data_actions/generate_backup.php (added)
-
tags/0.5.1/includes/data_actions/restore_backup.php (added)
-
tags/0.5.1/includes/data_actions/wpsc_data_management.php (added)
-
tags/0.5.1/includes/wpsc_backup_page.php (added)
-
tags/0.5.1/includes/wpsc_backup_setup.php (added)
-
tags/0.5.1/includes/wpsc_instructions_tab.php (added)
-
tags/0.5.1/index.php (added)
-
tags/0.5.1/wps_backup.php (added)
-
tags/0.6 (added)
-
tags/0.6/LICENSE.txt (added)
-
tags/0.6/README.txt (added)
-
tags/0.6/includes (added)
-
tags/0.6/includes/css (added)
-
tags/0.6/includes/css/wpsc_backup_styles.css (added)
-
tags/0.6/includes/data_actions (added)
-
tags/0.6/includes/data_actions/generate_backup.php (added)
-
tags/0.6/includes/data_actions/restore_backup.php (added)
-
tags/0.6/includes/data_actions/restore_backup_files_list.php (added)
-
tags/0.6/includes/data_actions/restore_backup_remote.php (added)
-
tags/0.6/includes/data_actions/restore_cloud_db_backup.php (added)
-
tags/0.6/includes/data_actions/setup_backup.php (added)
-
tags/0.6/includes/data_actions/wpsc_class_data_management.php (added)
-
tags/0.6/includes/data_actions/wpsc_data_management.php (added)
-
tags/0.6/includes/wpsc_backup_functions.php (added)
-
tags/0.6/includes/wpsc_backup_page.php (added)
-
tags/0.6/includes/wpsc_backup_setup.php (added)
-
tags/0.6/includes/wpsc_instructions_tab.php (added)
-
tags/0.6/index.php (added)
-
tags/0.6/wps_backup.php (added)
-
trunk/README.txt (modified) (1 diff)
-
trunk/includes/data_actions/wpsc_class_data_management.php (modified) (1 diff)
-
trunk/includes/wpsc_backup_functions.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wps-backup/trunk/README.txt
r2003439 r2005302 35 35 1. Make the backup of your current website database 36 36 1. Restore the backup you have previously saved 37 1. Select from cloud backups from WPScomplete.com 37 38 38 39 == Changelog == -
wps-backup/trunk/includes/data_actions/wpsc_class_data_management.php
r2003439 r2005302 130 130 return $data; 131 131 } 132 133 134 135 // public function process_part_file_download_transfer( $directory , $data , $filename , $part ) { 136 // $file_data = base64_decode( $data ); 137 // $create_file = $directory."/".$filename; 138 // $db_file = fopen( $create_file ,'w' ); 139 // $bytes = fwrite( $db_file , $file_data ); 140 // $close = fclose( $db_file ); 141 // return $data; 142 // } 132 143 133 144 -
wps-backup/trunk/includes/wpsc_backup_functions.php
r2003439 r2005302 29 29 } 30 30 wp_safe_redirect( $url ); 31 32 31 } 33 32 add_action('WPS_action_get-url-database-backups','wpsc_request_url_backups'); … … 44 43 } 45 44 wp_safe_redirect( $url ); 46 47 } 48 45 } 46 add_action('WPS_action_restore-url-database-backups','wpsc_restore_cloud_database_backup'); 49 47 50 48 // Delete backup api … … 64 62 add_action('WPS_action_delete-backup-api-key','wpsc_delete_backup_api_key'); 65 63 64 /* 65 * 66 * Download and restore database file 67 * 68 */ 69 66 70 function wpsc_retreve_db_file(){ 67 71 global $wpdb; 72 73 // echo "running the new thing"; 68 74 $description = 'wpscomplete_base_api'; 69 75 70 71 // var_dump($description);72 76 $keys = $wpdb->get_row( 73 77 $wpdb->prepare( " … … 79 83 80 84 $url = 'https://wpscomplete.com/wp-json/wpscb/v1/retrieve_db_backup_file/'; 85 86 $site_url = site_url(); 87 $site_url = substr($site_url, 8); 81 88 82 89 // api request to the server … … 97 104 'backup_site_url' => $_POST['url'], 98 105 'required_backup_file' => $_POST['required_backup'], 106 'current_site_url' => $site_url, 107 'file_part' => 0, 99 108 ), 100 109 'cookies' => array() … … 111 120 } 112 121 113 $data = $response['body']; 114 $file_name = $_GET['required_backup']; 122 123 $file_size = base64_decode( $response['body'] ); 124 settype($file_size, 'int'); 125 126 var_dump("File size: ",$file_size); 115 127 116 128 $data_management = new WPS_data_management; 117 129 $dirpath = $data_management->setup_directory_for_restoring(); 130 // var_dump($dirpath); 131 132 $file_name = $_GET['required_backup']; 133 $download_file = $dirpath."/".$file_name; 134 135 // var_dump($download_file); 136 137 138 $db_file = fopen( $download_file ,'w' ); 139 $file_divide = 10000; 140 141 $i = 1; 142 $divides = intdiv($file_size, $file_divide); 143 144 var_dump(" Divides: ",$divides); 145 146 for( $i = 1; $i <= ( $divides + 1 ); $i++){ 147 148 // api to request file section 149 // api request to the server 150 $response = wp_remote_post( $url, array( 151 'method' => 'POST', 152 'timeout' => 45, 153 'redirection' => 5, 154 'httpversion' => '1.0', 155 'blocking' => true, 156 // 'headers' => array( 157 // 'accept' => 'application/json', // The API returns JSON 158 // 'content-type' => 'application/binary', // Set content type to binary 159 // ), 160 'headers' => array(), 161 'body' => array( 162 'consumer_key' => $keys['consumer_key'], 163 'consumer_secret' => $keys['consumer_secret'], 164 'backup_site_url' => $_POST['url'], 165 'required_backup_file' => $_POST['required_backup'], 166 'current_site_url' => $site_url, 167 'file_part' => $i, 168 ), 169 'cookies' => array() 170 ) 171 ); 172 173 $file_data = base64_decode( $response['body'] ); 174 $bytes = fwrite( $db_file , $file_data ); 175 } 176 $close = fclose( $db_file ); 177 //check our file sizes are correct 178 if( $file_size != filesize( $download_file ) ){ 179 return 'file_hasnt_completed_download_correctly'; 180 } 181 // return; 118 182 $result = $data_management->process_file_download_transfer( $dirpath, $data , $file_name ); 119 183 120 184 //check the file is ready to be used 121 185 $download_complete = $data_management->check_backup_db_file_exists( 0 , $dirpath , $file_name ); 122 186 $download_complete = false; 123 187 if($download_complete){ 124 188 $unzip = $data_management->unzip_file( $dirpath , $file_name ); 125 if( $unzip){189 if( $unzip ){ 126 190 $unzipped_file = $data_management->fetch_sql_file( $dirpath ); 127 191 $restore = $data_management->wpsc_restore_db_to_site( $dirpath , $unzipped_file ); … … 138 202 139 203 add_action('WPS_action_restore-cloud-backup','wpsc_retreve_db_file'); 204 205
Note: See TracChangeset
for help on using the changeset viewer.