+ if(! x($_POST,'source_url')) {
+
+ $uid = ((is_array($handsfree)) ? $handsfree['uid'] : local_user());
+
+ if(! $uid) {
+ notice( t('Permission denied.') . EOL );
+ return;
+ }
+
+ $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
+ intval($uid)
+ );
+
+ if(! $user) {
+ notice( t('Profile not found.') . EOL );
+ return;
+ }
+
+
+ // These come from either the friend request notification form or $handsfree array.
+
+ if(is_array($handsfree)) {
+ $dfrn_id = $handsfree['dfrn_id'];
+ $intro_id = $handsfree['intro_id'];
+ $duplex = $handsfree['duplex'];
+ }
+ else {
+ $dfrn_id = ((x($_POST,'dfrn_id')) ? notags(trim($_POST['dfrn_id'])) : "");
+ $intro_id = intval($_POST['intro_id']);
+ $duplex = intval($_POST['duplex']);
+ $cid = intval($_POST['contact_id']);
+ }
+
+ // The other person will have been issued an ID when they first requested friendship.
+ // Locate their record. At this time, their record will have both pending and blocked set to 1.
+ // There won't be any dfrn_id if this is a network follower, so use the contact_id instead.
+
+ $r = q("SELECT * FROM `contact` WHERE ( ( `issued-id` != '' AND `issued-id` = '%s' ) OR ( `id` = %d AND `id` != 0 ) ) AND `uid` = %d LIMIT 1",
+ dbesc($dfrn_id),
+ intval($cid),
+ intval($uid)
+ );