GC.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php // $Id: GC.php 9246 2006-09-25 13:24:53Z bmol $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Istvan Mandak
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * Code library for HotPotatoes integration.
  22. *
  23. * @author Istvan Mandak
  24. * @package dokeos.exercise
  25. ==============================================================================
  26. */
  27. // usage: HotPotGC($rootSys,$flag);
  28. // working recursively, flag[0,1] print or delete the HotPotatoes temp files (.t.html)
  29. $rootSys = "C:/Program Files/EasyPHP1-7/www/dokeos_new/";
  30. echo "Garbage Collector<BR>";
  31. HotPotGC($rootSys,1,1);
  32. // functions
  33. function HotPotGC($rootSys,$flag,$userID)
  34. { // flag[0,1] - print or delete the HotPotatoes temp files (.t.html)
  35. $documentPath = $rootSys."courses";
  36. require_once(api_get_path(LIBRARY_PATH)."fileManage.lib.php");
  37. HotPotGCt($documentPath,$flag,$userID);
  38. }
  39. function HotPotGCt($folder,$flag,$userID)
  40. { // Garbage Collector
  41. $filelist = array();
  42. if ($dir = @opendir($folder)) {
  43. while (($file = readdir($dir)) !== false) {
  44. if ( $file != ".") {
  45. if ($file != "..")
  46. {
  47. $full_name = $folder."/".$file;
  48. if (is_dir($full_name))
  49. {
  50. HotPotGCt($folder."/".$file,$flag);
  51. }
  52. else
  53. {
  54. $filelist[] = $file;
  55. }
  56. }
  57. }
  58. }
  59. closedir($dir);
  60. }
  61. while (list ($key, $val) = each ($filelist))
  62. {
  63. if (stristr($val,$userID.".t.html"))
  64. { if ($flag == 1)
  65. {
  66. my_delete($folder."/".$val);
  67. }
  68. else
  69. {
  70. echo $folder."/".$val."<BR>";
  71. }
  72. }
  73. }
  74. }
  75. ?>