GC.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /*
  3. DOKEOS - elearning and course management software
  4. For a full list of contributors, see documentation/credits.html
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. See "documentation/licence.html" more details.
  10. Contact:
  11. Dokeos
  12. Rue des Palais 44 Paleizenstraat
  13. B-1030 Brussels - Belgium
  14. Tel. +32 (2) 211 34 56
  15. */
  16. /**
  17. * Code library for HotPotatoes integration.
  18. * @package dokeos.exercise
  19. * @author Istvan Mandak
  20. * @version $Id: GC.php 20451 2009-05-10 12:02:22Z ivantcholakov $
  21. */
  22. // usage: HotPotGC($_configuration['root_sys'],$flag);
  23. // working recursively, flag[0,1] print or delete the HotPotatoes temp files (.t.html)
  24. echo "Garbage Collector<BR>";
  25. HotPotGC($_configuration['root_sys'],1,1);
  26. // functions
  27. function HotPotGC($root_sys,$flag,$userID)
  28. {
  29. // flag[0,1] - print or delete the HotPotatoes temp files (.t.html)
  30. $documentPath = $root_sys."courses";
  31. require_once(api_get_path(LIBRARY_PATH)."fileManage.lib.php");
  32. HotPotGCt($documentPath,$flag,$userID);
  33. }
  34. function HotPotGCt($folder,$flag,$userID)
  35. { // Garbage Collector
  36. $filelist = array();
  37. if ($dir = @opendir($folder)) {
  38. while (($file = readdir($dir)) !== false) {
  39. if ( $file != ".") {
  40. if ($file != "..")
  41. {
  42. $full_name = $folder."/".$file;
  43. if (is_dir($full_name))
  44. {
  45. HotPotGCt($folder."/".$file,$flag);
  46. }
  47. else
  48. {
  49. $filelist[] = $file;
  50. }
  51. }
  52. }
  53. }
  54. closedir($dir);
  55. }
  56. while (list ($key, $val) = each ($filelist))
  57. {
  58. if (stristr($val,$userID.".t.html"))
  59. { if ($flag == 1)
  60. {
  61. my_delete($folder."/".$val);
  62. }
  63. else
  64. {
  65. echo $folder."/".$val."<br />";
  66. }
  67. }
  68. }
  69. }
  70. ?>