From 3b9aedec5f8445d723e41835ccba6d0add8068c8 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 5 Nov 2018 19:52:30 -0800 Subject: populate new fields --- include/channel.php | 57 ++++++++++++++++++++++++++++++++++++++--------------- include/xchan.php | 6 ++++++ 2 files changed, 47 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index 22cdb9fe7..030efffb9 100644 --- a/include/channel.php +++ b/include/channel.php @@ -10,6 +10,7 @@ use Zotlabs\Access\Permissions; use Zotlabs\Daemon\Master; use Zotlabs\Lib\System; use Zotlabs\Render\Comanche; +use Zotlabs\Lib\Zotlib; require_once('include/zot.php'); require_once('include/crypto.php'); @@ -232,6 +233,7 @@ function create_identity($arr) { $sig = base64url_encode(rsa_sign($guid,$key['prvkey'])); $hash = make_xchan_hash($guid,$sig); + $zhash = Zotlib::make_xchan_hash($guid,$key['pubkey']); // Force a few things on the short term until we can provide a theme or app with choice @@ -265,6 +267,7 @@ function create_identity($arr) { 'channel_guid' => $guid, 'channel_guid_sig' => $sig, 'channel_hash' => $hash, + 'channel_portable_id' => $zhash, 'channel_prvkey' => $key['prvkey'], 'channel_pubkey' => $key['pubkey'], 'channel_pageflags' => intval($pageflags), @@ -345,27 +348,48 @@ function create_identity($arr) { if(! $r) logger('Unable to store hub location'); + $r = hubloc_store_lowlevel( + [ + 'hubloc_guid' => $guid, + 'hubloc_guid_sig' => 'sha256.' . $sig, + 'hubloc_hash' => $zhash, + 'hubloc_addr' => channel_reddress($ret['channel']), + 'hubloc_primary' => intval($primary), + 'hubloc_url' => z_root(), + 'hubloc_url_sig' => 'sha256.' . base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey'])), + 'hubloc_host' => App::get_hostname(), + 'hubloc_callback' => z_root() . '/zot', + 'hubloc_sitekey' => get_config('system','pubkey'), + 'hubloc_network' => 'zot6', + 'hubloc_updated' => datetime_convert() + ] + ); + if(! $r) + logger('Unable to store hub location'); + + $newuid = $ret['channel']['channel_id']; $r = xchan_store_lowlevel( [ - 'xchan_hash' => $hash, - 'xchan_guid' => $guid, - 'xchan_guid_sig' => $sig, - 'xchan_pubkey' => $key['pubkey'], + 'xchan_hash' => $hash, + 'xchan_portable_id' => $zhash, + 'xchan_guid' => $guid, + 'xchan_guid_sig' => $sig, + 'xchan_pubkey' => $key['pubkey'], 'xchan_photo_mimetype' => (($photo_type) ? $photo_type : 'image/png'), - 'xchan_photo_l' => z_root() . "/photo/profile/l/{$newuid}", - 'xchan_photo_m' => z_root() . "/photo/profile/m/{$newuid}", - 'xchan_photo_s' => z_root() . "/photo/profile/s/{$newuid}", - 'xchan_addr' => channel_reddress($ret['channel']), - 'xchan_url' => z_root() . '/channel/' . $ret['channel']['channel_address'], - 'xchan_follow' => z_root() . '/follow?f=&url=%s', - 'xchan_connurl' => z_root() . '/poco/' . $ret['channel']['channel_address'], - 'xchan_name' => $ret['channel']['channel_name'], - 'xchan_network' => 'zot', - 'xchan_photo_date' => datetime_convert(), - 'xchan_name_date' => datetime_convert(), - 'xchan_system' => $system + 'xchan_photo_l' => z_root() . "/photo/profile/l/{$newuid}", + 'xchan_photo_m' => z_root() . "/photo/profile/m/{$newuid}", + 'xchan_photo_s' => z_root() . "/photo/profile/s/{$newuid}", + 'xchan_addr' => channel_reddress($ret['channel']), + 'xchan_url' => z_root() . '/channel/' . $ret['channel']['channel_address'], + 'xchan_follow' => z_root() . '/follow?f=&url=%s', + 'xchan_connurl' => z_root() . '/poco/' . $ret['channel']['channel_address'], + 'xchan_name' => $ret['channel']['channel_name'], + 'xchan_network' => 'zot', + 'xchan_photo_date' => datetime_convert(), + 'xchan_name_date' => datetime_convert(), + 'xchan_system' => $system ] ); @@ -2355,6 +2379,7 @@ function channel_store_lowlevel($arr) { 'channel_guid' => ((array_key_exists('channel_guid',$arr)) ? $arr['channel_guid'] : ''), 'channel_guid_sig' => ((array_key_exists('channel_guid_sig',$arr)) ? $arr['channel_guid_sig'] : ''), 'channel_hash' => ((array_key_exists('channel_hash',$arr)) ? $arr['channel_hash'] : ''), + 'channel_portable_id' => ((array_key_exists('channel_portable_id',$arr)) ? $arr['channel_portable_id'] : ''), 'channel_timezone' => ((array_key_exists('channel_timezone',$arr)) ? $arr['channel_timezone'] : 'UTC'), 'channel_location' => ((array_key_exists('channel_location',$arr)) ? $arr['channel_location'] : ''), 'channel_theme' => ((array_key_exists('channel_theme',$arr)) ? $arr['channel_theme'] : ''), diff --git a/include/xchan.php b/include/xchan.php index eb5f1b4a3..5516d046f 100644 --- a/include/xchan.php +++ b/include/xchan.php @@ -5,8 +5,14 @@ use Zotlabs\Zot6\HTTPSig; function xchan_store_lowlevel($arr) { + if(! $arr['xchan_hash']) { + logger('No xchan_hash'); + return false; + } + $store = [ 'xchan_hash' => ((array_key_exists('xchan_hash',$arr)) ? $arr['xchan_hash'] : ''), + 'xchan_portable_id' => ((array_key_exists('xchan_portable_id',$arr)) ? $arr['xchan_portable_id'] : ''), 'xchan_guid' => ((array_key_exists('xchan_guid',$arr)) ? $arr['xchan_guid'] : ''), 'xchan_guid_sig' => ((array_key_exists('xchan_guid_sig',$arr)) ? $arr['xchan_guid_sig'] : ''), 'xchan_pubkey' => ((array_key_exists('xchan_pubkey',$arr)) ? $arr['xchan_pubkey'] : ''), -- cgit v1.2.3 From bb8b3b92913832750a393533f491725b4330a8e1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 6 Nov 2018 20:44:40 -0800 Subject: this is brutal --- include/channel.php | 31 ++++++++++++++++++++++++++++--- include/xchan.php | 1 - 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index 030efffb9..1e5570f6b 100644 --- a/include/channel.php +++ b/include/channel.php @@ -10,7 +10,7 @@ use Zotlabs\Access\Permissions; use Zotlabs\Daemon\Master; use Zotlabs\Lib\System; use Zotlabs\Render\Comanche; -use Zotlabs\Lib\Zotlib; +use Zotlabs\Lib\Libzot; require_once('include/zot.php'); require_once('include/crypto.php'); @@ -233,7 +233,7 @@ function create_identity($arr) { $sig = base64url_encode(rsa_sign($guid,$key['prvkey'])); $hash = make_xchan_hash($guid,$sig); - $zhash = Zotlib::make_xchan_hash($guid,$key['pubkey']); + $zhash = Libzot::make_xchan_hash($guid,$key['pubkey']); // Force a few things on the short term until we can provide a theme or app with choice @@ -353,10 +353,12 @@ function create_identity($arr) { 'hubloc_guid' => $guid, 'hubloc_guid_sig' => 'sha256.' . $sig, 'hubloc_hash' => $zhash, + 'hubloc_id_url' => channel_url($ret['channel']), 'hubloc_addr' => channel_reddress($ret['channel']), 'hubloc_primary' => intval($primary), 'hubloc_url' => z_root(), 'hubloc_url_sig' => 'sha256.' . base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey'])), + 'hubloc_site_id' => Libzot::make_xchan_hash(z_root(),get_config('system','pubkey')), 'hubloc_host' => App::get_hostname(), 'hubloc_callback' => z_root() . '/zot', 'hubloc_sitekey' => get_config('system','pubkey'), @@ -373,7 +375,6 @@ function create_identity($arr) { $r = xchan_store_lowlevel( [ 'xchan_hash' => $hash, - 'xchan_portable_id' => $zhash, 'xchan_guid' => $guid, 'xchan_guid_sig' => $sig, 'xchan_pubkey' => $key['pubkey'], @@ -393,6 +394,30 @@ function create_identity($arr) { ] ); + $r = xchan_store_lowlevel( + [ + 'xchan_hash' => $zhash, + 'xchan_guid' => $guid, + 'xchan_guid_sig' => 'sha256.' . $sig, + 'xchan_pubkey' => $key['pubkey'], + 'xchan_photo_mimetype' => (($photo_type) ? $photo_type : 'image/png'), + 'xchan_photo_l' => z_root() . "/photo/profile/l/{$newuid}", + 'xchan_photo_m' => z_root() . "/photo/profile/m/{$newuid}", + 'xchan_photo_s' => z_root() . "/photo/profile/s/{$newuid}", + 'xchan_addr' => channel_reddress($ret['channel']), + 'xchan_url' => z_root() . '/channel/' . $ret['channel']['channel_address'], + 'xchan_follow' => z_root() . '/follow?f=&url=%s', + 'xchan_connurl' => z_root() . '/poco/' . $ret['channel']['channel_address'], + 'xchan_name' => $ret['channel']['channel_name'], + 'xchan_network' => 'zot6', + 'xchan_photo_date' => datetime_convert(), + 'xchan_name_date' => datetime_convert(), + 'xchan_system' => $system + ] + ); + + + // Not checking return value. // It's ok for this to fail if it's an imported channel, and therefore the hash is a duplicate diff --git a/include/xchan.php b/include/xchan.php index 5516d046f..4cbfb42c5 100644 --- a/include/xchan.php +++ b/include/xchan.php @@ -12,7 +12,6 @@ function xchan_store_lowlevel($arr) { $store = [ 'xchan_hash' => ((array_key_exists('xchan_hash',$arr)) ? $arr['xchan_hash'] : ''), - 'xchan_portable_id' => ((array_key_exists('xchan_portable_id',$arr)) ? $arr['xchan_portable_id'] : ''), 'xchan_guid' => ((array_key_exists('xchan_guid',$arr)) ? $arr['xchan_guid'] : ''), 'xchan_guid_sig' => ((array_key_exists('xchan_guid_sig',$arr)) ? $arr['xchan_guid_sig'] : ''), 'xchan_pubkey' => ((array_key_exists('xchan_pubkey',$arr)) ? $arr['xchan_pubkey'] : ''), -- cgit v1.2.3 From a5483a03c90967eea58f5a0db17c59c4ec3ff2ff Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 6 Nov 2018 21:44:57 -0800 Subject: fix signatures --- include/network.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/network.php b/include/network.php index f976dcc35..d37da05f7 100644 --- a/include/network.php +++ b/include/network.php @@ -233,7 +233,7 @@ function z_post_url($url, $params, $redirects = 0, $opts = array()) { return $ret; if(! array_key_exists('request_target',$opts)) { - $opts['request_target'] = 'get ' . get_request_string($url); + $opts['request_target'] = 'post ' . get_request_string($url); } @curl_setopt($ch, CURLOPT_HEADER, true); -- cgit v1.2.3 From d56e1f6285fd2e4cc7b2f9cd88df88a26c5d2ad7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 8 Nov 2018 19:49:57 -0800 Subject: begin native summary support --- include/items.php | 15 +++++++++++++-- include/text.php | 23 +++++++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index cae380b01..24f1be84f 100755 --- a/include/items.php +++ b/include/items.php @@ -597,6 +597,7 @@ function get_item_elements($x,$allow_code = false) { $arr = array(); $arr['body'] = $x['body']; + $arr['summary'] = $x['summary']; $maxlen = get_max_import_size(); @@ -605,6 +606,11 @@ function get_item_elements($x,$allow_code = false) { logger('get_item_elements: message length exceeds max_import_size: truncated'); } + if($maxlen && mb_strlen($arr['summary']) > $maxlen) { + $arr['summary'] = mb_substr($arr['summary'],0,$maxlen,'UTF-8'); + logger('get_item_elements: message summary length exceeds max_import_size: truncated'); + } + $arr['created'] = datetime_convert('UTC','UTC',$x['created']); $arr['edited'] = datetime_convert('UTC','UTC',$x['edited']); @@ -749,9 +755,10 @@ function get_item_elements($x,$allow_code = false) { // Do this after signature checking as the original signature // was generated on the escaped content. - if($arr['mimetype'] === 'text/markdown') + if($arr['mimetype'] === 'text/markdown') { + $arr['summary'] = MarkdownSoap::unescape($arr['summary']); $arr['body'] = MarkdownSoap::unescape($arr['body']); - + } if(array_key_exists('revision',$x)) { // extended export encoding @@ -1073,6 +1080,7 @@ function encode_item($item,$mirror = false) { $x['commented'] = $item['commented']; $x['mimetype'] = $item['mimetype']; $x['title'] = $item['title']; + $x['summary'] = $item['summary']; $x['body'] = $item['body']; $x['app'] = $item['app']; $x['verb'] = $item['verb']; @@ -1631,6 +1639,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { } $arr['title'] = ((array_key_exists('title',$arr) && strlen($arr['title'])) ? trim($arr['title']) : ''); + $arr['summary'] = ((array_key_exists('summary',$arr) && strlen($arr['summary'])) ? trim($arr['summary']) : ''); $arr['body'] = ((array_key_exists('body',$arr) && strlen($arr['body'])) ? trim($arr['body']) : ''); $arr['allow_cid'] = ((x($arr,'allow_cid')) ? trim($arr['allow_cid']) : ''); @@ -1651,6 +1660,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { // apply the input filter here + $arr['summary'] = trim(z_input_filter($arr['summary'],$arr['mimetype'],$allow_exec)); $arr['body'] = trim(z_input_filter($arr['body'],$arr['mimetype'],$allow_exec)); item_sign($arr); @@ -2096,6 +2106,7 @@ function item_store_update($arr, $allow_exec = false, $deliver = true) { // apply the input filter here + $arr['summary'] = trim(z_input_filter($arr['summary'],$arr['mimetype'],$allow_exec)); $arr['body'] = trim(z_input_filter($arr['body'],$arr['mimetype'],$allow_exec)); item_sign($arr); diff --git a/include/text.php b/include/text.php index 15cc0ca8a..3d351f7dc 100644 --- a/include/text.php +++ b/include/text.php @@ -3,8 +3,11 @@ * @file include/text.php */ -use \Zotlabs\Lib as Zlib; -use \Michelf\MarkdownExtra; +use Zotlabs\Lib as Zlib; + +use Michelf\MarkdownExtra; +use Ramsey\Uuid\Uuid; +use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; require_once("include/bbcode.php"); @@ -3467,3 +3470,19 @@ function print_val($v) { return $v; } + +/** + * @brief Generate a unique ID. + * + * @return string + */ +function new_uuid() { + + try { + $hash = Uuid::uuid4()->toString(); + } catch (UnsatisfiedDependencyException $e) { + $hash = random_string(48); + } + + return $hash; +} -- cgit v1.2.3 From c80ac58effdb71fe457daa164053ea57c1513e68 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 8 Nov 2018 20:42:09 -0800 Subject: add zot6 delivery method --- include/queue_fn.php | 99 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 76 insertions(+), 23 deletions(-) (limited to 'include') diff --git a/include/queue_fn.php b/include/queue_fn.php index f05bac5b0..074e3c407 100644 --- a/include/queue_fn.php +++ b/include/queue_fn.php @@ -1,5 +1,9 @@ run(true); + logger('returned_json: ' . json_encode($result,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES), LOGGER_DATA); + logger('deliver: local zot delivery succeeded to ' . $outq['outq_posturl']); + Libzot::process_response($outq['outq_posturl'],[ 'success' => true, 'body' => json_encode($result) ], $outq); + } + else { + logger('remote'); + $channel = null; + + if($outq['outq_channel']) { + $channel = channelx_by_n($outq['outq_channel']); + } + + $host_crypto = null; + if($channel && $base) { + $h = q("select hubloc_sitekey, site_crypto from hubloc left join site on hubloc_url = site_url where site_url = '%s' and\ + hubloc_network = 'zot6' order by hubloc_id desc limit 1", + dbesc($base) + ); + if($h) { + $host_crypto = $h[0]; + } + } + + $msg = $outq['outq_notify']; + + $result = Libzot::zot($outq['outq_posturl'],$msg,$channel,$host_crypto); + + if($result['success']) { + logger('deliver: remote zot delivery succeeded to ' . $outq['outq_posturl']); + Libzot::process_response($outq['outq_posturl'],$result, $outq); + } + else { + logger('deliver: remote zot delivery failed to ' . $outq['outq_posturl']); + logger('deliver: remote zot delivery fail data: ' . print_r($result,true), LOGGER_DATA); + update_queue_item($outq['outq_hash'],10); + } - if($outq['outq_msg'] && $outq['outq_channel']) { - $channel = channelx_by_n($outq['outq_channel']); + } + return; } + else { - $host_crypto = null; + $channel = null; - if($channel && $base) { - $h = q("select hubloc_sitekey, site_crypto from hubloc left join site on hubloc_url = site_url where site_url = '%s' order by hubloc_id desc limit 1", - dbesc($base) - ); - if($h) { - $host_crypto = $h[0]; + if($outq['outq_msg'] && $outq['outq_channel']) { + $channel = channelx_by_n($outq['outq_channel']); } - } - $msg = $outq['outq_notify']; + $host_crypto = null; - $result = zot_zot($outq['outq_posturl'],$msg,$channel,$host_crypto); + if($channel && $base) { + $h = q("select hubloc_sitekey, site_crypto from hubloc left join site on hubloc_url = site_url where site_url = '%s' order by hubloc_id desc limit 1", + dbesc($base) + ); + if($h) { + $host_crypto = $h[0]; + } + } + $msg = $outq['outq_notify']; - if($result['success']) { - logger('deliver: remote zot delivery succeeded to ' . $outq['outq_posturl']); - zot_process_response($outq['outq_posturl'],$result, $outq); - } - else { - logger('deliver: remote zot delivery failed to ' . $outq['outq_posturl']); - logger('deliver: remote zot delivery fail data: ' . print_r($result,true), LOGGER_DATA); - update_queue_item($outq['outq_hash'],10); + $result = zot_zot($outq['outq_posturl'],$msg,$channel,$host_crypto); + + + if($result['success']) { + logger('deliver: remote zot delivery succeeded to ' . $outq['outq_posturl']); + zot_process_response($outq['outq_posturl'],$result, $outq); + } + else { + logger('deliver: remote zot delivery failed to ' . $outq['outq_posturl']); + logger('deliver: remote zot delivery fail data: ' . print_r($result,true), LOGGER_DATA); + update_queue_item($outq['outq_hash'],10); + } + return; } - return; -} +} \ No newline at end of file -- cgit v1.2.3 From da452decf695ceac249642ec9d12fb724fa547f7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 11 Nov 2018 15:12:01 -0800 Subject: more z6 debugging --- include/crypto.php | 9 +++++++-- include/queue_fn.php | 11 +++++------ 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/crypto.php b/include/crypto.php index 1040ac29b..fc1029e55 100644 --- a/include/crypto.php +++ b/include/crypto.php @@ -225,9 +225,14 @@ function crypto_unencapsulate($data,$prvkey) { if(! $data) return; - $alg = ((array_key_exists('alg',$data)) ? $data['alg'] : 'aes256cbc'); - if($alg === 'aes256cbc') + $alg = ((is_array($data) && array_key_exists('encrypted',$data)) ? $data['alg'] : ''); + if(! $alg) { + return $data; + } + + if($alg === 'aes256cbc') { return aes_unencapsulate($data,$prvkey); + } return other_unencapsulate($data,$prvkey,$alg); diff --git a/include/queue_fn.php b/include/queue_fn.php index 074e3c407..f7e2922c6 100644 --- a/include/queue_fn.php +++ b/include/queue_fn.php @@ -237,7 +237,7 @@ function queue_deliver($outq, $immediate = false) { $zot = new Receiver(new Zot6Handler(),$outq['outq_notify']); $result = $zot->run(true); logger('returned_json: ' . json_encode($result,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES), LOGGER_DATA); - logger('deliver: local zot delivery succeeded to ' . $outq['outq_posturl']); + logger('deliver: local zot6 delivery succeeded to ' . $outq['outq_posturl']); Libzot::process_response($outq['outq_posturl'],[ 'success' => true, 'body' => json_encode($result) ], $outq); } else { @@ -250,8 +250,7 @@ function queue_deliver($outq, $immediate = false) { $host_crypto = null; if($channel && $base) { - $h = q("select hubloc_sitekey, site_crypto from hubloc left join site on hubloc_url = site_url where site_url = '%s' and\ - hubloc_network = 'zot6' order by hubloc_id desc limit 1", + $h = q("select hubloc_sitekey, site_crypto from hubloc left join site on hubloc_url = site_url where site_url = '%s' and hubloc_network = 'zot6' order by hubloc_id desc limit 1", dbesc($base) ); if($h) { @@ -264,12 +263,12 @@ function queue_deliver($outq, $immediate = false) { $result = Libzot::zot($outq['outq_posturl'],$msg,$channel,$host_crypto); if($result['success']) { - logger('deliver: remote zot delivery succeeded to ' . $outq['outq_posturl']); + logger('deliver: remote zot6 delivery succeeded to ' . $outq['outq_posturl']); Libzot::process_response($outq['outq_posturl'],$result, $outq); } else { - logger('deliver: remote zot delivery failed to ' . $outq['outq_posturl']); - logger('deliver: remote zot delivery fail data: ' . print_r($result,true), LOGGER_DATA); + logger('deliver: remote zot6 delivery failed to ' . $outq['outq_posturl']); + logger('deliver: remote zot6 delivery fail data: ' . print_r($result,true), LOGGER_DATA); update_queue_item($outq['outq_hash'],10); } -- cgit v1.2.3 From 770fdb2b7d095d763d43ffe8d2f6b5b2182673cb Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 12 Nov 2018 16:08:22 -0800 Subject: dreport updates --- include/zot.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 49fc89e33..756a5bde6 100644 --- a/include/zot.php +++ b/include/zot.php @@ -8,6 +8,8 @@ * */ +use Zotlabs\Lib\DReport; + require_once('include/crypto.php'); require_once('include/items.php'); require_once('include/queue_fn.php'); @@ -1120,7 +1122,7 @@ function zot_process_response($hub, $arr, $outq) { foreach($x['delivery_report'] as $xx) { call_hooks('dreport_process',$xx); - if(is_array($xx) && array_key_exists('message_id',$xx) && delivery_report_is_storable($xx)) { + if(is_array($xx) && array_key_exists('message_id',$xx) && DReport::is_storable($xx)) { q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ", dbesc($xx['message_id']), dbesc($xx['location']), @@ -1748,7 +1750,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ } $channel = $r[0]; - $DR->addto_recipient($channel['channel_name'] . ' <' . channel_reddress($channel) . '>'); + $DR->set_name($channel['channel_name'] . ' <' . channel_reddress($channel) . '>'); /* blacklisted channels get a permission denied, no special message to tip them off */ @@ -2297,7 +2299,7 @@ function process_mail_delivery($sender, $arr, $deliveries) { } $channel = $r[0]; - $DR->addto_recipient($channel['channel_name'] . ' <' . channel_reddress($channel) . '>'); + $DR->set_name($channel['channel_name'] . ' <' . channel_reddress($channel) . '>'); /* blacklisted channels get a permission denied, no special message to tip them off */ @@ -3987,7 +3989,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { if(array_key_exists('item',$arr) && is_array($arr['item'][0])) { $DR = new Zotlabs\Lib\DReport(z_root(),$d['hash'],$d['hash'],$arr['item'][0]['message_id'],'channel sync processed'); - $DR->addto_recipient($channel['channel_name'] . ' <' . channel_reddress($channel) . '>'); + $DR->set_name($channel['channel_name'] . ' <' . channel_reddress($channel) . '>'); } else $DR = new Zotlabs\Lib\DReport(z_root(),$d['hash'],$d['hash'],'sync packet','channel sync delivered'); -- cgit v1.2.3 From 1a2df9c51c4692fce433f483aba1b91738609df7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 12 Nov 2018 18:25:55 -0800 Subject: item uuid changes --- include/items.php | 10 +++++++++- include/text.php | 21 ++------------------- 2 files changed, 11 insertions(+), 20 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 24f1be84f..3d707a492 100755 --- a/include/items.php +++ b/include/items.php @@ -393,7 +393,11 @@ function post_activity_item($arr, $allow_code = false, $deliver = true) { if(! array_key_exists('mimetype',$arr)) $arr['mimetype'] = 'text/bbcode'; - $arr['mid'] = ((x($arr,'mid')) ? $arr['mid'] : item_message_id()); + + if(! $arr['mid']) { + $arr['uuid'] = ((x($arr,'uuid')) ? $arr['uuid'] : item_message_id()); + } + $arr['mid'] = ((x($arr,'mid')) ? $arr['mid'] : z_root() . '/item/' . $arr['uuid']); $arr['parent_mid'] = ((x($arr,'parent_mid')) ? $arr['parent_mid'] : $arr['mid']); $arr['thr_parent'] = ((x($arr,'thr_parent')) ? $arr['thr_parent'] : $arr['mid']); @@ -635,6 +639,7 @@ function get_item_elements($x,$allow_code = false) { if(mb_strlen($arr['title']) > 255) $arr['title'] = mb_substr($arr['title'],0,255); + $arr['uuid'] = (($x['uuid']) ? htmlspecialchars($x['uuid'], ENT_COMPAT,'UTF-8',false) : ''); $arr['app'] = (($x['app']) ? htmlspecialchars($x['app'], ENT_COMPAT,'UTF-8',false) : ''); $arr['route'] = (($x['route']) ? htmlspecialchars($x['route'], ENT_COMPAT,'UTF-8',false) : ''); $arr['mid'] = (($x['message_id']) ? htmlspecialchars($x['message_id'], ENT_COMPAT,'UTF-8',false) : ''); @@ -1070,6 +1075,7 @@ function encode_item($item,$mirror = false) { $x['item_blocked'] = $item['item_blocked']; } + $x['uuid'] = $item['uuid']; $x['message_id'] = $item['mid']; $x['message_top'] = $item['parent_mid']; $x['message_parent'] = $item['thr_parent']; @@ -1648,6 +1654,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { $arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : ''); $arr['postopts'] = ((x($arr,'postopts')) ? trim($arr['postopts']) : ''); $arr['route'] = ((x($arr,'route')) ? trim($arr['route']) : ''); + $arr['uuid'] = ((x($arr,'uuid')) ? trim($arr['uuid']) : ''); $arr['item_private'] = ((x($arr,'item_private')) ? intval($arr['item_private']) : 0 ); $arr['item_wall'] = ((x($arr,'item_wall')) ? intval($arr['item_wall']) : 0 ); $arr['item_type'] = ((x($arr,'item_type')) ? intval($arr['item_type']) : 0 ); @@ -2183,6 +2190,7 @@ function item_store_update($arr, $allow_exec = false, $deliver = true) { $arr['route'] = ((array_key_exists('route',$arr)) ? trim($arr['route']) : $orig[0]['route']); $arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : $orig[0]['location']); + $arr['uuid'] = ((x($arr,'uuid')) ? notags(trim($arr['uuid'])) : $orig[0]['uuid']); $arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : $orig[0]['coord']); $arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : $orig[0]['verb']); $arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : $orig[0]['obj_type']); diff --git a/include/text.php b/include/text.php index 3d351f7dc..d3130023c 100644 --- a/include/text.php +++ b/include/text.php @@ -574,18 +574,9 @@ function alt_pager($i, $more = '', $less = '') { * @return string a unique id */ function item_message_id() { - do { - $dups = false; - $hash = random_string(); - $mid = $hash . '@' . App::get_hostname(); - $r = q("SELECT id FROM item WHERE mid = '%s' LIMIT 1", - dbesc($mid)); - if($r) - $dups = true; - } while($dups == true); + return new_uuid(); - return $mid; } /** @@ -596,17 +587,9 @@ function item_message_id() { * @return string a uniqe hash */ function photo_new_resource() { - do { - $found = false; - $resource = hash('md5', uniqid(mt_rand(), true)); - $r = q("SELECT id FROM photo WHERE resource_id = '%s' LIMIT 1", - dbesc($resource)); - if($r) - $found = true; - } while($found === true); + return new_uuid(); - return $resource; } /** -- cgit v1.2.3 From ee85784be18c14905568fb259411f490c8d6bd91 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 13 Nov 2018 19:55:43 -0800 Subject: stay ahead of the game --- include/network.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/network.php b/include/network.php index d37da05f7..183a47105 100644 --- a/include/network.php +++ b/include/network.php @@ -153,7 +153,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) { // Pull out multiple headers, e.g. proxy and continuation headers // allow for HTTP/2.x without fixing code - while(preg_match('/^HTTP\/[1-2].+? [1-5][0-9][0-9]/',$base)) { + while(preg_match('/^HTTP\/[1-3].+? [1-5][0-9][0-9]/',$base)) { $chunk = substr($base,0,strpos($base,"\r\n\r\n")+4); $header .= $chunk; $base = substr($base,strlen($chunk)); @@ -319,7 +319,7 @@ function z_post_url($url, $params, $redirects = 0, $opts = array()) { // Pull out multiple headers, e.g. proxy and continuation headers // allow for HTTP/2.x without fixing code - while(preg_match('/^HTTP\/[1-2].+? [1-5][0-9][0-9]/',$base)) { + while(preg_match('/^HTTP\/[1-3].+? [1-5][0-9][0-9]/',$base)) { $chunk = substr($base,0,strpos($base,"\r\n\r\n")+4); $header .= $chunk; $base = substr($base,strlen($chunk)); -- cgit v1.2.3 From 4a06378d672cd355e337b2456096e76f698cf163 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 14 Nov 2018 18:19:35 -0800 Subject: crypto fix --- include/crypto.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/crypto.php b/include/crypto.php index fc1029e55..39bfd8d43 100644 --- a/include/crypto.php +++ b/include/crypto.php @@ -225,7 +225,7 @@ function crypto_unencapsulate($data,$prvkey) { if(! $data) return; - $alg = ((is_array($data) && array_key_exists('encrypted',$data)) ? $data['alg'] : ''); + $alg = ((is_array($data) && (array_key_exists('encrypted',$data) || array_key_exists('iv',$data))) ? $data['alg'] : ''); if(! $alg) { return $data; } -- cgit v1.2.3 From 5f166158c3900bd85a204d3b7741d8e190a92bc4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 14 Nov 2018 18:25:02 -0800 Subject: filter by network --- include/zot.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 756a5bde6..b0d6ffd61 100644 --- a/include/zot.php +++ b/include/zot.php @@ -83,7 +83,7 @@ function zot_get_hublocs($hash) { /* Only search for active hublocs - e.g. those that haven't been marked deleted */ - $ret = q("select * from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0 order by hubloc_url ", + $ret = q("select * from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0 and hubloc_network = 'zot' order by hubloc_url ", dbesc($hash) ); @@ -656,7 +656,7 @@ function zot_gethub($arr, $multiple = false) { $r = q("select hubloc.*, site.site_crypto from hubloc left join site on hubloc_url = site_url where hubloc_guid = '%s' and hubloc_guid_sig = '%s' - and hubloc_url = '%s' and hubloc_url_sig = '%s' + and hubloc_url = '%s' and hubloc_url_sig = '%s' and hubloc_network = 'zot' $sitekey $limit", dbesc($arr['guid']), dbesc($arr['guid_sig']), -- cgit v1.2.3 From 079e2af0c07f54f521cdee9b31b8be4dd1acd159 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 14 Nov 2018 18:33:00 -0800 Subject: check keyid --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index b0d6ffd61..12bd9995c 100644 --- a/include/zot.php +++ b/include/zot.php @@ -5187,7 +5187,7 @@ function zot6_check_sig() { $sigblock = \Zotlabs\Web\HTTPSig::parse_sigheader($_SERVER['HTTP_SIGNATURE']); if($sigblock) { $keyId = $sigblock['keyId']; - + logger('keyID: ' . $keyId); if($keyId) { $r = q("select hubloc.*, site_crypto from hubloc left join site on hubloc_url = site_url where hubloc_addr = '%s' ", -- cgit v1.2.3 From 830c2472cb7b2b1d53f1d99062f37e52c4aa7074 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 14 Nov 2018 18:39:23 -0800 Subject: more logging --- include/zot.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 12bd9995c..26eaee6b3 100644 --- a/include/zot.php +++ b/include/zot.php @@ -5197,6 +5197,7 @@ function zot6_check_sig() { foreach($r as $hubloc) { $verified = \Zotlabs\Web\HTTPSig::verify('',$hubloc['xchan_pubkey']); if($verified && $verified['header_signed'] && $verified['header_valid'] && $verified['content_signed'] && $verified['content_valid']) { + logger('zot6 verified'); $ret['hubloc'] = $hubloc; $ret['success'] = true; return $ret; -- cgit v1.2.3 From db4ff56f0b5c4610ef6706af39ac496b5d98e69b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 14 Nov 2018 18:41:36 -0800 Subject: more logging --- include/zot.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 26eaee6b3..2fca33a96 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1189,6 +1189,8 @@ function zot_fetch($arr) { $zret = zot6_check_sig(); + logger('zret: ' . print_r($zret,true)); + if($zret['success'] && $zret['hubloc'] && $zret['hubloc']['hubloc_guid'] === $data['sender']['guid'] && $data['msg']) { logger('zot6_delivery',LOGGER_DEBUG); logger('zot6_data: ' . print_r($data,true),LOGGER_DATA); -- cgit v1.2.3 From 9c25f300cf5032076c98bd597355c88e7ec08a34 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 14 Nov 2018 18:56:38 -0800 Subject: fixes to old z6 delivery --- include/zot.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 2fca33a96..580220182 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1189,15 +1189,14 @@ function zot_fetch($arr) { $zret = zot6_check_sig(); - logger('zret: ' . print_r($zret,true)); + if($zret['success'] && $zret['hubloc'] && $zret['hubloc']['hubloc_guid'] === $arr['sender']['guid'] && $arr['msg']) { - if($zret['success'] && $zret['hubloc'] && $zret['hubloc']['hubloc_guid'] === $data['sender']['guid'] && $data['msg']) { logger('zot6_delivery',LOGGER_DEBUG); - logger('zot6_data: ' . print_r($data,true),LOGGER_DATA); + logger('zot6_data: ' . print_r($arr,true),LOGGER_DATA); $ret['collected'] = true; - $import = [ 'success' => true, 'body' => json_encode( [ 'success' => true, 'pickup' => [ [ 'notify' => $data, 'message' => json_decode($data['msg'],true) ] ] ] ) ]; + $import = [ 'success' => true, 'body' => json_encode( [ 'success' => true, 'pickup' => [ [ 'notify' => $arr, 'message' => json_decode($arr['msg'],true) ] ] ] ) ]; $hubs = [ $zret['hubloc'] ] ; } -- cgit v1.2.3 From 39d914c9dfe87021351cb2aad9feedd381e791ec Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 15 Nov 2018 16:34:09 -0800 Subject: add item.uuid to relevant places --- include/activities.php | 3 ++- include/attach.php | 14 +++++++++----- include/event.php | 7 +++++-- include/help.php | 3 ++- include/import.php | 3 ++- include/items.php | 3 ++- include/photos.php | 8 ++++++-- 7 files changed, 28 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/activities.php b/include/activities.php index 9b83f7a5c..68c995338 100644 --- a/include/activities.php +++ b/include/activities.php @@ -16,7 +16,8 @@ function profile_activity($changed, $value) { return; $arr = array(); - $arr['mid'] = $arr['parent_mid'] = item_message_id(); + $arr['uuid'] = item_message_id(); + $arr['mid'] = $arr['parent_mid'] = z_root() . '/item/' . $arr['uuid']; $arr['uid'] = local_channel(); $arr['aid'] = $self['channel_account_id']; $arr['owner_xchan'] = $arr['author_xchan'] = $self['xchan_hash']; diff --git a/include/attach.php b/include/attach.php index 4db5bc435..6b0d3fb3b 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1759,16 +1759,18 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $arr_allow_cid = check_list_permissions($channel_id, $arr_allow_cid, 'view_storage'); } - $mid = item_message_id(); + $uuid = item_message_id(); + $mid = z_root() . '/item/' . $uuid; $objtype = ACTIVITY_OBJ_FILE; $arr = array(); $arr['aid'] = get_account_id(); $arr['uid'] = $channel_id; - $arr['item_wall'] = 1; - $arr['item_origin'] = 1; - $arr['item_unseen'] = 1; + $arr['uuid'] = $uuid; + $arr['item_wall'] = 1; + $arr['item_origin'] = 1; + $arr['item_unseen'] = 1; $arr['author_xchan'] = $poster['xchan_hash']; $arr['owner_xchan'] = $poster['xchan_hash']; $arr['title'] = ''; @@ -1813,8 +1815,10 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $private = (($u_arr_allow_cid[0] || $u_arr_allow_gid[0] || $u_arr_deny_cid[0] || $u_arr_deny_gid[0]) ? 1 : 0); - $u_mid = item_message_id(); + $uuid = item_message_id(); + $u_mid = z_root() . '/item/' . $uuid; + $arr['uuid'] = $uuid; $arr['mid'] = $u_mid; $arr['parent_mid'] = $u_mid; $arr['allow_cid'] = perms2str($u_arr_allow_cid); diff --git a/include/event.php b/include/event.php index 84a16e8be..a34250e7a 100644 --- a/include/event.php +++ b/include/event.php @@ -1125,11 +1125,14 @@ function event_store_item($arr, $event) { } } - if(! $arr['mid']) - $arr['mid'] = item_message_id(); + if(! $arr['mid']) { + $arr['uuid'] = item_message_id(); + $arr['mid'] = z_root() . '/item/' . $arr['uuid']; + } $item_arr['aid'] = $z[0]['channel_account_id']; $item_arr['uid'] = $arr['uid']; + $item_arr['uuid'] = $arr['uuid']; $item_arr['author_xchan'] = $arr['event_xchan']; $item_arr['mid'] = $arr['mid']; $item_arr['parent_mid'] = $arr['mid']; diff --git a/include/help.php b/include/help.php index 3b56a7238..f2aa4add3 100644 --- a/include/help.php +++ b/include/help.php @@ -351,7 +351,8 @@ function store_doc_file($s) { $x = item_store_update($item); } else { - $item['mid'] = $item['parent_mid'] = item_message_id(); + $item['uuid'] = $item_message_id(); + $item['mid'] = $item['parent_mid'] = z_root() . '/item/' . $item['uuid']; $x = item_store($item); } diff --git a/include/import.php b/include/import.php index 6476aa688..53b21c317 100644 --- a/include/import.php +++ b/include/import.php @@ -1520,7 +1520,8 @@ function import_webpage_element($element, $channel, $type) { } else { // otherwise, generate the creation times and unique id $arr['created'] = datetime_convert('UTC', 'UTC'); - $arr['mid'] = $arr['parent_mid'] = item_message_id(); + $arr['uuid'] = item_message_id(); + $arr['mid'] = $arr['parent_mid'] = z_root() . '/item/' . $arr['uuid']; } // Update the edited time whether or not the element already exists $arr['edited'] = datetime_convert('UTC', 'UTC'); diff --git a/include/items.php b/include/items.php index 3d707a492..2baad3d04 100755 --- a/include/items.php +++ b/include/items.php @@ -4765,7 +4765,8 @@ function item_create_edit_activity($post) { $new_item['id'] = 0; $new_item['parent'] = 0; - $new_item['mid'] = item_message_id(); + $new_item['uuid'] = item_message_id(); + $new_item['mid'] = z_root() . '/item/' . $new_item['uuid']; $new_item['body'] = sprintf( t('[Edited %s]'), (($update_item['item_thread_top']) ? t('Post','edit_activity') : t('Comment','edit_activity'))); diff --git a/include/photos.php b/include/photos.php index d5553b495..ae51703e0 100644 --- a/include/photos.php +++ b/include/photos.php @@ -441,11 +441,13 @@ function photo_upload($channel, $observer, $args) { } } else { - $mid = item_message_id(); + $uuid = item_message_id(); + $mid = z_root() . '/item/' . $uuid; $arr = [ 'aid' => $account_id, 'uid' => $channel_id, + 'uuid' => $uuid, 'mid' => $mid, 'parent_mid' => $mid, 'item_hidden' => $item_hidden, @@ -827,12 +829,14 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) { $item_hidden = (($visible) ? 0 : 1 ); - $mid = item_message_id(); + $uuid = item_message_id(); + $mid = z_root() . '/item/' . $uuid; $arr = array(); $arr['aid'] = $channel['channel_account_id']; $arr['uid'] = $channel['channel_id']; + $arr['uuid'] = $uuid; $arr['mid'] = $mid; $arr['parent_mid'] = $mid; $arr['item_wall'] = 1; -- cgit v1.2.3 From 5162459e4a77ccd1e4a4a68a2deae2a231947f62 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 15 Nov 2018 18:07:58 -0800 Subject: delivery report issue --- include/zot.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 580220182..9208a6a99 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1121,12 +1121,13 @@ function zot_process_response($hub, $arr, $outq) { } foreach($x['delivery_report'] as $xx) { - call_hooks('dreport_process',$xx); + call_hooks('dreport_process',$xx); if(is_array($xx) && array_key_exists('message_id',$xx) && DReport::is_storable($xx)) { - q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ", + q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_name, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s','%s' ) ", dbesc($xx['message_id']), dbesc($xx['location']), dbesc($xx['recipient']), + dbesc($xx['name']), dbesc($xx['status']), dbesc(datetime_convert($xx['date'])), dbesc($xx['sender']) -- cgit v1.2.3 From b0689614bff4272f90b0c3f064ca91b16cb392e0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 15 Nov 2018 21:14:14 -0800 Subject: datetime_convert wrong args --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 9208a6a99..d031b4a96 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1129,7 +1129,7 @@ function zot_process_response($hub, $arr, $outq) { dbesc($xx['recipient']), dbesc($xx['name']), dbesc($xx['status']), - dbesc(datetime_convert($xx['date'])), + dbesc(datetime_convert('UTC','UTC',$xx['date'])), dbesc($xx['sender']) ); } -- cgit v1.2.3 From 4812c5486db3f49cd1df34f8678c51369ac76d7a Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 16 Nov 2018 21:14:11 +0000 Subject: strlen($this->imageString()) does not return the correct size when dealing with os_storage images. use filesize() instead. (cherry picked from commit afc75af62f759181bbe6a806b523c6ca52126f5f) --- include/photo/photo_driver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index 4173d727e..b70a13622 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -413,7 +413,7 @@ abstract class photo_driver { intval($p['width']), (intval($p['os_storage']) ? dbescbin($p['os_syspath']) : dbescbin($this->imageString())), intval($p['os_storage']), - intval(strlen($this->imageString())), + (intval($p['os_storage']) ? @filesize($p['os_syspath']) : strlen($this->imageString())), intval($p['imgscale']), intval($p['photo_usage']), dbesc($p['title']), @@ -445,7 +445,7 @@ abstract class photo_driver { intval($p['width']), (intval($p['os_storage']) ? dbescbin($p['os_syspath']) : dbescbin($this->imageString())), intval($p['os_storage']), - intval(strlen($this->imageString())), + (intval($p['os_storage']) ? @filesize($p['os_syspath']) : strlen($this->imageString())), intval($p['imgscale']), intval($p['photo_usage']), dbesc($p['title']), -- cgit v1.2.3 From 3787c490d4fe9c6beda393580e4ee8ad8f7cd6dc Mon Sep 17 00:00:00 2001 From: "DM42.Net (Matt Dent)" Date: Sun, 18 Nov 2018 07:00:06 -0500 Subject: Fix: delayed items propagate before publication on cloned channels --- include/items.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 2baad3d04..8268d3fe7 100755 --- a/include/items.php +++ b/include/items.php @@ -618,8 +618,6 @@ function get_item_elements($x,$allow_code = false) { $arr['created'] = datetime_convert('UTC','UTC',$x['created']); $arr['edited'] = datetime_convert('UTC','UTC',$x['edited']); - if($arr['created'] > datetime_convert()) - $arr['created'] = datetime_convert(); if($arr['edited'] > datetime_convert()) $arr['edited'] = datetime_convert(); -- cgit v1.2.3 From ea235c0c6751b682332b968b4c18f905e8ece451 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 21 Nov 2018 20:03:58 -0800 Subject: no mention notifications from mastodon (and pleroma) --- include/items.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 2baad3d04..19df3bb80 100755 --- a/include/items.php +++ b/include/items.php @@ -2664,7 +2664,7 @@ function tag_deliver($uid, $item_id) { if(preg_match_all($pluspattern,$body,$matches,PREG_SET_ORDER)) { foreach($matches as $match) { $matched_forums ++; - if($term['url'] === $match[1] && $term['term'] === $match[2] && intval($term['ttype']) === TERM_MENTION) { + if($term['url'] === $match[1] && intval($term['ttype']) === TERM_MENTION) { if($matched_forums <= $max_forums) { $plustagged = true; $found = true; @@ -2678,7 +2678,7 @@ function tag_deliver($uid, $item_id) { if(preg_match_all($forumpattern,$body,$matches,PREG_SET_ORDER)) { foreach($matches as $match) { $matched_forums ++; - if($term['url'] === $match[1] && $term['term'] === $match[2] && intval($term['ttype']) === TERM_FORUM) { + if($term['url'] === $match[1] && intval($term['ttype']) === TERM_FORUM) { if($matched_forums <= $max_forums) { $plustagged = true; $found = true; @@ -2914,7 +2914,7 @@ function tgroup_check($uid, $item) { if(preg_match_all($pluspattern,$body,$matches,PREG_SET_ORDER)) { foreach($matches as $match) { $matched_forums ++; - if($term['url'] === $match[1] && $term['term'] === $match[2] && intval($term['ttype']) === TERM_MENTION) { + if($term['url'] === $match[1] && intval($term['ttype']) === TERM_MENTION) { if($matched_forums <= $max_forums) { $found = true; break; @@ -2927,7 +2927,7 @@ function tgroup_check($uid, $item) { if(preg_match_all($forumpattern,$body,$matches,PREG_SET_ORDER)) { foreach($matches as $match) { $matched_forums ++; - if($term['url'] === $match[1] && $term['term'] === $match[2] && intval($term['ttype']) === TERM_FORUM) { + if($term['url'] === $match[1] && intval($term['ttype']) === TERM_FORUM) { if($matched_forums <= $max_forums) { $found = true; break; -- cgit v1.2.3 From 8e713245144d0bcedca0d3345017b5fa232c8ca3 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 21 Nov 2018 20:25:59 -0800 Subject: fix mastodon tag notifications (again) --- include/items.php | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 19df3bb80..4ccc3e01c 100755 --- a/include/items.php +++ b/include/items.php @@ -2646,28 +2646,30 @@ function tag_deliver($uid, $item_id) { $plustagged = false; $matches = array(); - $pattern = '/[\!@]\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'],'/') . '\[\/zrl\]/'; + $pattern = '/[\!@]\!?\[[uz]rl\=' . preg_quote($term['url'],'/') . '\](.*?)\[\/[uz]rl\]/'; if(preg_match($pattern,$body,$matches)) $tagged = true; - // original red forum tagging sequence @forumname+ + $pattern = '/\[url\=' . preg_quote($term['url'],'/') . '\]\@(.*?)\[\/url\]/'; + if(preg_match($pattern,$body,$matches)) + $tagged = true; + + // standard forum tagging sequence !forumname - $pluspattern = '/@\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\+\[\/zrl\]/'; + $forumpattern = '/\!\!?\[[uz]rl\=([^\]]*?)\]((?:.(?!\[[uz]rl\=))*?)\[\/[uz]rl\]/'; - $forumpattern = '/\!\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\[\/zrl\]/'; + $forumpattern2 = '/\[[uz]rl\=([^\]]*?)\]\!((?:.(?!\[[uz]rl\=))*?)\[\/[uz]rl\]/'; - $found = false; $matches = array(); - if(preg_match_all($pluspattern,$body,$matches,PREG_SET_ORDER)) { + if(preg_match_all($forumpattern,$body,$matches,PREG_SET_ORDER)) { foreach($matches as $match) { $matched_forums ++; - if($term['url'] === $match[1] && intval($term['ttype']) === TERM_MENTION) { + if($term['url'] === $match[1] && intval($term['ttype']) === TERM_FORUM) { if($matched_forums <= $max_forums) { $plustagged = true; - $found = true; break; } logger('forum ' . $term['term'] . ' exceeded max_tagged_forums - ignoring'); @@ -2675,13 +2677,12 @@ function tag_deliver($uid, $item_id) { } } - if(preg_match_all($forumpattern,$body,$matches,PREG_SET_ORDER)) { + if(preg_match_all($forumpattern2,$body,$matches,PREG_SET_ORDER)) { foreach($matches as $match) { $matched_forums ++; if($term['url'] === $match[1] && intval($term['ttype']) === TERM_FORUM) { if($matched_forums <= $max_forums) { $plustagged = true; - $found = true; break; } logger('forum ' . $term['term'] . ' exceeded max_tagged_forums - ignoring'); @@ -2903,18 +2904,19 @@ function tgroup_check($uid, $item) { $body = preg_replace('/\[share(.*?)\[\/share\]/','',$item['body']); - $pluspattern = '/@\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\+\[\/zrl\]/'; - $forumpattern = '/\!\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\[\/zrl\]/'; + $forumpattern2 = '/\[zrl\=([^\]]*?)\]\!((?:.(?!\[zrl\=))*?)\[\/zrl\]/'; + + $found = false; $matches = array(); - if(preg_match_all($pluspattern,$body,$matches,PREG_SET_ORDER)) { + if(preg_match_all($forumpattern,$body,$matches,PREG_SET_ORDER)) { foreach($matches as $match) { $matched_forums ++; - if($term['url'] === $match[1] && intval($term['ttype']) === TERM_MENTION) { + if($term['url'] === $match[1] && intval($term['ttype']) === TERM_FORUM) { if($matched_forums <= $max_forums) { $found = true; break; @@ -2924,7 +2926,7 @@ function tgroup_check($uid, $item) { } } - if(preg_match_all($forumpattern,$body,$matches,PREG_SET_ORDER)) { + if(preg_match_all($forumpattern2,$body,$matches,PREG_SET_ORDER)) { foreach($matches as $match) { $matched_forums ++; if($term['url'] === $match[1] && intval($term['ttype']) === TERM_FORUM) { -- cgit v1.2.3 From 9a8d1200ecc9f877b431a00a5219b41d2bd68de6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 22 Nov 2018 18:39:38 -0800 Subject: use uuid in file storage --- include/attach.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 6b0d3fb3b..dd718aa14 100644 --- a/include/attach.php +++ b/include/attach.php @@ -739,7 +739,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { } if(! $hash) - $hash = random_string(); + $hash = new_uuid(); // Check storage limits if($options !== 'update') { @@ -1122,7 +1122,7 @@ function attach_mkdir($channel, $observer_hash, $arr = null) { return $ret; } - $arr['hash'] = (($arr['hash']) ? $arr['hash'] : random_string()); + $arr['hash'] = (($arr['hash']) ? $arr['hash'] : new_uuid()); // Check for duplicate name. // Check both the filename and the hash as we will be making use of both. -- cgit v1.2.3