Replace x() by !empty() or defaults() #779

Merged
MrPetovan merged 2 commits from task/remove-x into develop 2018-12-01 16:34:08 +01:00
43 changed files with 95 additions and 102 deletions

View file

@ -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). 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 You can add these addons to the /addon directory of your Friendica installation do extend the functionality of your node.
do extend the functionality of your node.
After uploading the addons to your server, you need to activate the desired addons 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.
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) 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.
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 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).
(e.g. Twitter, pump.io, Google+) that are needed for communication when the
protocoll is not supported by Friendica core (DFRN, OStatus and Diaspora).
For communication with contacts in networks supporting those (e.g. GNU social, 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.
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 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.
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.
See the [documentation](https://github.com/friendica/friendica/blob/master/doc/Addons.md) for more informations on the addon development.
Addons can be translated like any other part of Friendica. Translations for the ## Translation
addons included in this repository are done at the [Transifex project](https://www.transifex.com/projects/p/friendica/) for Friendica.
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).

View file

@ -165,7 +165,7 @@ function blogger_post_local(App $a, array &$b)
$bl_post = intval(PConfig::get(local_user(), 'blogger', 'post')); $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'))) { if ($b['api_source'] && intval(PConfig::get(local_user(), 'blogger', 'post_by_default'))) {
$bl_enable = 1; $bl_enable = 1;

View file

@ -86,8 +86,8 @@ function buffer_addon_admin(App $a, &$o)
function buffer_addon_admin_post(App $a) function buffer_addon_admin_post(App $a)
{ {
$client_id = ((!empty($_POST['client_id'])) ? Strings::escapeTags(trim($_POST['client_id'])) : ''); $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_secret = (!empty($_POST['client_secret']) ? Strings::escapeTags(trim($_POST['client_secret'])) : '');
Config::set('buffer', 'client_id' , $client_id); Config::set('buffer', 'client_id' , $client_id);
Config::set('buffer', 'client_secret', $client_secret); Config::set('buffer', 'client_secret', $client_secret);

View file

@ -118,7 +118,7 @@ function curweather_network_mod_init(App $a, &$b)
$rpt = PConfig::get(local_user(), 'curweather', 'curweather_loc'); $rpt = PConfig::get(local_user(), 'curweather', 'curweather_loc');
// Set the language to the browsers language or default and use metric units // 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'); $units = PConfig::get( local_user(), 'curweather', 'curweather_units');
$appid = Config::get('curweather', 'appid'); $appid = Config::get('curweather', 'appid');
$cachetime = intval(Config::get('curweather', 'cachetime')); $cachetime = intval(Config::get('curweather', 'cachetime'));

View file

@ -136,7 +136,7 @@ class Diaspora_Connection {
} elseif (!empty($m[1])) { } elseif (!empty($m[1])) {
$token = $m[1]; $token = $m[1];
} }
return (!empty($token)) ? $token : false; return !empty($token) ? $token : false;
} }
private function readJsonResponse($response) { private function readJsonResponse($response) {
@ -165,14 +165,14 @@ class Diaspora_Connection {
$this->doHttpRequest('/bookmarklet'); $this->doHttpRequest('/bookmarklet');
$m = []; $m = [];
preg_match('/"aspects"\:(\[.+?\])/', $this->last_http_result->response, $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() { public function getServices() {
$this->doHttpRequest('/bookmarklet'); $this->doHttpRequest('/bookmarklet');
$m = []; $m = [];
preg_match('/"configured_services"\:(\[.+?\])/', $this->last_http_result->response, $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 = '') { public function getNotifications($notification_type = '', $show = '') {

View file

@ -286,7 +286,7 @@ function diaspora_post_local(App $a, array &$b)
$diaspora_post = intval(PConfig::get(local_user(),'diaspora','post')); $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'))) { if ($b['api_source'] && intval(PConfig::get(local_user(),'diaspora','post_by_default'))) {
$diaspora_enable = 1; $diaspora_enable = 1;

View file

@ -137,7 +137,7 @@ function dwpost_post_local(App $a, array &$b)
$dw_post = intval(PConfig::get(local_user(),'dwpost','post')); $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'))) { if ($b['api_source'] && intval(PConfig::get(local_user(),'dwpost','post_by_default'))) {
$dw_enable = 1; $dw_enable = 1;

View file

@ -75,7 +75,7 @@ function forumdirectory_content(App $a)
if (!empty($a->data['search'])) { if (!empty($a->data['search'])) {
$search = Strings::escapeTags(trim($a->data['search'])); $search = Strings::escapeTags(trim($a->data['search']));
} else { } 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'); $tpl = Renderer::getMarkupTemplate('directory_header.tpl');

View file

@ -30,7 +30,7 @@ function fromapp_uninstall()
function fromapp_settings_post($a, $post) function fromapp_settings_post($a, $post)
{ {
if (!local_user() || (! x($_POST, 'fromapp-submit'))) { if (!local_user() || empty($_POST['fromapp-submit'])) {
return; return;
} }

View file

@ -89,9 +89,9 @@ function fromgplus_addon_settings_post(&$a,&$b) {
if (!empty($_POST['fromgplus-submit'])) { if (!empty($_POST['fromgplus-submit'])) {
PConfig::set(local_user(),'fromgplus','account',trim($_POST['fromgplus-account'])); 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); 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); PConfig::set(local_user(),'fromgplus', 'keywords', $keywords);
if (!$enable) if (!$enable)
@ -113,7 +113,7 @@ function fromgplus_addon_admin(&$a, &$o)
function fromgplus_addon_admin_post(&$a) 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); Config::set('fromgplus', 'key', $key);
info(L10n::t('Settings updated.'). EOL); info(L10n::t('Settings updated.'). EOL);
} }

View file

@ -100,10 +100,10 @@ function geocoordinates_addon_admin(&$a, &$o)
function geocoordinates_addon_admin_post(&$a) 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); 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); Config::set('geocoordinates', 'language', $language);
info(L10n::t('Settings updated.'). EOL); info(L10n::t('Settings updated.'). EOL);
} }

View file

@ -150,7 +150,7 @@ function geonames_post_hook($a, &$item) {
*/ */
function geonames_addon_admin_post($a,$post) { function geonames_addon_admin_post($a,$post) {
if(! local_user() || (! x($_POST,'geonames-submit'))) if(! local_user() || empty($_POST['geonames-submit']))
return; return;
PConfig::set(local_user(),'geonames','enable',intval($_POST['geonames'])); PConfig::set(local_user(),'geonames','enable',intval($_POST['geonames']));

View file

@ -44,7 +44,7 @@ function gnot_uninstall() {
*/ */
function gnot_settings_post($a,$post) { function gnot_settings_post($a,$post) {
if(! local_user() || (! x($_POST,'gnot-submit'))) if(! local_user() || empty($_POST['gnot-submit']))
return; return;
PConfig::set(local_user(),'gnot','enable',intval($_POST['gnot'])); PConfig::set(local_user(),'gnot','enable',intval($_POST['gnot']));

View file

@ -122,8 +122,8 @@ function gravatar_addon_admin (&$a, &$o) {
function gravatar_addon_admin_post (&$a) { function gravatar_addon_admin_post (&$a) {
BaseModule::checkFormSecurityToken('gravatarsave'); BaseModule::checkFormSecurityToken('gravatarsave');
$default_avatar = ((x($_POST, 'avatar')) ? Strings::escapeTags(trim($_POST['avatar'])) : 'identicon'); $default_avatar = (!empty($_POST['avatar']) ? Strings::escapeTags(trim($_POST['avatar'])) : 'identicon');
$rating = ((x($_POST, 'rating')) ? Strings::escapeTags(trim($_POST['rating'])) : 'g'); $rating = (!empty($_POST['rating']) ? Strings::escapeTags(trim($_POST['rating'])) : 'g');
Config::set('gravatar', 'default_avatar', $default_avatar); Config::set('gravatar', 'default_avatar', $default_avatar);
Config::set('gravatar', 'rating', $rating); Config::set('gravatar', 'rating', $rating);
info(L10n::t('Gravatar settings updated.') .EOL); info(L10n::t('Gravatar settings updated.') .EOL);

View file

@ -40,7 +40,7 @@ function group_text_uninstall() {
*/ */
function group_text_settings_post($a,$post) { function group_text_settings_post($a,$post) {
if(! local_user() || (! x($_POST,'group_text-submit'))) if(! local_user() || empty($_POST['group_text-submit']))
return; return;
PConfig::set(local_user(),'system','groupedit_image_limit',intval($_POST['group_text'])); PConfig::set(local_user(),'system','groupedit_image_limit',intval($_POST['group_text']));

View file

@ -90,7 +90,7 @@ function ifttt_settings(App $a, &$s)
function ifttt_settings_post() 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'); PConfig::delete(local_user(), 'ifttt', 'key');
} }
} }

View file

@ -108,7 +108,7 @@ function ijpost_settings(&$a, &$s)
function ijpost_settings_post(&$a, &$b) 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', intval($_POST['ijpost']));
PConfig::set(local_user(), 'ijpost', 'post_by_default', intval($_POST['ij_bydefault'])); PConfig::set(local_user(), 'ijpost', 'post_by_default', intval($_POST['ij_bydefault']));
PConfig::set(local_user(), 'ijpost', 'ij_username', trim($_POST['ij_username'])); 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_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'))) { if ($b['api_source'] && intval(PConfig::get(local_user(), 'ijpost', 'post_by_default'))) {
$ij_enable = 1; $ij_enable = 1;

View file

@ -87,12 +87,12 @@ function impressum_show($a,&$b) {
} }
function impressum_addon_admin_post (&$a) { function impressum_addon_admin_post (&$a) {
$owner = ((x($_POST, 'owner')) ? Strings::escapeTags(trim($_POST['owner'])) : ''); $owner = (!empty($_POST['owner']) ? Strings::escapeTags(trim($_POST['owner'])) : '');
$ownerprofile = ((x($_POST, 'ownerprofile')) ? Strings::escapeTags(trim($_POST['ownerprofile'])) : ''); $ownerprofile = (!empty($_POST['ownerprofile']) ? Strings::escapeTags(trim($_POST['ownerprofile'])) : '');
$postal = ((x($_POST, 'postal')) ? (trim($_POST['postal'])) : ''); $postal = (!empty($_POST['postal']) ? (trim($_POST['postal'])) : '');
$notes = ((x($_POST, 'notes')) ? (trim($_POST['notes'])) : ''); $notes = (!empty($_POST['notes']) ? (trim($_POST['notes'])) : '');
$email = ((x($_POST, 'email')) ? Strings::escapeTags(trim($_POST['email'])) : ''); $email = (!empty($_POST['email']) ? Strings::escapeTags(trim($_POST['email'])) : '');
$footer_text = ((x($_POST, 'footer_text')) ? (trim($_POST['footer_text'])) : ''); $footer_text = (!empty($_POST['footer_text']) ? (trim($_POST['footer_text'])) : '');
Config::set('impressum','owner',strip_tags($owner)); Config::set('impressum','owner',strip_tags($owner));
Config::set('impressum','ownerprofile',strip_tags($ownerprofile)); Config::set('impressum','ownerprofile',strip_tags($ownerprofile));
Config::set('impressum','postal',strip_tags($postal)); Config::set('impressum','postal',strip_tags($postal));

View file

@ -109,7 +109,7 @@ function irc_content(&$a) {
if($autochans) if($autochans)
$channels = $autochans; $channels = $autochans;
else else
$channels = ((x($_GET,'channels')) ? $_GET['channels'] : 'friendica'); $channels = defaults($_GET, 'channels', 'friendica');
/* add the chatroom frame and some html */ /* add the chatroom frame and some html */
$o .= <<< EOT $o .= <<< EOT

View file

@ -183,7 +183,7 @@ function js_upload_post_file(&$a,&$b) {
function js_upload_post_end(&$a,&$b) { function js_upload_post_end(&$a,&$b) {
Logger::log('upload_post_end'); Logger::log('upload_post_end');
if(x($a->data,'upload_jsonresponse')) { if(!empty($a->data['upload_jsonresponse'])) {
echo $a->data['upload_jsonresponse']; echo $a->data['upload_jsonresponse'];
killme(); killme();
} }

View file

@ -79,7 +79,7 @@ function langfilter_addon_settings_post(App $a, &$b)
if (!empty($_POST['langfilter-settings-submit'])) { if (!empty($_POST['langfilter-settings-submit'])) {
PConfig::set(local_user(), 'langfilter', 'languages', trim($_POST['langfilter_languages'])); 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; $disable = 1 - $enable;
PConfig::set(local_user(), 'langfilter', 'disable', $disable); PConfig::set(local_user(), 'langfilter', 'disable', $disable);
$minconfidence = 0 + $_POST['langfilter_minconfidence']; $minconfidence = 0 + $_POST['langfilter_minconfidence'];

View file

@ -111,7 +111,7 @@ function libertree_settings(&$a,&$s) {
function libertree_settings_post(&$a,&$b) { 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',intval($_POST['libertree']));
PConfig::set(local_user(),'libertree','post_by_default',intval($_POST['libertree_bydefault'])); 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_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'))) { if ($b['api_source'] && intval(PConfig::get(local_user(),'libertree','post_by_default'))) {
$ltree_enable = 1; $ltree_enable = 1;

View file

@ -125,7 +125,7 @@ function libravatar_addon_admin_post(&$a)
{ {
BaseModule::checkFormSecurityToken('libravatarrsave'); 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); Config::set('libravatar', 'default_avatar', $default_avatar);
info(L10n::t('Libravatar settings updated.') .EOL); info(L10n::t('Libravatar settings updated.') .EOL);
} }

View file

@ -105,7 +105,7 @@ function ljpost_settings(&$a,&$s) {
function ljpost_settings_post(&$a,&$b) { 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',intval($_POST['ljpost']));
PConfig::set(local_user(),'ljpost','post_by_default',intval($_POST['lj_bydefault'])); 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_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'))) if($b['api_source'] && intval(PConfig::get(local_user(),'ljpost','post_by_default')))
$lj_enable = 1; $lj_enable = 1;

View file

@ -86,7 +86,7 @@ function mailstream_addon_admin(&$a,&$o) {
} }
function mailstream_addon_admin_post ($a) { function mailstream_addon_admin_post ($a) {
if (x($_POST, 'frommail')) { if (!empty($_POST['frommail'])) {
Config::set('mailstream', 'frommail', $_POST['frommail']); Config::set('mailstream', 'frommail', $_POST['frommail']);
} }
} }

View file

@ -54,8 +54,8 @@ function newmemberwidget_network_mod_init ($a, $b)
function newmemberwidget_addon_admin_post(&$a) function newmemberwidget_addon_admin_post(&$a)
{ {
$ft = ((x($_POST, 'freetext')) ? trim($_POST['freetext']) : ""); $ft = (!empty($_POST['freetext']) ? trim($_POST['freetext']) : "");
$lsn = ((x($_POST, 'localsupportname')) ? Strings::escapeTags(trim($_POST['localsupportname'])) : ""); $lsn = (!empty($_POST['localsupportname']) ? Strings::escapeTags(trim($_POST['localsupportname'])) : "");
$gs = intval($_POST['linkglobalsupport']); $gs = intval($_POST['linkglobalsupport']);
$ls = intval($_POST['linklocalsupport']); $ls = intval($_POST['linklocalsupport']);
Config::set('newmemberwidget', 'freetext', trim($ft)); Config::set('newmemberwidget', 'freetext', trim($ft));

View file

@ -54,7 +54,7 @@ function notifyall_post(App $a)
$sender_name = '"' . L10n::t('%1$s, %2$s Administrator', Config::get('config', 'admin_name'), $sitename) . '"'; $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(); $sender_email = 'noreply@' . $a->getHostName();
} else { } else {
$sender_email = Config::get('config', 'sender_email'); $sender_email = Config::get('config', 'sender_email');

View file

@ -25,7 +25,7 @@ function notimeline_uninstall()
function notimeline_settings_post($a, $post) function notimeline_settings_post($a, $post)
{ {
if (!local_user() || (!x($_POST, 'notimeline-submit'))) { if (!local_user() || empty($_POST['notimeline-submit'])) {
return; return;
} }

View file

@ -103,7 +103,7 @@ function nsfw_addon_settings_post(&$a, &$b)
if (!empty($_POST['nsfw-submit'])) { if (!empty($_POST['nsfw-submit'])) {
PConfig::set(local_user(), 'nsfw', 'words', trim($_POST['nsfw-words'])); 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; $disable = 1 - $enable;
PConfig::set(local_user(), 'nsfw', 'disable', $disable); PConfig::set(local_user(), 'nsfw', 'disable', $disable);
info(L10n::t('NSFW Settings saved.') . EOL); info(L10n::t('NSFW Settings saved.') . EOL);

View file

@ -37,7 +37,7 @@ function numfriends_uninstall() {
* *
*/ */
function numfriends_settings_post($a,$post) { function numfriends_settings_post($a,$post) {
if(! local_user() || (! x($_POST,'numfriends-submit'))) if(! local_user() || empty($_POST['numfriends-submit']))
return; return;
PConfig::set(local_user(),'system','display_friend_count',intval($_POST['numfriends'])); PConfig::set(local_user(),'system','display_friend_count',intval($_POST['numfriends']));

View file

@ -108,10 +108,10 @@ function piwik_addon_admin (&$a, &$o) {
]); ]);
} }
function piwik_addon_admin_post (&$a) { function piwik_addon_admin_post (&$a) {
$url = ((x($_POST, 'baseurl')) ? Strings::escapeTags(trim($_POST['baseurl'])) : ''); $url = (!empty($_POST['baseurl']) ? Strings::escapeTags(trim($_POST['baseurl'])) : '');
$id = ((x($_POST, 'siteid')) ? trim($_POST['siteid']) : ''); $id = (!empty($_POST['siteid']) ? trim($_POST['siteid']) : '');
$optout = ((x($_POST, 'optout')) ? trim($_POST['optout']) : ''); $optout = (!empty($_POST['optout']) ? trim($_POST['optout']) : '');
$async = ((x($_POST, 'async')) ? trim($_POST['async']) : ''); $async = (!empty($_POST['async']) ? trim($_POST['async']) : '');
Config::set('piwik', 'baseurl', $url); Config::set('piwik', 'baseurl', $url);
Config::set('piwik', 'siteid', $id); Config::set('piwik', 'siteid', $id);
Config::set('piwik', 'optout', $optout); Config::set('piwik', 'optout', $optout);

View file

@ -124,8 +124,8 @@ function public_server_cron($a, $b)
function public_server_enotify(&$a, &$b) function public_server_enotify(&$a, &$b)
{ {
if (x($b, 'params') && $b['params']['type'] == NOTIFY_SYSTEM if (!empty($b['params']) && $b['params']['type'] == NOTIFY_SYSTEM
&& x($b['params'], 'system_type') && $b['params']['system_type'] === 'public_server_expire') { && !empty($b['params']['system_type']) && $b['params']['system_type'] === 'public_server_expire') {
$b['itemlink'] = $a->getBaseURL(); $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['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.'); $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) function public_server_addon_admin_post(&$a)
{ {
BaseModule::checkFormSecurityTokenRedirectOnError('/admin/addons/publicserver', 'publicserver'); BaseModule::checkFormSecurityTokenRedirectOnError('/admin/addons/publicserver', 'publicserver');
$expiredays = (x($_POST, 'expiredays') ? Strings::escapeTags(trim($_POST['expiredays'])) : ''); $expiredays = (!empty($_POST['expiredays']) ? Strings::escapeTags(trim($_POST['expiredays'])) : '');
$expireposts = (x($_POST, 'expireposts') ? Strings::escapeTags(trim($_POST['expireposts'])) : ''); $expireposts = (!empty($_POST['expireposts']) ? Strings::escapeTags(trim($_POST['expireposts'])) : '');
$nologin = (x($_POST, 'nologin') ? Strings::escapeTags(trim($_POST['nologin'])) : ''); $nologin = (!empty($_POST['nologin']) ? Strings::escapeTags(trim($_POST['nologin'])) : '');
$flagusers = (x($_POST, 'flagusers') ? Strings::escapeTags(trim($_POST['flagusers'])) : ''); $flagusers = (!empty($_POST['flagusers']) ? Strings::escapeTags(trim($_POST['flagusers'])) : '');
$flagposts = (x($_POST, 'flagposts') ? Strings::escapeTags(trim($_POST['flagposts'])) : ''); $flagposts = (!empty($_POST['flagposts']) ? Strings::escapeTags(trim($_POST['flagposts'])) : '');
$flagpostsexpire = (x($_POST, 'flagpostsexpire') ? Strings::escapeTags(trim($_POST['flagpostsexpire'])) : ''); $flagpostsexpire = (!empty($_POST['flagpostsexpire']) ? Strings::escapeTags(trim($_POST['flagpostsexpire'])) : '');
Config::set('public_server', 'expiredays', $expiredays); Config::set('public_server', 'expiredays', $expiredays);
Config::set('public_server', 'expireposts', $expireposts); Config::set('public_server', 'expireposts', $expireposts);
Config::set('public_server', 'nologin', $nologin); Config::set('public_server', 'nologin', $nologin);

View file

@ -58,7 +58,7 @@ function remote_permissions_settings(&$a,&$o) {
} }
function remote_permissions_settings_post($a,$post) { function remote_permissions_settings_post($a,$post) {
if(! local_user() || (! x($_POST,'remote-perms-submit'))) if(! local_user() || empty($_POST['remote-perms-submit']))
return; return;
PConfig::set(local_user(),'remote_perms','show',intval($_POST['remote-perms'])); 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){ 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)); Config::set('remote_perms','global',($choice == 1 ? 1 : 0));
info(L10n::t('Settings updated.'). EOL); info(L10n::t('Settings updated.'). EOL);
} }

View file

@ -92,7 +92,7 @@ function securemail_settings_post(App &$a, array &$b){
if ($_POST['securemail-submit']) { if ($_POST['securemail-submit']) {
PConfig::set(local_user(), 'securemail', 'pkey', trim($_POST['securemail-pkey'])); 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); PConfig::set(local_user(), 'securemail', 'enable', $enable);
info(L10n::t('Secure Mail Settings saved.') . EOL); info(L10n::t('Secure Mail Settings saved.') . EOL);
@ -150,7 +150,7 @@ function securemail_settings_post(App &$a, array &$b){
* @see App * @see App
*/ */
function securemail_emailer_send_prepare(App &$a, array &$b) { function securemail_emailer_send_prepare(App &$a, array &$b) {
if (!x($b, 'uid')) { if (empty($b['uid'])) {
return; return;
} }
@ -164,7 +164,7 @@ function securemail_emailer_send_prepare(App &$a, array &$b) {
$public_key_ascii = PConfig::get($uid, 'securemail', 'pkey'); $public_key_ascii = PConfig::get($uid, 'securemail', 'pkey');
preg_match('/-----BEGIN ([A-Za-z ]+)-----/', $public_key_ascii, $matches); 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); $public_key = OpenPGP::unarmor($public_key_ascii, $marker);
$key = OpenPGP_Message::parse($public_key); $key = OpenPGP_Message::parse($public_key);

View file

@ -71,7 +71,7 @@ function showmore_addon_settings_post(&$a, &$b)
if (!empty($_POST['showmore-submit'])) { if (!empty($_POST['showmore-submit'])) {
PConfig::set(local_user(), 'showmore', 'chars', trim($_POST['showmore-chars'])); 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; $disable = 1-$enable;
PConfig::set(local_user(), 'showmore', 'disable', $disable); PConfig::set(local_user(), 'showmore', 'disable', $disable);
info(L10n::t('Show More Settings saved.') . EOL); info(L10n::t('Show More Settings saved.') . EOL);

View file

@ -123,7 +123,7 @@ function statusnet_settings_post(App $a, $post)
return; return;
} }
// don't check GNU Social settings if GNU Social submit button is not clicked // 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; return;
} }
@ -447,7 +447,7 @@ function statusnet_post_local(App $a, &$b)
} }
$statusnet_post = PConfig::get(local_user(), 'statusnet', 'post'); $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 API is used, default to the chosen settings
if ($b['api_source'] && intval(PConfig::get(local_user(), 'statusnet', 'post_by_default'))) { 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]); $secret = trim($_POST['secret'][$id]);
$key = trim($_POST['key'][$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 != "" && if ($sitename != "" &&
$apiurl != "" && $apiurl != "" &&
$secret != "" && $secret != "" &&
$key != "" && $key != "" &&
!x($_POST['delete'][$id])) { empty($_POST['delete'][$id])) {
$sites[] = [ $sites[] = [
'sitename' => $sitename, 'sitename' => $sitename,

View file

@ -97,8 +97,8 @@ function testdrive_cron($a,$b) {
} }
function testdrive_enotify(&$a, &$b) { function testdrive_enotify(&$a, &$b) {
if (x($b, 'params') && $b['params']['type'] == NOTIFY_SYSTEM if (!empty($b['params']) && $b['params']['type'] == NOTIFY_SYSTEM
&& x($b['params'], 'system_type') && $b['params']['system_type'] === 'testdrive_expire') { && !empty($b['params']['system_type']) && $b['params']['system_type'] === 'testdrive_expire') {
$b['itemlink'] = $a->getBaseURL(); $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['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.'); $b['subject'] = L10n::t('Your Friendica test account is about to expire.');

View file

@ -86,8 +86,8 @@ function tumblr_addon_admin(App $a, &$o)
function tumblr_addon_admin_post(App $a) function tumblr_addon_admin_post(App $a)
{ {
$consumer_key = ((!empty($_POST['consumer_key'])) ? Strings::escapeTags(trim($_POST['consumer_key'])) : ''); $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_secret = (!empty($_POST['consumer_secret']) ? Strings::escapeTags(trim($_POST['consumer_secret'])): '');
Config::set('tumblr', 'consumer_key',$consumer_key); Config::set('tumblr', 'consumer_key',$consumer_key);
Config::set('tumblr', 'consumer_secret',$consumer_secret); Config::set('tumblr', 'consumer_secret',$consumer_secret);

View file

@ -446,7 +446,7 @@ function twitter_post_local(App $a, array &$b)
} }
$twitter_post = intval(PConfig::get(local_user(), 'twitter', 'post')); $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 API is used, default to the chosen settings
if ($b['api_source'] && intval(PConfig::get(local_user(), 'twitter', 'post_by_default'))) { 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) function twitter_addon_admin_post(App $a)
{ {
$consumerkey = x($_POST, 'consumerkey') ? Strings::escapeTags(trim($_POST['consumerkey'])) : ''; $consumerkey = !empty($_POST['consumerkey']) ? Strings::escapeTags(trim($_POST['consumerkey'])) : '';
$consumersecret = x($_POST, 'consumersecret') ? Strings::escapeTags(trim($_POST['consumersecret'])) : ''; $consumersecret = !empty($_POST['consumersecret']) ? Strings::escapeTags(trim($_POST['consumersecret'])) : '';
Config::set('twitter', 'consumerkey', $consumerkey); Config::set('twitter', 'consumerkey', $consumerkey);
Config::set('twitter', 'consumersecret', $consumersecret); Config::set('twitter', 'consumersecret', $consumersecret);
info(L10n::t('Settings updated.') . EOL); info(L10n::t('Settings updated.') . EOL);

View file

@ -33,7 +33,7 @@ function webrtc_addon_admin (&$a, &$o) {
]); ]);
} }
function webrtc_addon_admin_post (&$a) { 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); Config::set('webrtc', 'webrtcurl', $url);
info(L10n::t('Settings updated.'). EOL); info(L10n::t('Settings updated.'). EOL);
} }

View file

@ -82,7 +82,7 @@ function windowsphonepush_module()
*/ */
function windowsphonepush_settings_post($a, $post) function windowsphonepush_settings_post($a, $post)
{ {
if (!local_user() || (!x($_POST, 'windowsphonepush-submit'))) { if (!local_user() || empty($_POST['windowsphonepush-submit'])) {
return; return;
} }
$enable = intval($_POST['windowsphonepush']); $enable = intval($_POST['windowsphonepush']);

View file

@ -147,7 +147,7 @@ function wppost_settings(&$a,&$s) {
function wppost_settings_post(&$a,&$b) { 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',intval($_POST['wppost']));
PConfig::set(local_user(),'wppost','post_by_default',intval($_POST['wp_bydefault'])); 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_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'))) { if ($b['api_source'] && intval(PConfig::get(local_user(),'wppost','post_by_default'))) {
$wp_enable = 1; $wp_enable = 1;

View file

@ -117,8 +117,8 @@ function xmpp_addon_admin(App $a, &$o)
function xmpp_addon_admin_post() function xmpp_addon_admin_post()
{ {
$bosh_proxy = ((!empty($_POST['bosh_proxy'])) ? trim($_POST['bosh_proxy']) : ''); $bosh_proxy = (!empty($_POST['bosh_proxy']) ? trim($_POST['bosh_proxy']) : '');
$central_userbase = ((!empty($_POST['central_userbase'])) ? intval($_POST['central_userbase']) : false); $central_userbase = (!empty($_POST['central_userbase']) ? intval($_POST['central_userbase']) : false);
Config::set('xmpp', 'bosh_proxy', $bosh_proxy); Config::set('xmpp', 'bosh_proxy', $bosh_proxy);
Config::set('xmpp', 'central_userbase', $central_userbase); Config::set('xmpp', 'central_userbase', $central_userbase);