ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilUploadFiles Class Reference
+ Collaboration diagram for ilUploadFiles:

Static Public Member Functions

static _getUploadDirectory ()
 Get the directory with uploaded files. More...
 
static _getUploadFiles ()
 Get a list of readable files in the upload directory. More...
 
static _checkUploadFile ($a_file)
 Check if a file exists in the upload directory and is readable. More...
 
static _copyUploadFile ($a_file, $a_target, $a_raise_errors=true)
 copy an uploaded file to the target directory (including virus check) More...
 

Detailed Description

Member Function Documentation

◆ _checkUploadFile()

static ilUploadFiles::_checkUploadFile (   $a_file)
static

Check if a file exists in the upload directory and is readable.

Parameters
stringfile name
Returns
boolean true/false @access static

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

101 {
102 $files = self::_getUploadFiles();
103
104 return in_array($a_file, $files);
105 }
static _getUploadFiles()
Get a list of readable files in the upload directory.

References _getUploadFiles().

Referenced by ilObjCmiXapiGUI\afterSave(), ilObjSCORMLearningModuleGUI\newModuleVersionUpload(), ilFileSystemGUI\uploadFile(), and ilObjSAHSLearningModuleGUI\uploadObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _copyUploadFile()

static ilUploadFiles::_copyUploadFile (   $a_file,
  $a_target,
  $a_raise_errors = true 
)
static

copy an uploaded file to the target directory (including virus check)

Parameters
stringfile name
stringtarget path and name
Returns
boolean true/false @access static

Definition at line 115 of file class.ilUploadFiles.php.

116 {
117 global $DIC;
118 $lng = $DIC['lng'];
119 $ilias = $DIC['ilias'];
120
121 $file = self::_getUploadDirectory() . "/" . $a_file;
122
123 // check if file exists
124 if (!is_file($file)) {
125 if ($a_raise_errors) {
126 $ilias->raiseError($lng->txt("upload_error_file_not_found"), $ilias->error_obj->MESSAGE);
127 } else {
128 ilUtil::sendFailure($lng->txt("upload_error_file_not_found"), true);
129 }
130 return false;
131 }
132
133 // virus handling
134 $vir = ilUtil::virusHandling($file, $a_file);
135 if (!$vir[0]) {
136 if ($a_raise_errors) {
137 $ilias->raiseError(
138 $lng->txt("file_is_infected") . "<br />" .
139 $vir[1],
140 $ilias->error_obj->MESSAGE
141 );
142 } else {
143 ilUtil::sendFailure($lng->txt("file_is_infected") . "<br />" .
144 $vir[1], true);
145 }
146 return false;
147 } else {
148 if ($vir[1] != "") {
149 ilUtil::sendInfo($vir[1], true);
150 }
151 return copy($file, $a_target);
152 }
153 }
static _getUploadDirectory()
Get the directory with uploaded files.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$lng
$DIC
Definition: xapitoken.php:46

References $DIC, $lng, _getUploadDirectory(), ilUtil\sendFailure(), ilUtil\sendInfo(), and ilUtil\virusHandling().

Referenced by ilObjSCORMLearningModuleGUI\newModuleVersionUpload(), ilFileSystemGUI\uploadFile(), and ilObjSAHSLearningModuleGUI\uploadObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getUploadDirectory()

static ilUploadFiles::_getUploadDirectory ( )
static

Get the directory with uploaded files.

The directory is configured as cont_upload_dir in the settings table. The directory must exist and have read permissions. Currently the user must have admin permissions in ILIAS. Later there may be different directories for different users/roles.

Returns
string full path of upload directory on the server or empty @access static

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

47 {
48 global $DIC;
49 $rbacsystem = $DIC['rbacsystem'];
50
51 if (!$rbacsystem->checkAccess('write', SYSTEM_FOLDER_ID)) {
52 return '';
53 }
54
55 $lm_set = new ilSetting("lm");
56 $upload_dir = $lm_set->get("cont_upload_dir");
57
58 if (is_dir($upload_dir) and is_readable($upload_dir)) {
59 return $upload_dir;
60 } else {
61 return '';
62 }
63 }
ILIAS Setting Class.
$lm_set

References $DIC, and $lm_set.

Referenced by _copyUploadFile(), ilObjCmiXapiGUI\afterSave(), ilObjCmiXapiGUI\initCreateForm(), ilObjSAHSLearningModuleGUI\initUploadForm(), ilFileSystemGUI\listFiles(), and ilObjSCORMLearningModuleGUI\newModuleVersion().

+ Here is the caller graph for this function:

◆ _getUploadFiles()

static ilUploadFiles::_getUploadFiles ( )
static

Get a list of readable files in the upload directory.

Returns
array list of file names (without path) @access static

Definition at line 71 of file class.ilUploadFiles.php.

72 {
73 if (!$upload_dir = self::_getUploadDirectory()) {
74 return array();
75 }
76
77 // get the sorted content of the upload directory
78 $handle = opendir($upload_dir);
79 $files = array();
80 while (false !== ($file = readdir($handle))) {
81 $full_path = $upload_dir . "/" . $file;
82 if (is_file($full_path) and is_readable($full_path)) {
83 $files[] = $file;
84 }
85 }
86 closedir($handle);
87 sort($files);
88 reset($files);
89
90 return $files;
91 }

Referenced by _checkUploadFile(), ilObjCmiXapiGUI\initCreateForm(), ilObjSAHSLearningModuleGUI\initUploadForm(), ilFileSystemGUI\listFiles(), and ilObjSCORMLearningModuleGUI\newModuleVersion().

+ Here is the caller graph for this function:

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