function poco_detect_server_type($body) {
$server = false;
- $doc = new \DOMDocument();
+ $doc = new DOMDocument();
@$doc->loadHTML($body);
- $xpath = new \DomXPath($doc);
+ $xpath = new DomXPath($doc);
$list = $xpath->query("//meta[@name]");
if (in_array($contact["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)))
$contact["url"] = clean_contact_url($contact["url"]);
- $r = q("SELECT `id`, `last_contact`, `last_failure`, `network` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 2",
+ dba::lock('gcontact');
+ $r = q("SELECT `id`, `last_contact`, `last_failure`, `network` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
dbesc(normalise_link($contact["url"])));
- if ($r) {
+ if (dbm::is_result($r)) {
$gcontact_id = $r[0]["id"];
// Update every 90 days
$doprobing = in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""));
}
}
+ dba::unlock();
if ($doprobing) {
logger("Last Contact: ". $last_contact_str." - Last Failure: ".$last_failure_str." - Checking: ".$contact["url"], LOGGER_DEBUG);
proc_run(PRIORITY_LOW, 'include/gprobe.php', bin2hex($contact["url"]));
}
- if ((dbm::is_result($r)) AND (count($r) > 1) AND ($gcontact_id > 0) AND ($contact["url"] != ""))
- q("DELETE FROM `gcontact` WHERE `nurl` = '%s' AND `id` != %d",
- dbesc(normalise_link($contact["url"])),
- intval($gcontact_id));
-
return $gcontact_id;
}