archive_cleanup.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 = api_rmdirr($archive_path, true);
  24. if (!empty($htaccess)) {
  25. @file_put_contents($archive_path.'/.htaccess', $htaccess);
  26. }
  27. if ($result) {
  28. // Creating temp folders
  29. /** @var ChamiloLMS\Component\DataFilesystem\DataFilesystem $filesystem */
  30. $filesystem = $app['chamilo.filesystem'];
  31. $filesystem->createFolders($app['temp.paths']->folders);
  32. $message = 'ArchiveDirCleanupSucceeded';
  33. $type = 'confirmation';
  34. } else {
  35. $message = 'ArchiveDirCleanupFailed';
  36. $type = 'error';
  37. }
  38. header('Location: '.api_get_self().'?msg='.$message.'&type='.$type);
  39. exit;
  40. }
  41. Display::display_header(get_lang('ArchiveDirCleanup'));
  42. Display::display_normal_message(get_lang('ArchiveDirCleanupDescr'));
  43. if (isset($_GET['msg']) && isset($_GET['type'])) {
  44. if (in_array($_GET['msg'], array('ArchiveDirCleanupSucceeded', 'ArchiveDirCleanupFailed')))
  45. switch($_GET['type']) {
  46. case 'error':
  47. $message = Display::return_message(get_lang($_GET['msg']), 'error');
  48. break;
  49. case 'confirmation':
  50. $message = Display::return_message(get_lang($_GET['msg']), 'confirm');
  51. }
  52. }
  53. if (!empty($message)) {
  54. echo $message;
  55. }
  56. $form->display();
  57. Display::display_footer();