* You also find a graphic which describes the confirmation process at
* https://github.com/friendica/friendica/blob/master/spec/dfrn2_contact_request.png
*/
* You also find a graphic which describes the confirmation process at
* https://github.com/friendica/friendica/blob/master/spec/dfrn2_contact_request.png
*/
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
+use Friendica\Model\Contact;
+use Friendica\Model\Group;
+use Friendica\Model\Profile;
+use Friendica\Model\User;
+use Friendica\Module\Login;
* Scenario 2: We've introduced ourself to another cell, then have been returned to our own cell
* to confirm the request, and then we've clicked submit (perhaps after logging in).
* That brings us here:
* Scenario 2: We've introduced ourself to another cell, then have been returned to our own cell
* to confirm the request, and then we've clicked submit (perhaps after logging in).
* That brings us here:
-
- if((x($_POST,'localconfirm')) && ($_POST['localconfirm'] == 1)) {
-
- /*
- * Ensure this is a valid request
- */
-
- if(local_user() && ($a->user['nickname'] == $a->argv[1]) && (x($_POST,'dfrn_url'))) {
-
-
- $dfrn_url = notags(trim($_POST['dfrn_url']));
- $aes_allow = (((x($_POST,'aes_allow')) && ($_POST['aes_allow'] == 1)) ? 1 : 0);
- $confirm_key = ((x($_POST,'confirm_key')) ? $_POST['confirm_key'] : "");
- $hidden = ((x($_POST,'hidden-contact')) ? intval($_POST['hidden-contact']) : 0);
+ if ((x($_POST, 'localconfirm')) && ($_POST['localconfirm'] == 1)) {
+ // Ensure this is a valid request
+ if (local_user() && ($a->user['nickname'] == $a->argv[1]) && (x($_POST, 'dfrn_url'))) {
+ $dfrn_url = notags(trim($_POST['dfrn_url']));
+ $aes_allow = (((x($_POST, 'aes_allow')) && ($_POST['aes_allow'] == 1)) ? 1 : 0);
+ $confirm_key = ((x($_POST, 'confirm_key')) ? $_POST['confirm_key'] : "");
+ $hidden = ((x($_POST, 'hidden-contact')) ? intval($_POST['hidden-contact']) : 0);
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND NOT `self` LIMIT 1",
intval(local_user()),
dbesc(normalise_link($dfrn_url))
);
if (DBM::is_result($r)) {
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND NOT `self` LIMIT 1",
intval(local_user()),
dbesc(normalise_link($dfrn_url))
);
if (DBM::is_result($r)) {
- if(strlen($r[0]['dfrn-id'])) {
-
- /*
- * We don't need to be here. It has already happened.
- */
-
- notice( t("This introduction has already been accepted.") . EOL );
+ if (strlen($r[0]['dfrn-id'])) {
+ // We don't need to be here. It has already happened.
+ notice(L10n::t("This introduction has already been accepted.") . EOL);
$r = q("UPDATE `contact` SET `ret-aes` = %d, hidden = %d WHERE `id` = %d",
intval($aes_allow),
intval($hidden),
intval($contact_record['id'])
);
$r = q("UPDATE `contact` SET `ret-aes` = %d, hidden = %d WHERE `id` = %d",
intval($aes_allow),
intval($hidden),
intval($contact_record['id'])
);
- }
- else {
-
- /*
- * Scrape the other site's profile page to pick up the dfrn links, key, fn, and photo
- */
-
+ } else {
+ // Scrape the other site's profile page to pick up the dfrn links, key, fn, and photo
- }
- else {
- if (! x($parms,'fn')) {
- notice( t('Warning: profile location has no identifiable owner name.') . EOL );
+ } else {
+ if (!x($parms, 'fn')) {
+ notice(L10n::t('Warning: profile location has no identifiable owner name.') . EOL);
- if (! x($parms,'photo')) {
- notice( t('Warning: profile location has no profile photo.') . EOL );
+ if (!x($parms, 'photo')) {
+ notice(L10n::t('Warning: profile location has no profile photo.') . EOL);
- notice( sprintf( tt("%d required parameter was not found at the given location",
- "%d required parameters were not found at the given location",
- $invalid), $invalid) . EOL );
+ notice(L10n::tt("%d required parameter was not found at the given location", "%d required parameters were not found at the given location", $invalid) . EOL);
$r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `nurl`, `addr`, `name`, `nick`, `photo`, `site-pubkey`,
`request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`, `hidden`, `blocked`, `pending`)
VALUES ( %d, '%s', '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d)",
intval(local_user()),
$r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `nurl`, `addr`, `name`, `nick`, `photo`, `site-pubkey`,
`request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`, `hidden`, `blocked`, `pending`)
VALUES ( %d, '%s', '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d)",
intval(local_user()),
- $def_gid = get_default_group(local_user(), $r[0]["network"]);
- if(intval($def_gid))
- group_add_member(local_user(), '', $r[0]['id'], $def_gid);
+ Group::addMember(User::getDefaultGroup(local_user(), $r[0]["network"]), $r[0]['id']);
Contact::updateAvatar($photo, local_user(), $r[0]["id"], true);
Contact::updateAvatar($photo, local_user(), $r[0]["id"], true);
if (is_array($contact_record)) {
$dfrn_request = $contact_record['request'];
}
if (strlen($dfrn_request) && strlen($confirm_key)) {
if (is_array($contact_record)) {
$dfrn_request = $contact_record['request'];
}
if (strlen($dfrn_request) && strlen($confirm_key)) {
-
- if( x($_POST,'dfrn_url')) {
-
- /*
- * Block friend request spam
- */
-
- if($maxreq) {
+ if (x($_POST, 'dfrn_url')) {
+ // Block friend request spam
+ if ($maxreq) {
- notice( sprintf( t('%s has received too many connection requests today.'), $a->profile['name']) . EOL);
- notice( t('Spam protection measures have been invoked.') . EOL);
- notice( t('Friends are advised to please try again in 24 hours.') . EOL);
+ notice(L10n::t('%s has received too many connection requests today.', $a->profile['name']) . EOL);
+ notice(L10n::t('Spam protection measures have been invoked.') . EOL);
+ notice(L10n::t('Friends are advised to please try again in 24 hours.') . EOL);
$r = q("SELECT `intro`.*, `intro`.`id` AS `iid`, `contact`.`id` AS `cid`, `contact`.`rel`
FROM `intro` LEFT JOIN `contact` on `intro`.`contact-id` = `contact`.`id`
WHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0
$r = q("SELECT `intro`.*, `intro`.`id` AS `iid`, `contact`.`id` AS `cid`, `contact`.`rel`
FROM `intro` LEFT JOIN `contact` on `intro`.`contact-id` = `contact`.`id`
WHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0
- $url = Probe::webfingerDfrn($url,$hcard);
-
- if (substr($url,0,5) === 'stat:') {
+ $url = Probe::webfingerDfrn($url, $hcard);
// Every time we detect the remote subscription we define this as OStatus.
// We do this even if it is not OStatus.
// we only need to pass this through another section of the code.
// Every time we detect the remote subscription we define this as OStatus.
// We do this even if it is not OStatus.
// we only need to pass this through another section of the code.
$ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1",
intval($uid),
dbesc($url)
);
if (DBM::is_result($ret)) {
$ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1",
intval($uid),
dbesc($url)
);
if (DBM::is_result($ret)) {
- }
- elseif($ret[0]['rel'] == CONTACT_IS_FRIEND) {
- notice( sprintf( t('Apparently you are already friends with %s.'), $a->profile['name']) . EOL);
+ } elseif ($ret[0]['rel'] == CONTACT_IS_FRIEND) {
+ notice(L10n::t('Apparently you are already friends with %s.', $a->profile['name']) . EOL);
// There is a contact record but no issued-id, so this
// is a reciprocal introduction from a known contact
$r = q("UPDATE `contact` SET `issued-id` = '%s' WHERE `id` = %d",
dbesc($issued_id),
intval($contact_record['id'])
);
// There is a contact record but no issued-id, so this
// is a reciprocal introduction from a known contact
$r = q("UPDATE `contact` SET `issued-id` = '%s' WHERE `id` = %d",
dbesc($issued_id),
intval($contact_record['id'])
);
- }
- else {
- if (! x($parms,'fn')) {
- notice( t('Warning: profile location has no identifiable owner name.') . EOL );
+ } else {
+ if (!x($parms, 'fn')) {
+ notice(L10n::t('Warning: profile location has no identifiable owner name.') . EOL);
- if (! x($parms,'photo')) {
- notice( t('Warning: profile location has no profile photo.') . EOL );
+ if (!x($parms, 'photo')) {
+ notice(L10n::t('Warning: profile location has no profile photo.') . EOL);
- notice( sprintf( tt("%d required parameter was not found at the given location",
- "%d required parameters were not found at the given location",
- $invalid), $invalid) . EOL );
+ notice(L10n::tt("%d required parameter was not found at the given location", "%d required parameters were not found at the given location", $invalid) . EOL);
`request`, `confirm`, `notify`, `poll`, `poco`, `network`, `blocked`, `pending` )
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )",
intval($uid),
`request`, `confirm`, `notify`, `poll`, `poco`, `network`, `blocked`, `pending` )
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )",
intval($uid),
Contact::updateAvatar($photo, $uid, $contact_record["id"], true);
}
}
Contact::updateAvatar($photo, $uid, $contact_record["id"], true);
}
}
((x($_POST,'knowyou') && ($_POST['knowyou'] == 1)) ? 1 : 0),
dbesc(notags(trim($_POST['dfrn-request-message']))),
dbesc($hash),
((x($_POST,'knowyou') && ($_POST['knowyou'] == 1)) ? 1 : 0),
dbesc(notags(trim($_POST['dfrn-request-message']))),
dbesc($hash),
$dfrn_url = bin2hex(System::baseUrl() . '/profile/' . $nickname);
$aes_allow = ((function_exists('openssl_encrypt')) ? 1 : 0);
goaway($parms['dfrn-request'] . "?dfrn_url=$dfrn_url"
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION
$dfrn_url = bin2hex(System::baseUrl() . '/profile/' . $nickname);
$aes_allow = ((function_exists('openssl_encrypt')) ? 1 : 0);
goaway($parms['dfrn-request'] . "?dfrn_url=$dfrn_url"
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION
. (($aes_allow) ? "&aes_allow=1" : "")
);
// NOTREACHED
// END $network === NETWORK_DFRN
} elseif (($network != NETWORK_PHANTOM) && ($url != "")) {
. (($aes_allow) ? "&aes_allow=1" : "")
);
// NOTREACHED
// END $network === NETWORK_DFRN
} elseif (($network != NETWORK_PHANTOM) && ($url != "")) {
// Diaspora needs the uri in the format user@domain.tld
// Diaspora will support the remote subscription in a future version
if ($network == NETWORK_DIASPORA) {
// Diaspora needs the uri in the format user@domain.tld
// Diaspora will support the remote subscription in a future version
if ($network == NETWORK_DIASPORA) {
// "Homecoming". Make sure we're logged in to this site as the correct user. Then offer a confirm button
// to send us to the post section to record the introduction.
// "Homecoming". Make sure we're logged in to this site as the correct user. Then offer a confirm button
// to send us to the post section to record the introduction.
-
- if (x($_GET,'dfrn_url')) {
-
- if (! local_user()) {
- info( t("Please login to confirm introduction.") . EOL );
+ if (x($_GET, 'dfrn_url')) {
+ if (!local_user()) {
+ info(L10n::t("Please login to confirm introduction.") . EOL);
}
// Edge case, but can easily happen in the wild. This person is authenticated,
// but not as the person who needs to deal with this request.
}
// Edge case, but can easily happen in the wild. This person is authenticated,
// but not as the person who needs to deal with this request.
- $aes_allow = (((x($_GET,'aes_allow')) && ($_GET['aes_allow'] == 1)) ? 1 : 0);
- $confirm_key = (x($_GET,'confirm_key') ? $_GET['confirm_key'] : "");
+ $aes_allow = x($_GET, 'aes_allow') && $_GET['aes_allow'] == 1 ? 1 : 0;
+ $confirm_key = x($_GET, 'confirm_key') ? $_GET['confirm_key'] : "";
// Checking fastlane for validity
if (x($_SESSION, "fastlane") && (normalise_link($_SESSION["fastlane"]) == normalise_link($dfrn_url))) {
// Checking fastlane for validity
if (x($_SESSION, "fastlane") && (normalise_link($_SESSION["fastlane"]) == normalise_link($dfrn_url))) {
$_POST["confirm_key"] = $confirm_key;
$_POST["localconfirm"] = 1;
$_POST["hidden-contact"] = 0;
$_POST["confirm_key"] = $confirm_key;
$_POST["localconfirm"] = 1;
$_POST["hidden-contact"] = 0;
'$dfrn_url' => $dfrn_url,
'$aes_allow' => (($aes_allow) ? '<input type="hidden" name="aes_allow" value="1" />' : "" ),
'$dfrn_url' => $dfrn_url,
'$aes_allow' => (($aes_allow) ? '<input type="hidden" name="aes_allow" value="1" />' : "" ),
- '$welcome' => sprintf( t('Welcome home %s.'), $a->user['username']),
- '$please' => sprintf( t('Please confirm your introduction/connection request to %s.'), $dfrn_url),
- '$submit' => t('Confirm'),
+ '$welcome' => L10n::t('Welcome home %s.', $a->user['username']),
+ '$please' => L10n::t('Please confirm your introduction/connection request to %s.', $dfrn_url),
+ '$submit' => L10n::t('Confirm'),
'$uid' => $_SESSION['uid'],
'$nickname' => $a->user['nickname'],
'dfrn_rawurl' => $_GET['dfrn_url']
'$uid' => $_SESSION['uid'],
'$nickname' => $a->user['nickname'],
'dfrn_rawurl' => $_GET['dfrn_url']
// we are the requestee and it is now safe to send our user their introduction,
// We could just unblock it, but first we have to jump through a few hoops to
// send an email, or even to find out if we need to send an email.
// we are the requestee and it is now safe to send our user their introduction,
// We could just unblock it, but first we have to jump through a few hoops to
// send an email, or even to find out if we need to send an email.
$intro = q("SELECT * FROM `intro` WHERE `hash` = '%s' LIMIT 1",
dbesc($_GET['confirm_key'])
);
if (DBM::is_result($intro)) {
$intro = q("SELECT * FROM `intro` WHERE `hash` = '%s' LIMIT 1",
dbesc($_GET['confirm_key'])
);
if (DBM::is_result($intro)) {
$r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
WHERE `contact`.`id` = %d LIMIT 1",
intval($intro[0]['contact-id'])
$r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
WHERE `contact`.`id` = %d LIMIT 1",
intval($intro[0]['contact-id'])
'type' => NOTIFY_INTRO,
'notify_flags' => $r[0]['notify-flags'],
'language' => $r[0]['language'],
'type' => NOTIFY_INTRO,
'notify_flags' => $r[0]['notify-flags'],
'language' => $r[0]['language'],
'to_email' => $r[0]['email'],
'uid' => $r[0]['uid'],
'link' => System::baseUrl() . '/notifications/intros',
'to_email' => $r[0]['email'],
'uid' => $r[0]['uid'],
'link' => System::baseUrl() . '/notifications/intros',
'source_link' => $r[0]['url'],
'source_photo' => $r[0]['photo'],
'verb' => ACTIVITY_REQ_FRIEND,
'otype' => 'intro'
'source_link' => $r[0]['url'],
'source_photo' => $r[0]['photo'],
'verb' => ACTIVITY_REQ_FRIEND,
'otype' => 'intro'
'uid' => $r[0]['uid'],
'node' => $r[0]['nickname'],
'dfrn_id' => $r[0]['issued-id'],
'intro_id' => $intro[0]['id'],
'duplex' => (($r[0]['page-flags'] == PAGE_FREELOVE) ? 1 : 0),
'uid' => $r[0]['uid'],
'node' => $r[0]['nickname'],
'dfrn_id' => $r[0]['issued-id'],
'intro_id' => $intro[0]['id'],
'duplex' => (($r[0]['page-flags'] == PAGE_FREELOVE) ? 1 : 0),
- 'activity' => intval(PConfig::get($r[0]['uid'],'system','post_newfriend'))
- );
- dfrn_confirm_post($a,$handsfree);
+ ];
+ dfrn_confirm_post($a, $handsfree);
// If we are auto_confirming, this record will have already been nuked
// in dfrn_confirm_post()
// If we are auto_confirming, this record will have already been nuked
// in dfrn_confirm_post()
- }
- else {
-
- /*
- * Normal web request. Display our user's introduction form.
- */
-
- if((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) {
- if(! Config::get('system','local_block')) {
- notice( t('Public access denied.') . EOL);
+ } else {
+ // Normal web request. Display our user's introduction form.
+ if ((Config::get('system', 'block_public')) && (!local_user()) && (!remote_user())) {
+ if (!Config::get('system', 'local_block')) {
+ notice(L10n::t('Public access denied.') . EOL);
$myaddr = $_GET['address'];
} elseif (local_user()) {
if (strlen($a->path)) {
$myaddr = System::baseUrl() . '/profile/' . $a->user['nickname'];
} else {
$myaddr = $_GET['address'];
} elseif (local_user()) {
if (strlen($a->path)) {
$myaddr = System::baseUrl() . '/profile/' . $a->user['nickname'];
} else {
if ($a->profile['page-flags'] == PAGE_NORMAL) {
$tpl = get_markup_template('dfrn_request.tpl');
} else {
$tpl = get_markup_template('auto_request.tpl');
}
if ($a->profile['page-flags'] == PAGE_NORMAL) {
$tpl = get_markup_template('dfrn_request.tpl');
} else {
$tpl = get_markup_template('auto_request.tpl');
}
- t('If you are not yet a member of the free social web, <a href="%s/siteinfo">follow this link to find a public Friendica site and join us today</a>.'),
- get_server()
+ L10n::t('If you are not yet a member of the free social web, <a href="%s">follow this link to find a public Friendica site and join us today</a>.'),
+ get_server() . '/servers'
- $o = replace_macros($tpl,array(
- '$header' => t('Friend/Connection Request'),
- '$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@gnusocial.de'),
- '$pls_answer' => t('Please answer the following:'),
- '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'),$a->profile['name']), false, '', array(t('No'), t('Yes'))),
- /*'$does_know' => sprintf( t('Does %s know you?'),$a->profile['name']),
- '$yes' => t('Yes'),
- '$no' => t('No'), */
- '$add_note' => t('Add a personal note:'),
+ $o = replace_macros($tpl, [
+ '$header' => L10n::t('Friend/Connection Request'),
+ '$desc' => L10n::t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@gnusocial.de'),
+ '$pls_answer' => L10n::t('Please answer the following:'),
+ '$does_know_you' => ['knowyou', L10n::t('Does %s know you?', $a->profile['name']), false, '', [L10n::t('No'), L10n::t('Yes')]],
+ '$add_note' => L10n::t('Add a personal note:'),
- '$friendica' => t('Friendica'),
- '$statusnet' => t('GNU Social (Pleroma, Mastodon)'),
- '$diaspora' => t('Diaspora (Socialhome, Hubzilla)'),
- '$diasnote' => sprintf (t(' - please do not use this form. Instead, enter %s into your Diaspora search bar.'),$target_addr),
- '$your_address' => t('Your Identity Address:'),
+ '$friendica' => L10n::t('Friendica'),
+ '$statusnet' => L10n::t("GNU Social \x28Pleroma, Mastodon\x29"),
+ '$diaspora' => L10n::t("Diaspora \x28Socialhome, Hubzilla\x29"),
+ '$diasnote' => L10n::t(' - please do not use this form. Instead, enter %s into your Diaspora search bar.', $target_addr),
+ '$your_address' => L10n::t('Your Identity Address:'),
- '$submit' => t('Submit Request'),
- '$cancel' => t('Cancel'),
+ '$submit' => L10n::t('Submit Request'),
+ '$cancel' => L10n::t('Cancel'),
'$nickname' => $a->argv[1],
'$name' => $a->profile['name'],
'$myaddr' => $myaddr
'$nickname' => $a->argv[1],
'$name' => $a->profile['name'],
'$myaddr' => $myaddr