24 require_once(
"classes/class.ilFileData.php");
59 define(
'EXERCISE_PATH',
'exercise');
68 $this->obj_id = $a_obj_id;
89 $dp = opendir($this->exercise_path);
91 while(
$file = readdir($dp))
100 if(!is_dir($this->exercise_path.
'/'.
$file))
104 'size' => filesize($this->exercise_path.
'/'.
$file),
106 'fullpath' => $this->exercise_path.
'/'.
$file);
119 $this->getExercisePath().
"/".$a_new_obj_id.
'_'.$file[
"name"]);
130 $delivered_file_path = $this->
getExercisePath() .
"/" . $this->obj_id .
"/";
131 if (is_dir($delivered_file_path))
133 include_once
"./Services/Utilities/classes/class.ilUtil.php";
153 if ($secure_filename)
160 if(isset($a_http_post_file) && $a_http_post_file[
'size'])
175 rename($a_http_post_file[
'tmp_name'],
196 if ($secure_filename)
203 if(count($content) > 0 )
212 if (!$vir[0] ||$vir[1] !=
"")
229 function deliverFile($a_http_post_file, $user_id, $is_unziped =
false)
235 if(isset($a_http_post_file) && $a_http_post_file[
'size'])
247 $savepath .=
'/' .$user_id;
248 if(!is_dir($savepath))
254 if (!is_dir($savepath))
256 require_once
"./Services/Utilities/classes/class.ilUtil.php";
257 #ilUtil::makeDirParents($savepath);
261 $prefix = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
"year"], $now[
"mon"], $now[
"mday"], $now[
"hours"],
262 $now[
"minutes"], $now[
"seconds"]);
268 $savepath .
"/" . $prefix .
"_" .
$filename);
273 rename($a_http_post_file[
'tmp_name'],
274 $savepath .
"/" . $prefix .
"_" .
$filename);
277 require_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
279 if (is_file($savepath .
"/" . $prefix .
"_" .
$filename))
282 "filename" => $prefix .
"_" . $filename,
283 "fullname" => $savepath .
"/" . $prefix .
"_" . $filename,
298 require_once
"./Services/Utilities/classes/class.ilUtil.php";
299 global
$lng, $ilObjDataCache;
310 if (!is_dir($savepath))
325 foreach ($members as $id => $object) {
326 $directory = $savepath.DIRECTORY_SEPARATOR.$id;
329 if ($dirsize > disk_free_space($tmpdir)) {
338 foreach ($members as $id =>
$user)
340 $sourcedir = $savepath.DIRECTORY_SEPARATOR.$id;
341 if (!is_dir($sourcedir))
345 if (array_key_exists($directory, $cache))
349 if (array_key_exists($directory, $cache)) {
351 $directory .=
"_".$id;
355 $cache[$directory] = $directory;
357 $sourcefiles = scandir($sourcedir);
358 foreach ($sourcefiles as $sourcefile) {
359 if ($sourcefile ==
"." || $sourcefile ==
"..")
361 $targetfile = trim(basename($sourcefile));
362 $pos = strpos($targetfile,
"_");
367 $targetfile= substr($targetfile, $pos + 1);
369 $targetfile = $directory.DIRECTORY_SEPARATOR.$targetfile;
370 $sourcefile = $sourcedir.DIRECTORY_SEPARATOR.$sourcefile;
372 if (!copy ($sourcefile, $targetfile))
375 $this->ilias->raiseError(
'Could not copy '.basename($sourcefile).
" to '".$targetfile.
"'.",
376 $this->ilias->error_obj->MESSAGE);
381 touch($targetfile, filectime($sourcefile));
388 $tmpzipfile = $tmpfile .
".zip";
394 $exerciseTitle = $ilObjDataCache->lookupTitle($this->
getObjId());
395 ilUtil::deliverFile($tmpzipfile, (strlen($exerciseTitle) == 0? strtolower($lng->txt(
"excs")) : $exerciseTitle).
".zip");
410 if(is_array($a_filenames))
412 foreach($a_filenames as
$file)
430 if(file_exists($this->exercise_path.
'/'.$this->obj_id.
'_'.$a_filename))
432 return unlink($this->exercise_path.
'/'.$this->obj_id.
'_'.$a_filename);
443 return $this->exercise_path.
'/'.$this->obj_id.
'_'.$a_path;
456 foreach($a_files as
$file)
458 if(!file_exists($this->exercise_path.
'/'.$this->obj_id.
'_'.$file))
487 if(is_writable($this->exercise_path) && is_readable($this->exercise_path))
493 $this->ilias->raiseError(
"Exercise directory is not readable/writable by webserver",$this->ilias->error_obj->FATAL);
504 if(is_writable($this->
getPath()))
519 if(file_exists($a_path))
522 return rename($a_path,$a_path.
'.old');