31 const REGEX =
"(?<prefix>.*?)(?<path>(?<path_without_query>(?<secure_path_id>(?<module_path>\/data\/(?<client>[\w\-\.]*)\/(?<sec>sec\/|)(?<module_type>.*?)\/(?<module_identifier>.*\/|)))(?<appendix>[^\?\n]*)).*)";
147 assert(is_string(
$path));
149 $re =
'/' . self::REGEX .
'/';
152 $url_parts = parse_url(
$path);
153 $result[
'path_without_query'] = $url_parts[
'path'];
155 foreach (
$result as $k => $v) {
156 if (is_numeric($k)) {
161 $moduleId = strstr(is_null(
$result[
'module_identifier']) ?
'' :
$result[
'module_identifier'],
"/",
true);
162 $moduleId = $moduleId ===
false ?
'' : $moduleId;
164 $this->
setPrefix(is_null($result[
'prefix']) ?
'' : $result[
'prefix']);
165 $this->
setClient(is_null($result[
'client']) ?
'' : $result[
'client']);
166 $this->
setAppendix(is_null($result[
'appendix']) ?
'' : $result[
'appendix']);
168 $this->
setModuleType(is_null($result[
'module_type']) ?
'' : $result[
'module_type']);
173 $modulePath = strstr(is_null($result[
'module_path']) ?
'' : $result[
'module_path'], $this->
getModuleIdentifier(),
true);
174 $modulePath =
'.' . ($modulePath ===
false ?
'' : $modulePath);
176 $modulePath = (
'.' . (is_null($result[
'module_path']) ?
'' : $result[
'module_path']));
182 . (is_null($result[
'path_without_query']) ?
'' : $result[
'path_without_query']));
183 $this->
setPath(
'.' . (is_null($result[
'path']) ?
'' : $result[
'path']));
185 . (is_null($result[
'secure_path_id']) ?
'' : $result[
'secure_path_id']));
186 $this->
setSecurePathId(is_null($result[
'module_type']) ?
'' : $result[
'module_type']);
188 $parts = parse_url(
$path);
190 if (isset($parts[
'query'])) {
191 $parts_query = $parts[
'query'];
193 parse_str($parts_query,
$query);
196 $this->
setSuffix(pathinfo($parts[
'path'], PATHINFO_EXTENSION));
211 $this->
setTTL(intval(
$param[ilWACSignedPath::WAC_TTL_ID]));
239 return (array) self::$audio_suffixes;
257 return (array) self::$image_suffixes;
275 return (array) self::$video_suffixes;
378 return (
bool) in_array(strtolower($this->
getSuffix()), self::$image_suffixes);
415 return (
bool) in_array(strtolower($this->
getSuffix()), self::$audio_suffixes);
424 return (
bool) in_array(strtolower($this->
getSuffix()), self::$video_suffixes);
442 return (
bool) ($this->token !==
'');
451 return (
bool) ($this->timestamp !== 0);
460 return (
bool) ($this->ttl !== 0);
478 assert(is_string(
$token));
579 return $path_to_file;
588 assert(is_string(
$path));
607 assert(is_string(
$query));
setPathWithoutQuery($path_without_query)
static setAudioSuffixes(array $audio_suffixes)
static setVideoSuffixes(array $video_suffixes)
setModulePath($module_path)
setParameters(array $parameters)
setModuleType($module_type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getAudioSuffixes()
setSecurePath($secure_path)
setModuleIdentifier($module_identifier)
static getVideoSuffixes()
static setImageSuffixes(array $image_suffixes)
static getImageSuffixes()
const REGEX
Copy this without to regex101.com and test with some URL of files.
__construct($path)
ilWACPath constructor.
getCleanURLdecodedPath()
Returns a clean (everything behind ? is removed and rawurldecoded path.
setSecurePathId($secure_path_id)
setOriginalRequest($original_request)
setInSecFolder($in_sec_folder)