35include_once 
'Services/Utilities/classes/class.ilFileUtilsException.php';
 
   55        function processZipFile ($a_directory, $a_file, $structure, 
$ref_id = 
null, $containerType = 
null, $tree = 
null, $access_handler = 
null) {
 
   58                include_once(
"Services/Utilities/classes/class.ilUtil.php");
 
   60                self::$new_files = array();
 
   62                $pathinfo = pathinfo($a_file);
 
   63                $file = $pathinfo[
"basename"];
 
   66                if ($pathinfo[
"extension"] == 
"")
 
   76                unlink ($a_directory . 
"/" . 
$file);
 
   83                if (empty($filearray)) {
 
   89                foreach ($filearray[
"file"] as $key => $value)
 
   92                        if(substr($value, 0, 1) == 
"." || stristr($filearray[
"path"][$key], 
"/__MACOSX/"))
 
   94                                unlink($filearray[
"path"][$key].$value);
 
   95                                unset($filearray[
"path"][$key]);
 
   96                                unset($filearray[
"file"][$key]);                                
 
  104                                unlink($filearray[path][$key]);
 
  121                        foreach (array_count_values($filearray[
"file"]) as $key => $value)
 
  130                        if (isset($doublettes))
 
  139                        $mac_dir = $a_directory.
"/__MACOSX";
 
  140                        if(file_exists($mac_dir))
 
  166                $dirlist = opendir($dir);
 
  167                while (
false !== (
$file = readdir ($dirlist)))
 
  169                        if (!is_file($dir . 
"/" .  
$file) && !is_dir($dir . 
"/" . 
$file)) 
 
  176                                $newpath = $dir.
'/'.
$file;
 
  177                                $level = explode(
'/',$newpath);
 
  178                                if (is_dir($newpath))
 
  184                                        $arr[
"path"][] = $dir . 
"/";
 
  185                                        $arr[
"file"][] = end($level);
 
  208                $dirlist = opendir($dir);
 
  210                while (
false !== (
$file = readdir ($dirlist)))
 
  212                        if (!is_file($dir . 
"/" . 
$file) && !is_dir($dir . 
"/" . 
$file)) 
 
  218                                $newpath = $dir.
'/'.
$file;
 
  219                                $level = explode(
'/',$newpath);
 
  220                                if (is_dir($newpath))
 
  254                switch($containerType)
 
  257                                include_once(
"./Modules/Category/classes/class.ilObjCategory.php");
 
  259                                $newObj->setType(
"cat");
 
  263                                include_once(
"./Modules/Folder/classes/class.ilObjFolder.php");
 
  265                                $newObj->setType(
"fold");               
 
  268                        case "WorkspaceFolder":
 
  269                                include_once(
"./Modules/WorkspaceFolder/classes/class.ilObjWorkspaceFolder.php");
 
  274                $newObj->setTitle($name);
 
  280                        $newObj->createReference();
 
  282                        $newObj->setPermissions(
$ref_id);
 
  284                        if ($newObj->getType() == 
"cat") 
 
  287                                $newObj->addTranslation($name,
"", 
$lng->getLangKey(), 
$lng->getLangKey());
 
  290                        self::$new_files[
$ref_id][] = $newObj;
 
  292                        return $newObj->getRefId();
 
  297                        $node_id = $tree->insertObject(
$ref_id, $newObj->getId());
 
  298                        $access_handler->setPermissions(
$ref_id, $node_id);
 
  319                        $permission = $rbacsystem->checkAccess(
"create", 
$ref_id, 
"file");
 
  323                        $permission = $access_handler->checkAccess(
"create", 
"", 
$ref_id, 
"file");
 
  328                        include_once(
"./Modules/File/classes/class.ilObjFile.php");
 
  330                        $fileObj->setType(
'file');
 
  335                        include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
  343                                $fileObj->createReference();    
 
  345                                $fileObj->setPermissions(
$ref_id);
 
  347                                self::$new_files[
$ref_id][] = $fileObj;
 
  351                                $node_id = $tree->insertObject(
$ref_id, $fileObj->getId());
 
  352                                $access_handler->setPermissions(
$ref_id, $node_id);
 
  356                        $fileObj->createDirectory();    
 
  380                return (preg_match(
'%^(?: 
  381                        [\x09\x0A\x0D\x20-\x7E]            # ASCII 
  382                        | [\xC2-\xDF][\x80-\xBF]             # non-overlong 2-byte 
  383                        |  \xE0[\xA0-\xBF][\x80-\xBF]        # excluding overlongs 
  384                        | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}  # straight 3-byte 
  385                        |  \xED[\x80-\x9F][\x80-\xBF]        # excluding surrogates 
  386                        |  \xF0[\x90-\xBF][\x80-\xBF]{2}     # planes 1-3 
  387                        | [\xF1-\xF3][\x80-\xBF]{3}          # planes 4-15 
  388                        |  \xF4[\x80-\x8F][\x80-\xBF]{2}     # plane 16 
  389                        )*$%xs', $string))? $string : 
utf8_encode($string);
 
  400                $fh = fopen($filein, 
'rb');
 
  401                $fh2= fopen($fileout, 
'wb');
 
  402                stream_filter_append($fh2, 
'convert.base64-decode');
 
  406                    if ($chunk === 
false)
 
  408                    fwrite ($fh2, $chunk);
 
  422                $fh = fopen($filein, 
'rb');
 
  423                $fh2= fopen($fileout, 
'wb');
 
  424                stream_filter_append($fh2, 
'convert.base64-encode');
 
  427                        $chunk = fgets($fh,76);
 
  428                        if ($chunk === 
false) 
 
  432                        fwrite ($fh2, $chunk);                  
 
  449    if (!file_exists (
$in) || !is_readable (
$in))
 
  451    if ((!file_exists (
$out) && !is_writable (dirname (
$out)) || (file_exists(
$out) && !is_writable(
$out)) ))
 
  454    $in_file = fopen (
$in, 
"rb");
 
  455    if (!$out_file = gzopen (
$out, 
"wb".$param)) {
 
  459    while (!feof ($in_file)) {
 
  460        $buffer = fgets ($in_file, 4096);
 
  461        gzwrite ($out_file, $buffer, 4096);
 
  480    if (!file_exists (
$in) || !is_readable (
$in))
 
  482    if ((!file_exists (
$out) && !is_writable (dirname (
$out)) || (file_exists(
$out) && !is_writable(
$out)) ))
 
  485    $in_file = gzopen (
$in, 
"rb");
 
  486    $out_file = fopen (
$out, 
"wb");
 
  488    while (!gzeof ($in_file)) {
 
  489        $buffer = gzread ($in_file, 4096);
 
  490        fwrite ($out_file, $buffer, 4096);
 
  505                $finfo = 
new finfo(FILEINFO_MIME);
 
  506                return $finfo->buffer($content);
 
  515                if(!file_exists($a_file) or !is_readable($a_file))
 
  543                foreach (explode(
",", 
$ilSetting->get(
"suffix_repl_additional")) as $custom_black) {
 
  544                        $custom_black = trim(strtolower($custom_black));
 
  545                        if (($key = array_search($custom_black, $whitelist)) !== 
false) {
 
  546                                unset($whitelist[$key]);
 
  551                foreach (explode(
",", 
$ilSetting->get(
"suffix_custom_white_list")) as $custom_white) {
 
  552                        $custom_white = trim(strtolower($custom_white));
 
  553                        if (!in_array($custom_white, $whitelist)) {
 
  554                                $whitelist[] = $custom_white;
 
  791                $pi = pathinfo($a_filename);
 
  792                if (!in_array(strtolower($pi[
"extension"]), self::getValidExtensions())) {
 
  795                        $basename = str_replace(
".", 
"", $pi[
"basename"]);
 
  796                        if (trim($basename) == 
"")
 
  798                                include_once(
"./Services/Utilities/classes/class.ilFileUtilsException.php");
 
  802                        if ($pi[
"dirname"] != 
"" && ($pi[
"dirname"] != 
"." || substr($a_filename, 0, 2) == 
"./"))
 
  804                                $a_filename = $pi[
"dirname"].
"/".$basename;
 
  808                                $a_filename = $basename;
 
  823        public static function rename($a_source, $a_target)
 
  825                $pi = pathinfo($a_target);
 
  826                if (!in_array(strtolower($pi[
"extension"]), self::getValidExtensions()))
 
  828                        include_once(
"./Services/Utilities/classes/class.ilFileUtilsException.php");
 
  832                return rename($a_source, $a_target);
 
Class to report exception.
fileUtils class various functions for zip-archive handling
fastGunzip($in, $out)
fast uncompressing the file with the zlib-extension without memory consumption
createContainer($name, $ref_id, $containerType, $tree=null, $access_handler=null)
Creates and inserts container object (folder/category) into tree.
static getValidFilename($a_filename)
Get valid filename.
static getDefaultValidExtensionWhiteList()
Valid extensions.
static getValidExtensions()
createObjects($dir, $structure, $ref_id, $containerType, $tree=null, $access_handler=null)
Recursively scans a given directory and creates file and folder/category objects.
fastBase64Encode($filein, $fileout)
static lookupContentMimeType($content)
utf8_encode($string)
utf8-encodes string if it is not a valid utf8-string.
static _lookupMimeType($a_file)
processZipFile($a_directory, $a_file, $structure, $ref_id=null, $containerType=null, $tree=null, $access_handler=null)
unzips in given directory and processes uploaded zip for use as single files
fastGZip($in, $out, $level="9")
fast compressing the file with the zlib-extension without memory consumption
static createFile($filename, $path, $ref_id, $tree=null, $access_handler=null)
Creates and inserts file object into tree.
recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
static lookupFileMimeType($a_file)
fastBase64Decode($filein, $fileout)
static rename($a_source, $a_target)
Rename a file.
Class ilObjWorkspaceFolder.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled