33 public const REGEX =
"(?<prefix>.*?)(?<path>(?<path_without_query>(?<secure_path_id>(?<module_path>\/data\/(?<client>[\w\-\.]*)\/(?<sec>sec\/|)(?<module_type>.*?)\/(?<module_identifier>.*\/|)))(?<appendix>[^\?\n]*)).*)";
132 $re =
'/' . self::REGEX .
'/';
133 preg_match($re, $path,
$result);
135 $result[
'path_without_query'] = strstr(
136 parse_url($path)[
'path'],
141 foreach (
$result as $k => $v) {
142 if (is_numeric($k)) {
147 $moduleId = strstr(
$result[
'module_identifier'] ??
'',
"/",
true);
148 $moduleId = $moduleId ===
false ?
'' : $moduleId;
160 $modulePath =
'.' . ($modulePath ===
false ?
'' : $modulePath);
162 $modulePath = (
'.' . (
$result[
'module_path'] ??
''));
172 $parts = parse_url($path);
174 if (isset($parts[
'query'])) {
175 $parts_query = $parts[
'query'];
177 parse_str($parts_query,
$query);
180 $this->
setSuffix(pathinfo($parts[
'path'], PATHINFO_EXTENSION));
195 $this->
setTTL(intval(
$param[ilWACSignedPath::WAC_TTL_ID]));
223 return (array) self::$audio_suffixes;
241 return (array) self::$image_suffixes;
259 return (array) self::$video_suffixes;
273 $path = ltrim($path,
'.');
274 $path = rawurldecode($path);
277 $path = strstr($path,
'/' . self::DIR_DATA .
'/');
279 $original_path = parse_url($path, PHP_URL_PATH);
280 $query = parse_url($path, PHP_URL_QUERY);
282 $real_data_dir = realpath(
"./" . self::DIR_DATA);
283 $realpath = realpath(
"." . $original_path);
285 if (strpos($realpath, (
string) $real_data_dir) !== 0) {
289 $normalized_path = ltrim(
298 return "/" . self::DIR_DATA .
'/' . $normalized_path . (!empty(
$query) ?
'?' .
$query :
'');
391 return (
bool) in_array(strtolower($this->
getSuffix()), self::$image_suffixes);
428 return (
bool) in_array(strtolower($this->
getSuffix()), self::$audio_suffixes);
437 return (
bool) in_array(strtolower($this->
getSuffix()), self::$video_suffixes);
455 return (
bool) ($this->token !==
'');
464 return (
bool) ($this->timestamp !== 0);
473 return (
bool) ($this->ttl !== 0);
491 assert(is_string(
$token));
599 assert(is_string(
$path));
618 assert(is_string(
$query));
setPathWithoutQuery($path_without_query)
static setAudioSuffixes(array $audio_suffixes)
__construct(string $path, bool $normalize=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static setVideoSuffixes(array $video_suffixes)
setModulePath($module_path)
setParameters(array $parameters)
setModuleType($module_type)
static getAudioSuffixes()
setSecurePath($secure_path)
setModuleIdentifier($module_identifier)
static getVideoSuffixes()
static setImageSuffixes(array $image_suffixes)
normalizePath(string $path)
static getImageSuffixes()
const REGEX
Copy this without to regex101.com and test with some URL of files.
getCleanURLdecodedPath()
Returns a clean (everything behind ? is removed and rawurldecoded path.
setSecurePathId($secure_path_id)
setOriginalRequest($original_request)
setInSecFolder($in_sec_folder)