Browse Source

Merge remote-tracking branch 'upstream/develop' into sanitize-gcontact

pull/7757/head
Michael 2 years ago
parent
commit
98c12006d5
  1. 41
      boot.php
  2. 1
      doc/Developers-Intro.md
  3. 2
      include/api.php
  4. 16
      include/conversation.php
  5. 22
      include/enotify.php
  6. 2
      include/items.php
  7. 2
      mod/cal.php
  8. 2
      mod/common.php
  9. 22
      mod/crepair.php
  10. 26
      mod/dfrn_confirm.php
  11. 6
      mod/dfrn_notify.php
  12. 42
      mod/dfrn_poll.php
  13. 8
      mod/dfrn_request.php
  14. 4
      mod/display.php
  15. 24
      mod/events.php
  16. 2
      mod/fbrowser.php
  17. 2
      mod/follow.php
  18. 2
      mod/fsuggest.php
  19. 2
      mod/hcard.php
  20. 8
      mod/hovercard.php
  21. 2
      mod/ignored.php
  22. 71
      mod/item.php
  23. 10
      mod/match.php
  24. 6
      mod/message.php
  25. 6
      mod/msearch.php
  26. 24
      mod/network.php
  27. 2
      mod/noscrape.php
  28. 6
      mod/notifications.php
  29. 18
      mod/photos.php
  30. 2
      mod/poco.php
  31. 8
      mod/pubsub.php
  32. 12
      mod/redir.php
  33. 2
      mod/regmod.php
  34. 45
      mod/settings.php
  35. 4
      mod/tagrm.php
  36. 2
      mod/unfollow.php
  37. 4
      mod/videos.php
  38. 4
      mod/wallmessage.php
  39. 4
      mods/sample-Lighttpd.config
  40. 2
      src/App/Arguments.php
  41. 12
      src/App/BaseURL.php
  42. 2
      src/BaseObject.php
  43. 2
      src/Content/Pager.php
  44. 333
      src/Content/Text/BBCode.php
  45. 4
      src/Content/Text/HTML.php
  46. 2
      src/Content/Widget/CalendarExport.php
  47. 2
      src/Content/Widget/ContactBlock.php
  48. 22
      src/Core/ACL.php
  49. 2
      src/Core/Authentication.php
  50. 8
      src/Core/Config/Configuration.php
  51. 8
      src/Core/Config/PConfiguration.php
  52. 2
      src/Core/NotificationsManager.php
  53. 2
      src/Core/Renderer.php
  54. 48
      src/Core/Search.php
  55. 2
      src/Core/Session.php
  56. 2
      src/Core/StorageManager.php
  57. 8
      src/Database/DBStructure.php
  58. 44
      src/Model/Contact.php
  59. 11
      src/Model/Conversation.php
  60. 44
      src/Model/Event.php
  61. 12
      src/Model/GContact.php
  62. 6
      src/Model/GServer.php
  63. 86
      src/Model/Item.php
  64. 4
      src/Model/ItemContent.php
  65. 8
      src/Model/PermissionSet.php
  66. 16
      src/Model/Profile.php
  67. 2
      src/Model/Storage/Filesystem.php
  68. 2
      src/Model/Term.php
  69. 4
      src/Module/Acctlink.php
  70. 2
      src/Module/Admin/Addons/Details.php
  71. 2
      src/Module/Admin/Addons/Index.php
  72. 6
      src/Module/Admin/Blocklist/Contact.php
  73. 2
      src/Module/Admin/Logs/Settings.php
  74. 4
      src/Module/Admin/Site.php
  75. 2
      src/Module/Admin/Themes/Index.php
  76. 10
      src/Module/Admin/Users.php
  77. 2
      src/Module/AllFriends.php
  78. 4
      src/Module/Bookmarklet.php
  79. 49
      src/Module/Contact.php
  80. 10
      src/Module/Debug/Babel.php
  81. 2
      src/Module/Debug/Feed.php
  82. 6
      src/Module/Debug/Localtime.php
  83. 2
      src/Module/Debug/Probe.php
  84. 2
      src/Module/Debug/WebFinger.php
  85. 2
      src/Module/Feed.php
  86. 4
      src/Module/Filer/RemoveTag.php
  87. 2
      src/Module/Filer/SaveTag.php
  88. 8
      src/Module/FollowConfirm.php
  89. 2
      src/Module/Followers.php
  90. 2
      src/Module/Following.php
  91. 6
      src/Module/Install.php
  92. 2
      src/Module/Like.php
  93. 2
      src/Module/Login.php
  94. 4
      src/Module/Magic.php
  95. 2
      src/Module/Outbox.php
  96. 8
      src/Module/Profile.php
  97. 2
      src/Module/Profile/Contacts.php
  98. 2
      src/Module/Proxy.php
  99. 14
      src/Module/Register.php
  100. 8
      src/Module/Search/Acl.php

41
boot.php

