Replace deprecated defaults() calls by a combination of ?? and ?: operators in mod/

This commit is contained in:
Hypolite Petovan 2019-10-15 09:01:17 -04:00
parent 8998926e5b
commit 2db6171641
32 changed files with 186 additions and 189 deletions

View File

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

View File

@ -118,7 +118,7 @@ function common_content(App $a)
$entry = [ $entry = [
'url' => Model\Contact::magicLink($common_friend['url']), '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'], 'name' => $contact_details['name'],
'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB), 'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
'img_hover' => $contact_details['name'], 'img_hover' => $contact_details['name'],

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 // 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")) { if ($theme && is_file("view/theme/$theme/config.php")) {
$a->setCurrentTheme($theme); $a->setCurrentTheme($theme);
} }

View File

@ -62,7 +62,7 @@ function follow_content(App $a)
$uid = local_user(); $uid = local_user();
// Issue 4815: Silently removing a prefixing @ // 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 // Issue 6874: Allow remote following from Peertube
if (strpos($url, 'acct:') === 0) { if (strpos($url, 'acct:') === 0) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -35,7 +35,7 @@ function get_theme_config_file($theme)
$theme = Strings::sanitizeFilePathItem($theme); $theme = Strings::sanitizeFilePathItem($theme);
$a = \get_app(); $a = \get_app();
$base_theme = defaults($a->theme_info, 'extends'); $base_theme = $a->theme_info['extends'] ?? '';
if (file_exists("view/theme/$theme/config.php")) { if (file_exists("view/theme/$theme/config.php")) {
return "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'])) { 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'); BaseModule::checkFormSecurityTokenRedirectOnError('/settings/oauth', 'settings_oauth');
$name = defaults($_POST, 'name' , ''); $name = $_POST['name'] ?? '';
$key = defaults($_POST, 'key' , ''); $key = $_POST['key'] ?? '';
$secret = defaults($_POST, 'secret' , ''); $secret = $_POST['secret'] ?? '';
$redirect = defaults($_POST, 'redirect', ''); $redirect = $_POST['redirect'] ?? '';
$icon = defaults($_POST, 'icon' , ''); $icon = $_POST['icon'] ?? '';
if ($name == "" || $key == "" || $secret == "") { if ($name == "" || $key == "" || $secret == "") {
notice(L10n::t("Missing some important data!")); 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', 'default_group', $_POST['group-selection']);
PConfig::set(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']); PConfig::set(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']);
} elseif (!empty($_POST['imap-submit'])) { } elseif (!empty($_POST['imap-submit'])) {
$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'] ?? '';
$mail_server = defaults($_POST, 'mail_server', ''); if (
$mail_port = defaults($_POST, 'mail_port', ''); !Config::get('system', 'dfrn_only')
$mail_ssl = (!empty($_POST['mail_ssl']) ? strtolower(trim($_POST['mail_ssl'])) : ''); && function_exists('imap_open')
$mail_user = defaults($_POST, 'mail_user', ''); && !Config::get('system', 'imap_disabled')
$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) {
$failed = false; $failed = false;
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval(local_user()) intval(local_user())

View File

@ -22,11 +22,11 @@ function tagrm_post(App $a)
} }
$tags = []; $tags = [];
foreach (defaults($_POST, 'tag', []) as $tag) { foreach ($_POST['tag'] ?? [] as $tag) {
$tags[] = hex2bin(Strings::escapeTags(trim($tag))); $tags[] = hex2bin(Strings::escapeTags(trim($tag)));
} }
$item_id = defaults($_POST,'item', 0); $item_id = $_POST['item'] ?? 0;
update_tags($item_id, $tags); update_tags($item_id, $tags);
info(L10n::t('Tag(s) removed') . EOL); info(L10n::t('Tag(s) removed') . EOL);

View File

@ -25,7 +25,7 @@ function unfollow_post(App $a)
} }
$uid = local_user(); $uid = local_user();
$url = Strings::escapeTags(trim(defaults($_REQUEST, 'url', ''))); $url = Strings::escapeTags(trim($_REQUEST['url'] ?? ''));
$condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)", $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)",
$uid, Contact::SHARING, Contact::FRIEND, Strings::normaliseLink($url), $uid, Contact::SHARING, Contact::FRIEND, Strings::normaliseLink($url),

View File

@ -51,9 +51,9 @@ function videos_init(App $a)
$vcard_widget = Renderer::replaceMacros($tpl, [ $vcard_widget = Renderer::replaceMacros($tpl, [
'$name' => $profile['name'], '$name' => $profile['name'],
'$photo' => $profile['photo'], '$photo' => $profile['photo'],
'$addr' => defaults($profile, 'addr', ''), '$addr' => $profile['addr'] ?? '',
'$account_type' => $account_type, '$account_type' => $account_type,
'$pdesc' => defaults($profile, 'pdesc', ''), '$pdesc' => $profile['pdesc'] ?? '',
]); ]);
// If not there, create 'aside' empty // If not there, create 'aside' empty

View File

@ -131,8 +131,8 @@ function wallmessage_content(App $a) {
'$subject' => L10n::t('Subject:'), '$subject' => L10n::t('Subject:'),
'$recipname' => $user['username'], '$recipname' => $user['username'],
'$nickname' => $user['nickname'], '$nickname' => $user['nickname'],
'$subjtxt' => defaults($_REQUEST, 'subject', ''), '$subjtxt' => $_REQUEST['subject'] ?? '',
'$text' => defaults($_REQUEST, 'body', ''), '$text' => $_REQUEST['body'] ?? '',
'$readonly' => '', '$readonly' => '',
'$yourmessage'=> L10n::t('Your message:'), '$yourmessage'=> L10n::t('Your message:'),
'$parent' => '', '$parent' => '',