Changeset 2012719
- Timestamp:
- 01/15/2019 02:20:55 PM (7 years ago)
- Location:
- wps-backup
- Files:
-
- 59 added
- 9 edited
-
tags/0.6.4 (added)
-
tags/0.6.4/LICENSE.txt (added)
-
tags/0.6.4/README.txt (added)
-
tags/0.6.4/includes (added)
-
tags/0.6.4/includes/css (added)
-
tags/0.6.4/includes/css/wpsc_backup_styles.css (added)
-
tags/0.6.4/includes/data_actions (added)
-
tags/0.6.4/includes/data_actions/generate_backup.php (added)
-
tags/0.6.4/includes/data_actions/plugins_backup.php (added)
-
tags/0.6.4/includes/data_actions/plugins_restore_backup.php (added)
-
tags/0.6.4/includes/data_actions/plugins_restore_backup_files_list.php (added)
-
tags/0.6.4/includes/data_actions/plugins_restore_backup_remote.php (added)
-
tags/0.6.4/includes/data_actions/restore_backup.php (added)
-
tags/0.6.4/includes/data_actions/restore_backup_download_remote.php (added)
-
tags/0.6.4/includes/data_actions/restore_backup_files_list.php (added)
-
tags/0.6.4/includes/data_actions/restore_backup_remote.php (added)
-
tags/0.6.4/includes/data_actions/restore_cloud_db_backup.php (added)
-
tags/0.6.4/includes/data_actions/restore_cloud_plugins_backup.php (added)
-
tags/0.6.4/includes/data_actions/setup_backup.php (added)
-
tags/0.6.4/includes/data_actions/wpsc_class_data_management.php (added)
-
tags/0.6.4/includes/data_actions/wpsc_data_management.php (added)
-
tags/0.6.4/includes/wpsc_backup_functions.php (added)
-
tags/0.6.4/includes/wpsc_backup_page.php (added)
-
tags/0.6.4/includes/wpsc_backup_setup.php (added)
-
tags/0.6.4/includes/wpsc_instructions_tab.php (added)
-
tags/0.6.4/index.php (added)
-
tags/0.6.4/wps_backup.php (added)
-
tags/0.6.5 (added)
-
tags/0.6.5/LICENSE.txt (added)
-
tags/0.6.5/README.txt (added)
-
tags/0.6.5/includes (added)
-
tags/0.6.5/includes/css (added)
-
tags/0.6.5/includes/css/wpsc_backup_styles.css (added)
-
tags/0.6.5/includes/data_actions (added)
-
tags/0.6.5/includes/data_actions/generate_backup.php (added)
-
tags/0.6.5/includes/data_actions/plugins_backup.php (added)
-
tags/0.6.5/includes/data_actions/plugins_restore_backup.php (added)
-
tags/0.6.5/includes/data_actions/plugins_restore_backup_files_list.php (added)
-
tags/0.6.5/includes/data_actions/plugins_restore_backup_remote.php (added)
-
tags/0.6.5/includes/data_actions/restore_backup.php (added)
-
tags/0.6.5/includes/data_actions/restore_backup_download_remote.php (added)
-
tags/0.6.5/includes/data_actions/restore_backup_files_list.php (added)
-
tags/0.6.5/includes/data_actions/restore_backup_remote.php (added)
-
tags/0.6.5/includes/data_actions/restore_cloud_db_backup.php (added)
-
tags/0.6.5/includes/data_actions/restore_cloud_plugins_backup.php (added)
-
tags/0.6.5/includes/data_actions/setup_backup.php (added)
-
tags/0.6.5/includes/data_actions/wpsc_class_data_management.php (added)
-
tags/0.6.5/includes/data_actions/wpsc_data_management.php (added)
-
tags/0.6.5/includes/wpsc_backup_functions.php (added)
-
tags/0.6.5/includes/wpsc_backup_page.php (added)
-
tags/0.6.5/includes/wpsc_backup_setup.php (added)
-
tags/0.6.5/includes/wpsc_instructions_tab.php (added)
-
tags/0.6.5/index.php (added)
-
tags/0.6.5/wps_backup.php (added)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/includes/data_actions/generate_backup.php (modified) (2 diffs)
-
trunk/includes/data_actions/plugins_backup.php (added)
-
trunk/includes/data_actions/plugins_restore_backup.php (added)
-
trunk/includes/data_actions/plugins_restore_backup_files_list.php (added)
-
trunk/includes/data_actions/plugins_restore_backup_remote.php (added)
-
trunk/includes/data_actions/restore_backup.php (modified) (1 diff)
-
trunk/includes/data_actions/restore_backup_remote.php (modified) (1 diff)
-
trunk/includes/data_actions/restore_cloud_plugins_backup.php (added)
-
trunk/includes/data_actions/wpsc_class_data_management.php (modified) (14 diffs)
-
trunk/includes/data_actions/wpsc_data_management.php (modified) (6 diffs)
-
trunk/includes/wpsc_backup_functions.php (modified) (2 diffs)
-
trunk/includes/wpsc_backup_page.php (modified) (7 diffs)
-
trunk/wps_backup.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wps-backup/trunk/README.txt
r2010665 r2012719 3 3 Tags: tools, user, support, backup, database, mysqli, migrate 4 4 Requires at least: 3.0.1 5 Tested up to: 5.0. 26 Stable tag: 5.0. 25 Tested up to: 5.0.3 6 Stable tag: 5.0.3 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 49 49 == Changelog == 50 50 51 = 0.6.4 = 52 1. Remove old tables after restoration 53 51 = 0.6.5 = 52 1. Added support for local plugin backup 54 53 55 54 = 0.6.3 = -
wps-backup/trunk/includes/data_actions/generate_backup.php
r1980143 r2012719 1 1 <?php 2 2 3 //if user is admin4 5 6 7 8 // function to call a generation of the database9 10 // function to do the generation of the database11 12 // function to download the generated database13 3 14 4 ?> … … 32 22 } 33 23 } else { 34 echo "You haven't any backups yet." . "<br/>";24 echo "You haven't any backups yet." . "<br/>"; 35 25 } 36 26 37 /**38 * generate backup mysql39 *40 * @since 1.041 * @return void42 */43 27 44 function deliver_mysql_backup(){45 46 } -
wps-backup/trunk/includes/data_actions/restore_backup.php
r1980143 r2012719 1 1 <?php 2 2 3 // upload form to upload a saved database4 3 5 // restore the database function6 7 // reload the website8 4 ?> 9 5 -
wps-backup/trunk/includes/data_actions/restore_backup_remote.php
r2003439 r2012719 70 70 $remote_storage = load_remote_storage(); 71 71 $remote_storage = json_decode( $remote_storage['body'] ); 72 73 if( count($remote_storage) <= 0 ){ 74 echo "You have not setup your WPS cloud backups yet."; 72 $fail_response = "You have not setup your WPS cloud backups yet."; 73 if( $remote_storage ){ 74 if( count( $remote_storage ) <= 0 ){ 75 echo $fail_response; 76 } else { 77 foreach($remote_storage as $key => $value){ 78 ?> 79 <p> 80 <form action="" method="post"> 81 <input type="hidden" name="WPS-action" value="get-url-database-backups"/> 82 <input type="hidden" name="url_required" value="<?php echo $value->url ?>"/> 83 <?php // wp_nonce_field( 'wpsc_generate_mysqli_backup_nonce', 'wpsc_generate_mysqli_backup_nonce' ); ?> 84 <input type="submit" value="View backups" > 85 </form> 86 <?php echo $value->url ?> 87 </p> 88 <?php 89 } 90 } 91 } else { 92 echo $fail_response; 75 93 } 76 94 77 foreach($remote_storage as $key => $value){78 ?>79 <p>80 <form action="" method="post">81 <input type="hidden" name="WPS-action" value="get-url-database-backups"/>82 <input type="hidden" name="url_required" value="<?php echo $value->url ?>"/>83 <?php // wp_nonce_field( 'wpsc_generate_mysqli_backup_nonce', 'wpsc_generate_mysqli_backup_nonce' ); ?>84 <input type="submit" value="View backups" >85 </form>86 <?php echo $value->url ?>87 </p>88 <?php89 90 }91 95 96 -
wps-backup/trunk/includes/data_actions/wpsc_class_data_management.php
r2010665 r2012719 3 3 4 4 class WPS_data_management { 5 6 7 8 /** 9 * generate backup plugins 10 * 11 * @since 1.0 12 * @return void 13 */ 14 15 public function wpsc_generate_plugins_backup( $destination ){ 16 $ready = false; 17 $site_url = substr( explode(".", site_url('','https') )[0] , 8); 18 19 20 21 // $dirpath = $dirpath.'/plugins'; 22 // $ready = WPS_file_util::create_dir($dirpath); 23 // var_dump($dirpath); 24 25 // return; 26 if($destination == 'local'){ 27 28 $dirpath = $this->setup_directory_for_writing('plugins','local'); 29 30 WPS_file_util::delete_files($dirpath."/"); 31 $ready = WPS_file_util::create_dir($dirpath); 32 33 $source = WP_CONTENT_DIR.'/plugins/'; 34 self::recurse_copy( $source , $dirpath."/original"); 35 36 $zip_name = time() ."-". $site_url.'_plugins_backup.zip'; 37 38 // zip them to the original location 39 $sourcePath = WP_CONTENT_DIR.'/'.WPS_PLUGIN_DIR_STORAGE.'/'.WPS_BU_PLUGIN_FOLDER."/temp/plugins/local/original"; 40 $outZipPath = WP_CONTENT_DIR.'/'.WPS_PLUGIN_DIR_STORAGE.'/'.WPS_BU_PLUGIN_FOLDER."/temp/plugins/local/".$zip_name; 41 WPS_file_util::zipDir( $sourcePath , $outZipPath ); 42 43 $ready = true; 44 45 } 46 if( $destination == 'remote' ){ 47 48 $dirpath = $this->setup_directory_for_writing('plugins','remote'); 49 50 // $dirpath = $dirpath.'/remote'; 51 WPS_file_util::delete_files($dirpath."/"); 52 $ready = WPS_file_util::create_dir($dirpath); 53 54 $source = WP_CONTENT_DIR.'/plugins/'; 55 self::recurse_copy( $source , $dirpath."/original"); 56 57 $zip_name = time() ."-". $site_url.'_plugins_backup.zip'; 58 59 // zip them to the original location 60 $sourcePath = WP_CONTENT_DIR.'/'.WPS_PLUGIN_DIR_STORAGE.'/'.WPS_BU_PLUGIN_FOLDER."/temp/plugins/remote/original"; 61 $outZipPath = WP_CONTENT_DIR.'/'.WPS_PLUGIN_DIR_STORAGE.'/'.WPS_BU_PLUGIN_FOLDER."/temp/plugins/remote/".$zip_name; 62 WPS_file_util::zipDir( $sourcePath , $outZipPath ); 63 64 $ready = true; 65 66 } 67 68 return $ready; 69 } 70 71 72 // get current backup file from dirory options 73 74 public static function get_current_local_backup( $backup_type ){ 75 $output = ""; 76 $filtered = array(); 77 $dirpath = WP_CONTENT_DIR.'/'.WPS_PLUGIN_DIR_STORAGE.'/'.WPS_BU_PLUGIN_FOLDER."/temp/".$backup_type."/local"; 78 // WPS_file_util::create_dir($dirpath); 79 //to do 80 //ensure html silence is golden is added 81 // html page 82 if( is_dir( $dirpath ) ){ 83 foreach (scandir($dirpath) as $file) { 84 $files[$file] = filemtime($dirpath . '/' . $file); 85 } 86 foreach ( $files as $key => $file ){ 87 if ( strpos( $key, $backup_type .'_backup' ) !== false ){ 88 $filtered[] = $key; 89 } 90 } 91 return $filtered; 92 } 93 return false; 94 } 95 96 /** 97 * Copy directory content 98 * 99 * @since 1.0 100 * @return void 101 */ 102 103 104 static function recurse_copy($src,$dst) { 105 106 // check if the parent is the same as the new directory, this causes feedback loops 107 //this is not used at the moment 108 // $parent = explode('/', $src )[ ( count( explode('/', $src ) ) - 1)] ; 109 // $child_parent = explode('/', $dst )[ ( count( explode('/', $dst ) ) - 2)]; 110 111 $dir = opendir($src); 112 @mkdir($dst); 113 while(false !== ( $file = readdir($dir)) ) { 114 if (( $file != '.' ) && ( $file != '..' )) { 115 if ( is_dir($src . '/' . $file) ) { 116 // if($child_parent != $parent){ //stop from copying into itself 117 self::recurse_copy($src . '/' . $file, $dst . '/' . $file); 118 // } 119 } 120 else { 121 copy($src . '/' . $file,$dst . '/' . $file); 122 } 123 } 124 } 125 closedir($dir); 126 } 127 5 128 6 129 /** … … 82 205 83 206 84 public function setup_directory_for_writing( ){207 public function setup_directory_for_writing($backup_dir = 'database' , $destination = 'remote'){ 85 208 86 209 $dirpath = WP_CONTENT_DIR.'/'.WPS_PLUGIN_DIR_STORAGE; … … 90 213 $dirpath = $dirpath.'/temp'; 91 214 $ready = WPS_file_util::create_dir($dirpath); 215 $dirpath = $dirpath.'/'.$backup_dir; 216 $ready = WPS_file_util::create_dir($dirpath); 217 $dirpath = $dirpath.'/'.$destination; 218 $ready = WPS_file_util::create_dir($dirpath); 92 219 if($ready){ 93 220 return $dirpath; … … 97 224 } 98 225 226 227 99 228 100 229 /** … … 106 235 107 236 public function setup_directory_for_restoring(){ 237 238 //delete previous folder 108 239 $target = WP_CONTENT_DIR.'/'.WPS_PLUGIN_DIR_STORAGE.'/'.WPS_BU_PLUGIN_FOLDER.'/temp/restore/'; 109 240 if($target){ 110 241 WPS_file_util::delete_files($target); 111 242 } 243 244 112 245 if( $dirpath = $this->setup_directory_for_writing() ){ 113 246 $dirpath = $dirpath.'/restore'; … … 129 262 130 263 static function get_directory_for_restoring(){ 131 $target = WP_CONTENT_DIR.'/'.WPS_PLUGIN_DIR_STORAGE.'/'.WPS_BU_PLUGIN_FOLDER.'/temp/ restore/';264 $target = WP_CONTENT_DIR.'/'.WPS_PLUGIN_DIR_STORAGE.'/'.WPS_BU_PLUGIN_FOLDER.'/temp/database/remote/restore/'; 132 265 return $target; 133 266 } … … 212 345 public function write_file_to_directory( $dirpath , $sqlScript ){ 213 346 214 $site_url = site_url('','https'); 215 $site_url = explode(".",$site_url)[0]; 216 $site_url = substr( $site_url , 8); 347 $site_url = substr( explode(".", site_url('','https') )[0] , 8); 217 348 218 349 $backup_file_name = time() . "-" . $site_url. '_backup.sql'; … … 225 356 226 357 /** 227 * Write zip and delete original 358 * Write zip and delete original - only used for single files to be zipped for db backup 228 359 * 229 360 * @since 1.0 … … 233 364 public function zip_backup_directory( $dirpath , $backup_file_name ){ 234 365 235 $site_url = site_url('','https'); 236 $site_url = explode(".",$site_url)[0]; 237 $site_url = substr( $site_url , 8); 366 $site_url = substr( explode(".", site_url('','https') )[0] , 8); 238 367 239 368 if ( class_exists( 'ZipArchive' ) ) { 240 $zip_name = time() ."-". $site_url.'_backup.zip'; 369 $zip_name = time() ."-". $site_url.'_backup.zip'; 241 370 $zip = new ZipArchive(); 242 371 $archive = $zip->open($dirpath."/" . $zip_name, ZipArchive::CREATE); … … 283 412 /** 284 413 * Unzip our directory 414 * optionl $dst 285 415 * @param 286 416 * @param … … 290 420 291 421 292 public function unzip_file( $dirpath , $filename ){ 422 public function unzip_file( $dirpath , $filename , $dst ){ 423 424 if( $dst == '' ){ 425 $output_dst = $dirpath; 426 } else { 427 $output_dst = $dst; 428 } 429 293 430 $zip = new ZipArchive; 294 431 $section = $zip->open($dirpath . $filename ); 295 $extract = $zip->extractTo( $dirpath);432 $extract = $zip->extractTo( $output_dst ); 296 433 $extract = $zip->close(); 297 434 return $extract; 298 435 } 436 437 438 /** 439 * Advanced unzip - prevent over write, alternative destination 440 * @param 441 * @param 442 * @since 1.0 443 * @return true if file was unzipped 444 */ 445 446 // public function unzip_file_advanced( $dirpath , $filename , $dst ){ 447 // $zip = new ZipArchive; 448 // $section = $zip->open($dirpath . $filename ); 449 // $extract = $zip->extractTo($dst); 450 // $extract = $zip->close(); 451 // return $extract; 452 // } 299 453 300 454 … … 322 476 global $wpdb; 323 477 324 478 325 479 $tables = array(); 326 480 $sql = "SHOW TABLES"; … … 360 514 } 361 515 362 363 364 516 if ( substr( trim( $line ), - 1, 1) == ';') { 365 517 $result = $wpdb->query( $sql ); … … 407 559 } 408 560 } 561 562 563 /* 564 * PHP delete function that deals with directories recursively, deletes the directory as well, 565 * This is a modified version for the ensuring that the wps backups are not removed 566 */ 567 static function delete_files( $dirname , $parent = '' ) { 568 $parent_path = ''; 569 $current_path = ''; 570 571 //stop the parent being deleted if it passed when called 572 if( $parent != '' ){ 573 $parent_path = pathInfo( $parent )['dirname']; 574 $current_path = pathInfo( $dirname )['dirname']; 575 } 576 577 $do_not_delete = false; 578 $directory_array = explode('/', $dirname ); 579 if( in_array ( 'wps-complete', $directory_array ) || in_array ( 'wps-backup', $directory_array ) ){ 580 $do_not_delete = true; 581 } 582 583 if ( is_dir( $dirname ) ){ 584 585 $dir_handle = opendir($dirname); 586 if (!$dir_handle || $do_not_delete){ 587 return false; 588 } 589 590 while($file = readdir($dir_handle)) { 591 if ($file != "." && $file != "..") { 592 if (!is_dir($dirname."/".$file)){ 593 unlink($dirname."/".$file); 594 } else { 595 self::delete_files($dirname.'/'.$file , ''); 596 } 597 } 598 } 599 closedir($dir_handle); 600 601 //options to avoid deleting the parent 602 if( $parent == '' ){ 603 rmdir($dirname); 604 } 605 if( $parent == '' ){ 606 if( $parent_path != $current_path){ 607 rmdir($dirname); 608 } 609 } 610 return true; 611 } 612 } 613 409 614 } 410 615 -
wps-backup/trunk/includes/data_actions/wpsc_data_management.php
r2008527 r2012719 20 20 wp_die( __( 'Nonce verification failed.', 'wps' ), __( 'Error', 'wps' ), array( 'response' => 403 ) ); 21 21 } 22 22 23 23 24 $sqlScript = ""; … … 79 80 } 80 81 82 $dirpath = WP_CONTENT_DIR.'/'.WPS_PLUGIN_DIR_STORAGE.'/'.WPS_BU_PLUGIN_FOLDER."/temp/database/local"; 83 WPS_file_util::delete_files($dirpath); 84 // return; 81 85 if(!empty($sqlScript)){ 82 86 $dirpath = WP_CONTENT_DIR.'/'.WPS_PLUGIN_DIR_STORAGE; … … 84 88 $dirpath = $dirpath.'/'.WPS_BU_PLUGIN_FOLDER; 85 89 WPS_file_util::create_dir($dirpath); 90 $dirpath = $dirpath.'/temp'; 91 WPS_file_util::create_dir($dirpath); 92 $dirpath = $dirpath.'/database'; 93 WPS_file_util::create_dir($dirpath); 94 $dirpath = $dirpath.'/local'; 95 WPS_file_util::create_dir($dirpath); 86 96 //to do 87 97 //ensure html silence is golden is added … … 150 160 } 151 161 152 $dirpath = WP_CONTENT_DIR . '/' . WPS_PLUGIN_DIR_STORAGE . '/' . WPS_BU_PLUGIN_FOLDER; 162 $dirpath = WP_CONTENT_DIR . '/' . WPS_PLUGIN_DIR_STORAGE . '/' . WPS_BU_PLUGIN_FOLDER .'/temp/database/local'; 163 164 // var_dump( file_exists( $dirpath ) ); 165 153 166 $sql = ''; 154 167 $error = ''; … … 156 169 if (file_exists($dirpath)) { 157 170 $zip = new ZipArchive; 158 $zip->open($dirpath . "/" . $backup_file ); 171 $ready = $zip->open($dirpath . "/" . $backup_file ); 172 // var_dump($dirpath . "/" . $backup_file); 159 173 $zip->extractTo($dirpath.'/'); 160 174 $zip->close(); … … 220 234 $output = ""; 221 235 $filtered = array(); 222 $dirpath = WP_CONTENT_DIR.'/'.WPS_PLUGIN_DIR_STORAGE; 223 WPS_file_util::create_dir($dirpath); 224 $dirpath = $dirpath.'/'.WPS_BU_PLUGIN_FOLDER; 225 WPS_file_util::create_dir($dirpath); 236 $dirpath = WP_CONTENT_DIR.'/'.WPS_PLUGIN_DIR_STORAGE.'/'.WPS_BU_PLUGIN_FOLDER."/temp/database/local"; 237 // WPS_file_util::create_dir($dirpath); 226 238 //to do 227 239 //ensure html silence is golden is added 228 240 // html page 229 230 foreach (scandir($dirpath) as $file) { 231 $files[$file] = filemtime($dirpath . '/' . $file); 241 if( is_dir( $dirpath ) ){ 242 foreach (scandir($dirpath) as $file) { 243 $files[$file] = filemtime($dirpath . '/' . $file); 244 } 245 foreach ( $files as $key => $file ){ 246 if ( strpos( $key, '_backup' ) !== false ){ 247 $filtered[] = $key; 248 } 249 } 250 return $filtered; 232 251 } 233 foreach ( $files as $key => $file ){ 234 if ( strpos( $key, '_backup' ) !== false ){ 235 $filtered[] = $key; 236 } 237 } 238 return $filtered; 252 return false; 239 253 } -
wps-backup/trunk/includes/wpsc_backup_functions.php
r2010665 r2012719 259 259 $data_management = new WPS_data_management; 260 260 $dirpath = WPS_data_management::get_directory_for_restoring(); 261 var_dump($dirpath); 261 262 $files = WPS_data_management::get_file_type_from_directory( $dirpath , 'zip'); 262 263 $file_name = $files[0]; … … 293 294 add_action('WPS_action_restore-downloaded-cloud-backup','wpsc_restore_completed_db_download'); 294 295 296 297 //generate local backup 298 299 function wpsc_generate_local_plugin_backup( ){ 300 // nonce 301 // wpsc_generate_local_plugin_backup_nonce 302 303 $data_management = new WPS_data_management; 304 $backup = $data_management->wpsc_generate_plugins_backup( $_POST['destination'] ); 305 306 //redirect after generation 307 // false - message try again 308 // true redirect to self with success message 309 310 // if( current_user_can('manage_options') ){ 311 // $url = admin_url( 'admin.php?page=wpsc_backup&tab=data_remote_files&url='.$_POST['url_required'] ); 312 // } else { 313 $url = admin_url( 'admin.php?page=wpsc_backup&tab=plugins_backup&wps_message=plugins_backed_up' ); 314 315 // } 316 wp_safe_redirect( $url ); 317 } 318 add_action('WPS_action_generate-local-plugin-backup','wpsc_generate_local_plugin_backup'); 319 320 321 function wpsc_restore_local_plugin_backup( ){ 322 // nonce 323 // wpsc_generate_local_plugin_backup_nonce 324 325 $src = WP_CONTENT_DIR.'/plugins'; 326 $dirpath = WP_CONTENT_DIR.'/wpsc_complete/backups/old_plugins'; 327 WPS_data_management::recurse_copy($src,$dirpath); 328 WPS_data_management::delete_files( $src , $src ); 329 330 //extract the zip to a restore directory 331 $sourcePath = WP_CONTENT_DIR.'/'.WPS_PLUGIN_DIR_STORAGE.'/'.WPS_BU_PLUGIN_FOLDER."/temp/plugins/local/"; 332 $file_name = WPS_data_management::get_current_local_backup( 'plugins' ); 333 334 $restorePath = WP_CONTENT_DIR.'/'.WPS_PLUGIN_DIR_STORAGE.'/'.WPS_BU_PLUGIN_FOLDER."/temp/plugins/local/restore/"; 335 WPS_file_util::delete_files( $restorePath ); 336 WPS_file_util::create_dir($restorePath); 337 $unzip = WPS_data_management::unzip_file( $sourcePath , $file_name[0] , $restorePath ); 338 339 //copy the extracted folder into the plugins directory 340 $copySource = WP_CONTENT_DIR.'/'.WPS_PLUGIN_DIR_STORAGE.'/'.WPS_BU_PLUGIN_FOLDER."/temp/plugins/local/restore/original/"; 341 $resource = scandir( $copySource ); 342 foreach( $resource as $dir ){ 343 if( substr($dir,0,1) != '.' ){ 344 WPS_file_util::recurse_copy( $copySource.$dir , $src."/".$dir ); 345 } 346 } 347 348 // if( current_user_can('manage_options') ){ 349 $url = admin_url( 'admin.php?page=wpsc_backup&tab=plugins_restore&wps_message=plugins_restored' ); 350 // } else { 351 // $url = admin_url( 'admin.php?page=wpsc_backup&tab=data_remote_files&WPS_message=error' ); 352 // } 353 wp_safe_redirect( $url ); 354 } 355 add_action('WPS_action_restore-local-plugin-backup','wpsc_restore_local_plugin_backup'); 356 357 358 -
wps-backup/trunk/includes/wpsc_backup_page.php
r2008527 r2012719 21 21 $_GET['tab'] = isset( $_GET['tab'] ) ? $_GET['tab'] : 'data_backup'; 22 22 23 24 /* 25 * Build the settings page funciton that runs everything 26 * 27 * 28 */ 29 30 31 function wpsc_bu_settings_page() { 32 global $pagenow; 33 34 switch( $_GET['tab'] ){ 35 case 'wpsc_bu_plugins': 36 case 'plugins_backup': 37 wpsc_bu_admin_tabs('wpsc_bu_plugins'); 38 wpsc_backup_sub_tabs( 'plugins_backup' ); 39 break; 40 case 'plugins_restore': 41 wpsc_bu_admin_tabs('wpsc_bu_plugins'); 42 wpsc_backup_sub_tabs( 'plugins_restore' ); 43 break; 44 case 'plugins_remote': 45 wpsc_bu_admin_tabs('wpsc_bu_plugins'); 46 wpsc_backup_sub_tabs( 'plugins_remote' ); 47 break; 48 49 case 'admin_menu': 50 wpsc_bu_admin_tabs($_GET['tab']); 51 break; 52 case 'admin_toolbar': 53 wpsc_bu_admin_tabs($_GET['tab']); 54 break; 55 56 case 'data_backup': 57 wpsc_bu_admin_tabs('wpsc_database'); 58 wpsc_backup_sub_tabs( 'data_backup' ); 59 break; 60 case 'data_restore': 61 wpsc_bu_admin_tabs('wpsc_database'); 62 wpsc_backup_sub_tabs( 'data_restore' ); 63 break; 64 case 'data_remote': 65 wpsc_bu_admin_tabs('wpsc_database'); 66 wpsc_backup_sub_tabs( 'data_remote' ); 67 break; 68 69 case 'data_remote_files': 70 wpsc_bu_admin_tabs('wpsc_database'); 71 wpsc_backup_sub_tabs( 'data_remote_files' ); 72 break; 73 case 'data_restore_cloud_db': 74 wpsc_bu_admin_tabs('wpsc_database'); 75 wpsc_backup_sub_tabs( 'data_restore_cloud_db' ); 76 break; 77 case 'restore_data_restore_cloud_db': 78 wpsc_bu_admin_tabs('wpsc_database'); 79 wpsc_backup_sub_tabs( 'restore_data_restore_cloud_db' ); 80 break; 81 82 83 84 default: 85 wpsc_bu_admin_tabs($_GET['tab']); 86 wpsc_backup_sub_tabs( $_GET['tab'] ); 87 } 88 } 89 23 90 //call the setting page to be built 24 91 wpsc_bu_settings_page(); … … 34 101 function wpsc_bu_admin_tabs( $current = 'wpsc_database' ) { 35 102 $tabs = array( 'wpsc_database' => 'Database', 103 'wpsc_bu_plugins' => 'Plugins', 36 104 'wpsc_instructions' => 'Instructions' 37 105 ); … … 67 135 switch( $current ){ 68 136 137 //database 69 138 case 'data_actions': 70 139 $tabs['data_backup'] = 'Local Backup'; … … 94 163 // $tabs['data_setup'] = 'Setup'; 95 164 break; 165 166 //plugins 167 case 'plugins_backup': 168 $tabs['plugins_backup'] = 'Local Backup'; 169 $tabs['plugins_restore'] = 'Local Restore'; 170 $tabs['plugins_remote'] = 'Cloud Backups'; 171 // $tabs['data_setup'] = 'Setup'; 172 break; 173 case 'plugins_restore': 174 $tabs['plugins_backup'] = 'Local Backup'; 175 $tabs['plugins_restore'] = 'Local Restore'; 176 $tabs['plugins_remote'] = 'Cloud Backups'; 177 // $tabs['data_setup'] = 'Setup'; 178 break; 179 case 'plugins_remote': 180 $tabs['plugins_backup'] = 'Local Backup'; 181 $tabs['plugins_restore'] = 'Local Restore'; 182 $tabs['plugins_remote'] = 'Cloud Backups'; 183 // $tabs['data_setup'] = 'Setup'; 184 break; 185 case 'plugins_remote_files': 186 $tabs['plugins_backup'] = 'Local Backup'; 187 $tabs['plugins_restore'] = 'Local Restore'; 188 $tabs['plugins_remote_files'] = 'Cloud File Backups: '.$_GET['url']; 189 $tabs['plugins_remote'] = 'Cloud Backups'; 190 // $tabs['data_setup'] = 'Setup'; 191 break; 192 //downlaod 193 case 'plugins_restore_cloud_db': 194 $tabs['plugins_backup'] = 'Local Backup'; 195 $tabs['plugins_restore'] = 'Local Restore'; 196 $tabs['plugins_restore_cloud_plugins'] = 'Restoration Progress: Download'; 197 $tabs['plugins_remote'] = 'Cloud Backups'; 198 // $tabs['data_setup'] = 'Setup'; 199 break; 200 //restore 201 case 'restore_plugins_restore_cloud_db': 202 $tabs['plugins_backup'] = 'Local Backup'; 203 $tabs['plugins_restore'] = 'Local Restore'; 204 $tabs['restore_plugins_restore_cloud_plugins'] = 'Restoration Progress: Restore'; 205 $tabs['plugins_remote'] = 'Cloud Backups'; 206 // $tabs['data_setup'] = 'Setup'; 207 break; 208 209 //others 210 96 211 case 'wpsc_instructions': 97 212 break; … … 113 228 } 114 229 115 wpsc_backup_sub_tabs( $_GET['tab'] );230 // wpsc_backup_sub_tabs( $_GET['tab'] ); 116 231 117 232 … … 152 267 153 268 154 default: 269 270 //plugins 271 case 'wpsc_bu_plugins': 272 case 'plugins_backup': 273 include "data_actions/plugins_backup.php"; 274 break; 275 case 'plugins_restore_cloud_db': 276 include "data_actions/restore_cloud_plugins_backup.php"; 277 break; 278 case 'plugins_remote_files': 279 include "data_actions/plugins_restore_backup_files_list.php"; 280 break; 281 case 'plugins_restore': 282 include "data_actions/plugins_restore_backup.php"; 283 break; 284 case 'plugins_remote': 285 include "data_actions/plugins_restore_backup_remote.php"; 286 break; 287 288 289 default: 155 290 // include "wpsc_menu_tab.php"; 291 292 156 293 } 157 294 … … 169 306 170 307 171 /* 172 * Build the settings page 173 * 174 * 175 */ 176 177 178 function wpsc_bu_settings_page() { 179 global $pagenow; 180 181 switch( $_GET['tab'] ){ 182 case 'admin_menu': 183 wpsc_bu_admin_tabs($_GET['tab']); 184 break; 185 case 'admin_toolbar': 186 wpsc_bu_admin_tabs($_GET['tab']); 187 break; 188 default: 189 wpsc_bu_admin_tabs($_GET['tab']); 190 } 191 } 192 308 309 -
wps-backup/trunk/wps_backup.php
r2010665 r2012719 6 6 Description: Backup migrate your WordPress websites locally and with our cloud API 7 7 Author: WPScomplete.com 8 Version: 0.6. 48 Version: 0.6.5 9 9 Author URI: https://wpscomplete.com 10 10 */
Note: See TracChangeset
for help on using the changeset viewer.