17 const REGEX =
"(?<prefix>.*?)(?<path>(?<path_without_query>(?<secure_path_id>(?<module_path>\/data\/(?<client>[\w\-\.]*)\/(?<sec>sec\/|)(?<module_type>.*?)\/(?<module_identifier>.*\/|)))(?<appendix>[^\?\n]*)).*)";
133 assert(is_string(
$path));
135 $re =
'/' . self::REGEX .
'/';
138 foreach (
$result as $k => $v) {
139 if (is_numeric($k)) {
144 $moduleId = strstr(is_null(
$result[
'module_identifier']) ?
'' :
$result[
'module_identifier'],
"/",
true);
145 $moduleId = $moduleId ===
false ?
'' : $moduleId;
157 $modulePath =
'.' . ($modulePath ===
false ?
'' : $modulePath);
159 $modulePath = (
'.' . (is_null(
$result[
'module_path']) ?
'' :
$result[
'module_path']));
165 . (is_null(
$result[
'path_without_query']) ?
'' :
$result[
'path_without_query']));
168 . (is_null(
$result[
'secure_path_id']) ?
'' :
$result[
'secure_path_id']));
171 $parts = parse_url(
$path);
173 if (isset($parts[
'query'])) {
174 $parts_query = $parts[
'query'];
176 parse_str($parts_query,
$query);
179 $this->
setSuffix(pathinfo($parts[
'path'], PATHINFO_EXTENSION));
361 return (
bool) in_array(strtolower($this->
getSuffix()), self::$image_suffixes);
398 return (
bool) in_array(strtolower($this->
getSuffix()), self::$audio_suffixes);
407 return (
bool) in_array(strtolower($this->
getSuffix()), self::$video_suffixes);
425 return (
bool) ($this->token !==
'');
434 return (
bool) ($this->timestamp !== 0);
443 return (
bool) ($this->ttl !== 0);
461 assert(is_string(
$token));
560 $path = explode(
"?", (
string) $this->path);
561 $path_to_file = rawurldecode(
$path[0]);
563 return $path_to_file;
572 assert(is_string(
$path));
591 assert(is_string(
$query));
An exception for terminatinating execution or to throw for unit testing.
setOriginalRequest($original_request)
setSecurePathId($secure_path_id)
static getAudioSuffixes()
static getImageSuffixes()
static setAudioSuffixes(array $audio_suffixes)
getCleanURLdecodedPath()
Returns a clean (everything behind ? is removed and rawurldecoded path.
setModuleIdentifier($module_identifier)
setModulePath($module_path)
static setVideoSuffixes(array $video_suffixes)
const REGEX
Copy this without to regex101.com and test with some URL of files.
setModuleType($module_type)
__construct($path)
ilWACPath constructor.
setInSecFolder($in_sec_folder)
setSecurePath($secure_path)
setParameters(array $parameters)
static setImageSuffixes(array $image_suffixes)
setPathWithoutQuery($path_without_query)
static getVideoSuffixes()