[TASK] Replace deprecated Sabre functions.
Replaced some deprecated functions from Sabre's URLUtil class.
This commit is contained in:
parent
b0dbb6708e
commit
bb5b19c2fb
@ -101,8 +101,8 @@ class Browser extends DAV\Browser\Plugin {
|
|||||||
$parentpath = array();
|
$parentpath = array();
|
||||||
// only show parent if not leaving /cloud/; TODO how to improve this?
|
// only show parent if not leaving /cloud/; TODO how to improve this?
|
||||||
if ($path && $path != "cloud") {
|
if ($path && $path != "cloud") {
|
||||||
list($parentUri) = \Sabre\HTTP\URLUtil::splitPath($path);
|
list($parentUri) = \Sabre\Uri\split($path);
|
||||||
$fullPath = \Sabre\HTTP\URLUtil::encodePath($this->server->getBaseUri() . $parentUri);
|
$fullPath = \Sabre\HTTP\encodePath($this->server->getBaseUri() . $parentUri);
|
||||||
|
|
||||||
$parentpath['icon'] = $this->enableAssets ? '<a href="' . $fullPath . '"><img src="' . $this->getAssetUrl('icons/parent' . $this->iconExtension) . '" width="24" alt="' . t('parent') . '"></a>' : '';
|
$parentpath['icon'] = $this->enableAssets ? '<a href="' . $fullPath . '"><img src="' . $this->getAssetUrl('icons/parent' . $this->iconExtension) . '" width="24" alt="' . t('parent') . '"></a>' : '';
|
||||||
$parentpath['path'] = $fullPath;
|
$parentpath['path'] = $fullPath;
|
||||||
@ -116,7 +116,7 @@ class Browser extends DAV\Browser\Plugin {
|
|||||||
// This is the current directory, we can skip it
|
// This is the current directory, we can skip it
|
||||||
if (rtrim($file['href'], '/') == $path) continue;
|
if (rtrim($file['href'], '/') == $path) continue;
|
||||||
|
|
||||||
list(, $name) = \Sabre\HTTP\URLUtil::splitPath($file['href']);
|
list(, $name) = \Sabre\Uri\split($file['href']);
|
||||||
|
|
||||||
if (isset($file[200]['{DAV:}resourcetype'])) {
|
if (isset($file[200]['{DAV:}resourcetype'])) {
|
||||||
$type = $file[200]['{DAV:}resourcetype']->getValue();
|
$type = $file[200]['{DAV:}resourcetype']->getValue();
|
||||||
@ -166,8 +166,7 @@ class Browser extends DAV\Browser\Plugin {
|
|||||||
$size = isset($file[200]['{DAV:}getcontentlength']) ? (int)$file[200]['{DAV:}getcontentlength'] : '';
|
$size = isset($file[200]['{DAV:}getcontentlength']) ? (int)$file[200]['{DAV:}getcontentlength'] : '';
|
||||||
$lastmodified = ((isset($file[200]['{DAV:}getlastmodified'])) ? $file[200]['{DAV:}getlastmodified']->getTime()->format('Y-m-d H:i:s') : '');
|
$lastmodified = ((isset($file[200]['{DAV:}getlastmodified'])) ? $file[200]['{DAV:}getlastmodified']->getTime()->format('Y-m-d H:i:s') : '');
|
||||||
|
|
||||||
$fullPath = \Sabre\HTTP\URLUtil::encodePath('/' . trim($this->server->getBaseUri() . ($path ? $path . '/' : '') . $name, '/'));
|
$fullPath = \Sabre\HTTP\encodePath('/' . trim($this->server->getBaseUri() . ($path ? $path . '/' : '') . $name, '/'));
|
||||||
|
|
||||||
|
|
||||||
$displayName = isset($file[200]['{DAV:}displayname']) ? $file[200]['{DAV:}displayname'] : $name;
|
$displayName = isset($file[200]['{DAV:}displayname']) ? $file[200]['{DAV:}displayname'] : $name;
|
||||||
|
|
||||||
@ -248,7 +247,7 @@ class Browser extends DAV\Browser\Plugin {
|
|||||||
|
|
||||||
$current_theme = \Zotlabs\Render\Theme::current();
|
$current_theme = \Zotlabs\Render\Theme::current();
|
||||||
|
|
||||||
$theme_info_file = "view/theme/" . $current_theme[0] . "/php/theme.php";
|
$theme_info_file = 'view/theme/' . $current_theme[0] . '/php/theme.php';
|
||||||
if (file_exists($theme_info_file)) {
|
if (file_exists($theme_info_file)) {
|
||||||
require_once($theme_info_file);
|
require_once($theme_info_file);
|
||||||
if (function_exists(str_replace('-', '_', $current_theme[0]) . '_init')) {
|
if (function_exists(str_replace('-', '_', $current_theme[0]) . '_init')) {
|
||||||
@ -287,7 +286,6 @@ class Browser extends DAV\Browser\Plugin {
|
|||||||
$lockstate = (($acl->is_private()) ? 'lock' : 'unlock');
|
$lockstate = (($acl->is_private()) ? 'lock' : 'unlock');
|
||||||
|
|
||||||
$aclselect = ((local_channel() == $this->auth->owner_id) ? populate_acl($channel_acl,false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_storage')) : '');
|
$aclselect = ((local_channel() == $this->auth->owner_id) ? populate_acl($channel_acl,false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_storage')) : '');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,14 +361,13 @@ class Browser extends DAV\Browser\Plugin {
|
|||||||
* The name of the attachment
|
* The name of the attachment
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected function findAttachHash($owner, $parentHash, $attachName) {
|
protected function findAttachHash($owner, $parentHash, $attachName) {
|
||||||
$r = q("SELECT hash FROM attach WHERE uid = %d AND folder = '%s' AND filename = '%s' ORDER BY edited DESC LIMIT 1",
|
$r = q("SELECT hash FROM attach WHERE uid = %d AND folder = '%s' AND filename = '%s' ORDER BY edited DESC LIMIT 1",
|
||||||
intval($owner),
|
intval($owner),
|
||||||
dbesc($parentHash),
|
dbesc($parentHash),
|
||||||
dbesc($attachName)
|
dbesc($attachName)
|
||||||
);
|
);
|
||||||
$hash = "";
|
$hash = '';
|
||||||
if ($r) {
|
if ($r) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$hash = $rr['hash'];
|
$hash = $rr['hash'];
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
namespace Zotlabs\Storage;
|
namespace Zotlabs\Storage;
|
||||||
|
|
||||||
use Sabre\DAV;
|
use Sabre\DAV;
|
||||||
use Sabre\HTTP;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief RedDirectory class.
|
* @brief RedDirectory class.
|
||||||
@ -99,7 +98,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
/**
|
/**
|
||||||
* @brief Returns a child by name.
|
* @brief Returns a child by name.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @throw \Sabre\DAV\Exception\Forbidden
|
* @throw \Sabre\DAV\Exception\Forbidden
|
||||||
* @throw \Sabre\DAV\Exception\NotFound
|
* @throw \Sabre\DAV\Exception\NotFound
|
||||||
* @param string $name
|
* @param string $name
|
||||||
@ -160,7 +158,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
throw new DAV\Exception\Forbidden('Permission denied.');
|
throw new DAV\Exception\Forbidden('Permission denied.');
|
||||||
}
|
}
|
||||||
|
|
||||||
list($parent_path, ) = HTTP\URLUtil::splitPath($this->red_path);
|
list($parent_path, ) = \Sabre\Uri\split($this->red_path);
|
||||||
$new_path = $parent_path . '/' . $name;
|
$new_path = $parent_path . '/' . $name;
|
||||||
|
|
||||||
$r = q("UPDATE attach SET filename = '%s' WHERE hash = '%s' AND uid = %d",
|
$r = q("UPDATE attach SET filename = '%s' WHERE hash = '%s' AND uid = %d",
|
||||||
@ -169,7 +167,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
intval($this->auth->owner_id)
|
intval($this->auth->owner_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$ch = channelx_by_n($this->auth->owner_id);
|
$ch = channelx_by_n($this->auth->owner_id);
|
||||||
if ($ch) {
|
if ($ch) {
|
||||||
$sync = attach_export_data($ch, $this->folder_hash);
|
$sync = attach_export_data($ch, $this->folder_hash);
|
||||||
@ -207,7 +204,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
throw new DAV\Exception\Forbidden('Permission denied.');
|
throw new DAV\Exception\Forbidden('Permission denied.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$mimetype = z_mime_content_type($name);
|
$mimetype = z_mime_content_type($name);
|
||||||
|
|
||||||
$c = q("SELECT * FROM channel WHERE channel_id = %d AND channel_removed = 0 LIMIT 1",
|
$c = q("SELECT * FROM channel WHERE channel_id = %d AND channel_removed = 0 LIMIT 1",
|
||||||
@ -270,8 +266,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
dbesc($deny_gid)
|
dbesc($deny_gid)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// returns the number of bytes that were written to the file, or FALSE on failure
|
// returns the number of bytes that were written to the file, or FALSE on failure
|
||||||
$size = file_put_contents($f, $data);
|
$size = file_put_contents($f, $data);
|
||||||
// delete attach entry if file_put_contents() failed
|
// delete attach entry if file_put_contents() failed
|
||||||
@ -284,8 +278,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
// returns now
|
// returns now
|
||||||
$edited = datetime_convert();
|
$edited = datetime_convert();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$is_photo = 0;
|
$is_photo = 0;
|
||||||
$x = @getimagesize($f);
|
$x = @getimagesize($f);
|
||||||
logger('getimagesize: ' . print_r($x,true), LOGGER_DATA);
|
logger('getimagesize: ' . print_r($x,true), LOGGER_DATA);
|
||||||
@ -293,7 +285,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
$is_photo = 1;
|
$is_photo = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// updates entry with filesize and timestamp
|
// updates entry with filesize and timestamp
|
||||||
$d = q("UPDATE attach SET filesize = '%s', is_photo = %d, edited = '%s' WHERE hash = '%s' AND uid = %d",
|
$d = q("UPDATE attach SET filesize = '%s', is_photo = %d, edited = '%s' WHERE hash = '%s' AND uid = %d",
|
||||||
dbesc($size),
|
dbesc($size),
|
||||||
@ -349,8 +340,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
|
|
||||||
if ($sync)
|
if ($sync)
|
||||||
build_sync_packet($c[0]['channel_id'], array('file' => array($sync)));
|
build_sync_packet($c[0]['channel_id'], array('file' => array($sync)));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -391,7 +380,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
/**
|
/**
|
||||||
* @brief delete directory
|
* @brief delete directory
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
logger('delete file ' . basename($this->red_path), LOGGER_DEBUG);
|
logger('delete file ' . basename($this->red_path), LOGGER_DEBUG);
|
||||||
|
|
||||||
@ -413,8 +401,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
if ($sync)
|
if ($sync)
|
||||||
build_sync_packet($ch['channel_id'], array('file' => array($sync)));
|
build_sync_packet($ch['channel_id'], array('file' => array($sync)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -573,14 +559,12 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
/**
|
/**
|
||||||
* @brief Array with all Directory and File DAV\Node items for the given path.
|
* @brief Array with all Directory and File DAV\Node items for the given path.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param string $file path to a directory
|
* @param string $file path to a directory
|
||||||
* @param \Zotlabs\Storage\BasicAuth &$auth
|
* @param \Zotlabs\Storage\BasicAuth &$auth
|
||||||
* @returns null|array \Sabre\DAV\INode[]
|
* @returns null|array \Sabre\DAV\INode[]
|
||||||
* @throw \Sabre\DAV\Exception\Forbidden
|
* @throw \Sabre\DAV\Exception\Forbidden
|
||||||
* @throw \Sabre\DAV\Exception\NotFound
|
* @throw \Sabre\DAV\Exception\NotFound
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function CollectionData($file, &$auth) {
|
function CollectionData($file, &$auth) {
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
|
||||||
@ -697,7 +681,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
* @param BasicAuth &$auth
|
* @param BasicAuth &$auth
|
||||||
* @return array Directory[]
|
* @return array Directory[]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function ChannelList(&$auth) {
|
function ChannelList(&$auth) {
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
|
||||||
@ -722,7 +705,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param string $file
|
* @param string $file
|
||||||
* path to file or directory
|
* path to file or directory
|
||||||
* @param BasicAuth &$auth
|
* @param BasicAuth &$auth
|
||||||
@ -730,7 +712,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
* @return File|Directory|boolean|null
|
* @return File|Directory|boolean|null
|
||||||
* @throw \Sabre\DAV\Exception\Forbidden
|
* @throw \Sabre\DAV\Exception\Forbidden
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function FileData($file, &$auth, $test = false) {
|
function FileData($file, &$auth, $test = false) {
|
||||||
logger($file . (($test) ? ' (test mode) ' : ''), LOGGER_DATA);
|
logger($file . (($test) ? ' (test mode) ' : ''), LOGGER_DATA);
|
||||||
|
|
||||||
@ -744,7 +725,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
$file = substr($file, 4);
|
$file = substr($file, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((! $file) || ($file === '/')) {
|
if ((! $file) || ($file === '/')) {
|
||||||
return new Directory('/', $auth);
|
return new Directory('/', $auth);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user