3 require_once("boot.php");
5 function update_gcontact_run(&$argv, &$argc){
13 @include(".htconfig.php");
14 require_once("include/dba.php");
15 $db = new dba($db_host, $db_user, $db_pass, $db_data);
16 unset($db_host, $db_user, $db_pass, $db_data);
19 require_once('include/Scrape.php');
20 require_once("include/socgraph.php");
22 load_config('config');
23 load_config('system');
25 $a->set_baseurl(get_config('system','url'));
29 logger('update_gcontact: start');
31 if(($argc > 1) && (intval($argv[1])))
32 $contact_id = intval($argv[1]);
35 logger('update_gcontact: no contact');
39 // Don't check this stuff if the function is called by the poller
40 if (App::callstack() != "poller_run")
41 if (App::is_already_running('', 'update_gcontact'.$contact_id, 540))
44 $r = q("SELECT * FROM `gcontact` WHERE `id` = %d", intval($contact_id));
49 if (!in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)))
52 $data = probe_url($r[0]["url"]);
54 if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
55 if ($r[0]["server_url"] != "")
56 poco_check_server($r[0]["server_url"], $r[0]["network"]);
58 q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `id` = %d",
59 dbesc(datetime_convert()), intval($contact_id));
63 if (($data["name"] == "") AND ($r[0]['name'] != ""))
64 $data["name"] = $r[0]['name'];
66 if (($data["nick"] == "") AND ($r[0]['nick'] != ""))
67 $data["nick"] = $r[0]['nick'];
69 if (($data["addr"] == "") AND ($r[0]['addr'] != ""))
70 $data["addr"] = $r[0]['addr'];
72 if (($data["photo"] == "") AND ($r[0]['photo'] != ""))
73 $data["photo"] = $r[0]['photo'];
76 q("UPDATE `gcontact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `photo` = '%s'
81 dbesc($data["photo"]),
85 q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `photo` = '%s'
86 WHERE `uid` = 0 AND `addr` = '' AND `nurl` = '%s'",
90 dbesc($data["photo"]),
91 dbesc(normalise_link($data["url"]))
94 q("UPDATE `contact` SET `addr` = '%s'
95 WHERE `uid` != 0 AND `addr` = '' AND `nurl` = '%s'",
97 dbesc(normalise_link($data["url"]))
101 if (array_search(__file__,get_included_files())===0){
102 update_gcontact_run($_SERVER["argv"],$_SERVER["argc"]);