From 36d89d02e13ed856de6bace89bfbed05205005db Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sat, 26 Dec 2020 14:10:56 +0100 Subject: Implement Imagemagick resources consumption limiting --- include/photo/photo_driver.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index 52f761b65..f61919eea 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -38,6 +38,10 @@ function photo_factory($data, $type = null) { $v = Imagick::getVersion(); preg_match('/ImageMagick ([0-9]+\.[0-9]+\.[0-9]+)/', $v['versionString'], $m); if(version_compare($m[1], '6.6.7') >= 0) { + $limits = get_config('system', 'imagick_limits', false); + if ($limits) + foreach ($limits as $k => $v) + IMagick::setResourceLimit($k, $v); $ph = new PhotoImagick($data, $type); } else { // earlier imagick versions have issues with scaling png's -- cgit v1.2.3 From ca051e943f172ce272e7ecc5f77cfcc265d0e158 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sat, 26 Dec 2020 14:24:04 +0100 Subject: Do not revalidate cached photos --- Zotlabs/Module/Photo.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 01edda9ae..814705a85 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -35,7 +35,7 @@ class Photo extends \Zotlabs\Web\Controller { call_hooks('cache_mode_hook', $cache_mode); $observer_xchan = get_observer_hash(); - $cachecontrol = ''; + $cachecontrol = ', no-cache'; if(isset($type)) { @@ -102,7 +102,7 @@ class Photo extends \Zotlabs\Web\Controller { $modified = filemtime($default); } - $cachecontrol = ', must-revalidate'; + $cachecontrol .= ', must-revalidate'; } else { @@ -169,6 +169,7 @@ class Photo extends \Zotlabs\Web\Controller { $url = z_root() . '/sslify/' . $filename . '?f=&url=' . urlencode($url); goaway($url); } + $cachecontrol = ''; } } } @@ -271,7 +272,7 @@ class Photo extends \Zotlabs\Web\Controller { // in the event that infrastructure caching is present. $smaxage = intval($maxage/12); - header("Cache-Control: no-cache, s-maxage=" . $smaxage . ", max-age=" . $maxage . $cachecontrol); + header("Cache-Control: s-maxage=" . $smaxage . ", max-age=" . $maxage . $cachecontrol); } -- cgit v1.2.3 From 9670833a5ddc3c24343202fda6f29875e9b3b10b Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 28 Dec 2020 10:12:25 +0000 Subject: files_ng: provide a fallback in case the server timed out on compressing the zip file --- Zotlabs/Module/Attach.php | 32 ++++++++++++++++++++++++++++---- view/js/main.js | 10 ++++++++++ view/js/mod_cloud.js | 35 +++++++++++++++++++++++++++++++++-- 3 files changed, 71 insertions(+), 6 deletions(-) diff --git a/Zotlabs/Module/Attach.php b/Zotlabs/Module/Attach.php index 0bf7689be..cf78ac690 100644 --- a/Zotlabs/Module/Attach.php +++ b/Zotlabs/Module/Attach.php @@ -14,6 +14,7 @@ class Attach extends Controller { $attach_ids = ((x($_REQUEST, 'attach_ids')) ? $_REQUEST['attach_ids'] : []); $attach_path = ((x($_REQUEST, 'attach_path')) ? $_REQUEST['attach_path'] : ''); + $download_token = ((x($_REQUEST, 'download_token')) ? $_REQUEST['download_token'] : ''); $channel_id = ((x($_REQUEST, 'channel_id')) ? intval($_REQUEST['channel_id']) : 0); $channel = channelx_by_n($channel_id); @@ -52,6 +53,9 @@ class Attach extends Controller { ]; Verify::create('zip_token', 0, $token, json_encode($meta)); + Verify::create('download_token', 0, $download_token, $token); + + json_return_and_die([ 'success' => true, @@ -69,12 +73,32 @@ class Attach extends Controller { return; } - if(argv(1) === 'download') { + $token = ((x($_REQUEST, 'token')) ? $_REQUEST['token'] : ''); + $download_token = ((x($_REQUEST, 'download_token')) ? $_REQUEST['download_token'] : ''); - $token = ((x($_REQUEST, 'token')) ? $_REQUEST['token'] : ''); + if(argv(1) === 'check') { + $meta = Verify::get_meta('download_token', 0, $download_token); + + if(! $meta) + killme(); + + json_return_and_die([ + 'success' => true, + 'token' => $meta + ]); + } + + if(argv(1) === 'download') { $meta = Verify::get_meta('zip_token', 0, $token); + + if(! $meta) + killme(); + $meta = json_decode($meta, true); + // make sure we remove the download_token in case we have not checked yet + Verify::get_meta('download_token', 0, $download_token); + header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="'. $meta['zip_filename'] . '"'); header('Content-Length: ' . filesize($meta['zip_path'])); @@ -82,7 +106,7 @@ class Attach extends Controller { $istream = fopen($meta['zip_path'], 'rb'); $ostream = fopen('php://output', 'wb'); if($istream && $ostream) { - pipe_streams($istream,$ostream); + pipe_streams($istream, $ostream); fclose($istream); fclose($ostream); } @@ -123,7 +147,7 @@ class Attach extends Controller { $istream = fopen('store/' . $c[0]['channel_address'] . '/' . $fname,'rb'); $ostream = fopen('php://output','wb'); if($istream && $ostream) { - pipe_streams($istream,$ostream); + pipe_streams($istream, $ostream); fclose($istream); fclose($ostream); } diff --git a/view/js/main.js b/view/js/main.js index 7df705603..3e3fd057c 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1997,3 +1997,13 @@ function sse_fallback() { sse_handleNotifications(obj, false, false); }); } + +function makeid(length) { + var result = ''; + var characters = 'abcdef0123456789'; + var charactersLength = characters.length; + for ( var i = 0; i < length; i++ ) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)); + } + return result; +} diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js index aa9d308eb..aeaac8c69 100644 --- a/view/js/mod_cloud.js +++ b/view/js/mod_cloud.js @@ -70,8 +70,11 @@ $(document).ready(function () { $('body').css('cursor', 'wait'); $.jGrowl('Please stand by while your download is being prepared...', { sticky: false, theme: 'info', life: 10000 }); + var download_token = makeid(32); + let data = [ {name: 'attach_path', value: window.location.pathname}, + {name: 'download_token', value: download_token}, {name: 'channel_id', value: channelId}, {name: 'attach_ids[]', value: id} ] @@ -79,10 +82,22 @@ $(document).ready(function () { $.post('attach', data, function (data) { if (data.success) { $('body').css('cursor', 'auto'); - window.location.href = '/attach/download?token=' + data.token; + window.location.href = '/attach/download?token=' + data.token + '&download_token=' + download_token; + clearInterval(fallback); } }); + // fallback if server timed out + + var fallback = setInterval(function(){ $.get('/attach/check?download_token=' + download_token, function(data){ + if (data.success) { + $('body').css('cursor', 'auto'); + window.location.href = '/attach/download?token=' + data.token; + clearInterval(fallback); + } + + }); }, 30000); + }); $('.cloud-tool-delete-btn').on('click', function (e) { @@ -298,18 +313,34 @@ $(document).ready(function () { $('body').css('cursor', 'wait'); $.jGrowl('Please stand by while your download is being prepared...', { sticky: false, theme: 'info', life: 10000 }); + var download_token = makeid(32); + post_data.push( {name: 'attach_path', value: window.location.pathname}, + {name: 'download_token', value: download_token}, {name: 'channel_id', value: channelId}, ); $.post('attach', post_data, function (data) { if (data.success) { $('body').css('cursor', 'auto'); - window.location.href = '/attach/download?token=' + data.token; + window.location.href = '/attach/download?token=' + data.token + '&download_token=' + download_token; + clearInterval(fallback); } }); + // fallback if server timed out + + var fallback = setInterval(function(){ $.get('/attach/check?download_token=' + download_token, function(data){ + if (data.success) { + $('body').css('cursor', 'auto'); + window.location.href = '/attach/download?token=' + data.token; + clearInterval(fallback); + } + + }); }, 30000); + + }); $('#cloud-multi-tool-delete-btn').on('click', function (e) { -- cgit v1.2.3 From d5eeb948d51ac6619f89045984698d8d55bbb3f2 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 28 Dec 2020 13:19:40 +0000 Subject: sse: fix issue with direct message notificationss --- Zotlabs/Module/Sse_bs.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index 287c24829..534c63d46 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -162,7 +162,7 @@ class Sse_bs extends Controller { $item_normal = item_normal(); if ($notifications) { - $items = q("SELECT * FROM item + $items = q("SELECT * FROM item WHERE uid = %d AND created <= '%s' AND item_unseen = 1 AND item_wall = 0 AND item_private IN (0, 1) @@ -190,7 +190,7 @@ class Sse_bs extends Controller { } - $r = q("SELECT count(id) as total FROM item + $r = q("SELECT count(id) as total FROM item WHERE uid = %d and item_unseen = 1 AND item_wall = 0 AND item_private IN (0, 1) AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image') AND author_xchan != '%s' @@ -231,10 +231,10 @@ class Sse_bs extends Controller { $item_normal = item_normal(); if ($notifications) { - $items = q("SELECT * FROM item + $items = q("SELECT * FROM item WHERE uid = %d AND created <= '%s' - AND item_unseen = 1 AND item_wall = 0 AND item_private = 2 + AND item_unseen = 1 AND item_private = 2 AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image') AND author_xchan != '%s' $item_normal @@ -259,8 +259,8 @@ class Sse_bs extends Controller { } - $r = q("SELECT count(id) as total FROM item - WHERE uid = %d and item_unseen = 1 AND item_wall = 0 AND item_private = 2 + $r = q("SELECT count(id) as total FROM item + WHERE uid = %d and item_unseen = 1 AND item_private = 2 $item_normal $sql_extra AND author_xchan != '%s'", @@ -300,10 +300,10 @@ class Sse_bs extends Controller { $item_normal = item_normal(); if ($notifications) { - $items = q("SELECT * FROM item + $items = q("SELECT * FROM item WHERE uid = %d AND created <= '%s' - AND item_unseen = 1 AND item_wall = 1 + AND item_unseen = 1 AND item_wall = 1 AND item_private IN (0, 1) AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image') AND author_xchan != '%s' $item_normal @@ -328,8 +328,8 @@ class Sse_bs extends Controller { } - $r = q("SELECT count(id) as total FROM item - WHERE uid = %d and item_unseen = 1 AND item_wall = 1 + $r = q("SELECT count(id) as total FROM item + WHERE uid = %d and item_unseen = 1 AND item_wall = 1 AND item_private IN (0, 1) $item_normal $sql_extra AND author_xchan != '%s'", @@ -379,7 +379,7 @@ class Sse_bs extends Controller { $item_normal = item_normal(); if ($notifications) { - $items = q("SELECT * FROM item + $items = q("SELECT * FROM item WHERE uid = %d AND created <= '%s' AND item_unseen = 1 @@ -410,7 +410,7 @@ class Sse_bs extends Controller { } - $r = q("SELECT count(id) as total FROM item + $r = q("SELECT count(id) as total FROM item WHERE uid = %d AND item_unseen = 1 AND created > '%s' $item_normal @@ -516,7 +516,7 @@ class Sse_bs extends Controller { $p_str = ids_to_querystr($p, 'parent'); $p_sql = (($p_str) ? "OR parent IN ( $p_str )" : ''); - $r = q("select mid from item + $r = q("select mid from item where uid = %d and ( owner_xchan = '%s' OR author_xchan = '%s' $p_sql ) and item_unseen = 1 $sql_extra $item_normal", intval(self::$uid), dbesc($forums[$x]['xchan_hash']), @@ -577,7 +577,7 @@ class Sse_bs extends Controller { $item_normal = item_normal(); - $r = q("SELECT * FROM item + $r = q("SELECT * FROM item WHERE verb = '%s' AND obj_type IN ('Document', 'Video', 'Audio', 'Image') AND uid = %d -- cgit v1.2.3 From d889547b26bd203b552bb53e8931a5bec84a6918 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 29 Dec 2020 11:49:52 +0100 Subject: Deduplicate contacts list on autocomplete --- Zotlabs/Module/Acl.php | 53 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php index e0206bd43..4b79211a6 100644 --- a/Zotlabs/Module/Acl.php +++ b/Zotlabs/Module/Acl.php @@ -215,7 +215,7 @@ class Acl extends \Zotlabs\Web\Controller { // add connections - $r = q("SELECT abook_id as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, abook_their_perms, xchan_pubforum, abook_flags, abook_self + $r = q("SELECT abook_id as id, xchan_hash as hash, xchan_name as name, xchan_network as net, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, abook_their_perms, xchan_pubforum, abook_flags, abook_self FROM abook left join xchan on abook_xchan = xchan_hash WHERE (abook_channel = %d $extra_channels_sql) AND abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc" , intval(local_channel()) @@ -225,7 +225,7 @@ class Acl extends \Zotlabs\Web\Controller { } else { // Visitors - $r = q("SELECT xchan_hash as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags, 0 as abook_self + $r = q("SELECT xchan_hash as id, xchan_hash as hash, xchan_name as name, xchan_network as net, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags, 0 as abook_self FROM xchan left join xlink on xlink_link = xchan_hash WHERE xlink_xchan = '%s' AND xchan_deleted = 0 $sql_extra2_xchan order by $order_extra2 xchan_name asc" , dbesc(get_observer_hash()) @@ -241,7 +241,7 @@ class Acl extends \Zotlabs\Web\Controller { $known_hashes[] = "'".$rr['hash']."'"; $known_hashes_sql = 'AND xchan_hash not in ('.join(',',$known_hashes).')'; - $r2 = q("SELECT abook_id as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, abook_their_perms, abook_flags, abook_self + $r2 = q("SELECT abook_id as id, xchan_hash as hash, xchan_name as name, xchan_network as net, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, abook_their_perms, abook_flags, abook_self FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel IN ($extra_channels_sql) $known_hashes_sql AND abook_blocked = 0 and abook_pending = 0 and abook_hidden = 0 and xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc"); if($r2) @@ -269,7 +269,7 @@ class Acl extends \Zotlabs\Web\Controller { } } if((count($r) < 100) && $type == 'c') { - $r2 = q("SELECT substr(xchan_hash,1,18) as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags, 0 as abook_self + $r2 = q("SELECT substr(xchan_hash,1,18) as id, xchan_hash as hash, xchan_name as name, xchan_network as net, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags, 0 as abook_self FROM xchan WHERE xchan_deleted = 0 and not xchan_network in ('rss','anon','unknown') $sql_extra2_xchan order by $order_extra2 xchan_name asc" ); @@ -282,7 +282,7 @@ class Acl extends \Zotlabs\Web\Controller { elseif($type == 'm') { $r = array(); - $z = q("SELECT xchan_hash as hash, xchan_name as name, xchan_addr as nick, xchan_photo_s as micro, xchan_url as url + $z = q("SELECT xchan_hash as hash, xchan_name as name, xchan_network as net, xchan_addr as nick, xchan_photo_s as micro, xchan_url as url FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and xchan_deleted = 0 @@ -302,7 +302,7 @@ class Acl extends \Zotlabs\Web\Controller { } elseif($type == 'a') { - $r = q("SELECT abook_id as id, xchan_name as name, xchan_hash as hash, xchan_addr as nick, xchan_photo_s as micro, xchan_network as network, xchan_url as url, xchan_addr as attag , abook_their_perms FROM abook left join xchan on abook_xchan = xchan_hash + $r = q("SELECT abook_id as id, xchan_name as name, xchan_network as net, xchan_hash as hash, xchan_addr as nick, xchan_photo_s as micro, xchan_url as url, xchan_addr as attag , abook_their_perms FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and xchan_deleted = 0 $sql_extra3 @@ -336,9 +336,11 @@ class Acl extends \Zotlabs\Web\Controller { $r = array(); if($r) { + $i = count($contacts); + $x = []; foreach($r as $g) { - if(in_array($g['network'],['rss','anon','unknown']) && ($type != 'a')) + if(in_array($g['net'],['rss','anon','unknown']) && ($type != 'a')) continue; $g['hash'] = urlencode($g['hash']); @@ -347,14 +349,19 @@ class Acl extends \Zotlabs\Web\Controller { $g['nick'] = $g['url']; } + $clink = ($g['nick']) ? $g['nick'] : $g['url']; + $lkey = md5($clink); + if (! array_key_exists($lkey, $x)) + $x[$lkey] = $i; + if(in_array($g['hash'],$permitted) && $type === 'f' && (! $noforums)) { - $contacts[] = array( + $contacts[$i] = array( "type" => "c", "photo" => "images/twopeople.png", "name" => $g['name'], "id" => urlencode($g['id']), "xid" => $g['hash'], - "link" => (($g['nick']) ? $g['nick'] : $g['url']), + "link" => $clink, "nick" => substr($g['nick'],0,strpos($g['nick'],'@')), "self" => (intval($g['abook_self']) ? 'abook-self' : ''), "taggable" => 'taggable', @@ -362,19 +369,23 @@ class Acl extends \Zotlabs\Web\Controller { ); } if($type !== 'f') { - $contacts[] = array( - "type" => "c", - "photo" => $g['micro'], - "name" => $g['name'], - "id" => urlencode($g['id']), - "xid" => $g['hash'], - "link" => (($g['nick']) ? $g['nick'] : $g['url']), - "nick" => ((strpos($g['nick'],'@')) ? substr($g['nick'],0,strpos($g['nick'],'@')) : $g['nick']), - "self" => (intval($g['abook_self']) ? 'abook-self' : ''), - "taggable" => '', - "label" => '', - ); + if (! array_key_exists($x[$lkey], $contacts) || ($contacts[$x[$lkey]]['net'] !== 'zot6' && ($g['net'] == 'zot6' || $g['net'] == 'zot'))) { + $contacts[$x[$lkey]] = array( + "type" => "c", + "photo" => $g['micro'], + "name" => $g['name'], + "id" => urlencode($g['id']), + "xid" => $g['hash'], + "link" => $clink, + "nick" => ((strpos($g['nick'],'@')) ? substr($g['nick'],0,strpos($g['nick'],'@')) : $g['nick']), + "self" => (intval($g['abook_self']) ? 'abook-self' : ''), + "taggable" => '', + "label" => '', + "net" => $g['net'] + ); + } } + $i++; } } -- cgit v1.2.3 From c063fe07205bb22401d2a2c29a1829e17e5b7a66 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 29 Dec 2020 15:50:32 +0100 Subject: Revert "Fix sync item with Zot connections" This reverts commit 3db4aa69440553788d8f46cf4bbfb38ca4f09130 --- Zotlabs/Module/Item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 9a120dac1..f74b1e321 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -1337,7 +1337,7 @@ class Item extends Controller { killme(); } - if(($parent == $post_id) || ($datarray['item_private'] == 1)) { + if($parent || $datarray['item_private'] == 1) { $r = q("select * from item where id = %d", intval($post_id) ); -- cgit v1.2.3 From 5485f96625d03dab1f8f9e9fdf3f6ea5180509c9 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 29 Dec 2020 20:36:41 +0100 Subject: dirserach: return zot6 entries --- Zotlabs/Module/Dirsearch.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Dirsearch.php b/Zotlabs/Module/Dirsearch.php index c15b13a90..804d7af5c 100644 --- a/Zotlabs/Module/Dirsearch.php +++ b/Zotlabs/Module/Dirsearch.php @@ -192,7 +192,7 @@ class Dirsearch extends Controller { else { $qlimit = " LIMIT " . intval($perpage) . " OFFSET " . intval($startrec); if($return_total) { - $r = q("SELECT COUNT(xchan_hash) AS total FROM xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and xchan_network = 'zot' and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0 $safesql "); + $r = q("SELECT COUNT(xchan_hash) AS total FROM xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and xchan_network = 'zot6' and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0 $safesql "); if($r) { $ret['total_items'] = $r[0]['total']; } @@ -261,7 +261,7 @@ class Dirsearch extends Controller { else { $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash - where ( $logic $sql_extra ) $hub_query and xchan_network = 'zot' and xchan_system = 0 and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0 + where ( $logic $sql_extra ) $hub_query and xchan_network = 'zot6' and xchan_system = 0 and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0 $safesql $order $qlimit " ); -- cgit v1.2.3 From 5cefdbf98519ef6cb5dbd397e19ff9d0d79258d3 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 29 Dec 2020 20:37:23 +0100 Subject: random_profile: return zot6 entries --- include/connections.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/connections.php b/include/connections.php index 100e595d0..bd41e112e 100644 --- a/include/connections.php +++ b/include/connections.php @@ -472,7 +472,7 @@ function random_profile() { $r = q("select xchan_url, xchan_hash from xchan left join hubloc on hubloc_hash = xchan_hash where xchan_hidden = 0 and xchan_system = 0 and - xchan_network = 'zot' and xchan_deleted = 0 and + xchan_network = 'zot6' and xchan_deleted = 0 and hubloc_connected > %s - interval %s order by $randfunc limit 1", db_utcnow(), db_quoteinterval('30 day') -- cgit v1.2.3 From 11d61a744dcdbc47cdbad2122ca1e5417b8d6235 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 29 Dec 2020 20:16:23 +0000 Subject: escape both single and double quotes for the notifications title. fixes issue #1503 --- Zotlabs/Lib/Enotify.php | 66 ++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index c78325ee3..3a24cd349 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -64,7 +64,7 @@ class Enotify { $sitename = get_config('system','sitename'); $site_admin = sprintf( t('%s Administrator'), $sitename); $opt_out1 = sprintf( t('This email was sent by %1$s at %2$s.'), t('$Projectname'), \App::get_hostname()); - $opt_out2 = sprintf( t('To stop receiving these messages, please adjust your Notification Settings at %s'), z_root() . '/settings'); + $opt_out2 = sprintf( t('To stop receiving these messages, please adjust your Notification Settings at %s'), z_root() . '/settings'); $hopt_out2 = sprintf( t('To stop receiving these messages, please adjust your %s.'), '' . t('Notification Settings') . ''); $sender_name = $product; $hostname = \App::get_hostname(); @@ -80,7 +80,7 @@ class Enotify { $sender_email = get_config('system','from_email'); if(! $sender_email) $sender_email = 'Administrator' . '@' . $hostname; - + $sender_name = get_config('system','from_email_name'); if(! $sender_name) $sender_name = \Zotlabs\Lib\System::get_site_name(); @@ -108,7 +108,7 @@ class Enotify { logger('notification invoked for an old item which may have been refetched.',LOGGER_DEBUG,LOG_INFO); return; } - } + } else { $title = $body = ''; } @@ -181,7 +181,7 @@ class Enotify { pop_lang(); return; } - + // if it's a post figure out who's post it is. @@ -219,7 +219,7 @@ class Enotify { $itemlink, $p[0]['author']['xchan_name'], $item_post_type); - + // "your post" if($p[0]['owner']['xchan_name'] == $p[0]['author']['xchan_name'] && intval($p[0]['item_wall'])) $dest_str = sprintf(t('%1$s %2$s [zrl=%3$s]your %4$s[/zrl]'), @@ -230,15 +230,15 @@ class Enotify { // Some mail softwares relies on subject field for threading. // So, we cannot have different subjects for notifications of the same thread. - // Before this we have the name of the replier on the subject rendering + // Before this we have the name of the replier on the subject rendering // differents subjects for messages on the same thread. if($moderated) $subject = sprintf( t('[$Projectname:Notify] Moderated Comment to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']); else $subject = sprintf( t('[$Projectname:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']); - $preamble = sprintf( t('%1$s commented on an item/conversation you have been following.'), $sender['xchan_name']); - $epreamble = $dest_str; + $preamble = sprintf( t('%1$s commented on an item/conversation you have been following.'), $sender['xchan_name']); + $epreamble = $dest_str; $sitelink = t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf( $sitelink, $siteurl ); @@ -247,7 +247,7 @@ class Enotify { $tsitelink .= "\n\n" . sprintf( t('Please visit %s to approve or reject this comment.'), z_root() . '/moderate' ); $hsitelink .= "

" . sprintf( t('Please visit %s to approve or reject this comment.'), '' . z_root() . '/moderate' ); } - + } if ($params['type'] == NOTIFY_LIKE) { @@ -278,7 +278,7 @@ class Enotify { pop_lang(); return; } - + // if it's a post figure out who's post it is. @@ -314,12 +314,12 @@ class Enotify { // Some mail softwares relies on subject field for threading. // So, we cannot have different subjects for notifications of the same thread. - // Before this we have the name of the replier on the subject rendering + // Before this we have the name of the replier on the subject rendering // differents subjects for messages on the same thread. $subject = sprintf( t('[$Projectname:Notify] Like received to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']); - $preamble = sprintf( t('%1$s liked an item/conversation you created.'), $sender['xchan_name']); - $epreamble = $dest_str; + $preamble = sprintf( t('%1$s liked an item/conversation you created.'), $sender['xchan_name']); + $epreamble = $dest_str; $sitelink = t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf( $sitelink, $siteurl ); @@ -335,7 +335,7 @@ class Enotify { $epreamble = sprintf( t('%1$s posted to [zrl=%2$s]your wall[/zrl]') , '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', - $params['link']); + $params['link']); $sitelink = t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf( $sitelink, $siteurl ); @@ -355,12 +355,12 @@ class Enotify { pop_lang(); return; } - + $subject = sprintf( t('[$Projectname:Notify] %s tagged you') , $sender['xchan_name']); $preamble = sprintf( t('%1$s tagged you at %2$s') , $sender['xchan_name'], $sitename); $epreamble = sprintf( t('%1$s [zrl=%2$s]tagged you[/zrl].') , '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', - $params['link']); + $params['link']); $sitelink = t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf( $sitelink, $siteurl ); @@ -373,7 +373,7 @@ class Enotify { $preamble = sprintf( t('%1$s poked you at %2$s') , $sender['xchan_name'], $sitename); $epreamble = sprintf( t('%1$s [zrl=%2$s]poked you[/zrl].') , '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', - $params['link']); + $params['link']); $subject = str_replace('poked', t($params['activity']), $subject); $preamble = str_replace('poked', t($params['activity']), $preamble); @@ -390,7 +390,7 @@ class Enotify { $preamble = sprintf( t('%1$s tagged your post at %2$s'),$sender['xchan_name'], $sitename); $epreamble = sprintf( t('%1$s tagged [zrl=%2$s]your post[/zrl]') , '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', - $itemlink); + $itemlink); $sitelink = t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf( $sitelink, $siteurl ); @@ -400,10 +400,10 @@ class Enotify { if ($params['type'] == NOTIFY_INTRO) { $subject = sprintf( t('[$Projectname:Notify] Introduction received')); - $preamble = sprintf( t('You\'ve received an new connection request from \'%1$s\' at %2$s'), $sender['xchan_name'], $sitename); + $preamble = sprintf( t('You\'ve received an new connection request from \'%1$s\' at %2$s'), $sender['xchan_name'], $sitename); $epreamble = sprintf( t('You\'ve received [zrl=%1$s]a new connection request[/zrl] from %2$s.'), $siteurl . '/connections/ifpending', - '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]'); + '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]'); $body = sprintf( t('You may visit their profile at %s'),$sender['xchan_url']); $sitelink = t('Please visit %s to approve or reject the connection request.'); @@ -414,11 +414,11 @@ class Enotify { if ($params['type'] == NOTIFY_SUGGEST) { $subject = sprintf( t('[$Projectname:Notify] Friend suggestion received')); - $preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $sender['xchan_name'], $sitename); + $preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $sender['xchan_name'], $sitename); $epreamble = sprintf( t('You\'ve received [zrl=%1$s]a friend suggestion[/zrl] for %2$s from %3$s.'), $itemlink, '[zrl=' . $params['item']['url'] . ']' . $params['item']['name'] . '[/zrl]', - '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]'); + '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]'); $body = t('Name:') . ' ' . $params['item']['name'] . "\n"; $body .= t('Photo:') . ' ' . $params['item']['photo'] . "\n"; @@ -462,7 +462,7 @@ class Enotify { $sitelink = $h['sitelink']; $tsitelink = $h['tsitelink']; $hsitelink = $h['hsitelink']; - $itemlink = $h['itemlink']; + $itemlink = $h['itemlink']; require_once('include/html2bbcode.php'); @@ -510,7 +510,7 @@ class Enotify { // Mark some notifications as seen right away // Note! The notification have to be created, because they are used to send emails // So easiest solution to hide them from Notices is to mark them as seen right away. - // Another option would be to not add them to the DB, and change how emails are handled + // Another option would be to not add them to the DB, and change how emails are handled // (probably would be better that way) if (!$always_show_in_notices) { @@ -555,7 +555,7 @@ class Enotify { // wretched hack, but we don't want to duplicate all the preamble variations and we also don't want to screw up a translation if ((\App::$language === 'en' || (! \App::$language)) && strpos($msg,', ')) - $msg = substr($msg,strpos($msg,', ')+1); + $msg = substr($msg,strpos($msg,', ')+1); $datarray['id'] = $notify_id; $datarray['msg'] = $msg; @@ -587,12 +587,12 @@ class Enotify { $htmlversion = bbcode(stripslashes(str_replace(array("\\r","\\n"), array("","
\n"),$body))); - // use $_SESSION['zid_override'] to force zid() to use + // use $_SESSION['zid_override'] to force zid() to use // the recipient address instead of the current observer $_SESSION['zid_override'] = channel_reddress($recip); $_SESSION['zrl_override'] = z_root() . '/channel/' . $recip['channel_address']; - + $textversion = zidify_links($textversion); $htmlversion = zidify_links($htmlversion); @@ -754,7 +754,7 @@ class Enotify { return $params['result']; } - $fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8'); + $fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8'); $messageSubject = email_header_encode(html_entity_decode($params['messageSubject'],ENT_QUOTES,'UTF-8'),'UTF-8'); // generate a mime boundary @@ -767,8 +767,8 @@ class Enotify { $messageHeader = $params['additionalMailHeader'] . "From: $fromName <{$params['fromEmail']}>" . PHP_EOL . - "Reply-To: $fromName <{$params['replyTo']}>" . PHP_EOL . - "MIME-Version: 1.0" . PHP_EOL . + "Reply-To: $fromName <{$params['replyTo']}>" . PHP_EOL . + "MIME-Version: 1.0" . PHP_EOL . "Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\""; // assemble the final multipart message body with the text and html types included @@ -782,7 +782,7 @@ class Enotify { $textBody . PHP_EOL . "--" . $mimeBoundary . PHP_EOL . // text/html section "Content-Type: text/html; charset=UTF-8" . PHP_EOL . - "Content-Transfer-Encoding: base64" . PHP_EOL . PHP_EOL . + "Content-Transfer-Encoding: base64" . PHP_EOL . PHP_EOL . $htmlBody . PHP_EOL . "--" . $mimeBoundary . "--" . PHP_EOL; // message ending @@ -803,7 +803,7 @@ class Enotify { require_once('include/conversation.php'); - // Call localize_item to get a one line status for activities. + // Call localize_item to get a one line status for activities. // This should set $item['localized'] to indicate we have a brief summary. // and perhaps $item['shortlocalized'] for an even briefer summary @@ -860,7 +860,7 @@ class Enotify { //'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), 'thread_top' => (($item['item_thread_top']) ? true : false), 'message' => bbcode(escape_tags($itemem_text)), - 'body' => htmlentities(html2plain(bbcode($item['body']), 75, true), ENT_COMPAT, 'UTF-8', false), + 'body' => htmlentities(html2plain(bbcode($item['body']), 75, true), ENT_QUOTES, 'UTF-8', false), // these are for the superblock addon 'hash' => $item[$who]['xchan_hash'], 'uid' => $item['uid'], -- cgit v1.2.3 From 2c4fabba35267a590a86e5a173243dbf82be3606 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 30 Dec 2020 14:12:08 +0000 Subject: store zip files without compression --- Zotlabs/Module/Attach.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Attach.php b/Zotlabs/Module/Attach.php index cf78ac690..f70366448 100644 --- a/Zotlabs/Module/Attach.php +++ b/Zotlabs/Module/Attach.php @@ -55,8 +55,6 @@ class Attach extends Controller { Verify::create('zip_token', 0, $token, json_encode($meta)); Verify::create('download_token', 0, $download_token, $token); - - json_return_and_die([ 'success' => true, 'token' => $token @@ -196,6 +194,8 @@ class Attach extends Controller { else { $file_path = $r['data']['content']; $zip->addFile($file_path, $zip_path); + // compressing can be ressource intensive - just store the data + $zip->setCompressionName($zip_path, ZipArchive::CM_STORE); } } -- cgit v1.2.3 From 8db367c74353f2b86d0effeebfe84c7cc4f512ab Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 30 Dec 2020 14:30:39 +0000 Subject: remove fallback code - it will not be required if compression is dismissed --- Zotlabs/Module/Attach.php | 19 ------------------- view/js/mod_cloud.js | 37 +++---------------------------------- 2 files changed, 3 insertions(+), 53 deletions(-) diff --git a/Zotlabs/Module/Attach.php b/Zotlabs/Module/Attach.php index f70366448..172f6a4bc 100644 --- a/Zotlabs/Module/Attach.php +++ b/Zotlabs/Module/Attach.php @@ -14,8 +14,6 @@ class Attach extends Controller { $attach_ids = ((x($_REQUEST, 'attach_ids')) ? $_REQUEST['attach_ids'] : []); $attach_path = ((x($_REQUEST, 'attach_path')) ? $_REQUEST['attach_path'] : ''); - $download_token = ((x($_REQUEST, 'download_token')) ? $_REQUEST['download_token'] : ''); - $channel_id = ((x($_REQUEST, 'channel_id')) ? intval($_REQUEST['channel_id']) : 0); $channel = channelx_by_n($channel_id); @@ -53,7 +51,6 @@ class Attach extends Controller { ]; Verify::create('zip_token', 0, $token, json_encode($meta)); - Verify::create('download_token', 0, $download_token, $token); json_return_and_die([ 'success' => true, @@ -72,19 +69,6 @@ class Attach extends Controller { } $token = ((x($_REQUEST, 'token')) ? $_REQUEST['token'] : ''); - $download_token = ((x($_REQUEST, 'download_token')) ? $_REQUEST['download_token'] : ''); - - if(argv(1) === 'check') { - $meta = Verify::get_meta('download_token', 0, $download_token); - - if(! $meta) - killme(); - - json_return_and_die([ - 'success' => true, - 'token' => $meta - ]); - } if(argv(1) === 'download') { $meta = Verify::get_meta('zip_token', 0, $token); @@ -94,9 +78,6 @@ class Attach extends Controller { $meta = json_decode($meta, true); - // make sure we remove the download_token in case we have not checked yet - Verify::get_meta('download_token', 0, $download_token); - header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="'. $meta['zip_filename'] . '"'); header('Content-Length: ' . filesize($meta['zip_path'])); diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js index aeaac8c69..8fb66c5aa 100644 --- a/view/js/mod_cloud.js +++ b/view/js/mod_cloud.js @@ -70,33 +70,18 @@ $(document).ready(function () { $('body').css('cursor', 'wait'); $.jGrowl('Please stand by while your download is being prepared...', { sticky: false, theme: 'info', life: 10000 }); - var download_token = makeid(32); - let data = [ {name: 'attach_path', value: window.location.pathname}, - {name: 'download_token', value: download_token}, {name: 'channel_id', value: channelId}, {name: 'attach_ids[]', value: id} ] $.post('attach', data, function (data) { - if (data.success) { - $('body').css('cursor', 'auto'); - window.location.href = '/attach/download?token=' + data.token + '&download_token=' + download_token; - clearInterval(fallback); - } - }); - - // fallback if server timed out - - var fallback = setInterval(function(){ $.get('/attach/check?download_token=' + download_token, function(data){ if (data.success) { $('body').css('cursor', 'auto'); window.location.href = '/attach/download?token=' + data.token; - clearInterval(fallback); } - - }); }, 30000); + }); }); @@ -313,33 +298,17 @@ $(document).ready(function () { $('body').css('cursor', 'wait'); $.jGrowl('Please stand by while your download is being prepared...', { sticky: false, theme: 'info', life: 10000 }); - var download_token = makeid(32); - post_data.push( {name: 'attach_path', value: window.location.pathname}, - {name: 'download_token', value: download_token}, - {name: 'channel_id', value: channelId}, + {name: 'channel_id', value: channelId} ); $.post('attach', post_data, function (data) { - if (data.success) { - $('body').css('cursor', 'auto'); - window.location.href = '/attach/download?token=' + data.token + '&download_token=' + download_token; - clearInterval(fallback); - } - }); - - // fallback if server timed out - - var fallback = setInterval(function(){ $.get('/attach/check?download_token=' + download_token, function(data){ if (data.success) { $('body').css('cursor', 'auto'); window.location.href = '/attach/download?token=' + data.token; - clearInterval(fallback); } - - }); }, 30000); - + }); }); -- cgit v1.2.3 From 817e72846e2d2fe4e331262c91f51057e44f6c0a Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 30 Dec 2020 14:55:00 +0000 Subject: changelog --- CHANGELOG | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index f68251aa8..629d8b44c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,16 @@ +Hubzilla 5.0.8 (2020-12-30) + - Fix single quotes not escaped in the notifications title (issue 1503) + - Return zot6 xchans for random_profile() + - Return zot6 entries in dirsearch + - Fix comment sync issue + - Fix duplicate entries in contact autocomplete + - Fix issue where direct message notifications where not displayed for wall items + - Do not revalidate cached photos + - Implement imagemagic resource consumption limiting + - Specify key in mod owa + - Fix issue where array was passed to get_key() + + Hubzilla 5.0.7 (2020-12-21) - Fix CardDAV addressbook ID - Use Zot6 for CardDAV and CalDAV sync between clones -- cgit v1.2.3 From efc8ed484504e2e01a8bc9dc8c720144995be210 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 2 Jan 2021 11:20:03 +0000 Subject: make share title h3 --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/items.php b/include/items.php index 2426c189f..18f4e6f02 100755 --- a/include/items.php +++ b/include/items.php @@ -3263,7 +3263,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false "' message_id='" . $item['mid'] . "']"; if($item['title']) - $bb .= '[b]'.$item['title'].'[/b]'."\r\n"; + $bb .= '[h3][b]'.$item['title'].'[/b][/h3]'."\r\n"; $bb .= $item['body']; $bb .= "[/share]"; } -- cgit v1.2.3 From 98f3e4cbd39dca3c111a711b0aaaa53428eb14a6 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 2 Jan 2021 18:53:23 +0000 Subject: set is_owner does not need to be a per item flag. fix post button visible for collections --- Zotlabs/Storage/Browser.php | 3 ++- view/tpl/cloud_directory.tpl | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index 7b20e9ddb..b71032080 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -264,7 +264,6 @@ class Browser extends DAV\Browser\Plugin { $ft['attach_id'] = $id; $ft['icon'] = $icon; $ft['photo_icon'] = $photo_icon; - $ft['is_owner'] = $is_owner; $ft['is_creator'] = $is_creator; $ft['rel_path'] = (($data) ? '/cloud/' . $nick .'/' . $data['display_path'] : $href); $ft['full_path'] = z_root() . (($data) ? '/cloud/' . $nick .'/' . $data['display_path'] : $href); @@ -392,6 +391,8 @@ class Browser extends DAV\Browser\Plugin { '$deny_cid' => acl2json($channel_acl['deny_cid']), '$deny_gid' => acl2json($channel_acl['deny_gid']) + '$is_owner' = $is_owner; + )); diff --git a/view/tpl/cloud_directory.tpl b/view/tpl/cloud_directory.tpl index 5886391bb..84c9f2e86 100644 --- a/view/tpl/cloud_directory.tpl +++ b/view/tpl/cloud_directory.tpl @@ -35,8 +35,8 @@ {{$item.name}} - {{if $item.is_owner}} - {{* add file tools here*}} + {{if $is_owner}} + {{* add file tools here *}} {{/if}} {{/foreach}} @@ -160,25 +160,25 @@ {{/if}} - {{if ($item.is_owner || $item.is_creator) && $item.attach_id}} + {{if ($is_owner || $item.is_creator) && $item.attach_id}}