archive_cleanup.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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', 'post', '', '', array(), FormValidator::LAYOUT_BOX);
  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. \Chamilo\CoreBundle\Composer\ScriptHandler::dumpCssFiles();
  24. if (!empty($htaccess)) {
  25. @file_put_contents($archive_path.'/.htaccess', $htaccess);
  26. }
  27. if ($result) {
  28. $message = 'ArchiveDirCleanupSucceeded';
  29. $type = 'confirmation';
  30. } else {
  31. $message = 'ArchiveDirCleanupFailed';
  32. $type = 'error';
  33. }
  34. header('Location: '.api_get_self().'?msg='.$message.'&type='.$type);
  35. exit;
  36. }
  37. Display::display_header(get_lang('ArchiveDirCleanup'));
  38. Display::display_warning_message(get_lang('ArchiveDirCleanupDescr'));
  39. if (isset($_GET['msg']) && isset($_GET['type'])) {
  40. if (in_array($_GET['msg'], array('ArchiveDirCleanupSucceeded', 'ArchiveDirCleanupFailed')))
  41. switch($_GET['type']) {
  42. case 'error':
  43. $message = Display::return_message(get_lang($_GET['msg']), 'error');
  44. break;
  45. case 'confirmation':
  46. $message = Display::return_message(get_lang($_GET['msg']), 'confirm');
  47. }
  48. }
  49. if (!empty($message)) {
  50. echo $message;
  51. }
  52. $form->display();
  53. Display::display_footer();