From 8fea67dadecf491bd480d6c227c4545eaeca2d7f Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 7 Nov 2021 14:02:13 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Philipp --- buffer/buffer.php | 4 ++-- geocoordinates/geocoordinates.php | 4 ++-- gravatar/gravatar.php | 4 ++-- impressum/impressum.php | 12 ++++++------ libravatar/libravatar.php | 2 +- newmemberwidget/newmemberwidget.php | 2 +- piwik/piwik.php | 8 ++++---- public_server/public_server.php | 12 ++++++------ tumblr/tumblr.php | 4 ++-- twitter/twitter.php | 4 ++-- webrtc/webrtc.php | 2 +- 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/buffer/buffer.php b/buffer/buffer.php index 6be69ca8..1f50aa30 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -73,8 +73,8 @@ function buffer_addon_admin(App $a, &$o) function buffer_addon_admin_post(App $a) { - $client_id = (!empty($_POST['client_id']) ? trim($_POST['client_id']) : ''); - $client_secret = (!empty($_POST['client_secret']) ? trim($_POST['client_secret']) : ''); + $client_id = trim($_POST['client_id'] ?? ''); + $client_secret = trim($_POST['client_secret'] ?? ''); DI::config()->set('buffer', 'client_id' , $client_id); DI::config()->set('buffer', 'client_secret', $client_secret); diff --git a/geocoordinates/geocoordinates.php b/geocoordinates/geocoordinates.php index 08b45cec..d3f06fdb 100644 --- a/geocoordinates/geocoordinates.php +++ b/geocoordinates/geocoordinates.php @@ -90,9 +90,9 @@ function geocoordinates_addon_admin(&$a, &$o) function geocoordinates_addon_admin_post(&$a) { - $api_key = (!empty($_POST['api_key']) ? trim($_POST['api_key']) : ''); + $api_key = trim($_POST['api_key'] ?? ''); DI::config()->set('geocoordinates', 'api_key', $api_key); - $language = (!empty($_POST['language']) ? trim($_POST['language']) : ''); + $language = trim($_POST['language'] ?? ''); DI::config()->set('geocoordinates', 'language', $language); } diff --git a/gravatar/gravatar.php b/gravatar/gravatar.php index 3846d973..b49e7e94 100644 --- a/gravatar/gravatar.php +++ b/gravatar/gravatar.php @@ -108,8 +108,8 @@ function gravatar_addon_admin (&$a, &$o) { function gravatar_addon_admin_post (&$a) { BaseModule::checkFormSecurityToken('gravatarsave'); - $default_avatar = (!empty($_POST['avatar']) ? trim($_POST['avatar']) : 'identicon'); - $rating = (!empty($_POST['rating']) ? trim($_POST['rating']) : 'g'); + $default_avatar = trim($_POST['avatar'] ?? 'identicon'); + $rating = trim($_POST['rating'] ?? 'g'); DI::config()->set('gravatar', 'default_avatar', $default_avatar); DI::config()->set('gravatar', 'rating', $rating); } diff --git a/impressum/impressum.php b/impressum/impressum.php index 3bdc2465..3409f33b 100644 --- a/impressum/impressum.php +++ b/impressum/impressum.php @@ -78,12 +78,12 @@ function impressum_show($a,&$b) { } function impressum_addon_admin_post (&$a) { - $owner = (!empty($_POST['owner']) ? trim($_POST['owner']) : ''); - $ownerprofile = (!empty($_POST['ownerprofile']) ? trim($_POST['ownerprofile']) : ''); - $postal = (!empty($_POST['postal']) ? (trim($_POST['postal'])) : ''); - $notes = (!empty($_POST['notes']) ? (trim($_POST['notes'])) : ''); - $email = (!empty($_POST['email']) ? trim($_POST['email']) : ''); - $footer_text = (!empty($_POST['footer_text']) ? (trim($_POST['footer_text'])) : ''); + $owner = trim($_POST['owner'] ?? ''); + $ownerprofile = trim($_POST['ownerprofile'] ?? ''); + $postal = trim($_POST['postal'] ?? ''); + $notes = trim($_POST['notes'] ?? ''); + $email = trim($_POST['email'] ?? ''); + $footer_text = trim($_POST['footer_text'] ?? ''); DI::config()->set('impressum','owner',strip_tags($owner)); DI::config()->set('impressum','ownerprofile',strip_tags($ownerprofile)); DI::config()->set('impressum','postal',strip_tags($postal)); diff --git a/libravatar/libravatar.php b/libravatar/libravatar.php index d702874b..2458f52b 100644 --- a/libravatar/libravatar.php +++ b/libravatar/libravatar.php @@ -89,6 +89,6 @@ function libravatar_addon_admin(&$a, &$o) */ function libravatar_addon_admin_post(&$a) { - $default_avatar = (!empty($_POST['avatar']) ? trim($_POST['avatar']) : 'identicon'); + $default_avatar = trim($_POST['avatar'] ?? 'identicon'); DI::config()->set('libravatar', 'default_avatar', $default_avatar); } diff --git a/newmemberwidget/newmemberwidget.php b/newmemberwidget/newmemberwidget.php index c6122a52..398b908c 100644 --- a/newmemberwidget/newmemberwidget.php +++ b/newmemberwidget/newmemberwidget.php @@ -48,7 +48,7 @@ function newmemberwidget_network_mod_init ($a, $b) function newmemberwidget_addon_admin_post(&$a) { $ft = (!empty($_POST['freetext']) ? trim($_POST['freetext']) : ""); - $lsn = (!empty($_POST['localsupportname']) ? trim($_POST['localsupportname']) : ""); + $lsn = trim($_POST['localsupportname'] ?? ''); $gs = intval($_POST['linkglobalsupport']); $ls = intval($_POST['linklocalsupport']); DI::config()->set('newmemberwidget', 'freetext', trim($ft)); diff --git a/piwik/piwik.php b/piwik/piwik.php index 4035f467..8c4f91df 100644 --- a/piwik/piwik.php +++ b/piwik/piwik.php @@ -101,10 +101,10 @@ function piwik_addon_admin (&$a, &$o) { ]); } function piwik_addon_admin_post (&$a) { - $url = (!empty($_POST['baseurl']) ? trim($_POST['baseurl']) : ''); - $id = (!empty($_POST['siteid']) ? trim($_POST['siteid']) : ''); - $optout = (!empty($_POST['optout']) ? trim($_POST['optout']) : ''); - $async = (!empty($_POST['async']) ? trim($_POST['async']) : ''); + $url = trim($_POST['baseurl'] ?? ''); + $id = trim($_POST['siteid'] ?? ''); + $optout = trim($_POST['optout'] ?? ''); + $async = trim($_POST['async'] ?? ''); DI::config()->set('piwik', 'baseurl', $url); DI::config()->set('piwik', 'siteid', $id); DI::config()->set('piwik', 'optout', $optout); diff --git a/public_server/public_server.php b/public_server/public_server.php index 97e4b785..70aaacee 100644 --- a/public_server/public_server.php +++ b/public_server/public_server.php @@ -125,12 +125,12 @@ function public_server_login($a, $b) function public_server_addon_admin_post(&$a) { BaseModule::checkFormSecurityTokenRedirectOnError('/admin/addons/publicserver', 'publicserver'); - $expiredays = (!empty($_POST['expiredays']) ? trim($_POST['expiredays']) : ''); - $expireposts = (!empty($_POST['expireposts']) ? trim($_POST['expireposts']) : ''); - $nologin = (!empty($_POST['nologin']) ? trim($_POST['nologin']) : ''); - $flagusers = (!empty($_POST['flagusers']) ? trim($_POST['flagusers']) : ''); - $flagposts = (!empty($_POST['flagposts']) ? trim($_POST['flagposts']) : ''); - $flagpostsexpire = (!empty($_POST['flagpostsexpire']) ? trim($_POST['flagpostsexpire']) : ''); + $expiredays = trim($_POST['expiredays'] ?? ''); + $expireposts = trim($_POST['expireposts'] ?? ''); + $nologin = trim($_POST['nologin'] ?? ''); + $flagusers = trim($_POST['flagusers'] ?? ''); + $flagposts = trim($_POST['flagposts'] ?? ''); + $flagpostsexpire = trim($_POST['flagpostsexpire'] ?? ''); DI::config()->set('public_server', 'expiredays', $expiredays); DI::config()->set('public_server', 'expireposts', $expireposts); DI::config()->set('public_server', 'nologin', $nologin); diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index a6c598b3..f92de89f 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -75,8 +75,8 @@ function tumblr_addon_admin(App $a, &$o) function tumblr_addon_admin_post(App $a) { - $consumer_key = (!empty($_POST['consumer_key']) ? trim($_POST['consumer_key']) : ''); - $consumer_secret = (!empty($_POST['consumer_secret']) ? trim($_POST['consumer_secret']): ''); + $consumer_key = trim($_POST['consumer_key'] ?? : ''); + $consumer_secret = trim($_POST['consumer_secret'] ?? ''); DI::config()->set('tumblr', 'consumer_key',$consumer_key); DI::config()->set('tumblr', 'consumer_secret',$consumer_secret); diff --git a/twitter/twitter.php b/twitter/twitter.php index c6215fab..9811a06a 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -791,8 +791,8 @@ function twitter_post_hook(App $a, array &$b) function twitter_addon_admin_post(App $a) { - $consumerkey = !empty($_POST['consumerkey']) ? trim($_POST['consumerkey']) : ''; - $consumersecret = !empty($_POST['consumersecret']) ? trim($_POST['consumersecret']) : ''; + $consumerkey = trim($_POST['consumerkey'] ?? : ''); + $consumersecret = trim($_POST['consumersecret'] ?? ''); DI::config()->set('twitter', 'consumerkey', $consumerkey); DI::config()->set('twitter', 'consumersecret', $consumersecret); } diff --git a/webrtc/webrtc.php b/webrtc/webrtc.php index b3c7ced8..29c7fc8f 100644 --- a/webrtc/webrtc.php +++ b/webrtc/webrtc.php @@ -26,7 +26,7 @@ function webrtc_addon_admin (&$a, &$o) { ]); } function webrtc_addon_admin_post (&$a) { - $url = (!empty($_POST['webrtcurl']) ? trim($_POST['webrtcurl']) : ''); + $url = trim($_POST['webrtcurl'] ?? ''); DI::config()->set('webrtc', 'webrtcurl', $url); } -- 2.39.5