3 use \Friendica\Core\Config;
5 function update_gcontact_run(&$argv, &$argc){
8 require_once('include/Scrape.php');
9 require_once('include/socgraph.php');
11 logger('update_gcontact: start');
13 if (($argc > 1) && (intval($argv[1]))) {
14 $contact_id = intval($argv[1]);
18 logger('update_gcontact: no contact');
22 $r = q("SELECT * FROM `gcontact` WHERE `id` = %d", intval($contact_id));
24 if (!dbm::is_result($r)) {
28 if (!in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) }
32 $data = probe_url($r[0]["url"]);
34 if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
35 if ($r[0]["server_url"] != "") {
36 poco_check_server($r[0]["server_url"], $r[0]["network"]);
39 q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `id` = %d",
40 dbesc(datetime_convert()), intval($contact_id));
44 if (($data["name"] == "") AND ($r[0]['name'] != "")) {
45 $data["name"] = $r[0]['name'];
48 if (($data["nick"] == "") AND ($r[0]['nick'] != "")) {
49 $data["nick"] = $r[0]['nick'];
52 if (($data["addr"] == "") AND ($r[0]['addr'] != "")) {
53 $data["addr"] = $r[0]['addr'];
56 if (($data["photo"] == "") AND ($r[0]['photo'] != "")) {
57 $data["photo"] = $r[0]['photo'];
60 q("UPDATE `gcontact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `photo` = '%s'
65 dbesc($data["photo"]),
69 q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `photo` = '%s'
70 WHERE `uid` = 0 AND `addr` = '' AND `nurl` = '%s'",
74 dbesc($data["photo"]),
75 dbesc(normalise_link($data["url"]))
78 q("UPDATE `contact` SET `addr` = '%s'
79 WHERE `uid` != 0 AND `addr` = '' AND `nurl` = '%s'",
81 dbesc(normalise_link($data["url"]))