Changeset 1709427
- Timestamp:
- 08/07/2017 07:55:26 AM (9 years ago)
- Location:
- tp-backup-automator
- Files:
-
- 40 added
- 13 edited
-
tags/1.0.1 (added)
-
tags/1.0.1/assets (added)
-
tags/1.0.1/assets/css (added)
-
tags/1.0.1/assets/css/admin.css (added)
-
tags/1.0.1/assets/images (added)
-
tags/1.0.1/assets/images/bg.jpg (added)
-
tags/1.0.1/assets/images/logo.jpg (added)
-
tags/1.0.1/assets/images/success_80x80.png (added)
-
tags/1.0.1/assets/images/warning.png (added)
-
tags/1.0.1/assets/js (added)
-
tags/1.0.1/assets/js/admin.js (added)
-
tags/1.0.1/assets/js/installer.js (added)
-
tags/1.0.1/assets/scss (added)
-
tags/1.0.1/assets/scss/_installer.scss (added)
-
tags/1.0.1/assets/scss/_spiner.scss (added)
-
tags/1.0.1/assets/scss/admin.scss (added)
-
tags/1.0.1/includes (added)
-
tags/1.0.1/includes/class-tpba-ajax.php (added)
-
tags/1.0.1/includes/class-tpba-cron.php (added)
-
tags/1.0.1/includes/class-tpba-install.php (added)
-
tags/1.0.1/includes/class-tpba-log.php (added)
-
tags/1.0.1/includes/class-tpba-master.php (added)
-
tags/1.0.1/includes/class-tpba-scanner.php (added)
-
tags/1.0.1/includes/class-tpba-services.php (added)
-
tags/1.0.1/includes/class-tpba-sql-dump.php (added)
-
tags/1.0.1/includes/class-tpba-sql.php (added)
-
tags/1.0.1/includes/class-tpba-user.php (added)
-
tags/1.0.1/includes/file-functions.php (added)
-
tags/1.0.1/includes/helper-functions.php (added)
-
tags/1.0.1/languages (added)
-
tags/1.0.1/languages/tp-backup-automator.pot (added)
-
tags/1.0.1/readme.txt (added)
-
tags/1.0.1/templates (added)
-
tags/1.0.1/templates/backups.php (added)
-
tags/1.0.1/templates/dashboard.php (added)
-
tags/1.0.1/templates/install.php (added)
-
tags/1.0.1/templates/plugin-page.php (added)
-
tags/1.0.1/templates/settings.php (added)
-
tags/1.0.1/tp-backup-automator.php (added)
-
trunk/assets/js/admin.js (modified) (9 diffs)
-
trunk/includes/class-tpba-ajax.php (modified) (6 diffs)
-
trunk/includes/class-tpba-cron.php (modified) (11 diffs)
-
trunk/includes/class-tpba-install.php (modified) (1 diff)
-
trunk/includes/class-tpba-master.php (modified) (2 diffs)
-
trunk/includes/class-tpba-scanner.php (modified) (5 diffs)
-
trunk/includes/class-tpba-services.php (modified) (17 diffs)
-
trunk/includes/class-tpba-sql-dump.php (modified) (7 diffs)
-
trunk/includes/class-tpba-user.php (modified) (1 diff)
-
trunk/includes/file-functions.php (added)
-
trunk/languages/tp-backup-automator.pot (modified) (6 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/templates/dashboard.php (modified) (3 diffs)
-
trunk/tp-backup-automator.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tp-backup-automator/trunk/assets/js/admin.js
r1705516 r1709427 126 126 var trackBackup = _.bind(this.track, this); 127 127 var progress = _.bind(this.initProgressBar, this); 128 var done = _.bind(this.done, this); 128 129 129 Backbone.ajax({ 130 130 url: ajaxurl, … … 135 135 success: function (response) { 136 136 137 138 139 if (response.total_count && response.total_count > response.index) { 140 141 var progressBar = progress.call(this); 142 progressBar.setTotal(response.total_count); 143 progressBar.update(response.index, response.data); 144 trackBackup.call(this, response.index); 145 146 } else if (response.total_count && response.total_count == response.index) { 147 148 var progressBar = progress.call(this); 149 progressBar.setTotal(response.total_count); 150 progressBar.update(response.index, response.data); 151 152 done.call(this); 153 } 137 if (_.isObject(response)) { 138 if (response.continue) { 139 var progressBar = progress.call(this); 140 progressBar.setTotal(response.total_count); 141 progressBar.update(response.index, response.data); 142 trackBackup.call(this, response.index); 143 } else { 144 if (response.success) { 145 progressBar.remove(); 146 new ShowAlert(tpba_var.done, response.data, 'success'); 147 } else { 148 new ShowAlert(tpba_var.done, response.data, 'warning'); 149 } 150 } 151 } 152 154 153 } 155 154 }); … … 160 159 var progressBar = this.progressBar; 161 160 var trackBackup = _.bind(this.track, this); 162 var done = _.bind(this.done, this);163 161 164 162 Backbone.ajax({ … … 174 172 var response = data.responseJSON; 175 173 176 if (response. index < progressBar.total) {174 if (response.continue) { 177 175 progressBar.update(response.index, response.data); 178 176 trackBackup.call(this); 179 } else if (response.index == progressBar.total) { 180 progressBar.update(response.index, response.data); 177 } else { 181 178 progressBar.remove(); 182 done.call(this); 179 if (response.success) { 180 new ShowAlert(tpba_var.done, response.data, 'success'); 181 } else { 182 new ShowAlert(tpba_var.warning, response.data, 'warning'); 183 } 183 184 } 184 185 185 } else {186 } else if (data.responseText != '' && data.responseText != 0) { 186 187 new ShowAlert(tpba_var.warning, data.responseText, 'error'); 187 188 } … … 190 191 }); 191 192 192 },193 done: function () {194 195 var progressBar = this.progressBar;196 197 Backbone.ajax({198 url: ajaxurl,199 type: 'POST',200 data: {201 'action': 'tpba_alldone'202 },203 success: function (res) {204 new ShowAlert(tpba_var.done, progressBar.total + ' ' + tpba_var.file_backup_done, 'success');205 }206 });207 193 } 208 194 }); … … 215 201 initialize: function () { 216 202 this.checkCron(); 217 218 203 }, 219 204 initProgressBar: function () { … … 272 257 checkCron: function () { 273 258 274 var trac Resktore = _.bind(this.track, this);259 var trackRestore = _.bind(this.track, this); 275 260 var progress = _.bind(this.initProgressBar, this); 276 261 … … 283 268 success: function (response) { 284 269 285 if (response.total_count && response.total_count > response.index) { 286 $('.js-restore').addClass('disabled').attr('disabled', ''); 287 var progressBar = progress.call(this); 288 progressBar.setTotal(response.total_count); 289 progressBar.update(response.index, response.data); 290 tracResktore.call(this, response.index); 291 292 293 } else if (response.total_count && response.total_count == response.index) { 294 $('.js-restore').addClass('disabled').attr('disabled', ''); 295 var progressBar = progress.call(this); 296 progressBar.setTotal(response.total_count); 297 progressBar.update(response.index, response.data); 298 } 299 } 300 }); 301 302 }, 303 track: function () { 304 305 var progressBar = this.progressBar; 306 var trackBackup = _.bind(this.track, this); 307 var done = _.bind(this.done, this); 308 309 Backbone.ajax({ 310 url: ajaxurl, 311 type: 'POST', 312 data: { 313 action: 'tpba_restore_track' 314 }, 315 complete: function (data, status) { 316 317 if (data.hasOwnProperty('responseJSON')) { 318 319 var response = data.responseJSON; 320 321 if (response.index >= 0) { 322 if (response.index < progressBar.total) { 323 324 progressBar.update(response.index, response.data); 325 trackBackup.call(this); 326 327 } else if (response.index == progressBar.total) { 328 329 progressBar.update(response.index, response.data); 270 if (_.isObject(response)) { 271 if (response.continue) { 272 273 $('.js-restore').addClass('disabled').attr('disabled', ''); 274 var progressBar = progress.call(this); 275 progressBar.setTotal(response.total_count); 276 progressBar.update(response.index, response.data); 277 trackRestore.call(this, response.index); 278 279 } else { 280 281 $('.js-restore').removeClass('disabled').removeAttr('disabled'); 282 283 if (response.success) { 330 284 progressBar.remove(); 331 332 done.call(this);333 new ShowAlert(tpba_var. done, progressBar.total + ' ' + tpba_var.file_restore_done, 'success');285 new ShowAlert(tpba_var.done, response.data, 'success'); 286 } else { 287 new ShowAlert(tpba_var.warning, response.data, 'warning'); 334 288 } 335 289 } 336 290 } 337 } 338 }); 339 }, 340 done: function () { 341 342 Backbone.ajax({ 343 url: ajaxurl, 344 type: 'POST', 345 data: { 346 'action': 'tpba_alldone' 347 }, 348 success: function (res) { 349 291 292 } 293 }); 294 295 }, 296 track: function () { 297 298 var progressBar = this.progressBar; 299 var trackRestore = _.bind(this.track, this); 300 301 Backbone.ajax({ 302 url: ajaxurl, 303 type: 'POST', 304 data: { 305 action: 'tpba_restore_track' 306 }, 307 complete: function (data, status) { 308 309 if (data.hasOwnProperty('responseJSON')) { 310 311 var response = data.responseJSON; 312 313 if (response.continue) { 314 progressBar.update(response.index, response.data); 315 trackRestore.call(this); 316 } else { 317 if (response.success) { 318 progressBar.remove(); 319 new ShowAlert(tpba_var.done, response.data, 'success'); 320 } else { 321 new ShowAlert(tpba_var.done, response.data, 'warning'); 322 } 323 } 324 325 } 350 326 } 351 327 }); … … 362 338 363 339 $('.tpba_abort').on('click', function (e) { 364 365 Backbone.ajax({366 url: ajaxurl,367 type: 'POST',368 data: {369 'action': 'tpba_abort'370 },371 success: function (res) {372 console.log(res);373 }374 });375 340 341 Backbone.ajax({ 342 url: ajaxurl, 343 type: 'POST', 344 data: { 345 'action': 'tpba_abort' 346 }, 347 success: function (res) { 348 console.log(res); 349 } 350 }); 351 376 352 e.preventDefault(); 377 353 }); -
tp-backup-automator/trunk/includes/class-tpba-ajax.php
r1705516 r1709427 16 16 'restore_check_cron' => false, 17 17 'restore_track' => false, 18 'alldone' => false,19 18 'register_token' => false, 20 19 'validate_token' => false … … 57 56 58 57 public static function backup_check_cron() { 59 $message = get_option( 'tpba_cron_message' ); 60 $data = get_option( 'tpba_backup_current' ); 61 62 63 if ( !empty( $message ) && is_array( $message ) ) { 64 wp_send_json( array( 65 'index' => $message['index'], 66 'data' => $message['data'], 67 'total_count' => $data['total_count'] 68 ) ); 69 } 70 71 72 wp_send_json( array( 73 'index' => 0, 74 'data' => '', 75 'total_count' => 0 76 ) ); 58 59 $result = get_option( 'tpba_cron_result' ); 60 $is_cron = get_transient( 'doing_cron' ); 61 62 if ( !empty( $result ) && is_array( $result ) && !$is_cron ) { 63 $results = get_option( 'tpba_cron_result' ); 64 $result['continue'] = false; 65 delete_option( 'tpba_cron_result' ); 66 wp_send_json( $results ); 67 } else if ( $is_cron ) { 68 $message = get_option( 'tpba_cron_message' ); 69 $data = get_option( 'tpba_backup_current' ); 70 71 if ( !empty( $message ) && is_array( $message ) ) { 72 wp_send_json( array( 73 'index' => $message['index'], 74 'data' => $message['data'], 75 'total_count' => $data['total_count'], 76 'continue' => true 77 ) ); 78 } 79 } 80 81 die(); 77 82 } 78 83 … … 82 87 */ 83 88 public static function backup_track() { 89 84 90 sleep( 1 ); 85 91 86 $message = get_option( 'tpba_cron_message' ); 87 88 if ( !empty( $message ) && is_array( $message ) ) { 89 wp_send_json( array( 90 'index' => $message['index'], 91 'data' => $message['data'], 92 'wp_get_schedule' => wp_get_schedule( 'tpba_cron_backup' ), 93 'wp_next_scheduled' => wp_next_scheduled( 'tpba_cron_backup' ), 94 '_get_cron_lock' => function_exists( '_get_cron_lock' ) ? _get_cron_lock() : -1 95 ) ); 96 } 97 92 93 $result = get_option( 'tpba_cron_result' ); 94 95 if ( !empty( $result ) && is_array( $result ) ) { 96 $result['continue'] = false; 97 delete_option( 'tpba_cron_result' ); 98 delete_option( 'tpba_cron_message' ); 99 wp_send_json( $result ); 100 } else if ( get_transient( 'doing_cron' ) ) { 101 $message = get_option( 'tpba_cron_message' ); 102 if ( !empty( $message ) && is_array( $message ) ) { 103 wp_send_json( array( 104 'index' => $message['index'], 105 'data' => $message['data'], 106 'continue' => true 107 ) ); 108 } 109 } 110 98 111 wp_send_json( array( 99 'index' => 0, 100 'data' => esc_html__( 'Error when backup', 'tp-backup-automator' ) 112 'success' => false, 113 'data' => esc_html__( 'Error when backup', 'tp-backup-automator' ), 114 'continue' => false 101 115 ) ); 102 116 } … … 128 142 129 143 public static function restore_check_cron() { 130 $message = get_option( 'tpba_cron_message' ); 131 $data = get_option( 'tpba_restore_current' ); 132 133 if ( !empty( $message ) && is_array( $message ) ) { 134 wp_send_json( array( 135 'index' => $message['index'], 136 'data' => $message['data'], 137 'total_count' => $data['total_count'] 138 ) ); 139 } 140 141 142 wp_send_json( array( 143 'index' => 0, 144 'data' => '', 145 'total_count' => 0 146 ) ); 144 145 $result = get_option( 'tpba_cron_result' ); 146 147 if ( !empty( $result ) && is_array( $result ) ) { 148 149 $result['continue'] = false; 150 delete_option( 'tpba_cron_result' ); 151 wp_send_json( $result ); 152 153 } else if ( get_transient( 'doing_cron' ) ) { 154 155 $message = get_option( 'tpba_cron_message' ); 156 $data = get_option( 'tpba_restore_current' ); 157 158 if ( !empty( $message ) && is_array( $message ) ) { 159 wp_send_json( array( 160 'index' => $message['index'], 161 'data' => $message['data'], 162 'total_count' => $data['total_count'], 163 'continue'=>true 164 ) ); 165 } 166 } 167 168 die(); 147 169 } 148 170 … … 152 174 */ 153 175 public static function restore_track() { 176 154 177 sleep( 1 ); 155 $message = get_option( 'tpba_cron_message' ); 156 if ( !empty( $message ) && is_array( $message ) ) { 157 wp_send_json( array( 158 'index' => $message['index'], 159 'data' => $message['data'] 160 ) ); 161 } 178 179 $result = get_option( 'tpba_cron_result' ); 180 181 if ( !empty( $result ) && is_array( $result ) ) { 182 $result['continue'] = false; 183 delete_option( 'tpba_cron_result' ); 184 wp_send_json( $result ); 185 186 187 } else if ( get_transient( 'doing_cron' ) ) { 188 189 $message = get_option( 'tpba_cron_message' ); 190 if ( !empty( $message ) && is_array( $message ) ) { 191 wp_send_json( array( 192 'index' => $message['index'], 193 'data' => $message['data'], 194 'continue' => true 195 ) ); 196 } 197 } 198 199 162 200 163 201 wp_send_json( array( 164 'index' => -1, 165 'data' => esc_html__( 'There is nothing.', 'tp-backup-automator' ) 166 ) ); 167 } 168 169 public static function alldone() { 170 delete_option( 'tpba_backup_current' ); 171 delete_option( 'tpba_restore_current' ); 172 delete_option( 'tpba_cron_message' ); 173 update_option( 'tpba_alldone', 1 ); 174 wp_send_json_success( esc_html__( 'All done', 'tp-backup-automator' ) ); 202 'success' => false, 203 'data' => esc_html__( 'Error when restore a file', 'tp-backup-automator' ), 204 'continue' => false 205 ) ); 206 207 175 208 } 176 209 … … 283 316 ) ); 284 317 } 285 286 287 public static function abort(){288 289 } 318 319 public static function abort() { 320 321 } 322 290 323 } 291 324 -
tp-backup-automator/trunk/includes/class-tpba-cron.php
r1705516 r1709427 6 6 add_action( 'tpba_cron_backup', array( __CLASS__, 'do_backup' ) ); 7 7 add_action( 'tpba_cron_restore', array( __CLASS__, 'do_restore' ) ); 8 9 add_action( 'delete_transient_doing_cron', array( __CLASS__, 'cron_end' ) ); 8 10 } 9 11 10 12 public static function register_backup() { 11 13 if ( !wp_next_scheduled( 'tpba_cron_backup' ) ) { 12 wp_schedule_single_event( time() +1, 'tpba_cron_backup' );14 wp_schedule_single_event( time() - 1, 'tpba_cron_backup' ); 13 15 self::sendMessage( 0, esc_html__( 'Prepare files...', 'tp-backup-automator' ) ); 14 16 } … … 17 19 public static function register_restore() { 18 20 if ( !wp_next_scheduled( 'tpba_cron_restore' ) ) { 19 wp_schedule_single_event( time() +1, 'tpba_cron_restore' );21 wp_schedule_single_event( time() - 1, 'tpba_cron_restore' ); 20 22 self::sendMessage( 0, esc_html__( 'Prepare files...', 'tp-backup-automator' ) ); 21 23 } … … 41 43 42 44 $res = self::backup_file( $i, $session_id ); 43 update_option('test2', 'hihihi'); 44 self::sendMessage( $i, $res['data']); 45 46 $i++; 47 } 48 49 self::sendMessage( $total_count, esc_html__( 'Almost done', 'tp-backup-automator' ) ); 50 51 /** 52 * Backup done 53 * Remove sql file 54 */ 55 if ( is_dir( ABSPATH . 'tpba-sql' ) ) { 56 $scanner = new TPBA_Scanner(); 57 $scanner->delete_directory( ABSPATH . 'tpba-sql' ); 58 } 59 60 /** 61 * Save current locals to master 62 */ 63 $master = new TPBA_Master(); 64 $master->backup_changed(); 65 66 self::sendMessage( $total_count, esc_html__( 'Done', 'tp-backup-automator' ) ); 45 46 if ( $res ) { 47 $i++; 48 self::sendMessage( $i, $res['data'] ); 49 } else if ( $res == 0 ) { 50 51 /** 52 * If is lost connection 53 * Allow reconnect one time 54 */ 55 $res = self::backup_file( $i, $session_id ); 56 57 if ( $res ) { 58 $i++; 59 self::sendMessage( $i, $res['data'] ); 60 } else { 61 self::sendMessage( $total_count, esc_html__( 'The connection has been lost. Don\'t worry about it. Your data will be rolled back.' ) ); 62 sleep( 2 ); 63 return false; 64 } 65 } else { 66 self::sendMessage( $total_count, esc_html__( 'Some files were deleted during the backup running, please check them. Don\'t worry about it. Your data will be rolled back.' ) ); 67 sleep( 2 ); 68 return false; 69 } 70 } 71 72 self::sendMessage( $total_count, esc_html__( 'Almost done, please wait...', 'tp-backup-automator' ) ); 73 74 sleep( 2 ); 67 75 } else { 68 76 self::sendMessage( 0, esc_html__( 'Data backup is not avaiable.', 'tp-backup-automator' ) ); … … 80 88 $service = new TPBA_Services( $session_id ); 81 89 82 $res = $service->backup_file( $log_data['dir'], $log_data['file'], $log_data['checksums'], $log_data['file_status'] );90 $res = $service->backup_file( $log_data['dir'], $log_data['file'], $log_data['checksums'], $log_data['file_status'] ); 83 91 84 92 if ( !empty( $res['success'] ) ) { … … 87 95 $log->track( $log_data['ID'], $res['data'], 1 ); 88 96 $res['success'] = true; 89 } else if ( $res == 0 ) { 90 $log->track( $log_data['ID'], sprintf( esc_html__( 'Cannot remote %s file', 'tp-backup-automator' ), $log_data['file_status'] ), 0 ); 97 } else if ( $res === 0 ) { 98 $log->track( $log_data['ID'], sprintf( esc_html__( 'File is not exist', 'tp-backup-automator' ), $log_data['file_status'] ), 0 ); 99 return -1; 91 100 } else { 92 $log->track( $log_data['ID'], $res['server'], 0 ); 101 //Lost connection 102 return 0; 93 103 } 94 104 } else { 95 96 105 $res['success'] = false; 97 106 $res['data'] = sprintf( esc_html__( '%s not found.', 'tp-backup-automator' ), $log_data['file'] ); 98 $log->track( $log_data['ID'], $res ['data'], 0 );107 $log->track( $log_data['ID'], $res, 0 ); 99 108 } 100 109 … … 102 111 } 103 112 113 public static function backup_done() { 114 115 /** 116 * Backup done 117 * Remove sql file 118 */ 119 if ( is_dir( ABSPATH . 'tpba-sql' ) ) { 120 $scanner = new TPBA_Scanner(); 121 $scanner->delete_directory( ABSPATH . 'tpba-sql' ); 122 } 123 124 /** 125 * Save current locals to master 126 */ 127 $master = new TPBA_Master(); 128 $master->backup_changed(); 129 } 130 104 131 public static function do_restore() { 105 132 … … 110 137 111 138 $current = get_option( 'tpba_restore_current' ); 112 139 113 140 $service = new TPBA_Services(); 114 141 $service->remove_cache_activities(); … … 121 148 122 149 $res = self::restore_file( $i, $current['session_id'], $current['security'] ); 123 124 self::sendMessage( $i, $res ); 125 126 $i++; 127 } 128 129 self::sendMessage( $total_count, esc_html__( 'Almost done, Please wait...', 'tp-backup-automator' ) ); 130 131 sleep(1); 132 133 /** 134 * Restore done 135 */ 136 self::restore_done( $total_count ); 150 if ( $res ) { 151 $i++; 152 self::sendMessage( $i, $res ); 153 } else { 154 /** 155 * If is lost connection 156 * Allow reconnect one time 157 */ 158 $res = self::restore_file( $i, $current['session_id'], $current['security'] ); 159 160 if ( $res ) { 161 $i++; 162 self::sendMessage( $i, $res ); 163 } else { 164 self::sendMessage( $total_count, esc_html__( 'Some files cannot downloaded during the restore running. Don\'t worry about it. Your data will be rolled back.' ) ); 165 sleep( 2 ); 166 return false; 167 } 168 } 169 } 170 171 self::sendMessage( $total_count, esc_html__( 'Almost done, please wait...', 'tp-backup-automator' ) ); 172 sleep( 1 ); 137 173 } else { 138 self::sendMessage( 0, esc_html__( 'Data backup is not avaiable.', 'tp-backup-automator' ) );174 self::sendMessage( 0, esc_html__( 'Data to backup is not avaiable.', 'tp-backup-automator' ) ); 139 175 } 140 176 } … … 143 179 144 180 $service = new TPBA_Services( $session_id, $security_id ); 181 $scanner = new TPBA_Scanner(); 182 $log = new TPBA_Log(); 145 183 146 184 $file = $service->restore_file( $index ); 147 185 148 $file_path = $file['file']; 149 150 $dir = $file['dir']; 151 152 $file_path = str_replace( $dir . '/', '', $file_path ); 153 154 if ( $dir == 'root' ) { 155 $dir = ''; 156 } 157 158 $log = new TPBA_Log(); 186 $short_file = tpba_sanitize_file_from_server( $file ); 159 187 160 188 if ( $file['success'] ) { 161 189 162 $service->scanner->config_dir( untrailingslashit( ABSPATH . 'tpba/' . $dir ) ); 163 $res = $service->scanner->write_file( $file['content'], $file_path ); 164 165 $message = sprintf( esc_html__( '%s was not saved. ', 'tp-backup-automator' ), $file_path ); 190 $dir = $file['dir'] == 'root' ? '' : $file['dir']; 191 192 $real_file = ABSPATH . 'tpba/' . $dir . '/' . $short_file; 193 194 $res = $scanner->write_file( $file['content'], $real_file ); 195 196 $message = sprintf( esc_html__( '%s was not saved. ', 'tp-backup-automator' ), $short_file ); 166 197 167 198 if ( $res ) { 168 $message = sprintf( esc_html__( 'Prepare %s was done. ', 'tp-backup-automator' ), $ file_path);169 170 $log->add_file( $ file_path, $file['checksums'], $file['dir'], 'added', 1, $message );199 $message = sprintf( esc_html__( 'Prepare %s was done. ', 'tp-backup-automator' ), $short_file ); 200 201 $log->add_file( $short_file, $file['checksums'], $file['dir'], 'added', 1, $message ); 171 202 } 172 203 } else { 173 204 $message = $file['server']; 174 $log->add_file( $file_path, $file['checksums'], $file['dir'], 'added', 0, $message ); 205 $log->add_file( $short_file, $file['checksums'], $file['dir'], 'added', 0, $message ); 206 return 0; 175 207 } 176 208 … … 178 210 } 179 211 180 public static function restore_done( $total_count ) {181 182 $check_restore = true;183 212 public static function restore_done( $total_count, $session_id = '' ) { 213 /** 214 * Replace wp-content files 215 */ 184 216 $scanner = new TPBA_Scanner(); 185 186 /**187 * Replace files188 */189 217 $wp_content = str_replace( ABSPATH, '', WP_CONTENT_DIR ); 190 $check_restore = $scanner->replace_folder( ABSPATH . 'tpba/' . $wp_content, WP_CONTENT_DIR ); 191 192 /** 193 * Restore files done 194 */ 195 if ( $check_restore ) { 196 197 $list_sql = $scanner->scan_files( ABSPATH . 'tpba/sql' ); 198 199 if ( count( $list_sql ) ) { 200 201 $sql_dump = new TPBA_Sql_dump(); 202 203 foreach ( $list_sql as $sql ) { 204 /** 205 * Output: array('affected_rows' => 1, 'sql_file' => $sql, 'mysql_cli' => false, 'list_error' => $list_error); 206 */ 207 $sql_dump->import_SQL( $sql, false ); 208 } 209 } 210 211 $master = new TPBA_Master(); 212 $master->restore_changed(); 213 214 self::sendMessage( $total_count, esc_html__( 'All done', 'tp-backup-automator' ) ); 215 } else { 216 self::sendMessage( $total_count, esc_html__( 'Have an error while restore progress.', 'tp-backup-automator' ) ); 217 } 218 $downloaded_folder = ABSPATH . 'tpba/'; 219 220 $scanner->replace_folder( $downloaded_folder . $wp_content, WP_CONTENT_DIR ); 221 222 /** 223 * Replace sql 224 */ 225 $list_sql = $scanner->scan_files( $downloaded_folder . 'sql' ); 226 227 if ( count( $list_sql ) ) { 228 229 $sql_dump = new TPBA_Sql_dump(); 230 231 foreach ( $list_sql as $sql ) { 232 /** 233 * Output: array('affected_rows' => 1, 'sql_file' => $sql, 'mysql_cli' => false, 'list_error' => $list_error); 234 */ 235 $sql_dump->import_SQL( $sql, false ); 236 } 237 } 238 239 /** 240 * Remove downloaded folder when all replace 241 */ 242 $scanner->delete_directory( $downloaded_folder ); 243 244 /** 245 * Sync all restored data to master 246 */ 247 $master = new TPBA_Master(); 248 return $master->restore_changed(); 218 249 } 219 250 … … 226 257 } 227 258 259 /** 260 * Cron end 261 * @since 1.0.1 262 * @return void 263 */ 264 public static function cron_end() { 265 266 $backup = get_option( 'tpba_backup_current' ); 267 $restore = get_option( 'tpba_restore_current' ); 268 269 $res = false; 270 $data = ''; 271 $log = new TPBA_Log(); 272 273 if ( !empty( $backup['total_count'] ) && !empty( $backup['session_id'] ) ) { 274 275 $total_count = sanitize_text_field( $backup['total_count'] ); 276 $session_id = sanitize_text_field( $backup['session_id'] ); 277 $service = new TPBA_Services( $session_id ); 278 279 if ( $log->is_done() ) { 280 281 self::backup_done( $total_count, $session_id ); 282 $res = true; 283 $data = esc_html__( 'You have created a backup successfully.', 'tp-backup-automator' ); 284 } else { 285 $service->rollback(); 286 $data = esc_html__( 'Opps, this backup has not been done. All data will be rolled back.', 'tp-backup-automator' ); 287 } 288 289 update_option( 'tpba_cron_result', array( 'type' => 'backup', 'success' => $res, 'data' => $data ) ); 290 $service->remove_cache_activities(); 291 delete_option( 'tpba_backup_current' ); 292 } else if ( !empty( $restore['total_count'] ) && !empty( $restore['session_id'] ) ) {//Resore done 293 $total_count = sanitize_text_field( $restore['total_count'] ); 294 $session_id = sanitize_text_field( $restore['session_id'] ); 295 $service = new TPBA_Services( $session_id ); 296 $res = false; 297 298 if ( $log->is_done() ) { 299 $res = self::restore_done( $total_count, $session_id ); 300 } 301 302 if ( $res ) { 303 $data = esc_html__( 'Done! Your data has been restored successfully.', 'tp-backup-automator' ); 304 } else { 305 $service->rollback(); 306 $data = esc_html__( 'Opps, the restoration process cannot be completed now. Dont worry! Your data won\'t be affected.', 'tp-backup-automator' ); 307 } 308 309 delete_option( 'tpba_restore_current' ); 310 $service->remove_cache_activities(); 311 update_option( 'tpba_cron_result', array( 'type' => 'restore', 'success' => $res, 'data' => $data ) ); 312 } 313 314 315 delete_option( 'tpba_cron_message' ); 316 } 317 228 318 } 229 319 -
tp-backup-automator/trunk/includes/class-tpba-install.php
r1705516 r1709427 49 49 } 50 50 } 51 51 52 /** 53 * Un Install plugin 54 * @since 1.0.1 55 */ 56 public static function uninstall(){ 57 58 delete_transient('doing_cron'); 59 delete_option('tpba_restore_current'); 60 delete_option('tpba_backup_current'); 61 62 } 52 63 } -
tp-backup-automator/trunk/includes/class-tpba-master.php
r1705516 r1709427 201 201 * Insert all log to master when restore done 202 202 * @since 1.0.0 203 * @return void203 * @return bool 204 204 */ 205 205 public function restore_changed() { … … 216 216 $this->add(); 217 217 } 218 } 218 219 return true; 220 } 221 222 return false; 219 223 } 220 224 -
tp-backup-automator/trunk/includes/class-tpba-scanner.php
r1705516 r1709427 24 24 */ 25 25 public function config_dir( $dir ) { 26 27 if ( $dir == 'plugins' ) { 28 $dir = trailingslashit( WP_PLUGIN_DIR ); 29 } else if ( $dir == 'themes' ) { 30 $dir = trailingslashit( WP_CONTENT_DIR ) . 'themes/'; 31 } else if ( $dir == 'uploads' ) { 32 $uploadir = wp_upload_dir(); 33 $dir = trailingslashit( $uploadir['basedir'] ); 34 } else { 35 $dir = trailingslashit( WP_CONTENT_DIR ); 36 } 37 26 38 $this->dir = $dir; 27 39 } … … 296 308 * 297 309 * @param String $content File Content 298 * @param stirng $filename 310 * @param stirng $filename Real path file 299 311 * @return int File length 300 312 */ 301 313 public function write_file( $content, $filename ) { 302 314 303 $dir = $this->dir . '/' . $this->dir_of_file( $filename );315 $dir = $this->dir_of_file( $filename ); 304 316 305 317 if ( !is_dir( $dir ) ) { … … 307 319 } 308 320 309 $file = fopen( $this->dir . '/' .$filename, 'w' ) or die( 'Cannot open file: ' . $filename );321 $file = fopen($filename, 'w' ) or die( 'Cannot open file: ' . $filename ); 310 322 fwrite( $file, $content ); 311 323 return fclose( $file ); … … 333 345 334 346 $check_folder = $this->check_exist_folder( $folder_dest ); 347 335 348 // Remove original folder 336 349 if ( $check_folder ) { … … 339 352 // Create folder 340 353 @mkdir( $folder_dest, 0777, true ); 341 //chmod($folder_source, 0777); 354 342 355 // Copy folder source to folder destination 343 356 $check_replace = $this->recurse_copy( $folder_source, $folder_dest ); 344 357 345 358 // Remove source folder 346 //$check_replace = $this->delete_directory($folder_source);359 $check_replace = $this->delete_directory( $folder_source ); 347 360 348 361 return $check_replace; -
tp-backup-automator/trunk/includes/class-tpba-services.php
r1705516 r1709427 16 16 private $restore_security; 17 17 18 /**19 * @var string Full path from $dir20 */21 public $dir_path;22 23 /**24 * @var string Base path25 */26 public $dir;27 28 /**29 * @var object TPBA_Scanner30 */31 public $scanner;32 33 18 public function __construct( $session_id = '', $restore_security = '' ) { 34 19 35 20 parent::__construct(); 36 21 37 $this->session = $session_id;22 $this->session_id = $session_id; 38 23 $this->restore_security = $restore_security; 39 $this->scanner = new TPBA_Scanner(); 40 $this->dir = 'wp-content'; 41 $this->config_dir( 'wp-content' ); 42 } 43 24 } 25 26 /** 27 * Get magic method 28 * @param string $name Name of var 29 * @return var 30 */ 44 31 public function __get( $name ) { 45 32 return $this->$name; … … 47 34 48 35 /** 49 * Defined the path50 * @param string $dir51 * @return string Full path52 */53 public function get_dir( $dir ) {54 if ( $dir == 'plugins' ) {55 $dir = trailingslashit( WP_PLUGIN_DIR );56 } else if ( $dir == 'themes' ) {57 $dir = trailingslashit( WP_CONTENT_DIR ) . 'themes/';58 } else if ( $dir == 'uploads' ) {59 $uploadir = wp_upload_dir();60 $dir = trailingslashit( $uploadir['basedir'] );61 } else {62 $dir = trailingslashit( WP_CONTENT_DIR );63 }64 65 return $dir;66 }67 68 /**69 * Set local dir70 * @param string $dir71 * @return void72 */73 public function config_dir( $dir = '' ) {74 $this->dir_path = $this->get_dir( $dir );75 $this->scanner->config_dir( $this->dir_path );76 }77 78 /**79 36 * Create a connect backup 80 37 * @since 1.0.0 … … 83 40 public function connect_to_service() { 84 41 85 $local_files = $this->local_files();42 $local_files = tpba_local_files(); 86 43 87 44 $master = new TPBA_Master(); 88 $master_files = $master->get_master(); 89 90 $changed_files = $this->get_changed_files( $master_files, $local_files ); 91 $count_changed_files = $this->count_changed_files( $changed_files ); 45 $changed_files = tpba_get_changed_files( $master->get_master(), $local_files ); 46 $count_changed_files = tpba_count_changed_files( $changed_files ); 92 47 93 48 /** … … 154 109 * Save sql has changed content to local 155 110 */ 156 $this->dump_sql_changed( $changed_files['sql'] );111 tpba_dump_sql_changed( $changed_files['sql'] ); 157 112 158 113 update_option( 'tpba_backup_current', array( 'session_id' => $session_id, 'total_count' => $count_changed_files['all'] ) ); … … 192 147 } 193 148 194 if ( file_exists( $realfile ) || $status == 'deleted' ) { 195 196 $contents = $status != 'deleted' ? file_get_contents( $realfile ) : ''; 149 $file_exists = file_exists( $realfile ); 150 151 if ( $file_exists || $status == 'deleted' ) { 152 153 $contents = ''; 154 155 if ( $file_exists ) { 156 $contents = file_get_contents( $realfile ); 157 } 197 158 198 159 $response = wp_remote_post( $this->service_api . 'file', array( 199 'timeout' => 3000,160 'timeout' => 1500, 200 161 'headers' => array( 201 162 'remote' => 'FILE', … … 204 165 'file' => $file, 205 166 'status' => $status, 206 'session' => $this->session ,167 'session' => $this->session_id, 207 168 'dir' => $dir 208 169 ) ), … … 226 187 $res = array( 227 188 'status' => wp_remote_retrieve_response_code( $response ), 228 'data' => sprintf( esc_html__( '%s cannot completed.', 'tp-backup-automator' ), $file ),189 'data' => sprintf( esc_html__( '%s has error from service.', 'tp-backup-automator' ), $file ), 229 190 'success' => false, 230 191 'server' => wp_remote_retrieve_body( $response ) … … 240 201 } 241 202 203 if ( $res['status'] != 200 ) { 204 $res['data'] = esc_html__( 'Cannot create connect to service', 'tp-backup-automator' ); 205 return $res; 206 } 207 242 208 if ( !is_wp_error( $response ) ) { 243 209 … … 268 234 'headers' => array( 269 235 'authentication' => $this->token, 270 ), 'body' => array( 'session_restore' => $this->session ) ) );236 ), 'body' => array( 'session_restore' => $this->session_id ) ) ); 271 237 272 238 … … 302 268 if ( !empty( $response->session ) ) { 303 269 update_option( 'tpba_restore_current', array( 304 'total_count' => $response->file_count, 'session_id' => $this->session , 'security' => $response->session270 'total_count' => $response->file_count, 'session_id' => $this->session_id, 'security' => $response->session 305 271 ) ); 306 272 } … … 327 293 328 294 $response = wp_remote_post( $this->service_api . 'restore', array( 329 'timeout' => 30000,295 'timeout' => 1500, 330 296 'headers' => array( 331 297 'authentication' => $this->token, 332 298 ), 'body' => array( 333 'session_restore' => $this->session ,299 'session_restore' => $this->session_id, 334 300 'session' => $this->restore_security, 335 301 'index' => $index, … … 342 308 'server' => '', 343 309 'checksums' => '', 344 'success' => false 310 'success' => false, 311 'status' => wp_remote_retrieve_response_code( $response ) 345 312 ); 313 314 /** 315 * Check operation timed out 316 */ 317 if ( isset( $response->errors['http_request_failed'][0] ) ) { 318 $data['status'] = -1; 319 $data['data'] = esc_html__( '%s is response too long.', 'tp-backup-automator' ); 320 return $data; 321 } 322 323 if ( $data['status'] != 200 ) { 324 $data['server'] = esc_html__( 'Cannot create connect to service', 'tp-backup-automator' ); 325 return $data; 326 } 346 327 347 328 if ( !is_wp_error( $response ) ) { … … 358 339 if ( !empty( $response[3] ) ) { 359 340 if ( ($response[2] == 'sql') || strpos( $response[0], '.htacesss' ) > 0 || (strpos( $response[0], 'wp_config.php' ) > 0) ) { 360 $data['content'] = $this->update_new_domain( $response[3] );341 $data['content'] = tpba_update_new_domain( $response[3] ); 361 342 } else { 362 343 $data['content'] = $response[3]; … … 380 361 381 362 /** 382 * Replace old domain to new domain of SQL file 383 * 384 * @param string $content Content File 385 * @since 1.0.0 386 * 387 */ 388 private function update_new_domain( $content ) { 389 global $wpdb; 390 $old_domain = get_option( 'tpba_restore_domain' ); 391 $current_domain = get_site_url(); 392 $current_domain = format_address( $current_domain ); 393 394 return str_replace( $old_domain, $current_domain, $content ); 395 } 396 397 /** 398 * Compare repository with current files 399 * 400 * @param array $session_files File from session 401 * @param string $local_files Folder contain files 402 * 403 * @return array Group files with status 404 * @since 1.0.0 405 */ 406 private function compare_files( $session_files, $local_files ) { 407 408 $checked_files = array(); 409 410 $changed_files = array_diff_assoc( $local_files, $session_files ); 411 412 $new_files = array_diff_key( $local_files, $session_files ); 413 $deleted_files = array_diff_key( $session_files, $local_files ); 414 415 $checked_files['deleted'] = $deleted_files; 416 $checked_files['added'] = $new_files; 417 $checked_files['changed'] = array_diff_key( $changed_files, $new_files ); 418 return $checked_files; 419 } 420 421 /** 422 * Get all changed files from compare 423 * @since 1.0.0 424 * 425 * @param array $session_files File from session 426 * @param string $local_files Folder contain files 427 * @return array wp-content and sql file changed 428 */ 429 public function get_changed_files( $session_files, $local_files ) { 430 $sql = $this->compare_files( $session_files['sql'], $local_files['sql'] ); 431 $root = $this->compare_files( $session_files['root'], $local_files['root'] ); 432 $content = $this->compare_files( $session_files['wp-content'], $local_files['wp-content'] ); 433 $checked_files = array( 'sql' => $sql, 'root' => $root, 'wp-content' => $content ); 434 435 return $checked_files; 436 } 437 438 /** 439 * Count file changed 440 * @since 1.0.0 441 * 442 * @param array File after compared to local files 443 * @return array 444 */ 445 public function count_changed_files( $compare_files ) { 446 447 $count_content = count( $compare_files['wp-content']['deleted'] ); 448 $count_content += count( $compare_files['wp-content']['added'] ); 449 $count_content += count( $compare_files['wp-content']['changed'] ); 450 451 $count_sql = count( $compare_files['sql']['deleted'] ); 452 $count_sql += count( $compare_files['sql']['added'] ); 453 $count_sql += count( $compare_files['sql']['changed'] ); 454 455 $count_root = count( $compare_files['root']['deleted'] ); 456 $count_root += count( $compare_files['root']['added'] ); 457 $count_root += count( $compare_files['root']['changed'] ); 458 459 return array( 460 'wp-content' => $count_content, 461 'root' => $count_root, 462 'sql' => $count_sql, 463 'all' => ($count_content + $count_root + $count_sql) 464 ); 465 } 466 467 /** 468 * Scan all local file in wp-content with wp-config.php 469 * @since 1.0.0 470 * @return array Short path file with checksums 471 */ 472 public function local_files() { 473 474 $files = array(); 475 476 $files['sql'] = array(); 477 478 $sql = new TPBA_Sql(); 479 $tables = $sql->get_all_table(); 480 481 global $wpdb; 482 483 $ignore_tables = array( 484 $wpdb->prefix . 'tpba_master', 485 $wpdb->prefix . 'tpba_logs' 486 ); 487 488 foreach ( $tables as $table ) { 489 490 if ( !in_array( $table, $ignore_tables ) ) { 491 492 $sql_dump = new TPBA_Sql_dump(); 493 $sql_dump->table = $table; 494 $file = $sql_dump->toName(); 495 496 $contents = $sql_dump->toSQL( 0, 100000 ); 497 498 $files['sql'][$file] = md5( $contents ); 499 } 500 } 501 502 $files['root'] = array( 503 'wp-config.php' => $this->scanner->checksum_file( ABSPATH . 'wp-config.php' ), 504 '.htaccess' => $this->scanner->checksum_file( ABSPATH . '.htaccess' ) 505 ); 506 507 $files['wp-content'] = $this->scanner->checksum_files( WP_CONTENT_DIR, true ); 508 509 return $files; 510 } 511 512 /** 513 * @param array $sql 514 * @return void 515 */ 516 public function dump_sql_changed( $sql ) { 517 518 $sqls = $sql['changed'] + $sql['added']; 519 520 $this->scanner->config_dir( ABSPATH . 'tpba-sql' ); 521 522 foreach ( $sqls as $table => $checksums ) { 523 524 $sql_dump = new TPBA_Sql_dump(); 525 $dbname = $sql_dump->__get( 'db_name' ); 526 $name = str_replace( $dbname . '.', '', $table ); 527 $name = str_replace( '.sql', '', $name ); 528 $sql_dump->__set( 'table', $name ); 529 $this->scanner->write_file( $sql_dump->toSQL( 0, 100000 ), $sql_dump->toName() ); 530 } 363 * Rollback when a session was not done 364 * @since 1.0.0 365 */ 366 public function rollback() { 367 368 $response = wp_remote_post( $this->service_api . 'rollback', array( 369 'timeout' => 1500, 370 'headers' => array( 371 'authentication' => $this->token, 372 ), 'body' => array( 373 'session' => $this->session_id 374 ) 375 ) ); 376 377 return $this->remote_response( $response ); 531 378 } 532 379 … … 545 392 } 546 393 547 $response = wp_remote_get( $this->service_api . 'activity/' . $this->token . '?type=' . $type ); 394 $response = wp_remote_get( $this->service_api . 'activity/' . $this->token . '?type=' . $type, array( 'timeout' => 300 ) ); 395 /** 396 * Check operation timed out 397 */ 398 if ( isset( $response->errors['http_request_failed'][0] ) ) { 399 throw new Exception( esc_html__( 'Response to service is too long, pls try again.', 'tp-backup-automator' ), -1 ); 400 } 401 548 402 549 403 $status = wp_remote_retrieve_response_code( $response ); … … 594 448 update_option( 'themespond_key', '' ); 595 449 update_option( 'themespond_email', '' ); 596 wp_safe_redirect( admin_url('tools.php?page=tp-backup-automator'));450 wp_safe_redirect( admin_url( 'tools.php?page=tp-backup-automator' ) ); 597 451 exit(); 598 452 } … … 600 454 } 601 455 602 add_action( 'load-tools_page_tp-backup-automator', 'tpba_reset_key' );456 add_action( 'load-tools_page_tp-backup-automator', 'tpba_reset_key' ); -
tp-backup-automator/trunk/includes/class-tpba-sql-dump.php
r1705516 r1709427 23 23 // List column name of table 24 24 private $list_columns_name; 25 private $prefix; 25 26 26 27 public function __construct( $table_name = '' ) { … … 28 29 $this->db_name = $wpdb->dbname; 29 30 $this->table = $table_name; 31 $this->prefix = $wpdb->prefix; 30 32 } 31 33 … … 39 41 40 42 public function toName() { 41 return $this->db_name . '.' . $this->table. '.sql';43 return str_replace( $this->prefix, '', $this->table ) . '.sql'; 42 44 } 43 45 … … 56 58 // Delete if exist 57 59 58 $output = "DROP TABLE IF EXISTS ` " . $table . "`;\r\n-- --- \r\n";60 $output = "DROP TABLE IF EXISTS `$table`;\r\n-- --- \r\n"; 59 61 60 62 // Create table … … 71 73 72 74 foreach ( $rows as $row ) { 73 $cols = "INSERT INTO " . $table . "(";75 $cols = "INSERT INTO `$table` ("; 74 76 foreach ( $columns as $column ) { 75 77 // for custom queries we don't know the column types … … 253 255 exec( sprintf( '%s %s', escapeshellcmd( $mysql ), vsprintf( '-A --default-character-set=%s -u%s -p%s -h%s -P%s %s < %s', array_map( 'escapeshellarg', $params ) ) ), $output, $r ); 254 256 255 //if (0 === $r) { 257 256 258 if ( $delete ) { 257 259 @unlink( $sql_path ); 258 260 } 259 261 return array( 'affected_rows' => 1, 'sql_file' => $sql_path, 'mysql_cli' => true ); 260 //}261 262 } 262 263 … … 265 266 $sql_source = file_get_contents( $sql_path ); 266 267 $sql_queries = explode( "-- ---", $sql_source ); 268 267 269 foreach ( $sql_queries as $sql_query ) { 268 270 if ( !ctype_space( $sql_query ) ) { -
tp-backup-automator/trunk/includes/class-tpba-user.php
r1705516 r1709427 26 26 $this->tp_api = 'http://api.themespond.com/api/v1/'; 27 27 $this->service_api = 'http://api.themespond.com/api/v1/backup/'; 28 28 29 29 if ( !empty( $email ) ) { 30 30 $this->email = $email; -
tp-backup-automator/trunk/languages/tp-backup-automator.pot
r1705516 r1709427 4 4 "Project-Id-Version: PACKAGE VERSION\n" 5 5 "Report-Msgid-Bugs-To: \n" 6 "POT-Creation-Date: 2017-0 7-31 07:56+0000\n"6 "POT-Creation-Date: 2017-08-07 00:28+0000\n" 7 7 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 8 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 15 15 "X-Generator: Loco - https://localise.biz/" 16 16 17 #: tp-backup-automator.php:8 317 #: tp-backup-automator.php:84 18 18 #, php-format 19 19 msgid "" … … 22 22 msgstr "" 23 23 24 #: tp-backup-automator.php:8 724 #: tp-backup-automator.php:88 25 25 #, php-format 26 26 msgid "" … … 30 30 31 31 #. Name of the plugin 32 #: tp-backup-automator.php:11 6templates/plugin-page.php:1932 #: tp-backup-automator.php:118 templates/plugin-page.php:19 33 33 msgid "TP Backup Automator" 34 34 msgstr "" 35 35 36 #: tp-backup-automator.php:11 636 #: tp-backup-automator.php:118 37 37 msgid "Backup Automator" 38 38 msgstr "" 39 39 40 #: tp-backup-automator.php:17 4 includes/class-tpba-ajax.php:19340 #: tp-backup-automator.php:177 includes/class-tpba-ajax.php:226 41 41 msgid "Please, enter a valid email." 42 42 msgstr "" 43 43 44 #: tp-backup-automator.php:17 544 #: tp-backup-automator.php:178 45 45 msgid "Please, enter a valid product key." 46 46 msgstr "" 47 47 48 #: tp-backup-automator.php:17 648 #: tp-backup-automator.php:179 49 49 msgid "Connecting..." 50 50 msgstr "" 51 51 52 #: tp-backup-automator.php:1 7752 #: tp-backup-automator.php:180 53 53 msgid "Cannot prepare files." 54 54 msgstr "" 55 55 56 #: tp-backup-automator.php:178 includes/class-tpba-ajax.php:174 57 #: includes/class-tpba-cron.php:214 56 #: tp-backup-automator.php:181 58 57 msgid "All done" 59 58 msgstr "" 60 59 61 #: tp-backup-automator.php:1 7960 #: tp-backup-automator.php:182 62 61 msgid "Warning" 63 62 msgstr "" 64 63 65 #: tp-backup-automator.php:18 064 #: tp-backup-automator.php:183 66 65 msgid "files have backed up successfully." 67 66 msgstr "" 68 67 69 #: tp-backup-automator.php:18 168 #: tp-backup-automator.php:184 70 69 msgid "files have restored successfully." 71 70 msgstr "" 72 71 73 #: tp-backup-automator.php:18 272 #: tp-backup-automator.php:185 74 73 msgid "Are you sure you want to create a backup now?" 75 74 msgstr "" 76 75 77 #: tp-backup-automator.php:18 376 #: tp-backup-automator.php:186 78 77 msgid "All your current data will be changed, are you sure?" 79 78 msgstr "" 80 79 81 #: tp-backup-automator.php:22 5 tp-backup-automator.php:22580 #: tp-backup-automator.php:228 tp-backup-automator.php:228 82 81 msgid "Settings" 83 82 msgstr "" 84 83 85 #: includes/class-tpba-ajax.php:1 0084 #: includes/class-tpba-ajax.php:113 86 85 msgid "Error when backup" 87 86 msgstr "" 88 87 89 #: includes/class-tpba-ajax.php: 16590 msgid " There is nothing."91 msgstr "" 92 93 #: includes/class-tpba-ajax.php: 189 includes/class-tpba-ajax.php:23388 #: includes/class-tpba-ajax.php:203 89 msgid "Error when restore a file" 90 msgstr "" 91 92 #: includes/class-tpba-ajax.php:222 includes/class-tpba-ajax.php:266 94 93 msgid "Sorry, your security key did not verify." 95 94 msgstr "" 96 95 97 #: includes/class-tpba-ajax.php:2 3796 #: includes/class-tpba-ajax.php:270 98 97 msgid "Your product key can not be empty." 99 98 msgstr "" 100 99 101 #: includes/class-tpba-ajax.php:2 43100 #: includes/class-tpba-ajax.php:276 102 101 msgid "Email is not validate." 103 102 msgstr "" 104 103 105 #: includes/class-tpba-cron.php:1 3 includes/class-tpba-cron.php:20104 #: includes/class-tpba-cron.php:15 includes/class-tpba-cron.php:22 106 105 msgid "Prepare files..." 107 106 msgstr "" 108 107 109 #: includes/class-tpba-cron.php:49 110 msgid "Almost done" 111 msgstr "" 112 113 #: includes/class-tpba-cron.php:66 templates/backups.php:70 114 msgid "Done" 115 msgstr "" 116 117 #: includes/class-tpba-cron.php:68 includes/class-tpba-cron.php:138 108 #: includes/class-tpba-cron.php:72 includes/class-tpba-cron.php:171 109 msgid "Almost done, please wait..." 110 msgstr "" 111 112 #: includes/class-tpba-cron.php:76 118 113 msgid "Data backup is not avaiable." 119 114 msgstr "" 120 115 121 #: includes/class-tpba-cron.php: 86116 #: includes/class-tpba-cron.php:94 122 117 #, php-format 123 118 msgid "%s was %s" 124 119 msgstr "" 125 120 126 #: includes/class-tpba-cron.php:90 127 #, php-format 128 msgid "Cannot remote %s file" 129 msgstr "" 130 131 #: includes/class-tpba-cron.php:97 121 #: includes/class-tpba-cron.php:98 122 msgid "File is not exist" 123 msgstr "" 124 125 #: includes/class-tpba-cron.php:106 132 126 #, php-format 133 127 msgid "%s not found." 134 128 msgstr "" 135 129 136 #: includes/class-tpba-cron.php:1 29137 msgid " Almost done, Please wait..."138 msgstr "" 139 140 #: includes/class-tpba-cron.php:1 65130 #: includes/class-tpba-cron.php:174 131 msgid "Data to backup is not avaiable." 132 msgstr "" 133 134 #: includes/class-tpba-cron.php:196 141 135 #, php-format 142 136 msgid "%s was not saved. " 143 137 msgstr "" 144 138 145 #: includes/class-tpba-cron.php:1 68139 #: includes/class-tpba-cron.php:199 146 140 #, php-format 147 141 msgid "Prepare %s was done. " 148 142 msgstr "" 149 143 150 #: includes/class-tpba-cron.php:216 151 msgid "Have an error while restore progress." 152 msgstr "" 153 154 #: includes/class-tpba-services.php:121 includes/class-tpba-services.php:282 144 #: includes/class-tpba-cron.php:283 145 msgid "You have created a backup successfully." 146 msgstr "" 147 148 #: includes/class-tpba-cron.php:286 149 msgid "Opps, this backup has not been done. All data will be rolled back." 150 msgstr "" 151 152 #: includes/class-tpba-cron.php:303 153 msgid "Done! Your data has been restored successfully." 154 msgstr "" 155 156 #: includes/class-tpba-cron.php:306 157 msgid "" 158 "Opps, the restoration process cannot be completed now. Dont worry! Your data " 159 "won't be affected." 160 msgstr "" 161 162 #: includes/class-tpba-services.php:76 includes/class-tpba-services.php:248 163 #: includes/class-tpba-services.php:399 155 164 msgid "Response to service is too long, pls try again." 156 165 msgstr "" 157 166 158 #: includes/class-tpba-services.php: 126 includes/class-tpba-services.php:287159 #: includes/class-tpba-services.php: 556includes/class-tpba-user.php:72167 #: includes/class-tpba-services.php:81 includes/class-tpba-services.php:253 168 #: includes/class-tpba-services.php:410 includes/class-tpba-user.php:72 160 169 #: includes/class-tpba-user.php:112 161 170 msgid "Cannot connect to service." 162 171 msgstr "" 163 172 164 #: includes/class-tpba-services.php: 131 includes/class-tpba-services.php:560173 #: includes/class-tpba-services.php:86 includes/class-tpba-services.php:414 165 174 #: includes/class-tpba-user.php:76 includes/class-tpba-user.php:116 166 175 msgid "Error from service." 167 176 msgstr "" 168 177 169 #: includes/class-tpba-services.php:1 61178 #: includes/class-tpba-services.php:116 170 179 msgid "Connected." 171 180 msgstr "" 172 181 173 #: includes/class-tpba-services.php:1 66182 #: includes/class-tpba-services.php:121 174 183 msgid "Nothing changed now to backup" 175 184 msgstr "" 176 185 177 #: includes/class-tpba-services.php: 228178 #, php-format 179 msgid "%s cannot completed."180 msgstr "" 181 182 #: includes/class-tpba-services.php: 238186 #: includes/class-tpba-services.php:189 187 #, php-format 188 msgid "%s has error from service." 189 msgstr "" 190 191 #: includes/class-tpba-services.php:199 includes/class-tpba-services.php:319 183 192 #, php-format 184 193 msgid "%s is response too long." 185 194 msgstr "" 186 195 187 #: includes/class-tpba-services.php:299 196 #: includes/class-tpba-services.php:204 includes/class-tpba-services.php:324 197 msgid "Cannot create connect to service" 198 msgstr "" 199 200 #: includes/class-tpba-services.php:265 188 201 msgid "Connected" 189 202 msgstr "" 190 203 191 #: includes/class-tpba-services.php: 552204 #: includes/class-tpba-services.php:406 192 205 msgid "Email and product key are invalid." 193 206 msgstr "" … … 213 226 msgstr "" 214 227 228 #: templates/backups.php:70 229 msgid "Done" 230 msgstr "" 231 215 232 #: templates/backups.php:74 216 233 msgid "Error" … … 229 246 msgstr "" 230 247 231 #: templates/dashboard.php:3 0248 #: templates/dashboard.php:31 232 249 msgid "Recent activities" 233 250 msgstr "" 234 251 235 #: templates/dashboard.php:3 6252 #: templates/dashboard.php:37 236 253 msgid "Create a backup Now" 237 254 msgstr "" 238 255 239 #: templates/dashboard.php:7 6256 #: templates/dashboard.php:77 240 257 #, php-format 241 258 msgid "You have created a backup with %d changed files about %s ago." 242 259 msgstr "" 243 260 244 #: templates/dashboard.php: 79261 #: templates/dashboard.php:80 245 262 #, php-format 246 263 msgid "You have some error with a backup with %d changed files about %s ago." 247 264 msgstr "" 248 265 249 #: templates/dashboard.php:8 6250 #, php-format 251 msgid "You are restoring data with %d files, begin from %s ago."252 msgstr "" 253 254 #: templates/dashboard.php:8 8266 #: templates/dashboard.php:87 267 #, php-format 268 msgid "You are restoring data with %d files, begin from %s ago." 269 msgstr "" 270 271 #: templates/dashboard.php:89 255 272 #, php-format 256 273 msgid "You have restored all data with %d files about %s ago." 257 274 msgstr "" 258 275 259 #: templates/dashboard.php:10 2276 #: templates/dashboard.php:103 260 277 msgid "You have no activity to display." 261 278 msgstr "" -
tp-backup-automator/trunk/readme.txt
r1705516 r1709427 6 6 Requires at least: 4.0 7 7 Tested up to: 4.8 8 Stable tag: 1.0. 08 Stable tag: 1.0.1 9 9 License: GPLv3 10 10 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 65 65 == Changelog == 66 66 67 = 1.0.1 (August 07, 2017): = 68 * Rollback when restore or backup is not completed 69 67 70 = 1.0.0 (July 26, 2017): = 68 71 * Initial Public Release -
tp-backup-automator/trunk/templates/dashboard.php
r1705516 r1709427 21 21 echo '<div class="tpba_alert tpba_alert--error">' . $ex->getMessage() . ' ' . $button . '</div>'; 22 22 } 23 23 24 if ( $is_connect ): 24 25 ?> … … 84 85 if ( $session_id == $item->session ) { 85 86 $cssClass .= ' item-done'; 86 $content .= sprintf( esc_html__( 'You are restoring data with %d files, begin from %s ago.', 'tp-backup-automator' ), $item->total_count, $tagDate );87 $content .= sprintf( esc_html__( 'You are restoring data with %d files, begin from %s ago.', 'tp-backup-automator' ), $item->total_count, $tagDate ); 87 88 } else { 88 89 $content .= sprintf( esc_html__( 'You have restored all data with %d files about %s ago.', 'tp-backup-automator' ), $item->total_count, $tagDate ); … … 109 110 </table> 110 111 <?php 112 113 114 115 116 117 118 111 119 endif; -
tp-backup-automator/trunk/tp-backup-automator.php
r1705516 r1709427 5 5 * Plugin URI: https://wordpress.org/plugins/tp-backup-automator/ 6 6 * Description: Backup & Restore your WordPress data and keep it safe. 7 * Version: 1.0. 07 * Version: 1.0.1 8 8 * Author: ThemesPond 9 9 * Author URI: https://themespond.com/ … … 63 63 public function hook() { 64 64 register_activation_hook( __FILE__, array( 'TPBA_Install', 'install' ) ); 65 register_deactivation_hook( __FILE__, array( 'TPBA_Install', 'uninstall' ) ); 65 66 add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 15 ); 66 67 add_action( 'plugins_loaded', array( $this, 'load_plugin_textdomain' ) ); … … 98 99 99 100 require TPBA_DIR . 'includes/helper-functions.php'; 101 require TPBA_DIR . 'includes/file-functions.php'; 100 102 require TPBA_DIR . 'includes/class-tpba-ajax.php'; 101 103 require TPBA_DIR . 'includes/class-tpba-user.php'; … … 129 131 tpba_template( 'install', array( 'user' => $user ) ); 130 132 } 133 131 134 } 132 135 … … 152 155 define( 'TPBA_URL', plugin_dir_url( __FILE__ ) ); 153 156 define( 'TPBA_DIR', plugin_dir_path( __FILE__ ) ); 154 define( 'TPBA_VER', '1.0. 0' );157 define( 'TPBA_VER', '1.0.1' ); 155 158 } 156 159
Note: See TracChangeset
for help on using the changeset viewer.