archive_cleanup.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. // setting the section (for the tabs)
  12. $this_section = SECTION_PLATFORM_ADMIN;
  13. // Access restrictions
  14. api_protect_admin_script(true);
  15. // setting breadcrumbs
  16. $interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
  17. $form = new FormValidator('archive_cleanup_form');
  18. $form->addElement('style_submit_button','proceed', get_lang('ArchiveDirCleanupProceedButton'),'class="save"');
  19. $message = null;
  20. if ($form->validate()) {
  21. $archive_path = api_get_path(SYS_ARCHIVE_PATH);
  22. $htaccess = @file_get_contents($archive_path.'.htaccess');
  23. $result = rmdirr($archive_path, true, true);
  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_normal_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();