ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 37 of file SuffixDefinitions.php.

38 {
39 $this->white_list[] = '';
40 $this->white_list = array_unique($white_list);
41 }

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

Member Function Documentation

◆ getBlackList()

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

Definition at line 54 of file SuffixDefinitions.php.

54 : array
55 {
56 return $this->black_list;
57 }

◆ 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 62 of file SuffixDefinitions.php.

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

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

+ Here is the call graph for this function:

◆ getWhiteList()

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

Definition at line 46 of file SuffixDefinitions.php.

46 : array
47 {
48 return $this->white_list;
49 }

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

◆ 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 83 of file SuffixDefinitions.php.

83 : bool
84 {
85 $pi = pathinfo($filename);
86
87 return in_array(strtolower($pi["extension"]), $this->white_list)
88 && !in_array(strtolower($pi["extension"]), $this->black_list);
89 }

References $filename.

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

+ 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"

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