aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2018-06-17 17:00:17 +0200
committerMario <mario@mariovavti.com>2018-06-17 17:00:17 +0200
commit28043726e64f750e646b42aa6f649e277fc3767e (patch)
tree18a41bea6a4805454e0b1a2dacdfeda451854690 /Zotlabs
parent9c5df51141d68e50d3c1f5d3097160408debce48 (diff)
parent7e736c5359732647f5203bf2bb7fcd50c448fad9 (diff)
downloadvolse-hubzilla-28043726e64f750e646b42aa6f649e277fc3767e.tar.gz
volse-hubzilla-28043726e64f750e646b42aa6f649e277fc3767e.tar.bz2
volse-hubzilla-28043726e64f750e646b42aa6f649e277fc3767e.zip
Merge branch 'dev' of https://framagit.org/hubzilla/core into dev
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Lib/Share.php4
-rw-r--r--Zotlabs/Module/Admin/Security.php10
-rw-r--r--Zotlabs/Module/Channel.php4
-rw-r--r--Zotlabs/Module/Cloud.php9
-rw-r--r--Zotlabs/Module/Display.php4
-rw-r--r--Zotlabs/Module/Home.php2
-rw-r--r--Zotlabs/Module/Invite.php2
-rw-r--r--Zotlabs/Module/Network.php14
-rw-r--r--Zotlabs/Module/Pubstream.php4
-rw-r--r--Zotlabs/Module/Search.php4
-rw-r--r--Zotlabs/Storage/Browser.php10
-rw-r--r--Zotlabs/Storage/Directory.php77
12 files changed, 90 insertions, 54 deletions
diff --git a/Zotlabs/Lib/Share.php b/Zotlabs/Lib/Share.php
index e9e4d23c4..d3ecbf7fa 100644
--- a/Zotlabs/Lib/Share.php
+++ b/Zotlabs/Lib/Share.php
@@ -107,7 +107,7 @@ class Share {
}
public function bbcode() {
- $bb = NULL_STR;
+ $bb = EMPTY_STR;
if(! $this->item)
return $bb;
@@ -140,4 +140,4 @@ class Share {
}
-} \ No newline at end of file
+}
diff --git a/Zotlabs/Module/Admin/Security.php b/Zotlabs/Module/Admin/Security.php
index 49e1ccf42..80c1d85b7 100644
--- a/Zotlabs/Module/Admin/Security.php
+++ b/Zotlabs/Module/Admin/Security.php
@@ -16,7 +16,13 @@ class Security {
$block_public = ((x($_POST,'block_public')) ? True : False);
set_config('system','block_public',$block_public);
-
+
+ $cloud_noroot = ((x($_POST,'cloud_noroot')) ? 1 : 0);
+ set_config('system','cloud_disable_siteroot',1 - $cloud_noroot);
+
+ $cloud_disksize = ((x($_POST,'cloud_disksize')) ? 1 : 0);
+ set_config('system','cloud_report_disksize',$cloud_disksize);
+
$ws = $this->trim_array_elems(explode("\n",$_POST['whitelisted_sites']));
set_config('system','whitelisted_sites',$ws);
@@ -87,6 +93,8 @@ class Security {
'$page' => t('Security'),
'$form_security_token' => get_form_security_token('admin_security'),
'$block_public' => array('block_public', t("Block public"), get_config('system','block_public'), t("Check to block public access to all otherwise public personal pages on this site unless you are currently authenticated.")),
+ '$cloud_noroot' => [ 'cloud_noroot', t('Provide a cloud root directory'), 1 - intval(get_config('system','cloud_disable_siteroot')), t('The cloud root directory lists all channel names which provide public files') ],
+ '$cloud_disksize' => [ 'cloud_disksize', t('Show total disk space available to cloud uploads'), intval(get_config('system','cloud_report_disksize')), '' ],
'$transport_security' => array('transport_security', t('Set "Transport Security" HTTP header'),intval(get_config('system','transport_security_header')),''),
'$content_security' => array('content_security', t('Set "Content Security Policy" HTTP header'),intval(get_config('system','content_security_policy')),''),
'$allowed_email' => array('allowed_email', t("Allowed email domains"), get_config('system','allowed_email'), t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")),
diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php
index 80e81580a..b5e6b3aee 100644
--- a/Zotlabs/Module/Channel.php
+++ b/Zotlabs/Module/Channel.php
@@ -344,8 +344,8 @@ class Channel extends \Zotlabs\Web\Controller {
'$uid' => ((\App::$profile['profile_uid']) ? \App::$profile['profile_uid'] : '0'),
'$gid' => '0',
'$cid' => '0',
- '$cmin' => '0',
- '$cmax' => '0',
+ '$cmin' => '(-1)',
+ '$cmax' => '(-1)',
'$star' => '0',
'$liked' => '0',
'$conv' => '0',
diff --git a/Zotlabs/Module/Cloud.php b/Zotlabs/Module/Cloud.php
index 34397d275..1b330ecba 100644
--- a/Zotlabs/Module/Cloud.php
+++ b/Zotlabs/Module/Cloud.php
@@ -35,11 +35,20 @@ class Cloud extends \Zotlabs\Web\Controller {
if (argc() > 1)
$which = argv(1);
+
+ if (argc() < 2 && intval(get_config('system','cloud_disable_siteroot'))) {
+ notice( t('Permission denied.') . EOL);
+ construct_page();
+ killme();
+ }
+
$profile = 0;
if ($which)
profile_load( $which, $profile);
+
+
$auth = new \Zotlabs\Storage\BasicAuth();
$ob_hash = get_observer_hash();
diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php
index a127ab196..fe0408c6f 100644
--- a/Zotlabs/Module/Display.php
+++ b/Zotlabs/Module/Display.php
@@ -213,8 +213,8 @@ class Display extends \Zotlabs\Web\Controller {
'$uid' => '0',
'$gid' => '0',
'$cid' => '0',
- '$cmin' => '0',
- '$cmax' => '99',
+ '$cmin' => '(-1)',
+ '$cmax' => '(-1)',
'$star' => '0',
'$liked' => '0',
'$conv' => '0',
diff --git a/Zotlabs/Module/Home.php b/Zotlabs/Module/Home.php
index 4b3e596a9..647a6412a 100644
--- a/Zotlabs/Module/Home.php
+++ b/Zotlabs/Module/Home.php
@@ -9,7 +9,7 @@ require_once('include/conversation.php');
class Home extends \Zotlabs\Web\Controller {
function init() {
-
+
$ret = array();
call_hooks('home_init',$ret);
diff --git a/Zotlabs/Module/Invite.php b/Zotlabs/Module/Invite.php
index 0bcd1c1fa..359f99b3e 100644
--- a/Zotlabs/Module/Invite.php
+++ b/Zotlabs/Module/Invite.php
@@ -113,7 +113,7 @@ class Invite extends \Zotlabs\Web\Controller {
$invite_code = autoname(8) . rand(1000,9999);
$nmessage = str_replace('$invite_code',$invite_code,$message);
- $r = q("INSERT INTO register (hash,created) VALUES ('%s', '%s') ",
+ $r = q("INSERT INTO register (hash,created,uid,password,lang) VALUES ('%s', '%s',0,'','') ",
dbesc($invite_code),
dbesc(datetime_convert())
);
diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php
index 2e9bcd2ce..172157aab 100644
--- a/Zotlabs/Module/Network.php
+++ b/Zotlabs/Module/Network.php
@@ -123,8 +123,8 @@ class Network extends \Zotlabs\Web\Controller {
$def_acl = array('allow_gid' => '<' . $r[0]['hash'] . '>');
}
- $default_cmin = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmin',0) : 0);
- $default_cmax = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmax',99) : 99);
+ $default_cmin = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmin',0) : (-1));
+ $default_cmax = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmax',99) : (-1));
$cid = ((x($_GET,'cid')) ? intval($_GET['cid']) : 0);
$star = ((x($_GET,'star')) ? intval($_GET['star']) : 0);
@@ -140,6 +140,7 @@ class Network extends \Zotlabs\Web\Controller {
$deftag = '';
+
if(x($_GET,'search') || $file || (!$pf && $cid))
$nouveau = true;
@@ -334,8 +335,8 @@ class Network extends \Zotlabs\Web\Controller {
'$uid' => ((local_channel()) ? local_channel() : '0'),
'$gid' => (($gid) ? $gid : '0'),
'$cid' => (($cid) ? $cid : '0'),
- '$cmin' => (($cmin) ? $cmin : '0'),
- '$cmax' => (($cmax) ? $cmax : '0'),
+ '$cmin' => (($cmin) ? $cmin : '(-1)'),
+ '$cmax' => (($cmax) ? $cmax : '(-1)'),
'$star' => (($star) ? $star : '0'),
'$liked' => (($liked) ? $liked : '0'),
'$conv' => (($conv) ? $conv : '0'),
@@ -420,8 +421,9 @@ class Network extends \Zotlabs\Web\Controller {
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
}
-
- if(($cmin != 0) || ($cmax != 99)) {
+ // cmin and cmax are both -1 when the affinity tool is disabled
+
+ if(($cmin != (-1)) || ($cmax != (-1))) {
// Not everybody who shows up in the network stream will be in your address book.
// By default those that aren't are assumed to have closeness = 99; but this isn't
diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php
index f0e87f468..7b80a3978 100644
--- a/Zotlabs/Module/Pubstream.php
+++ b/Zotlabs/Module/Pubstream.php
@@ -118,8 +118,8 @@ class Pubstream extends \Zotlabs\Web\Controller {
'$uid' => ((local_channel()) ? local_channel() : '0'),
'$gid' => '0',
'$cid' => '0',
- '$cmin' => '0',
- '$cmax' => '99',
+ '$cmin' => '(-1)',
+ '$cmax' => '(-1)',
'$star' => '0',
'$liked' => '0',
'$conv' => '0',
diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php
index 3a552bb22..e520c671d 100644
--- a/Zotlabs/Module/Search.php
+++ b/Zotlabs/Module/Search.php
@@ -121,8 +121,8 @@ class Search extends \Zotlabs\Web\Controller {
'$uid' => ((\App::$profile['profile_uid']) ? \App::$profile['profile_uid'] : '0'),
'$gid' => '0',
'$cid' => '0',
- '$cmin' => '0',
- '$cmax' => '0',
+ '$cmin' => '(-1)',
+ '$cmax' => '(-1)',
'$star' => '0',
'$liked' => '0',
'$conv' => '0',
diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php
index 153016da6..c2d70b854 100644
--- a/Zotlabs/Storage/Browser.php
+++ b/Zotlabs/Storage/Browser.php
@@ -333,6 +333,7 @@ class Browser extends DAV\Browser\Plugin {
$aclselect = null;
$lockstate = '';
+ $limit = 0;
if($this->auth->owner_id) {
$channel = channelx_by_n($this->auth->owner_id);
@@ -343,10 +344,15 @@ class Browser extends DAV\Browser\Plugin {
$aclselect = ((local_channel() == $this->auth->owner_id) ? populate_acl($channel_acl,false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_storage')) : '');
}
+
+ // Storage and quota for the account (all channels of the owner of this directory)!
+ $limit = engr_units_to_bytes(service_class_fetch($this->auth->owner_id, 'attach_upload_limit'));
+ }
+
+ if((! $limit) && get_config('system','cloud_report_disksize')) {
+ $limit = engr_units_to_bytes(disk_free_space('store'));
}
- // Storage and quota for the account (all channels of the owner of this directory)!
- $limit = engr_units_to_bytes(service_class_fetch($owner, 'attach_upload_limit'));
$r = q("SELECT SUM(filesize) AS total FROM attach WHERE aid = %d",
intval($this->auth->channel_account_id)
);
diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php
index f46e2e666..73548fda0 100644
--- a/Zotlabs/Storage/Directory.php
+++ b/Zotlabs/Storage/Directory.php
@@ -571,39 +571,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo
return datetime_convert('UTC', 'UTC', $r[0]['edited'], 'U');
}
- /**
- * @brief Return quota usage.
- *
- * @fixme Should guests relly see the used/free values from filesystem of the
- * complete store directory?
- *
- * @return array with used and free values in bytes.
- */
- public function getQuotaInfo() {
- // values from the filesystem of the complete <i>store/</i> directory
- $limit = disk_total_space('store');
- $free = disk_free_space('store');
-
- if ($this->auth->owner_id) {
- $c = q("select * from channel where channel_id = %d and channel_removed = 0 limit 1",
- intval($this->auth->owner_id)
- );
-
- $ulimit = engr_units_to_bytes(service_class_fetch($c[0]['channel_id'], 'attach_upload_limit'));
- $limit = (($ulimit) ? $ulimit : $limit);
-
- $x = q("select sum(filesize) as total from attach where aid = %d",
- intval($c[0]['channel_account_id'])
- );
- $free = (($x) ? $limit - $x[0]['total'] : 0);
- }
-
- return array(
- $limit - $free,
- $free
- );
- }
-
/**
* @brief Array with all Directory and File DAV\\Node items for the given path.
@@ -895,4 +862,48 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo
return false;
}
+ public function getQuotaInfo() {
+
+ /**
+ * Returns the quota information
+ *
+ * This method MUST return an array with 2 values, the first being the total used space,
+ * the second the available space (in bytes)
+ */
+
+ $used = 0;
+ $limit = 0;
+ $free = 0;
+
+ if ($this->auth->owner_id) {
+ $channel = channelx_by_n($this->auth->owner_id);
+ if($channel) {
+ $r = q("SELECT SUM(filesize) AS total FROM attach WHERE aid = %d",
+ intval($channel['channel_account_id'])
+ );
+ $used = (($r) ? (float) $r[0]['total'] : 0);
+ $limit = (float) service_class_fetch($this->auth->owner_id, 'attach_upload_limit');
+ if($limit) {
+ // Don't let the result go negative
+ $free = (($limit > $used) ? $limit - $used : 0);
+ }
+ }
+ }
+
+ if(! $limit) {
+ $free = disk_free_space('store');
+ $used = disk_total_space('store') - $free;
+ }
+
+ // prevent integer overflow on 32-bit systems
+
+ if($used > (float) PHP_INT_MAX)
+ $used = PHP_INT_MAX;
+ if($free > (float) PHP_INT_MAX)
+ $free = PHP_INT_MAX;
+
+ return [ (int) $used, (int) $free ];
+
+ }
+
}