aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2016-09-28 21:53:16 +0200
committerKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2016-09-29 20:28:47 +0200
commitbb5b19c2fb3f2fef1c4f08011fd572e07563ef60 (patch)
tree253854aa5280ba8e71b68a87bf2b16e2b4333fe0
parentb0dbb6708eec0369d57802e1e5d8ea26bfb78292 (diff)
downloadvolse-hubzilla-bb5b19c2fb3f2fef1c4f08011fd572e07563ef60.tar.gz
volse-hubzilla-bb5b19c2fb3f2fef1c4f08011fd572e07563ef60.tar.bz2
volse-hubzilla-bb5b19c2fb3f2fef1c4f08011fd572e07563ef60.zip
[TASK] Replace deprecated Sabre functions.
Replaced some deprecated functions from Sabre's URLUtil class.
-rw-r--r--Zotlabs/Storage/Browser.php29
-rw-r--r--Zotlabs/Storage/Directory.php90
2 files changed, 48 insertions, 71 deletions
diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php
index 948f7c733..4a7e49e86 100644
--- a/Zotlabs/Storage/Browser.php
+++ b/Zotlabs/Storage/Browser.php
@@ -99,10 +99,10 @@ class Browser extends DAV\Browser\Plugin {
$parent = $this->server->tree->getNodeForPath($path);
$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") {
- list($parentUri) = \Sabre\HTTP\URLUtil::splitPath($path);
- $fullPath = \Sabre\HTTP\URLUtil::encodePath($this->server->getBaseUri() . $parentUri);
+ list($parentUri) = \Sabre\Uri\split($path);
+ $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['path'] = $fullPath;
@@ -114,9 +114,9 @@ class Browser extends DAV\Browser\Plugin {
$type = null;
// 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'])) {
$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'] : '';
$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;
@@ -248,8 +247,8 @@ class Browser extends DAV\Browser\Plugin {
$current_theme = \Zotlabs\Render\Theme::current();
- $theme_info_file = "view/theme/" . $current_theme[0] . "/php/theme.php";
- if (file_exists($theme_info_file)){
+ $theme_info_file = 'view/theme/' . $current_theme[0] . '/php/theme.php';
+ if (file_exists($theme_info_file)) {
require_once($theme_info_file);
if (function_exists(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;
$lockstate = '';
- if($this->auth->owner_id) {
+ if ($this->auth->owner_id) {
$channel = channelx_by_n($this->auth->owner_id);
- if($channel) {
+ if ($channel) {
$acl = new \Zotlabs\Access\AccessList($channel);
$channel_acl = $acl->get();
$lockstate = (($acl->is_private()) ? 'lock' : 'unlock');
$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['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(
'$folder_header' => t('Create new folder'),
@@ -354,7 +352,7 @@ class Browser extends DAV\Browser\Plugin {
*
* Given the owner, the parent folder and and attach name get the attachment
* hash.
- *
+ *
* @param int $owner
* The owner_id
* @param string $hash
@@ -363,14 +361,13 @@ class Browser extends DAV\Browser\Plugin {
* The name of the attachment
* @return string
*/
-
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",
intval($owner),
dbesc($parentHash),
dbesc($attachName)
);
- $hash = "";
+ $hash = '';
if ($r) {
foreach ($r as $rr) {
$hash = $rr['hash'];
diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php
index 15e06e28f..de4d90da4 100644
--- a/Zotlabs/Storage/Directory.php
+++ b/Zotlabs/Storage/Directory.php
@@ -3,7 +3,6 @@
namespace Zotlabs\Storage;
use Sabre\DAV;
-use Sabre\HTTP;
/**
* @brief RedDirectory class.
@@ -54,7 +53,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
logger('directory ' . $ext_path, LOGGER_DATA);
$this->ext_path = $ext_path;
// remove "/cloud" from the beginning of the path
- $modulename = \App::$module;
+ $modulename = \App::$module;
$this->red_path = ((strpos($ext_path, '/' . $modulename) === 0) ? substr($ext_path, strlen($modulename) + 1) : $ext_path);
if (! $this->red_path) {
$this->red_path = '/';
@@ -99,7 +98,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
/**
* @brief Returns a child by name.
*
- *
* @throw \Sabre\DAV\Exception\Forbidden
* @throw \Sabre\DAV\Exception\NotFound
* @param string $name
@@ -160,7 +158,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
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;
$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)
);
-
$ch = channelx_by_n($this->auth->owner_id);
- if($ch) {
- $sync = attach_export_data($ch,$this->folder_hash);
- if($sync)
- build_sync_packet($ch['channel_id'],array('file' => array($sync)));
+ if ($ch) {
+ $sync = attach_export_data($ch, $this->folder_hash);
+ if ($sync)
+ build_sync_packet($ch['channel_id'], array('file' => array($sync)));
}
$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.');
}
-
$mimetype = z_mime_content_type($name);
$c = q("SELECT * FROM channel WHERE channel_id = %d AND channel_removed = 0 LIMIT 1",
@@ -226,22 +222,22 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$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",
dbesc($this->folder_hash),
intval($c[0]['channel_id'])
);
- if($r)
+ if ($r)
$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_gid = $direct['allow_gid'];
$deny_cid = $direct['deny_cid'];
$deny_gid = $direct['deny_gid'];
}
- else {
+ else {
$allow_cid = $c[0]['channel_allow_cid'];
$allow_gid = $c[0]['channel_allow_gid'];
$deny_cid = $c[0]['channel_deny_cid'];
@@ -270,8 +266,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
dbesc($deny_gid)
);
-
-
// returns the number of bytes that were written to the file, or FALSE on failure
$size = file_put_contents($f, $data);
// delete attach entry if file_put_contents() failed
@@ -284,16 +278,13 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
// returns now
$edited = datetime_convert();
-
-
$is_photo = 0;
$x = @getimagesize($f);
- logger('getimagesize: ' . print_r($x,true), LOGGER_DATA);
- if(($x) && ($x[2] === IMAGETYPE_GIF || $x[2] === IMAGETYPE_JPEG || $x[2] === IMAGETYPE_PNG)) {
+ logger('getimagesize: ' . print_r($x,true), LOGGER_DATA);
+ if (($x) && ($x[2] === IMAGETYPE_GIF || $x[2] === IMAGETYPE_JPEG || $x[2] === IMAGETYPE_PNG)) {
$is_photo = 1;
}
-
// updates entry with filesize and timestamp
$d = q("UPDATE attach SET filesize = '%s', is_photo = %d, edited = '%s' WHERE hash = '%s' AND uid = %d",
dbesc($size),
@@ -329,28 +320,26 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
}
}
- if($is_photo) {
+ if ($is_photo) {
$album = '';
- if($this->folder_hash) {
+ if ($this->folder_hash) {
$f1 = q("select filename from attach WHERE hash = '%s' AND uid = %d",
dbesc($this->folder_hash),
intval($c[0]['channel_id'])
);
- if($f1)
+ if ($f1)
$album = $f1[0]['filename'];
}
require_once('include/photos.php');
$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);
-
- if($sync)
- build_sync_packet($c[0]['channel_id'],array('file' => array($sync)));
-
+ $sync = attach_export_data($c[0], $hash);
+ if ($sync)
+ build_sync_packet($c[0]['channel_id'], array('file' => array($sync)));
}
/**
@@ -379,10 +368,10 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
logger('createDirectory: attach_export_data returns $sync:' . print_r($sync, true), LOGGER_DEBUG);
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 {
logger('error ' . print_r($result, true), LOGGER_DEBUG);
}
}
@@ -391,7 +380,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
/**
* @brief delete directory
*/
-
public function delete() {
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);
$ch = channelx_by_n($this->auth->owner_id);
- if($ch) {
- $sync = attach_export_data($ch,$this->folder_hash,true);
- if($sync)
- build_sync_packet($ch['channel_id'],array('file' => array($sync)));
+ if ($ch) {
+ $sync = attach_export_data($ch, $this->folder_hash, true);
+ if ($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.
*
- *
* @param string $file path to a directory
* @param \Zotlabs\Storage\BasicAuth &$auth
* @returns null|array \Sabre\DAV\INode[]
* @throw \Sabre\DAV\Exception\Forbidden
* @throw \Sabre\DAV\Exception\NotFound
*/
-
function CollectionData($file, &$auth) {
$ret = array();
@@ -649,7 +633,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
if ($errors) {
if ($permission_error) {
throw new DAV\Exception\Forbidden('Permission denied.');
- }
+ }
else {
throw new DAV\Exception\NotFound('A component of the request file path could not be found.');
}
@@ -663,7 +647,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$prefix = 'DISTINCT ON (filename)';
$suffix = 'ORDER BY filename';
- }
+ }
else {
$prefix = '';
$suffix = 'GROUP BY filename';
@@ -677,7 +661,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
//logger('filename: ' . $rr['filename'], LOGGER_DEBUG);
if (intval($rr['is_dir'])) {
$ret[] = new Directory($path . '/' . $rr['filename'], $auth);
- }
+ }
else {
$ret[] = new File($path . '/' . $rr['filename'], $rr, $auth);
}
@@ -697,11 +681,10 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
* @param BasicAuth &$auth
* @return array Directory[]
*/
-
function ChannelList(&$auth) {
$ret = array();
- $r = q("SELECT channel_id, channel_address FROM channel WHERE channel_removed = 0
+ $r = q("SELECT channel_id, channel_address FROM channel WHERE channel_removed = 0
AND channel_system = 0 AND NOT (channel_pageflags & %d)>0",
intval(PAGE_HIDDEN)
);
@@ -720,8 +703,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
/**
- * @brief
- *
+ * @brief
*
* @param string $file
* path to file or directory
@@ -730,7 +712,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
* @return File|Directory|boolean|null
* @throw \Sabre\DAV\Exception\Forbidden
*/
-
function FileData($file, &$auth, $test = false) {
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);
}
else {
- $x = strpos($file,'/dav');
+ $x = strpos($file, '/dav');
if($x === 0)
- $file = substr($file,4);
+ $file = substr($file, 4);
}
-
if ((! $file) || ($file === '/')) {
return new Directory('/', $auth);
}
@@ -780,7 +760,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$errors = false;
- for ($x = 1; $x < count($path_arr); $x++) {
+ for ($x = 1; $x < count($path_arr); $x++) {
$r = q("select id, hash, filename, flags, is_dir from attach where folder = '%s' and filename = '%s' and uid = %d and is_dir != 0 $perms",
dbesc($folder),
dbesc($path_arr[$x]),
@@ -792,7 +772,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$path = $path . '/' . $r[0]['filename'];
}
if (! $r) {
- $r = q("select id, uid, hash, filename, filetype, filesize, revision, folder, flags, is_dir, os_storage, created, edited from attach
+ $r = q("select id, uid, hash, filename, filetype, filesize, revision, folder, flags, is_dir, os_storage, created, edited from attach
where folder = '%s' and filename = '%s' and uid = %d $perms order by filename limit 1",
dbesc($folder),
dbesc(basename($file)),
@@ -801,7 +781,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
}
if (! $r) {
$errors = true;
- $r = q("select id, uid, hash, filename, filetype, filesize, revision, folder, flags, is_dir, os_storage, created, edited from attach
+ $r = q("select id, uid, hash, filename, filetype, filesize, revision, folder, flags, is_dir, os_storage, created, edited from attach
where folder = '%s' and filename = '%s' and uid = %d order by filename limit 1",
dbesc($folder),
dbesc(basename($file)),