archive_cleanup.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Chamilo\CoreBundle\Framework\Container;
  4. /**
  5. * @package chamilo.admin
  6. */
  7. // resetting the course id
  8. $cidReset = true;
  9. // setting the section (for the tabs)
  10. $this_section = SECTION_PLATFORM_ADMIN;
  11. // Access restrictions
  12. api_protect_admin_script(true);
  13. // setting breadcrumbs
  14. $interbreadcrumb[] = array('url' => Container::getRouter()->generate('administration'),'name' => get_lang('PlatformAdmin'));
  15. $form = new FormValidator('archive_cleanup_form', 'post', '', '', array(), FormValidator::LAYOUT_BOX);
  16. $form->addButtonSend(get_lang('ArchiveDirCleanupProceedButton'));
  17. if ($form->validate()) {
  18. $archive_path = api_get_path(SYS_ARCHIVE_PATH);
  19. $htaccess = @file_get_contents($archive_path.'.htaccess');
  20. $result = rmdirr($archive_path, true, true);
  21. \Chamilo\CoreBundle\Composer\ScriptHandler::dumpCssFiles();
  22. if (!empty($htaccess)) {
  23. @file_put_contents($archive_path.'/.htaccess', $htaccess);
  24. }
  25. if ($result) {
  26. Display::addFlash(Display::return_message(get_lang('ArchiveDirCleanupSucceeded')));
  27. } else {
  28. Display::addFlash(Display::return_message(get_lang('ArchiveDirCleanupFailed'), 'error'));
  29. }
  30. header('Location: '.api_get_self());
  31. exit;
  32. }
  33. Display::display_header(get_lang('ArchiveDirCleanup'));
  34. Display::display_warning_message(get_lang('ArchiveDirCleanupDescr'));
  35. $form->display();
  36. Display::display_footer();