archive_cleanup.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.admin
  5. */
  6. // resetting the course id
  7. $cidReset = true;
  8. // including some necessary files
  9. require_once '../inc/global.inc.php';
  10. // setting the section (for the tabs)
  11. $this_section = SECTION_PLATFORM_ADMIN;
  12. // Access restrictions
  13. api_protect_admin_script(true);
  14. // setting breadcrumbs
  15. $interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
  16. $form = new FormValidator('archive_cleanup_form');
  17. $form->addButtonSend( get_lang('ArchiveDirCleanupProceedButton'));
  18. $message = null;
  19. if ($form->validate()) {
  20. $archive_path = api_get_path(SYS_ARCHIVE_PATH);
  21. $htaccess = @file_get_contents($archive_path.'.htaccess');
  22. $result = rmdirr($archive_path, true, true);
  23. if (!empty($htaccess)) {
  24. @file_put_contents($archive_path.'/.htaccess', $htaccess);
  25. }
  26. if ($result) {
  27. $message = 'ArchiveDirCleanupSucceeded';
  28. $type = 'confirmation';
  29. } else {
  30. $message = 'ArchiveDirCleanupFailed';
  31. $type = 'error';
  32. }
  33. header('Location: '.api_get_self().'?msg='.$message.'&type='.$type);
  34. exit;
  35. }
  36. Display::display_header(get_lang('ArchiveDirCleanup'));
  37. Display::display_warning_message(get_lang('ArchiveDirCleanupDescr'));
  38. if (isset($_GET['msg']) && isset($_GET['type'])) {
  39. if (in_array($_GET['msg'], array('ArchiveDirCleanupSucceeded', 'ArchiveDirCleanupFailed')))
  40. switch($_GET['type']) {
  41. case 'error':
  42. $message = Display::return_message(get_lang($_GET['msg']), 'error');
  43. break;
  44. case 'confirmation':
  45. $message = Display::return_message(get_lang($_GET['msg']), 'confirm');
  46. }
  47. }
  48. if (!empty($message)) {
  49. echo $message;
  50. }
  51. $form->display();
  52. Display::display_footer();