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"];
 
   68                move_uploaded_file($a_file, $a_directory . 
"/" . 
$file);
 
   70                unlink ($a_directory . 
"/" . 
$file);
 
   77                if (empty($filearray)) {
 
   83                foreach ($filearray[
"file"] as $key => $value)
 
   86                        if(substr($value, 0, 1) == 
"." || stristr($filearray[
"path"][$key], 
"/__MACOSX/"))
 
   88                                unlink($filearray[
"path"][$key].$value);
 
   89                                unset($filearray[
"path"][$key]);
 
   90                                unset($filearray[
"file"][$key]);                                
 
   98                                unlink($filearray[path][$key]);
 
  115                        foreach (array_count_values($filearray[
"file"]) as $key => $value)
 
  124                        if (isset($doublettes))
 
  133                        $mac_dir = $a_directory.
"/__MACOSX";
 
  134                        if(file_exists($mac_dir))
 
  160                $dirlist = opendir($dir);
 
  161                while (
false !== (
$file = readdir ($dirlist)))
 
  163                        if (!is_file($dir . 
"/" .  
$file) && !is_dir($dir . 
"/" . 
$file)) 
 
  170                                $newpath = $dir.
'/'.
$file;
 
  171                                $level = explode(
'/',$newpath);
 
  172                                if (is_dir($newpath))
 
  178                                        $arr[
"path"][] = $dir . 
"/";
 
  179                                        $arr[
"file"][] = end($level);
 
  202                $dirlist = opendir($dir);
 
  204                while (
false !== (
$file = readdir ($dirlist)))
 
  206                        if (!is_file($dir . 
"/" . 
$file) && !is_dir($dir . 
"/" . 
$file)) 
 
  212                                $newpath = $dir.
'/'.
$file;
 
  213                                $level = explode(
'/',$newpath);
 
  214                                if (is_dir($newpath))
 
  248                switch($containerType)
 
  251                                include_once(
"./Modules/Category/classes/class.ilObjCategory.php");
 
  253                                $newObj->setType(
"cat");
 
  257                                include_once(
"./Modules/Folder/classes/class.ilObjFolder.php");
 
  259                                $newObj->setType(
"fold");               
 
  262                        case "WorkspaceFolder":
 
  263                                include_once(
"./Modules/WorkspaceFolder/classes/class.ilObjWorkspaceFolder.php");
 
  268                $newObj->setTitle($name);
 
  274                        $newObj->createReference();
 
  276                        $newObj->setPermissions(
$ref_id);
 
  278                        if ($newObj->getType() == 
"cat") 
 
  281                                $newObj->addTranslation($name,
"", 
$lng->getLangKey(), 
$lng->getLangKey());
 
  284                        self::$new_files[
$ref_id][] = $newObj;
 
  286                        return $newObj->getRefId();
 
  291                        $node_id = $tree->insertObject(
$ref_id, $newObj->getId());
 
  292                        $access_handler->setPermissions(
$ref_id, $node_id);
 
  313                        $permission = $rbacsystem->checkAccess(
"create", 
$ref_id, 
"file");
 
  317                        $permission = $access_handler->checkAccess(
"create", 
"", 
$ref_id, 
"file");
 
  322                        include_once(
"./Modules/File/classes/class.ilObjFile.php");
 
  324                        $fileObj->setType(
'file');
 
  329                        include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
  337                                $fileObj->createReference();    
 
  339                                $fileObj->setPermissions(
$ref_id);
 
  341                                self::$new_files[
$ref_id][] = $fileObj;
 
  345                                $node_id = $tree->insertObject(
$ref_id, $fileObj->getId());
 
  346                                $access_handler->setPermissions(
$ref_id, $node_id);
 
  350                        $fileObj->createDirectory();    
 
  374                return (preg_match(
'%^(?: 
  375                        [\x09\x0A\x0D\x20-\x7E]            # ASCII 
  376                        | [\xC2-\xDF][\x80-\xBF]             # non-overlong 2-byte 
  377                        |  \xE0[\xA0-\xBF][\x80-\xBF]        # excluding overlongs 
  378                        | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}  # straight 3-byte 
  379                        |  \xED[\x80-\x9F][\x80-\xBF]        # excluding surrogates 
  380                        |  \xF0[\x90-\xBF][\x80-\xBF]{2}     # planes 1-3 
  381                        | [\xF1-\xF3][\x80-\xBF]{3}          # planes 4-15 
  382                        |  \xF4[\x80-\x8F][\x80-\xBF]{2}     # plane 16 
  383                        )*$%xs', $string))? $string : 
utf8_encode($string);
 
  394                $fh = fopen($filein, 
'rb');
 
  395                $fh2= fopen($fileout, 
'wb');
 
  396                stream_filter_append($fh2, 
'convert.base64-decode');
 
  400                    if ($chunk === 
false)
 
  402                    fwrite ($fh2, $chunk);
 
  416                $fh = fopen($filein, 
'rb');
 
  417                $fh2= fopen($fileout, 
'wb');
 
  418                stream_filter_append($fh2, 
'convert.base64-encode');
 
  421                        $chunk = fgets($fh,76);
 
  422                        if ($chunk === 
false) 
 
  426                        fwrite ($fh2, $chunk);                  
 
  443    if (!file_exists (
$in) || !is_readable (
$in))
 
  445    if ((!file_exists (
$out) && !is_writable (dirname (
$out)) || (file_exists(
$out) && !is_writable(
$out)) ))
 
  448    $in_file = fopen (
$in, 
"rb");
 
  449    if (!$out_file = gzopen (
$out, 
"wb".$param)) {
 
  453    while (!feof ($in_file)) {
 
  454        $buffer = fgets ($in_file, 4096);
 
  455        gzwrite ($out_file, $buffer, 4096);
 
  474    if (!file_exists (
$in) || !is_readable (
$in))
 
  476    if ((!file_exists (
$out) && !is_writable (dirname (
$out)) || (file_exists(
$out) && !is_writable(
$out)) ))
 
  479    $in_file = gzopen (
$in, 
"rb");
 
  480    $out_file = fopen (
$out, 
"wb");
 
  482    while (!gzeof ($in_file)) {
 
  483        $buffer = gzread ($in_file, 4096);
 
  484        fwrite ($out_file, $buffer, 4096);
 
  499                $finfo = 
new finfo(FILEINFO_MIME);
 
  500                return $finfo->buffer($content);
 
  509                if(!file_exists($a_file) or !is_readable($a_file))
 
  514                return file_get_contents($a_file);
 
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.
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)
Class ilObjWorkspaceFolder.
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