35 include_once
'Services/Utilities/classes/class.ilFileUtilsException.php';
53 function processZipFile ($a_directory, $a_file, $structure,
$ref_id = null, $containerType = null, $tree = null, $access_handler = null) {
56 include_once(
"Services/Utilities/classes/class.ilUtil.php");
58 $pathinfo = pathinfo($a_file);
59 $file = $pathinfo[
"basename"];
64 move_uploaded_file($a_file, $a_directory .
"/" .
$file);
66 unlink ($a_directory .
"/" . $file);
73 if (empty($filearray)) {
79 foreach ($filearray[
"file"] as $key => $value)
82 if(substr($value, 0, 1) ==
"." || stristr($filearray[
"path"][$key],
"/__MACOSX/"))
84 unlink($filearray[
"path"][$key].$value);
85 unset($filearray[
"path"][$key]);
86 unset($filearray[
"file"][$key]);
94 unlink($filearray[path][$key]);
111 foreach (array_count_values($filearray[
"file"]) as $key => $value)
120 if (isset($doublettes))
122 throw new ilFileUtilsException($lng->txt(
"exc_upload_error") .
"<br />" . $lng->txt(
"zip_structure_error") . $doublettes ,
129 $mac_dir = $a_directory.
"/__MACOSX";
130 if(file_exists($mac_dir))
156 $dirlist = opendir($dir);
157 while (
false !== (
$file = readdir ($dirlist)))
159 if (!is_file($dir .
"/" .
$file) && !is_dir($dir .
"/" . $file))
164 if ($file !=
'.' && $file !=
'..')
166 $newpath = $dir.
'/'.
$file;
167 $level = explode(
'/',$newpath);
168 if (is_dir($newpath))
174 $arr[
"path"][] = $dir .
"/";
175 $arr[
"file"][] = end($level);
198 $dirlist = opendir($dir);
200 while (
false !== (
$file = readdir ($dirlist)))
202 if (!is_file($dir .
"/" .
$file) && !is_dir($dir .
"/" . $file))
206 if ($file !=
'.' && $file !=
'..')
208 $newpath = $dir.
'/'.
$file;
209 $level = explode(
'/',$newpath);
210 if (is_dir($newpath))
244 switch($containerType)
247 include_once(
"./Modules/Category/classes/class.ilObjCategory.php");
249 $newObj->setType(
"cat");
253 include_once(
"./Modules/Folder/classes/class.ilObjFolder.php");
255 $newObj->setType(
"fold");
258 case "WorkspaceFolder":
259 include_once(
"./Modules/WorkspaceFolder/classes/class.ilObjWorkspaceFolder.php");
264 $newObj->setTitle($name);
270 $newObj->createReference();
272 $newObj->setPermissions(
$ref_id);
274 if ($newObj->getType() ==
"cat")
277 $newObj->addTranslation($name,
"", $lng->getLangKey(), $lng->getLangKey());
280 return $newObj->getRefId();
285 $node_id = $tree->insertObject(
$ref_id, $newObj->getId());
286 $access_handler->setPermissions(
$ref_id, $node_id);
307 $permission = $rbacsystem->checkAccess(
"create",
$ref_id,
"file");
311 $permission = $access_handler->checkAccess(
"create",
"",
$ref_id,
"file");
316 include_once(
"./Modules/File/classes/class.ilObjFile.php");
318 $fileObj->setType($this->type);
323 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
331 $fileObj->createReference();
333 $fileObj->setPermissions(
$ref_id);
337 $node_id = $tree->insertObject(
$ref_id, $fileObj->getId());
338 $access_handler->setPermissions(
$ref_id, $node_id);
342 $fileObj->createDirectory();
346 $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
361 return (preg_match(
'%^(?:
362 [\x09\x0A\x0D\x20-\x7E] # ASCII
363 | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
364 | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
365 | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
366 | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
367 | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
368 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
369 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
370 )*$%xs', $string))? $string :
utf8_encode($string);
381 $fh = fopen($filein,
'rb');
382 $fh2= fopen($fileout,
'wb');
383 stream_filter_append($fh2,
'convert.base64-decode');
387 if ($chunk ===
false)
389 fwrite ($fh2, $chunk);
403 $fh = fopen($filein,
'rb');
404 $fh2= fopen($fileout,
'wb');
405 stream_filter_append($fh2,
'convert.base64-encode');
408 $chunk = fgets($fh,76);
409 if ($chunk ===
false)
413 fwrite ($fh2, $chunk);
430 if (!file_exists (
$in) || !is_readable (
$in))
432 if ((!file_exists (
$out) && !is_writable (dirname (
$out)) || (file_exists(
$out) && !is_writable(
$out)) ))
435 $in_file = fopen (
$in,
"rb");
436 if (!$out_file = gzopen (
$out,
"wb".$param)) {
440 while (!feof ($in_file)) {
441 $buffer = fgets ($in_file, 4096);
442 gzwrite ($out_file, $buffer, 4096);
461 if (!file_exists (
$in) || !is_readable (
$in))
463 if ((!file_exists (
$out) && !is_writable (dirname (
$out)) || (file_exists(
$out) && !is_writable(
$out)) ))
466 $in_file = gzopen (
$in,
"rb");
467 $out_file = fopen (
$out,
"wb");
469 while (!gzeof ($in_file)) {
470 $buffer = gzread ($in_file, 4096);
471 fwrite ($out_file, $buffer, 4096);
485 if(!file_exists($a_file) or !is_readable($a_file))
490 if(class_exists(
'finfo'))
492 $finfo =
new finfo(FILEINFO_MIME);
493 return $finfo->buffer(file_get_contents($a_file));
495 if(function_exists(
'mime_content_type'))
497 return mime_content_type($a_file);
499 return 'application/octet-stream';