ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Filesystem\Definitions\SuffixDefinitions Class Reference
+ Collaboration diagram for ILIAS\Filesystem\Definitions\SuffixDefinitions:

Public Member Functions

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

Data Fields

const SEC = ".sec"
 

Protected Attributes

array $white_list = []
 
array $black_list = []
 

Detailed Description

Definition at line 7 of file SuffixDefinitions.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Filesystem\Definitions\SuffixDefinitions::__construct ( array  $white_list,
array  $black_list 
)
Parameters
array$white_list
array$black_list

Definition at line 17 of file SuffixDefinitions.php.

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

18  {
19  $this->white_list[] = '';
20  $this->white_list = array_unique($white_list);
21  $this->black_list = $black_list;
22  }

Member Function Documentation

◆ getBlackList()

ILIAS\Filesystem\Definitions\SuffixDefinitions::getBlackList ( )

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

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

37  : string
38  {
39  if ($this->hasValidFileName($filename)) {
40  return $filename;
41  }
42  $pi = pathinfo($filename);
43  // if extension is not in white list, remove all "." and add ".sec" extension
44  $basename = str_replace(".", "", $pi["basename"]);
45  if (trim($basename) == "") {
46  throw new \RuntimeException("Invalid upload filename.");
47  }
48  $basename .= self::SEC;
49  if ($pi["dirname"] != "" && ($pi["dirname"] != "." || substr($filename, 0, 2) == "./")) {
50  $filename = $pi["dirname"] . "/" . $basename;
51  } else {
52  $filename = $basename;
53  }
54  return $filename;
55  }
$filename
Definition: buildRTE.php:78
+ Here is the call graph for this function:

◆ getWhiteList()

ILIAS\Filesystem\Definitions\SuffixDefinitions::getWhiteList ( )

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

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

60  : bool
61  {
62  $pi = pathinfo($filename);
63 
64  return in_array(strtolower($pi["extension"]), $this->white_list)
65  && !in_array(strtolower($pi["extension"]), $this->black_list);
66  }
$filename
Definition: buildRTE.php:78
+ Here is the caller graph for this function:

Field Documentation

◆ $black_list

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

◆ $white_list

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

◆ SEC

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

Definition at line 9 of file SuffixDefinitions.php.


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