From d836593a3b54a30f961fc17c4e48c622f1e0b8e7 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 30 Nov 2018 09:11:56 -0500 Subject: [PATCH 1/2] Replace x() by !empty() or defaults() - Remove extraneous parentheses around !empty() --- blogger/blogger.php | 2 +- buffer/buffer.php | 4 ++-- curweather/curweather.php | 2 +- diaspora/Diaspora_Connection.php | 6 +++--- diaspora/diaspora.php | 2 +- dwpost/dwpost.php | 2 +- forumdirectory/forumdirectory.php | 2 +- fromapp/fromapp.php | 2 +- fromgplus/fromgplus.php | 6 +++--- geocoordinates/geocoordinates.php | 4 ++-- geonames/geonames.php | 2 +- gnot/gnot.php | 2 +- gravatar/gravatar.php | 4 ++-- group_text/group_text.php | 2 +- ifttt/ifttt.php | 2 +- ijpost/ijpost.php | 4 ++-- impressum/impressum.php | 12 ++++++------ irc/irc.php | 2 +- js_upload/js_upload.php | 2 +- langfilter/langfilter.php | 2 +- libertree/libertree.php | 4 ++-- libravatar/libravatar.php | 2 +- ljpost/ljpost.php | 4 ++-- mailstream/mailstream.php | 2 +- newmemberwidget/newmemberwidget.php | 4 ++-- notifyall/notifyall.php | 2 +- notimeline/notimeline.php | 2 +- nsfw/nsfw.php | 2 +- numfriends/numfriends.php | 2 +- piwik/piwik.php | 8 ++++---- public_server/public_server.php | 16 ++++++++-------- remote_permissions/remote_permissions.php | 4 ++-- securemail/securemail.php | 6 +++--- showmore/showmore.php | 2 +- statusnet/statusnet.php | 8 ++++---- testdrive/testdrive.php | 4 ++-- tumblr/tumblr.php | 4 ++-- twitter/twitter.php | 6 +++--- webrtc/webrtc.php | 2 +- windowsphonepush/windowsphonepush.php | 2 +- wppost/wppost.php | 4 ++-- xmpp/xmpp.php | 4 ++-- 42 files changed, 80 insertions(+), 80 deletions(-) diff --git a/blogger/blogger.php b/blogger/blogger.php index 84594f42..3faba1ca 100644 --- a/blogger/blogger.php +++ b/blogger/blogger.php @@ -165,7 +165,7 @@ function blogger_post_local(App $a, array &$b) $bl_post = intval(PConfig::get(local_user(), 'blogger', 'post')); - $bl_enable = (($bl_post && x($_REQUEST, 'blogger_enable')) ? intval($_REQUEST['blogger_enable']) : 0); + $bl_enable = (($bl_post && !empty($_REQUEST['blogger_enable'])) ? intval($_REQUEST['blogger_enable']) : 0); if ($b['api_source'] && intval(PConfig::get(local_user(), 'blogger', 'post_by_default'))) { $bl_enable = 1; diff --git a/buffer/buffer.php b/buffer/buffer.php index 7a62756a..385bdd5b 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -86,8 +86,8 @@ function buffer_addon_admin(App $a, &$o) function buffer_addon_admin_post(App $a) { - $client_id = ((!empty($_POST['client_id'])) ? Strings::escapeTags(trim($_POST['client_id'])) : ''); - $client_secret = ((!empty($_POST['client_secret'])) ? Strings::escapeTags(trim($_POST['client_secret'])) : ''); + $client_id = (!empty($_POST['client_id']) ? Strings::escapeTags(trim($_POST['client_id'])) : ''); + $client_secret = (!empty($_POST['client_secret']) ? Strings::escapeTags(trim($_POST['client_secret'])) : ''); Config::set('buffer', 'client_id' , $client_id); Config::set('buffer', 'client_secret', $client_secret); diff --git a/curweather/curweather.php b/curweather/curweather.php index 85fd4a60..9d4d42e7 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -118,7 +118,7 @@ function curweather_network_mod_init(App $a, &$b) $rpt = PConfig::get(local_user(), 'curweather', 'curweather_loc'); // Set the language to the browsers language or default and use metric units - $lang = (!empty($_SESSION['language']) ? $_SESSION['language'] : Config::get('system', 'language')); + $lang = defaults($_SESSION, 'language', Config::get('system', 'language')); $units = PConfig::get( local_user(), 'curweather', 'curweather_units'); $appid = Config::get('curweather', 'appid'); $cachetime = intval(Config::get('curweather', 'cachetime')); diff --git a/diaspora/Diaspora_Connection.php b/diaspora/Diaspora_Connection.php index 8b8811ec..67bc63df 100644 --- a/diaspora/Diaspora_Connection.php +++ b/diaspora/Diaspora_Connection.php @@ -136,7 +136,7 @@ class Diaspora_Connection { } elseif (!empty($m[1])) { $token = $m[1]; } - return (!empty($token)) ? $token : false; + return !empty($token) ? $token : false; } private function readJsonResponse($response) { @@ -165,14 +165,14 @@ class Diaspora_Connection { $this->doHttpRequest('/bookmarklet'); $m = []; preg_match('/"aspects"\:(\[.+?\])/', $this->last_http_result->response, $m); - return (!empty($m[1])) ? json_decode($m[1]) : false; + return !empty($m[1]) ? json_decode($m[1]) : false; } public function getServices() { $this->doHttpRequest('/bookmarklet'); $m = []; preg_match('/"configured_services"\:(\[.+?\])/', $this->last_http_result->response, $m); - return (!empty($m[1])) ? json_decode($m[1]) : false; + return !empty($m[1]) ? json_decode($m[1]) : false; } public function getNotifications($notification_type = '', $show = '') { diff --git a/diaspora/diaspora.php b/diaspora/diaspora.php index 66fa1b72..b36b2774 100644 --- a/diaspora/diaspora.php +++ b/diaspora/diaspora.php @@ -286,7 +286,7 @@ function diaspora_post_local(App $a, array &$b) $diaspora_post = intval(PConfig::get(local_user(),'diaspora','post')); - $diaspora_enable = (($diaspora_post && x($_REQUEST,'diaspora_enable')) ? intval($_REQUEST['diaspora_enable']) : 0); + $diaspora_enable = (($diaspora_post && !empty($_REQUEST['diaspora_enable'])) ? intval($_REQUEST['diaspora_enable']) : 0); if ($b['api_source'] && intval(PConfig::get(local_user(),'diaspora','post_by_default'))) { $diaspora_enable = 1; diff --git a/dwpost/dwpost.php b/dwpost/dwpost.php index 28ae2d97..cceb3ca0 100644 --- a/dwpost/dwpost.php +++ b/dwpost/dwpost.php @@ -137,7 +137,7 @@ function dwpost_post_local(App $a, array &$b) $dw_post = intval(PConfig::get(local_user(),'dwpost','post')); - $dw_enable = (($dw_post && x($_REQUEST,'dwpost_enable')) ? intval($_REQUEST['dwpost_enable']) : 0); + $dw_enable = (($dw_post && !empty($_REQUEST['dwpost_enable'])) ? intval($_REQUEST['dwpost_enable']) : 0); if ($b['api_source'] && intval(PConfig::get(local_user(),'dwpost','post_by_default'))) { $dw_enable = 1; diff --git a/forumdirectory/forumdirectory.php b/forumdirectory/forumdirectory.php index a901015f..0e2f0fe3 100644 --- a/forumdirectory/forumdirectory.php +++ b/forumdirectory/forumdirectory.php @@ -75,7 +75,7 @@ function forumdirectory_content(App $a) if (!empty($a->data['search'])) { $search = Strings::escapeTags(trim($a->data['search'])); } else { - $search = ((!empty($_GET['search'])) ? Strings::escapeTags(trim(rawurldecode($_GET['search']))) : ''); + $search = (!empty($_GET['search']) ? Strings::escapeTags(trim(rawurldecode($_GET['search']))) : ''); } $tpl = Renderer::getMarkupTemplate('directory_header.tpl'); diff --git a/fromapp/fromapp.php b/fromapp/fromapp.php index f2b0f1fc..e0ede735 100644 --- a/fromapp/fromapp.php +++ b/fromapp/fromapp.php @@ -30,7 +30,7 @@ function fromapp_uninstall() function fromapp_settings_post($a, $post) { - if (!local_user() || (! x($_POST, 'fromapp-submit'))) { + if (!local_user() || empty($_POST['fromapp-submit'])) { return; } diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php index 860438d8..35f90ac0 100644 --- a/fromgplus/fromgplus.php +++ b/fromgplus/fromgplus.php @@ -89,9 +89,9 @@ function fromgplus_addon_settings_post(&$a,&$b) { if (!empty($_POST['fromgplus-submit'])) { PConfig::set(local_user(),'fromgplus','account',trim($_POST['fromgplus-account'])); - $enable = (x($_POST,'fromgplus-enable') ? intval($_POST['fromgplus-enable']) : 0); + $enable = (!empty($_POST['fromgplus-enable']) ? intval($_POST['fromgplus-enable']) : 0); PConfig::set(local_user(),'fromgplus','enable', $enable); - $keywords = (x($_POST, 'fromgplus-keywords') ? intval($_POST['fromgplus-keywords']) : 0); + $keywords = (!empty($_POST['fromgplus-keywords']) ? intval($_POST['fromgplus-keywords']) : 0); PConfig::set(local_user(),'fromgplus', 'keywords', $keywords); if (!$enable) @@ -113,7 +113,7 @@ function fromgplus_addon_admin(&$a, &$o) function fromgplus_addon_admin_post(&$a) { - $key = ((x($_POST, 'key')) ? trim($_POST['key']) : ''); + $key = (!empty($_POST['key']) ? trim($_POST['key']) : ''); Config::set('fromgplus', 'key', $key); info(L10n::t('Settings updated.'). EOL); } diff --git a/geocoordinates/geocoordinates.php b/geocoordinates/geocoordinates.php index 58c5a30c..abb33abb 100644 --- a/geocoordinates/geocoordinates.php +++ b/geocoordinates/geocoordinates.php @@ -100,10 +100,10 @@ function geocoordinates_addon_admin(&$a, &$o) function geocoordinates_addon_admin_post(&$a) { - $api_key = ((x($_POST, 'api_key')) ? Strings::escapeTags(trim($_POST['api_key'])) : ''); + $api_key = (!empty($_POST['api_key']) ? Strings::escapeTags(trim($_POST['api_key'])) : ''); Config::set('geocoordinates', 'api_key', $api_key); - $language = ((x($_POST, 'language')) ? Strings::escapeTags(trim($_POST['language'])) : ''); + $language = (!empty($_POST['language']) ? Strings::escapeTags(trim($_POST['language'])) : ''); Config::set('geocoordinates', 'language', $language); info(L10n::t('Settings updated.'). EOL); } diff --git a/geonames/geonames.php b/geonames/geonames.php index 552ecf59..91a466fc 100644 --- a/geonames/geonames.php +++ b/geonames/geonames.php @@ -150,7 +150,7 @@ function geonames_post_hook($a, &$item) { */ function geonames_addon_admin_post($a,$post) { - if(! local_user() || (! x($_POST,'geonames-submit'))) + if(! local_user() || empty($_POST['geonames-submit'])) return; PConfig::set(local_user(),'geonames','enable',intval($_POST['geonames'])); diff --git a/gnot/gnot.php b/gnot/gnot.php index 3cab8539..f3a50705 100644 --- a/gnot/gnot.php +++ b/gnot/gnot.php @@ -44,7 +44,7 @@ function gnot_uninstall() { */ function gnot_settings_post($a,$post) { - if(! local_user() || (! x($_POST,'gnot-submit'))) + if(! local_user() || empty($_POST['gnot-submit'])) return; PConfig::set(local_user(),'gnot','enable',intval($_POST['gnot'])); diff --git a/gravatar/gravatar.php b/gravatar/gravatar.php index 68105554..fea06270 100644 --- a/gravatar/gravatar.php +++ b/gravatar/gravatar.php @@ -122,8 +122,8 @@ function gravatar_addon_admin (&$a, &$o) { function gravatar_addon_admin_post (&$a) { BaseModule::checkFormSecurityToken('gravatarsave'); - $default_avatar = ((x($_POST, 'avatar')) ? Strings::escapeTags(trim($_POST['avatar'])) : 'identicon'); - $rating = ((x($_POST, 'rating')) ? Strings::escapeTags(trim($_POST['rating'])) : 'g'); + $default_avatar = (!empty($_POST['avatar']) ? Strings::escapeTags(trim($_POST['avatar'])) : 'identicon'); + $rating = (!empty($_POST['rating']) ? Strings::escapeTags(trim($_POST['rating'])) : 'g'); Config::set('gravatar', 'default_avatar', $default_avatar); Config::set('gravatar', 'rating', $rating); info(L10n::t('Gravatar settings updated.') .EOL); diff --git a/group_text/group_text.php b/group_text/group_text.php index 76bb03fd..cf56dbec 100644 --- a/group_text/group_text.php +++ b/group_text/group_text.php @@ -40,7 +40,7 @@ function group_text_uninstall() { */ function group_text_settings_post($a,$post) { - if(! local_user() || (! x($_POST,'group_text-submit'))) + if(! local_user() || empty($_POST['group_text-submit'])) return; PConfig::set(local_user(),'system','groupedit_image_limit',intval($_POST['group_text'])); diff --git a/ifttt/ifttt.php b/ifttt/ifttt.php index fd570048..50fa119c 100644 --- a/ifttt/ifttt.php +++ b/ifttt/ifttt.php @@ -90,7 +90,7 @@ function ifttt_settings(App $a, &$s) function ifttt_settings_post() { - if (x($_POST, 'ifttt-submit') && isset($_POST['ifttt-rekey'])) { + if (!empty($_POST['ifttt-submit']) && isset($_POST['ifttt-rekey'])) { PConfig::delete(local_user(), 'ifttt', 'key'); } } diff --git a/ijpost/ijpost.php b/ijpost/ijpost.php index d2a3071e..dcb8f4bf 100644 --- a/ijpost/ijpost.php +++ b/ijpost/ijpost.php @@ -108,7 +108,7 @@ function ijpost_settings(&$a, &$s) function ijpost_settings_post(&$a, &$b) { - if (x($_POST, 'ijpost-submit')) { + if (!empty($_POST['ijpost-submit'])) { PConfig::set(local_user(), 'ijpost', 'post', intval($_POST['ijpost'])); PConfig::set(local_user(), 'ijpost', 'post_by_default', intval($_POST['ij_bydefault'])); PConfig::set(local_user(), 'ijpost', 'ij_username', trim($_POST['ij_username'])); @@ -134,7 +134,7 @@ function ijpost_post_local(&$a, &$b) $ij_post = intval(PConfig::get(local_user(), 'ijpost', 'post')); - $ij_enable = (($ij_post && x($_REQUEST, 'ijpost_enable')) ? intval($_REQUEST['ijpost_enable']) : 0); + $ij_enable = (($ij_post && !empty($_REQUEST['ijpost_enable'])) ? intval($_REQUEST['ijpost_enable']) : 0); if ($b['api_source'] && intval(PConfig::get(local_user(), 'ijpost', 'post_by_default'))) { $ij_enable = 1; diff --git a/impressum/impressum.php b/impressum/impressum.php index 6300efca..c5a1c98d 100644 --- a/impressum/impressum.php +++ b/impressum/impressum.php @@ -87,12 +87,12 @@ function impressum_show($a,&$b) { } function impressum_addon_admin_post (&$a) { - $owner = ((x($_POST, 'owner')) ? Strings::escapeTags(trim($_POST['owner'])) : ''); - $ownerprofile = ((x($_POST, 'ownerprofile')) ? Strings::escapeTags(trim($_POST['ownerprofile'])) : ''); - $postal = ((x($_POST, 'postal')) ? (trim($_POST['postal'])) : ''); - $notes = ((x($_POST, 'notes')) ? (trim($_POST['notes'])) : ''); - $email = ((x($_POST, 'email')) ? Strings::escapeTags(trim($_POST['email'])) : ''); - $footer_text = ((x($_POST, 'footer_text')) ? (trim($_POST['footer_text'])) : ''); + $owner = (!empty($_POST['owner']) ? Strings::escapeTags(trim($_POST['owner'])) : ''); + $ownerprofile = (!empty($_POST['ownerprofile']) ? Strings::escapeTags(trim($_POST['ownerprofile'])) : ''); + $postal = (!empty($_POST['postal']) ? (trim($_POST['postal'])) : ''); + $notes = (!empty($_POST['notes']) ? (trim($_POST['notes'])) : ''); + $email = (!empty($_POST['email']) ? Strings::escapeTags(trim($_POST['email'])) : ''); + $footer_text = (!empty($_POST['footer_text']) ? (trim($_POST['footer_text'])) : ''); Config::set('impressum','owner',strip_tags($owner)); Config::set('impressum','ownerprofile',strip_tags($ownerprofile)); Config::set('impressum','postal',strip_tags($postal)); diff --git a/irc/irc.php b/irc/irc.php index 4804fb6f..2677dc75 100644 --- a/irc/irc.php +++ b/irc/irc.php @@ -109,7 +109,7 @@ function irc_content(&$a) { if($autochans) $channels = $autochans; else - $channels = ((x($_GET,'channels')) ? $_GET['channels'] : 'friendica'); + $channels = defaults($_GET, 'channels', 'friendica'); /* add the chatroom frame and some html */ $o .= <<< EOT diff --git a/js_upload/js_upload.php b/js_upload/js_upload.php index d4f0ec1e..2203c9bf 100644 --- a/js_upload/js_upload.php +++ b/js_upload/js_upload.php @@ -183,7 +183,7 @@ function js_upload_post_file(&$a,&$b) { function js_upload_post_end(&$a,&$b) { Logger::log('upload_post_end'); - if(x($a->data,'upload_jsonresponse')) { + if(!empty($a->data['upload_jsonresponse'])) { echo $a->data['upload_jsonresponse']; killme(); } diff --git a/langfilter/langfilter.php b/langfilter/langfilter.php index 8cc8f697..512ac840 100644 --- a/langfilter/langfilter.php +++ b/langfilter/langfilter.php @@ -79,7 +79,7 @@ function langfilter_addon_settings_post(App $a, &$b) if (!empty($_POST['langfilter-settings-submit'])) { PConfig::set(local_user(), 'langfilter', 'languages', trim($_POST['langfilter_languages'])); - $enable = (x($_POST, 'langfilter_enable') ? intval($_POST['langfilter_enable']) : 0); + $enable = (!empty($_POST['langfilter_enable']) ? intval($_POST['langfilter_enable']) : 0); $disable = 1 - $enable; PConfig::set(local_user(), 'langfilter', 'disable', $disable); $minconfidence = 0 + $_POST['langfilter_minconfidence']; diff --git a/libertree/libertree.php b/libertree/libertree.php index 34fcd798..d5aa97e5 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -111,7 +111,7 @@ function libertree_settings(&$a,&$s) { function libertree_settings_post(&$a,&$b) { - if(x($_POST,'libertree-submit')) { + if(!empty($_POST['libertree-submit'])) { PConfig::set(local_user(),'libertree','post',intval($_POST['libertree'])); PConfig::set(local_user(),'libertree','post_by_default',intval($_POST['libertree_bydefault'])); @@ -155,7 +155,7 @@ function libertree_post_local(&$a,&$b) { $ltree_post = intval(PConfig::get(local_user(),'libertree','post')); - $ltree_enable = (($ltree_post && x($_REQUEST,'libertree_enable')) ? intval($_REQUEST['libertree_enable']) : 0); + $ltree_enable = (($ltree_post && !empty($_REQUEST['libertree_enable'])) ? intval($_REQUEST['libertree_enable']) : 0); if ($b['api_source'] && intval(PConfig::get(local_user(),'libertree','post_by_default'))) { $ltree_enable = 1; diff --git a/libravatar/libravatar.php b/libravatar/libravatar.php index 09f31c5b..d6ccb718 100644 --- a/libravatar/libravatar.php +++ b/libravatar/libravatar.php @@ -125,7 +125,7 @@ function libravatar_addon_admin_post(&$a) { BaseModule::checkFormSecurityToken('libravatarrsave'); - $default_avatar = ((x($_POST, 'avatar')) ? Strings::escapeTags(trim($_POST['avatar'])) : 'identicon'); + $default_avatar = (!empty($_POST['avatar']) ? Strings::escapeTags(trim($_POST['avatar'])) : 'identicon'); Config::set('libravatar', 'default_avatar', $default_avatar); info(L10n::t('Libravatar settings updated.') .EOL); } diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php index c60af03c..dc0c0fd6 100644 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -105,7 +105,7 @@ function ljpost_settings(&$a,&$s) { function ljpost_settings_post(&$a,&$b) { - if(x($_POST,'ljpost-submit')) { + if(!empty($_POST['ljpost-submit'])) { PConfig::set(local_user(),'ljpost','post',intval($_POST['ljpost'])); PConfig::set(local_user(),'ljpost','post_by_default',intval($_POST['lj_bydefault'])); @@ -131,7 +131,7 @@ function ljpost_post_local(&$a,&$b) { $lj_post = intval(PConfig::get(local_user(),'ljpost','post')); - $lj_enable = (($lj_post && x($_REQUEST,'ljpost_enable')) ? intval($_REQUEST['ljpost_enable']) : 0); + $lj_enable = (($lj_post && !empty($_REQUEST['ljpost_enable'])) ? intval($_REQUEST['ljpost_enable']) : 0); if($b['api_source'] && intval(PConfig::get(local_user(),'ljpost','post_by_default'))) $lj_enable = 1; diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index 1d2a4917..6b693f6c 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -86,7 +86,7 @@ function mailstream_addon_admin(&$a,&$o) { } function mailstream_addon_admin_post ($a) { - if (x($_POST, 'frommail')) { + if (!empty($_POST['frommail'])) { Config::set('mailstream', 'frommail', $_POST['frommail']); } } diff --git a/newmemberwidget/newmemberwidget.php b/newmemberwidget/newmemberwidget.php index 8ecbaaa9..4c0cfc3b 100644 --- a/newmemberwidget/newmemberwidget.php +++ b/newmemberwidget/newmemberwidget.php @@ -54,8 +54,8 @@ function newmemberwidget_network_mod_init ($a, $b) function newmemberwidget_addon_admin_post(&$a) { - $ft = ((x($_POST, 'freetext')) ? trim($_POST['freetext']) : ""); - $lsn = ((x($_POST, 'localsupportname')) ? Strings::escapeTags(trim($_POST['localsupportname'])) : ""); + $ft = (!empty($_POST['freetext']) ? trim($_POST['freetext']) : ""); + $lsn = (!empty($_POST['localsupportname']) ? Strings::escapeTags(trim($_POST['localsupportname'])) : ""); $gs = intval($_POST['linkglobalsupport']); $ls = intval($_POST['linklocalsupport']); Config::set('newmemberwidget', 'freetext', trim($ft)); diff --git a/notifyall/notifyall.php b/notifyall/notifyall.php index ea6712f1..51c426cc 100644 --- a/notifyall/notifyall.php +++ b/notifyall/notifyall.php @@ -54,7 +54,7 @@ function notifyall_post(App $a) $sender_name = '"' . L10n::t('%1$s, %2$s Administrator', Config::get('config', 'admin_name'), $sitename) . '"'; } - if (! x(Config::get('config', 'sender_email'))) { + if (!Config::get('config', 'sender_email')) { $sender_email = 'noreply@' . $a->getHostName(); } else { $sender_email = Config::get('config', 'sender_email'); diff --git a/notimeline/notimeline.php b/notimeline/notimeline.php index 6f747ca9..adba95c5 100644 --- a/notimeline/notimeline.php +++ b/notimeline/notimeline.php @@ -25,7 +25,7 @@ function notimeline_uninstall() function notimeline_settings_post($a, $post) { - if (!local_user() || (!x($_POST, 'notimeline-submit'))) { + if (!local_user() || empty($_POST['notimeline-submit'])) { return; } diff --git a/nsfw/nsfw.php b/nsfw/nsfw.php index 77d172ce..9836a056 100644 --- a/nsfw/nsfw.php +++ b/nsfw/nsfw.php @@ -103,7 +103,7 @@ function nsfw_addon_settings_post(&$a, &$b) if (!empty($_POST['nsfw-submit'])) { PConfig::set(local_user(), 'nsfw', 'words', trim($_POST['nsfw-words'])); - $enable = (x($_POST, 'nsfw-enable') ? intval($_POST['nsfw-enable']) : 0); + $enable = (!empty($_POST['nsfw-enable']) ? intval($_POST['nsfw-enable']) : 0); $disable = 1 - $enable; PConfig::set(local_user(), 'nsfw', 'disable', $disable); info(L10n::t('NSFW Settings saved.') . EOL); diff --git a/numfriends/numfriends.php b/numfriends/numfriends.php index 9e22b0ea..5bdc264c 100644 --- a/numfriends/numfriends.php +++ b/numfriends/numfriends.php @@ -37,7 +37,7 @@ function numfriends_uninstall() { * */ function numfriends_settings_post($a,$post) { - if(! local_user() || (! x($_POST,'numfriends-submit'))) + if(! local_user() || empty($_POST['numfriends-submit'])) return; PConfig::set(local_user(),'system','display_friend_count',intval($_POST['numfriends'])); diff --git a/piwik/piwik.php b/piwik/piwik.php index d96eba09..3e3144fb 100644 --- a/piwik/piwik.php +++ b/piwik/piwik.php @@ -108,10 +108,10 @@ function piwik_addon_admin (&$a, &$o) { ]); } function piwik_addon_admin_post (&$a) { - $url = ((x($_POST, 'baseurl')) ? Strings::escapeTags(trim($_POST['baseurl'])) : ''); - $id = ((x($_POST, 'siteid')) ? trim($_POST['siteid']) : ''); - $optout = ((x($_POST, 'optout')) ? trim($_POST['optout']) : ''); - $async = ((x($_POST, 'async')) ? trim($_POST['async']) : ''); + $url = (!empty($_POST['baseurl']) ? Strings::escapeTags(trim($_POST['baseurl'])) : ''); + $id = (!empty($_POST['siteid']) ? trim($_POST['siteid']) : ''); + $optout = (!empty($_POST['optout']) ? trim($_POST['optout']) : ''); + $async = (!empty($_POST['async']) ? trim($_POST['async']) : ''); Config::set('piwik', 'baseurl', $url); Config::set('piwik', 'siteid', $id); Config::set('piwik', 'optout', $optout); diff --git a/public_server/public_server.php b/public_server/public_server.php index ba7f2a64..7e09806e 100644 --- a/public_server/public_server.php +++ b/public_server/public_server.php @@ -124,8 +124,8 @@ function public_server_cron($a, $b) function public_server_enotify(&$a, &$b) { - if (x($b, 'params') && $b['params']['type'] == NOTIFY_SYSTEM - && x($b['params'], 'system_type') && $b['params']['system_type'] === 'public_server_expire') { + if (!empty($b['params']) && $b['params']['type'] == NOTIFY_SYSTEM + && !empty($b['params']['system_type']) && $b['params']['system_type'] === 'public_server_expire') { $b['itemlink'] = $a->getBaseURL(); $b['epreamble'] = $b['preamble'] = L10n::t('Your account on %s will expire in a few days.', Config::get('system', 'sitename')); $b['subject'] = L10n::t('Your Friendica account is about to expire.'); @@ -148,12 +148,12 @@ function public_server_login($a, $b) function public_server_addon_admin_post(&$a) { BaseModule::checkFormSecurityTokenRedirectOnError('/admin/addons/publicserver', 'publicserver'); - $expiredays = (x($_POST, 'expiredays') ? Strings::escapeTags(trim($_POST['expiredays'])) : ''); - $expireposts = (x($_POST, 'expireposts') ? Strings::escapeTags(trim($_POST['expireposts'])) : ''); - $nologin = (x($_POST, 'nologin') ? Strings::escapeTags(trim($_POST['nologin'])) : ''); - $flagusers = (x($_POST, 'flagusers') ? Strings::escapeTags(trim($_POST['flagusers'])) : ''); - $flagposts = (x($_POST, 'flagposts') ? Strings::escapeTags(trim($_POST['flagposts'])) : ''); - $flagpostsexpire = (x($_POST, 'flagpostsexpire') ? Strings::escapeTags(trim($_POST['flagpostsexpire'])) : ''); + $expiredays = (!empty($_POST['expiredays']) ? Strings::escapeTags(trim($_POST['expiredays'])) : ''); + $expireposts = (!empty($_POST['expireposts']) ? Strings::escapeTags(trim($_POST['expireposts'])) : ''); + $nologin = (!empty($_POST['nologin']) ? Strings::escapeTags(trim($_POST['nologin'])) : ''); + $flagusers = (!empty($_POST['flagusers']) ? Strings::escapeTags(trim($_POST['flagusers'])) : ''); + $flagposts = (!empty($_POST['flagposts']) ? Strings::escapeTags(trim($_POST['flagposts'])) : ''); + $flagpostsexpire = (!empty($_POST['flagpostsexpire']) ? Strings::escapeTags(trim($_POST['flagpostsexpire'])) : ''); Config::set('public_server', 'expiredays', $expiredays); Config::set('public_server', 'expireposts', $expireposts); Config::set('public_server', 'nologin', $nologin); diff --git a/remote_permissions/remote_permissions.php b/remote_permissions/remote_permissions.php index d08b40c9..623d4172 100644 --- a/remote_permissions/remote_permissions.php +++ b/remote_permissions/remote_permissions.php @@ -58,7 +58,7 @@ function remote_permissions_settings(&$a,&$o) { } function remote_permissions_settings_post($a,$post) { - if(! local_user() || (! x($_POST,'remote-perms-submit'))) + if(! local_user() || empty($_POST['remote-perms-submit'])) return; PConfig::set(local_user(),'remote_perms','show',intval($_POST['remote-perms'])); @@ -207,7 +207,7 @@ function remote_permissions_addon_admin(&$a, &$o){ } function remote_permissions_addon_admin_post(&$a){ - $choice = ((x($_POST,'remotepermschoice')) ? Strings::escapeTags(trim($_POST['remotepermschoice'])) : ''); + $choice = (!empty($_POST['remotepermschoice']) ? Strings::escapeTags(trim($_POST['remotepermschoice'])) : ''); Config::set('remote_perms','global',($choice == 1 ? 1 : 0)); info(L10n::t('Settings updated.'). EOL); } diff --git a/securemail/securemail.php b/securemail/securemail.php index 90251788..10a2b298 100644 --- a/securemail/securemail.php +++ b/securemail/securemail.php @@ -92,7 +92,7 @@ function securemail_settings_post(App &$a, array &$b){ if ($_POST['securemail-submit']) { PConfig::set(local_user(), 'securemail', 'pkey', trim($_POST['securemail-pkey'])); - $enable = ((x($_POST, 'securemail-enable')) ? 1 : 0); + $enable = (!empty($_POST['securemail-enable']) ? 1 : 0); PConfig::set(local_user(), 'securemail', 'enable', $enable); info(L10n::t('Secure Mail Settings saved.') . EOL); @@ -150,7 +150,7 @@ function securemail_settings_post(App &$a, array &$b){ * @see App */ function securemail_emailer_send_prepare(App &$a, array &$b) { - if (!x($b, 'uid')) { + if (empty($b['uid'])) { return; } @@ -164,7 +164,7 @@ function securemail_emailer_send_prepare(App &$a, array &$b) { $public_key_ascii = PConfig::get($uid, 'securemail', 'pkey'); preg_match('/-----BEGIN ([A-Za-z ]+)-----/', $public_key_ascii, $matches); - $marker = (empty($matches[1])) ? 'MESSAGE' : $matches[1]; + $marker = empty($matches[1]) ? 'MESSAGE' : $matches[1]; $public_key = OpenPGP::unarmor($public_key_ascii, $marker); $key = OpenPGP_Message::parse($public_key); diff --git a/showmore/showmore.php b/showmore/showmore.php index b46fe740..a7b5979b 100644 --- a/showmore/showmore.php +++ b/showmore/showmore.php @@ -71,7 +71,7 @@ function showmore_addon_settings_post(&$a, &$b) if (!empty($_POST['showmore-submit'])) { PConfig::set(local_user(), 'showmore', 'chars', trim($_POST['showmore-chars'])); - $enable = (x($_POST, 'showmore-enable') ? intval($_POST['showmore-enable']) : 0); + $enable = (!empty($_POST['showmore-enable']) ? intval($_POST['showmore-enable']) : 0); $disable = 1-$enable; PConfig::set(local_user(), 'showmore', 'disable', $disable); info(L10n::t('Show More Settings saved.') . EOL); diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 7fc6d4d3..0c4da5d2 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -123,7 +123,7 @@ function statusnet_settings_post(App $a, $post) return; } // don't check GNU Social settings if GNU Social submit button is not clicked - if (!x($_POST, 'statusnet-submit')) { + if (empty($_POST['statusnet-submit'])) { return; } @@ -447,7 +447,7 @@ function statusnet_post_local(App $a, &$b) } $statusnet_post = PConfig::get(local_user(), 'statusnet', 'post'); - $statusnet_enable = (($statusnet_post && x($_REQUEST, 'statusnet_enable')) ? intval($_REQUEST['statusnet_enable']) : 0); + $statusnet_enable = (($statusnet_post && !empty($_REQUEST['statusnet_enable'])) ? intval($_REQUEST['statusnet_enable']) : 0); // if API is used, default to the chosen settings if ($b['api_source'] && intval(PConfig::get(local_user(), 'statusnet', 'post_by_default'))) { @@ -667,12 +667,12 @@ function statusnet_addon_admin_post(App $a) } $secret = trim($_POST['secret'][$id]); $key = trim($_POST['key'][$id]); - //$applicationname = ((x($_POST, 'applicationname')) ? Strings::escapeTags(trim($_POST['applicationname'][$id])):''); + //$applicationname = (!empty($_POST['applicationname']) ? Strings::escapeTags(trim($_POST['applicationname'][$id])):''); if ($sitename != "" && $apiurl != "" && $secret != "" && $key != "" && - !x($_POST['delete'][$id])) { + empty($_POST['delete'][$id])) { $sites[] = [ 'sitename' => $sitename, diff --git a/testdrive/testdrive.php b/testdrive/testdrive.php index 4da5959b..6daf136e 100644 --- a/testdrive/testdrive.php +++ b/testdrive/testdrive.php @@ -97,8 +97,8 @@ function testdrive_cron($a,$b) { } function testdrive_enotify(&$a, &$b) { - if (x($b, 'params') && $b['params']['type'] == NOTIFY_SYSTEM - && x($b['params'], 'system_type') && $b['params']['system_type'] === 'testdrive_expire') { + if (!empty($b['params']) && $b['params']['type'] == NOTIFY_SYSTEM + && !empty($b['params']['system_type']) && $b['params']['system_type'] === 'testdrive_expire') { $b['itemlink'] = $a->getBaseURL(); $b['epreamble'] = $b['preamble'] = L10n::t('Your account on %s will expire in a few days.', Config::get('system', 'sitename')); $b['subject'] = L10n::t('Your Friendica test account is about to expire.'); diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index 83bdcf6e..2d4bd1a3 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -86,8 +86,8 @@ function tumblr_addon_admin(App $a, &$o) function tumblr_addon_admin_post(App $a) { - $consumer_key = ((!empty($_POST['consumer_key'])) ? Strings::escapeTags(trim($_POST['consumer_key'])) : ''); - $consumer_secret = ((!empty($_POST['consumer_secret'])) ? Strings::escapeTags(trim($_POST['consumer_secret'])): ''); + $consumer_key = (!empty($_POST['consumer_key']) ? Strings::escapeTags(trim($_POST['consumer_key'])) : ''); + $consumer_secret = (!empty($_POST['consumer_secret']) ? Strings::escapeTags(trim($_POST['consumer_secret'])): ''); Config::set('tumblr', 'consumer_key',$consumer_key); Config::set('tumblr', 'consumer_secret',$consumer_secret); diff --git a/twitter/twitter.php b/twitter/twitter.php index 2dbc1a2e..00342e82 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -446,7 +446,7 @@ function twitter_post_local(App $a, array &$b) } $twitter_post = intval(PConfig::get(local_user(), 'twitter', 'post')); - $twitter_enable = (($twitter_post && x($_REQUEST, 'twitter_enable')) ? intval($_REQUEST['twitter_enable']) : 0); + $twitter_enable = (($twitter_post && !empty($_REQUEST['twitter_enable'])) ? intval($_REQUEST['twitter_enable']) : 0); // if API is used, default to the chosen settings if ($b['api_source'] && intval(PConfig::get(local_user(), 'twitter', 'post_by_default'))) { @@ -703,8 +703,8 @@ function twitter_post_hook(App $a, array &$b) function twitter_addon_admin_post(App $a) { - $consumerkey = x($_POST, 'consumerkey') ? Strings::escapeTags(trim($_POST['consumerkey'])) : ''; - $consumersecret = x($_POST, 'consumersecret') ? Strings::escapeTags(trim($_POST['consumersecret'])) : ''; + $consumerkey = !empty($_POST['consumerkey']) ? Strings::escapeTags(trim($_POST['consumerkey'])) : ''; + $consumersecret = !empty($_POST['consumersecret']) ? Strings::escapeTags(trim($_POST['consumersecret'])) : ''; Config::set('twitter', 'consumerkey', $consumerkey); Config::set('twitter', 'consumersecret', $consumersecret); info(L10n::t('Settings updated.') . EOL); diff --git a/webrtc/webrtc.php b/webrtc/webrtc.php index d122870e..61bacfcd 100644 --- a/webrtc/webrtc.php +++ b/webrtc/webrtc.php @@ -33,7 +33,7 @@ function webrtc_addon_admin (&$a, &$o) { ]); } function webrtc_addon_admin_post (&$a) { - $url = ((x($_POST, 'webrtcurl')) ? Strings::escapeTags(trim($_POST['webrtcurl'])) : ''); + $url = (!empty($_POST['webrtcurl']) ? Strings::escapeTags(trim($_POST['webrtcurl'])) : ''); Config::set('webrtc', 'webrtcurl', $url); info(L10n::t('Settings updated.'). EOL); } diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php index 5ae0c3f3..a6c9aa9b 100644 --- a/windowsphonepush/windowsphonepush.php +++ b/windowsphonepush/windowsphonepush.php @@ -82,7 +82,7 @@ function windowsphonepush_module() */ function windowsphonepush_settings_post($a, $post) { - if (!local_user() || (!x($_POST, 'windowsphonepush-submit'))) { + if (!local_user() || empty($_POST['windowsphonepush-submit'])) { return; } $enable = intval($_POST['windowsphonepush']); diff --git a/wppost/wppost.php b/wppost/wppost.php index 018e86c4..1cc27976 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -147,7 +147,7 @@ function wppost_settings(&$a,&$s) { function wppost_settings_post(&$a,&$b) { - if(x($_POST,'wppost-submit')) { + if(!empty($_POST['wppost-submit'])) { PConfig::set(local_user(),'wppost','post',intval($_POST['wppost'])); PConfig::set(local_user(),'wppost','post_by_default',intval($_POST['wp_bydefault'])); @@ -198,7 +198,7 @@ function wppost_post_local(&$a, &$b) { $wp_post = intval(PConfig::get(local_user(),'wppost','post')); - $wp_enable = (($wp_post && x($_REQUEST,'wppost_enable')) ? intval($_REQUEST['wppost_enable']) : 0); + $wp_enable = (($wp_post && !empty($_REQUEST['wppost_enable'])) ? intval($_REQUEST['wppost_enable']) : 0); if ($b['api_source'] && intval(PConfig::get(local_user(),'wppost','post_by_default'))) { $wp_enable = 1; diff --git a/xmpp/xmpp.php b/xmpp/xmpp.php index 1342c26c..51ad2c90 100644 --- a/xmpp/xmpp.php +++ b/xmpp/xmpp.php @@ -117,8 +117,8 @@ function xmpp_addon_admin(App $a, &$o) function xmpp_addon_admin_post() { - $bosh_proxy = ((!empty($_POST['bosh_proxy'])) ? trim($_POST['bosh_proxy']) : ''); - $central_userbase = ((!empty($_POST['central_userbase'])) ? intval($_POST['central_userbase']) : false); + $bosh_proxy = (!empty($_POST['bosh_proxy']) ? trim($_POST['bosh_proxy']) : ''); + $central_userbase = (!empty($_POST['central_userbase']) ? intval($_POST['central_userbase']) : false); Config::set('xmpp', 'bosh_proxy', $bosh_proxy); Config::set('xmpp', 'central_userbase', $central_userbase); From a66099a05c499d94307ee51a7f05b93f16c6c4fb Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 30 Nov 2018 09:12:11 -0500 Subject: [PATCH 2/2] Update addon documentation --- README.md | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index deffa2a5..08451b6d 100644 --- a/README.md +++ b/README.md @@ -2,33 +2,26 @@ Addons for Friendica ==================== This repository is a collection of addons for the [Friendica Social Communications Server](https://github.com/friendica/friendica). -You can add these addons to the /addon directory of your Friendica installation -do extend the functionality of your node. +You can add these addons to the /addon directory of your Friendica installation do extend the functionality of your node. -After uploading the addons to your server, you need to activate the desired addons -in the Admin panel. Addons not activated have no effect on your node. +After uploading the addons to your server, you need to activate the desired addons in the Admin panel. Addons not activated have no effect on your node. -You can find more addons in the [Friendica Addon listing](https://addons.friendo.ca) -in cases the addon developers have choosen not to include them here. +You can find more addons in the [Friendica Addon listing](https://addons.friendo.ca) in cases the addon developers have choosen not to include them here. -Connectors ----------- +## Connectors -Among these addons there are also the [connectors](https://github.com/friendica/friendica/blob/master/doc/Connectors.md) for various other networks -(e.g. Twitter, pump.io, Google+) that are needed for communication when the -protocoll is not supported by Friendica core (DFRN, OStatus and Diaspora). +Among these addons there are also the [connectors](https://github.com/friendica/friendica/blob/master/doc/Connectors.md) for various other networks (e.g. Twitter, pump.io, Google+) that are needed for communication when the protocol is not supported by Friendica core (DFRN, OStatus and Diaspora). -For communication with contacts in networks supporting those (e.g. GNU social, -Diaspora and red#matrix) you just need to access the page configuration in the -Admin panel and enable them. For networks where communication is only possible -the API access to a remote account, you need to activate the fitting connectors. +For communication with contacts in networks supporting those (e.g. GNU social, Diaspora and red#matrix) you just need to access the page configuration in the Admin panel and enable them. For networks where communication is only possible the API access to a remote account, you need to activate the fitting connectors. -Development ------------ +## Development -The addon interface of Friendica is very flexible and powerful, so if you are -missing functionality, your chances are high it may be added with an addon. -See the [documentation](https://github.com/friendica/friendica/blob/master/doc/Addons.md) for more informations on the addon development. +The addon interface of Friendica is very flexible and powerful, so if you are missing functionality, your chances are high it may be added with an addon. +See the [documentation](https://github.com/friendica/friendica/blob/master/doc/Addons.md) for more information on the addon development. -Addons can be translated like any other part of Friendica. Translations for the -addons included in this repository are done at the [Transifex project](https://www.transifex.com/projects/p/friendica/) for Friendica. +## Translation + +Addons can be translated like any other part of Friendica. +Translation for addons is done at [the Transifex Friendica page](https://www.transifex.com/Friendica/friendica/dashboard/). + +Read more about the workflow in the [Friendica translation documentation](https://github.com/friendica/friendica/blob/master/doc/translations.md#addon).