Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/main/exercice/GC.php

88 lines
2.5 KiB

<?php // $Id: GC.php 10083 2006-11-21 19:43:29Z pcool $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Istvan Mandak
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* Code library for HotPotatoes integration.
*
* @author Istvan Mandak
* @package dokeos.exercise
==============================================================================
*/
// usage: HotPotGC($_configuration['root_sys'],$flag);
// working recursively, flag[0,1] print or delete the HotPotatoes temp files (.t.html)
echo "Garbage Collector<BR>";
HotPotGC($_configuration['root_sys'],1,1);
// functions
function HotPotGC($root_sys,$flag,$userID)
{
// flag[0,1] - print or delete the HotPotatoes temp files (.t.html)
$documentPath = $root_sys."courses";
require_once(api_get_path(LIBRARY_PATH)."fileManage.lib.php");
HotPotGCt($documentPath,$flag,$userID);
}
function HotPotGCt($folder,$flag,$userID)
{ // Garbage Collector
$filelist = array();
if ($dir = @opendir($folder)) {
while (($file = readdir($dir)) !== false) {
if ( $file != ".") {
if ($file != "..")
{
$full_name = $folder."/".$file;
if (is_dir($full_name))
{
HotPotGCt($folder."/".$file,$flag);
}
else
{
$filelist[] = $file;
}
}
}
}
closedir($dir);
}
while (list ($key, $val) = each ($filelist))
{
if (stristr($val,$userID.".t.html"))
{ if ($flag == 1)
{
my_delete($folder."/".$val);
}
else
{
echo $folder."/".$val."<BR>";
}
}
}
}
?>