ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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  }

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.

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

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
+ Here is the call graph for this function:

◆ getWhiteList()

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

Definition at line 46 of file SuffixDefinitions.php.

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

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

◆ 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.

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

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  }
$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 31 of file SuffixDefinitions.php.


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