From 8879776d6436ed5257648a1873ddaa9486b25070 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 23 Oct 2022 14:02:19 +0200 Subject: fix php warnings --- Zotlabs/Daemon/Checksites.php | 3 +++ Zotlabs/Lib/ASCollection.php | 4 +++- Zotlabs/Lib/AbConfig.php | 15 ++++++++++----- Zotlabs/Lib/Connect.php | 3 ++- Zotlabs/Lib/Libzot.php | 14 ++++++++++++-- Zotlabs/Lib/Webfinger.php | 2 +- Zotlabs/Module/Cal.php | 2 +- Zotlabs/Module/Channel.php | 2 +- Zotlabs/Module/Directory.php | 2 +- Zotlabs/Module/Follow.php | 3 +-- Zotlabs/Module/Lostpass.php | 4 ++-- Zotlabs/Module/Manage.php | 2 +- Zotlabs/Module/Photos.php | 1 + Zotlabs/Module/Profile.php | 2 +- Zotlabs/Module/Pubsites.php | 4 +++- Zotlabs/Module/Settings.php | 7 ++++--- Zotlabs/Module/Settings/Channel.php | 9 +++++---- Zotlabs/Module/Settings/Display.php | 10 +++++----- Zotlabs/Module/Theme_info.php | 28 ++++++++++++++-------------- Zotlabs/Widget/Photo_albums.php | 3 ++- include/channel.php | 6 ++++-- include/conversation.php | 7 +++---- include/items.php | 4 ++-- view/theme/redbasic/php/config.php | 12 +++++++----- 24 files changed, 89 insertions(+), 60 deletions(-) diff --git a/Zotlabs/Daemon/Checksites.php b/Zotlabs/Daemon/Checksites.php index 7227e96e4..eacf8c6bc 100644 --- a/Zotlabs/Daemon/Checksites.php +++ b/Zotlabs/Daemon/Checksites.php @@ -10,6 +10,9 @@ class Checksites { logger('checksites: start'); + $site_id = ''; + $sql_options = ''; + if (($argc > 1) && ($argv[1])) $site_id = $argv[1]; 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/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/Libzot.php b/Zotlabs/Lib/Libzot.php index c86eb29cd..6e8a5d5bc 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -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,12 @@ class Libzot { */ static function import_xchan($arr, $ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) { + + 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 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/Module/Cal.php b/Zotlabs/Module/Cal.php index 329150424..9049fe7d0 100644 --- a/Zotlabs/Module/Cal.php +++ b/Zotlabs/Module/Cal.php @@ -39,7 +39,7 @@ class Cal extends Controller { head_set_icon(App::$data['channel']['xchan_photo_s']); - App::$page['htmlhead'] .= "" ; + App::$page['htmlhead'] = "" ; } diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 24a3fd44f..0874551d6 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -294,7 +294,7 @@ class Channel extends Controller { $abook_uids = " and abook.abook_channel = " . intval(App::$profile['profile_uid']) . " "; $simple_update = ''; - if ($update && $_SESSION['loadtime']) + if ($update && isset($_SESSION['loadtime'])) $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC', 'UTC', $_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC', 'UTC', $_SESSION['loadtime']) . "' ) "; if ($search) { diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index 8995f709c..d92ea2c0e 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -309,7 +309,7 @@ class Directory extends Controller { $keywords = str_replace(',',' ', $keywords); $keywords = str_replace(' ',' ', $keywords); $karr = explode(' ', $keywords); - + $marr = []; if($karr) { if(local_channel()) { $r = q("select keywords from profile where uid = %d and is_default = 1 limit 1", diff --git a/Zotlabs/Module/Follow.php b/Zotlabs/Module/Follow.php index 94daa4c70..54e29c492 100644 --- a/Zotlabs/Module/Follow.php +++ b/Zotlabs/Module/Follow.php @@ -72,8 +72,7 @@ class Follow extends Controller { $uid = local_channel(); $url = notags(trim(punify($_REQUEST['url']))); $return_url = $_SESSION['return_url']; - $confirm = intval($_REQUEST['confirm']); - $interactive = (($_REQUEST['interactive']) ? intval($_REQUEST['interactive']) : 1); + $interactive = $_REQUEST['interactive'] ?? 1; $channel = App::get_channel(); $result = Connect::connect($channel,$url); diff --git a/Zotlabs/Module/Lostpass.php b/Zotlabs/Module/Lostpass.php index 83478bb10..a0f9018b2 100644 --- a/Zotlabs/Module/Lostpass.php +++ b/Zotlabs/Module/Lostpass.php @@ -87,7 +87,7 @@ class Lostpass extends \Zotlabs\Web\Controller { if($r) { $tpl = get_markup_template('pwdreset.tpl'); - $o .= replace_macros($tpl,array( + $o = replace_macros($tpl,array( '$lbl1' => t('Password Reset'), '$lbl2' => t('Your password has been reset as requested.'), '$lbl3' => t('Your new password is'), @@ -126,7 +126,7 @@ class Lostpass extends \Zotlabs\Web\Controller { else { $tpl = get_markup_template('lostpass.tpl'); - $o .= replace_macros($tpl,array( + $o = replace_macros($tpl,array( '$title' => t('Forgot your Password?'), '$desc' => t('Enter your email address and submit to have your password reset. Then check your email for further instructions.'), '$name' => t('Email Address'), diff --git a/Zotlabs/Module/Manage.php b/Zotlabs/Module/Manage.php index 3f168c15d..2cc05e09c 100644 --- a/Zotlabs/Module/Manage.php +++ b/Zotlabs/Module/Manage.php @@ -6,7 +6,7 @@ class Manage extends \Zotlabs\Web\Controller { function get() { - if((! get_account_id()) || ($_SESSION['delegate'])) { + if((! get_account_id()) || (isset($_SESSION['delegate']) && $_SESSION['delegate'])) { notice( t('Permission denied.') . EOL); return; } diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 6acaf6673..68f7c55e7 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -593,6 +593,7 @@ class Photos extends \Zotlabs\Web\Controller { */ $upload_form = ''; + $usage_message = ''; if($can_post) { diff --git a/Zotlabs/Module/Profile.php b/Zotlabs/Module/Profile.php index bcc7ad930..732beaa6a 100644 --- a/Zotlabs/Module/Profile.php +++ b/Zotlabs/Module/Profile.php @@ -110,7 +110,7 @@ class Profile extends Controller { $is_owner = ((local_channel()) && (local_channel() == App::$profile['profile_uid']) ? true : false); - if (App::$profile['hidewall'] && (!$is_owner) && (!remote_channel())) { + if ((isset(App::$profile['hidewall']) && App::$profile['hidewall']) && (!$is_owner) && (!remote_channel())) { notice(t('Permission denied.') . EOL); return; } diff --git a/Zotlabs/Module/Pubsites.php b/Zotlabs/Module/Pubsites.php index fd5aeaa72..032406be4 100644 --- a/Zotlabs/Module/Pubsites.php +++ b/Zotlabs/Module/Pubsites.php @@ -8,6 +8,8 @@ class Pubsites extends \Zotlabs\Web\Controller { function get() { $dirmode = intval(get_config('system','directory_mode')); + $url = ''; + if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) { $url = z_root() . '/dirsearch'; } @@ -19,7 +21,7 @@ class Pubsites extends \Zotlabs\Web\Controller { $rating_enabled = get_config('system','rating_enabled'); - $o .= '
'; + $o = '
'; $o .= '

' . t('Public Hubs') . '

'; diff --git a/Zotlabs/Module/Settings.php b/Zotlabs/Module/Settings.php index 624cbb0c1..94f67a349 100644 --- a/Zotlabs/Module/Settings.php +++ b/Zotlabs/Module/Settings.php @@ -11,8 +11,9 @@ class Settings extends \Zotlabs\Web\Controller { if(! local_channel()) return; - if($_SESSION['delegate']) + if (isset($_SESSION['delegate']) && $_SESSION['delegate']) { return; + } \App::$profile_uid = local_channel(); @@ -33,7 +34,7 @@ class Settings extends \Zotlabs\Web\Controller { if(! local_channel()) return; - if($_SESSION['delegate']) + if(isset($_SESSION['delegate']) && $_SESSION['delegate']) return; // logger('mod_settings: ' . print_r($_REQUEST,true)); @@ -54,7 +55,7 @@ class Settings extends \Zotlabs\Web\Controller { nav_set_selected('Settings'); - if((! local_channel()) || ($_SESSION['delegate'])) { + if((! local_channel()) || (isset($_SESSION['delegate']) && $_SESSION['delegate'])) { notice( t('Permission denied.') . EOL ); return login(); } diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index 840efc162..1e0c2a2db 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -27,10 +27,10 @@ class Channel { $photo_path = ((x($_POST, 'photo_path')) ? escape_tags(trim($_POST['photo_path'])) : ''); $attach_path = ((x($_POST, 'attach_path')) ? escape_tags(trim($_POST['attach_path'])) : ''); $allow_location = (((x($_POST, 'allow_location')) && (intval($_POST['allow_location']) == 1)) ? 1 : 0); - $post_newfriend = (($_POST['post_newfriend'] == 1) ? 1 : 0); - $post_joingroup = (($_POST['post_joingroup'] == 1) ? 1 : 0); - $post_profilechange = (($_POST['post_profilechange'] == 1) ? 1 : 0); - $adult = (($_POST['adult'] == 1) ? 1 : 0); + $post_newfriend = ((isset($_POST['post_newfriend']) && $_POST['post_newfriend'] == 1) ? 1 : 0); + $post_joingroup = ((isset($_POST['post_joingroup']) && $_POST['post_joingroup'] == 1) ? 1 : 0); + $post_profilechange = ((isset($_POST['post_profilechange']) && $_POST['post_profilechange'] == 1) ? 1 : 0); + $adult = ((isset($_POST['adult']) && $_POST['adult'] == 1) ? 1 : 0); $mailhost = ((array_key_exists('mailhost', $_POST)) ? notags(trim($_POST['mailhost'])) : ''); $pageflags = $channel['channel_pageflags']; $existing_adult = (($pageflags & PAGE_ADULT) ? 1 : 0); @@ -152,6 +152,7 @@ class Channel { Master::Summon(['Directory', local_channel()]); Libsync::build_sync_packet(); + $email_changed = false; if ($email_changed && App::$config['system']['register_policy'] == REGISTER_VERIFY) { // FIXME - set to un-verified, blocked and redirect to logout diff --git a/Zotlabs/Module/Settings/Display.php b/Zotlabs/Module/Settings/Display.php index 11181907b..ea9ae2da1 100644 --- a/Zotlabs/Module/Settings/Display.php +++ b/Zotlabs/Module/Settings/Display.php @@ -90,8 +90,8 @@ class Display { $default_theme = 'redbasic'; $themespec = explode(':', \App::$channel['channel_theme']); - $existing_theme = $themespec[0]; - $existing_schema = $themespec[1]; + $existing_theme = $themespec[0] ?? ''; + $existing_schema = $themespec[1] ?? ''; $theme = (($existing_theme) ? $existing_theme : $default_theme); @@ -207,12 +207,12 @@ class Display { function get_theme_config_file($theme){ - $base_theme = \App::$theme_info['extends']; + $base_theme = \App::$theme_info['extends'] ?? ''; - if (file_exists("view/theme/$theme/php/config.php")){ + if ($theme && file_exists("view/theme/$theme/php/config.php")){ return "view/theme/$theme/php/config.php"; } - if (file_exists("view/theme/$base_theme/php/config.php")){ + if ($base_theme && file_exists("view/theme/$base_theme/php/config.php")){ return "view/theme/$base_theme/php/config.php"; } return null; diff --git a/Zotlabs/Module/Theme_info.php b/Zotlabs/Module/Theme_info.php index e27ec9444..bf1e5cb9b 100644 --- a/Zotlabs/Module/Theme_info.php +++ b/Zotlabs/Module/Theme_info.php @@ -9,7 +9,7 @@ class Theme_info extends \Zotlabs\Web\Controller { $theme = argv(1); if(! $theme) killme(); - + $schemalist = array(); $theme_config = ""; @@ -40,32 +40,32 @@ class Theme_info extends \Zotlabs\Web\Controller { $credits = ''; } - $ret = [ - 'theme' => $theme, - 'img' => get_theme_screenshot($theme), - 'desc' => $desc, - 'version' => $version, - 'credits' => $credits, + $ret = [ + 'theme' => $theme, + 'img' => get_theme_screenshot($theme), + 'desc' => $desc, + 'version' => $version, + 'credits' => $credits, 'schemas' => $schemalist, 'config' => $theme_config ]; json_return_and_die($ret); - + } function get_theme_config_file($theme){ - $base_theme = \App::$theme_info['extends']; - - if (file_exists("view/theme/$theme/php/config.php")){ + $base_theme = \App::$theme_info['extends'] ?? ''; + + if ($theme && file_exists("view/theme/$theme/php/config.php")){ return "view/theme/$theme/php/config.php"; - } - if (file_exists("view/theme/$base_theme/php/config.php")){ + } + if ($base_theme && file_exists("view/theme/$base_theme/php/config.php")){ return "view/theme/$base_theme/php/config.php"; } return null; } -} \ No newline at end of file +} diff --git a/Zotlabs/Widget/Photo_albums.php b/Zotlabs/Widget/Photo_albums.php index 2ce916048..d0004e68d 100644 --- a/Zotlabs/Widget/Photo_albums.php +++ b/Zotlabs/Widget/Photo_albums.php @@ -14,8 +14,9 @@ class Photo_albums { function widget($arr) { - if(! \App::$profile['profile_uid']) + if (!(isset(\App::$profile['profile_uid']) && \App::$profile['profile_uid'])) { return ''; + } $channelx = channelx_by_n(\App::$profile['profile_uid']); diff --git a/include/channel.php b/include/channel.php index a42315ed6..296615524 100644 --- a/include/channel.php +++ b/include/channel.php @@ -1581,6 +1581,8 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $details = $location = false; $pdesc = true; $reddress = true; + $connect_url = ''; + $connect = ''; if(! perm_is_allowed($profile['uid'], $observer_hash, 'view_profile')) { $block = true; @@ -1792,7 +1794,7 @@ function advanced_profile() { $profile['birthday'] = array( t('Birthday:'), $val); } - if($age = age(App::$profile['dob'],App::$profile['timezone'],'')) + if($age = age(App::$profile['dob'], App::$profile['timezone'] ?? '','')) $profile['age'] = array( t('Age:'), $age ); if(App::$profile['marital']) @@ -1874,7 +1876,7 @@ function advanced_profile() { return replace_macros($tpl, array( '$title' => t('Profile'), - '$canlike' => (($profile['canlike'])? true : false), + '$canlike' => ((isset($profile['canlike']) && $profile['canlike'])? true : false), '$likethis' => t('Like this thing'), '$export' => t('Export'), '$exportlink' => $exportlink, diff --git a/include/conversation.php b/include/conversation.php index bb0603eca..a8e89d194 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -643,10 +643,9 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa $channel = App::get_channel(); $observer = App::get_observer(); - if($update) - $return_url = $_SESSION['return_url']; - else - $return_url = $_SESSION['return_url'] = App::$query_string; + if (!$update) { + $_SESSION['return_url'] = App::$query_string; + } load_contact_links(local_channel()); diff --git a/include/items.php b/include/items.php index a01a0e2fa..46140b699 100644 --- a/include/items.php +++ b/include/items.php @@ -2108,8 +2108,8 @@ function item_store_update($arr, $allow_exec = false, $deliver = true) { // apply the input filter here - $arr['summary'] = trim(z_input_filter($arr['summary'],$arr['mimetype'],$allow_exec)); - $arr['body'] = trim(z_input_filter($arr['body'],$arr['mimetype'],$allow_exec)); + $arr['summary'] = ((isset($arr['summary'])) ? trim(z_input_filter($arr['summary'],$arr['mimetype'],$allow_exec)) : ''); + $arr['body'] = ((isset($arr['body'])) ? trim(z_input_filter($arr['body'],$arr['mimetype'],$allow_exec)) : ''); item_sign($arr); diff --git a/view/theme/redbasic/php/config.php b/view/theme/redbasic/php/config.php index 9d242fab0..65834526d 100644 --- a/view/theme/redbasic/php/config.php +++ b/view/theme/redbasic/php/config.php @@ -89,10 +89,12 @@ class RedbasicConfig { function form($arr) { - if(get_pconfig(local_channel(), 'redbasic', 'advanced_theming')) - $expert = 1; + $expert = false; + if(get_pconfig(local_channel(), 'redbasic', 'advanced_theming')) { + $expert = true; + } - $o .= replace_macros(get_markup_template('theme_settings.tpl'), array( + $o = replace_macros(get_markup_template('theme_settings.tpl'), array( '$submit' => t('Submit'), '$baseurl' => z_root(), '$theme' => \App::$channel['channel_theme'], @@ -102,8 +104,8 @@ class RedbasicConfig { '$nav_bg' => array('redbasic_nav_bg', t('Navigation bar background color'), $arr['nav_bg']), '$nav_icon_colour' => array('redbasic_nav_icon_colour', t('Navigation bar icon color '), $arr['nav_icon_colour']), '$nav_active_icon_colour' => array('redbasic_nav_active_icon_colour', t('Navigation bar active icon color '), $arr['nav_active_icon_colour']), - '$link_colour' => array('redbasic_link_colour', t('Link color'), $arr['link_colour'], '', $link_colour), - '$link_hover_colour' => array('redbasic_link_hover_colour', t('Link hover color'), $arr['link_hover_colour'], '', $link_hover_colour), + '$link_colour' => array('redbasic_link_colour', t('Link color'), $arr['link_colour']), + '$link_hover_colour' => array('redbasic_link_hover_colour', t('Link hover color'), $arr['link_hover_colour']), '$banner_colour' => array('redbasic_banner_colour', t('Set font-color for banner'), $arr['banner_colour']), '$bgcolour' => array('redbasic_background_colour', t('Set the background color'), $arr['bgcolour']), '$background_image' => array('redbasic_background_image', t('Set the background image'), $arr['background_image']), -- cgit v1.2.3