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);
21 require_once('include/Scrape.php');
22 require_once("include/socgraph.php");
24 load_config('config');
25 load_config('system');
27 $a->set_baseurl(get_config('system','url'));
31 logger('update_gcontact: start');
33 if(($argc > 1) && (intval($argv[1])))
34 $contact_id = intval($argv[1]);
37 logger('update_gcontact: no contact');
41 // Don't check this stuff if the function is called by the poller
42 if (App::callstack() != "poller_run")
43 if (App::is_already_running('update_gcontact'.$contact_id, '', 540))
46 $r = q("SELECT * FROM `gcontact` WHERE `id` = %d", intval($contact_id));
51 if (!in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)))
54 $data = probe_url($r[0]["url"]);
56 if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
57 if ($r[0]["server_url"] != "")
58 poco_check_server($r[0]["server_url"], $r[0]["network"]);
60 q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `id` = %d",
61 dbesc(datetime_convert()), intval($contact_id));
65 if (($data["name"] == "") AND ($r[0]['name'] != ""))
66 $data["name"] = $r[0]['name'];
68 if (($data["nick"] == "") AND ($r[0]['nick'] != ""))
69 $data["nick"] = $r[0]['nick'];
71 if (($data["addr"] == "") AND ($r[0]['addr'] != ""))
72 $data["addr"] = $r[0]['addr'];
74 if (($data["photo"] == "") AND ($r[0]['photo'] != ""))
75 $data["photo"] = $r[0]['photo'];
78 q("UPDATE `gcontact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `photo` = '%s'
83 dbesc($data["photo"]),
87 q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `photo` = '%s'
88 WHERE `uid` = 0 AND `addr` = '' AND `nurl` = '%s'",
92 dbesc($data["photo"]),
93 dbesc(normalise_link($data["url"]))
96 q("UPDATE `contact` SET `addr` = '%s'
97 WHERE `uid` != 0 AND `addr` = '' AND `nurl` = '%s'",
99 dbesc(normalise_link($data["url"]))
103 if (array_search(__file__,get_included_files())===0){
104 update_gcontact_run($_SERVER["argv"],$_SERVER["argc"]);