ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 106 of file class.ilUploadFiles.php.

107 {
108 $files = self::_getUploadFiles();
109
110 return in_array($a_file, $files);
111 }
static _getUploadFiles()
Get a list of readable files in the upload directory.

References _getUploadFiles().

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:

◆ _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 121 of file class.ilUploadFiles.php.

122 {
123 global $lng, $ilias;
124
125 $file = self::_getUploadDirectory() . "/". $a_file;
126
127 // check if file exists
128 if (!is_file($file))
129 {
130 if ($a_raise_errors)
131 {
132 $ilias->raiseError($lng->txt("upload_error_file_not_found"), $ilias->error_obj->MESSAGE);
133 }
134 else
135 {
136 ilUtil::sendFailure($lng->txt("upload_error_file_not_found"), true);
137 }
138 return false;
139 }
140
141 // virus handling
142 $vir = ilUtil::virusHandling($file, $a_file);
143 if (!$vir[0])
144 {
145 if ($a_raise_errors)
146 {
147 $ilias->raiseError($lng->txt("file_is_infected")."<br />".
148 $vir[1],
149 $ilias->error_obj->MESSAGE);
150 }
151 else
152 {
153 ilUtil::sendFailure($lng->txt("file_is_infected")."<br />".
154 $vir[1], true);
155 }
156 return false;
157 }
158 else
159 {
160 if ($vir[1] != "")
161 {
162 ilUtil::sendInfo($vir[1], true);
163 }
164 return copy($file, $a_target);
165 }
166 }
print $file
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.
global $lng
Definition: privfeed.php:40

References $file, $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 $rbacsystem;
49
50 if(!$rbacsystem->checkAccess('write', SYSTEM_FOLDER_ID))
51 {
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 {
60 return $upload_dir;
61 }
62 else
63 {
64 return '';
65 }
66 }
ILIAS Setting Class.
$lm_set

References $lm_set.

Referenced by _copyUploadFile(), 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 74 of file class.ilUploadFiles.php.

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

References $file.

Referenced by _checkUploadFile(), 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: