aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-09-08 20:02:22 +0000
committerMario <mario@mariovavti.com>2022-09-08 20:02:22 +0000
commit990a3af2a7349e07c10224cf2a023d179ecfd6ca (patch)
tree75c6f7bcb2f7d630a3fc5395e7f3480541e4fe25 /include
parent1f5a23143aa5aa1fb3273b8a9c74782cd0441fde (diff)
downloadvolse-hubzilla-990a3af2a7349e07c10224cf2a023d179ecfd6ca.tar.gz
volse-hubzilla-990a3af2a7349e07c10224cf2a023d179ecfd6ca.tar.bz2
volse-hubzilla-990a3af2a7349e07c10224cf2a023d179ecfd6ca.zip
php8: random cleanup and warning fixes
Diffstat (limited to 'include')
-rw-r--r--include/auth.php4
-rw-r--r--include/bbcode.php16
-rw-r--r--include/channel.php15
-rw-r--r--include/conversation.php68
-rw-r--r--include/text.php16
5 files changed, 49 insertions, 70 deletions
diff --git a/include/auth.php b/include/auth.php
index 8a83f16fe..4f4d26a6c 100644
--- a/include/auth.php
+++ b/include/auth.php
@@ -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));
diff --git a/include/bbcode.php b/include/bbcode.php
index 100991afd..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);
}
diff --git a/include/channel.php b/include/channel.php
index 0d02dff1e..68e7fdf31 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -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,7 +1568,7 @@ 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
@@ -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;
}
@@ -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,
diff --git a/include/conversation.php b/include/conversation.php
index d450bc609..fe001a79d 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -165,7 +165,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 +567,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";
}
}
@@ -970,7 +967,7 @@ function best_link_url($item) {
$best_url = '';
$sparkle = false;
- $clean_url = normalise_link($item['author-link']);
+ $clean_url = isset($item['author-link']) ? normalise_link($item['author-link']) : '';
if((local_channel()) && (local_channel() == $item['uid'])) {
if(isset(App::$contacts) && x(App::$contacts,$clean_url)) {
@@ -1071,6 +1068,8 @@ function thread_author_menu($item, $mode = '') {
$profile_link = chanlink_hash($item['author_xchan']);
$contact = false;
+ $follow_url = '';
+
if($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 +1082,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 +1142,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',
@@ -1766,11 +1740,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/text.php b/include/text.php
index 0c806d009..87aaf7bf8 100644
--- a/include/text.php
+++ b/include/text.php
@@ -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'));
@@ -1593,7 +1595,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 +1625,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 +1649,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 +1672,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 +1791,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,6 +1830,7 @@ function prepare_body(&$item,$attach = false,$opts = false) {
$tags = format_hashtags($item);
+ $mentions = '';
if($item['resource_type'] == 'photo')
$mentions = format_mentions($item);