aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-12-12 11:54:26 -0800
committerzotlabs <mike@macgirvin.com>2017-12-12 11:54:26 -0800
commit215d615fc3bb9e168e21a78a6319a7971c4d1e9e (patch)
treeff0af309ef283c48a6f3df5d590068c103d6bf7a /include
parent979c05b24da0497be582aacaa8b744f692b56ccf (diff)
parentd0956eb39d7a361639f5cd73fb1c3c8463fb1e99 (diff)
downloadvolse-hubzilla-215d615fc3bb9e168e21a78a6319a7971c4d1e9e.tar.gz
volse-hubzilla-215d615fc3bb9e168e21a78a6319a7971c4d1e9e.tar.bz2
volse-hubzilla-215d615fc3bb9e168e21a78a6319a7971c4d1e9e.zip
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
Diffstat (limited to 'include')
-rw-r--r--include/api_auth.php3
-rw-r--r--include/api_zot.php11
-rw-r--r--include/attach.php29
-rw-r--r--include/bbcode.php2
-rw-r--r--include/channel.php2
-rw-r--r--include/import.php37
-rwxr-xr-xinclude/items.php16
-rw-r--r--include/nav.php2
-rw-r--r--include/socgraph.php4
-rw-r--r--include/zot.php2
10 files changed, 93 insertions, 15 deletions
diff --git a/include/api_auth.php b/include/api_auth.php
index 0818fa54b..5c0bcb317 100644
--- a/include/api_auth.php
+++ b/include/api_auth.php
@@ -52,6 +52,7 @@ function api_login(&$a){
/* Signature authentication */
if(array_key_exists($head,$_SERVER) && substr(trim($_SERVER[$head]),0,9) === 'Signature') {
+
if($head !== 'HTTP_AUTHORIZATION') {
$_SERVER['HTTP_AUTHORIZATION'] = $_SERVER[$head];
continue;
@@ -59,7 +60,7 @@ function api_login(&$a){
$sigblock = \Zotlabs\Web\HTTPSig::parse_sigheader($_SERVER[$head]);
if($sigblock) {
- $keyId = $sigblock['keyId'];
+ $keyId = str_replace('acct:','',$sigblock['keyId']);
if($keyId) {
$r = q("select * from hubloc where hubloc_addr = '%s' limit 1",
dbesc($keyId)
diff --git a/include/api_zot.php b/include/api_zot.php
index aaa9ee497..54f905b4c 100644
--- a/include/api_zot.php
+++ b/include/api_zot.php
@@ -150,7 +150,11 @@
$start = ((array_key_exists('start',$_REQUEST)) ? intval($_REQUEST['start']) : 0);
$records = ((array_key_exists('records',$_REQUEST)) ? intval($_REQUEST['records']) : 0);
- $x = attach_list_files(api_user(),get_observer_hash(),$hash,$filename,$filetype,'created asc',$start,$records);
+ $since = ((array_key_exists('since',$_REQUEST)) ? datetime_convert(date_default_timezone_get(),'UTC',$_REQUEST['since']) : NULL_DATE);
+ $until = ((array_key_exists('until',$_REQUEST)) ? datetime_convert(date_default_timezone_get(),'UTC',$_REQUEST['until']) : datetime_convert());
+
+ $x = attach_list_files(api_user(),get_observer_hash(),$hash,$filename,$filetype,'created asc',$start,$records, $since, $until);
+
if($start || $records) {
$x['start'] = $start;
$x['records'] = count($x['results']);
@@ -226,7 +230,10 @@
if(! $_REQUEST['file_id'])
return false;
- $ret = attach_export_data(api_user(),$_REQUEST['file_id']);
+ $channel = channelx_by_n(api_user());
+
+ $ret = attach_export_data($channel,$_REQUEST['file_id']);
+
if($ret) {
json_return_and_die($ret);
}
diff --git a/include/attach.php b/include/attach.php
index 3a802bd11..88b6fa8e7 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -189,7 +189,7 @@ function attach_count_files($channel_id, $observer, $hash = '', $filename = '',
* * \e array|boolean \b results array with results, or false
* * \e string \b message with error messages if any
*/
-function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $filetype = '', $orderby = 'created desc', $start = 0, $entries = 0) {
+function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $filetype = '', $orderby = 'created desc', $start = 0, $entries = 0, $since = '', $until = '') {
$ret = array('success' => false);
@@ -198,6 +198,7 @@ function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $
return $ret;
}
+
require_once('include/security.php');
$sql_extra = permissions_sql($channel_id);
@@ -213,14 +214,22 @@ function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $
if($entries)
$limit = " limit " . intval($start) . ", " . intval($entries) . " ";
- // Retrieve all columns except 'data'
+ if(! $since)
+ $since = NULL_DATE;
+
+ if(! $until)
+ $until = datetime_convert();
+
+ $sql_extra .= " and created >= '" . dbesc($since) . "' and created <= '" . dbesc($until) . "' ";
+
+ // Retrieve all columns except 'content'
$r = q("select id, aid, uid, hash, filename, filetype, filesize, revision, folder, os_path, display_path, os_storage, is_dir, is_photo, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d $sql_extra ORDER BY $orderby $limit",
intval($channel_id)
);
$ret['success'] = ((is_array($r)) ? true : false);
- $ret['results'] = ((is_array($r)) ? $r : false);
+ $ret['results'] = ((is_array($r)) ? $r : []);
return $ret;
}
@@ -2052,6 +2061,9 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
if($attach_ptr['is_photo']) {
+
+ // This query could potentially result in a few megabytes of data use.
+
$r = q("select * from photo where resource_id = '%s' and uid = %d order by imgscale asc",
dbesc($resource_id),
intval($channel['channel_id'])
@@ -2063,6 +2075,17 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
$ret['photo'] = $r;
}
+// This query can be used instead in memory starved environments. There will be a corresponding
+// performance hit during sync because the data will need to be fetched over the network.
+// $r = q("select aid,uid,xchan,resource_id,created,edited,title,description,album,filename,mimetype,height,width,filesize,imgscale,photo_usage,profile,is_nsfw,os_storage,display_path,photo_flags,allow_cid,allow_gid,deny_cid,deny_gid from photo where resource_id = '%s' and uid = %d order by imgscale asc",
+// dbesc($resource_id),
+// intval($channel['channel_id'])
+// );
+
+// if($r) {
+// $ret['photo'] = $r;
+// }
+
$r = q("select * from item where resource_id = '%s' and resource_type = 'photo' and uid = %d ",
dbesc($resource_id),
intval($channel['channel_id'])
diff --git a/include/bbcode.php b/include/bbcode.php
index e38473168..ed34bc5d6 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -711,7 +711,7 @@ function parseIdentityAwareHTML($Text) {
function bbcode($Text, $options = []) {
$preserve_nl = ((array_key_exists('preserve_nl',$options)) ? $options['preserve_nl'] : false);
- $tryoembed = ((array_key_exists('tryomebed',$options)) ? $options['tryoembed'] : true);
+ $tryoembed = ((array_key_exists('tryoembed',$options)) ? $options['tryoembed'] : true);
$cache = ((array_key_exists('cache',$options)) ? $options['cache'] : false);
diff --git a/include/channel.php b/include/channel.php
index 16afd8209..2d40b7db6 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -325,7 +325,7 @@ function create_identity($arr) {
'hubloc_guid_sig' => $sig,
'hubloc_hash' => $hash,
'hubloc_addr' => channel_reddress($ret['channel']),
- 'hubloc_primary' => $primary,
+ 'hubloc_primary' => intval($primary),
'hubloc_url' => z_root(),
'hubloc_url_sig' => base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey'])),
'hubloc_host' => App::get_hostname(),
diff --git a/include/import.php b/include/import.php
index cd7056497..a5e8adeb5 100644
--- a/include/import.php
+++ b/include/import.php
@@ -1263,10 +1263,43 @@ function sync_files($channel, $files) {
);
}
- if($p['imgscale'] === 0 && $p['os_storage'])
+ if(intval($p['imgscale']) === 0 && $p['os_storage'])
$p['content'] = $store_path;
else
- $p['content'] = base64_decode($p['content']);
+ $p['content'] = (($p['content'])? base64_decode($p['content']) : '');
+
+ if(intval($p['imgscale']) && (! $p['content'])) {
+
+ $time = datetime_convert();
+
+ $parr = array('hash' => $channel['channel_hash'],
+ 'time' => $time,
+ 'resource' => $att['hash'],
+ 'revision' => 0,
+ 'signature' => base64url_encode(rsa_sign($channel['channel_hash'] . '.' . $time, $channel['channel_prvkey'])),
+ 'resolution' => $p['imgscale']
+ );
+
+ $stored_image = $newfname . '-' . intval($p['imgscale']);
+
+ $fp = fopen($stored_image,'w');
+ if(! $fp) {
+ logger('failed to open storage file.',LOGGER_NORMAL,LOG_ERR);
+ continue;
+ }
+ $redirects = 0;
+
+
+ $headers = [];
+ $headers['Accept'] = 'application/x-zot+json' ;
+ $headers['Sigtoken'] = random_string();
+ $headers = \Zotlabs\Web\HTTPSig::create_sig('',$headers,$channel['channel_prvkey'], 'acct:' . $channel['channel_address'] . '@' . \App::get_hostname(),false,true,'sha512');
+
+ $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]);
+ fclose($fp);
+ $p['content'] = file_get_contents($stored_image);
+ unlink($stored_image);
+ }
if(!isset($p['display_path']))
$p['display_path'] = '';
diff --git a/include/items.php b/include/items.php
index e4727e19e..7948a7c22 100755
--- a/include/items.php
+++ b/include/items.php
@@ -2694,8 +2694,8 @@ function tag_deliver($uid, $item_id) {
}
- if((! $mention) && (! $union)) {
- logger('No mention for ' . $u[0]['channel_name'] . ' and no union.');
+ if(! $mention) {
+ logger('No mention for ' . $u[0]['channel_name']);
continue;
}
@@ -2714,6 +2714,18 @@ function tag_deliver($uid, $item_id) {
}
}
+
+ if($union) {
+ if(intval($item['item_wall']) || intval($item['item_origin']) || (! intval($item['item_thread_top'])) || ($item['id'] != $item['parent'])) {
+ logger('Item was local or a comment. rejected.');
+ return;
+ }
+
+ logger('Creating second delivery chain.');
+ start_delivery_chain($u[0],$item,$item_id,null);
+
+ }
+
}
/**
diff --git a/include/nav.php b/include/nav.php
index 66c4c1556..2366fe7f1 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -313,7 +313,7 @@ EOT;
'$sitelocation' => $sitelocation,
'$nav' => $x['nav'],
'$banner' => $banner,
- '$emptynotifications' => t('Loading...'),
+ '$emptynotifications' => t('Loading'),
'$userinfo' => $x['usermenu'],
'$localuser' => local_channel(),
'$is_owner' => $is_owner,
diff --git a/include/socgraph.php b/include/socgraph.php
index 3c7a893c6..26446d9c7 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -178,9 +178,11 @@ function poco_load($xchan = '', $url = null) {
);
if(! $r) {
- q("insert into xlink ( xlink_xchan, xlink_link, xlink_updated, xlink_static ) values ( '%s', '%s', '%s', 0 ) ",
+ q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_updated, xlink_static ) values ( '%s', '%s', %d, '%s', '%s', 0 ) ",
dbesc($xchan),
dbesc($hash),
+ intval(0),
+ dbesc(''),
dbesc(datetime_convert())
);
}
diff --git a/include/zot.php b/include/zot.php
index d60494d94..6c0d92a42 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -2552,7 +2552,7 @@ function sync_locations($sender, $arr, $absolute = false) {
'hubloc_hash' => $sender['hash'],
'hubloc_addr' => $location['address'],
'hubloc_network' => 'zot',
- 'hubloc_primary' => $location['primary'],
+ 'hubloc_primary' => intval($location['primary']),
'hubloc_url' => $location['url'],
'hubloc_url_sig' => $location['url_sig'],
'hubloc_host' => $location['host'],