ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilFileUtils Class Reference

Class ilFileUtils. More...

+ Collaboration diagram for ilFileUtils:

Static Public Member Functions

static recursive_dirscan (string $dir, array &$arr)
 Recursively scans a given directory and writes path and filename into referenced array. More...
 
static utf8_encode (string $string)
 
static getValidFilename (string $a_filename)
 
static rename (string $a_source, string $a_target)
 
static rCopy (string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
 Copies content of a directory $a_sdir recursively to a directory $a_tdir. More...
 
static makeDirParents (string $a_dir)
 Create a new directory and all parent directories. More...
 
static getDataDir ()
 get data directory (outside webspace) More...
 
static dirsize (string $directory)
 get size of a directory or a file. More...
 
static makeDir (string $a_dir)
 creates a new directory and inherits all filesystem permissions of the parent directory You may pass only the name of your new directory or with the entire path or relative path information. More...
 
static moveUploadedFile (string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
 move uploaded file More...
 
static zip (string $a_dir, string $a_file, bool $compress_content=false)
 
static delDir (string $a_dir, bool $a_clean_only=false)
 removes a dir and all its content (subdirs and files) recursively More...
 
static getSafeFilename (string $a_initial_filename)
 
static getDir (string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
 get directory More...
 
static getWebspaceDir (string $mode="filesystem")
 get webspace directory More...
 
static createDirectory (string $a_dir, int $a_mod=0755)
 create directory More...
 
static getFileSizeInfo ()
 
static getASCIIFilename (string $a_filename)
 
static ilTempnam (?string $a_temp_path=null)
 Returns a unique and non existing Path for e temporary file or directory. More...
 
static unzip (string $a_file, bool $overwrite=false, bool $a_flat=false)
 unzip file More...
 
static renameExecutables (string $a_dir)
 
static rRenameSuffix (string $a_dir, string $a_old_suffix, string $a_new_suffix)
 Renames all files with certain suffix and gives them a new suffix. More...
 
static removeTrailingPathSeparators (string $path)
 
static getPhpUploadSizeLimitInBytes ()
 
static _sanitizeFilemame (string $a_filename)
 

Static Protected Member Functions

static sanitateTargetPath (string $a_target)
 

Detailed Description

Class ilFileUtils.

Deprecated:
All Methods are widely used and there is currently no other service providing all of them, but please do not implement new methods in this class.

Definition at line 35 of file class.ilFileUtils.php.

Member Function Documentation

◆ _sanitizeFilemame()

static ilFileUtils::_sanitizeFilemame ( string  $a_filename)
static

Definition at line 844 of file class.ilFileUtils.php.

References ilUtil\stripSlashes().

Referenced by ilFileDataMail\storeAsAttachment(), and ilFileDataMail\storeUploadedFile().

844  : string
845  {
846  return strip_tags(ilUtil::stripSlashes($a_filename));
847  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createDirectory()

static ilFileUtils::createDirectory ( string  $a_dir,
int  $a_mod = 0755 
)
static

create directory

Parameters
string$a_dir
int$a_mod
Deprecated:
in favour of Filesystem::createDir() located at the filesystem service.
See also
::createDir()

Definition at line 644 of file class.ilFileUtils.php.

References makeDir().

Referenced by ilPropertyFormGUI\appendOnloadCode(), ilExerciseManagementCollectFilesJob\createSubmissionsDirectory(), ilObjQuestionPool\exportXMLMediaObjects(), ilObjTest\exportXMLMediaObjects(), and ilTempnam().

644  : void
645  {
646  ilFileUtils::makeDir($a_dir);
647  }
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delDir()

static ilFileUtils::delDir ( string  $a_dir,
bool  $a_clean_only = false 
)
static

removes a dir and all its content (subdirs and files) recursively

public

Parameters
string$a_dirdir to delete
bool$a_clean_only
Author
Unknown flexe.nosp@m.r@cu.nosp@m.tephp.nosp@m..com (source: http://www.php.net/rmdir)
Deprecated:
in favour of Filesystem::deleteDir() located at the filesystem service.
See also
::deleteDir()

Definition at line 484 of file class.ilFileUtils.php.

Referenced by ilObjTest\_createImportDirectory(), assSingleChoice\afterSyncWithOriginal(), assMatchingQuestion\afterSyncWithOriginal(), ilScorm2004DataSet\afterXmlRecordWriting(), ilUserDataSet\afterXmlRecordWriting(), ilSurveyExport\buildExportFileXML(), ILIAS\TestQuestionPool\Import\buildImportQuestionsSelectionForm(), ilObjStyleSheet\cleanExportDirectory(), assOrderingQuestion\cleanImagefiles(), ilObjQuestionPoolGUI\cleanupAfterImport(), assLongMenu\clearFolder(), ilMobMultiSrtUpload\clearMultiSrtDirectory(), ilObjMediaObject\clearMultiSrtDirectory(), assQuestion\cloneSuggestedSolutionFiles(), ILIAS\Repository\IRSS\IRSSWrapper\createContainer(), ILIAS\Export\ExportHandler\Repository\Wrapper\IRSS\Handler\createEmptyContainer(), ILIAS\Export\ExportHandler\Manager\Handler\createExport(), ilCertificateUtilHelper\delDir(), ilObjFileBasedLM\delete(), ilObjSurvey\delete(), ilBadgeImageTemplate\delete(), SurveyQuestion\delete(), assQuestion\delete(), ilObjSAHSLearningModule\delete(), ilObjSurveyQuestionPool\deleteAllData(), ilFileDataMail\deleteAttachmentDirectory(), ILIAS\Mail\Cron\ExpiredOrOrphanedMails\MailDeletionHandler\deleteDirectory(), ilFileDataCourse\deleteDirectory(), ilObjSurveyQuestionPoolGUI\deleteExportFileObject(), ilFileSystemGUI\deleteFile(), ilObjQuestionPool\deleteQuestionpool(), ilBadge\deleteStaticFiles(), assQuestion\deleteSuggestedSolutions(), ilObjSurvey\deleteSurveyRecord(), ilObjTest\deleteTest(), ilObjCmiXapi\doDelete(), ilExport\exportEntity(), ilObjFileBasedLMGUI\exportHTML(), ilExportContainer\exportObject(), ilExport\exportObject(), ilObjUser\exportPersonalData(), ilObjContentObject\getExportDirectory(), ilObjSAHSLearningModuleGUI\importFile(), ilObjTestGUI\importFile(), ilObjQuestionPoolGUI\importFile(), ilObjSurveyQuestionPool\importObject(), ilObjQuestionPoolGUI\importQuestionsFile(), ilObjTestGUI\importVerifiedFileObject(), ILIAS\Notes\Export\NotesHtmlExport\initDirectories(), ILIAS\Wiki\Export\BlogHtmlExport\initDirectories(), ILIAS\Export\ExportHandler\Consumer\ExportOption\BasicLegacyHandler\onDeleteFiles(), ilTestExportOptionARC\onDeleteFiles(), ilDataCollectionExportOptionsXLSX\onDeleteFiles(), ilMediaPoolExportOptionXMLMaster\onDeleteFiles(), ilMediaPoolExportOptionXMLMasterNoMedia\onDeleteFiles(), ilHTLMExportOptionHTML\onExportOptionSelected(), ilExSubmission\processZipFile(), assKprimChoice\removeAnswerImage(), ilObjTest\removeTestResultsByActiveIds(), rRenameSuffix(), ILIAS\MediaCast\BackgroundTasks\DownloadAllZipJob\run(), ilSubmissionsZipJob\run(), ilCalendarZipJob\run(), ilZipJob\run(), assSingleChoice\saveAdditionalQuestionDataToDb(), assMultipleChoice\saveAdditionalQuestionDataToDb(), ilOrgUnitExporter\sendAndCreateSimpleExportFile(), ilMobMultiSrtUpload\uploadMultipleSubtitleFile(), ilObjMediaObject\uploadMultipleSubtitleFile(), ilUserCertificateZip\zipCertificatesInArchiveDirectory(), ILIAS\Notes\Export\NotesHtmlExport\zipPackage(), and ILIAS\Wiki\Export\BlogHtmlExport\zipPackage().

484  : void
485  {
486  if (!is_dir($a_dir) || is_int(strpos($a_dir, ".."))) {
487  return;
488  }
489 
490  $current_dir = opendir($a_dir);
491 
492  $files = [];
493 
494  // this extra loop has been necessary because of a strange bug
495  // at least on MacOS X. A looped readdir() didn't work
496  // correctly with larger directories
497  // when an unlink happened inside the loop. Getting all files
498  // into the memory first solved the problem.
499  while ($entryname = readdir($current_dir)) {
500  $files[] = $entryname;
501  }
502 
503  foreach ($files as $file) {
504  if (is_dir(
505  $a_dir . "/" . $file
506  ) && ($file !== "." && $file !== "..")) {
507  ilFileUtils::delDir($a_dir . "/" . $file);
508  } elseif ($file !== "." && $file !== "..") {
509  unlink($a_dir . "/" . $file);
510  }
511  }
512 
513  closedir($current_dir);
514  if (!$a_clean_only) {
515  @rmdir($a_dir);
516  }
517  }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the caller graph for this function:

◆ dirsize()

static ilFileUtils::dirsize ( string  $directory)
static

get size of a directory or a file.

Parameters
stringpath to a directory or a file
Returns
integer. Returns -1, if the directory does not exist.

Definition at line 263 of file class.ilFileUtils.php.

Referenced by ilObjSAHSLearningModuleAccess\_lookupDiskUsage(), ilObjMediaCastAccess\_lookupDiskUsage(), and ilObjFileBasedLMAccess\_lookupDiskUsage().

263  : int
264  {
265  $size = 0;
266  if (!is_dir($directory)) {
267  // dirsize of non-existing directory
268  $size = @filesize($directory);
269  return ($size === false) ? -1 : $size;
270  }
271  if ($DIR = opendir($directory)) {
272  while (($dirfile = readdir($DIR)) !== false) {
273  if (is_link(
274  $directory . DIRECTORY_SEPARATOR . $dirfile
275  )) {
276  continue;
277  }
278  if ($dirfile === '.') {
279  continue;
280  }
281  if ($dirfile === '..') {
282  continue;
283  }
284  if (is_file($directory . DIRECTORY_SEPARATOR . $dirfile)) {
285  $size += filesize(
286  $directory . DIRECTORY_SEPARATOR . $dirfile
287  );
288  } elseif (is_dir($directory . DIRECTORY_SEPARATOR . $dirfile)) {
289  $dirSize = ilFileUtils::dirsize(
290  $directory . DIRECTORY_SEPARATOR . $dirfile
291  );
292  if ($dirSize >= 0) {
293  $size += $dirSize;
294  } else {
295  return -1;
296  }
297  }
298  }
299  closedir($DIR);
300  }
301  return $size;
302  }
static dirsize(string $directory)
get size of a directory or a file.
+ Here is the caller graph for this function:

◆ getASCIIFilename()

static ilFileUtils::getASCIIFilename ( string  $a_filename)
static
Deprecated:

Definition at line 662 of file class.ilFileUtils.php.

References $DIC, and ilFileServicesPolicy\ascii().

Referenced by ilPropertyFormGUI\appendOnloadCode(), ILIAS\Wiki\Export\WikiHtmlExport\buildExportFile(), ilExerciseManagementCollectFilesJob\collectAssignmentData(), ilDownloadFilesBackgroundTask\collectFiles(), ILIAS\Exercise\Submission\SubmissionManager\copySubmissionsToDir(), ilFileDataMail\deliverAttachmentsAsZip(), ilObjTest\deliverPDFfromFO(), ilSurveyParticipantsGUI\exportAllCodesObject(), ilSurveyParticipantsGUI\exportCodesObject(), ilSurveyEvaluationGUI\exportCumulatedResults(), ilSurveyEvaluationGUI\exportEvaluationUser(), ilObjExercise\exportGradesExcel(), ilCOPageHTMLExport\exportHTMLFileDirect(), ilObjMediaObject\fixFilename(), ilObjWorkspaceFolderGUI\getBucketTitle(), ilContainerGUI\getBucketTitle(), ILIAS\Exercise\Submission\SubmissionManager\getDirectoryNameFromUserData(), ilExSubmission\getDirectoryNameFromUserData(), ilAssFileUploadUploadsExporter\getDispoZipFileName(), ilCollectWorkspaceFilesJob\getFileDirs(), ilTestParticipantData\getFileSystemCompliantFullnameByActiveId(), ilVerificationObject\getOfflineFilename(), ilDclPropertyFormGUI\getTempFilename(), ilObjTest\getTitleFilenameCompliant(), assQuestion\getTitleFilenameCompliant(), ilAssFileUploadUploadsExporter\initFilenames(), ilDclMobRecordFieldModel\parseValue(), ilCollectWorkspaceFilesJob\recurseFolder(), ilCollectFilesJob\recurseFolder(), ILIAS\MediaCast\BackgroundTasks\DownloadAllBackgroundTask\run(), ilDownloadSubmissionsBackgroundTask\run(), ilDownloadWorkspaceFolderBackgroundTask\run(), ilDownloadContainerFilesBackgroundTask\run(), ilDownloadFilesBackgroundTask\run(), ilQtiMatImageSecurity\sanitizeLabel(), ilChatroomHistoryGUI\showMessages(), ilObjMediaCastGUI\updateMediaItem(), and ILIAS\Test\ExportImport\CertificateExport\write().

662  : string
663  {
664  global $DIC;
665  $policy = new ilFileServicesPolicy($DIC->fileServiceSettings());
666  return $policy->ascii($a_filename);
667  }
Class ilFileServicesPolicy.
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDataDir()

static ilFileUtils::getDataDir ( )
static

get data directory (outside webspace)

Deprecated:
in favour of the filesystem service which should be used to operate on the storage directory.
See also
filesystem()
::storage()

Definition at line 250 of file class.ilFileUtils.php.

References CLIENT_DATA_DIR.

Referenced by ilAdvancedMDRecordImportFiles\__construct(), ilObjTest\_createImportDirectory(), ilHtmlPurifierAbstractLibWrapper\_getCacheDirectory(), ilExport\_getExportDirectory(), ilObjCategoryGUI\_getImportDir(), ilPropertyFormGUI\appendOnloadCode(), assLongMenu\buildFolderName(), ilObjStyleSheet\cleanExportDirectory(), ilDclPropertyFormGUI\cleanupTempFiles(), ilSimpleSAMLphpConfigTemplateHandler\copy(), ilChatroomConfigFileHandler\createDataDirIfNotExists(), ilObjTest\createExportDirectory(), ilObjContentObject\createExportDirectory(), ilObjSurveyQuestionPool\createExportDirectory(), ilObjUserFolder\createExportDirectory(), ilObjQuestionPool\createExportDirectory(), ilObjStyleSheet\createExportDirectory(), ilObjSurvey\createExportDirectory(), ilObjContentObject\createImportDirectory(), ilObjSurveyQuestionPool\createImportDirectory(), ilObjStyleSheet\createImportDirectory(), ilObjSurvey\createImportDirectory(), ilObjSurveyQuestionPool\deleteAllData(), ilObjQuestionPool\deleteQuestionpool(), ilObjSurvey\deleteSurveyRecord(), ilObjTest\deleteTest(), ilImportDirectory\getAbsolutePath(), ilExportImportDirectory\getAbsolutePathForHash(), ilSamlAuthFactory\getConfigDirectory(), ilObjContentObject\getDataDirectory(), ILIAS\Setup\RecordFilesMigration\getExportDir(), ilObjUserFolder\getExportDirectory(), ILIAS\Export\Setup\FilesToIRSSMigration\getExportDirectory(), ilObjTest\getExportDirectory(), ilObjContentObject\getExportDirectory(), ilObjSurveyQuestionPool\getExportDirectory(), ilObjQuestionPool\getExportDirectory(), ilObjSurvey\getExportDirectory(), ilObjContentObject\getImportDirectory(), ilObjSurveyQuestionPool\getImportDirectory(), ilObjSurvey\getImportDirectory(), ILIAS\Data\Password\LocalUserPasswordManager\getInstance(), ilFSStorageMail\getRelativePathExMailDirectory(), ilDclPropertyFormGUI\getTempFilename(), ilLMMultiSrt\getUploadDir(), ilMepMultiSrt\getUploadDir(), ilObjUserFolderGUI\handleUploadedFiles(), ilTempnam(), ilObjUserFolderGUI\importUserRoleAssignmentObject(), ilObjUserFolderGUI\importUsersObject(), ilTestQuestionPoolExporter\lookupExportDirectory(), ilXmlExporter\lookupExportDirectory(), ilDclPropertyFormGUI\rebuildTempFileByHash(), ilPropertyFormGUI\rebuildUploadedFiles(), ilObjectCustomIcon\saveFromTempFileName(), and ilObjStudyProgramme\updateCustomIcon().

250  : string
251  {
252  return CLIENT_DATA_DIR;
253  }
const CLIENT_DATA_DIR
Definition: constants.php:46
+ Here is the caller graph for this function:

◆ getDir()

static ilFileUtils::getDir ( string  $a_dir,
bool  $a_rec = false,
?string  $a_sub_dir = "" 
)
static

get directory

Parameters
string$a_dir
bool$a_rec
string | null$a_sub_dir
Returns
array
Deprecated:
in favour of Filesystem::listContents() located at the filesystem service.
See also
::listContents()

Definition at line 565 of file class.ilFileUtils.php.

Referenced by assOrderingQuestion\cleanImagefiles(), ilFileDataMail\getAttachmentPathAndFilenameByMd5Hash(), ilCertificateUtilHelper\getDir(), ilFileSystemGUI\getFileList(), ilUploadDirFilesTableGUI\getFiles(), ILIAS\Setup\RecordFilesMigration\getFiles(), ilMobMultiSrtUpload\getMultiSrtFiles(), ilObjMediaObject\getMultiSrtFiles(), ilObjUser\getPersonalDataExportFile(), ilObjMediaObject\getSrtFiles(), and ilFileSystemGUI\unzipFile().

569  : array {
570  $current_dir = opendir($a_dir . $a_sub_dir);
571 
572  $dirs = [];
573  $files = [];
574  $subitems = [];
575  while ($entry = readdir($current_dir)) {
576  if (is_dir($a_dir . "/" . $entry)) {
577  $dirs[$entry] = [
578  "type" => "dir",
579  "entry" => $entry,
580  "subdir" => $a_sub_dir
581  ];
582  if ($a_rec && $entry !== "." && $entry !== "..") {
583  $si = ilFileUtils::getDir(
584  $a_dir,
585  true,
586  $a_sub_dir . "/" . $entry
587  );
588  $subitems = array_merge($subitems, $si);
589  }
590  } elseif ($entry !== "." && $entry !== "..") {
591  $size = filesize($a_dir . $a_sub_dir . "/" . $entry);
592  $files[$entry] = [
593  "type" => "file",
594  "entry" => $entry,
595  "size" => $size,
596  "subdir" => $a_sub_dir
597  ];
598  }
599  }
600  ksort($dirs);
601  ksort($files);
602 
603  return array_merge($dirs, $files, $subitems);
604  }
static getDir(string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
get directory
+ Here is the caller graph for this function:

◆ getFileSizeInfo()

static ilFileUtils::getFileSizeInfo ( )
static

Definition at line 649 of file class.ilFileUtils.php.

References $DIC, and $lng.

Referenced by ilTinyMCE\addCustomRTESupport(), ilTinyMCE\addRTESupport(), ilAssSingleChoiceCorrectionsInputGUI\insert(), ilAssMultipleChoiceCorrectionsInputGUI\insert(), ilKprimChoiceWizardInputGUI\insert(), ilMultipleChoiceWizardInputGUI\insert(), ilMatchingWizardInputGUI\insert(), ilSingleChoiceWizardInputGUI\insert(), and ilMultipleImagesInputGUI\render().

649  : string
650  {
651  global $DIC;
652  $size = new DataSize(self::getPhpUploadSizeLimitInBytes(), DataSize::MB);
653  $max_filesize = $size->__toString();
654  $lng = $DIC->language();
655 
656  return $lng->txt("file_notice") . " $max_filesize.";
657  }
This class provides the data size with additional information to remove the work to calculate the siz...
Definition: DataSize.php:30
global $DIC
Definition: shib_login.php:22
global $lng
Definition: privfeed.php:31
+ Here is the caller graph for this function:

◆ getPhpUploadSizeLimitInBytes()

static ilFileUtils::getPhpUploadSizeLimitInBytes ( )
static
Deprecated:
should use DataSize instead

Definition at line 805 of file class.ilFileUtils.php.

Referenced by ilDAVContainer\createFile(), ILIAS\UI\Implementation\Component\Input\Container\Form\FormAdapterGUI\file(), ILIAS\FileServices\FileServicesLegacyInitialisationAdapter\getPhpUploadLimitInBytes(), ilDAVFile\put(), and ILIAS\FileUpload\FileUploadImpl\uploadSizeLimit().

805  : string
806  {
807  $convertPhpIniSizeValueToBytes = function ($phpIniSizeValue) {
808  if (is_numeric($phpIniSizeValue)) {
809  return $phpIniSizeValue;
810  }
811 
812  $suffix = substr($phpIniSizeValue, -1);
813  $value = substr($phpIniSizeValue, 0, -1);
814 
815  switch (strtoupper($suffix)) {
816  case 'P':
817  $value *= 1024;
818  // no break
819  case 'T':
820  $value *= 1024;
821  // no break
822  case 'G':
823  $value *= 1024;
824  // no break
825  case 'M':
826  $value *= 1024;
827  // no break
828  case 'K':
829  $value *= 1024;
830  break;
831  }
832 
833  return $value;
834  };
835 
836  $uploadSizeLimitBytes = min(
837  $convertPhpIniSizeValueToBytes(ini_get('post_max_size')),
838  $convertPhpIniSizeValueToBytes(ini_get('upload_max_filesize'))
839  );
840 
841  return $uploadSizeLimitBytes;
842  }
+ Here is the caller graph for this function:

◆ getSafeFilename()

static ilFileUtils::getSafeFilename ( string  $a_initial_filename)
static

Definition at line 519 of file class.ilFileUtils.php.

Referenced by ilExAssignment\instructionFileInsertOrder().

519  : string
520  {
521  $file_peaces = explode('.', $a_initial_filename);
522 
523  $file_extension = array_pop($file_peaces);
524 
525  if (SUFFIX_REPL_ADDITIONAL) {
526  $string_extensions = SUFFIX_REPL_DEFAULT . "," . SUFFIX_REPL_ADDITIONAL;
527  } else {
528  $string_extensions = SUFFIX_REPL_DEFAULT;
529  }
530 
531  $sufixes = explode(",", $string_extensions);
532 
533  if (in_array($file_extension, $sufixes)) {
534  $file_extension = "sec";
535  }
536 
537  $file_peaces[] = $file_extension;
538 
539  $safe_filename = "";
540  foreach ($file_peaces as $piece) {
541  $safe_filename .= "$piece";
542  if ($piece != end($file_peaces)) {
543  $safe_filename .= ".";
544  }
545  }
546 
547  return $safe_filename;
548  }
+ Here is the caller graph for this function:

◆ getValidFilename()

◆ getWebspaceDir()

static ilFileUtils::getWebspaceDir ( string  $mode = "filesystem")
static

get webspace directory

Parameters
string$modeuse "filesystem" for filesystem operations and "output" for output operations, e.g. images
Returns
string
Deprecated:
in favour of the filesystem service which should be used for operations on the web dir.
See also
filesystem()
Filesystems::web()

Definition at line 621 of file class.ilFileUtils.php.

References CLIENT_ID, and ILIAS_WEB_DIR.

Referenced by ilObjStyleSheet\_createImagesDirectory(), ilObjFileBasedLMAccess\_determineStartUrl(), ilContainer\_getContainerDirectory(), ilObjMediaObject\_getDirectory(), ilObjStyleSheet\_getImagesDirectory(), ilObjMediaObject\_getURL(), ilObjSAHSLearningModuleAccess\_lookupDiskUsage(), ilObjFileBasedLMAccess\_lookupDiskUsage(), ilPCTableGUI\_renderTable(), ilObjMediaObjectGUI\assignFullscreenObject(), ilObjMediaObjectGUI\assignStandardObject(), ilCmiXapiLaunchGUI\buildLaunchLink(), ilObjUser\copyProfilePicturesToDirectory(), ilContainer\createContainerDirectory(), ilObjSAHSLearningModule\createDataDirectory(), ilObjectCustomIcon\createFromImportDir(), ilObjStyleSheet\delete(), ilPageObjectGUI\displayMedia(), ilObjCmiXapi\doCloneObject(), ilObjCmiXapi\doDelete(), ilObjMediaObject\exportFiles(), ilCOPageHTMLExport\exportHTMLMOB(), ilCOPageHTMLExport\exportQuestionFiles(), ilStudyProgrammeTypeCustomIconsFormGUI\fillForm(), ilLTIConsumeProviderIcon\getAbsoluteFilePath(), ilCmiXapiContentUploadImporter\getAbsoluteObjectDirectory(), ilDidacticTemplateIconHandler\getAbsolutePath(), ilPCInteractiveImage\getBackgroundImage(), ilBadgeHandler\getBasePath(), ilPCTabsGUI\getCaptionForm(), ilObjSAHSLearningModule\getDataDirectory(), ilObjMediaObject\getDataDirectory(), ilCmiXapiDataSet\getDependencies(), ilScormAiccDataSet\getExtendedXmlRepresentation(), ILIAS\Object\Properties\CoreProperties\TileImage\ilObjectTileImage\getFullPath(), ilObjectCustomIcon\getFullPath(), ilOpenIdConnectSettings\getImageFilePath(), ilImageMapEditorGUI\getImageMapOutput(), ilFileDataCourse\getOnlineLink(), ILIAS\Style\Content\Style\StyleRepo\getPath(), ilFSStorageMail\getRelativePathExMailDirectory(), ilLMPresentationGUI\ilMedia(), ilUserCertificateGUI\listCertificates(), ilGlossaryPresentationGUI\media(), ilCmiXapiImporter\prepareLocalSourceStorage(), ilObjUserGUI\removeUserPictureObject(), ilPCTableGUI\renderCell(), ilCmiXapiContentUploadImporter\sanitizeObjectDirectory(), ilObjMediaPoolGUI\showMedia(), ilPageObjectGUI\showMediaFullscreen(), ilPageObjectGUI\showPage(), ilLMPresentationGUI\showPrintView(), and ilObjStyleSheet\writeCSSFile().

621  : string
622  {
623  if ($mode === "filesystem") {
624  return "./" . ILIAS_WEB_DIR . "/" . CLIENT_ID;
625  }
626  if (defined("ILIAS_MODULE")) {
627  return "../" . ILIAS_WEB_DIR . "/" . CLIENT_ID;
628  }
629  return "./" . ILIAS_WEB_DIR . "/" . CLIENT_ID;
630  }
const CLIENT_ID
Definition: constants.php:41
const ILIAS_WEB_DIR
Definition: constants.php:45
+ Here is the caller graph for this function:

◆ ilTempnam()

static ilFileUtils::ilTempnam ( ?string  $a_temp_path = null)
static

Returns a unique and non existing Path for e temporary file or directory.

Parameters
string | null$a_temp_path
Returns
string

Definition at line 676 of file class.ilFileUtils.php.

References createDirectory(), and getDataDir().

Referenced by ilImagemapPreview\__construct(), ilObjUserFolder\buildExportFile(), ilTestArchiveService\buildOverviewFilename(), ilDidacticTemplateSettingsGUI\checkInput(), ilVirusScanner\createBufferFile(), ILIAS\Repository\IRSS\IRSSWrapper\createContainer(), ILIAS\MediaCast\BackgroundTasks\DownloadAllCollectFilesJob\createDirectory(), ILIAS\Export\ExportHandler\Repository\Wrapper\IRSS\Handler\createEmptyContainer(), ilRestFileStorage\createFile(), ilAdvancedMDParser\createLocalRecord(), ilTestExportGUI\createTestArchiveExport(), ilCopyWorkspaceFilesToTempDirectoryJob\createUniqueTempDirectory(), ilCopyFilesToTempDirectoryJob\createUniqueTempDirectory(), ilCalendarCopyFilesToTempDirectoryJob\createUniqueTempDirectory(), ilExerciseManagementCollectFilesJob\createUniqueTempDirectory(), ilFileDataMail\deliverAttachmentsAsZip(), ilObjTest\deliverPDFfromFO(), ilMediaItem\determineDuration(), ilPageLayoutAdministrationGUI\exportLayout(), ilFFmpeg\extractPNGFromVideoInZip(), ILIAS\Test\ExportImport\ExportFilename\getPathname(), ilObjectCustomIconUploadHandlerGUI\getUploadResult(), ilUserDataSet\getXmlRecord(), ilFileXMLParser\handlerEndTag(), assOrderingQuestionImport\handleUploadedFile(), ilImport\importEntity(), ilObjSAHSLearningModuleGUI\importFile(), ilAssFileUploadUploadsExporter\initFilenames(), ilTestHTMLGenerator\makeHtmlDocument(), ilObjectCommonSettingFormAdapter\saveIcon(), ilUserImportParser\saveTempImage(), ilExcel\sendToClient(), ilRestFileStorage\storeFileForRest(), ilECSConnector\updateResource(), ilCalendarCategoryGUI\uploadAppointments(), ilObjLanguageExtGUI\uploadObject(), ILIAS\Test\ExportImport\ResultsExportExcel\write(), and ilExcel\writeToTmpFile().

676  : string
677  {
678  $temp_path = $a_temp_path ?? ilFileUtils::getDataDir() . "/temp";
679 
680  if (!is_dir($temp_path)) {
681  ilFileUtils::createDirectory($temp_path);
682  }
683  $temp_name = $temp_path . "/" . uniqid("tmp");
684 
685  return $temp_name;
686  }
static createDirectory(string $a_dir, int $a_mod=0755)
create directory
static getDataDir()
get data directory (outside webspace)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeDir()

static ilFileUtils::makeDir ( string  $a_dir)
static

creates a new directory and inherits all filesystem permissions of the parent directory You may pass only the name of your new directory or with the entire path or relative path information.

examples: a_dir = /tmp/tests/your_dir a_dir = ../tests/your_dir a_dir = your_dir (–> creates your_dir in current directory)

public

Parameters
string[path] + directory name
Returns
boolean
Deprecated:
in favour of Filesystem::createDir() located at the filesystem service.
See also
::createDir()

Definition at line 322 of file class.ilFileUtils.php.

References $path.

Referenced by ilFileDataCourse\__checkImportPath(), ilFileDataCourse\__checkPath(), ilFileDataCourse\__initDirectory(), ilObjStyleSheet\_createImagesDirectory(), ilObjTest\_createImportDirectory(), ilFileDataCourse\addDirectory(), ilSurveyExport\buildExportFileXML(), ilSurveyQuestionpoolExport\buildExportFileXML(), ilContObjectExport\buildExportFileXML(), ilQuestionpoolExport\buildExportFileXML(), ilContainer\createContainerDirectory(), ilObjSAHSLearningModule\createDataDirectory(), ilChatroomConfigFileHandler\createDataDirIfNotExists(), ilCOPageHTMLExport\createDirectories(), ilFileSystemGUI\createDirectory(), createDirectory(), ilObjTest\createExportDirectory(), ilObjContentObject\createExportDirectory(), ilObjSurveyQuestionPool\createExportDirectory(), ilObjUserFolder\createExportDirectory(), ilObjQuestionPool\createExportDirectory(), ilObjStyleSheet\createExportDirectory(), ilObjSurvey\createExportDirectory(), ilObjStyleSheet\createExportSubDirectory(), ilObjContentObject\createImportDirectory(), ilObjSurveyQuestionPool\createImportDirectory(), ilObjStyleSheet\createImportDirectory(), ilObjSurvey\createImportDirectory(), ilFileDataCourse\createOnlineVersion(), ilMediaItem\determineDuration(), ilObjQuestionPool\exportFileItems(), ilObjTest\exportFileItems(), ilObjMediaObject\exportFiles(), ilObjFileBasedLMGUI\exportHTML(), ilCOPageHTMLExport\exportHTMLFile(), ilCOPageHTMLExport\exportHTMLFileDirect(), ilCOPageHTMLExport\exportHTMLMOB(), ilPageLayoutAdministrationGUI\exportLayout(), ilObjLanguageExt\getDataPath(), ilUserDataSet\getXmlRecord(), ilObjSAHSLearningModuleGUI\importFile(), ILIAS\Notes\Export\NotesHtmlExport\initDirectories(), ILIAS\Wiki\Export\BlogHtmlExport\initDirectories(), ilFileDataImport\initExportDirectory(), ilSCORM13PlayerGUI\logDirectory(), ilHTLMExportOptionHTML\onExportOptionSelected(), ilForumXMLWriter\start(), and ILIAS\Test\ExportImport\Export\write().

322  : bool
323  {
324  $a_dir = trim($a_dir);
325 
326  // remove trailing slash (bugfix for php 4.2.x)
327  if (str_ends_with($a_dir, "/")) {
328  $a_dir = substr($a_dir, 0, -1);
329  }
330 
331  // check if a_dir comes with a path
332  if (($path = substr(
333  $a_dir,
334  0,
335  strrpos($a_dir, "/") - strlen($a_dir)
336  )) === '' || ($path = substr(
337  $a_dir,
338  0,
339  strrpos($a_dir, "/") - strlen($a_dir)
340  )) === '0') {
341  $path = ".";
342  }
343 
344  // create directory with file permissions of parent directory
345  if (is_dir($a_dir)) {
346  return true;
347  }
348  $old_mask = umask(0000);
349  $result = @mkdir($a_dir, fileperms($path));
350  umask($old_mask);
351 
352  return $result;
353  }
$path
Definition: ltiservices.php:29
+ Here is the caller graph for this function:

◆ makeDirParents()

static ilFileUtils::makeDirParents ( string  $a_dir)
static

Create a new directory and all parent directories.

Creates a new directory and inherits all filesystem permissions of the parent directory If the parent directories doesn't exist, they will be created recursively. The directory name NEEDS TO BE an absolute path, because it seems that relative paths are not working with PHP's file_exists function.

Parameters
string$a_dirThe directory name to be created public
Returns
bool
Author
Helmut Schottmüller hscho.nosp@m.ttm@.nosp@m.tzi.d.nosp@m.e
Deprecated:
in favour of Filesystem::createDir() located at the filesystem service.
See also
::createDir()

Definition at line 188 of file class.ilFileUtils.php.

Referenced by ilExport\_createExportDirectory(), ilHtmlPurifierAbstractLibWrapper\_getCacheDirectory(), ilExportContainer\addSubitems(), assSingleChoice\afterSyncWithOriginal(), assMatchingQuestion\afterSyncWithOriginal(), assLongMenu\assertDirExists(), ilQuestionpoolExport\buildExportFileXML(), assOrderingQuestion\cloneImages(), assMatchingQuestion\cloneImages(), assQuestion\cloneSuggestedSolutionFiles(), ilCopyWorkspaceFilesToTempDirectoryJob\copyFiles(), ilCopyFilesToTempDirectoryJob\copyFiles(), ilExerciseManagementCollectFilesJob\copyFileToSubDirectory(), assImagemapQuestion\copyImagemapFiles(), ILIAS\Exercise\Submission\SubmissionManager\copySubmissionsToDir(), ilCalendarCopyFilesToTempDirectoryJob\copyWithAbsolutePath(), ilCalendarCopyFilesToTempDirectoryJob\copyWithRId(), ilIndividualAssessmentFileStorage\create(), ilUserCertificateZip\createArchiveDirectory(), ilTestArchiver\createArchiveForTest(), ilLoggingErrorFileStorage\createDir(), ilSystemStyleHTMLExport\createDirectories(), ilCOPageHTMLExport\createDirectories(), ilFSStorageSession\createDirectory(), ILIAS\MediaCast\BackgroundTasks\DownloadAllCollectFilesJob\createDirectory(), ilObjMediaObject\createDirectory(), ILIAS\Export\ExportHandler\Manager\Handler\createExport(), ilObjContentObject\createExportDirectory(), ilExplorerBaseGUI\createHTMLExportDirs(), ilCopyWorkspaceFilesToTempDirectoryJob\createTargetDirectory(), ilCopyFilesToTempDirectoryJob\createTargetDirectory(), ilCalendarCopyFilesToTempDirectoryJob\createTargetDirectory(), ilExerciseManagementCollectFilesJob\createTargetDirectory(), ilTestExportGUI\createTestArchiveExport(), ilCopyWorkspaceFilesToTempDirectoryJob\createUniqueTempDirectory(), ilCopyFilesToTempDirectoryJob\createUniqueTempDirectory(), ilCalendarCopyFilesToTempDirectoryJob\createUniqueTempDirectory(), ilExerciseManagementCollectFilesJob\createUniqueTempDirectory(), assQuestion\duplicateSuggestedSolutionFiles(), assOrderingQuestionImport\ensureImagePathExists(), assOrderingQuestion\ensureImagePathExists(), ilDclContentExporter\export(), ilExport\exportEntity(), ilBibliographicDataSet\exportLibraryFile(), ilExportContainer\exportObject(), ilExport\exportObject(), ilCOPageHTMLExport\exportQuestionFiles(), ILIAS\components\Export\HTML\Util\exportResourceFile(), ilCOPageHTMLExport\exportResourceFile(), ilCOPageHTMLExport\exportStyles(), ILIAS\User\Export\UserHtmlExport\exportUserImages(), assMultipleChoiceImport\fromXML(), assImagemapQuestionImport\fromXML(), assSingleChoiceImport\fromXML(), assKprimChoiceImport\fromXML(), ilBadgeHandler\getBadgePath(), ilObjSurvey\getImportDirectory(), ilBadgeHandler\getInstancePath(), ilStyleExporter\getXmlRepresentation(), ilContentPageExporter\getXmlRepresentation(), ilForumExporter\getXmlRepresentation(), ilIndividualAssessmentExporter\getXmlRepresentation(), ilSurveyExporter\getXmlRepresentation(), ilMediaObjectsExporter\getXmlRepresentation(), ilBibliographicExporter\getXmlRepresentation(), ilDataCollectionExporter\getXmlRepresentation(), ilLMContentRendererGUI\handleCodeParagraph(), ilLMPresentationGUI\handleCodeParagraph(), assKprimChoice\handleFileUpload(), ilAdvancedMDRecordImportFiles\init(), ilFSStorageCourse\initInfoDirectory(), ilFSStorageGroup\initMemberExportDirectory(), ilFSStoragePRG\initMemberExportDirectory(), ilFSStorageCourse\initMemberExportDirectory(), ilObjQuestionPool\pasteFromClipboard(), ilObjSurveyQuestionPool\pasteFromClipboard(), ilFileExporter\prepareExportDirectories(), ilExport\processExporter(), assMatchingQuestionImport\saveImage(), assFileUpload\savePreviewData(), ilOrgUnitExporter\sendAndCreateSimpleExportFile(), assMultipleChoice\setImageFile(), assSingleChoice\setImageFile(), assMatchingQuestion\setImageFile(), assImagemapQuestion\setImageFilename(), SurveyQuestion\setMaterialsfile(), ilForumXMLWriter\start(), assQuestionGUI\suggestedsolution(), ilMobMultiSrtUpload\uploadMultipleSubtitleFile(), ilObjMediaObject\uploadMultipleSubtitleFile(), and ilObjStyleSheet\writeCSSFile().

188  : bool
189  {
190  $dirs = [$a_dir];
191  $a_dir = dirname($a_dir);
192  $last_dirname = '';
193  while ($last_dirname !== $a_dir) {
194  array_unshift($dirs, $a_dir);
195  $last_dirname = $a_dir;
196  $a_dir = dirname($a_dir);
197  }
198 
199  // find the first existing dir
200  $reverse_paths = array_reverse($dirs, true);
201  $found_index = -1;
202  foreach ($reverse_paths as $key => $value) {
203  if ($found_index != -1) {
204  continue;
205  }
206  if (!is_dir($value)) {
207  continue;
208  }
209  $found_index = $key;
210  }
211 
212  $old_mask = umask(0000);
213  foreach ($dirs as $dirindex => $dir) {
214  // starting with the longest existing path
215  if ($dirindex >= $found_index) {
216  if (!file_exists($dir)) {
217  if (strcmp(substr($dir, strlen($dir) - 1, 1), "/") == 0) {
218  // on some systems there is an error when there is a slash
219  // at the end of a directory in mkdir, see Mantis #2554
220  $dir = substr($dir, 0, strlen($dir) - 1);
221  }
222  if (!mkdir($dir)) {
223  error_log("Can't make directory: $dir");
224  return false;
225  }
226  } elseif (!is_dir($dir)) {
227  error_log("$dir is not a directory");
228  return false;
229  } else {
230  // get umask of the last existing parent directory
231  $umask = fileperms($dir);
232  }
233  }
234  }
235  umask($old_mask);
236 
237  return true;
238  }
+ Here is the caller graph for this function:

◆ moveUploadedFile()

static ilFileUtils::moveUploadedFile ( string  $a_file,
string  $a_name,
string  $a_target,
bool  $a_raise_errors = true,
string  $a_mode = "move_uploaded" 
)
static

move uploaded file

Parameters
string$a_file
string$a_name
string$a_target
bool$a_raise_errors
string$a_mode
Returns
bool
Exceptions
ilExceptionThrown if no uploaded files are found and raise error is set to true.
Deprecated:
in favour of the FileUpload service.
See also
upload()

Definition at line 398 of file class.ilFileUtils.php.

References $DIC, Vendor\Package\$e, getValidFilename(), and null.

Referenced by ilObjUserFolder\_updateAccountMailAttachment(), ilPropertyFormGUI\appendOnloadCode(), ilDidacticTemplateSettingsGUI\checkInput(), ilCourseFile\create(), assKprimChoice\handleFileUpload(), ilObjStyleSheet\import(), ilImport\importEntity(), ilObjSurvey\importObject(), ilPropertyFormGUI\moveFileUpload(), ilAdvancedMDRecordImportFiles\moveUploadedFile(), ilCertificateUtilHelper\moveUploadedFile(), ilObjSCORMLearningModuleGUI\newModuleVersionUpload(), ilExSubmission\processZipFile(), assFileUpload\savePreviewData(), assMultipleChoice\setImageFile(), assSingleChoice\setImageFile(), assMatchingQuestion\setImageFile(), assImagemapQuestion\setImageFilename(), SurveyQuestion\setMaterialsfile(), ilObjMediaObjectGUI\setObjectPerCreationForm(), assOrderingQuestion\storeImageFile(), ilFileDataMail\storeUploadedFile(), assQuestionGUI\suggestedsolution(), ilPCInteractiveImageGUI\update(), ilObjMediaCastGUI\updateMediaItem(), ilCalendarCategoryGUI\uploadAppointments(), ilIndividualAssessmentFileStorage\uploadFile(), ilBadgeImageTemplate\uploadImage(), ilBadge\uploadImage(), ilMobMultiSrtUpload\uploadMultipleSubtitleFile(), ilObjMediaObject\uploadMultipleSubtitleFile(), ilObjSAHSLearningModuleGUI\uploadObject(), and ilObjSurveyQuestionPoolGUI\uploadQuestionsObject().

404  : bool {
405  global $DIC;
406  $main_tpl = $DIC->ui()->mainTemplate();
407  $target_filename = basename($a_target);
408 
409  $target_filename = ilFileUtils::getValidFilename($target_filename);
410 
411  // Make sure the target is in a valid subfolder. (e.g. no uploads to ilias/setup_/....)
412  [$target_filesystem, $target_dir] = self::sanitateTargetPath($a_target);
413 
414  $upload = $DIC->upload();
415 
416  // If the upload has not yet been processed make sure he gets processed now.
417  if (!$upload->hasBeenProcessed()) {
418  $upload->process();
419  }
420 
421  try {
422  if (!$upload->hasUploads()) {
423  throw new ilException(
424  $DIC->language()->txt("upload_error_file_not_found")
425  );
426  }
427  $upload_result = $upload->getResults()[$a_file] ?? null;
428  if ($upload_result instanceof UploadResult) {
429  if (!$upload_result->isOK()) {
430  throw new ilException($upload_result->getStatus()->getMessage());
431  }
432  } else {
433  return false;
434  }
435  } catch (ilException $e) {
436  if (!$a_raise_errors) {
437  $main_tpl->setOnScreenMessage('failure', $e->getMessage(), true);
438  } else {
439  throw $e;
440  }
441 
442  return false;
443  }
444 
445  $upload->moveOneFileTo(
446  $upload_result,
447  $target_dir,
448  $target_filesystem,
449  $target_filename,
450  true
451  );
452 
453  return true;
454  }
static getValidFilename(string $a_filename)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rCopy()

static ilFileUtils::rCopy ( string  $a_sdir,
string  $a_tdir,
bool  $preserveTimeAttributes = false 
)
static

Copies content of a directory $a_sdir recursively to a directory $a_tdir.

Parameters
string$a_sdirsource directory
string$a_tdirtarget directory
boolean$preserveTimeAttributesif true, ctime will be kept.
Returns
boolean TRUE for sucess, FALSE otherwise
Exceptions
DirectoryNotFoundException
FileNotFoundException
IOExceptionpublic
Deprecated:
in favour of Filesystem::copyDir() located at the filesystem service.
See also
Filesystem::copyDir()

Definition at line 132 of file class.ilFileUtils.php.

Referenced by assSingleChoice\afterSyncWithOriginal(), assMatchingQuestion\afterSyncWithOriginal(), ilObjStyleSheet\copyImagesToDir(), ilObjectCustomIcon\createFromImportDir(), ilFileDataCourse\createOnlineVersion(), ilObjCmiXapi\doCloneObject(), ilObjStyleSheet\export(), ilObjMediaObject\exportFiles(), ilObjFileBasedLMGUI\exportHTML(), ilCOPageHTMLExport\exportHTMLMOB(), ilCOPageHTMLExport\exportQuestionFiles(), ilCOPageHTMLExport\exportStyles(), ilHTMLLearningModuleDataSet\getXmlRecord(), ilHTLMExportOptionHTML\onExportOptionSelected(), ilObjFileBasedLM\populateByDirectoy(), ilObjSAHSLearningModule\populateByDirectoy(), and ilFileDataCourse\rCopy().

136  : bool {
137  $sourceFS = LegacyPathHelper::deriveFilesystemFrom($a_sdir);
138  $targetFS = LegacyPathHelper::deriveFilesystemFrom($a_tdir);
139 
140  $sourceDir = LegacyPathHelper::createRelativePath($a_sdir);
141  $targetDir = LegacyPathHelper::createRelativePath($a_tdir);
142 
143  // check if arguments are directories
144  if (!$sourceFS->hasDir($sourceDir)) {
145  return false;
146  }
147 
148  $sourceList = $sourceFS->listContents($sourceDir, true);
149 
150  foreach ($sourceList as $item) {
151  if ($item->isDir()) {
152  continue;
153  }
154  try {
155  $itemPath = $targetDir . '/' . substr(
156  $item->getPath(),
157  strlen($sourceDir)
158  );
159  $stream = $sourceFS->readStream($item->getPath());
160  $targetFS->writeStream($itemPath, $stream);
161  } catch (FileAlreadyExistsException) {
162  // Do nothing with that type of exception
163  }
164  }
165 
166  return true;
167  }
+ Here is the caller graph for this function:

◆ recursive_dirscan()

static ilFileUtils::recursive_dirscan ( string  $dir,
array &  $arr 
)
static

Recursively scans a given directory and writes path and filename into referenced array.

Parameters
string$dirDirectory to start from
array&$arrReferenced array which is filled with Filename and path
Exceptions
ilFileUtilsException
Deprecated:
Will be removed completely with ILIAS 9

Definition at line 46 of file class.ilFileUtils.php.

References ilFileUtilsException\$BROKEN_FILE, $DIC, and $lng.

Referenced by ilExSubmission\processZipFile(), and ilFileSystemGUI\unzipFile().

46  : void
47  {
48  global $DIC;
49 
50  $lng = $DIC->language();
51 
52  $dirlist = opendir($dir);
53  while (false !== ($file = readdir($dirlist))) {
54  if (!is_file($dir . "/" . $file) && !is_dir($dir . "/" . $file)) {
55  throw new ilFileUtilsException(
56  $lng->txt("filenames_not_supported"),
58  );
59  }
60 
61  if ($file !== '.' && $file !== '..') {
62  $newpath = $dir . '/' . $file;
63  $level = explode('/', $newpath);
64  if (is_dir($newpath)) {
65  ilFileUtils::recursive_dirscan($newpath, $arr);
66  } else {
67  $arr["path"][] = $dir . "/";
68  $arr["file"][] = end($level);
69  }
70  }
71  }
72  closedir($dirlist);
73  }
static recursive_dirscan(string $dir, array &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
global $DIC
Definition: shib_login.php:22
global $lng
Definition: privfeed.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ removeTrailingPathSeparators()

◆ rename()

static ilFileUtils::rename ( string  $a_source,
string  $a_target 
)
static
Deprecated:

Definition at line 100 of file class.ilFileUtils.php.

References $DIC.

Referenced by ilAssFileUploadUploadsExporter\createFileUploadCollectionZipFile(), ilObjSAHSLearningModuleGUI\importFile(), ilScormAiccImporter\importXmlRepresentation(), ilPropertyFormGUI\moveFileUpload(), ilObjSCORMLearningModuleGUI\newModuleVersionUpload(), ilDclMobRecordFieldModel\parseValue(), ilObjSurveyQuestionPool\pasteFromClipboard(), ilFileSystemGUI\renameFile(), ilFileDataMail\rotateFiles(), rRenameSuffix(), and assOrderingQuestion\updateImageFile().

100  : bool
101  {
102  $pi = pathinfo($a_target);
103  global $DIC;
104  $sanitizer = new ilFileServicesFilenameSanitizer(
105  $DIC->fileServiceSettings()
106  );
107 
108  if (!$sanitizer->isClean($a_target)) {
109  throw new ilFileUtilsException("Invalid target file");
110  }
111 
112  return rename($a_source, $a_target);
113  }
global $DIC
Definition: shib_login.php:22
Class ilFileServicesFilenameSanitizer.
static rename(string $a_source, string $a_target)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ renameExecutables()

static ilFileUtils::renameExecutables ( string  $a_dir)
static
Deprecated:

Definition at line 715 of file class.ilFileUtils.php.

Referenced by ilObjSAHSLearningModuleGUI\importFile(), ilScormAiccImporter\importXmlRepresentation(), ilObjSCORMLearningModuleGUI\newModuleVersionUpload(), ilDclMobRecordFieldModel\parseValue(), ilObjFileBasedLM\populateByDirectoy(), ilObjSAHSLearningModule\populateByDirectoy(), ilObjMediaObject\renameExecutables(), ilFileSystemGUI\renameFile(), ilCmiXapiContentUploadImporter\sanitizeObjectDirectory(), assQuestionGUI\suggestedsolution(), ilFileSystemGUI\unzipFile(), ilObjMediaCastGUI\updateMediaItem(), ilFileSystemGUI\uploadFile(), and ilObjSAHSLearningModuleGUI\uploadObject().

715  : void
716  {
717  $def_arr = explode(",", SUFFIX_REPL_DEFAULT);
718  foreach ($def_arr as $def) {
719  self::rRenameSuffix($a_dir, trim($def), "sec");
720  }
721 
722  $def_arr = explode(",", SUFFIX_REPL_ADDITIONAL);
723  foreach ($def_arr as $def) {
724  self::rRenameSuffix($a_dir, trim($def), "sec");
725  }
726  }
+ Here is the caller graph for this function:

◆ rRenameSuffix()

static ilFileUtils::rRenameSuffix ( string  $a_dir,
string  $a_old_suffix,
string  $a_new_suffix 
)
static

Renames all files with certain suffix and gives them a new suffix.

This words recursively through a directory.

Deprecated:

Definition at line 734 of file class.ilFileUtils.php.

References delDir(), and rename().

Referenced by ilObjMediaObject\renameExecutables().

734  : bool
735  {
736  if ($a_dir === "/" || $a_dir === "" || is_int(strpos($a_dir, ".."))
737  || trim($a_old_suffix) === "") {
738  return false;
739  }
740 
741  // check if argument is directory
742  if (!@is_dir($a_dir)) {
743  return false;
744  }
745 
746  // read a_dir
747  $dir = opendir($a_dir);
748 
749  while ($file = readdir($dir)) {
750  if ($file !== "." && $file !== "..") {
751  // triple dot is not allowed in filenames
752  if ($file === '...') {
753  unlink($a_dir . "/" . $file);
754  continue;
755  }
756  // directories
757  if (@is_dir($a_dir . "/" . $file)) {
758  ilFileUtils::rRenameSuffix($a_dir . "/" . $file, $a_old_suffix, $a_new_suffix);
759  }
760 
761  // files
762  if (@is_file($a_dir . "/" . $file)) {
763  // first check for files with trailing dot
764  if (strrpos($file, '.') == (strlen($file) - 1)) {
765  try {
766  rename($a_dir . '/' . $file, substr($a_dir . '/' . $file, 0, -1));
767  } catch (Throwable) {
768  // to avoid exploits we do delete this file and continue renaming
769  unlink($a_dir . '/' . $file);
770  continue;
771  }
772  $file = substr($file, 0, -1);
773  }
774 
775  $path_info = pathinfo($a_dir . "/" . $file);
776 
777  if (strtolower($path_info["extension"] ?? '') === strtolower($a_old_suffix)) {
778  $pos = strrpos($a_dir . "/" . $file, ".");
779  $new_name = substr($a_dir . "/" . $file, 0, $pos) . "." . $a_new_suffix;
780  // check if file exists
781  if (file_exists($new_name)) {
782  if (is_dir($new_name)) {
783  ilFileUtils::delDir($new_name);
784  } else {
785  unlink($new_name);
786  }
787  }
788  rename($a_dir . "/" . $file, $new_name);
789  }
790  }
791  }
792  }
793  return true;
794  }
static rRenameSuffix(string $a_dir, string $a_old_suffix, string $a_new_suffix)
Renames all files with certain suffix and gives them a new suffix.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static rename(string $a_source, string $a_target)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sanitateTargetPath()

static ilFileUtils::sanitateTargetPath ( string  $a_target)
staticprotected

Definition at line 355 of file class.ilFileUtils.php.

References CLIENT_DATA_DIR, CLIENT_ID, CLIENT_WEB_DIR, and ILIAS_WEB_DIR.

355  : array
356  {
357  $target_file_system = match (true) {
358  str_starts_with($a_target, 'public/' . ILIAS_WEB_DIR . '/' . CLIENT_ID),
359  str_starts_with($a_target, './public/' . ILIAS_WEB_DIR . '/' . CLIENT_ID),
360  str_starts_with($a_target, '/' . ILIAS_WEB_DIR . '/' . CLIENT_ID),
361  str_starts_with($a_target, './' . ILIAS_WEB_DIR . '/' . CLIENT_ID),
362  str_starts_with($a_target, CLIENT_WEB_DIR) => Location::WEB,
363 
364  str_starts_with($a_target, CLIENT_DATA_DIR . "/temp") => Location::TEMPORARY,
365  str_starts_with($a_target, CLIENT_DATA_DIR) => Location::STORAGE,
366 
367  str_starts_with($a_target, ILIAS_ABSOLUTE_PATH . '/Customizing') => Location::CUSTOMIZING,
368  default => throw new InvalidArgumentException(
369  "Can not move files to \"$a_target\" because path can not be mapped to web, storage or customizing location."
370  ),
371  };
372 
373  $absolute_target_dir = dirname($a_target);
374  $target_dir = LegacyPathHelper::createRelativePath($absolute_target_dir);
375 
376  return [$target_file_system, $target_dir];
377  }
const CLIENT_DATA_DIR
Definition: constants.php:46
const CLIENT_ID
Definition: constants.php:41
const CLIENT_WEB_DIR
Definition: constants.php:47
const ILIAS_WEB_DIR
Definition: constants.php:45

◆ unzip()

static ilFileUtils::unzip ( string  $a_file,
bool  $overwrite = false,
bool  $a_flat = false 
)
static

unzip file

Parameters
string$a_filefull path/filename
boolean$overwritepass true to overwrite existing files

Definition at line 696 of file class.ilFileUtils.php.

References $DIC, and null.

696  : bool
697  {
698  if (defined('DEVMODE') && DEVMODE) {
699  trigger_error('Deprecated method called: ' . __METHOD__, E_USER_DEPRECATED);
700  }
701 
702  global $DIC;
703  return $DIC->legacyArchives()->unzip(
704  $a_file,
705  null,
706  $overwrite,
707  $a_flat,
708  false
709  );
710  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22

◆ utf8_encode()

static ilFileUtils::utf8_encode ( string  $string)
static
Deprecated:
in ILIAS 9 for ILIAS 10: Use Refinery instead

Definition at line 78 of file class.ilFileUtils.php.

References $DIC.

Referenced by ilExSubmission\processZipFile().

78  : string
79  {
80  global $DIC;
81  return $DIC->refinery()->string()->encoding()->latin1ToUtf8()->transform($string);
82  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ zip()

static ilFileUtils::zip ( string  $a_dir,
string  $a_file,
bool  $compress_content = false 
)
static
Deprecated:
Please refactor your code using $DIC->archives()->zip() (recommended) or $DIC->legacyArchives()->zip() instead.

Definition at line 459 of file class.ilFileUtils.php.

References $DIC.

Referenced by ilSurveyExport\buildExportFileXML(), ilSurveyQuestionpoolExport\buildExportFileXML(), ilContObjectExport\buildExportFileXML(), ilQuestionpoolExport\buildExportFileXML(), ilTestArchiver\compressTestArchive(), ilAssFileUploadUploadsExporter\createFileUploadCollectionZipFile(), ilSkinStyleContainer\createTempZip(), ilFileDataMail\deliverAttachmentsAsZip(), ilObjStyleSheet\export(), ilExport\exportEntity(), ilObjFileBasedLMGUI\exportHTML(), ilExportContainer\exportObject(), ilExport\exportObject(), ilCmiXapiDataSet\getDependencies(), ilScormAiccDataSet\getExtendedXmlRepresentation(), ilHTLMExportOptionHTML\onExportOptionSelected(), ILIAS\MediaCast\BackgroundTasks\DownloadAllZipJob\run(), ilSubmissionsZipJob\run(), ilCalendarZipJob\run(), ilOrgUnitExporter\sendAndCreateSimpleExportFile(), ILIAS\Test\ExportImport\Export\write(), ilUserCertificateZip\zipCertificatesInArchiveDirectory(), ilFileDataCourse\zipFile(), ILIAS\Notes\Export\NotesHtmlExport\zipPackage(), and ILIAS\Wiki\Export\BlogHtmlExport\zipPackage().

463  : bool {
464  global $DIC;
465  // ensure top directory should be the same behaviour as before, if you need it to be different, you should legacyArchives directly
466  return $DIC->legacyArchives()->zip($a_dir, $a_file, true);
467  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: