[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;
|
||||||
@ -114,9 +114,9 @@ class Browser extends DAV\Browser\Plugin {
|
|||||||
$type = null;
|
$type = null;
|
||||||
|
|
||||||
// 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,8 +247,8 @@ 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')) {
|
||||||
$func = str_replace('-', '_', $current_theme[0]) . '_init';
|
$func = str_replace('-', '_', $current_theme[0]) . '_init';
|
||||||
@ -279,15 +278,14 @@ class Browser extends DAV\Browser\Plugin {
|
|||||||
$aclselect = null;
|
$aclselect = null;
|
||||||
$lockstate = '';
|
$lockstate = '';
|
||||||
|
|
||||||
if($this->auth->owner_id) {
|
if ($this->auth->owner_id) {
|
||||||
$channel = channelx_by_n($this->auth->owner_id);
|
$channel = channelx_by_n($this->auth->owner_id);
|
||||||
if($channel) {
|
if ($channel) {
|
||||||
$acl = new \Zotlabs\Access\AccessList($channel);
|
$acl = new \Zotlabs\Access\AccessList($channel);
|
||||||
$channel_acl = $acl->get();
|
$channel_acl = $acl->get();
|
||||||
$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')) : '');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +314,7 @@ class Browser extends DAV\Browser\Plugin {
|
|||||||
$quota['desc'] = $quotaDesc;
|
$quota['desc'] = $quotaDesc;
|
||||||
$quota['warning'] = ((($limit) && ((round($used / $limit, 1) * 100) >= 90)) ? t('WARNING:') : ''); // 10485760 bytes = 100MB
|
$quota['warning'] = ((($limit) && ((round($used / $limit, 1) * 100) >= 90)) ? t('WARNING:') : ''); // 10485760 bytes = 100MB
|
||||||
|
|
||||||
$path = trim(str_replace('cloud/' . $this->auth->owner_nick, '', $path),'/');
|
$path = trim(str_replace('cloud/' . $this->auth->owner_nick, '', $path), '/');
|
||||||
|
|
||||||
$output .= replace_macros(get_markup_template('cloud_actionspanel.tpl'), array(
|
$output .= replace_macros(get_markup_template('cloud_actionspanel.tpl'), array(
|
||||||
'$folder_header' => t('Create new folder'),
|
'$folder_header' => t('Create new folder'),
|
||||||
@ -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,12 +167,11 @@ 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);
|
||||||
if($sync)
|
if ($sync)
|
||||||
build_sync_packet($ch['channel_id'],array('file' => array($sync)));
|
build_sync_packet($ch['channel_id'], array('file' => array($sync)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->red_path = $new_path;
|
$this->red_path = $new_path;
|
||||||
@ -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",
|
||||||
@ -226,16 +222,16 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
|
|
||||||
$direct = null;
|
$direct = null;
|
||||||
|
|
||||||
if($this->folder_hash) {
|
if ($this->folder_hash) {
|
||||||
$r = q("select * from attach where hash = '%s' and is_dir = 1 and uid = %d limit 1",
|
$r = q("select * from attach where hash = '%s' and is_dir = 1 and uid = %d limit 1",
|
||||||
dbesc($this->folder_hash),
|
dbesc($this->folder_hash),
|
||||||
intval($c[0]['channel_id'])
|
intval($c[0]['channel_id'])
|
||||||
);
|
);
|
||||||
if($r)
|
if ($r)
|
||||||
$direct = $r[0];
|
$direct = $r[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($direct) && (($direct['allow_cid']) || ($direct['allow_gid']) || ($direct['deny_cid']) || ($direct['deny_gid']))) {
|
if (($direct) && (($direct['allow_cid']) || ($direct['allow_gid']) || ($direct['deny_cid']) || ($direct['deny_gid']))) {
|
||||||
$allow_cid = $direct['allow_cid'];
|
$allow_cid = $direct['allow_cid'];
|
||||||
$allow_gid = $direct['allow_gid'];
|
$allow_gid = $direct['allow_gid'];
|
||||||
$deny_cid = $direct['deny_cid'];
|
$deny_cid = $direct['deny_cid'];
|
||||||
@ -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,16 +278,13 @@ 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);
|
||||||
if(($x) && ($x[2] === IMAGETYPE_GIF || $x[2] === IMAGETYPE_JPEG || $x[2] === IMAGETYPE_PNG)) {
|
if (($x) && ($x[2] === IMAGETYPE_GIF || $x[2] === IMAGETYPE_JPEG || $x[2] === IMAGETYPE_PNG)) {
|
||||||
$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),
|
||||||
@ -329,28 +320,26 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($is_photo) {
|
if ($is_photo) {
|
||||||
$album = '';
|
$album = '';
|
||||||
if($this->folder_hash) {
|
if ($this->folder_hash) {
|
||||||
$f1 = q("select filename from attach WHERE hash = '%s' AND uid = %d",
|
$f1 = q("select filename from attach WHERE hash = '%s' AND uid = %d",
|
||||||
dbesc($this->folder_hash),
|
dbesc($this->folder_hash),
|
||||||
intval($c[0]['channel_id'])
|
intval($c[0]['channel_id'])
|
||||||
);
|
);
|
||||||
if($f1)
|
if ($f1)
|
||||||
$album = $f1[0]['filename'];
|
$album = $f1[0]['filename'];
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once('include/photos.php');
|
require_once('include/photos.php');
|
||||||
$args = array( 'resource_id' => $hash, 'album' => $album, 'os_path' => $f, 'filename' => $name, 'getimagesize' => $x, 'directory' => $direct);
|
$args = array( 'resource_id' => $hash, 'album' => $album, 'os_path' => $f, 'filename' => $name, 'getimagesize' => $x, 'directory' => $direct);
|
||||||
$p = photo_upload($c[0],\App::get_observer(),$args);
|
$p = photo_upload($c[0], \App::get_observer(), $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sync = attach_export_data($c[0],$hash);
|
$sync = attach_export_data($c[0], $hash);
|
||||||
|
|
||||||
if($sync)
|
|
||||||
build_sync_packet($c[0]['channel_id'],array('file' => array($sync)));
|
|
||||||
|
|
||||||
|
|
||||||
|
if ($sync)
|
||||||
|
build_sync_packet($c[0]['channel_id'], array('file' => array($sync)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -379,7 +368,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
logger('createDirectory: attach_export_data returns $sync:' . print_r($sync, true), LOGGER_DEBUG);
|
logger('createDirectory: attach_export_data returns $sync:' . print_r($sync, true), LOGGER_DEBUG);
|
||||||
|
|
||||||
if($sync) {
|
if($sync) {
|
||||||
build_sync_packet($r[0]['channel_id'],array('file' => array($sync)));
|
build_sync_packet($r[0]['channel_id'], array('file' => array($sync)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -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);
|
||||||
|
|
||||||
@ -408,13 +396,11 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
attach_delete($this->auth->owner_id, $this->folder_hash);
|
attach_delete($this->auth->owner_id, $this->folder_hash);
|
||||||
|
|
||||||
$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,true);
|
$sync = attach_export_data($ch, $this->folder_hash, true);
|
||||||
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);
|
||||||
|
|
||||||
@ -739,12 +720,11 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
$file = substr($file, 6);
|
$file = substr($file, 6);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$x = strpos($file,'/dav');
|
$x = strpos($file, '/dav');
|
||||||
if($x === 0)
|
if($x === 0)
|
||||||
$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