remove.php 899 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /*
  3. * Download backup file
  4. */
  5. global $CONFIG;
  6. $files = get_input('file', false);
  7. $counter = 0;
  8. if ($files) {
  9. if (!is_array($files)) {
  10. $files = array($files);
  11. }
  12. //get path to default backup dir specified in plugin settings
  13. $backup_dir = elgg_get_plugin_setting('backup_dir', 'backup-tool');
  14. foreach ($files as $filename) {
  15. if ($filename) {
  16. $file_path = $backup_dir . $filename;
  17. if (file_exists($file_path)) {
  18. unlink($file_path);
  19. if (file_exists($file_path . ".ini")) {
  20. unlink($file_path . ".ini");
  21. }
  22. $counter++;
  23. }
  24. }
  25. }
  26. }
  27. if (!$counter) {
  28. register_error(elgg_echo("backup-tool:message:nofiles"));
  29. } else {
  30. system_message(elgg_echo("backup-tool:message:removed", array($counter)));
  31. }
  32. forward("admin/backups/list");