backup.html.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php if (!defined('HTMLY')) die('HTMLy'); ?>
  2. <?php
  3. if (login()) {
  4. if (isset($_GET['file'])) {
  5. $file = _h($_GET['file']);
  6. $file = preg_replace('/\/|\\\\/','0',$file);
  7. if (!empty($file)) {
  8. unlink("backup/$file");
  9. }
  10. }
  11. }
  12. ?>
  13. <?php if (!extension_loaded('zip')) { ?>
  14. <div class="callout callout-info">
  15. <h5><i class="fa fa-info"></i> Note:</h5>
  16. Please install the ZIP extension to use the backup feature.
  17. </div>
  18. <?php } ?>
  19. <h2><?php echo i18n('Your_backups');?></h2>
  20. <br>
  21. <a class="btn btn-primary <?php if (!extension_loaded('zip')) { ?>disabled<?php } ?>" href="<?php echo site_url() ?>admin/backup-start"><?php echo i18n('Create_backup');?></a>
  22. <br><br>
  23. <?php
  24. if (isset($_SESSION[site_url()]['user'])) {
  25. $files = get_zip_files();
  26. if (!empty($files)) {
  27. krsort($files);
  28. echo '<table class="table backup-list">';
  29. echo '<tr class="head"><th>' . i18n('Filename') . '</th><th>'.i18n('Date').'</th><th>' . i18n('Operations') . '</th></tr>';
  30. foreach ($files as $file) {
  31. $arr = explode('_', pathinfo($file, PATHINFO_FILENAME));
  32. $t = str_replace('-', '', $arr[1]);
  33. $dt = new DateTime($t);
  34. $timestamp = $dt->format("D, d F Y, H:i:s");
  35. $url = site_url() . $file;
  36. echo '<tr>';
  37. echo '<td>' . pathinfo($file, PATHINFO_BASENAME) . '</td>';
  38. echo '<td>' . $timestamp . '</td>';
  39. echo '<td><a class="btn btn-primary btn-xs" target="_blank" href="' . $url . '">Download</a> <form method="GET"><input type="hidden" name="file" value="' . pathinfo($file, PATHINFO_BASENAME) . '"/><input type="submit" class="btn btn-danger btn-xs" name="submit" value="Delete"/></form></td>';
  40. echo '</tr>';
  41. }
  42. echo '</table>';
  43. } else {
  44. echo i18n('No_available_backup');
  45. }
  46. }
  47. ?>