ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ILIAS\Filesystem\Definitions\SuffixDefinitions Class Reference
+ Collaboration diagram for ILIAS\Filesystem\Definitions\SuffixDefinitions:

Public Member Functions

 __construct (array $white_list, protected array $black_list)
 
 getWhiteList ()
 
 getBlackList ()
 
 getValidFileName (string $filename)
 
 hasValidFileName (string $filename)
 

Data Fields

const SEC = ".sec"
 

Protected Attributes

array $white_list = []
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 26 of file SuffixDefinitions.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Filesystem\Definitions\SuffixDefinitions::__construct ( array  $white_list,
protected array  $black_list 
)
Parameters
mixed[]$black_list

Definition at line 34 of file SuffixDefinitions.php.

35  {
36  $this->white_list[] = '';
37  $this->white_list = array_unique($white_list);
38  }

Member Function Documentation

◆ getBlackList()

ILIAS\Filesystem\Definitions\SuffixDefinitions::getBlackList ( )
Returns
mixed[]

Definition at line 51 of file SuffixDefinitions.php.

51  : array
52  {
53  return $this->black_list;
54  }

◆ getValidFileName()

ILIAS\Filesystem\Definitions\SuffixDefinitions::getValidFileName ( string  $filename)
Deprecated:
Use ILIAS ResourceStorage to store files, there is no need to check valid filenames

Definition at line 59 of file SuffixDefinitions.php.

References $filename, and ILIAS\Filesystem\Definitions\SuffixDefinitions\hasValidFileName().

59  : string
60  {
61  if ($this->hasValidFileName($filename)) {
62  return $filename;
63  }
64  $pi = pathinfo($filename);
65  // if extension is not in white list, remove all "." and add ".sec" extension
66  $basename = str_replace(".", "", $pi["basename"]);
67  if (trim($basename) == "") {
68  throw new \RuntimeException("Invalid upload filename.");
69  }
70  $basename .= self::SEC;
71  if ($pi["dirname"] != "" && ($pi["dirname"] != "." || substr($filename, 0, 2) == "./")) {
72  return $pi["dirname"] . "/" . $basename;
73  }
74  return $basename;
75  }
$filename
Definition: buildRTE.php:78
+ Here is the call graph for this function:

◆ getWhiteList()

ILIAS\Filesystem\Definitions\SuffixDefinitions::getWhiteList ( )
Returns
mixed[]

Definition at line 43 of file SuffixDefinitions.php.

References ILIAS\Filesystem\Definitions\SuffixDefinitions\$white_list.

43  : array
44  {
45  return $this->white_list;
46  }

◆ hasValidFileName()

ILIAS\Filesystem\Definitions\SuffixDefinitions::hasValidFileName ( string  $filename)
Deprecated:
Use ILIAS ResourceStorage to store files, there is no need to check valid filenames

Definition at line 80 of file SuffixDefinitions.php.

Referenced by ILIAS\Filesystem\Definitions\SuffixDefinitions\getValidFileName().

80  : bool
81  {
82  $pi = pathinfo($filename);
83 
84  return in_array(strtolower($pi["extension"]), $this->white_list)
85  && !in_array(strtolower($pi["extension"]), $this->black_list);
86  }
$filename
Definition: buildRTE.php:78
+ Here is the caller graph for this function:

Field Documentation

◆ $white_list

array ILIAS\Filesystem\Definitions\SuffixDefinitions::$white_list = []
protected

◆ SEC

const ILIAS\Filesystem\Definitions\SuffixDefinitions::SEC = ".sec"

Definition at line 28 of file SuffixDefinitions.php.


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