archive_cleanup.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.admin
  5. */
  6. $language_file = array('admin');
  7. // resetting the course id
  8. $cidReset = true;
  9. // including some necessary files
  10. require_once '../inc/global.inc.php';
  11. require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
  12. // setting the section (for the tabs)
  13. $this_section = SECTION_PLATFORM_ADMIN;
  14. // Access restrictions
  15. //api_protect_admin_script(true);
  16. api_protect_global_admin_script();
  17. // setting breadcrumbs
  18. $interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
  19. $form = new FormValidator('archive_cleanup_form');
  20. $form->addElement('style_submit_button','proceed', get_lang('ArchiveDirCleanupProceedButton'),'class="save"');
  21. if ($form->validate()) {
  22. $archive_path = api_get_path(SYS_ARCHIVE_PATH);
  23. $htaccess = @file_get_contents($archive_path.'.htaccess');
  24. $result = rmdirr($archive_path, true);
  25. if (!empty($htaccess)) {
  26. @file_put_contents($archive_path.'/.htaccess', $htaccess);
  27. }
  28. if ($result) {
  29. $message = 'ArchiveDirCleanupSucceeded';
  30. $type = 'confirmation';
  31. } else {
  32. $message = 'ArchiveDirCleanupFailed';
  33. $type = 'error';
  34. }
  35. header('Location: index.php?msg='.$message.'&type='.$type);
  36. exit;
  37. }
  38. Display::display_header(get_lang('ArchiveDirCleanup'));
  39. Display::display_normal_message(get_lang('ArchiveDirCleanupDescr'));
  40. $form->display();
  41. Display::display_footer();