35 private $use_cookie =
true;
62 $this->expires = strtotime($expires);
72 if (!in_array($disposition, array(self::ATTACHMENT, self::INLINE))) {
73 throw new \InvalidArgumentException(
"Disposition $disposition is not supported in " . __CLASS__);
75 $this->disposition = $disposition;
85 $this->use_cookie = $use_cookie;
94 if (!$this->file instanceof \
ElggFile || !$this->file->exists()) {
95 elgg_log(
"Unable to resolve resource URL for a file that does not exist on filestore");
101 $path = $this->file->getFilenameOnFilestore();
102 if (substr(
$path, 0, strlen($root_prefix)) == $root_prefix) {
103 $relative_path = substr(
$path, strlen($root_prefix));
106 if (!$relative_path) {
107 elgg_log(
"Unable to resolve relative path of the file on the filestore");
111 if (preg_match(
'~[^a-zA-Z0-9_\./ ]~', $relative_path)) {
118 'expires' => isset($this->expires) ? $this->expires : 0,
119 'last_updated' => filemtime($this->file->getFilenameOnFilestore()),
120 'disposition' => $this->disposition == self::INLINE ?
'i' :
'a',
121 'path' => $relative_path,
124 if ($this->use_cookie) {
126 if (empty(
$data[
'cookie'])) {
129 $data[
'use_cookie'] = 1;
131 $data[
'use_cookie'] = 0;
137 $url_segments = array(
139 "e{$data['expires']}",
140 "l{$data['last_updated']}",
141 "d{$data['disposition']}",
142 "c{$data['use_cookie']}",
bindSession($use_cookie=true)
Bind URL to current user session.
getFile()
Returns file object.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
setFile(\ElggFile $file)
Set file object.
elgg_log($message, $level= 'NOTICE')
Display or log a message.
setExpires($expires= '+2 hours')
Sets URL expiration.
setDisposition($disposition=self::ATTACHMENT)
Sets content disposition.
getURL()
Returns publicly accessible URL.
http free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
static encode($bytes)
Encode base 64 URL.