diff options
author | Mario <mario@mariovavti.com> | 2021-03-10 13:18:12 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-03-10 13:18:12 +0000 |
commit | 440a132c6be512314484b7b331fab5dab92e5fad (patch) | |
tree | b182fb923f7a6de0c0149c423fb8da6c502b0b0e | |
parent | f8447521a84c0eb30c08da212e8156256558617b (diff) | |
parent | c8050ea86587b460769a32be5c55a91fb91c2414 (diff) | |
download | volse-hubzilla-440a132c6be512314484b7b331fab5dab92e5fad.tar.gz volse-hubzilla-440a132c6be512314484b7b331fab5dab92e5fad.tar.bz2 volse-hubzilla-440a132c6be512314484b7b331fab5dab92e5fad.zip |
Merge branch 'dev' of https://framagit.org/hubzilla/core into dev
-rw-r--r-- | Zotlabs/Lib/Queue.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Channel.php | 10 | ||||
-rw-r--r-- | Zotlabs/Widget/Cover_photo.php | 2 | ||||
-rw-r--r-- | Zotlabs/Widget/Notifications.php | 6 | ||||
-rw-r--r-- | Zotlabs/Widget/Pinned.php | 28 | ||||
-rw-r--r-- | boot.php | 5 | ||||
-rw-r--r-- | include/html2plain.php | 47 | ||||
-rw-r--r-- | include/network.php | 12 |
8 files changed, 67 insertions, 45 deletions
diff --git a/Zotlabs/Lib/Queue.php b/Zotlabs/Lib/Queue.php index 779719d8b..ba314ded3 100644 --- a/Zotlabs/Lib/Queue.php +++ b/Zotlabs/Lib/Queue.php @@ -116,7 +116,7 @@ class Queue { dbesc(($arr['driver']) ? $arr['driver'] : 'zot6'), dbesc($arr['posturl']), intval(1), - intval(($arr['priority']) ? $arr['priority'] : 0), + intval(isset($arr['priority']) ? $arr['priority'] : 0), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 233e5ac86..ab5000b9a 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -27,7 +27,7 @@ class Channel extends Controller { function init() { - if (in_array(substr($_GET['search'], 0, 1), ['@', '!', '?']) || strpos($_GET['search'], 'https://') === 0) + if (array_key_exists('search', $_GET) && (in_array(substr($_GET['search'], 0, 1), ['@', '!', '?']) || strpos($_GET['search'], 'https://') === 0)) goaway(z_root() . '/search?f=&search=' . $_GET['search']); $which = null; @@ -155,7 +155,7 @@ class Channel extends Controller { intval($channel['channel_id']) ); - opengraph_add_meta($r ? $r[0] : [], $channel); + opengraph_add_meta((isset($r) && count($r) ? $r[0] : []), $channel); } function get($update = 0, $load = false) { @@ -168,7 +168,7 @@ class Channel extends Controller { if (strpos($mid, 'b64.') === 0) $decoded = @base64url_decode(substr($mid, 4)); - if ($decoded) + if (isset($decoded)) $mid = $decoded; $datequery = ((x($_GET, 'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : ''); @@ -420,7 +420,7 @@ class Channel extends Controller { if ((!$update) && (!$load)) { - if ($decoded) + if (isset($decoded)) $mid = 'b64.' . base64url_encode($mid); // This is ugly, but we can't pass the profile_uid through the session to the ajax updater, @@ -486,7 +486,7 @@ class Channel extends Controller { $o .= conversation($items, $mode, $update, $page_mode); - if ($mid && $items[0]['title']) + if ($mid && count($items) > 0 && isset($items[0]['title'])) App::$page['title'] = $items[0]['title'] . " - " . App::$page['title']; } diff --git a/Zotlabs/Widget/Cover_photo.php b/Zotlabs/Widget/Cover_photo.php index 955048992..97323ea8c 100644 --- a/Zotlabs/Widget/Cover_photo.php +++ b/Zotlabs/Widget/Cover_photo.php @@ -9,7 +9,7 @@ class Cover_photo { require_once('include/channel.php'); $o = ''; - if(\App::$module == 'channel' && $_REQUEST['mid']) + if(\App::$module == 'channel' && isset($_REQUEST['mid'])) return ''; $channel_id = 0; diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php index e2a543f80..dd5a6cd46 100644 --- a/Zotlabs/Widget/Notifications.php +++ b/Zotlabs/Widget/Notifications.php @@ -175,13 +175,13 @@ class Notifications { ]; } - $o = replace_macros(get_markup_template('notifications_widget.tpl'), array( + $o = replace_macros(get_markup_template('notifications_widget.tpl'), [ '$module' => \App::$module, '$notifications' => $notifications, '$no_notifications' => t('Sorry, you have got no notifications at the moment'), '$loading' => t('Loading'), - '$startpage' => $channel['channel_startpage'] - )); + '$startpage' => ($channel ? $channel['channel_startpage'] : '') + ]); return $o; diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php index 0a7806908..cad139a91 100644 --- a/Zotlabs/Widget/Pinned.php +++ b/Zotlabs/Widget/Pinned.php @@ -43,7 +43,7 @@ class Pinned { $midb64 = 'b64.' . base64url_encode($item['mid']); - if(in_array($observer['xchan_hash'], get_pconfig($item['uid'], 'pinned_hide', $midb64, []))) + if(isset($observer['xchan_hash']) && in_array($observer['xchan_hash'], get_pconfig($item['uid'], 'pinned_hide', $midb64, []))) continue; $author = channelx_by_hash($item['author_xchan']); @@ -67,7 +67,7 @@ class Pinned { $conv_responses['attendno'] = [ 'title' => t('Not attending','title') ]; $conv_responses['attendmaybe'] = [ 'title' => t('Might attend','title') ]; if($commentable && $observer) { - $attend = array( t('I will attend'), t('I will not attend'), t('I might attend')); + $attend = [ t('I will attend'), t('I will not attend'), t('I might attend') ]; $isevent = true; } } @@ -78,7 +78,7 @@ class Pinned { $conv_responses['disagree'] = [ 'title' => t('Disagree','title') ]; $conv_responses['abstain'] = [ 'title' => t('Abstain','title') ]; if($commentable && $observer) { - $conlabels = array( t('I agree'), t('I disagree'), t('I abstain')); + $conlabels = [ t('I agree'), t('I disagree'), t('I abstain') ]; $canvote = true; } } @@ -93,14 +93,13 @@ class Pinned { // This actually turns out not to be possible in some protocol stacks without opening up hundreds of new issues. // Will allow it only for uri resolvable sources. if(strpos($item['mid'],'http') === 0) { - $share = []; //Not yet ready for primetime - //$share = array( t('Repeat This'), t('repeat')); + $share = []; // Isn't yet ready for primetime + //$share = [ t('Repeat This'), t('repeat') ]; } - $embed = array( t('Share This'), t('share')); + $embed = [ t('Share This'), t('share') ]; } - - if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) - $is_new = true; + + $is_new = boolval(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0); $body = prepare_body($item,true); @@ -118,7 +117,7 @@ class Pinned { 'isevent' => $isevent, 'attend' => $attend, 'consensus' => $consensus, - 'conlabels' => $conlabels, + 'conlabels' => ($canvote ? $conlabels : []), 'canvote' => $canvote, 'linktitle' => sprintf( t('View %s\'s profile - %s'), $profile_name, ($author['xchan_addr'] ? $author['xchan_addr'] : $author['xchan_url']) ), 'olinktitle' => sprintf( t('View %s\'s profile - %s'), $owner['xchan_name'], ($owner['xchan_addr'] ? $owner['xchan_addr'] : $owner['xchan_url']) ), @@ -135,7 +134,6 @@ class Pinned { 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), 'editedtime' => (($item['edited'] != $item['created']) ? sprintf( t('last edited: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r') ) : ''), 'expiretime' => ($item['expires'] > NULL_DATE ? sprintf( t('Expires: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['expires'], 'r') ) : ''), - 'lock' => $lock, 'verified' => $verified, 'forged' => $forged, 'location' => $location, @@ -150,12 +148,12 @@ class Pinned { 'event' => $body['event'], 'has_tags' => (($body['tags'] || $body['categories'] || $body['mentions'] || $body['attachments'] || $body['folders']) ? true : false), // Item toolbar buttons - 'share' => $share, - 'embed' => $embed, + 'share' => (isset($share) && count($share) ? $share : false), + 'embed' => (isset($embed) && count($embed) ? $embed : false), 'plink' => get_plink($item), 'pinned' => t('Pinned post'), - 'pinme' => (($observer['xchan_hash'] == $owner['xchan_hash']) ? t('Unpin from the top') : ''), - 'hide' => (! $is_new && $observer && ($observer['xchan_hash'] != $owner['xchan_hash']) ? t("Don't show") : ''), + 'pinme' => (isset($observer['xchan_hash']) && $observer['xchan_hash'] == $owner['xchan_hash'] ? t('Unpin from the top') : ''), + 'hide' => (! $is_new && isset($observer['xchan_hash']) && $observer['xchan_hash'] != $owner['xchan_hash'] ? t("Don't show") : ''), // end toolbar buttons 'modal_dismiss' => t('Close'), 'responses' => $conv_responses @@ -2316,13 +2316,14 @@ function construct_page() { $navbar = get_pconfig($uid,'system','navbar',$navbar); } - if($comanche && App::$layout['navbar']) { + if($comanche && isset(App::$layout['navbar'])) { $navbar = App::$layout['navbar']; } if (App::$module == 'setup') { $installing = true; - } else { + } + else { nav($navbar); } diff --git a/include/html2plain.php b/include/html2plain.php index 91a1f14cb..bf8581bdb 100644 --- a/include/html2plain.php +++ b/include/html2plain.php @@ -76,28 +76,47 @@ function quotelevel($message, $wraplength = 75) return(implode("\n", $newlines)); } + function collecturls($message) { + $pattern = '/<a.*?href="(.*?)".*?>(.*?)<\/a>/is'; preg_match_all($pattern, $message, $result, PREG_SET_ORDER); - - $urls = array(); - foreach ($result as $treffer) { - // A list of some links that should be ignored - $list = array("/user/", "/tag/", "/group/", "/profile/", "/channel/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/", - "//facebook.com/profile.php?id=", "//plus.google.com/"); - foreach ($list as $listitem) - if (strpos($treffer[1], $listitem) !== false) - $ignore = true; - - if ((strpos($treffer[1], "//plus.google.com/") !== false) and (strpos($treffer[1], "/posts") !== false)) + + $urls = []; + if ($result) { + $ignore = false; + foreach ($result as $treffer) { + // A list of some links that should be ignored + $list = [ + "/user/", + "/tag/", + "/group/", + "/profile/", + "/channel/", + "/search?search=", + "/search?tag=", + "mailto:", + "/u/", + "/node/", + "//facebook.com/profile.php?id=", + "//plus.google.com/" + ]; + foreach ($list as $listitem) + if (strpos($treffer[1], $listitem) !== false) + $ignore = true; + + if ((strpos($treffer[1], "//plus.google.com/") !== false) and (strpos($treffer[1], "/posts") !== false)) $ignore = false; - - if (!$ignore) - $urls[$treffer[1]] = $treffer[1]; + + if (! $ignore) + $urls[$treffer[1]] = $treffer[1]; + } } + return($urls); } + function html2plain($html, $wraplength = 75, $compact = false) { diff --git a/include/network.php b/include/network.php index f5ff48fce..fcc7b4289 100644 --- a/include/network.php +++ b/include/network.php @@ -1134,11 +1134,15 @@ function discover_by_webbie($webbie, $protocol = '') { foreach($x['links'] as $link) { if(array_key_exists('rel',$link)) { if($link['rel'] === PROTOCOL_ZOT6 && ((! $protocol) || (strtolower($protocol) === 'zot6'))) { + logger('zot6 found for ' . $webbie, LOGGER_DEBUG); $record = Zotfinger::exec($link['href']); + if (! $record) { + logger('Record not found for ' . $link['href']); + continue; + } // Check the HTTP signature - $hsig = $record['signature']; if($hsig && $hsig['signer'] === $link['href'] && $hsig['header_valid'] === true && $hsig['content_valid'] === true) $hsig_valid = true; @@ -1226,7 +1230,7 @@ function webfinger_rfc7033($webbie, $zot = false) { if($m['scheme'] !== 'https') return false; - $rhs = $m['host'] . (($m['port']) ? ':' . $m['port'] : ''); + $rhs = $m['host'] . (array_key_exists('port', $m) ? ':' . $m['port'] : ''); $resource = urlencode($webbie); } } @@ -1957,10 +1961,10 @@ function service_plink($contact, $guid) { $m = parse_url($contact['xchan_url']); if($m) { - $url = $m['scheme'] . '://' . $m['host'] . (($m['port']) ? ':' . $m['port'] : ''); + $url = $m['scheme'] . '://' . $m['host'] . (array_key_exists('port', $m) ? ':' . $m['port'] : ''); } else { - $url = 'https://' . substr($contact['xchan_addr'],strpos($contact['xchan_addr'],'@')+1); + $url = 'https://' . substr($contact['xchan_addr'], strpos($contact['xchan_addr'], '@') + 1); } $handle = substr($contact['xchan_addr'], 0, strpos($contact['xchan_addr'],'@')); |