+ if(is_array($handsfree)) {
+ logger('dfrn_confirm: Confirm in handsfree mode');
+ $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 = ((x($_POST,'intro_id')) ? intval($_POST['intro_id']) : 0 );
+ $duplex = ((x($_POST,'duplex')) ? intval($_POST['duplex']) : 0 );
+ $cid = ((x($_POST,'contact_id')) ? intval($_POST['contact_id']) : 0 );
+ }
+
+ /**
+ *
+ * Ensure that dfrn_id has precedence when we go to find the contact record.
+ * We only want to search based on contact id if there is no dfrn_id,
+ * e.g. for OStatus network followers.
+ *
+ */
+
+ if(strlen($dfrn_id))
+ $cid = 0;
+
+ logger('dfrn_confirm: Confirming request for dfrn_id (issued) ' . $dfrn_id);
+ if($cid)
+ logger('dfrn_confirm: Confirming follower with contact_id: ' . $cid);
+
+
+ /**
+ *
+ * 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)