// 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,
$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'],
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(
* 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;
$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);
}
/*
*/
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);
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)) {
$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');
{
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");
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)) {
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;
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;
$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']);
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())
);
$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))) {
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'];
$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;
// 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 = [
$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())
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) {
}
// 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);
}
$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) {
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'],
}
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";
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'))) {
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 = [];
$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
}
// 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, '?')) {
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
}
// 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;
$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) {
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'])) {
$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,
$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);
$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) {
// 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)) {
$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
$msearch = json_decode($msearch_json);
- $start = defaults($_GET, 'start', 0);
+ $start = $_GET['start'] ?? 0;
$entries = [];
$paginate = '';
$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'),
'$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,
'$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'],
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;
// 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');
$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'] ?? '');
}
/**
$o = '';
- $file = defaults($_GET, 'file', '');
+ $file = $_GET['file'] ?? '';
if (!$update && !$rawmode) {
$tabs = network_tabs($a);
$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) {
$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'],
];
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, [
exit;
}
- $keywords = defaults($a->profile, 'pub_keywords', '');
+ $keywords = $a->profile['pub_keywords'] ?? '';
$keywords = str_replace(['#',',',' ',',,'], ['',' ',',',','], $keywords);
$keywords = explode(',', $keywords);
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');
];
// 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');
$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']);
$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));
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);
$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 {
* 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';
$system_mode = true;
}
- $format = defaults($_GET, 'format', 'json');
+ $format = ($_GET['format'] ?? '') ?: 'json';
$justme = false;
$global = false;
$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);
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])) {
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()) {
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);
}
// 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);
}
. '&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
}
} else {
$contact_url = $contact['url'];
- $target_url = defaults($url, $contact_url);
+ $target_url = $url ?: $contact_url;
}
$basepath = Contact::getBasepath($contact_url);
$user,
Config::get('config', 'sitename'),
$a->getBaseUrl(),
- defaults($register, 'password', 'Sent in a previous email')
+ ($register['password'] ?? '') ?: 'Sent in a previous email'
);
L10n::popLang();
$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";
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!"));
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')
+ ) {
$failed = false;
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval(local_user())
}
$tags = [];
- foreach (defaults($_POST, 'tag', []) as $tag) {
+ foreach ($_POST['tag'] ?? [] as $tag) {
$tags[] = hex2bin(Strings::escapeTags(trim($tag)));
}
- $item_id = defaults($_POST,'item', 0);
+ $item_id = $_POST['item'] ?? 0;
update_tags($item_id, $tags);
info(L10n::t('Tag(s) removed') . EOL);
}
$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` = ?)",
$uid, Contact::SHARING, Contact::FRIEND, Strings::normaliseLink($url),
$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'] ?? '',
]);
// If not there, create 'aside' empty
'$subject' => L10n::t('Subject:'),
'$recipname' => $user['username'],
'$nickname' => $user['nickname'],
- '$subjtxt' => defaults($_REQUEST, 'subject', ''),
- '$text' => defaults($_REQUEST, 'body', ''),
+ '$subjtxt' => $_REQUEST['subject'] ?? '',
+ '$text' => $_REQUEST['body'] ?? '',
'$readonly' => '',
'$yourmessage'=> L10n::t('Your message:'),
'$parent' => '',