PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/backupbuddy/destinations/local/_manage.php

https://bitbucket.org/betaimages/chakalos
PHP | 69 lines | 47 code | 14 blank | 8 comment | 7 complexity | 153068817386148df4c4a629d6dfc5c3 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. // @author Dustin Bolton 2012.
  3. // Set reference to destination.
  4. if ( isset( pb_backupbuddy::$options['remote_destinations'][pb_backupbuddy::_GET('destination_id')] ) ) {
  5. $destination = &pb_backupbuddy::$options['remote_destinations'][pb_backupbuddy::_GET('destination_id')];
  6. }
  7. // Welcome text.
  8. pb_backupbuddy::$ui->title( 'Local Destination `' . $destination['title'] . '`' );
  9. echo 'Listing backups in local directory `' . $destination['path'] . '`...<br><br>';
  10. // Handle deletion.
  11. if ( pb_backupbuddy::_POST( 'bulk_action' ) == 'delete_backup' ) {
  12. pb_backupbuddy::verify_nonce();
  13. $deleted_files = array();
  14. foreach( (array)pb_backupbuddy::_POST( 'items' ) as $item ) {
  15. @unlink( $destination['path'] . $item );
  16. if ( file_exists( $destination['path'] . $item ) ) {
  17. pb_backupbuddy::alert( 'Error: Unable to delete `' . $item . '`. Verify permissions.' );
  18. } else {
  19. $deleted_files[] = $item;
  20. }
  21. }
  22. if ( count( $deleted_files ) > 0 ) {
  23. pb_backupbuddy::alert( 'Deleted ' . implode( ', ', $deleted_files ) . '.' );
  24. }
  25. }
  26. // Find backups in directory.
  27. $backups = glob( $destination['path'] . '*.zip' );
  28. if ( !is_array( $backups ) ) {
  29. $backups = array();
  30. }
  31. // Generate array of table rows.
  32. $backup_list = array();
  33. foreach( $backups as $backup ) {
  34. $backup_list[basename($backup)] = array(
  35. basename( $backup ),
  36. pb_backupbuddy::$format->date(
  37. pb_backupbuddy::$format->localize_time( filemtime( $backup ) )
  38. ) . '<br /><span class="description">(' .
  39. pb_backupbuddy::$format->time_ago( filemtime( $backup ) ) .
  40. ' ago)</span>',
  41. pb_backupbuddy::$format->file_size( filesize( $backup ) ),
  42. );
  43. }
  44. // Render table.
  45. pb_backupbuddy::$ui->list_table(
  46. $backup_list,
  47. array(
  48. 'action' => pb_backupbuddy::page_url() . '&custom=remoteclient&destination_id=' . htmlentities( pb_backupbuddy::_GET( 'destination_id' ) ),
  49. 'columns' => array( 'Backup File', 'Last Modified', 'File Size' ),
  50. //'hover_actions' => array( 'copy' => 'Copy to Local' ),
  51. 'hover_action_column_key' => '0',
  52. 'bulk_actions' => array( 'delete_backup' => 'Delete' ),
  53. 'css' => 'width: 100%;',
  54. )
  55. );