require_once("include/Scrape.php");
require_once("include/html2bbcode.php");
require_once("include/Contact.php");
-
+require_once("include/Photo.php");
/*
* poco_load
$noscrape = json_decode($noscraperet["body"], true);
- $contact = array("url" => $profile,
- "network" => $server[0]["network"],
- "generation" => $gcontacts[0]["generation"]);
+ if (is_array($noscrape)) {
+ $contact = array("url" => $profile,
+ "network" => $server[0]["network"],
+ "generation" => $gcontacts[0]["generation"]);
- $contact["name"] = $noscrape["fn"];
- $contact["community"] = $noscrape["comm"];
+ $contact["name"] = $noscrape["fn"];
+ $contact["community"] = $noscrape["comm"];
- if (isset($noscrape["tags"])) {
- $keywords = implode(" ", $noscrape["tags"]);
- if ($keywords != "")
- $contact["keywords"] = $keywords;
- }
+ if (isset($noscrape["tags"])) {
+ $keywords = implode(" ", $noscrape["tags"]);
+ if ($keywords != "")
+ $contact["keywords"] = $keywords;
+ }
+
+ $location = formatted_location($noscrape);
+ if ($location)
+ $contact["location"] = $location;
+
+ $contact["notify"] = $noscrape["dfrn-notify"];
+
+ // Remove all fields that are not present in the gcontact table
+ unset($noscrape["fn"]);
+ unset($noscrape["key"]);
+ unset($noscrape["homepage"]);
+ unset($noscrape["comm"]);
+ unset($noscrape["tags"]);
+ unset($noscrape["locality"]);
+ unset($noscrape["region"]);
+ unset($noscrape["country-name"]);
+ unset($noscrape["contacts"]);
+ unset($noscrape["dfrn-request"]);
+ unset($noscrape["dfrn-confirm"]);
+ unset($noscrape["dfrn-notify"]);
+ unset($noscrape["dfrn-poll"]);
+
+ $contact = array_merge($contact, $noscrape);
- $location = formatted_location($noscrape);
- if ($location)
- $contact["location"] = $location;
-
- $contact["notify"] = $noscrape["dfrn-notify"];
-
- // Remove all fields that are not present in the gcontact table
- unset($noscrape["fn"]);
- unset($noscrape["key"]);
- unset($noscrape["homepage"]);
- unset($noscrape["comm"]);
- unset($noscrape["tags"]);
- unset($noscrape["locality"]);
- unset($noscrape["region"]);
- unset($noscrape["country-name"]);
- unset($noscrape["contacts"]);
- unset($noscrape["dfrn-request"]);
- unset($noscrape["dfrn-confirm"]);
- unset($noscrape["dfrn-notify"]);
- unset($noscrape["dfrn-poll"]);
-
- $contact = array_merge($contact, $noscrape);
- update_gcontact($contact);
-
- return $noscrape["updated"];
+ update_gcontact($contact);
+
+ return $noscrape["updated"];
+ }
}
}
}
// Will also return data for Friendica and GNU Social - but it will be overwritten later
// The "not implemented" is a special treatment for really, really old Friendica versions
$serverret = z_fetch_url($server_url."/api/statusnet/version.json");
- if ($serverret["success"] AND ($serverret["body"] != '{"error":"not implemented"}') AND ($serverret["body"] != '') AND (strlen($serverret["body"]) < 250)) {
+ if ($serverret["success"] AND ($serverret["body"] != '{"error":"not implemented"}') AND
+ ($serverret["body"] != '') AND (strlen($serverret["body"]) < 30)) {
$platform = "StatusNet";
$version = trim($serverret["body"], '"');
$network = NETWORK_OSTATUS;
// Test for GNU Social
$serverret = z_fetch_url($server_url."/api/gnusocial/version.json");
- if ($serverret["success"] AND ($serverret["body"] != '{"error":"not implemented"}') AND ($serverret["body"] != '') AND (strlen($serverret["body"]) < 250)) {
+ if ($serverret["success"] AND ($serverret["body"] != '{"error":"not implemented"}') AND
+ ($serverret["body"] != '') AND (strlen($serverret["body"]) < 30)) {
$platform = "GNU Social";
$version = trim($serverret["body"], '"');
$network = NETWORK_OSTATUS;
// Check again if the server exists
$servers = q("SELECT `nurl` FROM `gserver` WHERE `nurl` = '%s'", dbesc(normalise_link($server_url)));
+ $version = strip_tags($version);
+ $site_name = strip_tags($site_name);
+ $info = strip_tags($info);
+ $platform = strip_tags($platform);
+
if ($servers)
q("UPDATE `gserver` SET `url` = '%s', `version` = '%s', `site_name` = '%s', `info` = '%s', `register_policy` = %d, `poco` = '%s', `noscrape` = '%s',
`network` = '%s', `platform` = '%s', `last_contact` = '%s', `last_failure` = '%s' WHERE `nurl` = '%s'",
unset($fields["url"]);
unset($fields["updated"]);
+ // Bugfix: We had an error in the storing of keywords which lead to the "0"
+ // This value is still transmitted via poco.
+ if ($contact["keywords"] == "0")
+ unset($contact["keywords"]);
+
+ if ($r[0]["keywords"] == "0")
+ $r[0]["keywords"] = "";
+
// assign all unassigned fields from the database entry
foreach ($fields AS $field => $data)
if (!isset($contact[$field]) OR ($contact[$field] == ""))
if (!isset($contact["updated"]))
$contact["updated"] = datetime_convert();
+ if ($contact["server_url"] == "") {
+ $server_url = $contact["url"];
+
+ $server_url = matching_url($server_url, $contact["alias"]);
+ if ($server_url != "")
+ $contact["server_url"] = $server_url;
+
+ $server_url = matching_url($server_url, $contact["photo"]);
+ if ($server_url != "")
+ $contact["server_url"] = $server_url;
+
+ $server_url = matching_url($server_url, $contact["notify"]);
+ if ($server_url != "")
+ $contact["server_url"] = $server_url;
+ } else
+ $contact["server_url"] = normalise_link($contact["server_url"]);
+
+ if (($contact["addr"] == "") AND ($contact["server_url"] != "") AND ($contact["nick"] != "")) {
+ $hostname = str_replace("http://", "", $contact["server_url"]);
+ $contact["addr"] = $contact["nick"]."@".$hostname;
+ }
+
// Check if any field changed
$update = false;
unset($fields["generation"]);
intval($contact["generation"]), dbesc($contact["updated"]),
dbesc($contact["server_url"]), dbesc($contact["connect"]),
dbesc(normalise_link($contact["url"])), intval($contact["generation"]));
+
+
+ // Now update the contact entry with the user id "0" as well.
+ // This is used for the shadow copies of public items.
+ $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = 0 ORDER BY `id` LIMIT 1",
+ dbesc(normalise_link($contact["url"])));
+
+ if ($r) {
+ logger("Update shadow contact ".$r[0]["id"], LOGGER_DEBUG);
+
+ update_contact_avatar($contact["photo"], 0, $r[0]["id"]);
+
+ q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `addr` = '%s',
+ `network` = '%s', `bd` = '%s', `gender` = '%s',
+ `keywords` = '%s', `alias` = '%s', `url` = '%s',
+ `location` = '%s', `about` = '%s'
+ WHERE `id` = %d",
+ dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["addr"]),
+ dbesc($contact["network"]), dbesc($contact["birthday"]), dbesc($contact["gender"]),
+ dbesc($contact["keywords"]), dbesc($contact["alias"]), dbesc($contact["url"]),
+ dbesc($contact["location"]), dbesc($contact["about"]), intval($r[0]["id"]));
+ }
}
return $gcontact_id;