aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/ASCollection.php4
-rw-r--r--Zotlabs/Lib/AbConfig.php15
-rw-r--r--Zotlabs/Lib/Activity.php80
-rw-r--r--Zotlabs/Lib/Apps.php17
-rw-r--r--Zotlabs/Lib/Connect.php3
-rw-r--r--Zotlabs/Lib/Enotify.php49
-rw-r--r--Zotlabs/Lib/Libsync.php4
-rw-r--r--Zotlabs/Lib/Libzot.php112
-rw-r--r--Zotlabs/Lib/Libzotdir.php43
-rw-r--r--Zotlabs/Lib/ThreadItem.php7
-rw-r--r--Zotlabs/Lib/Webfinger.php2
-rw-r--r--Zotlabs/Lib/XConfig.php2
12 files changed, 197 insertions, 141 deletions
diff --git a/Zotlabs/Lib/ASCollection.php b/Zotlabs/Lib/ASCollection.php
index 392dd5d4e..c72b2fd04 100644
--- a/Zotlabs/Lib/ASCollection.php
+++ b/Zotlabs/Lib/ASCollection.php
@@ -24,6 +24,8 @@ class ASCollection {
$this->direction = $direction;
$this->limit = $limit;
+ $data = null;
+
if (is_array($obj)) {
$data = $obj;
}
@@ -147,4 +149,4 @@ class ASCollection {
}
logger('nextpage: ' . $this->nextpage, LOGGER_DEBUG);
}
-} \ No newline at end of file
+}
diff --git a/Zotlabs/Lib/AbConfig.php b/Zotlabs/Lib/AbConfig.php
index dfc9efc6c..af1786966 100644
--- a/Zotlabs/Lib/AbConfig.php
+++ b/Zotlabs/Lib/AbConfig.php
@@ -6,12 +6,17 @@ namespace Zotlabs\Lib;
class AbConfig {
static public function Load($chan,$xhash,$family = '') {
- if($family)
+ $where = '';
+
+ if($family) {
$where = sprintf(" and cat = '%s' ",dbesc($family));
+ }
+
$r = q("select * from abconfig where chan = %d and xchan = '%s' $where",
intval($chan),
dbesc($xhash)
);
+
return $r;
}
@@ -21,7 +26,7 @@ class AbConfig {
intval($chan),
dbesc($xhash),
dbesc($family),
- dbesc($key)
+ dbesc($key)
);
if($r) {
return ((preg_match('|^a:[0-9]+:{.*}$|s', $r[0]['v'])) ? unserialize($r[0]['v']) : $r[0]['v']);
@@ -41,19 +46,19 @@ class AbConfig {
dbesc($xhash),
dbesc($family),
dbesc($key),
- dbesc($dbvalue)
+ dbesc($dbvalue)
);
}
else {
$r = q("update abconfig set v = '%s' where chan = %d and xchan = '%s' and cat = '%s' and k = '%s' ",
- dbesc($dbvalue),
+ dbesc($dbvalue),
dbesc($chan),
dbesc($xhash),
dbesc($family),
dbesc($key)
);
}
-
+
if($r)
return $value;
return false;
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 4ff13bc04..1a34fdae6 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -68,6 +68,10 @@ class Activity {
else {
$m = parse_url($url);
+ if (!$m) {
+ return null;
+ }
+
// handle bearcaps
if ($m['scheme'] === 'bear') {
$params = explode('&', $m['query']);
@@ -117,7 +121,7 @@ class Activity {
$y = json_decode($x['body'], true);
logger('returned: ' . json_encode($y, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), LOGGER_DEBUG);
- if (ActivityStreams::is_an_actor($y['type'])) {
+ if (isset($y['type']) && ActivityStreams::is_an_actor($y['type'])) {
XConfig::Set($y['id'], 'system', 'actor_record', $y);
}
@@ -415,7 +419,7 @@ class Activity {
$objtype = self::activity_obj_mapper($i['obj_type']);
}
- if ($i['obj']) {
+ if (isset($i['obj']) && $i['obj']) {
$ret = Activity::encode_object($i['obj']);
}
@@ -430,7 +434,7 @@ class Activity {
return $ret;
}
- if ($i['obj']) {
+ if (isset($i['obj']) && $i['obj']) {
if (is_array($i['obj'])) {
$ret = $i['obj'];
}
@@ -717,7 +721,7 @@ class Activity {
$ret['type'] = self::activity_mapper($i['verb']);
- if (intval($i['item_deleted']) && !$recurse) {
+ if ((isset($i['item_deleted']) && intval($i['item_deleted'])) && !$recurse) {
$is_response = false;
if (ActivityStreams::is_response_activity($ret['type'])) {
@@ -801,10 +805,10 @@ class Activity {
$ret['diaspora:guid'] = $i['uuid'];
- if ($i['title'])
+ if (isset($i['title']) && $i['title'])
$ret['name'] = html2plain(bbcode($i['title'], ['cache' => true]));
- if ($i['summary'])
+ if (isset($i['summary']) && $i['summary'])
$ret['summary'] = bbcode($i['summary'], ['cache' => true]);
if ($ret['type'] === 'Announce') {
@@ -816,13 +820,14 @@ class Activity {
];
}
- $ret['published'] = datetime_convert('UTC', 'UTC', $i['created'], ATOM_TIME);
- if ($i['created'] !== $i['edited'])
+ $ret['published'] = ((isset($i['created'])) ? datetime_convert('UTC', 'UTC', $i['created'], ATOM_TIME) : datetime_convert());
+ if (isset($i['created'], $i['edited']) && $i['created'] !== $i['edited'])
$ret['updated'] = datetime_convert('UTC', 'UTC', $i['edited'], ATOM_TIME);
- if ($i['app']) {
+
+ if (isset($i['app']) && $i['app']) {
$ret['generator'] = ['type' => 'Application', 'name' => $i['app']];
}
- if ($i['location'] || $i['coord']) {
+ if (isset($i['location']) || isset($i['coord'])) {
$ret['location'] = ['type' => 'Place'];
if ($i['location']) {
$ret['location']['name'] = $i['location'];
@@ -851,7 +856,7 @@ class Activity {
else
return [];
- if ($i['obj']) {
+ if (isset($i['obj']) && $i['obj']) {
if (!is_array($i['obj'])) {
$i['obj'] = json_decode($i['obj'], true);
}
@@ -879,7 +884,7 @@ class Activity {
$ret['type'] = 'Invite';
}
- if ($i['target']) {
+ if (isset($i['target']) && $i['target']) {
if (!is_array($i['target'])) {
$i['target'] = json_decode($i['target'], true);
}
@@ -1596,15 +1601,18 @@ class Activity {
// we already store this in Activity::fetch()
// XConfig::Set($url, 'system', 'actor_record', $person_obj);
- $name = $person_obj['name'];
+ $name = $person_obj['name'] ?? '';
if (!$name) {
- $name = $person_obj['preferredUsername'];
+ $name = $person_obj['preferredUsername'] ?? '';
}
if (!$name) {
$name = t('Unknown');
}
$webfinger_addr = '';
+ $hostname = '';
+ $baseurl = '';
+ $site_url = '';
$m = parse_url($url);
if ($m) {
@@ -1613,7 +1621,7 @@ class Activity {
$site_url = $m['scheme'] . '://' . $m['host'];
}
- if (!empty($person_obj['preferredUsername']) && isset($parsed_url['host'])) {
+ if (!empty($person_obj['preferredUsername']) && $hostname) {
$webfinger_addr = escape_tags($person_obj['preferredUsername']) . '@' . $hostname;
}
@@ -1640,7 +1648,7 @@ class Activity {
$links = false;
$profile = false;
- if (is_array($person_obj['url'])) {
+ if (isset($person_obj['url']) && is_array($person_obj['url'])) {
if (!array_key_exists(0, $person_obj['url'])) {
$links = [$person_obj['url']];
}
@@ -1649,7 +1657,7 @@ class Activity {
}
}
- if ($links) {
+ if (is_array($links) && $links) {
foreach ($links as $link) {
if (is_array($link) && array_key_exists('mediaType', $link) && $link['mediaType'] === 'text/html') {
$profile = $link['href'];
@@ -2262,6 +2270,10 @@ class Activity {
$obj_actor = ((isset($act->obj['actor'])) ? $act->obj['actor'] : $act->get_actor('attributedTo', $act->obj));
+ if (!isset($obj_actor['id'])) {
+ return false;
+ }
+
// ensure we store the original actor
self::actor_store($obj_actor['id'], $obj_actor);
@@ -2323,9 +2335,6 @@ class Activity {
if ($remainder) {
$s['comment_policy'] = $remainder;
}
- if (!(isset($item['comment_policy']) && strlen($item['comment_policy']))) {
- $s['comment_policy'] = 'contacts';
- }
}
}
@@ -2995,18 +3004,6 @@ class Activity {
set_iconfig($item, 'activitypub', 'recips', $act->raw_recips);
- // TODO: inheritPrivacy should probably be set in encode activity. Zap does not do so yet - check what this is about
- if (!(isset($act->data['inheritPrivacy']) && $act->data['inheritPrivacy'])) {
- if ($item['item_private']) {
- $item['item_restrict'] = $item['item_restrict'] & 1;
- if ($is_child_node) {
- $item['allow_cid'] = '<' . $channel['channel_hash'] . '>';
- $item['allow_gid'] = $item['deny_cid'] = $item['deny_gid'] = '';
- }
- logger('restricted');
- }
- }
-
if (intval($act->sigok)) {
$item['item_verified'] = 1;
}
@@ -3054,7 +3051,24 @@ class Activity {
$item['thr_parent'] = $parent[0]['parent_mid'];
}
$item['parent_mid'] = $parent[0]['parent_mid'];
- //$item['item_private'] = $parent[0]['item_private'];
+
+ /*
+ *
+ * Check for conversation privacy mismatches
+ * We can only do this if we have a channel and we have fetched the parent
+ *
+ */
+
+ // public conversation, but this comment went rogue and was published privately
+ // hide it from everybody except the channel owner
+
+ if (intval($parent[0]['item_private']) === 0) {
+ if (intval($item['item_private'])) {
+ $item['item_restrict'] = $item['item_restrict'] | 1;
+ $item['allow_cid'] = '<' . $channel['channel_hash'] . '>';
+ $item['allow_gid'] = $item['deny_cid'] = $item['deny_gid'] = '';
+ }
+ }
}
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php
index a29992bbc..a9c7d0a2a 100644
--- a/Zotlabs/Lib/Apps.php
+++ b/Zotlabs/Lib/Apps.php
@@ -159,7 +159,7 @@ class Apps {
foreach(self::$available_apps as $iapp) {
if($iapp['app_id'] == hash('whirlpool',$app['name'])) {
$notfound = false;
- if(($iapp['app_version'] !== $app['version'])
+ if((isset($app['version']) && $iapp['app_version'] !== $app['version'])
|| ($app['plugin'] && (! $iapp['app_plugin']))) {
return intval($iapp['app_id']);
}
@@ -236,6 +236,7 @@ class Apps {
$ret['photo'] = $baseurl . '/' . get_default_profile_photo(80);
$ret['type'] = 'system';
+ $ret['plugin'] = '';
foreach($ret as $k => $v) {
if(strpos($v,'http') === 0) {
@@ -600,12 +601,12 @@ class Apps {
'$edit' => ((local_channel() && $installed && $mode == 'edit') ? t('Edit') : ''),
'$delete' => ((local_channel() && $mode == 'edit') ? t('Delete') : ''),
'$undelete' => ((local_channel() && $mode == 'edit') ? t('Undelete') : ''),
- '$settings_url' => ((local_channel() && $installed && $mode == 'list') ? $papp['settings_url'] : ''),
- '$deleted' => $papp['deleted'],
+ '$settings_url' => ((local_channel() && $installed && $mode == 'list' && isset($papp['settings_url'])) ? $papp['settings_url'] : ''),
+ '$deleted' => $papp['deleted'] ?? false,
'$feature' => ((isset($papp['embed']) || $mode == 'edit') ? false : true),
'$pin' => ((isset($papp['embed']) || $mode == 'edit') ? false : true),
- '$featured' => ((strpos($papp['categories'], 'nav_featured_app') === false) ? false : true),
- '$pinned' => ((strpos($papp['categories'], 'nav_pinned_app') === false) ? false : true),
+ '$featured' => ((isset($papp['categories']) && strpos($papp['categories'], 'nav_featured_app') === false) ? false : true),
+ '$pinned' => ((isset($papp['categories']) && strpos($papp['categories'], 'nav_pinned_app') === false) ? false : true),
'$mode' => $mode,
'$add' => t('Add to app-tray'),
'$remove' => t('Remove from app-tray'),
@@ -644,7 +645,7 @@ class Apps {
);
if($r) {
if($app['uid']) {
- if($app['categories'] && (! $app['term'])) {
+ if((isset($app['categories']) && $app['categories']) && !(isset($app['term']) && $app['term'])) {
$r[0]['term'] = q("select * from term where otype = %d and oid = %d",
intval(TERM_OBJ_APP),
intval($r[0]['id'])
@@ -1189,7 +1190,7 @@ class Apps {
$ret['success'] = true;
$ret['app_id'] = $darray['app_id'];
}
- if($arr['categories']) {
+ if(isset($arr['categories']) && $arr['categories']) {
$x = q("select id from app where app_id = '%s' and app_channel = %d limit 1",
dbesc($darray['app_id']),
intval($darray['app_channel'])
@@ -1287,7 +1288,7 @@ class Apps {
intval(TERM_OBJ_APP),
intval($x[0]['id'])
);
- if($arr['categories']) {
+ if(isset($arr['categories']) && $arr['categories']) {
$y = explode(',',$arr['categories']);
if($y) {
foreach($y as $t) {
diff --git a/Zotlabs/Lib/Connect.php b/Zotlabs/Lib/Connect.php
index 0b9ff7089..6f10bbbae 100644
--- a/Zotlabs/Lib/Connect.php
+++ b/Zotlabs/Lib/Connect.php
@@ -86,6 +86,7 @@ class Connect {
$singleton = false;
$d = false;
+ $wf = false;
if (! $r) {
@@ -111,7 +112,7 @@ class Connect {
// something was discovered - find the record which was just created.
$r = q("select * from xchan where ( xchan_hash = '%s' or xchan_url = '%s' or xchan_addr = '%s' ) $sql_options",
- dbesc(($wf) ? $wf : $url),
+ dbesc($wf ?? $url),
dbesc($url),
dbesc($url)
);
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php
index 5a09ade90..67efe5e9d 100644
--- a/Zotlabs/Lib/Enotify.php
+++ b/Zotlabs/Lib/Enotify.php
@@ -122,8 +122,11 @@ class Enotify {
// e.g. "your post", "David's photo", etc.
$possess_desc = t('%s <!item_type!>');
+ $parent_mid = '';
+ $parent_item = [];
+
// @@TODO: consider using switch instead of those elseif
- if ($params['type'] == NOTIFY_MAIL) {
+ if (isset($params['type']) && $params['type'] == NOTIFY_MAIL) {
logger('notification: mail');
$subject = sprintf( t('[$Projectname:Notify] New direct message received at %s'), $sitename);
@@ -135,7 +138,7 @@ class Enotify {
$itemlink = $siteurl . '/hq/' . gen_link_id($params['item']['mid']);
}
- elseif ($params['type'] === NOTIFY_COMMENT) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_COMMENT) {
//logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
$moderated = (($params['item']['item_blocked'] == ITEM_MODERATED) ? true : false);
@@ -167,7 +170,7 @@ class Enotify {
}
- $parent_mid = $params['parent_mid'];
+ $parent_mid = $params['parent_mid'] ?? '';
// Check to see if there was already a notify for this post.
// If so don't create a second notification
@@ -251,7 +254,7 @@ class Enotify {
}
- elseif ($params['type'] === NOTIFY_LIKE) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_LIKE) {
// logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
$itemlink = $params['link'];
@@ -264,7 +267,7 @@ class Enotify {
}
}
- $parent_mid = $params['parent_mid'];
+ $parent_mid = $params['parent_mid'] ?? '';
// Check to see if there was already a notify for this post.
// If so don't create a second notification
@@ -335,7 +338,7 @@ class Enotify {
- elseif($params['type'] === NOTIFY_WALL) {
+ elseif(isset($params['type']) && $params['type'] === NOTIFY_WALL) {
$subject = sprintf( t('[$Projectname:Notify] %s posted to your profile wall') , $sender['xchan_name']);
$preamble = sprintf( t('%1$s posted to your profile wall at %2$s') , $sender['xchan_name'], $sitename);
@@ -350,7 +353,7 @@ class Enotify {
$itemlink = $params['link'];
}
- elseif ($params['type'] === NOTIFY_TAGSELF) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_TAGSELF) {
$p = q("select id from notify where link = '%s' and uid = %d limit 1",
dbesc($params['link']),
@@ -374,7 +377,7 @@ class Enotify {
$itemlink = $params['link'];
}
- elseif ($params['type'] === NOTIFY_POKE) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_POKE) {
$subject = sprintf( t('[$Projectname:Notify] %1$s poked you') , $sender['xchan_name']);
$preamble = sprintf( t('%1$s poked you at %2$s') , $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('%1$s [zrl=%2$s]poked you[/zrl].') ,
@@ -391,7 +394,7 @@ class Enotify {
$itemlink = $params['link'];
}
- elseif ($params['type'] === NOTIFY_TAGSHARE) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_TAGSHARE) {
$subject = sprintf( t('[$Projectname:Notify] %s tagged your post') , $sender['xchan_name']);
$preamble = sprintf( t('%1$s tagged your post at %2$s'),$sender['xchan_name'], $sitename);
$epreamble = sprintf( t('%1$s tagged [zrl=%2$s]your post[/zrl]') ,
@@ -404,7 +407,7 @@ class Enotify {
$itemlink = $params['link'];
}
- elseif ($params['type'] === NOTIFY_INTRO) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_INTRO) {
$subject = sprintf( t('[$Projectname:Notify] Introduction received'));
$preamble = sprintf( t('You\'ve received an new connection request from \'%1$s\' at %2$s'), $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('You\'ve received [zrl=%1$s]a new connection request[/zrl] from %2$s.'),
@@ -418,7 +421,7 @@ class Enotify {
$itemlink = $params['link'];
}
- elseif ($params['type'] === NOTIFY_SUGGEST) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_SUGGEST) {
$subject = sprintf( t('[$Projectname:Notify] Friend suggestion received'));
$preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('You\'ve received [zrl=%1$s]a friend suggestion[/zrl] for %2$s from %3$s.'),
@@ -436,11 +439,11 @@ class Enotify {
$itemlink = $params['link'];
}
- elseif ($params['type'] === NOTIFY_CONFIRM) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_CONFIRM) {
// ?
}
- elseif ($params['type'] === NOTIFY_SYSTEM) {
+ elseif (isset($params['type']) && $params['type'] === NOTIFY_SYSTEM) {
// ?
}
@@ -495,12 +498,13 @@ class Enotify {
$datarray['link'] = $itemlink;
$datarray['parent'] = $parent_mid;
$datarray['parent_item'] = $parent_item;
- $datarray['ntype'] = $params['type'];
- $datarray['verb'] = $params['verb'];
- $datarray['otype'] = $params['otype'];
+ $datarray['ntype'] = $params['type'] ?? '';
+ $datarray['verb'] = $params['verb'] ?? '';
+ $datarray['otype'] = $params['otype'] ?? '';
$datarray['abort'] = false;
+ $datarray['seen'] = 0;
- $datarray['item'] = $params['item'];
+ $datarray['item'] = $params['item'] ?? [];
call_hooks('enotify_store', $datarray);
@@ -511,7 +515,6 @@ class Enotify {
// create notification entry in DB
- $seen = 0;
// Mark some notifications as seen right away
// Note! The notification have to be created, because they are used to send emails
@@ -521,7 +524,7 @@ class Enotify {
if (!$always_show_in_notices) {
if (($params['type'] === NOTIFY_WALL) || ($params['type'] === NOTIFY_MAIL) || ($params['type'] === NOTIFY_INTRO)) {
- $seen = 1;
+ $datarray['seen'] = 1;
}
}
@@ -537,7 +540,7 @@ class Enotify {
intval($datarray['uid']),
dbesc($datarray['link']),
dbesc($datarray['parent']),
- intval($seen),
+ intval($datarray['seen']),
intval($datarray['ntype']),
dbesc($datarray['verb']),
dbesc($datarray['otype'])
@@ -613,8 +616,8 @@ class Enotify {
$datarray['preamble'] = $preamble;
$datarray['sitename'] = $sitename;
$datarray['siteurl'] = $siteurl;
- $datarray['type'] = $params['type'];
- $datarray['parent'] = $params['parent_mid'];
+ $datarray['type'] = $params['type'] ?? '';
+ $datarray['parent'] = $params['parent_mid'] ?? '';
$datarray['source_name'] = $sender['xchan_name'];
$datarray['source_link'] = $sender['xchan_url'];
$datarray['source_photo'] = $sender['xchan_photo_s'];
@@ -681,7 +684,6 @@ class Enotify {
'$source_name' => $datarray['source_name'],
'$source_link' => $datarray['source_link'],
'$source_photo' => $datarray['source_photo'],
- '$username' => $datarray['to_name'],
'$hsitelink' => $datarray['hsitelink'],
'$hitemlink' => $datarray['hitemlink'],
'$thanks' => $datarray['thanks'],
@@ -703,7 +705,6 @@ class Enotify {
'$source_name' => $datarray['source_name'],
'$source_link' => $datarray['source_link'],
'$source_photo' => $datarray['source_photo'],
- '$username' => $datarray['to_name'],
'$tsitelink' => $datarray['tsitelink'],
'$titemlink' => $datarray['titemlink'],
'$thanks' => $datarray['thanks'],
diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php
index 36a0a044c..914969d97 100644
--- a/Zotlabs/Lib/Libsync.php
+++ b/Zotlabs/Lib/Libsync.php
@@ -762,6 +762,8 @@ class Libsync {
static function sync_locations($sender, $arr, $absolute = false) {
$ret = [];
+ $what = '';
+ $changed = false;
// If a sender reports that the channel has been deleted, delete its hubloc
if (isset($arr['deleted_locally']) && intval($arr['deleted_locally'])) {
@@ -772,7 +774,7 @@ class Libsync {
);
}
- if ($arr['locations']) {
+ if (isset($arr['locations']) && $arr['locations']) {
if ($absolute)
Libzot::check_location_move($sender['hash'], $arr['locations']);
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index 6f7d74606..cbb614429 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -473,7 +473,7 @@ class Libzot {
unset($new_connection[0]['abook_account']);
unset($new_connection[0]['abook_channel']);
- $abconfig = load_abconfig($channel['channel_id'], $new_connection['abook_xchan']);
+ $abconfig = load_abconfig($channel['channel_id'], $new_connection[0]['abook_xchan']);
if ($abconfig) {
$new_connection['abconfig'] = $abconfig;
@@ -589,8 +589,6 @@ class Libzot {
*/
static function register_hub($id) {
- $hsig_valid = false;
-
$result = ['success' => false];
if (!$id) {
@@ -599,8 +597,14 @@ class Libzot {
$record = Zotfinger::exec($id);
+ if (!$record) {
+ return $result;
+ }
+
// Check the HTTP signature
+ $hsig_valid = false;
+
$hsig = $record['signature'];
if ($hsig['signer'] === $id && $hsig['header_valid'] === true && $hsig['content_valid'] === true) {
$hsig_valid = true;
@@ -641,6 +645,14 @@ class Libzot {
*/
static function import_xchan($arr, $ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) {
+
+ $ret = ['success' => false];
+
+ if (!is_array($arr)) {
+ logger('Not an array: ' . print_r($arr, true), LOGGER_DEBUG);
+ return $ret;
+ }
+
/**
* @hooks import_xchan
* Called when processing the result of zot_finger() to store the result
@@ -648,7 +660,6 @@ class Libzot {
*/
call_hooks('import_xchan', $arr);
- $ret = ['success' => false];
$dirmode = intval(get_config('system', 'directory_mode'));
$changed = false;
@@ -668,7 +679,7 @@ class Libzot {
$verified = false;
if (!self::verify($arr['id'], $arr['id_sig'], $arr['public_key'])) {
- logger('Unable to verify channel signature for ' . $arr['address']);
+ logger('Unable to verify channel signature for ' . $arr['primary_location']['address']);
return $ret;
}
else {
@@ -703,18 +714,18 @@ class Libzot {
$dirmode = get_config('system', 'directory_mode');
- if ((($arr['site']['directory_mode'] === 'standalone') || ($dirmode & DIRECTORY_MODE_STANDALONE)) && ($arr['site']['url'] != z_root()))
+ if (((isset($arr['site']['directory_mode']) && $arr['site']['directory_mode'] === 'standalone') || ($dirmode & DIRECTORY_MODE_STANDALONE)) && ($arr['site']['url'] != z_root()))
$arr['searchable'] = false;
$hidden = (1 - intval($arr['searchable']));
$hidden_changed = $adult_changed = $deleted_changed = $pubforum_changed = 0;
- if (intval($r[0]['xchan_hidden']) != (1 - intval($arr['searchable'])))
+ if (isset($arr['searchable']) && intval($r[0]['xchan_hidden']) != (1 - intval($arr['searchable'])))
$hidden_changed = 1;
- if (intval($r[0]['xchan_selfcensored']) != intval($arr['adult_content']))
+ if (isset($arr['adult_content']) && intval($r[0]['xchan_selfcensored']) != intval($arr['adult_content']))
$adult_changed = 1;
- if (intval($r[0]['xchan_deleted']) != intval($arr['deleted']))
+ if (isset($arr['xchan_deleted']) && intval($r[0]['xchan_deleted']) != intval($arr['deleted']))
$deleted_changed = 1;
// new style 6-MAR-2019
@@ -733,7 +744,7 @@ class Libzot {
// old style
- if (intval($r[0]['xchan_pubforum']) != intval($arr['public_forum']))
+ if (isset($arr['public_forum']) && intval($r[0]['xchan_pubforum']) != intval($arr['public_forum']))
$pubforum_changed = 1;
@@ -761,10 +772,10 @@ class Libzot {
dbesc($arr['name_updated']),
dbesc($arr['primary_location']['connections_url']),
dbesc($arr['primary_location']['follow_url']),
- dbesc($arr['primary_location']['connect_url']),
+ dbesc($arr['connect_url']),
intval(1 - intval($arr['searchable'])),
intval($arr['adult_content']),
- intval($arr['deleted']),
+ intval($arr['deleted'] ?? 0),
intval($arr['public_forum']),
dbesc(escape_tags($arr['primary_location']['address'])),
dbesc(escape_tags($arr['primary_location']['url'])),
@@ -804,7 +815,7 @@ class Libzot {
'xchan_name_date' => $arr['name_updated'],
'xchan_hidden' => intval(1 - intval($arr['searchable'])),
'xchan_selfcensored' => $arr['adult_content'],
- 'xchan_deleted' => $arr['deleted'],
+ 'xchan_deleted' => $arr['deleted'] ?? 0,
'xchan_pubforum' => $arr['public_forum']
]
);
@@ -885,7 +896,7 @@ class Libzot {
else {
$r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s'
where xchan_hash = '%s'",
- dbescdate(datetime_convert('UTC', 'UTC', $arr['photo_updated'])),
+ dbescdate(datetime_convert('UTC', 'UTC', $arr['photo']['updated'])),
dbesc($photos[0]),
dbesc($photos[1]),
dbesc($photos[2]),
@@ -914,7 +925,7 @@ class Libzot {
// Which entries in the update table are we interested in updating?
- $address = (($ud_arr && $ud_arr['ud_addr']) ? $ud_arr['ud_addr'] : $arr['address']);
+ $address = (($ud_arr && $ud_arr['ud_addr']) ? $ud_arr['ud_addr'] : $arr['primary_location']['address']);
// Are we a directory server of some kind?
@@ -1027,7 +1038,7 @@ class Libzot {
// handle remote validation issues
$b = q("update dreport set dreport_result = '%s', dreport_time = '%s' where dreport_queue = '%s'",
- dbesc(($x['message']) ? $x['message'] : 'unknown delivery error'),
+ dbesc($x['message'] ?? 'unknown delivery error'),
dbesc(datetime_convert()),
dbesc($outq['outq_hash'])
);
@@ -1298,7 +1309,7 @@ class Libzot {
}
}
- if ($AS->meta['hubloc']) {
+ if (isset($AS->meta['hubloc']) && $AS->meta['hubloc']) {
$arr['item_verified'] = true;
}
@@ -1306,7 +1317,7 @@ class Libzot {
$arr['comment_policy'] = 'authenticated';
}
- if ($AS->meta['signed_data']) {
+ if (isset($AS->meta['signed_data']) && $AS->meta['signed_data']) {
IConfig::Set($arr, 'activitypub', 'signed_data', $AS->meta['signed_data'], false);
}
@@ -1437,7 +1448,7 @@ class Libzot {
if ($check_mentions) {
// It's a top level post. Look at the tags. See if any of them are mentions and are on this hub.
if ($act && $act->obj) {
- if (is_array($act->obj['tag']) && $act->obj['tag']) {
+ if (isset($act->obj['tag']) && is_array($act->obj['tag']) && $act->obj['tag']) {
foreach ($act->obj['tag'] as $tag) {
if ($tag['type'] === 'Mention' && (strpos($tag['href'], z_root()) !== false)) {
$address = basename($tag['href']);
@@ -1516,6 +1527,7 @@ class Libzot {
foreach ($deliveries as $d) {
$local_public = $public;
+ $item_result = null;
$DR = new DReport(z_root(), $sender, $d, $arr['mid']);
@@ -1910,7 +1922,7 @@ class Libzot {
$stored = (($item_result && $item_result['item']) ? $item_result['item'] : false);
if ((is_array($stored)) && ($stored['id'] != $stored['parent'])
- && ($stored['author_xchan'] === $channel['channel_hash'] || $stored['author_xchan'] === $channel['channel_hash'])) {
+ && ($stored['author_xchan'] === $channel['channel_hash'])) {
retain_item($stored['item']['parent']);
}
@@ -1944,7 +1956,7 @@ class Libzot {
return false;
}
- if ($a['data']['type'] !== 'OrderedCollection') {
+ if (isset($a['data']['type']) && $a['data']['type'] !== 'OrderedCollection') {
return false;
}
@@ -1978,13 +1990,18 @@ class Libzot {
logger('FOF Activity rejected: ' . print_r($activity, true));
continue;
}
- $arr = Activity::decode_note($AS);
// logger($AS->debug());
+ if(empty($AS->actor['id'])) {
+ logger('No actor id!');
+ continue;
+ }
+
$r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_id_url = '%s'",
dbesc($AS->actor['id'])
);
+
$r = self::zot_record_preferred($r);
if (!$r) {
@@ -2001,7 +2018,7 @@ class Libzot {
}
}
- if ($AS->obj['actor'] && $AS->obj['actor']['id'] && $AS->obj['actor']['id'] !== $AS->actor['id']) {
+ if (isset($AS->obj['actor']['id']) && $AS->obj['actor']['id'] !== $AS->actor['id']) {
$y = import_author_xchan(['url' => $AS->obj['actor']['id']]);
if (!$y) {
logger('FOF Activity: no object actor');
@@ -2009,6 +2026,12 @@ class Libzot {
}
}
+ $arr = Activity::decode_note($AS);
+
+ if (!$arr) {
+ continue;
+ }
+
if ($r) {
$arr['author_xchan'] = $r['hubloc_hash'];
}
@@ -2478,32 +2501,32 @@ class Libzot {
}
$site_directory = 0;
- if ($arr['directory_mode'] == 'normal')
+ if (isset($arr['directory_mode']) && $arr['directory_mode'] == 'normal')
$site_directory = DIRECTORY_MODE_NORMAL;
- if ($arr['directory_mode'] == 'primary')
+ if (isset($arr['directory_mode']) && $arr['directory_mode'] == 'primary')
$site_directory = DIRECTORY_MODE_PRIMARY;
- if ($arr['directory_mode'] == 'secondary')
+ if (isset($arr['directory_mode']) && $arr['directory_mode'] == 'secondary')
$site_directory = DIRECTORY_MODE_SECONDARY;
- if ($arr['directory_mode'] == 'standalone')
+ if (isset($arr['directory_mode']) && $arr['directory_mode'] == 'standalone')
$site_directory = DIRECTORY_MODE_STANDALONE;
$register_policy = 0;
- if ($arr['register_policy'] == 'closed')
+ if (isset($arr['register_policy']) && $arr['register_policy'] == 'closed')
$register_policy = REGISTER_CLOSED;
- if ($arr['register_policy'] == 'open')
+ if (isset($arr['register_policy']) && $arr['register_policy'] == 'open')
$register_policy = REGISTER_OPEN;
- if ($arr['register_policy'] == 'approve')
+ if (isset($arr['register_policy']) && $arr['register_policy'] == 'approve')
$register_policy = REGISTER_APPROVE;
$access_policy = 0;
if (array_key_exists('access_policy', $arr)) {
- if ($arr['access_policy'] === 'private')
+ if (isset($arr['access_policy']) && $arr['access_policy'] === 'private')
$access_policy = ACCESS_PRIVATE;
- if ($arr['access_policy'] === 'paid')
+ if (isset($arr['access_policy']) && $arr['access_policy'] === 'paid')
$access_policy = ACCESS_PAID;
- if ($arr['access_policy'] === 'free')
+ if (isset($arr['access_policy']) && $arr['access_policy'] === 'free')
$access_policy = ACCESS_FREE;
- if ($arr['access_policy'] === 'tiered')
+ if (isset($arr['access_policy']) && $arr['access_policy'] === 'tiered')
$access_policy = ACCESS_TIERED;
}
@@ -2916,7 +2939,7 @@ class Libzot {
$ret['mail'] = map_scope(PermissionLimits::Get($e['channel_id'], 'post_mail'));
if ($deleted)
- $ret['deleted'] = $deleted;
+ $ret['deleted'] = true;
if (intval($e['channel_removed'])) {
$ret['deleted_locally'] = true;
@@ -2988,18 +3011,17 @@ class Libzot {
$signing_key = get_config('system', 'prvkey');
$sig_method = get_config('system', 'signature_algorithm', 'sha256');
- $ret = [];
- $ret['site'] = [];
- $ret['site']['url'] = z_root();
- $ret['site']['site_sig'] = self::sign(z_root(), $signing_key);
- $ret['site']['post'] = z_root() . '/zot';
- $ret['site']['openWebAuth'] = z_root() . '/owa';
- $ret['site']['authRedirect'] = z_root() . '/magic';
- $ret['site']['sitekey'] = get_config('system', 'pubkey');
+ $ret = [];
+ $ret['site'] = [];
+ $ret['site']['url'] = z_root();
+ $ret['site']['site_sig'] = self::sign(z_root(), $signing_key);
+ $ret['site']['post'] = z_root() . '/zot';
+ $ret['site']['openWebAuth'] = z_root() . '/owa';
+ $ret['site']['authRedirect'] = z_root() . '/magic';
+ $ret['site']['sitekey'] = get_config('system', 'pubkey');
+ $ret['site']['directory_mode'] = 'normal';
$dirmode = get_config('system', 'directory_mode');
- if (($dirmode === false) || ($dirmode == DIRECTORY_MODE_NORMAL))
- $ret['site']['directory_mode'] = 'normal';
if ($dirmode == DIRECTORY_MODE_PRIMARY)
$ret['site']['directory_mode'] = 'primary';
diff --git a/Zotlabs/Lib/Libzotdir.php b/Zotlabs/Lib/Libzotdir.php
index 4f35a1b80..fa691080f 100644
--- a/Zotlabs/Lib/Libzotdir.php
+++ b/Zotlabs/Lib/Libzotdir.php
@@ -145,8 +145,8 @@ class Libzotdir {
if(! $directory_sort_order)
$directory_sort_order = 'date';
- $current_order = (($_REQUEST['order']) ? $_REQUEST['order'] : $directory_sort_order);
- $suggest = (($_REQUEST['suggest']) ? '&suggest=' . $_REQUEST['suggest'] : '');
+ $current_order = $_REQUEST['order'] ?? $directory_sort_order;
+ $suggest = ((isset($_REQUEST['suggest'])) ? '&suggest=' . $_REQUEST['suggest'] : '');
$url = 'directory?f=';
@@ -453,22 +453,29 @@ class Libzotdir {
if (! $hash)
return false;
- $arr = array();
-
- $arr['xprof_hash'] = $hash;
- $arr['xprof_dob'] = (($profile['birthday'] === '0000-00-00') ? $profile['birthday'] : datetime_convert('','',$profile['birthday'],'Y-m-d')); // !!!! check this for 0000 year
- $arr['xprof_age'] = (($profile['age']) ? intval($profile['age']) : 0);
- $arr['xprof_desc'] = (($profile['description']) ? htmlspecialchars($profile['description'], ENT_COMPAT,'UTF-8',false) : '');
- $arr['xprof_gender'] = (($profile['gender']) ? htmlspecialchars($profile['gender'], ENT_COMPAT,'UTF-8',false) : '');
- $arr['xprof_marital'] = (($profile['marital']) ? htmlspecialchars($profile['marital'], ENT_COMPAT,'UTF-8',false) : '');
- $arr['xprof_sexual'] = (($profile['sexual']) ? htmlspecialchars($profile['sexual'], ENT_COMPAT,'UTF-8',false) : '');
- $arr['xprof_locale'] = (($profile['locale']) ? htmlspecialchars($profile['locale'], ENT_COMPAT,'UTF-8',false) : '');
- $arr['xprof_region'] = (($profile['region']) ? htmlspecialchars($profile['region'], ENT_COMPAT,'UTF-8',false) : '');
- $arr['xprof_postcode'] = (($profile['postcode']) ? htmlspecialchars($profile['postcode'], ENT_COMPAT,'UTF-8',false) : '');
- $arr['xprof_country'] = (($profile['country']) ? htmlspecialchars($profile['country'], ENT_COMPAT,'UTF-8',false) : '');
- $arr['xprof_about'] = (($profile['about']) ? htmlspecialchars($profile['about'], ENT_COMPAT,'UTF-8',false) : '');
- $arr['xprof_homepage'] = (($profile['homepage']) ? htmlspecialchars($profile['homepage'], ENT_COMPAT,'UTF-8',false) : '');
- $arr['xprof_hometown'] = (($profile['hometown']) ? htmlspecialchars($profile['hometown'], ENT_COMPAT,'UTF-8',false) : '');
+ $arr = [];
+
+ $arr['xprof_hash'] = $hash;
+ $arr['xprof_dob'] = '0000-00-00';
+
+ if (isset($profile['birthday'])) {
+ $arr['xprof_dob'] = (($profile['birthday'] === '0000-00-00')
+ ? $profile['birthday']
+ : datetime_convert('', '', $profile['birthday'], 'Y-m-d')); // !!!! check this for 0000 year
+ }
+
+ $arr['xprof_age'] = ((isset($profile['age']) && $profile['age']) ? intval($profile['age']) : 0);
+ $arr['xprof_desc'] = ((isset($profile['description']) && $profile['description']) ? htmlspecialchars($profile['description'], ENT_COMPAT,'UTF-8',false) : '');
+ $arr['xprof_gender'] = ((isset($profile['gender']) && $profile['gender']) ? htmlspecialchars($profile['gender'], ENT_COMPAT,'UTF-8',false) : '');
+ $arr['xprof_marital'] = ((isset($profile['marital']) && $profile['marital']) ? htmlspecialchars($profile['marital'], ENT_COMPAT,'UTF-8',false) : '');
+ $arr['xprof_sexual'] = ((isset($profile['sexual']) && $profile['sexual']) ? htmlspecialchars($profile['sexual'], ENT_COMPAT,'UTF-8',false) : '');
+ $arr['xprof_locale'] = ((isset($profile['locale']) && $profile['locale']) ? htmlspecialchars($profile['locale'], ENT_COMPAT,'UTF-8',false) : '');
+ $arr['xprof_region'] = ((isset($profile['region']) && $profile['region']) ? htmlspecialchars($profile['region'], ENT_COMPAT,'UTF-8',false) : '');
+ $arr['xprof_postcode'] = ((isset($profile['postcode']) && $profile['postcode']) ? htmlspecialchars($profile['postcode'], ENT_COMPAT,'UTF-8',false) : '');
+ $arr['xprof_country'] = ((isset($profile['country']) && $profile['country']) ? htmlspecialchars($profile['country'], ENT_COMPAT,'UTF-8',false) : '');
+ $arr['xprof_about'] = ((isset($profile['about']) && $profile['about']) ? htmlspecialchars($profile['about'], ENT_COMPAT,'UTF-8',false) : '');
+ $arr['xprof_homepage'] = ((isset($profile['homepage']) && $profile['homepage']) ? htmlspecialchars($profile['homepage'], ENT_COMPAT,'UTF-8',false) : '');
+ $arr['xprof_hometown'] = ((isset($profile['hometown']) && $profile['hometown']) ? htmlspecialchars($profile['hometown'], ENT_COMPAT,'UTF-8',false) : '');
$clean = array();
if (array_key_exists('keywords', $profile) and is_array($profile['keywords'])) {
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php
index 8cc0f6aa5..472e2c6db 100644
--- a/Zotlabs/Lib/ThreadItem.php
+++ b/Zotlabs/Lib/ThreadItem.php
@@ -240,6 +240,7 @@ class ThreadItem {
}
$like_button_label = tt('Like','Likes',$like_count,'noun');
+ $showdislike = '';
if (feature_enabled($conv->get_profile_owner(),'dislike')) {
$dislike_count = ((x($conv_responses['dislike'],$item['mid'])) ? $conv_responses['dislike'][$item['mid']] : '');
$dislike_list = ((x($conv_responses['dislike'],$item['mid'])) ? $conv_responses['dislike'][$item['mid'] . '-l'] : '');
@@ -250,11 +251,11 @@ class ThreadItem {
} else {
$dislike_list_part = '';
}
+
+ $showdislike = ((x($conv_responses['dislike'],$item['mid'])) ? format_like($conv_responses['dislike'][$item['mid']],$conv_responses['dislike'][$item['mid'] . '-l'],'dislike',$item['mid']) : '');
}
$showlike = ((x($conv_responses['like'],$item['mid'])) ? format_like($conv_responses['like'][$item['mid']],$conv_responses['like'][$item['mid'] . '-l'],'like',$item['mid']) : '');
- $showdislike = ((x($conv_responses['dislike'],$item['mid']) && feature_enabled($conv->get_profile_owner(),'dislike'))
- ? format_like($conv_responses['dislike'][$item['mid']],$conv_responses['dislike'][$item['mid'] . '-l'],'dislike',$item['mid']) : '');
/*
* We should avoid doing this all the time, but it depends on the conversation mode
@@ -298,7 +299,7 @@ class ThreadItem {
}
$has_bookmarks = false;
- if(Apps::system_app_installed(local_channel(), 'Bookmarks') && is_array($item['term'])) {
+ if(Apps::system_app_installed(local_channel(), 'Bookmarks') && isset($item['term']) && is_array($item['term'])) {
foreach($item['term'] as $t) {
if(($t['ttype'] == TERM_BOOKMARK))
$has_bookmarks = true;
diff --git a/Zotlabs/Lib/Webfinger.php b/Zotlabs/Lib/Webfinger.php
index 8484fb797..16d54010c 100644
--- a/Zotlabs/Lib/Webfinger.php
+++ b/Zotlabs/Lib/Webfinger.php
@@ -53,7 +53,7 @@ class Webfinger {
if(strpos($resource,'http') === 0) {
$m = parse_url($resource);
if($m) {
- if($m['scheme'] !== 'https') {
+ if(isset($m['scheme']) && $m['scheme'] !== 'https') {
return false;
}
self::$server = $m['host'] . ((isset($m['port'])) ? ':' . $m['port'] : '');
diff --git a/Zotlabs/Lib/XConfig.php b/Zotlabs/Lib/XConfig.php
index c5a108ac9..76ac8dc7a 100644
--- a/Zotlabs/Lib/XConfig.php
+++ b/Zotlabs/Lib/XConfig.php
@@ -162,7 +162,7 @@ class XConfig {
*/
static public function Delete($xchan, $family, $key) {
- if(x(\App::$config[$xchan][$family], $key))
+ if(isset(\App::$config[$xchan][$family][$key]))
unset(\App::$config[$xchan][$family][$key]);
$ret = q("DELETE FROM xconfig WHERE xchan = '%s' AND cat = '%s' AND k = '%s'",