archive_cleanup.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 __DIR__.'/../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(
  17. 'archive_cleanup_form',
  18. 'post',
  19. '',
  20. '',
  21. array(),
  22. FormValidator::LAYOUT_BOX
  23. );
  24. $form->addButtonSend(get_lang('ArchiveDirCleanupProceedButton'));
  25. if ($form->validate()) {
  26. $archive_path = api_get_path(SYS_ARCHIVE_PATH);
  27. $htaccess = @file_get_contents($archive_path.'.htaccess');
  28. $result = rmdirr($archive_path, true, true);
  29. try {
  30. \Chamilo\CoreBundle\Composer\ScriptHandler::dumpCssFiles();
  31. } catch (Exception $e) {
  32. error_log($e->getMessage());
  33. }
  34. if (!empty($htaccess)) {
  35. @file_put_contents($archive_path.'/.htaccess', $htaccess);
  36. }
  37. if (function_exists('opcache_reset')) {
  38. opcache_reset();
  39. }
  40. if ($result) {
  41. Display::addFlash(Display::return_message(get_lang('ArchiveDirCleanupSucceeded')));
  42. } else {
  43. Display::addFlash(Display::return_message(get_lang('ArchiveDirCleanupFailed'), 'error'));
  44. }
  45. header('Location: '.api_get_self());
  46. exit;
  47. }
  48. Display::display_header(get_lang('ArchiveDirCleanup'));
  49. echo Display::return_message(get_lang('ArchiveDirCleanupDescr'), 'warning');
  50. $form->display();
  51. Display::display_footer();