32 public const REGEX =
"(?<prefix>.*?)(?<path>(?<path_without_query>(?<secure_path_id>(?<module_path>\/data\/(?<client>[\w\-\.]*)\/(?<sec>sec\/|)(?<module_type>.*?)\/(?<module_identifier>.*\/|)))(?<appendix>[^\?\n]*)).*)";
87 public function __construct(
string $path,
bool $normalize =
true)
94 $re =
'/' . self::REGEX .
'/';
95 preg_match($re, $path, $result);
97 $result[
'path_without_query'] = strstr(
98 parse_url($path)[
'path'],
104 foreach ($result as $k => $v) {
105 if (is_numeric($k)) {
111 !isset($result[
'module_identifier']) || is_null($result[
'module_identifier']) ?
'' : $result[
'module_identifier'],
115 $moduleId = $moduleId ===
false ?
'' : $moduleId;
117 $this->
setPrefix(!isset($result[
'prefix']) || is_null($result[
'prefix']) ?
'' : $result[
'prefix']);
118 $this->
setClient(!isset($result[
'client']) || is_null($result[
'client']) ?
'' : $result[
'client']);
119 $this->
setAppendix(!isset($result[
'appendix']) || is_null($result[
'appendix']) ?
'' : $result[
'appendix']);
121 $this->
setModuleType(!isset($result[
'module_type']) || is_null($result[
'module_type']) ?
'' : $result[
'module_type']);
124 $module_path = strstr(
125 !isset($result[
'module_path']) || is_null($result[
'module_path']) ?
'' : $result[
'module_path'],
129 $module_path =
'.' . ($module_path ===
false ?
'' :
$module_path);
131 $module_path = (
'.' . (!isset($result[
'module_path']) || is_null($result[
'module_path']) ?
'' : $result[
'module_path']));
135 $this->
setInSecFolder(isset($result[
'sec']) && $result[
'sec'] ===
'sec/');
137 '.' . (!isset($result[
'path_without_query']) || is_null($result[
'path_without_query']) ?
'' : $result[
'path_without_query'])
139 $this->
setPath(
'.' . (!isset($result[
'path']) || is_null($result[
'path']) ?
'' : $result[
'path']));
141 '.' . (!isset($result[
'secure_path_id']) || is_null($result[
'secure_path_id']) ?
'' : $result[
'secure_path_id'])
143 $this->
setSecurePathId(!isset($result[
'module_type']) || is_null($result[
'module_type']) ?
'' : $result[
'module_type']);
145 $parts = parse_url($path);
147 if (isset(
$parts[
'query'])) {
148 $parts_query =
$parts[
'query'];
150 parse_str($parts_query, $query);
167 $this->
setTTL((
int)
$param[ilWACSignedPath::WAC_TTL_ID]);
192 return self::$audio_suffixes;
208 return self::$image_suffixes;
224 return self::$video_suffixes;
237 $path = ltrim($path,
'.');
238 $path = rawurldecode($path);
241 $path = strstr($path,
'/' . self::DIR_DATA .
'/');
243 $original_path = parse_url($path, PHP_URL_PATH);
244 $query = parse_url($path, PHP_URL_QUERY);
246 $real_data_dir = realpath(
"./" . self::DIR_DATA);
247 $realpath = realpath(
"." . $original_path);
249 if (strpos($realpath, $real_data_dir) !== 0) {
253 $normalized_path = ltrim(
262 return "/" . self::DIR_DATA .
'/' . $normalized_path . (!empty($query) ?
'?' .
$query :
'');
312 return in_array(strtolower($this->
getSuffix()), self::$image_suffixes);
332 return in_array(strtolower($this->
getSuffix()), self::$audio_suffixes);
337 return in_array(strtolower($this->
getSuffix()), self::$video_suffixes);
347 return ($this->token !==
'');
352 return ($this->timestamp !== 0);
357 return ($this->ttl !== 0);
static array $video_suffixes
setOriginalRequest(string $original_request)
setClient(string $client)
static setAudioSuffixes(array $audio_suffixes)
__construct(string $path, bool $normalize=true)
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
string $module_identifier
static setVideoSuffixes(array $video_suffixes)
setParameters(array $parameters)
setModulePath(string $module_path)
static array $audio_suffixes
setPathWithoutQuery(string $path_without_query)
string $path_without_query
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getAudioSuffixes()
setSecurePath(string $secure_path)
setTimestamp(int $timestamp)
setSuffix(string $suffix)
static getVideoSuffixes()
static setImageSuffixes(array $image_suffixes)
normalizePath(string $path)
static getImageSuffixes()
setAppendix(string $appendix)
setInSecFolder(bool $in_sec_folder)
setPrefix(string $prefix)
const REGEX
Copy this without to regex101.com and test with some URL of files.
setSecurePathId(string $secure_path_id)
getCleanURLdecodedPath()
Returns a clean (everything behind ? is removed and rawurldecoded path.
setModuleIdentifier(string $module_identifier)
setModuleType(string $module_type)
static array $image_suffixes
setFileName(string $file_name)