+ $xml = simplexml_load_string($res);
+ $status = (int) $xml->status;
+ $message = unxmlify($xml->message); // human readable text of what may have gone wrong.
+ switch($status) {
+ case 0:
+ notice( t("Confirmation completed successfully.") . EOL);
+ if(strlen($message))
+ notice( t('Remote site reported: ') . $message . EOL);
+ break;
+ case 1:
+ // birthday paradox - generate new dfrn-id and fall through.
+ $new_dfrn_id = random_string();
+ $r = q("UPDATE contact SET `issued-id` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ dbesc($new_dfrn_id),
+ intval($contact_id),
+ intval($uid)
+ );
+
+ case 2:
+ notice( t("Temporary failure. Please wait and try again.") . EOL);
+ if(strlen($message))
+ notice( t('Remote site reported: ') . $message . EOL);
+ break;
+
+
+ case 3:
+ notice( t("Introduction failed or was revoked.") . EOL);
+ if(strlen($message))
+ notice( t('Remote site reported: ') . $message . EOL);
+ break;
+ }
+
+ if(($status == 0) && ($intro_id)) {
+
+ // Success. Delete the notification.
+
+ $r = q("DELETE FROM `intro` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ intval($intro_id),
+ intval($uid)
+ );
+
+ }
+
+ if($status != 0)
+ return;
+ }
+
+
+ /*
+ *
+ * We have now established a relationship with the other site.
+ * Let's make our own personal copy of their profile photo so we don't have
+ * to always load it from their site.
+ *
+ * We will also update the contact record with the nature and scope of the relationship.
+ *
+ */
+
+ require_once("Photo.php");
+
+ $photos = import_profile_photo($contact['photo'],$uid,$contact_id);
+
+ logger('dfrn_confirm: confirm - imported photos');
+
+ if($network === 'dfrn') {
+
+ $new_relation = REL_VIP;
+ if(($relation == REL_FAN) || ($duplex))