From 34d1f797778c71357989d793a6356ed9f8aeefed Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 20 May 2019 12:26:33 +0200 Subject: calendar merge: initial commit for timezone support --- include/event.php | 15 +++++++++++---- include/features.php | 16 ++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index 471fb7afa..9bae69f5c 100644 --- a/include/event.php +++ b/include/event.php @@ -75,17 +75,19 @@ function format_event_obj($jobject) { //ensure compatibility with older items - this check can be removed at a later point if(array_key_exists('description', $object)) { + $tz = (($object['timezone']) ? $object['timezone'] : 'UTC'); + $bd_format = t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8:01 AM $event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array( '$title' => zidify_links(smilies(bbcode($object['title']))), '$dtstart_label' => t('Starts:'), - '$dtstart_title' => datetime_convert('UTC', 'UTC', $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))), + '$dtstart_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), + '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'] , $bd_format))), '$finish' => (($object['nofinish']) ? false : true), '$dtend_label' => t('Finishes:'), - '$dtend_title' => datetime_convert('UTC','UTC',$object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))) + '$dtend_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), + '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtend'] , $bd_format ))) )); $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( @@ -1042,6 +1044,7 @@ function event_store_item($arr, $event) { 'type' => ACTIVITY_OBJ_EVENT, 'id' => z_root() . '/event/' . $r[0]['resource_id'], 'title' => $arr['summary'], + 'timezone' => $arr['timezone'], 'dtstart' => $arr['dtstart'], 'dtend' => $arr['dtend'], 'nofinish' => $arr['nofinish'], @@ -1107,6 +1110,8 @@ function event_store_item($arr, $event) { } $item_id = $r[0]['id']; + set_iconfig($item_id, 'event', 'timezone', $arr['timezone'], true); + /** * @hooks event_updated * Called when an event record is modified. @@ -1197,6 +1202,7 @@ function event_store_item($arr, $event) { 'type' => ACTIVITY_OBJ_EVENT, 'id' => z_root() . '/event/' . $event['event_hash'], 'title' => $arr['summary'], + 'timezone' => $arr['timezone'], 'dtstart' => $arr['dtstart'], 'dtend' => $arr['dtend'], 'nofinish' => $arr['nofinish'], @@ -1223,6 +1229,7 @@ function event_store_item($arr, $event) { // activities refer to the item message_id as the parent. set_iconfig($item_arr, 'system','event_id',$event['event_hash'],true); + set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true); $res = item_store($item_arr); diff --git a/include/features.php b/include/features.php index d8607f447..431b199a5 100644 --- a/include/features.php +++ b/include/features.php @@ -87,6 +87,14 @@ function get_features($filtered = true, $level = (-1)) { t('Default is Sunday'), false, get_config('feature_lock','cal_first_day') + ], + + [ + 'event_tz_select', + t('Event Timezone Selection'), + t('Allow event creation in timezones other than your own.'), + false, + get_config('feature_lock','event_tz_select'), ] ], @@ -290,14 +298,6 @@ function get_features($filtered = true, $level = (-1)) { t('Make birthday events timezone aware in case your friends are scattered across the planet.'), true, get_config('feature_lock','smart_birthdays'), - ], - - [ - 'event_tz_select', - t('Event Timezone Selection'), - t('Allow event creation in timezones other than your own.'), - false, - get_config('feature_lock','event_tz_select'), ] ], -- cgit v1.2.3 From c9d64d75f3acab6b44d28cd7bcc6e7e5dd042e77 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 20 May 2019 13:51:53 +0200 Subject: move smart birthday feature to calendar settings and override the adjust flag at display time instead of import --- include/datetime.php | 2 +- include/features.php | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/datetime.php b/include/datetime.php index 3a07f1ccf..d049fc7c5 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -516,7 +516,7 @@ function update_birthdays() { 'event_xchan' => $rr['xchan_hash'], 'dtstart' => datetime_convert('UTC', 'UTC', $rr['abook_dob']), 'dtend' => datetime_convert('UTC', 'UTC', $rr['abook_dob'] . ' + 1 day '), - 'adjust' => intval(feature_enabled($rr['abook_channel'],'smart_birthdays')), + 'adjust' => 1, //intval(feature_enabled($rr['abook_channel'],'smart_birthdays')), 'summary' => sprintf( t('%1$s\'s birthday'), $rr['xchan_name']), 'description' => sprintf( t('Happy Birthday %1$s'), '[zrl=' . $rr['xchan_url'] . ']' . $rr['xchan_name'] . '[/zrl]'), 'etype' => 'birthday', diff --git a/include/features.php b/include/features.php index 431b199a5..a44b424a6 100644 --- a/include/features.php +++ b/include/features.php @@ -95,6 +95,14 @@ function get_features($filtered = true, $level = (-1)) { t('Allow event creation in timezones other than your own.'), false, get_config('feature_lock','event_tz_select'), + ], + + [ + 'smart_birthdays', + t('Smart Birthdays'), + t('Make birthday events timezone aware in case your friends are scattered across the planet.'), + true, + get_config('feature_lock','smart_birthdays'), ] ], @@ -290,14 +298,6 @@ function get_features($filtered = true, $level = (-1)) { t('Default is Sunday'), false, get_config('feature_lock','events_cal_first_day') - ], - - [ - 'smart_birthdays', - t('Smart Birthdays'), - t('Make birthday events timezone aware in case your friends are scattered across the planet.'), - true, - get_config('feature_lock','smart_birthdays'), ] ], -- cgit v1.2.3 From 39613aa2d9298e13629b5b4a7c6b6f1bbe7edca5 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 22 May 2019 12:40:37 +0200 Subject: improve timezone detection for caldav and remove smart birthday feature. Force adjust birthdays until we agree on how to deal with this. --- include/event.php | 4 ++-- include/features.php | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index 9bae69f5c..eb8731f46 100644 --- a/include/event.php +++ b/include/event.php @@ -83,11 +83,11 @@ function format_event_obj($jobject) { '$title' => zidify_links(smilies(bbcode($object['title']))), '$dtstart_label' => t('Starts:'), '$dtstart_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'] , $bd_format))), + '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))), '$finish' => (($object['nofinish']) ? false : true), '$dtend_label' => t('Finishes:'), '$dtend_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtend'] , $bd_format ))) + '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))) )); $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( diff --git a/include/features.php b/include/features.php index a44b424a6..5841395c5 100644 --- a/include/features.php +++ b/include/features.php @@ -96,14 +96,15 @@ function get_features($filtered = true, $level = (-1)) { false, get_config('feature_lock','event_tz_select'), ], - +/* [ 'smart_birthdays', t('Smart Birthdays'), t('Make birthday events timezone aware in case your friends are scattered across the planet.'), - true, + false, get_config('feature_lock','smart_birthdays'), ] +*/ ], -- cgit v1.2.3 From 528b9b6a60d847b0ecb639cb7fb8e01ee79b11d4 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 24 May 2019 10:27:45 +0200 Subject: fix #1374 --- include/markdown.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/markdown.php b/include/markdown.php index 2513a7d77..7d1f16958 100644 --- a/include/markdown.php +++ b/include/markdown.php @@ -76,6 +76,8 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) { $s = html2bbcode($s); + $s = bb_code_protect($s); + // Convert everything that looks like a link to a link if($use_zrl) { if (strpos($s,'[/img]') !== false) { @@ -88,6 +90,8 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) { $s = preg_replace("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)/ismu", '$1[url=$2$3]$2$3[/url]',$s); } + $s = bb_code_unprotect($s); + // remove duplicate adjacent code tags $s = preg_replace("/(\[code\])+(.*?)(\[\/code\])+/ism","[code]$2[/code]", $s); -- cgit v1.2.3 From e466d72058b2543bec69c77d2730828acada38a1 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 26 May 2019 18:05:11 +0200 Subject: adjust birthday handling according to community decision and slightly change display of allday event items --- include/datetime.php | 3 ++- include/event.php | 24 ++++++++++++++++++++---- include/features.php | 9 --------- include/zot.php | 2 +- 4 files changed, 23 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/datetime.php b/include/datetime.php index d049fc7c5..ef0927ea4 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -516,13 +516,14 @@ function update_birthdays() { 'event_xchan' => $rr['xchan_hash'], 'dtstart' => datetime_convert('UTC', 'UTC', $rr['abook_dob']), 'dtend' => datetime_convert('UTC', 'UTC', $rr['abook_dob'] . ' + 1 day '), - 'adjust' => 1, //intval(feature_enabled($rr['abook_channel'],'smart_birthdays')), + 'adjust' => 0, 'summary' => sprintf( t('%1$s\'s birthday'), $rr['xchan_name']), 'description' => sprintf( t('Happy Birthday %1$s'), '[zrl=' . $rr['xchan_url'] . ']' . $rr['xchan_name'] . '[/zrl]'), 'etype' => 'birthday', ]; $z = event_store_event($ev); + if ($z) { $item_id = event_store_item($ev, $z); q("update abook set abook_dob = '%s' where abook_id = %d", diff --git a/include/event.php b/include/event.php index eb8731f46..ca08a67b5 100644 --- a/include/event.php +++ b/include/event.php @@ -76,18 +76,34 @@ function format_event_obj($jobject) { if(array_key_exists('description', $object)) { $tz = (($object['timezone']) ? $object['timezone'] : 'UTC'); + $allday = (($object['adjust']) ? false : true); - $bd_format = t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8:01 AM + $dtstart = new DateTime($object['dtstart']); + $dtend = new DateTime($object['dtend']); + $dtdiff = $dtstart->diff($dtend); + + if($allday && ($dtdiff->days < 2)) + $oneday = true; + + if($allday && !$oneday) { + // Subtract one day from the end date so we can use the "first day - last day" format for display. + $dtend->modify('-1 day'); + $object['dtend'] = datetime_convert('UTC', 'UTC', $dtend->format('Y-m-d H:i:s')); + } + + $bd_format = (($allday) ? t('l F d, Y') : t('l F d, Y \@ g:i A')); // Friday January 18, 2011 @ 8:01 AM or Friday January 18, 2011 for allday events $event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array( '$title' => zidify_links(smilies(bbcode($object['title']))), - '$dtstart_label' => t('Starts:'), + '$dtstart_label' => t('Start:'), '$dtstart_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))), '$finish' => (($object['nofinish']) ? false : true), - '$dtend_label' => t('Finishes:'), + '$dtend_label' => t('End:'), '$dtend_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))) + '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))), + '$allday' => $allday, + '$oneday' => $oneday )); $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( diff --git a/include/features.php b/include/features.php index 5841395c5..9528d3418 100644 --- a/include/features.php +++ b/include/features.php @@ -95,16 +95,7 @@ function get_features($filtered = true, $level = (-1)) { t('Allow event creation in timezones other than your own.'), false, get_config('feature_lock','event_tz_select'), - ], -/* - [ - 'smart_birthdays', - t('Smart Birthdays'), - t('Make birthday events timezone aware in case your friends are scattered across the planet.'), - false, - get_config('feature_lock','smart_birthdays'), ] -*/ ], diff --git a/include/zot.php b/include/zot.php index b99eeb1ec..a37b7cdb5 100644 --- a/include/zot.php +++ b/include/zot.php @@ -4430,7 +4430,7 @@ function zotinfo($arr) { $profile['description'] = $p[0]['pdesc']; $profile['birthday'] = $p[0]['dob']; - if(($profile['birthday'] != '0000-00-00') && (($bd = z_birthday($p[0]['dob'],$e['channel_timezone'])) !== '')) + if(($profile['birthday'] != '0000-00-00') && (($bd = z_birthday($p[0]['dob'],'UTC')) !== '')) $profile['next_birthday'] = $bd; if($age = age($p[0]['dob'],$e['channel_timezone'],'')) -- cgit v1.2.3 From f1b61d5882cba9584ef35f574b29050397cb8d58 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 26 May 2019 20:22:40 +0200 Subject: mod cal band-aid fixes --- include/event.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index ca08a67b5..de4e692b8 100644 --- a/include/event.php +++ b/include/event.php @@ -27,6 +27,7 @@ function format_event_html($ev) { if(! ((is_array($ev)) && count($ev))) return ''; + $tz = (($ev['timezone']) ? $ev['timezone'] : 'UTC'); $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8:01 AM @@ -39,7 +40,7 @@ function format_event_html($ev) { $o .= '
' . t('Starts:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), + . (($ev['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $ev['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtstart'] , $bd_format))) @@ -49,7 +50,7 @@ function format_event_html($ev) { $o .= '
' . t('Finishes:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), + . (($ev['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $ev['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtend'] , $bd_format ))) -- cgit v1.2.3 From 620fc06b6cd068d6819e1613c4ef0ad10f3ba2a6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 28 May 2019 23:14:22 -0700 Subject: anomolies in calls to datetime_convert in include/import --- include/import.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/import.php b/include/import.php index 92ba014d8..4da0d1a0b 100644 --- a/include/import.php +++ b/include/import.php @@ -897,9 +897,9 @@ function import_menus($channel, $menus) { $m['menu_name'] = $menu['pagetitle']; $m['menu_desc'] = $menu['desc']; if($menu['created']) - $m['menu_created'] = datetime_convert($menu['created']); + $m['menu_created'] = datetime_convert('UTC','UTC',$menu['created']); if($menu['edited']) - $m['menu_edited'] = datetime_convert($menu['edited']); + $m['menu_edited'] = datetime_convert('UTC','UTC',$menu['edited']); $m['menu_flags'] = 0; if($menu['flags']) { @@ -955,9 +955,9 @@ function sync_menus($channel, $menus) { $m['menu_name'] = $menu['pagetitle']; $m['menu_desc'] = $menu['desc']; if($menu['created']) - $m['menu_created'] = datetime_convert($menu['created']); + $m['menu_created'] = datetime_convert('UTC','UTC',$menu['created']); if($menu['edited']) - $m['menu_edited'] = datetime_convert($menu['edited']); + $m['menu_edited'] = datetime_convert('UTC','UTC',$menu['edited']); $m['menu_flags'] = 0; if($menu['flags']) { @@ -1643,12 +1643,12 @@ function import_webpage_element($element, $channel, $type) { $arr['created'] = $iteminfo[0]['created']; } else { // otherwise, generate the creation times and unique id - $arr['created'] = datetime_convert('UTC', 'UTC'); + $arr['created'] = datetime_convert(); $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'); + $arr['edited'] = datetime_convert(); // Import the actual element content $arr['body'] = file_get_contents($element['path']); // The element owner is the channel importing the elements -- cgit v1.2.3 From a8e25ccfe6a00c2b25eb75f0b20a1d854adcecb9 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 30 May 2019 13:41:32 +0200 Subject: Add single photo URL rewrite for clonned channel --- include/text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 6a2a9e427..a2dfda952 100644 --- a/include/text.php +++ b/include/text.php @@ -3091,7 +3091,7 @@ function item_url_replace($channel,&$item,$old,$new,$oldnick = '') { json_url_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['target']); } - $item['body'] = preg_replace("/(\[zrl=".preg_quote($old,'/')."\/(photos|gallery)\/".$channel['channel_address'].".+\]\[zmg=\d+x\d+\])".preg_quote($old,'/')."\/(.+\[\/zmg\])/", '${1}'.$new.'/${3}', $item['body']); + $item['body'] = preg_replace("/(\[zrl=".preg_quote($old,'/')."\/(photo|photos|gallery)\/".$channel['channel_address'].".+\]\[zmg=\d+x\d+\])".preg_quote($old,'/')."\/(.+\[\/zmg\])/", '${1}'.$new.'/${3}', $item['body']); $item['body'] = preg_replace("/".preg_quote($old,'/')."\/(search|\w+\/".$channel['channel_address'].")/", $new.'/${1}', $item['body']); $item['sig'] = base64url_encode(rsa_sign($item['body'],$channel['channel_prvkey'])); -- cgit v1.2.3 From 66c6c6c7d1c87aa50ac0fe701505802110b8eecb Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 3 Jun 2019 11:25:48 +0000 Subject: regard timezones in calendar import/export (cherry picked from commit 5b4aa1afc2d3811aae93706299dfb5d5c703198f) --- include/event.php | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index de4e692b8..b1da2de8e 100644 --- a/include/event.php +++ b/include/event.php @@ -144,6 +144,12 @@ function format_event_ical($ev) { if($ev['etype'] === 'task') return format_todo_ical($ev); + $tz = get_iconfig($ev['item_id'], 'event', 'timezone'); + if(! $tz) + $tz = 'UTC'; + + $tzid = ';TZID=' . $tz; + $o = ''; $o .= "\r\nBEGIN:VEVENT"; @@ -151,10 +157,19 @@ function format_event_ical($ev) { $o .= "\r\nCREATED:" . datetime_convert('UTC','UTC', $ev['created'],'Ymd\\THis\\Z'); $o .= "\r\nLAST-MODIFIED:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z'); $o .= "\r\nDTSTAMP:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z'); - if($ev['dtstart']) - $o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['dtstart'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : '')); - if($ev['dtend'] && ! $ev['nofinish']) - $o .= "\r\nDTEND:" . datetime_convert('UTC','UTC', $ev['dtend'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : '')); + + if($ev['adjust']) { + if($ev['dtstart']) + $o .= "\r\nDTSTART$tzid:" . datetime_convert($tz,'UTC', $ev['dtstart'],'Ymd\\THis\\Z'); + if($ev['dtend'] && ! $ev['nofinish']) + $o .= "\r\nDTEND$tzid:" . datetime_convert($tz,'UTC', $ev['dtend'],'Ymd\\THis\\Z'); + } + else { + if($ev['dtstart']) + $o .= "\r\nDTSTART;VALUE=DATE:" . datetime_convert('UTC','UTC', $ev['dtstart'],'Ymd'); + if($ev['dtend'] && ! $ev['nofinish']) + $o .= "\r\nDTEND;VALUE=DATE:" . datetime_convert('UTC','UTC', $ev['dtend'],'Ymd'); + } if($ev['summary']) { $o .= "\r\nSUMMARY:" . format_ical_text($ev['summary']); $o .= "\r\nX-ZOT-SUMMARY:" . format_ical_sourcetext($ev['summary']); @@ -856,6 +871,10 @@ function event_import_ical($ical, $uid) { $ev['external_id'] = $evuid; } + $ev['timezone'] = 'UTC'; + if(isset($ical->DTSTART['TZID'])) + $ev['timezone'] = $ical->DTSTART['TZID']; + if($ev['summary'] && $ev['dtstart']) { $ev['event_xchan'] = $channel['channel_hash']; $ev['uid'] = $channel['channel_id']; -- cgit v1.2.3 From 2b452ea3e8dca9324ebea6031b3060e6c27d5526 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 3 Jun 2019 21:03:43 +0200 Subject: fix timezone issue when importing adjusted events --- include/event.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index b1da2de8e..f1a095d1d 100644 --- a/include/event.php +++ b/include/event.php @@ -757,7 +757,6 @@ function parse_vobject($ical, $type) { function parse_ical_file($f,$uid) { - require_once('vendor/autoload.php'); $s = @file_get_contents($f); @@ -816,12 +815,23 @@ function event_import_ical($ical, $uid) { // logger('dtstart: ' . var_export($dtstart,true)); - $ev['dtstart'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $ev['timezone'] = 'UTC'; + + // Try to get an usable olson format timezone + if($ev['adjust']) { + //TODO: we should pass the vcalendar to getTimeZone() to be more accurate + // we do not have it here since parse_ical_file() is passing the vevent only. + $timezone_obj = \Sabre\VObject\TimeZoneUtil::getTimeZone($ical->DTSTART['TZID']); + $timezone = $timezone_obj->getName(); + $ev['timezone'] = $timezone; + } + + $ev['dtstart'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),$ev['timezone'], $dtstart->format(\DateTime::W3C)); if(isset($ical->DTEND)) { $dtend = $ical->DTEND->getDateTime(); - $ev['dtend'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $ev['dtend'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),$ev['timezone'], $dtend->format(\DateTime::W3C)); } else { @@ -871,10 +881,6 @@ function event_import_ical($ical, $uid) { $ev['external_id'] = $evuid; } - $ev['timezone'] = 'UTC'; - if(isset($ical->DTSTART['TZID'])) - $ev['timezone'] = $ical->DTSTART['TZID']; - if($ev['summary'] && $ev['dtstart']) { $ev['event_xchan'] = $channel['channel_hash']; $ev['uid'] = $channel['channel_id']; -- cgit v1.2.3 From f1b54cf0a49afcaa7b5a8d5f8fb35a4da72b6b85 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 3 Jun 2019 22:37:03 +0200 Subject: do not change default timezone in parse_ical_file() --- include/event.php | 9 --------- 1 file changed, 9 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index f1a095d1d..6689919cf 100644 --- a/include/event.php +++ b/include/event.php @@ -760,13 +760,6 @@ function parse_ical_file($f,$uid) { $s = @file_get_contents($f); - // Change the current timezone to something besides UTC. - // Doesn't matter what it is, as long as it isn't UTC. - // Save the current timezone so we can reset it when we're done processing. - - $saved_timezone = date_default_timezone_get(); - date_default_timezone_set('Australia/Sydney'); - $ical = VObject\Reader::read($s); if($ical) { @@ -782,8 +775,6 @@ function parse_ical_file($f,$uid) { } } - date_default_timezone_set($saved_timezone); - if($ical) return true; -- cgit v1.2.3 From f3b6708a92cf347ea65b0db88a6b112b28228f14 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 11 Jun 2019 18:00:42 -0700 Subject: attach sync issues --- include/import.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/import.php b/include/import.php index 4da0d1a0b..24ad1b901 100644 --- a/include/import.php +++ b/include/import.php @@ -1177,7 +1177,7 @@ function sync_files($channel, $files) { convert_oldfields($att,'data','content'); if($att['deleted']) { - attach_delete($channel,$att['hash']); + attach_delete($channel['channel_id'],$att['hash']); continue; } @@ -1383,12 +1383,14 @@ function sync_files($channel, $files) { ); } - if(intval($p['imgscale']) === 0 && $p['os_storage']) - $p['content'] = $store_path; - else + if(intval($p['os_storage'])) { + $p['content'] = $store_path . ((intval($p['imgscale'])) ? '-' . $p['imgscale'] : ''); + } + else { $p['content'] = (($p['content'])? base64_decode($p['content']) : ''); + } - if(intval($p['imgscale']) && (! empty($p['content']))) { + if (intval($p['imgscale']) && ((intval($p['os_storage'])) || (! $p['content']))) { $time = datetime_convert(); -- cgit v1.2.3 From decd0dc035cce0918519bef77742ff87db23e3f3 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 12 Jun 2019 11:27:39 +0200 Subject: more work on event item deletion --- include/items.php | 12 +++++++++++- include/zot.php | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 95b696034..b6d8eb652 100755 --- a/include/items.php +++ b/include/items.php @@ -3740,6 +3740,13 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal if($ok_to_delete) { + if ($item['resource_type'] === 'event') { + $x = q("delete from event where event_hash = '%s' and uid = %d", + dbesc($item['resource_id']), + intval($item['uid']) + ); + } + // set the deleted flag immediately on this item just in case the // hook calls a remote process which loops. We'll delete it properly in a second. @@ -3816,7 +3823,10 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal */ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) { - $linked_item = (($item['resource_id']) ? true : false); + //$linked_item = (($item['resource_id']) ? true : false); + + $linked_resource_types = [ 'photo' ]; + $linked_item = (($item['resource_id'] && $item['resource_type'] && in_array($item['resource_type'], $linked_resource_types)) ? true : false); logger('item: ' . $item['id'] . ' stage: ' . $stage . ' force: ' . $force, LOGGER_DATA); diff --git a/include/zot.php b/include/zot.php index a37b7cdb5..9dd9aceff 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2278,6 +2278,25 @@ function delete_imported_item($sender, $item, $uid, $relay) { return false; } + if ($item['obj_type'] == ACTIVITY_OBJ_EVENT) { + $i = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1", + dbesc($item['uuid']), + intval($uid) + ); + if ($i) { + if ($i[0]['event_xchan'] === $sender['hash']) { + q("delete from event where event_hash = '%s' and uid = %d", + dbesc($item['uuid']), + intval($uid) + ); + } + else { + logger('delete linked event: not owner'); + return; + } + } + } + require_once('include/items.php'); if($item_found) { -- cgit v1.2.3 From bc34167c8490c2dad5fcd6553b27b5df54449c39 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 12 Jun 2019 12:46:29 +0200 Subject: port delete fixes from zap --- include/zot.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 9dd9aceff..5fd900765 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2241,7 +2241,7 @@ function delete_imported_item($sender, $item, $uid, $relay) { $item_found = false; $post_id = 0; - $r = q("select id, author_xchan, owner_xchan, source_xchan, item_deleted from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' ) + $r = q("select * from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' ) and mid = '%s' and uid = %d limit 1", dbesc($sender['hash']), dbesc($sender['hash']), @@ -2251,10 +2251,13 @@ function delete_imported_item($sender, $item, $uid, $relay) { ); if($r) { - if($r[0]['author_xchan'] === $sender['hash'] || $r[0]['owner_xchan'] === $sender['hash'] || $r[0]['source_xchan'] === $sender['hash']) + + $stored = $r[0]; + + if($stored['author_xchan'] === $sender['hash'] || $stored['owner_xchan'] === $sender['hash'] || $stored['source_xchan'] === $sender['hash']) $ownership_valid = true; - $post_id = $r[0]['id']; + $post_id = $stored['id']; $item_found = true; } else { @@ -2278,15 +2281,15 @@ function delete_imported_item($sender, $item, $uid, $relay) { return false; } - if ($item['obj_type'] == ACTIVITY_OBJ_EVENT) { + if ($stored['resource_type'] === 'event') { $i = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1", - dbesc($item['uuid']), + dbesc($stored['resource_id']), intval($uid) ); if ($i) { if ($i[0]['event_xchan'] === $sender['hash']) { q("delete from event where event_hash = '%s' and uid = %d", - dbesc($item['uuid']), + dbesc($stored['resource_id']), intval($uid) ); } @@ -2300,7 +2303,7 @@ function delete_imported_item($sender, $item, $uid, $relay) { require_once('include/items.php'); if($item_found) { - if(intval($r[0]['item_deleted'])) { + if(intval($stored['item_deleted'])) { logger('delete_imported_item: item was already deleted'); if(! $relay) return false; @@ -2312,10 +2315,10 @@ function delete_imported_item($sender, $item, $uid, $relay) { // back, and we aren't going to (or shouldn't at any rate) delete it again in the future - so losing // this information from the metadata should have no other discernible impact. - if (($r[0]['id'] != $r[0]['parent']) && intval($r[0]['item_origin'])) { + if (($stored['id'] != $stored['parent']) && intval($stored['item_origin'])) { q("update item set item_origin = 0 where id = %d and uid = %d", - intval($r[0]['id']), - intval($r[0]['uid']) + intval($stored['id']), + intval($stored['uid']) ); } } -- cgit v1.2.3 From 801ab611ede45921d1d6869fa65fc3fbf941d666 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 13 Jun 2019 13:34:04 +0200 Subject: more work on linked item/resource deletion for photos and events, deprecate the force flag in drop_item() and comment out goaway() in drop_item(). --- include/attach.php | 7 +++- include/items.php | 115 ++++++++++++++++++++++------------------------------- 2 files changed, 53 insertions(+), 69 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index f169e0669..80efe0838 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1514,12 +1514,15 @@ function attach_delete($channel_id, $resource, $is_photo = 0) { function attach_drop_photo($channel_id,$resource) { - $x = q("select id, item_hidden from item where resource_id = '%s' and resource_type = 'photo' and uid = %d", + $x = q("select id, item_hidden from item where resource_id = '%s' and resource_type = 'photo' and uid = %d and item_deleted = 0", dbesc($resource), intval($channel_id) ); + if($x) { - drop_item($x[0]['id'],false,(($x[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1),true); + $stage = (($x[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1); + $interactive = (($x[0]['item_hidden']) ? false : true); + drop_item($x[0]['id'], $interactive, $stage); } $r = q("SELECT content FROM photo WHERE resource_id = '%s' AND uid = %d AND os_storage = 1", diff --git a/include/items.php b/include/items.php index b6d8eb652..35a5a6124 100755 --- a/include/items.php +++ b/include/items.php @@ -3663,7 +3663,7 @@ function retain_item($id) { ); } -function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force = false) { +function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL) { $uid = 0; if(! local_channel() && ! remote_channel()) @@ -3671,7 +3671,7 @@ function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force if(count($items)) { foreach($items as $item) { - $owner = drop_item($item,$interactive,$stage,$force); + $owner = drop_item($item,$interactive,$stage); if($owner && ! $uid) $uid = $owner; } @@ -3694,12 +3694,7 @@ function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force // $stage = 1 => set deleted flag on the item and perform intial notifications // $stage = 2 => perform low level delete at a later stage -function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = false) { - - // These resource types have linked items that should only be removed at the same time - // as the linked resource; if we encounter one set it to item_hidden rather than item_deleted. - - $linked_resource_types = [ 'photo' ]; +function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { // locate item to be deleted @@ -3711,13 +3706,11 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal if(! $interactive) return 0; notice( t('Item not found.') . EOL); - goaway(z_root() . '/' . $_SESSION['return_url']); + //goaway(z_root() . '/' . $_SESSION['return_url']); } $item = $r[0]; - $linked_item = (($item['resource_id'] && $item['resource_type'] && in_array($item['resource_type'], $linked_resource_types)) ? true : false); - $ok_to_delete = false; // system deletion @@ -3740,26 +3733,12 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal if($ok_to_delete) { - if ($item['resource_type'] === 'event') { - $x = q("delete from event where event_hash = '%s' and uid = %d", - dbesc($item['resource_id']), - intval($item['uid']) - ); - } - // set the deleted flag immediately on this item just in case the // hook calls a remote process which loops. We'll delete it properly in a second. - if(($linked_item) && (! $force)) { - $r = q("UPDATE item SET item_hidden = 1 WHERE id = %d", - intval($item['id']) - ); - } - else { - $r = q("UPDATE item SET item_deleted = 1 WHERE id = %d", - intval($item['id']) - ); - } + $r = q("UPDATE item SET item_deleted = 1 WHERE id = %d", + intval($item['id']) + ); $arr = [ 'item' => $item, @@ -3799,14 +3778,13 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal if((intval($item['item_wall']) && ($stage != DROPITEM_PHASE2)) || ($stage == DROPITEM_PHASE1)) { Master::Summon([ 'Notifier','drop',$notify_id ]); } - - goaway(z_root() . '/' . $_SESSION['return_url']); + //goaway(z_root() . '/' . $_SESSION['return_url']); } else { if(! $interactive) return 0; notice( t('Permission denied.') . EOL); - goaway(z_root() . '/' . $_SESSION['return_url']); + //goaway(z_root() . '/' . $_SESSION['return_url']); } } @@ -3821,14 +3799,9 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal * @param boolean $force * @return boolean */ -function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) { - - //$linked_item = (($item['resource_id']) ? true : false); - - $linked_resource_types = [ 'photo' ]; - $linked_item = (($item['resource_id'] && $item['resource_type'] && in_array($item['resource_type'], $linked_resource_types)) ? true : false); +function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL) { - logger('item: ' . $item['id'] . ' stage: ' . $stage . ' force: ' . $force, LOGGER_DATA); + logger('item: ' . $item['id'] . ' stage: ' . $stage, LOGGER_DATA); switch($stage) { case DROPITEM_PHASE2: @@ -3841,42 +3814,50 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) { break; case DROPITEM_PHASE1: - if($linked_item && ! $force) { - $r = q("UPDATE item SET item_hidden = 1, - changed = '%s', edited = '%s' WHERE id = %d", - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval($item['id']) - ); - } - else { - $r = q("UPDATE item set item_deleted = 1, changed = '%s', edited = '%s' where id = %d", - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval($item['id']) - ); - } - + $r = q("UPDATE item set item_deleted = 1, changed = '%s', edited = '%s' where id = %d", + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($item['id']) + ); break; case DROPITEM_NORMAL: default: - if($linked_item && ! $force) { - $r = q("UPDATE item SET item_hidden = 1, - changed = '%s', edited = '%s' WHERE id = %d", - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval($item['id']) - ); - } - else { - $r = q("DELETE FROM item WHERE id = %d", - intval($item['id']) - ); - } + $r = q("DELETE FROM item WHERE id = %d", + intval($item['id']) + ); break; } + // immediately remove local linked resources + + if($item['resource_type'] === 'event') { + $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1", + dbesc($item['resource_id']), + intval($item['uid']) + ); + + $sync_data = $r[0]; + + $x = q("delete from event where event_hash = '%s' and uid = %d", + dbesc($item['resource_id']), + intval($item['uid']) + ); + + if($x) { + $sync_data['event_deleted'] = 1; + build_sync_packet($item['uid'], ['event' => [$syncsync_data]]); + } + } + + if($item['resource_type'] === 'photo') { + attach_delete($item['uid'], $item['resource_id'], true ); + $channel = channelx_by_n($item['uid']); + $sync_data = attach_export_data($channel, $item['resource_id'], true); + if($sync_data) + build_sync_packet($item['uid'], ['file' => [$sync_data]]); + } + // immediately remove any undesired profile likes. q("delete from likes where iid = %d and channel_id = %d", -- cgit v1.2.3 From 48604041e8b2f42c88b741dedae480029db72fdd Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 14 Jun 2019 09:12:47 +0200 Subject: fix typo --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 35a5a6124..9ceb91519 100755 --- a/include/items.php +++ b/include/items.php @@ -3846,7 +3846,7 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL) { if($x) { $sync_data['event_deleted'] = 1; - build_sync_packet($item['uid'], ['event' => [$syncsync_data]]); + build_sync_packet($item['uid'], ['event' => [$sync_data]]); } } -- cgit v1.2.3 From abeb924554cc4a91ed5e420a9f426ced3e2a085a Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 14 Jun 2019 20:53:43 +0200 Subject: Add signatures processing for private messages --- include/message.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/message.php b/include/message.php index 2486beb83..7d05b9ab7 100644 --- a/include/message.php +++ b/include/message.php @@ -19,7 +19,7 @@ function mail_prepare_binary($item) { // send a private message -function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $replyto = '', $expires = NULL_DATE, $mimetype = 'text/bbcode', $raw = false) { +function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $replyto = '', $expires = NULL_DATE, $mimetype = 'text/bbcode', $raw = false, $sig = '') { $ret = array('success' => false); $is_reply = false; @@ -175,8 +175,7 @@ function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $rep $subject = str_rot47(base64url_encode($subject)); if(($body )&& (! $raw)) $body = str_rot47(base64url_encode($body)); - - $sig = ''; // placeholder + $mimetype = ''; //placeholder $r = q("INSERT INTO mail ( account_id, conv_guid, mail_obscured, channel_id, from_xchan, to_xchan, mail_mimetype, title, body, sig, attach, mid, parent_mid, created, expires, mail_isreply, mail_raw ) -- cgit v1.2.3 From 86f4a8d33afbdda7f5f2ace003ad237bde387819 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 14 Jun 2019 20:54:42 +0200 Subject: Add signatures processing for private messages --- include/items.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index 9ceb91519..ed5572233 100755 --- a/include/items.php +++ b/include/items.php @@ -1457,6 +1457,7 @@ function encode_mail($item,$extended = false) { $x['to'] = encode_item_xchan($item['to']); $x['raw'] = $item['mail_raw']; $x['mimetype'] = $item['mail_mimetype']; + $x['sig'] = $item['sig']; if($item['attach']) $x['attach'] = json_decode($item['attach'],true); @@ -1516,6 +1517,9 @@ function get_mail_elements($x) { $arr['expires'] = datetime_convert('UTC','UTC',$x['expires']); $arr['mail_flags'] = 0; + + if(array_key_exists('sig',$x)) + $arr['sig'] = $x['sig']; if($x['flags'] && is_array($x['flags'])) { if(in_array('recalled',$x['flags'])) { -- cgit v1.2.3 From 134dfb8804429ba68c613bb98900d468fdfdba49 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 14 Jun 2019 20:56:00 +0200 Subject: Formatting --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index ed5572233..0af119cc9 100755 --- a/include/items.php +++ b/include/items.php @@ -1457,7 +1457,7 @@ function encode_mail($item,$extended = false) { $x['to'] = encode_item_xchan($item['to']); $x['raw'] = $item['mail_raw']; $x['mimetype'] = $item['mail_mimetype']; - $x['sig'] = $item['sig']; + $x['sig'] = $item['sig']; if($item['attach']) $x['attach'] = json_decode($item['attach'],true); -- cgit v1.2.3 From 8535eb7bf5a3836502a4e5ded93c453abf723370 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 17 Jun 2019 10:10:44 +0200 Subject: update feature set --- include/features.php | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'include') diff --git a/include/features.php b/include/features.php index 9528d3418..87df0c50d 100644 --- a/include/features.php +++ b/include/features.php @@ -280,20 +280,6 @@ function get_features($filtered = true, $level = (-1)) { ], - 'events' => [ - - t('Events'), - - [ - 'events_cal_first_day', - t('Start calendar week on Monday'), - t('Default is Sunday'), - false, - get_config('feature_lock','events_cal_first_day') - ] - - ], - 'manage' => [ t('Manage'), -- cgit v1.2.3 From becaa3b920bfe87c031c01bdf35d35db5c82e31e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 17 Jun 2019 18:30:05 -0700 Subject: minor zot6 compatibility issues uncovered through daily use --- include/photos.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/photos.php b/include/photos.php index 7ea2729ae..7fd712f3e 100644 --- a/include/photos.php +++ b/include/photos.php @@ -390,7 +390,7 @@ function photo_upload($channel, $observer, $args) { 'edited' => $p['edited'], 'id' => z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash, 'link' => $link, - 'body' => $obj_body + 'body' => $summary ); $target = array( -- cgit v1.2.3 From 983d6d3b4228bdfe7ac0c08fcbdaf2ca687f53a2 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 18 Jun 2019 22:17:50 +0200 Subject: Include Zot6 hubs in the Grid scope --- include/zid.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/zid.php b/include/zid.php index ed79de76a..564ec740c 100644 --- a/include/zid.php +++ b/include/zid.php @@ -13,7 +13,7 @@ function is_matrix_url($url) { if(array_key_exists($m['host'],$remembered)) return $remembered[$m['host']]; - $r = q("select hubloc_url from hubloc where hubloc_host = '%s' and hubloc_network = 'zot' limit 1", + $r = q("select hubloc_url from hubloc where hubloc_host = '%s' and hubloc_network LIKE 'zot%' limit 1", dbesc($m['host']) ); if($r) { -- cgit v1.2.3 From 75746d714a2e7c7ae67fc03d24ddea6a61a2e5e1 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 19 Jun 2019 09:39:56 +0200 Subject: Update zid.php --- include/zid.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/zid.php b/include/zid.php index 564ec740c..27ef0cefa 100644 --- a/include/zid.php +++ b/include/zid.php @@ -13,7 +13,7 @@ function is_matrix_url($url) { if(array_key_exists($m['host'],$remembered)) return $remembered[$m['host']]; - $r = q("select hubloc_url from hubloc where hubloc_host = '%s' and hubloc_network LIKE 'zot%' limit 1", + $r = q("select hubloc_url from hubloc where hubloc_host = '%s' and hubloc_network in ('zot', 'zot6') limit 1", dbesc($m['host']) ); if($r) { -- cgit v1.2.3 From 9d156141b1205e48bbb3008f2a3040caa4c33192 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 19 Jun 2019 17:32:38 -0700 Subject: changes to support direct messages in zot6 (set item.item_private = 2 when private mentions are used and federate with zot:directMessage attribute which aligns with litepub:directMessage) --- include/items.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 95b696034..26a74fd86 100755 --- a/include/items.php +++ b/include/items.php @@ -1984,11 +1984,12 @@ function item_store($arr, $allow_exec = false, $deliver = true) { unset($arr['iconfig']); } - - if(strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid) || strlen($public_policy)) - $private = 1; - else - $private = $arr['item_private']; + $private = intval($arr['item_private']); + if (! $private) { + if (strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid)) { + $private = 1; + } + } $arr['parent'] = $parent_id; $arr['allow_cid'] = $allow_cid; @@ -4620,12 +4621,12 @@ function set_linkified_perms($linkified, &$str_contact_allow, &$str_group_allow, if(strpos($access_tag,'cid:') === 0) { $str_contact_allow .= '<' . substr($access_tag,4) . '>'; $access_tag = ''; - $private = 1; + $private = 2; } elseif(strpos($access_tag,'gid:') === 0) { $str_group_allow .= '<' . substr($access_tag,4) . '>'; $access_tag = ''; - $private = 1; + $private = 2; } } } -- cgit v1.2.3 From 3dd6499ac4bfbb7ef52ba3a224ec7a35ff481a48 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 21 Jun 2019 10:37:09 +0200 Subject: fix mid not dbesc'd. the comment was no longer true. this fixes an issue with mid's that contain single quotes --- include/items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index d2dba9677..4fc659926 100755 --- a/include/items.php +++ b/include/items.php @@ -2012,7 +2012,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { // find the item we just created $r = q("SELECT * FROM item WHERE mid = '%s' AND uid = %d and revision = %d ORDER BY id ASC ", - $arr['mid'], // already dbesc'd + dbesc($arr['mid']), intval($arr['uid']), intval($arr['revision']) ); @@ -2033,7 +2033,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { if(count($r) > 1) { logger('item_store: duplicated post occurred. Removing duplicates.'); q("DELETE FROM item WHERE mid = '%s' AND uid = %d AND id != %d ", - $arr['mid'], + dbesc($arr['mid']), intval($arr['uid']), intval($current_post) ); -- cgit v1.2.3 From 82478eef0960facad62d93c9bd8fcadd56ad4ead Mon Sep 17 00:00:00 2001 From: "DM42.Net (Matt Dent)" Date: Fri, 21 Jun 2019 14:23:16 -0400 Subject: export all items except photos --- include/channel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index e4b6df47b..0280cd1cd 100644 --- a/include/channel.php +++ b/include/channel.php @@ -1161,7 +1161,7 @@ function channel_export_items_date($channel_id, $start, $finish) { $ret['relocate'] = [ 'channel_address' => $ch['channel_address'], 'url' => z_root()]; } - $r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and created >= '%s' and created <= '%s' and resource_type = '' order by created", + $r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and created >= '%s' and created <= '%s' and resource_type != 'photo' order by created", intval(ITEM_TYPE_POST), intval($channel_id), dbesc($start), @@ -1223,7 +1223,7 @@ function channel_export_items_page($channel_id, $start, $finish, $page = 0, $lim $ret['relocate'] = [ 'channel_address' => $ch['channel_address'], 'url' => z_root()]; } - $r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and resource_type = '' and created >= '%s' and created <= '%s' order by created limit %d offset %d", + $r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and resource_type != 'photo' and created >= '%s' and created <= '%s' order by created limit %d offset %d", intval(ITEM_TYPE_POST), intval($channel_id), dbesc($start), -- cgit v1.2.3 From e8918ca149f9eb0ea4148431772b9e5090f3ea7f Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 21 Jun 2019 22:27:27 +0200 Subject: Respect photo thumbnails storage in import --- include/photo/photo_driver.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index c11580bdc..2ca3acf7d 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -371,21 +371,19 @@ function import_channel_photo($photo, $type, $aid, $uid) { // photo size $img->scaleImageSquare(300); - $r = $img->save($p); + $r = $img->storeThumbnail($p, PHOTO_RES_PROFILE_300); if($r === false) $photo_failure = true; // thumb size $img->scaleImage(80); - $p['imgscale'] = 5; - $r = $img->save($p); + $r = $img->storeThumbnail($p, PHOTO_RES_PROFILE_80); if($r === false) $photo_failure = true; // micro size $img->scaleImage(48); - $p['imgscale'] = 6; - $r = $img->save($p); + $r = $img->storeThumbnail($p, PHOTO_RES_PROFILE_48); if($r === false) $photo_failure = true; -- cgit v1.2.3 From 8730bbac2fd93a9ddc9922f7fed3d89abad1eccc Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 21 Jun 2019 22:42:38 +0200 Subject: Revert "Respect photo thumbnails storage in import" This reverts commit e8918ca149f9eb0ea4148431772b9e5090f3ea7f --- include/photo/photo_driver.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index 2ca3acf7d..c11580bdc 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -371,19 +371,21 @@ function import_channel_photo($photo, $type, $aid, $uid) { // photo size $img->scaleImageSquare(300); - $r = $img->storeThumbnail($p, PHOTO_RES_PROFILE_300); + $r = $img->save($p); if($r === false) $photo_failure = true; // thumb size $img->scaleImage(80); - $r = $img->storeThumbnail($p, PHOTO_RES_PROFILE_80); + $p['imgscale'] = 5; + $r = $img->save($p); if($r === false) $photo_failure = true; // micro size $img->scaleImage(48); - $r = $img->storeThumbnail($p, PHOTO_RES_PROFILE_48); + $p['imgscale'] = 6; + $r = $img->save($p); if($r === false) $photo_failure = true; -- cgit v1.2.3 From b1b415ec5b46f56a335a31527c9f987854be7282 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 21 Jun 2019 23:15:16 +0200 Subject: Fix thumbnails processing logic on files sync --- include/import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/import.php b/include/import.php index 24ad1b901..caf25f5d2 100644 --- a/include/import.php +++ b/include/import.php @@ -1390,7 +1390,7 @@ function sync_files($channel, $files) { $p['content'] = (($p['content'])? base64_decode($p['content']) : ''); } - if (intval($p['imgscale']) && ((intval($p['os_storage'])) || (! $p['content']))) { + if(intval($p['imgscale'])) { $time = datetime_convert(); -- cgit v1.2.3 From 07f850ed15a0af3037b96c0849b949b0bfac791b Mon Sep 17 00:00:00 2001 From: "DM42.Net (Matt Dent)" Date: Sun, 23 Jun 2019 20:23:03 -0400 Subject: Make export_page API endpoint match ZAP --- include/api_zot.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/api_zot.php b/include/api_zot.php index b332aea71..287720484 100644 --- a/include/api_zot.php +++ b/include/api_zot.php @@ -6,8 +6,8 @@ api_register_func('api/export/basic','api_export_basic', true); api_register_func('api/red/channel/export/basic','api_export_basic', true); api_register_func('api/z/1.0/channel/export/basic','api_export_basic', true); - api_register_func('api/red/item/export/page','api_item_export_page', true); - api_register_func('api/z/1.0/item/export/page','api_item_export_page', true); + api_register_func('api/red/item/export_page','api_item_export_page', true); + api_register_func('api/z/1.0/item/export_page','api_item_export_page', true); api_register_func('api/red/channel/list','api_channel_list', true); api_register_func('api/z/1.0/channel/list','api_channel_list', true); api_register_func('api/red/channel/stream','api_channel_stream', true); -- cgit v1.2.3 From 4f280b5497325c7e7389096cb39f1f409de2638c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 25 Jun 2019 18:47:16 -0700 Subject: allow api login by address or url (url will use zot6 hubloc records, address can use either zot or zot6 hubloc records) --- include/api_auth.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/api_auth.php b/include/api_auth.php index 23ab9c946..9235bd28c 100644 --- a/include/api_auth.php +++ b/include/api_auth.php @@ -96,11 +96,15 @@ function api_login(&$a){ if($sigblock) { $keyId = str_replace('acct:','',$sigblock['keyId']); if($keyId) { - $r = q("select * from hubloc where hubloc_addr = '%s' limit 1", + $r = q("select * from hubloc where ( hubloc_addr = '%s' or hubloc_id_url = '%s' ) limit 1", + dbesc($keyId), dbesc($keyId) ); if($r) { $c = channelx_by_hash($r[0]['hubloc_hash']); + if (! $c) { + $c = channelx_by_portid($r[0]['hubloc_hash']); + } if($c) { $a = q("select * from account where account_id = %d limit 1", intval($c['channel_account_id']) -- cgit v1.2.3 From cf844cb27c02c3aae636eb1aa1587b1d5e3e81a0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 26 Jun 2019 21:45:21 -0700 Subject: http signature consolidation --- include/import.php | 6 ++++-- include/xchan.php | 2 +- include/zot.php | 5 ++--- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/import.php b/include/import.php index 24ad1b901..1843c9741 100644 --- a/include/import.php +++ b/include/import.php @@ -2,6 +2,8 @@ use Zotlabs\Lib\IConfig; +use Zotlabs\Web\HTTPSig; + require_once('include/menu.php'); require_once('include/perm_upgrade.php'); @@ -1329,7 +1331,7 @@ function sync_files($channel, $files) { $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'); + $headers = HTTPSig::create_sig($headers,$channel['channel_prvkey'], 'acct:' . channel_reddress($channel),true,'sha512'); $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]); fclose($fp); @@ -1415,7 +1417,7 @@ function sync_files($channel, $files) { $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'); + $headers = HTTPSig::create_sig($headers,$channel['channel_prvkey'],'acct:' . channel_reddress($channel),true,'sha512'); $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]); fclose($fp); diff --git a/include/xchan.php b/include/xchan.php index 4fcdf9fce..d69d707aa 100644 --- a/include/xchan.php +++ b/include/xchan.php @@ -1,6 +1,6 @@ Date: Thu, 27 Jun 2019 17:05:25 -0700 Subject: support zot and zot6 in social graph operations (suggestions, common friends) --- include/socgraph.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/socgraph.php b/include/socgraph.php index 6cddbbaac..3d26f5cfd 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -1,5 +1,10 @@ 0 and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = '' and mitem_channel_id = %d", + $rooms = q("select * from menu_item where ( mitem_flags & " . intval(MENU_ITEM_CHATROOM) . " ) > 0 and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = '' and mitem_channel_id = %d", intval($channel_id) ); } -- cgit v1.2.3 From 60c003733e7fed70f28eadaf3d9abcf16ec3a8ab Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 27 Jun 2019 17:36:29 -0700 Subject: photo objects: incorrect media type on links --- include/photos.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/photos.php b/include/photos.php index 7fd712f3e..ee662f707 100644 --- a/include/photos.php +++ b/include/photos.php @@ -261,7 +261,7 @@ function photo_upload($channel, $observer, $args) { $r0 = $ph->save($p); $link[0] = array( 'rel' => 'alternate', - 'type' => 'text/html', + 'type' => $type, 'href' => z_root() . '/photo/' . $photo_hash . '-0.' . $ph->getExt(), 'width' => $width, 'height' => $height @@ -280,7 +280,7 @@ function photo_upload($channel, $observer, $args) { $r1 = $ph->storeThumbnail($p, PHOTO_RES_1024); $link[1] = array( 'rel' => 'alternate', - 'type' => 'text/html', + 'type' => $type, 'href' => z_root() . '/photo/' . $photo_hash . '-1.' . $ph->getExt(), 'width' => $ph->getWidth(), 'height' => $ph->getHeight() @@ -294,7 +294,7 @@ function photo_upload($channel, $observer, $args) { $r2 = $ph->storeThumbnail($p, PHOTO_RES_640); $link[2] = array( 'rel' => 'alternate', - 'type' => 'text/html', + 'type' => $type, 'href' => z_root() . '/photo/' . $photo_hash . '-2.' . $ph->getExt(), 'width' => $ph->getWidth(), 'height' => $ph->getHeight() @@ -308,7 +308,7 @@ function photo_upload($channel, $observer, $args) { $r3 = $ph->storeThumbnail($p, PHOTO_RES_320); $link[3] = array( 'rel' => 'alternate', - 'type' => 'text/html', + 'type' => $type, 'href' => z_root() . '/photo/' . $photo_hash . '-3.' . $ph->getExt(), 'width' => $ph->getWidth(), 'height' => $ph->getHeight() -- cgit v1.2.3 From 98100520eba567138799997506027daa10063f55 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 28 Jun 2019 16:21:54 -0700 Subject: begin directory migration to zot6, see the code comments --- include/dir_fns.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'include') diff --git a/include/dir_fns.php b/include/dir_fns.php index 2bd1228ec..0b404925d 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -329,6 +329,32 @@ function update_directory_entry($ud) { if ($ud['ud_addr'] && (! ($ud['ud_flags'] & UPDATE_FLAGS_DELETED))) { $success = false; + + // directory migration phase 1 (Macgirvin - 29-JUNE-2019) + // fetch zot6 info (if available) as well as historical zot info (if available) + // Once this has been running for > 1 month on the primary directory we can deprecate the historical info and + // modify the directory search to only return zot6 entries, and also modify this function + // to *only* fetch the zot6 entries. + // Otherwise we'll be showing duplicates or have a mostly empty directory for a good chunk of + // the transition period. Directory server load will likely increase "moderately" during this transition. + // The one month counter begins when the primary directory has upgraded to a release which uses this code. + // Hubzilla channels running traditional zot which have not upgraded can or will be dropped from the directory or + // "not found" at the end of the transition period as the directory will only serve zot6 entries at that time. + + $uri = \Zotlabs\Lib\Webfinger::zot_url($ud['ud_addr']); + if($uri) { + $record = \Zotlabs\Lib\Zotfinger::exec($url,$channel); + + // Check the HTTP signature + + $hsig = $record['signature']; + if($hsig && $hsig['signer'] === $url && $hsig['header_valid'] === true && $hsig['content_valid'] === true) { + $x = \Zotlabs\Zot\Libzot::import_xchan($record['data'], 0, $ud); + if($x['success']) { + $success = true; + } + } + } $x = zot_finger($ud['ud_addr'], ''); if ($x['success']) { $j = json_decode($x['body'], true); -- cgit v1.2.3 From d53c98860dbf5a9fa4e1b25aa06957034783bb9f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 28 Jun 2019 16:29:56 -0700 Subject: minor fix --- include/dir_fns.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/dir_fns.php b/include/dir_fns.php index 0b404925d..d4f55a469 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -343,7 +343,7 @@ function update_directory_entry($ud) { $uri = \Zotlabs\Lib\Webfinger::zot_url($ud['ud_addr']); if($uri) { - $record = \Zotlabs\Lib\Zotfinger::exec($url,$channel); + $record = \Zotlabs\Lib\Zotfinger::exec($uri); // Check the HTTP signature -- cgit v1.2.3 From 4aa59226d7f11e4d97bb3bff649cc0e2ecbbe5e8 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 28 Jun 2019 16:49:23 -0700 Subject: I wonder how long zot_finger() has been missing and how this may have affected the directory servers. --- include/dir_fns.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/dir_fns.php b/include/dir_fns.php index d4f55a469..068ab4831 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -355,7 +355,7 @@ function update_directory_entry($ud) { } } } - $x = zot_finger($ud['ud_addr'], ''); + $x = \Zotlabs\Zot\Finger::run($ud['ud_addr'], ''); if ($x['success']) { $j = json_decode($x['body'], true); if ($j) -- cgit v1.2.3 From 65cd33cb153ccc167567e0e4fbb3bf3856408add Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 28 Jun 2019 16:59:15 -0700 Subject: zot_finger() and Zotlabs\Zot\Finger::run() have different output. Adjusted accordingly. --- include/dir_fns.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/dir_fns.php b/include/dir_fns.php index 068ab4831..08a9fb653 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -357,11 +357,8 @@ function update_directory_entry($ud) { } $x = \Zotlabs\Zot\Finger::run($ud['ud_addr'], ''); if ($x['success']) { - $j = json_decode($x['body'], true); - if ($j) - $success = true; - - $y = import_xchan($j, 0, $ud); + import_xchan($x, 0, $ud); + $success = true; } if (! $success) { q("update updates set ud_last = '%s' where ud_addr = '%s'", -- cgit v1.2.3 From 090d9210062e1ab5a666210551eed30a61fd609c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 12 Jul 2019 12:43:12 +0200 Subject: webfinger: better handling of URLs that contain a @ --- include/network.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/network.php b/include/network.php index c754625cd..f6992291d 100644 --- a/include/network.php +++ b/include/network.php @@ -1183,12 +1183,12 @@ function discover_by_webbie($webbie, $protocol = '') { */ function webfinger_rfc7033($webbie, $zot = false) { - if(strpos($webbie,'@')) { + if(filter_var($webbie, FILTER_VALIDATE_EMAIL)) { $lhs = substr($webbie,0,strpos($webbie,'@')); $rhs = substr($webbie,strpos($webbie,'@')+1); $resource = urlencode('acct:' . $webbie); } - else { + elseif(filter_var($webbie, FILTER_VALIDATE_URL)) { $m = parse_url($webbie); if($m) { if($m['scheme'] !== 'https') @@ -1197,9 +1197,10 @@ function webfinger_rfc7033($webbie, $zot = false) { $rhs = $m['host'] . (($m['port']) ? ':' . $m['port'] : ''); $resource = urlencode($webbie); } - else - return false; } + else + return false; + logger('fetching url from resource: ' . $rhs . ':' . $webbie); $counter = 0; @@ -1217,7 +1218,7 @@ function webfinger_rfc7033($webbie, $zot = false) { function old_webfinger($webbie) { $host = ''; - if(strstr($webbie,'@')) + if(filter_var($webbie, FILTER_VALIDATE_EMAIL)) $host = substr($webbie,strpos($webbie,'@') + 1); if(strlen($host)) { -- cgit v1.2.3 From db6e4d1c32f4260873b3fd1f9367390798c09ce6 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 13 Jul 2019 19:59:52 +0200 Subject: admin should be allowed to delete any item --- include/items.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 4fc659926..84bfc263b 100755 --- a/include/items.php +++ b/include/items.php @@ -3722,13 +3722,12 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { if(! $interactive) $ok_to_delete = true; - // owner deletion - if(local_channel() && local_channel() == $item['uid']) + // admin deletion + if(is_site_admin()) $ok_to_delete = true; - // sys owned item, requires site admin to delete - $sys = get_sys_channel(); - if(is_site_admin() && $sys['channel_id'] == $item['uid']) + // owner deletion + if(local_channel() && local_channel() == $item['uid']) $ok_to_delete = true; // author deletion -- cgit v1.2.3 From 3b73e5223e4a0f9dfae3a456ff5b3b6dec03ab76 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 15 Jul 2019 15:05:54 +0200 Subject: stringify_array_elms() could return weird results if the initial array key was not zero. this could trigger obscure bugs e.g. adding an empty string value to the recipients array in the notifier which could then select some broken hubloc/xchan entries. --- include/text.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index a2dfda952..8ce6b5d7c 100644 --- a/include/text.php +++ b/include/text.php @@ -2456,8 +2456,8 @@ function magic_link($s) { * @param boolean $escape (optional) default false */ function stringify_array_elms(&$arr, $escape = false) { - for($x = 0; $x < count($arr); $x ++) - $arr[$x] = "'" . (($escape) ? dbesc($arr[$x]) : $arr[$x]) . "'"; + foreach($arr as $k => $v) + $arr[$k] = "'" . (($escape) ? dbesc($v) : $v) . "'"; } -- cgit v1.2.3 From 821af482f070bfc671d2f5b6480a370dc86f212e Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 16 Jul 2019 18:11:47 +0200 Subject: Exclude trailing punctuations from URL --- include/activities.php | 2 +- include/bbcode.php | 2 +- include/text.php | 4 ++-- include/zid.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/activities.php b/include/activities.php index 68c995338..f329e374c 100644 --- a/include/activities.php +++ b/include/activities.php @@ -51,7 +51,7 @@ function profile_activity($changed, $value) { if($t == 1 && strlen($value)) { // if it's a url, the HTML quotes will mess it up, so link it and don't try and zidify it because we don't know what it points to. - $value = preg_replace_callback("/([^\]\='".'"'."]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]+)/ismu", 'red_zrl_callback', $value); + $value = preg_replace_callback("/([^\]\='".'"'."]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]+)([\,\.\:\;]\s|$)/ismu", 'red_zrl_callback', $value); // take out the bookmark indicator if(substr($value,0,2) === '#^') $value = str_replace('#^','',$value); diff --git a/include/bbcode.php b/include/bbcode.php index 485a1f5b2..df91356de 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -70,7 +70,7 @@ function bb_tag_preg_replace($pattern, $replace, $name, $s) { function tryoembed($match) { - $url = ((count($match) == 2) ? $match[1] : $match[2]); + $url = ((count($match) == 3) ? $match[1] : $match[2]); $o = oembed_fetch_url($url); diff --git a/include/text.php b/include/text.php index 8ce6b5d7c..17fd1bfe4 100644 --- a/include/text.php +++ b/include/text.php @@ -3403,10 +3403,10 @@ function cleanup_bbcode($body) { $body = preg_replace_callback('/\[zrl(.*?)\[\/(zrl)\]/ism','\red_escape_codeblock',$body); $body = preg_replace_callback("/([^\]\='".'"'."\/\{]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\\ -+\,\(\)]+)/ismu", '\nakedoembed', $body); ++\,\(\)]+)([\,\.\:\;]\s|$)/ismu", '\nakedoembed', $body); $body = preg_replace_callback("/([^\]\='".'"'."\/\{]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\\ -+\,\(\)]+)/ismu", '\red_zrl_callback', $body); ++\,\(\)]+)([\,\.\:\;]\s|$)/ismu", '\red_zrl_callback', $body); $body = preg_replace_callback('/\[\$b64zrl(.*?)\[\/(zrl)\]/ism','\red_unescape_codeblock',$body); diff --git a/include/zid.php b/include/zid.php index 27ef0cefa..fc8a31094 100644 --- a/include/zid.php +++ b/include/zid.php @@ -216,9 +216,9 @@ function red_zrl_callback($matches) { if($matches[1] === '#^') $matches[1] = ''; if($zrl) - return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]'; + return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $matches[3]; - return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]'; + return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]' . $matches[3]; } /** -- cgit v1.2.3 From c4de5b45dfead76bc564d306ac2c3f0c407dbe6f Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 18 Jul 2019 13:19:10 +0200 Subject: do not format hashtags with missing url --- include/text.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 17fd1bfe4..5a0e6ad3d 100644 --- a/include/text.php +++ b/include/text.php @@ -1572,7 +1572,9 @@ function format_hashtags(&$item) { $term = htmlspecialchars($t['term'], ENT_COMPAT, 'UTF-8', false) ; if(! trim($term)) continue; - if($t['url'] && strpos($item['body'], $t['url'])) + if(empty($t['url'])) + continue; + if(strpos($item['body'], $t['url'])) continue; if($s) $s .= ' '; -- cgit v1.2.3 From dc56d8560d0786a50f5131d114e0fb17b5b85d9c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 22 Jul 2019 20:38:10 +0200 Subject: pleroma uses slightly different URLs in body - also look for the string --- include/text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 5a0e6ad3d..1cde6bb01 100644 --- a/include/text.php +++ b/include/text.php @@ -1574,7 +1574,7 @@ function format_hashtags(&$item) { continue; if(empty($t['url'])) continue; - if(strpos($item['body'], $t['url'])) + if(strpos($item['body'], $t['url']) || strpos($item['body'], '#' . $t['term'])) continue; if($s) $s .= ' '; -- cgit v1.2.3 From 5695350e98a8a2c802ff419c5b29b0f01f0180df Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 25 Jul 2019 12:25:27 +0200 Subject: Revert "Merge branch 'dev' into 'dev'" This reverts merge request !1694 --- include/activities.php | 2 +- include/bbcode.php | 2 +- include/text.php | 4 ++-- include/zid.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/activities.php b/include/activities.php index f329e374c..68c995338 100644 --- a/include/activities.php +++ b/include/activities.php @@ -51,7 +51,7 @@ function profile_activity($changed, $value) { if($t == 1 && strlen($value)) { // if it's a url, the HTML quotes will mess it up, so link it and don't try and zidify it because we don't know what it points to. - $value = preg_replace_callback("/([^\]\='".'"'."]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]+)([\,\.\:\;]\s|$)/ismu", 'red_zrl_callback', $value); + $value = preg_replace_callback("/([^\]\='".'"'."]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]+)/ismu", 'red_zrl_callback', $value); // take out the bookmark indicator if(substr($value,0,2) === '#^') $value = str_replace('#^','',$value); diff --git a/include/bbcode.php b/include/bbcode.php index df91356de..485a1f5b2 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -70,7 +70,7 @@ function bb_tag_preg_replace($pattern, $replace, $name, $s) { function tryoembed($match) { - $url = ((count($match) == 3) ? $match[1] : $match[2]); + $url = ((count($match) == 2) ? $match[1] : $match[2]); $o = oembed_fetch_url($url); diff --git a/include/text.php b/include/text.php index 1cde6bb01..8adcc1269 100644 --- a/include/text.php +++ b/include/text.php @@ -3405,10 +3405,10 @@ function cleanup_bbcode($body) { $body = preg_replace_callback('/\[zrl(.*?)\[\/(zrl)\]/ism','\red_escape_codeblock',$body); $body = preg_replace_callback("/([^\]\='".'"'."\/\{]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\\ -+\,\(\)]+)([\,\.\:\;]\s|$)/ismu", '\nakedoembed', $body); ++\,\(\)]+)/ismu", '\nakedoembed', $body); $body = preg_replace_callback("/([^\]\='".'"'."\/\{]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\\ -+\,\(\)]+)([\,\.\:\;]\s|$)/ismu", '\red_zrl_callback', $body); ++\,\(\)]+)/ismu", '\red_zrl_callback', $body); $body = preg_replace_callback('/\[\$b64zrl(.*?)\[\/(zrl)\]/ism','\red_unescape_codeblock',$body); diff --git a/include/zid.php b/include/zid.php index fc8a31094..27ef0cefa 100644 --- a/include/zid.php +++ b/include/zid.php @@ -216,9 +216,9 @@ function red_zrl_callback($matches) { if($matches[1] === '#^') $matches[1] = ''; if($zrl) - return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $matches[3]; + return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]'; - return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]' . $matches[3]; + return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]'; } /** -- cgit v1.2.3 From 696359daba11c51d8f733dfa173e48b5e1de69ef Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 28 Jul 2019 19:57:17 -0700 Subject: fix urls on imported item taxonomy --- include/text.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/text.php b/include/text.php index a2dfda952..a49ff5a29 100644 --- a/include/text.php +++ b/include/text.php @@ -3105,6 +3105,15 @@ function item_url_replace($channel,&$item,$old,$new,$oldnick = '') { if($oldnick) $item['llink'] = str_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['llink']); + if($item['term']) { + for($x = 0; $x < count($item['term']); $x ++) { + $item['term'][$x]['url'] = str_replace($old,$new,$item['term'][$x]['url']); + if ($oldnick) { + $item['term'][$x]['url'] = str_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['term'][$x]['url']); + } + } + } + } -- cgit v1.2.3 From 59fed33797221003ef5ec730946f84588f3606a4 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 30 Jul 2019 11:54:14 +0200 Subject: Do not control limits on service class settings with 0 values --- include/account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/account.php b/include/account.php index 5f0c8737f..5dd91f909 100644 --- a/include/account.php +++ b/include/account.php @@ -668,7 +668,7 @@ function downgrade_accounts() { function service_class_allows($uid, $property, $usage = false) { $limit = service_class_fetch($uid, $property); - if($limit === false) + if($limit == false) return true; // No service class set => everything is allowed $limit = engr_units_to_bytes($limit); -- cgit v1.2.3 From d4a038c437a231ceba1ad79fe0c2f9a48e3afce1 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 30 Jul 2019 13:59:12 +0200 Subject: Update account.php --- include/account.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/account.php b/include/account.php index 5dd91f909..7546657fd 100644 --- a/include/account.php +++ b/include/account.php @@ -668,10 +668,12 @@ function downgrade_accounts() { function service_class_allows($uid, $property, $usage = false) { $limit = service_class_fetch($uid, $property); - if($limit == false) + if($limit === false) return true; // No service class set => everything is allowed $limit = engr_units_to_bytes($limit); + if($limit == 0) + return true; // 0 means no limits if($usage === false) { // We use negative values for not allowed properties in a subscriber plan return ((x($limit)) ? (bool) $limit : true); -- cgit v1.2.3 From 9ea1d6e8af731606d8876c2e22c951946ac98a14 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 31 Jul 2019 17:09:24 +0200 Subject: Do not limit channel if service class property value set with 0 --- include/account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/account.php b/include/account.php index 7546657fd..4bd218a5b 100644 --- a/include/account.php +++ b/include/account.php @@ -761,7 +761,7 @@ function service_class_fetch($uid, $property) { if(! is_array($arr) || (! count($arr))) return false; - return((array_key_exists($property, $arr)) ? $arr[$property] : false); + return((array_key_exists($property, $arr) && $arr[$property]) ? $arr[$property] : false); } /** -- cgit v1.2.3 From aaffc7485daf01dba56f2020b284fb06dd5a1ce1 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 31 Jul 2019 17:18:11 +0200 Subject: Update account.php --- include/account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/account.php b/include/account.php index 4bd218a5b..bea84cea7 100644 --- a/include/account.php +++ b/include/account.php @@ -761,7 +761,7 @@ function service_class_fetch($uid, $property) { if(! is_array($arr) || (! count($arr))) return false; - return((array_key_exists($property, $arr) && $arr[$property]) ? $arr[$property] : false); + return((array_key_exists($property, $arr) && $arr[$property] != 0) ? $arr[$property] : false); } /** -- cgit v1.2.3 From 2300581c93d0f40b1972774e05f493332729a948 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 8 Aug 2019 18:19:07 +0200 Subject: Catch and exclude trailing punctuation while URL embedding --- include/zid.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/zid.php b/include/zid.php index 27ef0cefa..344976437 100644 --- a/include/zid.php +++ b/include/zid.php @@ -205,6 +205,10 @@ function zidify_text($s) { */ function red_zrl_callback($matches) { + // Catch and exclude trailing punctuation + if (preg_match("/[.,;:!?)]*$/i", $matches[2], $pts)) + $matches[2] = substr($matches[2], 0, strlen($matches[2])-strlen($pts[0])); + $zrl = is_matrix_url($matches[2]); $t = strip_zids($matches[2]); @@ -215,10 +219,11 @@ function red_zrl_callback($matches) { if($matches[1] === '#^') $matches[1] = ''; + if($zrl) - return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]'; + return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $pts[0]; - return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]'; + return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]' . $pts[0]; } /** -- cgit v1.2.3 From 1c2f4132113a38948468fa992b738cb864e67774 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 8 Aug 2019 18:27:07 +0200 Subject: Formatting --- include/zid.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/zid.php b/include/zid.php index 344976437..05161d5c2 100644 --- a/include/zid.php +++ b/include/zid.php @@ -205,7 +205,7 @@ function zidify_text($s) { */ function red_zrl_callback($matches) { - // Catch and exclude trailing punctuation + // Catch and exclude trailing punctuation if (preg_match("/[.,;:!?)]*$/i", $matches[2], $pts)) $matches[2] = substr($matches[2], 0, strlen($matches[2])-strlen($pts[0])); -- cgit v1.2.3 From 33e258291870fcfe22ea8522c5e97d3bdeb84437 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 8 Aug 2019 18:29:26 +0200 Subject: Update zid.php --- include/zid.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/zid.php b/include/zid.php index 05161d5c2..4b17e1cd2 100644 --- a/include/zid.php +++ b/include/zid.php @@ -208,20 +208,20 @@ function red_zrl_callback($matches) { // Catch and exclude trailing punctuation if (preg_match("/[.,;:!?)]*$/i", $matches[2], $pts)) $matches[2] = substr($matches[2], 0, strlen($matches[2])-strlen($pts[0])); - - $zrl = is_matrix_url($matches[2]); - - $t = strip_zids($matches[2]); - if($t !== $matches[2]) { - $zrl = true; - $matches[2] = $t; - } - - if($matches[1] === '#^') - $matches[1] = ''; - + + $zrl = is_matrix_url($matches[2]); + + $t = strip_zids($matches[2]); + if($t !== $matches[2]) { + $zrl = true; + $matches[2] = $t; + } + + if($matches[1] === '#^') + $matches[1] = ''; + if($zrl) - return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $pts[0]; + return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $pts[0]; return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]' . $pts[0]; } -- cgit v1.2.3 From 832adf92a65489dd9ee253453d1421e36a9af9d5 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 8 Aug 2019 18:30:08 +0200 Subject: Update zid.php --- include/zid.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/zid.php b/include/zid.php index 4b17e1cd2..aaa509a09 100644 --- a/include/zid.php +++ b/include/zid.php @@ -219,11 +219,11 @@ function red_zrl_callback($matches) { if($matches[1] === '#^') $matches[1] = ''; - - if($zrl) - return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $pts[0]; - - return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]' . $pts[0]; + + if($zrl) + return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $pts[0]; + + return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]' . $pts[0]; } /** -- cgit v1.2.3 From 4382e53acbd9e5fa071428a6f365a637561f6820 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 8 Aug 2019 18:37:05 +0200 Subject: Remove condition --- include/zid.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/zid.php b/include/zid.php index aaa509a09..3b3dd8554 100644 --- a/include/zid.php +++ b/include/zid.php @@ -206,8 +206,8 @@ function zidify_text($s) { function red_zrl_callback($matches) { // Catch and exclude trailing punctuation - if (preg_match("/[.,;:!?)]*$/i", $matches[2], $pts)) - $matches[2] = substr($matches[2], 0, strlen($matches[2])-strlen($pts[0])); + preg_match("/[.,;:!?)]*$/i", $matches[2], $pts); + $matches[2] = substr($matches[2], 0, strlen($matches[2])-strlen($pts[0])); $zrl = is_matrix_url($matches[2]); -- cgit v1.2.3 From 4886d088e9889d828bc0e43de4f8844f210f785d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 9 Aug 2019 22:19:51 +0200 Subject: use stripos() to match the body against terms in format_hashtags() --- include/text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 572b43916..54ad9ec7a 100644 --- a/include/text.php +++ b/include/text.php @@ -1574,7 +1574,7 @@ function format_hashtags(&$item) { continue; if(empty($t['url'])) continue; - if(strpos($item['body'], $t['url']) || strpos($item['body'], '#' . $t['term'])) + if(strpos($item['body'], $t['url']) || stripos($item['body'], '#' . $t['term'])) continue; if($s) $s .= ' '; -- cgit v1.2.3