ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilFileServicesSettings.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27{
28 private array $white_list_default = [];
29 private array $white_list_negative = [];
30 private array $white_list_positive = [];
31 private array $white_list_overall = [];
32 private array $black_list_prohibited = [];
33 private array $black_list_overall = [];
34 private bool $convert_to_ascii = true;
35 private ?bool $bypass = null;
36 protected int $file_admin_ref_id;
37
38 public function __construct(
39 private ilSetting $settings,
40 ilIniFile $client_ini,
41 private ilDBInterface $db
42 ) {
43 $general_settings = new General();
44 $this->convert_to_ascii = $general_settings->isDownloadWithAsciiFileName();
46 $this->white_list_default = include __DIR__ . "/../defaults/default_whitelist.php";
47 $this->file_admin_ref_id = $this->determineFileAdminRefId();
48 $this->read();
49 }
50
51 private function determineFileAdminRefId(): int
52 {
53 $r = $this->db->query(
54 "SELECT ref_id FROM object_reference JOIN object_data ON object_reference.obj_id = object_data.obj_id WHERE object_data.type = 'facs';"
55 );
56 $r = $this->db->fetchObject($r);
57 return (int) ($r->ref_id ?? 0);
58 }
59
60 private function determineByPass(): bool
61 {
62 global $DIC;
63 return $DIC->isDependencyAvailable('rbac')
64 && isset($DIC["rbacsystem"])
65 && $DIC->rbac()->system()->checkAccess(
66 'upload_blacklisted_files',
67 $this->file_admin_ref_id
68 );
69 }
70
71 public function isByPassAllowedForCurrentUser(): bool
72 {
73 if ($this->bypass !== null) {
74 return $this->bypass;
75 }
76 return $this->bypass = $this->determineByPass();
77 }
78
79 private function read(): void
80 {
81 $this->readBlackList();
82 $this->readWhiteList();
83 }
84
85 public function isASCIIConvertionEnabled(): bool
86 {
88 }
89
90 private function readWhiteList(): void
91 {
92 $cleaner = $this->getCleaner();
93
94 $this->white_list_negative = array_map(
95 $cleaner,
96 explode(",", $this->settings->get("suffix_repl_additional") ?? '')
97 );
98
99 $this->white_list_positive = array_map(
100 $cleaner,
101 explode(",", $this->settings->get("suffix_custom_white_list") ?? '')
102 );
103
104 $this->white_list_overall = array_merge($this->white_list_default, $this->white_list_positive);
105 $this->white_list_overall = array_diff($this->white_list_overall, $this->white_list_negative);
106 $this->white_list_overall = array_diff($this->white_list_overall, $this->black_list_overall);
107 $this->white_list_overall[] = '';
108 $this->white_list_overall = array_unique($this->white_list_overall);
109 $this->white_list_overall = array_diff($this->white_list_overall, $this->black_list_prohibited);
110 }
111
112 private function readBlackList(): void
113 {
114 $cleaner = $this->getCleaner();
115
116 $this->black_list_prohibited = array_map(
117 $cleaner,
118 explode(",", $this->settings->get("suffix_custom_expl_black") ?? '')
119 );
120
121 $this->black_list_prohibited = array_filter($this->black_list_prohibited, fn($item): bool => $item !== '');
122 $this->black_list_overall = $this->black_list_prohibited;
123 }
124
125 private function getCleaner(): Closure
126 {
127 return fn(string $suffix): string => trim(strtolower($suffix));
128 }
129
130 public function getWhiteListedSuffixes(): array
131 {
133 }
134
135 public function getBlackListedSuffixes(): array
136 {
138 }
139
143 public function getDefaultWhitelist(): array
144 {
146 }
147
151 public function getWhiteListNegative(): array
152 {
154 }
155
159 public function getWhiteListPositive(): array
160 {
162 }
163
167 public function getProhibited(): array
168 {
170 }
171}
__construct(private ilSetting $settings, ilIniFile $client_ini, private ilDBInterface $db)
INIFile Parser Early access in init proceess! Avoid further dependencies like logging or other servic...
ILIAS Setting Class.
Interface ilDBInterface.
global $DIC
Definition: shib_login.php:26