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]*)).*)";
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'],
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']);
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]);
241 $path = strstr(
$path,
'/' . self::DIR_DATA .
'/');
243 $original_path = parse_url(
$path, PHP_URL_PATH);
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);
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...
string $path_without_query
static array $audio_suffixes
static array $image_suffixes
__construct(string $path, bool $normalize=true)
setInSecFolder(bool $in_sec_folder)
static array $video_suffixes
static getAudioSuffixes()
setAppendix(string $appendix)
setModuleIdentifier(string $module_identifier)
setSecurePath(string $secure_path)
static getImageSuffixes()
setModulePath(string $module_path)
setPrefix(string $prefix)
setOriginalRequest(string $original_request)
setFileName(string $file_name)
static setAudioSuffixes(array $audio_suffixes)
setClient(string $client)
getCleanURLdecodedPath()
Returns a clean (everything behind ? is removed and rawurldecoded path.
setModuleType(string $module_type)
normalizePath(string $path)
setSecurePathId(string $secure_path_id)
static setVideoSuffixes(array $video_suffixes)
const REGEX
Copy this without to regex101.com and test with some URL of files.
string $module_identifier
setSuffix(string $suffix)
setPathWithoutQuery(string $path_without_query)
setParameters(array $parameters)
static setImageSuffixes(array $image_suffixes)
setTimestamp(int $timestamp)
static getVideoSuffixes()
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts