ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 static

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

References $files.

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

107  {
108  $files = self::_getUploadFiles();
109 
110  return in_array($a_file, $files);
111  }
$files
Definition: add-vimline.php:18
+ 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 static

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

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

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

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  }
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.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ 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 static

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

References $lm_set.

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

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
+ 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) static

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

References $file, $files, and array.

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

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  }
$files
Definition: add-vimline.php:18
Create styles array
The data for the language used.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the caller graph for this function:

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