aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/account.php4
-rw-r--r--include/api_auth.php6
-rw-r--r--include/api_zot.php4
-rw-r--r--include/attach.php7
-rw-r--r--include/channel.php4
-rw-r--r--include/datetime.php3
-rw-r--r--include/dir_fns.php35
-rw-r--r--include/event.php90
-rw-r--r--include/features.php38
-rw-r--r--include/import.php30
-rwxr-xr-xinclude/items.php137
-rw-r--r--include/markdown.php4
-rw-r--r--include/message.php5
-rw-r--r--include/network.php11
-rw-r--r--include/photos.php10
-rw-r--r--include/socgraph.php21
-rw-r--r--include/text.php19
-rw-r--r--include/xchan.php2
-rw-r--r--include/zid.php35
-rw-r--r--include/zot.php43
20 files changed, 308 insertions, 200 deletions
diff --git a/include/account.php b/include/account.php
index 5f0c8737f..bea84cea7 100644
--- a/include/account.php
+++ b/include/account.php
@@ -672,6 +672,8 @@ function service_class_allows($uid, $property, $usage = 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);
@@ -759,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] != 0) ? $arr[$property] : false);
}
/**
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'])
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);
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/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),
diff --git a/include/datetime.php b/include/datetime.php
index 3a07f1ccf..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' => 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/dir_fns.php b/include/dir_fns.php
index 2bd1228ec..08a9fb653 100644
--- a/include/dir_fns.php
+++ b/include/dir_fns.php
@@ -329,13 +329,36 @@ function update_directory_entry($ud) {
if ($ud['ud_addr'] && (! ($ud['ud_flags'] & UPDATE_FLAGS_DELETED))) {
$success = false;
- $x = zot_finger($ud['ud_addr'], '');
- if ($x['success']) {
- $j = json_decode($x['body'], true);
- if ($j)
- $success = true;
- $y = import_xchan($j, 0, $ud);
+ // 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($uri);
+
+ // 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 = \Zotlabs\Zot\Finger::run($ud['ud_addr'], '');
+ if ($x['success']) {
+ import_xchan($x, 0, $ud);
+ $success = true;
}
if (! $success) {
q("update updates set ud_last = '%s' where ud_addr = '%s'",
diff --git a/include/event.php b/include/event.php
index 471fb7afa..6689919cf 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 .= '<div class="event-start"><span class="event-label">' . t('Starts:') . '</span>&nbsp;<span class="dtstart" title="'
. datetime_convert('UTC', 'UTC', $ev['dtstart'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
. '" >'
- . (($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 .= '<div class="event-end" ><span class="event-label">' . t('Finishes:') . '</span>&nbsp;<span class="dtend" title="'
. datetime_convert('UTC','UTC',$ev['dtend'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
. '" >'
- . (($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 )))
@@ -75,17 +76,35 @@ 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)) {
- $bd_format = t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8:01 AM
+ $tz = (($object['timezone']) ? $object['timezone'] : 'UTC');
+ $allday = (($object['adjust']) ? false : true);
+
+ $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_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_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_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_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 ))),
+ '$allday' => $allday,
+ '$oneday' => $oneday
));
$event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array(
@@ -125,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";
@@ -132,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']);
@@ -723,17 +757,9 @@ function parse_vobject($ical, $type) {
function parse_ical_file($f,$uid) {
- require_once('vendor/autoload.php');
$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) {
@@ -749,8 +775,6 @@ function parse_ical_file($f,$uid) {
}
}
- date_default_timezone_set($saved_timezone);
-
if($ical)
return true;
@@ -782,12 +806,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 {
@@ -1042,6 +1077,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 +1143,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 +1235,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 +1262,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..87df0c50d 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'),
]
],
@@ -272,36 +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')
- ],
-
- [
- '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'),
- ],
-
- [
- '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'),
- ]
-
- ],
-
'manage' => [
t('Manage'),
diff --git a/include/import.php b/include/import.php
index 92ba014d8..1d3b7c035 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');
@@ -897,9 +899,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 +957,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']) {
@@ -1177,7 +1179,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;
}
@@ -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);
@@ -1383,12 +1385,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'])) {
$time = datetime_convert();
@@ -1413,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);
@@ -1643,12 +1647,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
diff --git a/include/items.php b/include/items.php
index 95b696034..84bfc263b 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'])) {
@@ -1984,11 +1988,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;
@@ -2007,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'])
);
@@ -2028,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)
);
@@ -3663,7 +3668,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 +3676,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 +3699,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,26 +3711,23 @@ 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
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
@@ -3743,16 +3740,9 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
// 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,
@@ -3792,14 +3782,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']);
}
}
@@ -3814,11 +3803,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) {
+function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL) {
- $linked_item = (($item['resource_id']) ? true : false);
-
- logger('item: ' . $item['id'] . ' stage: ' . $stage . ' force: ' . $force, LOGGER_DATA);
+ logger('item: ' . $item['id'] . ' stage: ' . $stage, LOGGER_DATA);
switch($stage) {
case DROPITEM_PHASE2:
@@ -3831,42 +3818,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' => [$sync_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",
@@ -4620,12 +4615,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;
}
}
}
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);
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 )
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)) {
diff --git a/include/photos.php b/include/photos.php
index 7ea2729ae..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()
@@ -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(
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 @@
<?php /** @file */
+
+use Zotlabs\Lib\Libzot;
+use Zotlabs\Lib\Libzotdir;
+use Zotlabs\Lib\Zotfinger;
+
require_once('include/dir_fns.php');
require_once('include/zot.php');
@@ -122,7 +127,7 @@ function poco_load($xchan = '', $url = null) {
$profile_url = $url['value'];
continue;
}
- if($url['type'] == 'zot') {
+ if(in_array($url['type'], ['zot','zot6'] )) {
$network = $url['type'];
$address = str_replace('acct:' , '', $url['value']);
continue;
@@ -151,6 +156,18 @@ function poco_load($xchan = '', $url = null) {
if(($x !== false) && (! count($x))) {
if($address) {
+ if($network === 'zot6') {
+ $j = Zotfinger::exec($profile_url);
+ if(is_array($j) && array_path_exists('signature/signer',$j) && $j['signature']['signer'] === $profile_url && intval($j['signature']['header_valid'])) {
+ Libzot::import_xchan($j['data']);
+ }
+ $x = q("select xchan_hash from xchan where xchan_hash = '%s' limit 1",
+ dbesc($hash)
+ );
+ if(! $x) {
+ continue;
+ }
+ }
if($network === 'zot') {
$j = Zotlabs\Zot\Finger::run($address,null);
if($j['success']) {
@@ -402,7 +419,7 @@ function poco($a,$extended = false) {
$sql_extra ",
intval($channel_id)
);
- $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",
+ $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)
);
}
diff --git a/include/text.php b/include/text.php
index 6a2a9e427..54ad9ec7a 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']) || stripos($item['body'], '#' . $t['term']))
continue;
if($s)
$s .= ' ';
@@ -2456,8 +2458,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) . "'";
}
@@ -3091,7 +3093,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']));
@@ -3105,6 +3107,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']);
+ }
+ }
+ }
+
}
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 @@
<?php
-use Zotlabs\Zot6\HTTPSig;
+use Zotlabs\Web\HTTPSig;
use Zotlabs\Lib\Libzot;
diff --git a/include/zid.php b/include/zid.php
index ed79de76a..3b3dd8554 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 in ('zot', 'zot6') limit 1",
dbesc($m['host'])
);
if($r) {
@@ -205,20 +205,25 @@ function zidify_text($s) {
*/
function red_zrl_callback($matches) {
- $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]';
-
- return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]';
+ // Catch and exclude trailing punctuation
+ 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] = '';
+
+ if($zrl)
+ return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $pts[0];
+
+ return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]' . $pts[0];
}
/**
diff --git a/include/zot.php b/include/zot.php
index b99eeb1ec..53c3d4d86 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -303,9 +303,8 @@ function zot_zot($url, $data, $channel = null,$crypto = null) {
if($channel) {
$headers['X-Zot-Token'] = random_string();
- $hash = \Zotlabs\Web\HTTPSig::generate_digest($data,false);
- $headers['X-Zot-Digest'] = 'SHA-256=' . $hash;
- $h = \Zotlabs\Web\HTTPSig::create_sig('',$headers,$channel['channel_prvkey'],'acct:' . $channel['channel_address'] . '@' . \App::get_hostname(),false,false,'sha512',(($crypto) ? $crypto['hubloc_sitekey'] : ''), (($crypto) ? zot_best_algorithm($crypto['site_crypto']) : ''));
+ $headers['X-Zot-Digest'] = \Zotlabs\Web\HTTPSig::generate_digest_header($data);
+ $h = \Zotlabs\Web\HTTPSig::create_sig($headers,$channel['channel_prvkey'],'acct:' . channel_reddress($channel),false,'sha512',(($crypto) ? $crypto['hubloc_sitekey'] : ''), (($crypto) ? zot_best_algorithm($crypto['site_crypto']) : ''));
}
$redirects = 0;
@@ -2241,7 +2240,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 +2250,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,10 +2280,29 @@ function delete_imported_item($sender, $item, $uid, $relay) {
return false;
}
+ if ($stored['resource_type'] === 'event') {
+ $i = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
+ 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($stored['resource_id']),
+ intval($uid)
+ );
+ }
+ else {
+ logger('delete linked event: not owner');
+ return;
+ }
+ }
+ }
+
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;
@@ -2293,10 +2314,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'])
);
}
}
@@ -4430,7 +4451,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'],''))