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 .
'/';
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));
277 $path = strstr(
$path,
'/' . self::DIR_DATA .
'/');
279 $original_path = parse_url(
$path, PHP_URL_PATH);
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));
An exception for terminatinating execution or to throw for unit testing.
The scope of this class is split ilias-conform URI's into components.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setOriginalRequest($original_request)
setSecurePathId($secure_path_id)
__construct(string $path, bool $normalize=true)
static getAudioSuffixes()
static getImageSuffixes()
static setAudioSuffixes(array $audio_suffixes)
getCleanURLdecodedPath()
Returns a clean (everything behind ? is removed and rawurldecoded path.
setModuleIdentifier($module_identifier)
normalizePath(string $path)
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)
setInSecFolder($in_sec_folder)
setSecurePath($secure_path)
setParameters(array $parameters)
static setImageSuffixes(array $image_suffixes)
setPathWithoutQuery($path_without_query)
static getVideoSuffixes()