ILIAS  release_8 Revision v8.24
class.ilFileServicesSettings.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
25{
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(
40 ilIniFile $client_ini,
42 ) {
43 $this->db = $db;
44 $this->convert_to_ascii = (bool) !$client_ini->readVariable('file_access', 'disable_ascii');
45 $this->settings = $settings;
47 $this->white_list_default = include "./Services/FileServices/defaults/default_whitelist.php";
48 $this->file_admin_ref_id = $this->determineFileAdminRefId();
49 $this->read();
50 }
51
52 private function determineFileAdminRefId(): int
53 {
54 $r = $this->db->query(
55 "SELECT ref_id FROM object_reference JOIN object_data ON object_reference.obj_id = object_data.obj_id WHERE object_data.type = 'facs';"
56 );
57 $r = $this->db->fetchObject($r);
58 return (int) ($r->ref_id ?? 0);
59 }
60
61 private function determineByPass(): bool
62 {
63 global $DIC;
64 return $DIC->isDependencyAvailable('rbac')
65 && isset($DIC["rbacsystem"])
66 && $DIC->rbac()->system()->checkAccess(
67 'upload_blacklisted_files',
68 $this->file_admin_ref_id
69 );
70 }
71
72 public function isByPassAllowedForCurrentUser(): bool
73 {
74 if ($this->bypass !== null) {
75 return $this->bypass;
76 }
77 return $this->bypass = $this->determineByPass();
78 }
79
80 private function read(): void
81 {
82 $this->readBlackList();
83 $this->readWhiteList();
84 }
85
86 public function isASCIIConvertionEnabled(): bool
87 {
89 }
90
91 private function readWhiteList(): void
92 {
93 $cleaner = $this->getCleaner();
94
95 $this->white_list_negative = array_map(
96 $cleaner,
97 explode(",", $this->settings->get("suffix_repl_additional") ?? '')
98 );
99
100 $this->white_list_positive = array_map(
101 $cleaner,
102 explode(",", $this->settings->get("suffix_custom_white_list") ?? '')
103 );
104
105 $this->white_list_overall = array_merge($this->white_list_default, $this->white_list_positive);
106 $this->white_list_overall = array_diff($this->white_list_overall, $this->white_list_negative);
107 $this->white_list_overall = array_diff($this->white_list_overall, $this->black_list_overall);
108 $this->white_list_overall[] = '';
109 $this->white_list_overall = array_unique($this->white_list_overall);
110 $this->white_list_overall = array_diff($this->white_list_overall, $this->black_list_prohibited);
111 }
112
113 private function readBlackList(): void
114 {
115 $cleaner = $this->getCleaner();
116
117 $this->black_list_prohibited = array_map(
118 $cleaner,
119 explode(",", $this->settings->get("suffix_custom_expl_black") ?? '')
120 );
121
122 $this->black_list_prohibited = array_filter($this->black_list_prohibited, fn ($item): bool => $item !== '');
123 $this->black_list_overall = $this->black_list_prohibited;
124 }
125
126 private function getCleaner(): Closure
127 {
128 return function (string $suffix): string {
129 return trim(strtolower($suffix));
130 };
131 }
132
133 public function getWhiteListedSuffixes(): array
134 {
136 }
137
138 public function getBlackListedSuffixes(): array
139 {
141 }
142
146 public function getDefaultWhitelist()
147 {
149 }
150
154 public function getWhiteListNegative(): array
155 {
157 }
158
162 public function getWhiteListPositive(): array
163 {
165 }
166
170 public function getProhibited(): array
171 {
173 }
174}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilSetting $settings, ilIniFile $client_ini, ilDBInterface $db)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
Interface ilDBInterface.