35 include_once
'Services/Utilities/classes/class.ilFileUtilsException.php';
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)
85 unlink($filearray[path][$key]);
103 foreach (array_count_values($filearray[
"file"]) as
$key => $value)
112 if (isset($doublettes))
114 throw new ilFileUtilsException($lng->txt(
"exc_upload_error") .
"<br />" . $lng->txt(
"zip_structure_error") . $doublettes ,
140 $dirlist = opendir(
$dir);
141 while (
false !== (
$file = readdir ($dirlist)))
143 if (!is_file(
$dir .
"/" .
$file) && !is_dir(
$dir .
"/" . $file))
148 if ($file !=
'.' && $file !=
'..')
151 $level = explode(
'/',$newpath);
152 if (is_dir($newpath))
158 $arr[
"path"][] =
$dir .
"/";
159 $arr[
"file"][] = end($level);
182 $dirlist = opendir(
$dir);
184 while (
false !== (
$file = readdir ($dirlist)))
186 if (!is_file(
$dir .
"/" .
$file) && !is_dir(
$dir .
"/" . $file))
190 if ($file !=
'.' && $file !=
'..')
193 $level = explode(
'/',$newpath);
194 if (is_dir($newpath))
228 if ($containerType ==
"Category")
230 include_once(
"./Modules/Category/classes/class.ilObjCategory.php");
232 $newObj->setType(
"cat");
234 if ($containerType ==
"Folder")
236 include_once(
"./Modules/Folder/classes/class.ilObjFolder.php");
238 $newObj->setType(
"fold");
241 $newObj->setTitle(
$name);
243 $newObj->createReference();
245 $newObj->setPermissions(
$ref_id);
246 $newObj->initDefaultRoles();
248 if ($newObj->getType() ==
"cat")
251 $newObj->addTranslation(
$name,
"", $lng->getLangKey(), $lng->getLangKey());
254 return $newObj->getRefId();
269 if ($rbacsystem->checkAccess(
"create",
$ref_id,
"file")) {
272 include_once(
"./Modules/File/classes/class.ilObjFile.php");
274 $fileObj->setType($this->type);
279 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
282 $fileObj->setFileSize(filesize($path.
"/" .
$filename));
284 $fileObj->createReference();
287 $fileObj->setPermissions(
$ref_id);
291 $fileObj->createDirectory();
296 $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
311 return (preg_match(
'%^(?:
312 [\x09\x0A\x0D\x20-\x7E] # ASCII
313 | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
314 | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
315 | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
316 | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
317 | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
318 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
319 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
320 )*$%xs', $string))? $string :
utf8_encode($string);
331 $fh = fopen($filein,
'rb');
332 $fh2= fopen($fileout,
'wb');
333 stream_filter_append($fh2,
'convert.base64-decode');
337 if ($chunk ===
false)
339 fwrite ($fh2, $chunk);
353 $fh = fopen($filein,
'rb');
354 $fh2= fopen($fileout,
'wb');
355 stream_filter_append($fh2,
'convert.base64-encode');
358 $chunk = fgets($fh,76);
359 if ($chunk ===
false)
363 fwrite ($fh2, $chunk);
380 if (!file_exists (
$in) || !is_readable (
$in))
382 if ((!file_exists (
$out) && !is_writable (dirname (
$out)) || (file_exists(
$out) && !is_writable(
$out)) ))
385 $in_file = fopen (
$in,
"rb");
386 if (!$out_file = gzopen (
$out,
"wb".
$param)) {
390 while (!feof ($in_file)) {
391 $buffer = fgets ($in_file, 4096);
392 gzwrite ($out_file, $buffer, 4096);
411 if (!file_exists (
$in) || !is_readable (
$in))
413 if ((!file_exists (
$out) && !is_writable (dirname (
$out)) || (file_exists(
$out) && !is_writable(
$out)) ))
416 $in_file = gzopen (
$in,
"rb");
417 $out_file = fopen (
$out,
"wb");
419 while (!gzeof ($in_file)) {
420 $buffer = gzread ($in_file, 4096);
421 fwrite ($out_file, $buffer, 4096);
435 if(!file_exists($a_file) or !is_readable($a_file))
440 if(class_exists(
'finfo'))
442 $finfo =
new finfo(FILEINFO_MIME);
443 return $finfo->buffer(file_get_contents($a_file));
445 if(function_exists(
'mime_content_type'))
447 return mime_content_type($a_file);
449 return 'application/octet-stream';