@ -322,47 +322,6 @@ function get_app()
return BaseObject::getApp();
}
/**
* Return the provided variable value if it exists and is truthy or the provided
* default value instead.
*
* Works with initialized variables and potentially uninitialized array keys
*
* Usages:
* - defaults($var, $default)
* - defaults($array, 'key', $default)
*
* @param array $args
* @brief Returns a defaut value if the provided variable or array key is falsy
* @return mixed
* @deprecated since version 2019.06, use native coalesce operator (??) instead
*/
function defaults(...$args)
{
if (count($args) < 2) {
throw new BadFunctionCallException('defaults() requires at least 2 parameters');
}
if (count($args) > 3) {
throw new BadFunctionCallException('defaults() cannot use more than 3 parameters');
}
if (count($args) === 3 && is_null($args[1])) {
throw new BadFunctionCallException('defaults($arr, $key, $def) $key is null');
}
// The default value always is the last argument
$return = array_pop($args);
if (count($args) == 2 && is_array($args[0]) && !empty($args[0][$args[1]])) {
$return = $args[0][$args[1]];
}
if (count($args) == 1 && !empty($args[0])) {
$return = $args[0];
}
return $return;
}
/**
* @brief Used to end the current process, after saving session state.
* @deprecated

1
doc/Developers-Intro.md

@ -81,6 +81,7 @@ Here's a few primers if you are new to Friendica or to the PSR-2 coding standard
* No closing PHP tag
* No trailing spaces
* Array declarations use the new square brackets syntax
* Quoting style is single quotes by default, except for needed string interpolation, SQL query strings by convention and comments that should stay in natural language.
Don't worry, you don't have to know by heart the PSR-2 coding standards to start contributing to Friendica.
There are a few tools you can use to check or fix your files before you commit.

2
include/api.php

@ -322,7 +322,7 @@ function api_call(App $a)
$stamp = microtime(true);
$return = call_user_func($info['func'], $type);
$duration = (float) (microtime(true) - $stamp);
$duration = floatval(microtime(true) - $stamp);
Logger::info(API_LOG_PREFIX . 'username {username}', ['module' => 'api', 'action' => 'call', 'username' => $a->user['username'], 'duration' => round($duration, 2)]);

16
include/conversation.php

@ -1208,7 +1208,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
'$new_post' => L10n::t('New Post'),
'$return_path' => $query_str,
'$action' => 'item',
'$share' => defaults($x, 'button', L10n::t('Share')),
'$share' => ($x['button'] ?? '') ?: L10n::t('Share'),
'$upload' => L10n::t('Upload photo'),
'$shortupload' => L10n::t('upload photo'),
'$attach' => L10n::t('Attach file'),
@ -1225,17 +1225,17 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
'$shortsetloc' => L10n::t('set location'),
'$noloc' => L10n::t('Clear browser location'),
'$shortnoloc' => L10n::t('clear location'),
'$title' => defaults($x, 'title', ''),
'$title' => $x['title'] ?? '',
'$placeholdertitle' => L10n::t('Set title'),
'$category' => defaults($x, 'category', ''),
'$category' => $x['category'] ?? '',
'$placeholdercategory' => Feature::isEnabled(local_user(), 'categories') ? L10n::t("Categories \x28comma-separated list\x29") : '',
'$wait' => L10n::t('Please wait'),
'$permset' => L10n::t('Permission settings'),
'$shortpermset' => L10n::t('permissions'),
'$wall' => $notes_cid ? 0 : 1,
'$posttype' => $notes_cid ? Item::PT_PERSONAL_NOTE : Item::PT_ARTICLE,
'$content' => defaults($x, 'content', ''),
'$post_id' => defaults($x, 'post_id', ''),
'$content' => $x['content'] ?? '',
'$post_id' => $x['post_id'] ?? '',
'$baseurl' => System::baseUrl(true),
'$defloc' => $x['default_location'],
'$visitor' => $x['visitor'],
@ -1527,9 +1527,9 @@ function get_responses(array $conv_responses, array $response_verbs, array $item
$ret = [];
foreach ($response_verbs as $v) {
$ret[$v] = [];
$ret[$v]['count'] = defaults($conv_responses[$v], $item['uri'], 0);
$ret[$v]['list'] = defaults($conv_responses[$v], $item['uri'] . '-l', []);
$ret[$v]['self'] = defaults($conv_responses[$v], $item['uri'] . '-self', '0');
$ret[$v]['count'] = $conv_responses[$v][$item['uri']] ?? 0;
$ret[$v]['list'] = $conv_responses[$v][$item['uri'] . '-l'] ?? [];
$ret[$v]['self'] = $conv_responses[$v][$item['uri'] . '-self'] ?? '0';
if (count($ret[$v]['list']) > MAX_LIKERS) {
$ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS);
array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-'

22
include/enotify.php

@ -46,10 +46,10 @@ function notification($params)
return false;
}
$params['notify_flags'] = defaults($params, 'notify_flags', $user['notify-flags']);
$params['language'] = defaults($params, 'language' , $user['language']);
$params['to_name'] = defaults($params, 'to_name' , $user['username']);
$params['to_email'] = defaults($params, 'to_email' , $user['email']);
$params['notify_flags'] = ($params['notify_flags'] ?? '') ?: $user['notify-flags'];
$params['language'] = ($params['language'] ?? '') ?: $user['language'];
$params['to_name'] = ($params['to_name'] ?? '') ?: $user['username'];
$params['to_email'] = ($params['to_email'] ?? '') ?: $user['email'];
// from here on everything is in the recipients language
L10n::pushLang($params['language']);
@ -456,17 +456,17 @@ function notification($params)
if (!isset($params['subject'])) {
Logger::warning('subject isn\'t set.', ['type' => $params['type']]);
}
$subject = defaults($params, 'subject', '');
$subject = $params['subject'] ?? '';
if (!isset($params['preamble'])) {
Logger::warning('preamble isn\'t set.', ['type' => $params['type'], 'subject' => $subject]);
}
$preamble = defaults($params, 'preamble', '');
$preamble = $params['preamble'] ?? '';
if (!isset($params['body'])) {
Logger::warning('body isn\'t set.', ['type' => $params['type'], 'subject' => $subject, 'preamble' => $preamble]);
}
$body = defaults($params, 'body', '');
$body = $params['body'] ?? '';
$show_in_notification_page = false;
}
@ -613,11 +613,11 @@ function notification($params)
$datarray['siteurl'] = $siteurl;
$datarray['type'] = $params['type'];
$datarray['parent'] = $parent_id;
$datarray['source_name'] = defaults($params, 'source_name', '');
$datarray['source_link'] = defaults($params, 'source_link', '');
$datarray['source_photo'] = defaults($params, 'source_photo', '');
$datarray['source_name'] = $params['source_name'] ?? '';
$datarray['source_link'] = $params['source_link'] ?? '';
$datarray['source_photo'] = $params['source_photo'] ?? '';
$datarray['uid'] = $params['uid'];
$datarray['username'] = defaults($params, 'to_name', '');
$datarray['username'] = $params['to_name'] ?? '';
$datarray['hsitelink'] = $hsitelink;
$datarray['tsitelink'] = $tsitelink;
$datarray['hitemlink'] = '<a href="'.$itemlink.'">'.$itemlink.'</a>';

2
include/items.php

@ -42,7 +42,7 @@ function add_page_info_data(array $data, $no_photos = false)
$data["type"] = "link";
}
$data["title"] = defaults($data, "title", "");
$data["title"] = $data["title"] ?? '';
if ((($data["type"] != "link") && ($data["type"] != "video") && ($data["type"] != "photo")) || ($data["title"] == $data["url"])) {
return "";

2
mod/cal.php

@ -200,7 +200,7 @@ function cal_content(App $a)
// put the event parametes in an array so we can better transmit them
$event_params = [
'event_id' => intval(defaults($_GET, 'id', 0)),
'event_id' => intval($_GET['id'] ?? 0),
'start' => $start,
'finish' => $finish,
'adjust_start' => $adjust_start,

2
mod/common.php

@ -118,7 +118,7 @@ function common_content(App $a)
$entry = [
'url' => Model\Contact::magicLink($common_friend['url']),
'itemurl' => defaults($contact_details, 'addr', $common_friend['url']),
'itemurl' => ($contact_details['addr'] ?? '') ?: $common_friend['url'],
'name' => $contact_details['name'],
'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
'img_hover' => $contact_details['name'],

22
mod/crepair.php

@ -38,17 +38,17 @@ function crepair_post(App $a)
return;
}
$name = defaults($_POST, 'name' , $contact['name']);
$nick = defaults($_POST, 'nick' , '');
$url = defaults($_POST, 'url' , '');
$alias = defaults($_POST, 'alias' , '');
$request = defaults($_POST, 'request' , '');
$confirm = defaults($_POST, 'confirm' , '');
$notify = defaults($_POST, 'notify' , '');
$poll = defaults($_POST, 'poll' , '');
$attag = defaults($_POST, 'attag' , '');
$photo = defaults($_POST, 'photo' , '');
$remote_self = defaults($_POST, 'remote_self', false);
$name = ($_POST['name'] ?? '') ?: $contact['name'];
$nick = $_POST['nick'] ?? '';
$url = $_POST['url'] ?? '';
$alias = $_POST['alias'] ?? '';
$request = $_POST['request'] ?? '';
$confirm = $_POST['confirm'] ?? '';
$notify = $_POST['notify'] ?? '';
$poll = $_POST['poll'] ?? '';
$attag = $_POST['attag'] ?? '';
$photo = $_POST['photo'] ?? '';
$remote_self = $_POST['remote_self'] ?? false;
$nurl = Strings::normaliseLink($url);
$r = DBA::update(

26
mod/dfrn_confirm.php

@ -59,7 +59,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
* since we are operating on behalf of our registered user to approve a friendship.
*/
if (empty($_POST['source_url'])) {
$uid = defaults($handsfree, 'uid', local_user());
$uid = ($handsfree['uid'] ?? 0) ?: local_user();
if (!$uid) {
notice(L10n::t('Permission denied.') . EOL);
return;
@ -78,13 +78,13 @@ function dfrn_confirm_post(App $a, $handsfree = null)
$intro_id = $handsfree['intro_id'];
$duplex = $handsfree['duplex'];
$cid = 0;
$hidden = intval(defaults($handsfree, 'hidden' , 0));
$hidden = intval($handsfree['hidden'] ?? 0);
} else {
$dfrn_id = Strings::escapeTags(trim(defaults($_POST, 'dfrn_id' , '')));
$intro_id = intval(defaults($_POST, 'intro_id' , 0));
$duplex = intval(defaults($_POST, 'duplex' , 0));
$cid = intval(defaults($_POST, 'contact_id', 0));
$hidden = intval(defaults($_POST, 'hidden' , 0));
$dfrn_id = Strings::escapeTags(trim($_POST['dfrn_id'] ?? ''));
$intro_id = intval($_POST['intro_id'] ?? 0);
$duplex = intval($_POST['duplex'] ?? 0);
$cid = intval($_POST['contact_id'] ?? 0);
$hidden = intval($_POST['hidden'] ?? 0);
}
/*
@ -347,12 +347,12 @@ function dfrn_confirm_post(App $a, $handsfree = null)
*/
if (!empty($_POST['source_url'])) {
// We are processing an external confirmation to an introduction created by our user.
$public_key = defaults($_POST, 'public_key', '');
$dfrn_id = hex2bin(defaults($_POST, 'dfrn_id' , ''));
$source_url = hex2bin(defaults($_POST, 'source_url', ''));
$aes_key = defaults($_POST, 'aes_key' , '');
$duplex = intval(defaults($_POST, 'duplex' , 0));
$page = intval(defaults($_POST, 'page' , 0));
$public_key = $_POST['public_key'] ?? '';
$dfrn_id = hex2bin($_POST['dfrn_id'] ?? '');
$source_url = hex2bin($_POST['source_url'] ?? '');
$aes_key = $_POST['aes_key'] ?? '';
$duplex = intval($_POST['duplex'] ?? 0);
$page = intval($_POST['page'] ?? 0);
$forum = (($page == 1) ? 1 : 0);
$prv = (($page == 2) ? 1 : 0);

6
mod/dfrn_notify.php

@ -26,7 +26,7 @@ function dfrn_notify_post(App $a) {
if (empty($_POST) || !empty($postdata)) {
$data = json_decode($postdata);
if (is_object($data)) {
$nick = defaults($a->argv, 1, '');
$nick = $a->argv[1] ?? '';
$user = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
if (!DBA::isResult($user)) {
@ -42,8 +42,8 @@ function dfrn_notify_post(App $a) {
$dfrn_id = (!empty($_POST['dfrn_id']) ? Strings::escapeTags(trim($_POST['dfrn_id'])) : '');
$dfrn_version = (!empty($_POST['dfrn_version']) ? (float) $_POST['dfrn_version'] : 2.0);
$challenge = (!empty($_POST['challenge']) ? Strings::escapeTags(trim($_POST['challenge'])) : '');
$data = defaults($_POST, 'data', '');
$key = defaults($_POST, 'key', '');
$data = $_POST['data'] ?? '';
$key = $_POST['key'] ?? '';
$rino_remote = (!empty($_POST['rino']) ? intval($_POST['rino']) : 0);
$dissolve = (!empty($_POST['dissolve']) ? intval($_POST['dissolve']) : 0);
$perm = (!empty($_POST['perm']) ? Strings::escapeTags(trim($_POST['perm'])) : 'r');

42
mod/dfrn_poll.php

@ -22,17 +22,17 @@ function dfrn_poll_init(App $a)
{
Login::sessionAuth();
$dfrn_id = defaults($_GET, 'dfrn_id' , '');
$type = defaults($_GET, 'type' , 'data');
$last_update = defaults($_GET, 'last_update' , '');
$destination_url = defaults($_GET, 'destination_url', '');
$challenge = defaults($_GET, 'challenge' , '');
$sec = defaults($_GET, 'sec' , '');
$dfrn_version = (float) defaults($_GET, 'dfrn_version' , 2.0);
$dfrn_id = $_GET['dfrn_id'] ?? '';
$type = ($_GET['type'] ?? '') ?: 'data';
$last_update = $_GET['last_update'] ?? '';
$destination_url = $_GET['destination_url'] ?? '';
$challenge = $_GET['challenge'] ?? '';
$sec = $_GET['sec'] ?? '';
$dfrn_version = floatval(($_GET['dfrn_version'] ?? 0.0) ?: 2.0);
$quiet = !empty($_GET['quiet']);
// Possibly it is an OStatus compatible server that requests a user feed
$user_agent = defaults($_SERVER, 'HTTP_USER_AGENT', '');
$user_agent = $_SERVER['HTTP_USER_AGENT'] ?? '';
if (($a->argc > 1) && ($dfrn_id == '') && !strstr($user_agent, 'Friendica')) {
$nickname = $a->argv[1];
header("Content-type: application/atom+xml");
@ -225,13 +225,13 @@ function dfrn_poll_init(App $a)
function dfrn_poll_post(App $a)
{
$dfrn_id = defaults($_POST, 'dfrn_id' , '');
$challenge = defaults($_POST, 'challenge', '');
$url = defaults($_POST, 'url' , '');
$sec = defaults($_POST, 'sec' , '');
$ptype = defaults($_POST, 'type' , '');
$perm = defaults($_POST, 'perm' , 'r');
$dfrn_version = !empty($_POST['dfrn_version']) ? (float) $_POST['dfrn_version'] : 2.0;
$dfrn_id = $_POST['dfrn_id'] ?? '';
$challenge = $_POST['challenge'] ?? '';
$url = $_POST['url'] ?? '';
$sec = $_POST['sec'] ?? '';
$ptype = $_POST['type'] ?? '';
$perm = ($_POST['perm'] ?? '') ?: 'r';
$dfrn_version = floatval(($_GET['dfrn_version'] ?? 0.0) ?: 2.0);
if ($ptype === 'profile-check') {
if (strlen($challenge) && strlen($sec)) {
@ -391,12 +391,12 @@ function dfrn_poll_post(App $a)
function dfrn_poll_content(App $a)
{
$dfrn_id = defaults($_GET, 'dfrn_id' , '');
$type = defaults($_GET, 'type' , 'data');
$last_update = defaults($_GET, 'last_update' , '');
$destination_url = defaults($_GET, 'destination_url', '');
$sec = defaults($_GET, 'sec' , '');
$dfrn_version = !empty($_GET['dfrn_version']) ? (float) $_GET['dfrn_version'] : 2.0;
$dfrn_id = $_GET['dfrn_id'] ?? '';
$type = ($_GET['type'] ?? '') ?: 'data';
$last_update = $_GET['last_update'] ?? '';
$destination_url = $_GET['destination_url'] ?? '';
$sec = $_GET['sec'] ?? '';
$dfrn_version = floatval(($_GET['dfrn_version'] ?? 0.0) ?: 2.0);
$quiet = !empty($_GET['quiet']);
$direction = -1;

8
mod/dfrn_request.php

@ -80,7 +80,7 @@ function dfrn_request_post(App $a)
if (local_user() && ($a->user['nickname'] == $a->argv[1]) && !empty($_POST['dfrn_url'])) {
$dfrn_url = Strings::escapeTags(trim($_POST['dfrn_url']));
$aes_allow = !empty($_POST['aes_allow']);
$confirm_key = defaults($_POST, 'confirm_key', "");
$confirm_key = $_POST['confirm_key'] ?? '';
$hidden = (!empty($_POST['hidden-contact']) ? intval($_POST['hidden-contact']) : 0);
$contact_record = null;
$blocked = 1;
@ -169,7 +169,7 @@ function dfrn_request_post(App $a)
$r = q("SELECT `id`, `network` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `site-pubkey` = '%s' LIMIT 1",
intval(local_user()),
DBA::escape($dfrn_url),
defaults($parms, 'key', '') // Potentially missing
$parms['key'] ?? '' // Potentially missing
);
if (DBA::isResult($r)) {
Group::addMember(User::getDefaultGroup(local_user(), $r[0]["network"]), $r[0]['id']);
@ -423,7 +423,7 @@ function dfrn_request_post(App $a)
intval($uid),
intval($contact_record['id']),
intval(!empty($_POST['knowyou'])),
DBA::escape(Strings::escapeTags(trim(defaults($_POST, 'dfrn-request-message', '')))),
DBA::escape(Strings::escapeTags(trim($_POST['dfrn-request-message'] ?? ''))),
DBA::escape($hash),
DBA::escape(DateTimeFormat::utcNow())
);
@ -499,7 +499,7 @@ function dfrn_request_content(App $a)
$dfrn_url = Strings::escapeTags(trim(hex2bin($_GET['dfrn_url'])));
$aes_allow = !empty($_GET['aes_allow']);
$confirm_key = defaults($_GET, 'confirm_key', "");
$confirm_key = $_GET['confirm_key'] ?? '';
// Checking fastlane for validity
if (!empty($_SESSION['fastlane']) && (Strings::normaliseLink($_SESSION["fastlane"]) == Strings::normaliseLink($dfrn_url))) {

4
mod/display.php

@ -276,8 +276,8 @@ function display_content(App $a, $update = false, $update_uid = 0)
if (isset($item_parent_uri)) {
$parent = Item::selectFirst(['uid'], ['uri' => $item_parent_uri, 'wall' => true]);
if (DBA::isResult($parent)) {
$a->profile['uid'] = defaults($a->profile, 'uid', $parent['uid']);
$a->profile['profile_uid'] = defaults($a->profile, 'profile_uid', $parent['uid']);
$a->profile['uid'] = ($a->profile['uid'] ?? 0) ?: $parent['uid'];
$a->profile['profile_uid'] = ($a->profile['profile_uid'] ?? 0) ?: $parent['uid'];
$is_remote_contact = Session::getRemoteContactID($a->profile['profile_uid']);
if ($is_remote_contact) {
$item_uid = $parent['uid'];

24
mod/events.php

@ -59,11 +59,11 @@ function events_post(App $a)
$cid = !empty($_POST['cid']) ? intval($_POST['cid']) : 0;
$uid = local_user();
$start_text = Strings::escapeHtml(defaults($_REQUEST, 'start_text', ''));
$finish_text = Strings::escapeHtml(defaults($_REQUEST, 'finish_text', ''));
$start_text = Strings::escapeHtml($_REQUEST['start_text'] ?? '');
$finish_text = Strings::escapeHtml($_REQUEST['finish_text'] ?? '');
$adjust = intval(defaults($_POST, 'adjust', 0));
$nofinish = intval(defaults($_POST, 'nofinish', 0));
$adjust = intval($_POST['adjust'] ?? 0);
$nofinish = intval($_POST['nofinish'] ?? 0);
// The default setting for the `private` field in event_store() is false, so mirror that
$private_event = false;
@ -96,9 +96,9 @@ function events_post(App $a)
// and we'll waste a bunch of time responding to it. Time that
// could've been spent doing something else.
$summary = trim(defaults($_POST, 'summary' , ''));
$desc = trim(defaults($_POST, 'desc' , ''));
$location = trim(defaults($_POST, 'location', ''));
$summary = trim($_POST['summary'] ?? '');
$desc = trim($_POST['desc'] ?? '');
$location = trim($_POST['location'] ?? '');
$type = 'event';
$params = [
@ -132,7 +132,7 @@ function events_post(App $a)
$a->internalRedirect($onerror_path);
}
$share = intval(defaults($_POST, 'share', 0));
$share = intval($_POST['share'] ?? 0);
$c = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
intval(local_user())
@ -146,10 +146,10 @@ function events_post(App $a)
if ($share) {
$str_group_allow = perms2str(defaults($_POST, 'group_allow' , ''));
$str_contact_allow = perms2str(defaults($_POST, 'contact_allow', ''));
$str_group_deny = perms2str(defaults($_POST, 'group_deny' , ''));
$str_contact_deny = perms2str(defaults($_POST, 'contact_deny' , ''));
$str_group_allow = perms2str($_POST['group_allow'] ?? '');
$str_contact_allow = perms2str($_POST['contact_allow'] ?? '');
$str_group_deny = perms2str($_POST['group_deny'] ?? '');
$str_contact_deny = perms2str($_POST['contact_deny'] ?? '');
// Undo the pseudo-contact of self, since there are real contacts now
if (strpos($str_contact_allow, '<' . $self . '>') !== false) {

2
mod/fbrowser.php

@ -29,7 +29,7 @@ function fbrowser_content(App $a)
}
// Needed to match the correct template in a module that uses a different theme than the user/site/default
$theme = Strings::sanitizeFilePathItem(defaults($_GET, 'theme', null));
$theme = Strings::sanitizeFilePathItem($_GET['theme'] ?? null);
if ($theme && is_file("view/theme/$theme/config.php")) {
$a->setCurrentTheme($theme);
}

2
mod/follow.php

@ -62,7 +62,7 @@ function follow_content(App $a)
$uid = local_user();
// Issue 4815: Silently removing a prefixing @
$url = ltrim(Strings::escapeTags(trim(defaults($_REQUEST, 'url', ''))), '@!');
$url = ltrim(Strings::escapeTags(trim($_REQUEST['url'] ?? '')), '@!');
// Issue 6874: Allow remote following from Peertube
if (strpos($url, 'acct:') === 0) {

2
mod/fsuggest.php

@ -45,7 +45,7 @@ function fsuggest_post(App $a)
return;
}
$note = Strings::escapeHtml(trim(defaults($_POST, 'note', '')));
$note = Strings::escapeHtml(trim($_POST['note'] ?? ''));
$fields = ['uid' => local_user(),'cid' => $contact_id, 'name' => $contact['name'],
'url' => $contact['url'], 'request' => $contact['request'],

2
mod/hcard.php

@ -41,7 +41,7 @@ function hcard_init(App $a)
}
if (!$blocked) {
$keywords = defaults($a->profile, 'pub_keywords', '');
$keywords = $a->profile['pub_keywords'] ?? '';
$keywords = str_replace([',',' ',',,'], [' ',',',','], $keywords);
if (strlen($keywords)) {
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n";

8
mod/hovercard.php

@ -26,8 +26,8 @@ function hovercard_init(App $a)
function hovercard_content()
{
$profileurl = defaults($_REQUEST, 'profileurl', '');
$datatype = defaults($_REQUEST, 'datatype' , 'json');
$profileurl = $_REQUEST['profileurl'] ?? '';
$datatype = ($_REQUEST['datatype'] ?? '') ?: 'json';
// Get out if the system doesn't have public access allowed
if (intval(Config::get('system', 'block_public'))) {
@ -50,7 +50,7 @@ function hovercard_content()
if (strpos($profileurl, 'redir/') === 0) {
$cid = intval(substr($profileurl, 6));
$remote_contact = DBA::selectFirst('contact', ['nurl'], ['id' => $cid]);
$profileurl = defaults($remote_contact, 'nurl', '');
$profileurl = $remote_contact['nurl'] ?? '';
}
$contact = [];
@ -97,7 +97,7 @@ function hovercard_content()
$profile = [
'name' => $contact['name'],
'nick' => $contact['nick'],
'addr' => defaults($contact, 'addr', $contact['url']),
'addr' => ($contact['addr'] ?? '') ?: $contact['url'],
'thumb' => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB),
'url' => Contact::magicLink($contact['url']),
'nurl' => $contact['nurl'], // We additionally store the nurl as identifier

2
mod/ignored.php

@ -33,7 +33,7 @@ function ignored_init(App $a)
}
// See if we've been passed a return path to redirect to
$return_path = defaults($_REQUEST, 'return', '');
$return_path = $_REQUEST['return'] ?? '';
if ($return_path) {
$rand = '_=' . time();
if (strpos($return_path, '?')) {

71
mod/item.php

@ -64,12 +64,12 @@ function item_post(App $a) {
Logger::log('postvars ' . print_r($_REQUEST, true), Logger::DATA);
$api_source = defaults($_REQUEST, 'api_source', false);
$api_source = $_REQUEST['api_source'] ?? false;
$message_id = ((!empty($_REQUEST['message_id']) && $api_source) ? strip_tags($_REQUEST['message_id']) : '');
$return_path = defaults($_REQUEST, 'return', '');
$preview = intval(defaults($_REQUEST, 'preview', 0));
$return_path = $_REQUEST['return'] ?? '';
$preview = intval($_REQUEST['preview'] ?? 0);
/*
* Check for doubly-submitted posts, and reject duplicates
@ -86,8 +86,8 @@ function item_post(App $a) {
}
// Is this a reply to something?
$toplevel_item_id = intval(defaults($_REQUEST, 'parent', 0));
$thr_parent_uri = trim(defaults($_REQUEST, 'parent_uri', ''));
$toplevel_item_id = intval($_REQUEST['parent'] ?? 0);
$thr_parent_uri = trim($_REQUEST['parent_uri'] ?? '');
$thread_parent_id = 0;
$thread_parent_contact = null;
@ -98,8 +98,8 @@ function item_post(App $a) {
$parent_contact = null;
$objecttype = null;
$profile_uid = defaults($_REQUEST, 'profile_uid', local_user());
$posttype = defaults($_REQUEST, 'post_type', Item::PT_ARTICLE);
$profile_uid = ($_REQUEST['profile_uid'] ?? 0) ?: local_user();
$posttype = ($_REQUEST['post_type'] ?? '') ?: Item::PT_ARTICLE;
if ($toplevel_item_id || $thr_parent_uri) {
if ($toplevel_item_id) {
@ -138,10 +138,10 @@ function item_post(App $a) {
Logger::info('mod_item: item_post parent=' . $toplevel_item_id);
}
$post_id = intval(defaults($_REQUEST, 'post_id', 0));
$app = strip_tags(defaults($_REQUEST, 'source', ''));
$extid = strip_tags(defaults($_REQUEST, 'extid', ''));
$object = defaults($_REQUEST, 'object', '');
$post_id = intval($_REQUEST['post_id'] ?? 0);
$app = strip_tags($_REQUEST['source'] ?? '');
$extid = strip_tags($_REQUEST['extid'] ?? '');
$object = $_REQUEST['object'] ?? '';
// Don't use "defaults" here. It would turn 0 to 1
if (!isset($_REQUEST['wall'])) {
@ -194,20 +194,20 @@ function item_post(App $a) {
$categories = '';
$postopts = '';
$emailcc = '';
$body = defaults($_REQUEST, 'body', '');
$has_attachment = defaults($_REQUEST, 'has_attachment', 0);
$body = $_REQUEST['body'] ?? '';
$has_attachment = $_REQUEST['has_attachment'] ?? 0;
// If we have a speparate attachment, we need to add it to the body.
if (!empty($has_attachment)) {
$attachment_type = defaults($_REQUEST, 'attachment_type', '');
$attachment_title = defaults($_REQUEST, 'attachment_title', '');
$attachment_text = defaults($_REQUEST, 'attachment_text', '');
$attachment_type = $_REQUEST['attachment_type'] ?? '';
$attachment_title = $_REQUEST['attachment_title'] ?? '';
$attachment_text = $_REQUEST['attachment_text'] ?? '';
$attachment_url = hex2bin(defaults($_REQUEST, 'attachment_url', ''));
$attachment_img_src = hex2bin(defaults($_REQUEST, 'attachment_img_src', ''));
$attachment_url = hex2bin($_REQUEST['attachment_url'] ?? '');
$attachment_img_src = hex2bin($_REQUEST['attachment_img_src'] ?? '');
$attachment_img_width = defaults($_REQUEST, 'attachment_img_width', 0);
$attachment_img_height = defaults($_REQUEST, 'attachment_img_height', 0);
$attachment_img_width = $_REQUEST['attachment_img_width'] ?? 0;
$attachment_img_height = $_REQUEST['attachment_img_height'] ?? 0;
$attachment = [
'type' => $attachment_type,
'title' => $attachment_title,
@ -229,6 +229,9 @@ function item_post(App $a) {
$body .= $att_bbcode;
}
// Convert links with empty descriptions to links without an explicit description
$body = preg_replace('#\[url=([^\]]*?)\]\[/url\]#ism', '[url]$1[/url]', $body);
if (!empty($orig_post)) {
$str_group_allow = $orig_post['allow_gid'];
$str_contact_allow = $orig_post['allow_cid'];
@ -266,22 +269,22 @@ function item_post(App $a) {
$str_contact_deny = $user['deny_cid'];
} else {
// use the posted permissions
$str_group_allow = perms2str(defaults($_REQUEST, 'group_allow', ''));
$str_contact_allow = perms2str(defaults($_REQUEST, 'contact_allow', ''));
$str_group_deny = perms2str(defaults($_REQUEST, 'group_deny', ''));
$str_contact_deny = perms2str(defaults($_REQUEST, 'contact_deny', ''));
$str_group_allow = perms2str($_REQUEST['group_allow'] ?? '');
$str_contact_allow = perms2str($_REQUEST['contact_allow'] ?? '');
$str_group_deny = perms2str($_REQUEST['group_deny'] ?? '');
$str_contact_deny = perms2str($_REQUEST['contact_deny'] ?? '');
}
$title = Strings::escapeTags(trim(defaults($_REQUEST, 'title' , '')));
$location = Strings::escapeTags(trim(defaults($_REQUEST, 'location', '')));
$coord = Strings::escapeTags(trim(defaults($_REQUEST, 'coord' , '')));
$verb = Strings::escapeTags(trim(defaults($_REQUEST, 'verb' , '')));
$emailcc = Strings::escapeTags(trim(defaults($_REQUEST, 'emailcc' , '')));
$title = Strings::escapeTags(trim($_REQUEST['title'] ?? ''));
$location = Strings::escapeTags(trim($_REQUEST['location'] ?? ''));
$coord = Strings::escapeTags(trim($_REQUEST['coord'] ?? ''));
$verb = Strings::escapeTags(trim($_REQUEST['verb'] ?? ''));
$emailcc = Strings::escapeTags(trim($_REQUEST['emailcc'] ?? ''));
$body = Strings::escapeHtml(trim($body));
$network = Strings::escapeTags(trim(defaults($_REQUEST, 'network' , Protocol::DFRN)));
$network = Strings::escapeTags(trim(($_REQUEST['network'] ?? '') ?: Protocol::DFRN));
$guid = System::createUUID();
$postopts = defaults($_REQUEST, 'postopts', '');
$postopts = $_REQUEST['postopts'] ?? '';
$private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0);
@ -304,7 +307,7 @@ function item_post(App $a) {
$wall = $toplevel_item['wall'];
}
$pubmail_enabled = defaults($_REQUEST, 'pubmail_enable', false) && !$private;
$pubmail_enabled = ($_REQUEST['pubmail_enable'] ?? false) && !$private;
// if using the API, we won't see pubmail_enable - figure out if it should be set
if ($api_source && $profile_uid && $profile_uid == local_user() && !$private) {
@ -332,7 +335,7 @@ function item_post(App $a) {
// save old and new categories, so we can determine what needs to be deleted from pconfig
$categories_old = $categories;
$categories = FileTag::listToFile(trim(defaults($_REQUEST, 'category', '')), 'category');
$categories = FileTag::listToFile(trim($_REQUEST['category'] ?? ''), 'category');
$categories_new = $categories;
if (!empty($filedas) && is_array($filedas)) {
@ -1012,7 +1015,7 @@ function handle_tag(&$body, &$inform, &$str_tags, $profile_uid, $tag, $network =
$profile = $contact["url"];
$alias = $contact["alias"];
$newname = defaults($contact, "name", $contact["nick"]);
$newname = ($contact["name"] ?? '') ?: $contact["nick"];
}
//if there is an url for this persons profile

10
mod/match.php

@ -66,7 +66,7 @@ function match_content(App $a)
$msearch = json_decode($msearch_json);
$start = defaults($_GET, 'start', 0);
$start = $_GET['start'] ?? 0;
$entries = [];
$paginate = '';
@ -92,11 +92,11 @@ function match_content(App $a)
$entry = [
'url' => Contact::magicLink($profile->url),
'itemurl' => defaults($contact_details, 'addr', $profile->url),
'itemurl' => $contact_details['addr'] ?? $profile->url,
'name' => $profile->name,
'details' => defaults($contact_details, 'location', ''),
'tags' => defaults($contact_details, 'keywords', ''),
'about' => defaults($contact_details, 'about', ''),
'details' => $contact_details['location'] ?? '',
'tags' => $contact_details['keywords'] ?? '',
'about' => $contact_details['about'] ?? '',
'account_type' => Contact::getAccountType($contact_details),
'thumb' => ProxyUtils::proxifyUrl($profile->photo, false, ProxyUtils::SIZE_THUMB),
'conntxt' => L10n::t('Connect'),

6
mod/message.php

@ -249,8 +249,8 @@ function message_content(App $a)
'$prefill' => $prefill,
'$preid' => $preid,
'$subject' => L10n::t('Subject:'),
'$subjtxt' => defaults($_REQUEST, 'subject', ''),
'$text' => defaults($_REQUEST, 'body', ''),
'$subjtxt' => $_REQUEST['subject'] ?? '',
'$text' => $_REQUEST['body'] ?? '',
'$readonly' => '',
'$yourmessage'=> L10n::t('Your message:'),
'$select' => $select,
@ -530,7 +530,7 @@ function render_messages(array $msg, $t)
'$id' => $rr['id'],
'$from_name' => $participants,
'$from_url' => Contact::magicLink($rr['url']),
'$from_addr' => defaults($contact, 'addr', ''),
'$from_addr' => $contact['addr'] ?? '',
'$sparkle' => ' sparkle',
'$from_photo' => ProxyUtils::proxifyUrl($from_photo, false, ProxyUtils::SIZE_THUMB),
'$subject' => $rr['title'],

6
mod/msearch.php

@ -6,9 +6,9 @@ use Friendica\Database\DBA;
function msearch_post(App $a)
{
$search = defaults($_POST, 's', '');
$perpage = intval(defaults($_POST, 'n', 80));
$page = intval(defaults($_POST, 'p', 1));
$search = $_POST['s'] ?? '';
$perpage = intval(($_POST['n'] ?? 0) ?: 80);
$page = intval(($_POST['p'] ?? 0) ?: 1);
$startrec = ($page - 1) * $perpage;
$total = 0;

24
mod/network.php

@ -66,7 +66,7 @@ function network_init(App $a)
// fetch last used network view and redirect if needed
if (!$is_a_date_query) {
$sel_nets = defaults($_GET, 'nets', '');
$sel_nets = $_GET['nets'] ?? '';
$sel_tabs = network_query_get_sel_tab($a);
$sel_groups = network_query_get_sel_group($a);
$last_sel_tabs = PConfig::get(local_user(), 'network.view', 'tab.selected');
@ -138,9 +138,9 @@ function network_init(App $a)
$a->page['aside'] .= Group::sidebarWidget('network/0', 'network', 'standard', $group_id);
$a->page['aside'] .= ForumManager::widget(local_user(), $cid);
$a->page['aside'] .= Widget::postedByYear('network', local_user(), false);
$a->page['aside'] .= Widget::networks('network', defaults($_GET, 'nets', '') );
$a->page['aside'] .= Widget::networks('network', $_GET['nets'] ?? '');
$a->page['aside'] .= Widget\SavedSearches::getHTML($a->query_string);
$a->page['aside'] .= Widget::fileAs('network', defaults($_GET, 'file', '') );
$a->page['aside'] .= Widget::fileAs('network', $_GET['file'] ?? '');
}
/**
@ -356,7 +356,7 @@ function networkFlatView(App $a, $update = 0)
$o = '';
$file = defaults($_GET, 'file', '');
$file = $_GET['file'] ?? '';
if (!$update && !$rawmode) {
$tabs = network_tabs($a);
@ -479,12 +479,12 @@ function networkThreadedView(App $a, $update, $parent)
$o = '';
$cid = intval(defaults($_GET, 'cid' , 0));
$star = intval(defaults($_GET, 'star' , 0));
$bmark = intval(defaults($_GET, 'bmark', 0));
$conv = intval(defaults($_GET, 'conv' , 0));
$order = Strings::escapeTags(defaults($_GET, 'order', 'comment'));
$nets = defaults($_GET, 'nets' , '');
$cid = intval($_GET['cid'] ?? 0);
$star = intval($_GET['star'] ?? 0);
$bmark = intval($_GET['bmark'] ?? 0);
$conv = intval($_GET['conv'] ?? 0);
$order = Strings::escapeTags(($_GET['order'] ?? '') ?: 'comment');
$nets = $_GET['nets'] ?? '';
$allowedCids = [];
if ($cid) {
@ -623,7 +623,7 @@ function networkThreadedView(App $a, $update, $parent)
$entries[0] = [
'id' => 'network',
'name' => $contact['name'],
'itemurl' => defaults($contact, 'addr', $contact['nurl']),
'itemurl' => ($contact['addr'] ?? '') ?: $contact['nurl'],
'thumb' => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB),
'details' => $contact['location'],
];
@ -1013,7 +1013,7 @@ function network_infinite_scroll_head(App $a, &$htmlhead)
global $pager;
if (PConfig::get(local_user(), 'system', 'infinite_scroll')
&& defaults($_GET, 'mode', '') != 'minimal'
&& ($_GET['mode'] ?? '') != 'minimal'
) {
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
$htmlhead .= Renderer::replaceMacros($tpl, [

2
mod/noscrape.php

@ -49,7 +49,7 @@ function noscrape_init(App $a)
exit;
}
$keywords = defaults($a->profile, 'pub_keywords', '');
$keywords = $a->profile['pub_keywords'] ?? '';
$keywords = str_replace(['#',',',' ',',,'], ['',' ',',',','], $keywords);
$keywords = explode(',', $keywords);

6
mod/notifications.php

@ -78,8 +78,8 @@ function notifications_content(App $a)
return Login::form();
}
$page = defaults($_REQUEST, 'page', 1);
$show = defaults($_REQUEST, 'show', 0);
$page = ($_REQUEST['page'] ?? 0) ?: 1;
$show = $_REQUEST['show'] ?? 0;
Nav::setSelected('notifications');
@ -158,7 +158,7 @@ function notifications_content(App $a)
];
// Process the data for template creation
if (defaults($notifs, 'ident', '') === 'introductions') {
if (($notifs['ident'] ?? '') == 'introductions') {
$sugg = Renderer::getMarkupTemplate('suggestions.tpl');
$tpl = Renderer::getMarkupTemplate('intros.tpl');

18
mod/photos.php

@ -63,9 +63,9 @@ function photos_init(App $a) {
$vcard_widget = Renderer::replaceMacros($tpl, [
'$name' => $profile['name'],
'$photo' => $profile['photo'],
'$addr' => defaults($profile, 'addr', ''),
'$addr' => $profile['addr'] ?? '',
'$account_type' => $account_type,
'$pdesc' => defaults($profile, 'pdesc', ''),
'$pdesc' => $profile['pdesc'] ?? '',
]);
$albums = Photo::getAlbums($a->data['user']['uid']);
@ -630,10 +630,10 @@ function photos_post(App $a)
$visible = 0;
}
$group_allow = defaults($_REQUEST, 'group_allow' , []);
$contact_allow = defaults($_REQUEST, 'contact_allow', []);
$group_deny = defaults($_REQUEST, 'group_deny' , []);
$contact_deny = defaults($_REQUEST, 'contact_deny' , []);
$group_allow = $_REQUEST['group_allow'] ?? [];
$contact_allow = $_REQUEST['contact_allow'] ?? [];
$group_deny = $_REQUEST['group_deny'] ?? [];
$contact_deny = $_REQUEST['contact_deny'] ?? [];
$str_group_allow = perms2str(is_array($group_allow) ? $group_allow : explode(',', $group_allow));
$str_contact_allow = perms2str(is_array($contact_allow) ? $contact_allow : explode(',', $contact_allow));
@ -666,7 +666,7 @@ function photos_post(App $a)
notice(L10n::t('Image exceeds size limit of %s', ini_get('upload_max_filesize')) . EOL);
break;
case UPLOAD_ERR_FORM_SIZE:
notice(L10n::t('Image exceeds size limit of %s', Strings::formatBytes(defaults($_REQUEST, 'MAX_FILE_SIZE', 0))) . EOL);
notice(L10n::t('Image exceeds size limit of %s', Strings::formatBytes($_REQUEST['MAX_FILE_SIZE'] ?? 0)) . EOL);
break;
case UPLOAD_ERR_PARTIAL:
notice(L10n::t('Image upload didn\'t complete, please try again') . EOL);
@ -1006,7 +1006,7 @@ function photos_content(App $a)
$pager = new Pager($a->query_string, 20);
/// @TODO I have seen this many times, maybe generalize it script-wide and encapsulate it?
$order_field = defaults($_GET, 'order', '');
$order_field = $_GET['order'] ?? '';
if ($order_field === 'posted') {
$order = 'ASC';
} else {
@ -1158,7 +1158,7 @@ function photos_content(App $a)
* By now we hide it if someone wants to.
*/
if ($cmd === 'view' && !Config::get('system', 'no_count', false)) {
$order_field = defaults($_GET, 'order', '');
$order_field = $_GET['order'] ?? '';
if ($order_field === 'posted') {
$order = 'ASC';

2
mod/poco.php

@ -36,7 +36,7 @@ function poco_init(App $a) {
$system_mode = true;
}
$format = defaults($_GET, 'format', 'json');
$format = ($_GET['format'] ?? '') ?: 'json';
$justme = false;
$global = false;

8
mod/pubsub.php

@ -33,10 +33,10 @@ function pubsub_init(App $a)
$contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0 );
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$hub_mode = Strings::escapeTags(trim(defaults($_GET, 'hub_mode', '')));
$hub_topic = Strings::escapeTags(trim(defaults($_GET, 'hub_topic', '')));
$hub_challenge = Strings::escapeTags(trim(defaults($_GET, 'hub_challenge', '')));
$hub_verify = Strings::escapeTags(trim(defaults($_GET, 'hub_verify_token', '')));
$hub_mode = Strings::escapeTags(trim($_GET['hub_mode'] ?? ''));
$hub_topic = Strings::escapeTags(trim($_GET['hub_topic'] ?? ''));
$hub_challenge = Strings::escapeTags(trim($_GET['hub_challenge'] ?? ''));
$hub_verify = Strings::escapeTags(trim($_GET['hub_verify_token'] ?? ''));
Logger::log('Subscription from ' . $_SERVER['REMOTE_ADDR'] . ' Mode: ' . $hub_mode . ' Nick: ' . $nick);
Logger::log('Data: ' . print_r($_GET,true), Logger::DATA);

12
mod/redir.php

@ -13,7 +13,7 @@ use Friendica\Util\Strings;
function redir_init(App $a) {
$url = defaults($_GET, 'url', '');
$url = $_GET['url'] ?? '';
$quiet = !empty($_GET['quiet']) ? '&quiet=1' : '';
if ($a->argc > 1 && intval($a->argv[1])) {
@ -38,7 +38,7 @@ function redir_init(App $a) {
if (!Session::isAuthenticated() // Visitors (not logged in or not remotes) can't authenticate.
|| (!empty($a->contact['id']) && $a->contact['id'] == $cid)) // Local user is already authenticated.
{
$a->redirect(defaults($url, $contact_url));
$a->redirect($url ?: $contact_url);
}
if ($contact['uid'] == 0 && local_user()) {
@ -52,7 +52,7 @@ function redir_init(App $a) {
if (!empty($a->contact['id']) && $a->contact['id'] == $cid) {
// Local user is already authenticated.
$target_url = defaults($url, $contact_url);
$target_url = $url ?: $contact_url;
Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, Logger::DEBUG);
$a->redirect($target_url);
}
@ -68,7 +68,7 @@ function redir_init(App $a) {
// contact.
if (($host == $remotehost) && (Session::getRemoteContactID(Session::get('visitor_visiting')) == Session::get('visitor_id'))) {
// Remote user is already authenticated.
$target_url = defaults($url, $contact_url);
$target_url = $url ?: $contact_url;
Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, Logger::DEBUG);
$a->redirect($target_url);
}
@ -101,7 +101,7 @@ function redir_init(App $a) {
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest . $quiet);
}
$url = defaults($url, $contact_url);
$url = $url ?: $contact_url;
}
// If we don't have a connected contact, redirect with
@ -142,7 +142,7 @@ function redir_magic($a, $cid, $url)
}
} else {
$contact_url = $contact['url'];
$target_url = defaults($url, $contact_url);
$target_url = $url ?: $contact_url;
}
$basepath = Contact::getBasepath($contact_url);

2
mod/regmod.php

@ -44,7 +44,7 @@ function user_allow($hash)
$user,
Config::get('config', 'sitename'),
$a->getBaseUrl(),
defaults($register, 'password', 'Sent in a previous email')
($register['password'] ?? '') ?: 'Sent in a previous email'
);
L10n::popLang();

45
mod/settings.php

@ -35,7 +35,7 @@ function get_theme_config_file($theme)
$theme = Strings::sanitizeFilePathItem($theme);
$a = \get_app();
$base_theme = defaults($a->theme_info, 'extends');
$base_theme = $a->theme_info['extends'] ?? '';
if (file_exists("view/theme/$theme/config.php")) {
return "view/theme/$theme/config.php";
@ -180,11 +180,11 @@ function settings_post(App $a)
if (($a->argc > 2) && ($a->argv[1] === 'oauth') && ($a->argv[2] === 'edit'||($a->argv[2] === 'add')) && !empty($_POST['submit'])) {
BaseModule::checkFormSecurityTokenRedirectOnError('/settings/oauth', 'settings_oauth');
$name = defaults($_POST, 'name' , '');
$key = defaults($_POST, 'key' , '');
$secret = defaults($_POST, 'secret' , '');
$redirect = defaults($_POST, 'redirect', '');
$icon = defaults($_POST, 'icon' , '');
$name = $_POST['name'] ?? '';
$key = $_POST['key'] ?? '';
$secret = $_POST['secret'] ?? '';
$redirect = $_POST['redirect'] ?? '';
$icon = $_POST['icon'] ?? '';
if ($name == "" || $key == "" || $secret == "") {
notice(L10n::t("Missing some important data!"));
@ -241,24 +241,21 @@ function settings_post(App $a)
PConfig::set(local_user(), 'ostatus', 'default_group', $_POST['group-selection']);
PConfig::set(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']);
} elseif (!empty($_POST['imap-submit'])) {
$mail_server = defaults($_POST, 'mail_server', '');
$mail_port = defaults($_POST, 'mail_port', '');
$mail_ssl = (!empty($_POST['mail_ssl']) ? strtolower(trim($_POST['mail_ssl'])) : '');
$mail_user = defaults($_POST, 'mail_user', '');
$mail_pass = (!empty($_POST['mail_pass']) ? trim($_POST['mail_pass']) : '');
$mail_action = (!empty($_POST['mail_action']) ? trim($_POST['mail_action']) : '');
$mail_movetofolder = (!empty($_POST['mail_movetofolder']) ? trim($_POST['mail_movetofolder']) : '');
$mail_replyto = defaults($_POST, 'mail_replyto', '');
$mail_pubmail = defaults($_POST, 'mail_pubmail', '');
$mail_disabled = ((function_exists('imap_open') && (!Config::get('system', 'imap_disabled'))) ? 0 : 1);
if (Config::get('system', 'dfrn_only')) {
$mail_disabled = 1;
}
if (!$mail_disabled) {
$mail_server = $_POST['mail_server'] ?? '';
$mail_port = $_POST['mail_port'] ?? '';
$mail_ssl = strtolower(trim($_POST['mail_ssl'] ?? ''));
$mail_user = $_POST['mail_user'] ?? '';
$mail_pass = trim($_POST['mail_pass'] ?? '');
$mail_action = trim($_POST['mail_action'] ?? '');
$mail_movetofolder = trim($_POST['mail_movetofolder'] ?? '');
$mail_replyto = $_POST['mail_replyto'] ?? '';
$mail_pubmail = $_POST['mail_pubmail'] ?? '';
if (
!Config::get('system', 'dfrn_only')
&& function_exists('imap_open')
&& !Config::get('system', 'imap_disabled')
) {