3 use \Friendica\Core\Config;
5 require_once("boot.php");
6 require_once('include/Scrape.php');
7 require_once('include/socgraph.php');
9 function gprobe_run(&$argv, &$argc){
17 @include(".htconfig.php");
18 require_once("include/dba.php");
19 $db = new dba($db_host, $db_user, $db_pass, $db_data);
20 unset($db_host, $db_user, $db_pass, $db_data);
23 require_once('include/session.php');
24 require_once('include/datetime.php');
28 $a->set_baseurl(get_config('system','url'));
35 $url = hex2bin($argv[1]);
37 $r = q("SELECT `id`, `url`, `network` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 1",
38 dbesc(normalise_link($url))
41 logger("gprobe start for ".normalise_link($url), LOGGER_DEBUG);
43 if (!dbm::is_result($r)) {
45 // Is it a DDoS attempt?
46 $urlparts = parse_url($url);
48 $result = Cache::get("gprobe:".$urlparts["host"]);
49 if (!is_null($result)) {
50 if (in_array($result["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) {
51 logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG);
56 $arr = probe_url($url);
59 Cache::set("gprobe:".$urlparts["host"], $arr);
61 if (!in_array($arr["network"], array(NETWORK_FEED, NETWORK_PHANTOM)))
62 update_gcontact($arr);
64 $r = q("SELECT `id`, `url`, `network` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 1",
65 dbesc(normalise_link($url))
68 if (dbm::is_result($r)) {
69 // Check for accessibility and do a poco discovery
70 if (poco_last_updated($r[0]['url'], true) AND ($r[0]["network"] == NETWORK_DFRN))
71 poco_load(0,0,$r[0]['id'], str_replace('/profile/','/poco/',$r[0]['url']));
74 logger("gprobe end for ".normalise_link($url), LOGGER_DEBUG);
78 if (array_search(__file__,get_included_files())===0){
79 gprobe_run($_SERVER["argv"],$_SERVER["argc"]);