even more php8 stuff

This commit is contained in:
nobody 2021-03-11 16:03:45 -08:00
parent 6feff1b31c
commit 3b67277ff8
13 changed files with 85 additions and 58 deletions

View file

@ -103,7 +103,7 @@ class ThreadItem {
$is_item = false;
$osparkle = '';
$total_children = $this->count_descendants();
$unseen_comments = (($item['real_uid']) ? 0 : $this->count_unseen_descendants());
$unseen_comments = ((isset($item['real_uid']) && $item['real_uid']) ? 0 : $this->count_unseen_descendants());
$conv = $this->get_conversation();
$observer = $conv->get_observer();
@ -161,7 +161,7 @@ class ThreadItem {
$drop = [ 'dropping' => true, 'delete' => t('Admin Delete') ];
}
if($observer_is_pageowner) {
if(isset($observer_is_pageowner) && $observer_is_pageowner) {
$multidrop = array(
'select' => t('Select'),
);
@ -271,7 +271,7 @@ class ThreadItem {
}
$has_bookmarks = false;
if(is_array($item['term'])) {
if(isset($item['term']) && is_array($item['term'])) {
foreach($item['term'] as $t) {
if($t['ttype'] == TERM_BOOKMARK)
$has_bookmarks = true;
@ -287,6 +287,8 @@ class ThreadItem {
$dislike = array( t("I don't like this \x28toggle\x29"), t("dislike"));
}
$share = $embed = EMPTY_STR;
if ($shareable) {
$share = t('Repeat This');
$embed = t('Share this');
@ -302,9 +304,11 @@ class ThreadItem {
$dreport = t('Delivery Report');
$dreport_link = gen_link_id($item['mid']);
}
if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
$is_new = false;
if (strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) {
$is_new = true;
}
localize_item($item);
@ -376,7 +380,7 @@ class ThreadItem {
'thread_action_menu' => thread_action_menu($item,$conv->get_mode()),
'thread_author_menu' => thread_author_menu($item,$conv->get_mode()),
'dreport' => $dreport,
'dreport_link' => $dreport_link,
'dreport_link' => ((isset($dreport_link) && $dreport_link) ? $dreport_link : EMPTY_STR),
'name' => $profile_name,
'thumb' => $profile_avatar,
'osparkle' => $osparkle,
@ -461,7 +465,7 @@ class ThreadItem {
'modal_dismiss' => t('Close'),
'showlike' => $showlike,
'showdislike' => $showdislike,
'comment' => ($item['item_delayed'] ? '' : $this->get_comment_box($indent)),
'comment' => ($item['item_delayed'] ? '' : $this->get_comment_box()),
'previewing' => ($conv->is_preview() ? true : false ),
'preview_lbl' => t('This is an unsaved preview'),
'wait' => t('Please wait'),
@ -490,7 +494,7 @@ class ThreadItem {
}
// Add any mentions from the immediate parent, unless they are mentions of the current viewer or duplicates
if ($item['term']) {
if (isset($item['term']) && is_array($item['term'])) {
$additional_mentions = [];
foreach ($item['term'] as $t) {
if ($t['ttype'] == TERM_MENTION) {
@ -835,7 +839,7 @@ class ThreadItem {
* _ The comment box string (empty if no comment box)
* _ false on failure
*/
private function get_comment_box($indent) {
private function get_comment_box($indent = 0) {
if(!$this->is_toplevel() && !get_config('system','thread_allow',true)) {
return '';

View file

@ -155,13 +155,10 @@ class Acl extends Controller {
$r = q("SELECT abook_id as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, xchan_type, abook_flags, abook_self
FROM abook left join xchan on abook_xchan = xchan_hash
WHERE (abook_channel = %d $extra_channels_sql) AND abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 $sql_extra4 order by xchan_name asc limit $count" ,
WHERE abook_channel = %d AND abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 $sql_extra4 order by xchan_name asc limit $count" ,
intval(local_channel())
);
if($r && $r2) {
$r = array_merge($r2,$r);
}
}
else { // Visitors
$r = q("SELECT xchan_hash as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_flags, 0 as abook_self

View file

@ -46,7 +46,7 @@ class Connections extends Controller {
$unconnected = false;
$all = false;
if (! $_REQUEST['aj']) {
if (! (isset($_REQUEST['aj']) && $_REQUEST['aj'])) {
$_SESSION['return_url'] = App::$query_string;
}
@ -195,12 +195,12 @@ class Connections extends Controller {
}
$sql_extra .= (($searching) ? " AND ( xchan_name like '%%$search_txt%%' OR abook_alias like '%%$search_txt%%' ) " : "");
if($_REQUEST['gid']) {
if (isset($_REQUEST['gid']) && intval($_REQUEST['gid'])) {
$sql_extra .= " and xchan_hash in ( select xchan from pgrp_member where gid = " . intval($_REQUEST['gid']) . " and uid = " . intval(local_channel()) . " ) ";
}
$r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash
where abook_channel = %d and abook_self = 0 and xchan_deleted = 0 and xchan_orphan = 0 $sql_extra $sql_extra2 ",
where abook_channel = %d and abook_self = 0 and xchan_deleted = 0 and xchan_orphan = 0 $sql_extra ",
intval(local_channel())
);
if($r) {
@ -208,20 +208,23 @@ class Connections extends Controller {
$total = $r[0]['total'];
}
switch($_REQUEST['order']) {
case 'date':
$order_q = 'abook_created desc';
break;
case 'created':
$order_q = 'abook_created';
break;
case 'cmax':
$order_q = 'abook_closeness';
break;
case 'name':
default:
$order_q = 'xchan_name';
break;
$order_q = 'xchan_name';
if (isset($_REQUEST['order'])) {
switch ($_REQUEST['order']) {
case 'date':
$order_q = 'abook_created desc';
break;
case 'created':
$order_q = 'abook_created';
break;
case 'cmax':
$order_q = 'abook_closeness';
break;
case 'name':
default:
$order_q = 'xchan_name';
break;
}
}
@ -230,21 +233,21 @@ class Connections extends Controller {
'name' => array(
'label' => t('Name'),
'url' => z_root() . '/connections' . ((argv(1)) ? '/' . argv(1) : '') . '?order=name',
'sel' => ($_REQUEST['order'] === 'name' || (! isset($_REQUEST['order']))) ? 'active' : '',
'sel' => ((isset($_REQUEST['order']) && $_REQUEST['order'] !== 'name') ? 'active' : ''),
'title' => t('Order by name'),
),
'date' => array(
'label' => t('Recent'),
'url' => z_root() . '/connections' . ((argv(1)) ? '/' . argv(1) : '') . '?order=date',
'sel' => ($_REQUEST['order'] === 'date') ? 'active' : '',
'sel' => ((isset($_REQUEST['order']) && $_REQUEST['order'] === 'date') ? 'active' : ''),
'title' => t('Order by recent'),
),
'created' => array(
'label' => t('Created'),
'url' => z_root() . '/connections' . ((argv(1)) ? '/' . argv(1) : '') . '?order=created',
'sel' => ($_REQUEST['order'] === 'created') ? 'active' : '',
'sel' => ((isset($_REQUEST['order']) && $_REQUEST['order'] === 'created') ? 'active' : ''),
'title' => t('Order by date'),
),
// reserved for cmax
@ -261,7 +264,7 @@ class Connections extends Controller {
$r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash
WHERE abook_channel = %d and abook_self = 0 and xchan_deleted = 0 and xchan_orphan = 0 $sql_extra $sql_extra2 ORDER BY $order_q LIMIT %d OFFSET %d ",
WHERE abook_channel = %d and abook_self = 0 and xchan_deleted = 0 and xchan_orphan = 0 $sql_extra ORDER BY $order_q LIMIT %d OFFSET %d ",
intval(local_channel()),
intval(App::$pager['itemspage']),
intval(App::$pager['start'])
@ -280,14 +283,14 @@ class Connections extends Controller {
}
if($rr['xchan_url']) {
if(($rr['vcard']) && is_array($rr['vcard']['tels']) && $rr['vcard']['tels'][0]['nr'])
if((isset($rr['vcard']) && $rr['vcard']) && is_array($rr['vcard']['tels']) && $rr['vcard']['tels'][0]['nr'])
$phone = $rr['vcard']['tels'][0]['nr'];
else
$phone = '';
$status_str = '';
$status = array(
((intval($rr['abook_active'])) ? t('Active') : ''),
((isset($rr['abook_active']) && intval($rr['abook_active'])) ? t('Active') : ''),
((intval($rr['abook_pending'])) ? t('Pending approval') : ''),
((intval($rr['abook_archived'])) ? t('Archived') : ''),
((intval($rr['abook_hidden'])) ? t('Hidden') : ''),
@ -369,7 +372,7 @@ class Connections extends Controller {
'$sort' => t('Filter by'),
'$sortorder' => t('Sort by'),
'$total' => $total,
'$search' => $search_hdr,
'$search' => ((isset($search_hdr)) ? $search_hdr : EMPTY_STR),
'$label' => t('Search'),
'$desc' => t('Search your connections'),
'$finding' => (($searching) ? t('Connections search') . ": '" . $search . "'" : ""),

View file

@ -634,7 +634,7 @@ class Stream extends Controller {
}
}
if ($update_unseen && (! $_SESSION['sudo'])) {
if ($update_unseen && (! (isset($_SESSION['sudo']) && $_SESSION['sudo']))) {
$x = [ 'channel_id' => local_channel(), 'update' => 'unset' ];
call_hooks('update_unseen',$x);
if ($x['update'] === 'unset' || intval($x['update'])) {

View file

@ -20,7 +20,7 @@ class Tasks extends Controller {
$x = tasks_fetch($arr);
$x['html'] = '';
if($x['tasks']) {
if(isset($x['tasks']) && is_array($x['tasks'])) {
foreach($x['tasks'] as $y) {
$x['html'] .= '<div class="tasklist-item"><input type="checkbox" onchange="taskComplete(' . $y['id'] . '); return false;" /> ' . $y['summary'] . '</div>';
}

View file

@ -31,7 +31,7 @@ class HTTPHeaders {
}
}
if ($this->in_progress['k']) {
if (isset($this->in_progress['k'])) {
$this->parsed[] = [ $this->in_progress['k'] => $this->in_progress['v'] ];
$this->in_progress = [];
}

View file

@ -19,6 +19,7 @@ class Activity_filter {
$events_active = false;
$polls_active = false;
$group_active = false;
$forum_active = false;
$tabs = [];
@ -162,7 +163,7 @@ class Activity_filter {
'url' => z_root() . '/' . $cmd . '/?f=&pf=1&cid=' . $f['abook_id'],
'sel' => $forum_active,
'title' => t('Show posts to this group'),
'lock' => (($f['private_forum']) ? 'lock' : ''),
'lock' => ((isset($f['private_forum']) && $f['private_forum']) ? 'lock' : ''),
'edit' => t('New post'),
'edit_url' => $f['xchan_url']
];
@ -216,7 +217,7 @@ class Activity_filter {
$ft = get_pconfig(local_channel(),'system','followed_tags', EMPTY_STR);
if (is_array($ft) && $ft) {
foreach($ft as $t) {
$tag_active = (($_GET['netsearch'] === '#' . $t) ? 'active' : '');
$tag_active = ((isset($_GET['netsearch']) && $_GET['netsearch'] === '#' . $t) ? 'active' : '');
if ($tag_active) {
$filter_active = 'tags';
}

View file

@ -10,8 +10,10 @@ class Tasklist {
function widget($arr) {
$o = EMPTY_STR;
if(! ( local_channel() && Apps::system_app_installed(local_channel(),'Tasks'))) {
return EMPTY_STR;
return $o;
}
$o .= '<script>var tasksShowAll = 0; $(document).ready(function() { tasksFetch(); $("#tasklist-new-form").submit(function(event) { event.preventDefault(); $.post( "tasks/new", $("#tasklist-new-form").serialize(), function(data) { tasksFetch(); $("#tasklist-new-summary").val(""); } ); return false; } )});</script>';

View file

@ -58,7 +58,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']) && strlen($ev['location']))
$o .= '<div class="event-location"><span class="event-label"> ' . t('Location:') . '</span>&nbsp;<span class="location">'
. zidify_links(smilies(bbcode($ev['location'])))
. '</span></div>' . "\r\n";
@ -100,7 +100,7 @@ function format_event_obj($jobject) {
$bd_format = t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8:01 AM
$dtend = ((array_key_exists('endTime',$object)) ? $object['endTime'] : NULL_DATE);
$title = (($object['summary']) ? zidify_links(smilies(bbcode($object['summary']))) : $object['name']);
$title = ((isset($object['summary']) && $object['summary']) ? zidify_links(smilies(bbcode($object['summary']))) : $object['name']);
$event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array(
'$title' => $title,

View file

@ -16,8 +16,12 @@ function nav($template = 'default') {
*
*/
if(!(x(App::$page,'nav')))
App::$page['nav'] = '';
if (! isset(App::$page['nav'])) {
App::$page['nav'] = EMPTY_STR;
}
if (! isset(App::$page['htmlhead'])) {
App::$page['htmlhead'] = EMPTY_STR;
}
App::$page['htmlhead'] .= '<script>$(document).ready(function() { $("#nav-search-text").search_autocomplete(\'' . z_root() . '/acl' . '\');});</script>';
@ -301,16 +305,16 @@ function nav($template = 'default') {
'$powered_by' => $powered_by,
'$help' => t('@name, #tag, ?doc, content'),
'$pleasewait' => t('Please wait...'),
'$nav_apps' => $nav_apps,
'$navbar_apps' => $navbar_apps,
'$nav_apps' => ((isset($nav_apps)) ? $nav_apps : []),
'$navbar_apps' => ((isset($navbar_apps)) ? $navbar_apps : []),
'$channel_menu' => get_pconfig(App::$profile_uid,'system','channel_menu',get_config('system','channel_menu')),
'$channel_thumb' => ((App::$profile) ? App::$profile['thumb'] : ''),
'$channel_apps' => $channel_apps,
'$channel_apps' => ((isset($channel_apps)) ? $channel_apps : []),
'$manageapps' => t('My Apps'),
'$addapps' => t('Available Apps'),
'$orderapps' => t('Arrange Apps'),
'$sysapps_toggle' => t('Toggle System Apps'),
'$url' => (($url) ? $url : App::$cmd)
'$url' => ((isset($url) && $url) ? $url : App::$cmd)
));
if(x($_SESSION, 'reload_avatar') && $observer) {

View file

@ -412,7 +412,7 @@ function poco() {
if(argc() > 1) {
$user = notags(trim(argv(1)));
}
if(! x($user)) {
if(! (isset($user) && $user)) {
$c = q("select * from pconfig where cat = 'system' and k = 'suggestme' and v = '1'");
if(! $c) {
logger('mod_poco: system mode. No candidates.', LOGGER_DEBUG);

View file

@ -1370,6 +1370,8 @@ function unobscure_mail(&$item) {
function theme_attachments(&$item) {
$s = EMPTY_STR;
$arr = json_decode($item['attach'],true);
if (is_array($arr) && count($arr)) {
@ -1423,7 +1425,12 @@ function theme_attachments(&$item) {
function format_categories(&$item,$writeable) {
$s = '';
$s = EMPTY_STR;
if (! (isset($item['term']) && $item['term'])) {
return $s;
}
$terms = get_terms_oftype($item['term'],TERM_CATEGORY);
if($terms) {
@ -1485,7 +1492,7 @@ function format_hashtags(&$item) {
function format_mentions(&$item) {
$s = '';
$s = EMPTY_STR;
$pref = intval(PConfig::Get($item['uid'],'system','tag_username',Config::Get('system','tag_username',false)));
@ -1493,13 +1500,16 @@ function format_mentions(&$item) {
$show = intval(PConfig::Get($item['uid'],'system','show_auto_mentions',false));
if ((! $show) && (! $item['resource_type'])) {
return;
return $s;
}
if ($pref === 127) {
return;
return $s;
}
if (! (isset($item['term']) && is_array($item['term']) && $item['term'])) {
return $s;
}
$terms = get_terms_oftype($item['term'],TERM_MENTION);
if($terms) {
foreach($terms as $t) {
@ -1548,7 +1558,11 @@ function format_mentions(&$item) {
function format_filer(&$item) {
$s = '';
$s = EMPTY_STR;
if (! (isset($item['term']) && $item['term'])) {
return $s;
}
$terms = get_terms_oftype($item['term'],TERM_FILE);
if($terms) {

View file

@ -58,10 +58,12 @@ function zid($s, $address = '') {
$mine_parsed = parse_url($mine);
$s_parsed = parse_url($s);
$url_match = false;
if(isset($mine_parsed['host']) && isset($s_parsed['host'])
&& $mine_parsed['host'] === $s_parsed['host'])
&& $mine_parsed['host'] === $s_parsed['host']) {
$url_match = true;
}
if ($mine && $myaddr && (! $url_match))
$zurl = $s . (($num_slashes >= 3) ? '' : '/') . (($achar === '?') ? '?f=&' : '&') . 'zid=' . urlencode($myaddr);