diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/auth.php | 8 | ||||
-rw-r--r-- | include/bbcode.php | 33 | ||||
-rw-r--r-- | include/channel.php | 35 | ||||
-rw-r--r-- | include/conversation.php | 117 | ||||
-rw-r--r-- | include/event.php | 12 | ||||
-rw-r--r-- | include/feedutils.php | 29 | ||||
-rw-r--r-- | include/items.php | 62 | ||||
-rw-r--r-- | include/js_strings.php | 1 | ||||
-rw-r--r-- | include/nav.php | 13 | ||||
-rw-r--r-- | include/network.php | 2 | ||||
-rw-r--r-- | include/photo/photo_driver.php | 25 | ||||
-rw-r--r-- | include/security.php | 3 | ||||
-rw-r--r-- | include/taxonomy.php | 98 | ||||
-rw-r--r-- | include/text.php | 60 |
14 files changed, 248 insertions, 250 deletions
diff --git a/include/auth.php b/include/auth.php index 07b8e2971..4f4d26a6c 100644 --- a/include/auth.php +++ b/include/auth.php @@ -189,7 +189,7 @@ if((isset($_SESSION)) && (x($_SESSION, 'authenticated')) && call_hooks('logging_out', $args); - if($_SESSION['delegate'] && $_SESSION['delegate_push']) { + if(isset($_SESSION['delegate']) && isset($_SESSION['delegate_push'])) { $_SESSION = $_SESSION['delegate_push']; info( t('Delegation session ended.') . EOL); } @@ -280,8 +280,8 @@ else { // handle a fresh login request - $password = $_POST['main_login_password'] ?? $_POST['modal_login_password']; - $username = $_POST['main_login_username'] ?? $_POST['modal_login_username']; + $password = $_POST['main_login_password'] ?? $_POST['modal_login_password'] ?? ''; + $username = $_POST['main_login_username'] ?? $_POST['modal_login_username'] ?? ''; if($password) $encrypted = hash('whirlpool', trim($password)); @@ -337,7 +337,7 @@ else { // (i.e. expire when the browser is closed), even when there's a time expiration // on the cookie - $remember = $_POST['main_login_remember'] ?? $_POST['modal_login_remember']; + $remember = $_POST['main_login_remember'] ?? $_POST['modal_login_remember'] ?? false; if($remember) { $_SESSION['remember_me'] = 1; diff --git a/include/bbcode.php b/include/bbcode.php index 794cb25d0..6ec24fa0b 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -367,26 +367,30 @@ function bb_format_attachdata($body) { if($data) { $txt = ''; - if($data['url'] && $data['title']) { + if(isset($data['url']) && isset($data['title'])) { $txt .= "\n\n" . '[url=' . $data['url'] . ']' . $data['title'] . '[/url]'; } else { - if($data['url']) { + if(isset($data['url'])) { $txt .= "\n\n" . $data['url']; } - if($data['title']) { + if(isset($data['title'])) { $txt .= "\n\n" . $data['title']; } } - if($data['preview']) { + + if(isset($data['preview'])) { $txt .= "\n\n" . '[img]' . $data['preview'] . '[/img]'; } - if($data['image']) { + + if(isset($data['image'])) { $txt .= "\n\n" . '[img]' . $data['image'] . '[/img]'; } + if(isset($data['text'])) { + $txt .= "\n\n" . $data['text']; + } - $txt .= "\n\n" . $data['text']; return preg_replace('/\[attachment(.*?)\](.*?)\[\/attachment\]/ism',$txt,$body); } @@ -502,32 +506,37 @@ function bb_ShareAttributes($match) { $author = ""; preg_match("/author='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") + if (isset($matches[1]) && $matches[1] !== '') { $author = urldecode($matches[1]); + } $link = ""; preg_match("/link='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") + if (isset($matches[1]) && $matches[1] !== '') { $link = $matches[1]; + } $avatar = ""; preg_match("/avatar='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") + if (isset($matches[1]) && $matches[1] !== '') { $avatar = $matches[1]; + } $profile = ""; preg_match("/profile='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") + if (isset($matches[1]) && $matches[1] !== '') { $profile = $matches[1]; + } $posted = ""; preg_match("/posted='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") + if (isset($matches[1]) && $matches[1] !== '') { $posted = $matches[1]; + } $auth = ""; preg_match("/auth='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") { + if (isset($matches[1]) && $matches[1] !== '') { if($matches[1] === 'true') $auth = true; else diff --git a/include/channel.php b/include/channel.php index 4e84b1b32..a309fa5c8 100644 --- a/include/channel.php +++ b/include/channel.php @@ -1376,19 +1376,19 @@ function profile_load($nickname, $profile = '') { } // get the current observer - $observer = App::get_observer(); + $observer_hash = get_observer_hash(); $can_view_profile = true; // Can the observer see our profile? require_once('include/permissions.php'); - if(! perm_is_allowed($user[0]['channel_id'],$observer['xchan_hash'],'view_profile')) { + if(! perm_is_allowed($user[0]['channel_id'], $observer_hash, 'view_profile')) { $can_view_profile = false; } - if(! $profile) { + if($observer_hash && !$profile) { $r = q("SELECT abook_profile FROM abook WHERE abook_xchan = '%s' and abook_channel = '%d' limit 1", - dbesc($observer['xchan_hash']), + dbesc($observer_hash), intval($user[0]['channel_id']) ); if($r) @@ -1433,10 +1433,10 @@ function profile_load($nickname, $profile = '') { dbesc($p[0]['profile_guid']), intval($p[0]['profile_uid']) ); - if($q) { - $extra_fields = array(); - require_once('include/channel.php'); + $extra_fields = []; + + if($q) { $profile_fields_basic = get_profile_fields_basic(); $profile_fields_advanced = get_profile_fields_advanced(); @@ -1568,21 +1568,21 @@ function profile_edit_menu($uid) { * @param array $profile * @param int $block * @param boolean $show_connect (optional) default true - * @param mixed $zcard (optional) default false + * @param mixed $details (optional) default false * * @return string (HTML) suitable for sidebar inclusion * Exceptions: Returns empty string if passed $profile is wrong type or not populated */ function profile_sidebar($profile, $block = 0, $show_connect = true, $details = false) { - $observer = App::get_observer(); + $observer_hash = get_observer_hash(); $o = ''; $location = false; $pdesc = true; $reddress = true; - if(! perm_is_allowed($profile['uid'],((is_array($observer)) ? $observer['xchan_hash'] : ''),'view_profile')) { + if(! perm_is_allowed($profile['uid'], $observer_hash, 'view_profile')) { $block = true; } @@ -1635,7 +1635,7 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $details = // logger('online: ' . $profile['online']); - if(($profile['hidewall'] && (! local_channel()) && (! remote_channel())) || $block ) { + if((isset($profile['hidewall']) && (! local_channel()) && (! remote_channel())) || $block ) { $location = $reddress = $pdesc = $gender = $marital = $homepage = False; } @@ -1654,7 +1654,7 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $details = $menu = get_pconfig($profile['uid'],'system','channel_menu'); if($menu && ! $block) { require_once('include/menu.php'); - $m = menu_fetch($menu,$profile['uid'],$observer['xchan_hash']); + $m = menu_fetch($menu,$profile['uid'], $observer_hash); if($m) $channel_menu = menu_render($m); } @@ -1664,10 +1664,7 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $details = $channel_menu .= $comanche->block($menublock); } - if($zcard) - $tpl = get_markup_template('profile_vcard_short.tpl'); - else - $tpl = get_markup_template('profile_vcard.tpl'); + $tpl = get_markup_template('profile_vcard.tpl'); $o .= replace_macros($tpl, array( '$details' => $details, @@ -2002,7 +1999,7 @@ function atoken_delete_and_sync($channel_id, $atoken_guid) { * @return int */ function get_theme_uid() { - $uid = (($_REQUEST['puid']) ? intval($_REQUEST['puid']) : 0); + $uid = $_REQUEST['puid'] ?? 0; if(local_channel()) { if((get_pconfig(local_channel(),'system','always_my_theme')) || (! $uid)) return local_channel(); @@ -2010,10 +2007,10 @@ function get_theme_uid() { if(! $uid) { $x = get_sys_channel(); if($x) - return $x['channel_id']; + return intval($x['channel_id']); } - return $uid; + return intval($uid); } /** diff --git a/include/conversation.php b/include/conversation.php index 685e6b15b..2b00c12be 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -102,28 +102,29 @@ function localize_item(&$item){ logger('localize_item: failed to decode object: ' . print_r($item['obj'],true)); } - if(is_array($obj['author']) && $obj['author']['link']) + if(isset($obj['author']) && isset($obj['author']['link'])) $author_link = get_rel_link($obj['author']['link'],'alternate'); - elseif(is_array($obj['actor']) && $obj['actor']['url']) + elseif(isset($obj['actor']) && isset($obj['actor']['url'])) $author_link = ((is_array($obj['actor']['url'])) ? $obj['actor']['url'][0]['href'] : $obj['actor']['url']); - elseif (is_string($obj['actor'])) + elseif (isset($obj['actor']) && is_string($obj['actor'])) $author_link = $obj['actor']; else $author_link = ''; - $author_name = (($obj['author'] && $obj['author']['name']) ? $obj['author']['name'] : ''); + $author_name = $obj['author']['name'] ?? ''; if(!$author_name) - $author_name = ((is_array($obj['actor']) && $obj['actor']['name']) ? $obj['actor']['name'] : ''); + $author_name = $obj['actor']['name'] ?? ''; - if(!$author_name && is_string($obj['actor'])) { + if(!$author_name && isset($obj['actor']) && is_string($obj['actor'])) { $cached_actor = Activity::get_cached_actor($obj['actor']); if (is_array($cached_actor)) { - $author_name = (($cached_actor['name']) ? $cached_actor['name'] : $cached_actor['preferredUsername']); + $author_name = $cached_actor['name'] ?? $cached_actor['preferredUsername']; } } - if(is_array($obj['link'])) + $item_url = ''; + if(isset($obj['link']) && is_array($obj['link'])) $item_url = get_rel_link($obj['link'],'alternate'); if(!$item_url) @@ -165,7 +166,7 @@ function localize_item(&$item){ case 'Note': default: $post_type = t('post'); - if(($obj['parent'] && $obj['id'] != $obj['parent']) || $obj['inReplyTo']) + if(((isset($obj['parent']) && isset($obj['id']) && $obj['id'] != $obj['parent'])) || isset($obj['inReplyTo'])) $post_type = t('comment'); break; } @@ -567,15 +568,12 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa $page_writeable = ($profile_owner == local_channel()); if (!$update) { - $tab = notags(trim((string)$_GET['tab'])); - if ($tab === 'posts') { - // This is ugly, but we can't pass the profile_uid through the session to the ajax updater, - // because browser prefetching might change it on us. We have to deliver it with the page. - - $live_update_div = '<div id="live-channel"></div>' . "\r\n" - . "<script> var profile_uid = " . App::$profile['profile_uid'] - . "; var netargs = '?f='; var profile_page = " . App::$pager['page'] . "; </script>\r\n"; - } + // This is ugly, but we can't pass the profile_uid through the session to the ajax updater, + // because browser prefetching might change it on us. We have to deliver it with the page. + + $live_update_div = '<div id="live-channel"></div>' . "\r\n" + . "<script> var profile_uid = " . App::$profile['profile_uid'] + . "; var netargs = '?f='; var profile_page = " . App::$pager['page'] . "; </script>\r\n"; } } @@ -693,7 +691,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa ]; call_hooks('stream_item',$x); - if($x['item']['blocked']) + if(isset($x['item']['blocked']) && $x['item']['blocked']) continue; $item = $x['item']; @@ -801,7 +799,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa 'id' => (($preview) ? 'P0' : $item['item_id']), 'mid' => gen_link_id($item['mid']), 'mids' => json_encode([gen_link_id($item['mid'])]), - 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, $profile_url), + 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, $profile_link), 'profile_url' => $profile_link, 'thread_action_menu' => thread_action_menu($item,$mode), 'thread_author_menu' => thread_author_menu($item,$mode), @@ -966,14 +964,12 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa function best_link_url($item) { - - $best_url = ''; + $best_url = $item['author-link'] ?? $item['url'] ?? ''; $sparkle = false; + $clean_url = isset($item['author-link']) ? normalise_link($item['author-link']) : ''; - $clean_url = normalise_link($item['author-link']); - - if((local_channel()) && (local_channel() == $item['uid'])) { - if(isset(App::$contacts) && x(App::$contacts,$clean_url)) { + if($clean_url && local_channel() && (local_channel() == $item['uid'])) { + if(isset(App::$contacts) && x(App::$contacts, $clean_url)) { if(App::$contacts[$clean_url]['network'] === NETWORK_DFRN) { $best_url = z_root() . '/redir/' . App::$contacts[$clean_url]['id']; $sparkle = true; @@ -982,12 +978,6 @@ function best_link_url($item) { $best_url = App::$contacts[$clean_url]['url']; } } - if(! $best_url) { - if($item['author-link']) - $best_url = $item['author-link']; - else - $best_url = $item['url']; - } return $best_url; } @@ -1058,20 +1048,22 @@ function author_is_pmable($xchan, $abook) { function thread_author_menu($item, $mode = '') { $menu = []; - + $channel = []; $local_channel = local_channel(); if($local_channel) { if(! count(App::$contacts)) load_contact_links($local_channel); + $channel = App::get_channel(); - $channel_hash = (($channel) ? $channel['channel_hash'] : ''); } $profile_link = chanlink_hash($item['author_xchan']); $contact = false; - if($channel['channel_hash'] !== $item['author_xchan']) { + $follow_url = ''; + + if(isset($channel['channel_hash']) && $channel['channel_hash'] !== $item['author_xchan']) { if(App::$contacts && array_key_exists($item['author_xchan'],App::$contacts)) { $contact = App::$contacts[$item['author_xchan']]; } @@ -1083,19 +1075,18 @@ function thread_author_menu($item, $mode = '') { } } + + $contact_url = ''; + $posts_link = ''; + $poke_link = ''; + if($contact) { $poke_link = ((Apps::system_app_installed($local_channel, 'Poke')) ? z_root() . '/poke/?f=&c=' . $contact['abook_id'] : ''); - if (! intval($contact['abook_self'])) + if (isset($contact['abook_self']) && !intval($contact['abook_self'])) $contact_url = z_root() . '/connections#' . $contact['abook_id']; $posts_link = z_root() . '/network/?cid=' . $contact['abook_id']; - - $clean_url = normalise_link($item['author-link']); } - $rating_enabled = get_config('system','rating_enabled'); - - $ratings_url = (($rating_enabled) ? z_root() . '/ratings/' . urlencode($item['author_xchan']) : ''); - if($profile_link) { $menu[] = [ 'menu' => 'view_profile', @@ -1144,30 +1135,6 @@ function thread_author_menu($item, $mode = '') { ]; } - if($pm_url) { - $menu[] = [ - 'menu' => 'prv_message', - 'title' => t('Message'), - 'icon' => 'fw', - 'action' => '', - 'href' => $pm_url, - 'data' => '', - 'class' => '' - ]; - } - - if($ratings_url) { - $menu[] = [ - 'menu' => 'ratings', - 'title' => t('Ratings'), - 'icon' => 'fw', - 'action' => '', - 'href' => $ratings_url, - 'data' => '', - 'class' => '' - ]; - } - if($poke_link) { $menu[] = [ 'menu' => 'poke', @@ -1431,7 +1398,13 @@ function hz_status_editor($a, $x, $popup = false) { ]; call_hooks('jot_header_tpl_filter',$tplmacros); - App::$page['htmlhead'] .= replace_macros($tpl, $tplmacros); + + if (isset(App::$page['htmlhead'])) { + App::$page['htmlhead'] .= replace_macros($tpl, $tplmacros); + } + else { + App::$page['htmlhead'] = replace_macros($tpl, $tplmacros); + } $tpl = get_markup_template('jot.tpl'); @@ -1760,11 +1733,11 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) { $ret = array(); foreach($response_verbs as $v) { - $ret[$v] = array(); - $ret[$v]['count'] = ((x($conv_responses[$v],$item['mid'])) ? $conv_responses[$v][$item['mid']] : 0); - $ret[$v]['list'] = ((x($conv_responses[$v],$item['mid'])) ? $conv_responses[$v][$item['mid'] . '-l'] : ''); - $ret[$v]['button'] = get_response_button_text($v,$ret[$v]['count']); - $ret[$v]['title'] = $conv_responses[$v]['title']; + $ret[$v] = []; + $ret[$v]['count'] = $conv_responses[$v][$item['mid']] ?? 0; + $ret[$v]['list'] = ((isset($conv_responses[$v][$item['mid']])) ? $conv_responses[$v][$item['mid'] . '-l'] : ''); + $ret[$v]['button'] = get_response_button_text($v, $ret[$v]['count']); + $ret[$v]['title'] = $conv_responses[$v]['title'] ?? ''; $ret[$v]['modal'] = (($ret[$v]['count'] > MAX_LIKERS) ? true : false); } diff --git a/include/event.php b/include/event.php index f62c22792..0805bd2fe 100644 --- a/include/event.php +++ b/include/event.php @@ -28,7 +28,7 @@ function format_event_html($ev) { if(! ((is_array($ev)) && count($ev))) return ''; - $tz = (($ev['timezone']) ? $ev['timezone'] : 'UTC'); + $tz = $ev['timezone'] ?? 'UTC'; $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8:01 AM @@ -39,9 +39,9 @@ function format_event_html($ev) { $o .= '<div class="event-title"><h3><i class="fa fa-calendar"></i> ' . zidify_links(smilies(bbcode($ev['summary']))) . '</h3></div>' . "\r\n"; $o .= '<div class="event-start"><span class="event-label">' . t('Starts:') . '</span> <span class="dtstart" title="' - . datetime_convert('UTC', 'UTC', $ev['dtstart'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )) + . datetime_convert('UTC', 'UTC', $ev['dtstart'], ((isset($ev['adjust']) && $ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )) . '" >' - . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), + . ((isset($ev['adjust']) && $ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $ev['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtstart'] , $bd_format))) @@ -49,9 +49,9 @@ function format_event_html($ev) { if(! $ev['nofinish']) $o .= '<div class="event-end" ><span class="event-label">' . t('Finishes:') . '</span> <span class="dtend" title="' - . datetime_convert('UTC','UTC',$ev['dtend'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )) + . datetime_convert('UTC','UTC',$ev['dtend'], ((isset($ev['adjust']) && $ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )) . '" >' - . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), + . ((isset($ev['adjust']) && $ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $ev['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtend'] , $bd_format ))) @@ -59,7 +59,7 @@ function format_event_html($ev) { $o .= '<div class="event-description">' . zidify_links(smilies(bbcode($ev['description']))) . '</div>' . "\r\n"; - if(strlen($ev['location'])) + if(isset($ev['location']) && $ev['location']) $o .= '<div class="event-location"><span class="event-label"> ' . t('Location:') . '</span> <span class="location">' . zidify_links(smilies(bbcode($ev['location']))) . '</span></div>' . "\r\n"; diff --git a/include/feedutils.php b/include/feedutils.php index 734018922..814e9c163 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -270,18 +270,14 @@ function get_atom_author($feed, $item) { $found_author = $item->get_author(); if($found_author) { - /// @FIXME $rawauthor is undefined here - if($rawauthor) { - if($rawauthor[0]['child'][NAMESPACE_POCO]['displayName'][0]['data']) - $author['full_name'] = unxmlify($rawauthor[0]['child'][NAMESPACE_POCO]['displayName'][0]['data']); + $rawauthor = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author'); + if(isset($rawauthor[0]['child'][NAMESPACE_POCO]['displayName'][0]['data'])) { + $author['full_name'] = unxmlify($rawauthor[0]['child'][NAMESPACE_POCO]['displayName'][0]['data']); } + $author['author_name'] = unxmlify($found_author->get_name()); $author['author_link'] = unxmlify($found_author->get_link()); $author['author_is_feed'] = false; - - $rawauthor = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author'); - //logger('rawauthor: ' . print_r($rawauthor, true)); - } else { $author['author_name'] = unxmlify($feed->get_title()); @@ -497,6 +493,7 @@ function get_atom_elements($feed, $item) { $res['verb'] = unxmlify($rawverb[0]['data']); } + $ostatus_conversation = ''; $rawcnv = $item->get_item_tags(NAMESPACE_OSTATUS, 'conversation'); if($rawcnv) { // new style @@ -1434,9 +1431,9 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { if($author['author_link'] != $contact['xchan_url']) { $name = ''; - if($author['full_name']) { + if(isset($author['full_name'])) { $name = $author['full_name']; - if($author['author_name']) + if(isset($author['author_name'])) $name .= ' (' . $author['author_name'] . ')'; } else { @@ -1468,8 +1465,8 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { // Update content if 'updated' changes if($r) { - if(activity_match($datarray['verb'],ACTIVITY_DELETE) - && $datarray['author_xchan'] === $r[0]['author_xchan']) { + if(isset($datarray['verb']) && activity_match($datarray['verb'], ACTIVITY_DELETE) + && isset($datarray['author_xchan']) && $datarray['author_xchan'] === $r[0]['author_xchan']) { if(! intval($r[0]['item_deleted'])) { logger('deleting item ' . $r[0]['id'] . ' mid=' . $datarray['mid'], LOGGER_DEBUG); drop_item($r[0]['id'],false); @@ -1498,11 +1495,11 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { $datarray['uid'] = $importer['channel_id']; $datarray['aid'] = $importer['channel_account_id']; - if(! link_compare($author['owner_link'], $contact['xchan_url'])) { + if(isset($author['owner_link']) && !link_compare($author['owner_link'], $contact['xchan_url'])) { logger('Correcting item owner.', LOGGER_DEBUG); - $author['owner_name'] = $contact['name']; - $author['owner_link'] = $contact['url']; - $author['owner_avatar'] = $contact['thumb']; + $author['owner_name'] = $contact['xchan_name']; + $author['owner_link'] = $contact['xchan_url']; + $author['owner_avatar'] = $contact['xchan_photo_m']; } if($importer['channel_system']) { diff --git a/include/items.php b/include/items.php index d4c27ab28..be3c83f7d 100644 --- a/include/items.php +++ b/include/items.php @@ -974,10 +974,10 @@ function import_author_rss($x) { $r = xchan_store_lowlevel( [ - 'xchan_hash' => $x['guid'], - 'xchan_guid' => $x['guid'], - 'xchan_url' => $x['url'], - 'xchan_name' => (($name) ? $name : t('(Unknown)')), + 'xchan_hash' => $x['guid'] ?? '', + 'xchan_guid' => $x['guid'] ?? '', + 'xchan_url' => $x['url'] ?? '', + 'xchan_name' => $name ?? '(Unknown)', 'xchan_name_date' => datetime_convert(), 'xchan_network' => 'rss' ] @@ -1163,8 +1163,7 @@ function encode_item($item,$mirror = false,$zap_compat = false) { if($item['comments_closed'] > NULL_DATE) $x['comments_closed'] = $item['comments_closed']; - $x['public_scope'] = $scope; - + $x['public_scope'] = $item['public_policy']; $x['comment_scope'] = $item['comment_policy']; if(! empty($item['term'])) @@ -2432,17 +2431,14 @@ function send_status_notifications($post_id,$item) { return; // my own post - no notification needed - if($item['author_xchan'] === $r[0]['channel_hash']) + if(isset($item['author_xchan']) && $item['author_xchan'] === $r[0]['channel_hash']) return; - // I'm the owner - notify me - - if($item['owner_hash'] === $r[0]['channel_hash']) + if(isset($item['owner_hash']) && $item['owner_hash'] === $r[0]['channel_hash']) $notify = true; // Was I involved in this conversation? - $x = q("select * from item where parent_mid = '%s' and uid = %d", dbesc($item['parent_mid']), intval($item['uid']) @@ -3428,7 +3424,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false function check_item_source($uid, $item) { logger('source: uid: ' . $uid, LOGGER_DEBUG); - $xchan = (($item['source_xchan'] && intval($item['item_uplink'])) ? $item['source_xchan'] : $item['owner_xchan']); + $xchan = ((isset($item['source_xchan']) && $item['source_xchan'] && isset($item['item_uplink']) && $item['item_uplink']) ? $item['source_xchan'] : $item['owner_xchan']); $r = q("select * from source where src_channel_id = %d and ( src_xchan = '%s' or src_xchan = '*' ) limit 1", intval($uid), @@ -4356,7 +4352,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C ); } - if($arr['uid']) { + if(isset($arr['uid'])) { $uid = $arr['uid']; } @@ -4366,30 +4362,30 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $item_uids = " item.uid = " . intval($uid) . " "; } - if($arr['top']) + if(isset($arr['top'])) $sql_options .= " and item_thread_top = 1 "; - if($arr['star']) + if(isset($arr['star'])) $sql_options .= " and item_starred = 1 "; - if($arr['wall']) + if(isset($arr['wall'])) $sql_options .= " and item_wall = 1 "; - if($arr['item_id']) + if(isset($arr['item_id'])) $sql_options .= " and parent = " . intval($arr['item_id']) . " "; - if($arr['mid']) + if(isset($arr['mid'])) $sql_options .= " and parent_mid = '" . dbesc($arr['mid']) . "' "; $sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE $item_uids and item_thread_top = 1 $sql_options $item_normal ) "; - if($arr['since_id']) + if(isset($arr['since_id'])) $sql_extra .= " and item.id > " . intval($arr['since_id']) . " "; - if($arr['cat']) + if(isset($arr['cat'])) $sql_extra .= protect_sprintf(term_query('item', $arr['cat'], TERM_CATEGORY)); - if($arr['gid'] && $uid) { + if(isset($arr['gid']) && $uid) { $r = q("SELECT * FROM pgrp WHERE id = %d AND uid = %d LIMIT 1", intval($arr['group']), intval($uid) @@ -4420,7 +4416,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $x = AccessList::by_hash($uid, $r[0]['hash']); $result['headline'] = sprintf( t('Privacy group: %s'),$x['gname']); } - elseif($arr['cid'] && $uid) { + elseif(isset($arr['cid']) && $uid) { $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d and abook_blocked = 0 limit 1", intval($arr['cid']), @@ -4439,14 +4435,14 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $sql_extra = " AND author_xchan = '" . $channel['channel_hash'] . "' and item_private = 0 $item_normal "; } - if ($arr['datequery']) { + if (isset($arr['datequery'])) { $sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert('UTC','UTC',$arr['datequery'])))); } - if ($arr['datequery2']) { + if (isset($arr['datequery2'])) { $sql_extra3 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert('UTC','UTC',$arr['datequery2'])))); } - if($arr['search']) { + if(isset($arr['search'])) { if(strpos($arr['search'],'#') === 0) $sql_extra .= term_query('item',substr($arr['search'],1),TERM_HASHTAG,TERM_COMMUNITYTAG); else @@ -4455,11 +4451,11 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C ); } - if($arr['file']) { + if(isset($arr['file'])) { $sql_extra .= term_query('item',$arr['files'],TERM_FILE); } - if($arr['conv'] && $channel) { + if(isset($arr['conv']) && $channel) { $sql_extra .= sprintf(" AND parent IN (SELECT distinct parent from item where ( author_xchan like '%s' or item_mentionsme = 1 )) ", dbesc(protect_sprintf($uidhash)) ); @@ -4469,7 +4465,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C // only setup pagination on initial page view $pager_sql = ''; } else { - if(! $arr['total']) { + if(!isset($arr['total'])) { $itemspage = (($channel) ? get_pconfig($uid,'system','itemspage') : 10); App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 10)); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start'])); @@ -4509,19 +4505,19 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C require_once('include/security.php'); $sql_extra .= item_permissions_sql($channel['channel_id'],$observer_hash); - if($arr['pages']) + if(isset($arr['pages'])) $item_restrict = " AND item_type = " . ITEM_TYPE_WEBPAGE . " "; else $item_restrict = " AND item_type = 0 "; - if($arr['item_type'] === '*') + if(isset($arr['item_type']) && $arr['item_type'] === '*') $item_restrict = ''; - if ((($arr['compat']) || ($arr['nouveau'] && ($client_mode & CLIENT_MODE_LOAD))) && $channel) { + if (((isset($arr['compat'])) || (isset($arr['nouveau']) && ($client_mode & CLIENT_MODE_LOAD))) && $channel) { // "New Item View" - show all items unthreaded in reverse created date order - if ($arr['total']) { + if (isset($arr['total'])) { $items = dbq("SELECT count(item.id) AS total FROM item WHERE $item_uids $item_restrict $simple_update $sql_options @@ -4548,7 +4544,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C // Normal conversation view - if($arr['order'] === 'post') + if(isset($arr['order']) && $arr['order'] === 'post') $ordering = "created"; else $ordering = "commented"; diff --git a/include/js_strings.php b/include/js_strings.php index ed73b0420..090d28ce3 100644 --- a/include/js_strings.php +++ b/include/js_strings.php @@ -3,6 +3,7 @@ function js_strings() { return replace_macros(get_markup_template('js_strings.tpl'), array( '$delitem' => t('Delete this item?'), + '$itemdel' => t('Item deleted'), '$comment' => t('Comment'), '$showmore' => sprintf( t('%s show all'), '<i class=\'fa fa-chevron-down\'></i>'), '$showfewer' => sprintf( t('%s show less'), '<i class=\'fa fa-chevron-up\'></i>'), diff --git a/include/nav.php b/include/nav.php index c2c87232b..65d5a3ef6 100644 --- a/include/nav.php +++ b/include/nav.php @@ -19,6 +19,8 @@ function nav($template = 'default') { App::$page['htmlhead'] .= '<script>$(document).ready(function() { $("#nav-search-text").search_autocomplete(\'' . z_root() . '/acl' . '\');});</script>'; $is_owner = (((local_channel()) && ((App::$profile_uid == local_channel()) || (App::$profile_uid == 0))) ? true : false); $observer = App::get_observer(); + $chans = []; + if (local_channel()) { $channel = App::get_channel(); @@ -35,7 +37,7 @@ function nav($template = 'default') { $sitelocation = (($is_owner) ? '' : App::$profile['reddress']); } else { - $sitelocation = ((App::$profile['reddress']) ? App::$profile['reddress'] : '@' . App::get_hostname()); + $sitelocation = ((isset(App::$profile['reddress'])) ? App::$profile['reddress'] : '@' . App::get_hostname()); } require_once('include/conversation.php'); @@ -336,8 +338,8 @@ function nav($template = 'default') { '$featured_apps' => t('Featured Apps'), '$url' => (($url) ? $url : z_root() . '/' . App::$cmd), '$settings_url' => $settings_url, - '$name' => ((!$is_owner) ? App::$profile['fullname'] : ''), - '$thumb' => ((!$is_owner) ? App::$profile['thumb'] : ''), + '$name' => ((!$is_owner && isset(App::$profile['fullname'])) ? App::$profile['fullname'] : ''), + '$thumb' => ((!$is_owner && isset(App::$profile['thumb'])) ? App::$profile['thumb'] : ''), '$form_security_token' => get_form_security_token('pconfig') ]); @@ -414,9 +416,6 @@ function channel_apps($is_owner = false, $nickname = null) { $has_webpages = (($r) ? true : false); - if (x($_GET, 'tab')) - $tab = notags(trim($_GET['tab'])); - $url = z_root() . '/channel/' . $nickname; $pr = z_root() . '/profile/' . $nickname; @@ -522,7 +521,7 @@ function channel_apps($is_owner = false, $nickname = null) { ]; } - $arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => (($tab) ? $tab : false), 'tabs' => $tabs]; + $arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tabs' => $tabs]; call_hooks('channel_apps', $arr); diff --git a/include/network.php b/include/network.php index a236a6f8e..36859bc2f 100644 --- a/include/network.php +++ b/include/network.php @@ -1997,7 +1997,7 @@ function getBestSupportedMimeType($mimeTypes = null, $acceptedTypes = false) { $AcceptTypes = []; if($acceptedTypes === false) - $acceptedTypes = $_SERVER['HTTP_ACCEPT']; + $acceptedTypes = $_SERVER['HTTP_ACCEPT'] ?? ''; if (!$acceptedTypes) { return null; diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index b7ace4f37..14408ea50 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -85,6 +85,10 @@ function guess_image_type($filename, $data = '') { $hdrs = []; $h = explode("\n", $headers); foreach ($h as $l) { + if (strpos($l, ':') === false) { + continue; + } + list($k, $v) = array_map('trim', explode(':', trim($l), 2)); $hdrs[strtolower($k)] = $v; } @@ -251,20 +255,31 @@ function import_xchan_photo($photo, $xchan, $thing = false, $force = false) { $hdrs = []; $h = explode("\n", $result['header']); foreach ($h as $l) { + if (strpos($l, ':') === false) { + continue; + } + list($t,$v) = array_map("trim", explode(":", trim($l), 2)); $hdrs[strtolower($t)] = $v; } + $expires = time() + 86400; + if(array_key_exists('expires', $hdrs)) $expires = strtotime($hdrs['expires']); - if($expires - 60 < time()) - $expires = time() + 60; + + if($expires - 60 < time()) { + $expires = time() + 60; + } else { $cc = ''; - if(array_key_exists('cache-control', $hdrs)) + if(array_key_exists('cache-control', $hdrs)) { $cc = $hdrs['cache-control']; - if(strpos($cc, 'no-cache')) + } + + if(strpos($cc, 'no-cache')) { $expires = time() + 60; + } else { $ttl = (preg_match('/max-age=(\d+)/i', $cc, $o) ? intval($o[1]) : 86400); $expires = time() + $ttl; @@ -289,7 +304,7 @@ function import_xchan_photo($photo, $xchan, $thing = false, $force = false) { $micro = z_root() . '/photo/' . $hash . '-6'; if(isset($result)) q("UPDATE photo SET expires = '%s' WHERE xchan = '%s' and photo_usage = %d and imgscale IN (4, 5, 6)", - dbescdate(gmdate('Y-m-d H:i:s', (isset($expires) ? $expires : time() + 86400))), + dbescdate(gmdate('Y-m-d H:i:s', $expires)), dbesc($xchan), intval(PHOTO_XCHAN) ); diff --git a/include/security.php b/include/security.php index 881adb818..de9f1f337 100644 --- a/include/security.php +++ b/include/security.php @@ -604,7 +604,8 @@ function public_permissions_sql($observer_hash) { function get_form_security_token($typename = '') { $timestamp = time(); - $sec_hash = hash('whirlpool', App::$observer['xchan_guid'] . ((local_channel()) ? App::$channel['channel_prvkey'] : '') . session_id() . $timestamp . $typename); + $guid = App::$observer['xchan_guid'] ?? ''; + $sec_hash = hash('whirlpool', $guid . ((local_channel()) ? App::$channel['channel_prvkey'] : '') . session_id() . $timestamp . $typename); return $timestamp . '.' . $sec_hash; } diff --git a/include/taxonomy.php b/include/taxonomy.php index f765a9f0e..88be43464 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -3,7 +3,7 @@ // post categories and "save to file" use the same item.file table for storage. // We will differentiate the different uses by wrapping categories in angle brackets // and save to file categories in square brackets. -// To do this we need to escape these characters if they appear in our tag. +// To do this we need to escape these characters if they appear in our tag. use Zotlabs\Lib\Cache; @@ -50,10 +50,10 @@ function term_query($table,$s,$type = TERM_UNKNOWN, $type2 = '') { function term_item_parent_query($uid,$table,$s,$type = TERM_UNKNOWN, $type2 = '') { // Allow asterisks for wildcard search - // In theory this means '%' will also do a wildcard search, but there appear to be multiple escape + // In theory this means '%' will also do a wildcard search, but there appear to be multiple escape // issues with '%' in term names and trying to fix this with '\\%' here did not help. // Ideally I think we want '*' to indicate wildcards and allow '%' literally in names, but that is being - // left for another developer on another day. + // left for another developer on another day. $s = str_replace('*','%',$s); @@ -89,11 +89,11 @@ function term_item_parent_query($uid,$table,$s,$type = TERM_UNKNOWN, $type2 = '' function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') { - if(! $term) + if(! $term) return false; - $r = q("select * from term - where uid = %d and oid = %d and otype = %d and ttype = %d + $r = q("select * from term + where uid = %d and oid = %d and otype = %d and ttype = %d and term = '%s' and url = '%s' ", intval($uid), intval($iid), @@ -146,9 +146,9 @@ function format_term_for_display($term) { else return $s; - if($term['url']) + if($term['url']) $s .= '<a href="' . $term['url'] . '">' . htmlspecialchars($term['term'], ENT_COMPAT,'UTF-8') . '</a>'; - else + else $s .= htmlspecialchars($term['term'], ENT_COMPAT,'UTF-8'); return $s; } @@ -177,17 +177,17 @@ function tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0, $re if(! is_array($authors)) $authors = array($authors); - $sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") "; + $sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") "; } if($owner) { $sql_options .= " and owner_xchan = '" . dbesc($owner) . "' "; - } + } // Fetch tags $r = q("select term, count(term) as total from term left join item on term.oid = item.id - where term.uid = %d and term.ttype = %d - and otype = %d and item_type = %d + where term.uid = %d and term.ttype = %d + and otype = %d and item_type = %d $sql_options $item_normal group by term order by total desc %s", intval($uid), @@ -229,19 +229,19 @@ function card_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0 if(! is_array($authors)) $authors = array($authors); - $sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") "; + $sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") "; } if($owner) { $sql_options .= " and owner_xchan = '" . dbesc($owner) . "' "; - } + } // Fetch tags $r = q("select term, count(term) as total from term left join item on term.oid = item.id - where term.uid = %d and term.ttype = %d - and otype = %d and item_type = %d + where term.uid = %d and term.ttype = %d + and otype = %d and item_type = %d $sql_options $item_normal group by term order by total desc %s", intval($uid), @@ -281,18 +281,18 @@ function article_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags if(! is_array($authors)) $authors = array($authors); - $sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") "; + $sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") "; } if($owner) { $sql_options .= " and owner_xchan = '" . dbesc($owner) . "' "; - } + } // Fetch tags $r = q("select term, count(term) as total from term left join item on term.oid = item.id - where term.uid = %d and term.ttype = %d - and otype = %d and item_type = %d + where term.uid = %d and term.ttype = %d + and otype = %d and item_type = %d $sql_options $item_normal group by term order by total desc %s", intval($uid), @@ -321,7 +321,7 @@ function pubtagblock($net,$site,$limit,$recent = 0,$safemode = 1, $type = TERM_H if($r) { $o = '<div class="tagblock widget"><h3>' . (($recent) ? t('Trending') : t('Tags')) . '</h3><div class="tags" align="center">'; - foreach($r as $rr) { + foreach($r as $rr) { $o .= '<span class="tag'.$rr[2].'">#</span><a href="'.$link .'/' . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n"; } $o .= '</div></div>'; @@ -332,7 +332,7 @@ function pubtagblock($net,$site,$limit,$recent = 0,$safemode = 1, $type = TERM_H function pub_tagadelic($net, $site, $limit, $recent, $safemode, $type) { - + $item_normal = item_normal(); $count = intval($limit); $sql_extra = ""; @@ -354,12 +354,12 @@ function pub_tagadelic($net, $site, $limit, $recent, $safemode, $type) { $sql_extra .= " and not term.term in ( " . stringify_array($unsafetags,true) . ") "; } } - + $key = __FUNCTION__ . "-" . md5($site . $recent . $safemode . $limit . $type); - + $content = Cache::get($key, '5 MINUTE'); if(! $content) { - + $content = Cache::get($key, '1 MONTH'); $arr = [ "SELECT term, count(term) AS total FROM term LEFT JOIN item ON term.oid = item.id @@ -373,10 +373,10 @@ function pub_tagadelic($net, $site, $limit, $recent, $safemode, $type) { intval(ITEM_TYPE_POST), (intval($count) ? "LIMIT $count" : '') ]; - + \Zotlabs\Daemon\Master::Summon([ 'Cache_query', $key, base64_encode(json_encode($arr)) ]); } - + $r = unserialize($content); if(! $r) return []; @@ -390,8 +390,8 @@ function dir_tagadelic($count = 0, $hub = '') { $count = intval($count); if($hub) { - $r = q("select xtag_term as term, count(xtag_term) as total from xtag - left join hubloc on xtag_hash = hubloc_hash + $r = q("select xtag_term as term, count(xtag_term) as total from xtag + left join hubloc on xtag_hash = hubloc_hash where xtag_flags = 0 and xtag_hash in (select hubloc_hash from hubloc where hubloc_host = '%s' ) group by xtag_term order by total desc %s", dbesc($hub), @@ -418,7 +418,7 @@ function app_tagblock($link,$count = 0) { if($r) { $o = '<div class="tagblock widget"><h3>' . t('Categories') . '</h3><div class="tags" align="center">'; - foreach($r as $rr) { + foreach($r as $rr) { $o .= '<a href="'.$link .'/' . '?f=&cat=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n"; } $o .= '</div></div>'; @@ -458,7 +458,7 @@ function tagblock($link,$uid,$count = 0,$authors = '',$owner = '', $flags = 0,$r if($r) { $o = '<div class="tagblock widget"><h3>' . t('Tags') . '</h3><div class="tags" align="center">'; - foreach($r as $rr) { + foreach($r as $rr) { $o .= '<span class="tag'.$rr[2].'">#</span><a href="'.$link .'/' . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n"; } $o .= '</div></div>'; @@ -477,9 +477,9 @@ function wtagblock($uid,$count = 0,$authors = '',$owner = '', $flags = 0,$restri $c = q("select channel_address from channel where channel_id = %d limit 1", intval($uid) ); - + $o = '<div class="tagblock widget"><h3>' . t('Tags') . '</h3><div class="tags" align="center">'; - foreach($r as $rr) { + foreach($r as $rr) { $o .= '<span class="tag' . $rr[2] . '">#</span><a href="channel/' . $c[0]['channel_address'] . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n"; } $o .= '</div></div>'; @@ -498,9 +498,9 @@ function catblock($uid,$count = 0,$authors = '',$owner = '', $flags = 0,$restric $c = q("select channel_address from channel where channel_id = %d limit 1", intval($uid) ); - + $o = '<div class="tagblock widget"><h3>' . t('Categories') . '</h3><div class="tags" align="center">'; - foreach($r as $rr) { + foreach($r as $rr) { $o .= '<a href="channel/' . $c[0]['channel_address']. '?f=&cat=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n"; } $o .= '</div></div>'; @@ -518,9 +518,9 @@ function card_catblock($uid,$count = 0,$authors = '',$owner = '', $flags = 0,$re $c = q("select channel_address from channel where channel_id = %d limit 1", intval($uid) ); - + $o = '<div class="tagblock widget"><h3>' . t('Categories') . '</h3><div class="tags" align="center">'; - foreach($r as $rr) { + foreach($r as $rr) { $o .= '<a href="cards/' . $c[0]['channel_address']. '?f=&cat=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n"; } $o .= '</div></div>'; @@ -539,9 +539,9 @@ function article_catblock($uid,$count = 0,$authors = '',$owner = '', $flags = 0, $c = q("select channel_address from channel where channel_id = %d limit 1", intval($uid) ); - + $o = '<div class="tagblock widget"><h3>' . t('Categories') . '</h3><div class="tags" align="center">'; - foreach($r as $rr) { + foreach($r as $rr) { $o .= '<a href="articles/' . $c[0]['channel_address']. '?f=&cat=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n"; } $o .= '</div></div>'; @@ -559,7 +559,7 @@ function dir_tagblock($link,$r) { if($r) { $o = '<div class="dirtagblock widget"><h3>' . t('Keywords') . '</h3><div class="tags" align="center">'; - foreach($r as $rr) { + foreach($r as $rr) { $o .= '<a href="'.$link .'/' . '?f=&keywords=' . urlencode($rr['term']).'" class="tag'.$rr['normalise'].'" rel="nofollow" >'.$rr['term'].'</a> ' . "\r\n"; } $o .= '</div></div>'; @@ -570,8 +570,8 @@ function dir_tagblock($link,$r) { - /** - * verbs: [0] = first person singular, e.g. "I want", [1] = 3rd person singular, e.g. "Bill wants" + /** + * verbs: [0] = first person singular, e.g. "I want", [1] = 3rd person singular, e.g. "Bill wants" * We use the first person form when creating an activity, but the third person for use in activities * FIXME: There is no accounting for verb gender for languages where this is significant. We may eventually * require obj_verbs() to provide full conjugations and specify which form to use in the $_REQUEST params to this module. @@ -606,9 +606,11 @@ function obj_verb_selector($current = '') { function get_things($profile_hash,$uid) { - $sql_extra = (($profile_hash) ? " and obj_page = '" . $profile_hash . "' " : ''); + $sql_extra = permissions_sql($uid); + + $sql_extra_profile = (($profile_hash) ? " and obj_page = '" . $profile_hash . "' " : ''); - $r = q("select * from obj where obj_channel = %d and obj_type = %d $sql_extra order by obj_verb, obj_term", + $r = q("select * from obj where obj_channel = %d and obj_type = %d $sql_extra $sql_extra_profile order by obj_verb, obj_term", intval($uid), intval(TERM_OBJ_THING) ); @@ -619,7 +621,7 @@ function get_things($profile_hash,$uid) { if($r) { - // if no profile_hash was specified (display on profile page mode), match each of the things to a profile name + // if no profile_hash was specified (display on profile page mode), match each of the things to a profile name // (list all my things mode). This is harder than it sounds. foreach($r as $rr) { @@ -632,7 +634,7 @@ function get_things($profile_hash,$uid) { $p = q("select profile_guid as hash, profile_name as name from profile where profile_guid in ( $exp ) "); if($p) { foreach($r as $rr) { - foreach($p as $pp) { + foreach($p as $pp) { if($rr['obj_page'] == $pp['hash']) { $rr['profile_name'] == $pp['name']; } @@ -646,7 +648,7 @@ function get_things($profile_hash,$uid) { // Use the system obj_verbs array as a sort key, since we don't really // want an alphabetic sort. To change the order, use a plugin to // alter the obj_verbs() array or alter it in code. Unknown verbs come - // after the known ones - in no particular order. + // after the known ones - in no particular order. $v = obj_verbs(); foreach($v as $k => $foo) @@ -668,7 +670,7 @@ function get_things($profile_hash,$uid) { $things[$rr['obj_verb']] = array(); $things[$rr['obj_verb']][] = array('term' => $rr['obj_term'],'url' => $rr['obj_url'],'img' => $rr['obj_imgurl'], 'editurl' => z_root() . '/thing/' . $rr['obj_obj'], 'profile' => $rr['profile_name'],'term_hash' => $rr['obj_obj'], 'likes' => $l,'like_count' => count($l),'like_label' => tt('Like','Likes',count($l),'noun')); - } + } $sorted_things = array(); if($things) { foreach($things as $k => $v) { diff --git a/include/text.php b/include/text.php index 0c806d009..37d185ce6 100644 --- a/include/text.php +++ b/include/text.php @@ -1254,26 +1254,24 @@ function sslify($s) { * * \e value is array containing past tense verb, translation of present, translation of past */ function get_poke_verbs() { - if (get_config('system', 'poke_basic')) { - $arr = array( - 'poke' => array('poked', t('poke'), t('poked')), - ); - } else { - $arr = array( - 'poke' => array( 'poked', t('poke'), t('poked')), - 'ping' => array( 'pinged', t('ping'), t('pinged')), - 'prod' => array( 'prodded', t('prod'), t('prodded')), - 'slap' => array( 'slapped', t('slap'), t('slapped')), - 'finger' => array( 'fingered', t('finger'), t('fingered')), - 'rebuff' => array( 'rebuffed', t('rebuff'), t('rebuffed')), - ); - /** - * @hooks poke_verbs - * * \e array associative array with another array as value - */ - call_hooks('poke_verbs', $arr); - } + $arr = [ + 'poke' => ['poked', t('poke'), t('poked')], + 'ping' => ['pinged', t('ping'), t('pinged')], + + // Those might be better suited for a nsfw poke addon + + // 'prod' => ['prodded', t('prod'), t('prodded')], + // 'slap' => ['slapped', t('slap'), t('slapped')], + // 'finger' => ['fingered', t('finger'), t('fingered')], + // 'rebuff' => ['rebuffed', t('rebuff'), t('rebuffed')] + ]; + + /** + * @hooks poke_verbs + * * \e array associative array with another array as value + */ + call_hooks('poke_verbs', $arr); return $arr; } @@ -1544,8 +1542,10 @@ function link_compare($a, $b) { function theme_attachments(&$item) { + $s = ''; $arr = json_decode($item['attach'],true); + if(is_array($arr) && count($arr)) { $attaches = []; @@ -1554,6 +1554,8 @@ function theme_attachments(&$item) { if(isset($r['type'])) $icon = getIconFromType($r['type']); + $label = ''; + if(isset($r['title'])) $label = urldecode(htmlspecialchars($r['title'], ENT_COMPAT, 'UTF-8')); @@ -1566,13 +1568,15 @@ function theme_attachments(&$item) { $title = t('Size') . ' ' . (isset($r['length']) ? userReadableSize($r['length']) : t('unknown')); + $revision = $r['revision'] ?? ''; + require_once('include/channel.php'); if (isset($r['href'])) { if(is_foreigner($item['author_xchan'])) $url = $r['href']; else - $url = z_root() . '/magic?f=&owa=1&hash=' . $item['author_xchan'] . '&bdest=' . bin2hex($r['href'] . '/' . $r['revision']); + $url = z_root() . '/magic?f=&owa=1&hash=' . $item['author_xchan'] . '&bdest=' . bin2hex($r['href'] . '/' . $revision); } //$s .= '<a href="' . $url . '" title="' . $title . '" class="attachlink" >' . $icon . '</a>'; @@ -1593,7 +1597,7 @@ function theme_attachments(&$item) { function format_categories(&$item,$writeable) { $s = ''; - $terms = get_terms_oftype($item['term'],TERM_CATEGORY); + $terms = isset($item['term']) ? get_terms_oftype($item['term'], TERM_CATEGORY) : []; if($terms) { $categories = array(); foreach($terms as $t) { @@ -1623,7 +1627,7 @@ function format_categories(&$item,$writeable) { function format_hashtags(&$item) { $s = ''; - $terms = get_terms_oftype($item['term'], array(TERM_HASHTAG,TERM_COMMUNITYTAG)); + $terms = isset($item['term']) ? get_terms_oftype($item['term'], array(TERM_HASHTAG, TERM_COMMUNITYTAG)) : []; if($terms) { foreach($terms as $t) { $term = htmlspecialchars($t['term'], ENT_COMPAT, 'UTF-8', false) ; @@ -1647,7 +1651,7 @@ function format_hashtags(&$item) { function format_mentions(&$item) { $s = ''; - $terms = get_terms_oftype($item['term'],TERM_MENTION); + $terms = isset($item['term']) ? get_terms_oftype($item['term'], TERM_MENTION) : []; if($terms) { foreach($terms as $t) { if(! isset($t['term'])) @@ -1670,7 +1674,7 @@ function format_mentions(&$item) { function format_filer(&$item) { $s = ''; - $terms = get_terms_oftype($item['term'],TERM_FILE); + $terms = isset($item['term']) ? get_terms_oftype($item['term'], TERM_FILE) : []; if($terms) { $categories = array(); foreach($terms as $t) { @@ -1789,14 +1793,15 @@ function prepare_body(&$item,$attach = false,$opts = false) { $s = $poll; } - $event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event_obj($item['obj']) : false); + $event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event_obj($item['obj']) : []); $prep_arr = [ 'item' => $item, 'html' => $event ? $event['content'] : $s, - 'event' => $event['header'], + 'event' => $event ? $event['header'] : '', 'photo' => $photo ]; + /** * @hooks prepare_body * * \e array \b item @@ -1827,11 +1832,13 @@ function prepare_body(&$item,$attach = false,$opts = false) { $tags = format_hashtags($item); + $mentions = ''; if($item['resource_type'] == 'photo') $mentions = format_mentions($item); $categories = format_categories($item,$writeable); + $filer = ''; if(local_channel() == $item['uid']) $filer = format_filer($item); @@ -3013,6 +3020,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $fn_results = []; $access_tag = EMPTY_STR; + $url = EMPTY_STR; // $r is set if we found something |