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;
147 $this->
setPrefix(is_null($result[
'prefix']) ?
'' : $result[
'prefix']);
148 $this->
setClient(is_null($result[
'client']) ?
'' : $result[
'client']);
149 $this->
setAppendix(is_null($result[
'appendix']) ?
'' : $result[
'appendix']);
151 $this->
setModuleType(is_null($result[
'module_type']) ?
'' : $result[
'module_type']);
156 $modulePath = strstr(is_null($result[
'module_path']) ?
'' : $result[
'module_path'], $this->
getModuleIdentifier(),
true);
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']));
166 $this->
setPath(
'.' . (is_null($result[
'path']) ?
'' : $result[
'path']));
168 . (is_null($result[
'secure_path_id']) ?
'' : $result[
'secure_path_id']));
169 $this->
setSecurePathId(is_null($result[
'module_type']) ?
'' : $result[
'module_type']);
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));
188 $this->
setToken($param[ilWACSignedPath::WAC_TOKEN_ID]);
191 $this->
setTimestamp(intval($param[ilWACSignedPath::WAC_TIMESTAMP_ID]));
194 $this->
setTTL(intval($param[ilWACSignedPath::WAC_TTL_ID]));
222 return (array) self::$audio_suffixes;
240 return (array) self::$image_suffixes;
258 return (array) self::$video_suffixes;
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));
setPathWithoutQuery($path_without_query)
static setAudioSuffixes(array $audio_suffixes)
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)
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)