+ if ($contactid == 0) {
+ q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
+ `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`,
+ `batch`, `request`, `confirm`, `poco`,
+ `writable`, `blocked`, `readonly`, `pending`)
+ VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', 1, 0, 0, 0)",
+ intval($uid),
+ dbesc(datetime_convert()),
+ dbesc($data["url"]),
+ dbesc(normalise_link($data["url"])),
+ dbesc($data["addr"]),
+ dbesc($data["alias"]),
+ dbesc($data["notify"]),
+ dbesc($data["poll"]),
+ dbesc($data["name"]),
+ dbesc($data["nick"]),
+ dbesc($data["photo"]),
+ dbesc($data["network"]),
+ dbesc($data["pubkey"]),
+ intval(CONTACT_IS_SHARING),
+ intval($data["priority"]),
+ dbesc($data["batch"]),
+ dbesc($data["request"]),
+ dbesc($data["confirm"]),
+ dbesc($data["poco"])
+ );
+
+ $contact = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d",
+ dbesc(normalise_link($data["url"])),
+ intval($uid));
+ if (!$contact)
+ return 0;
+
+ $contactid = $contact[0]["id"];
+ }