3 use \Friendica\Core\Config;
5 require_once('include/Scrape.php');
6 require_once('include/socgraph.php');
7 require_once('include/datetime.php');
9 function gprobe_run(&$argv, &$argc){
13 $url = hex2bin($argv[1]);
15 $r = q("SELECT `id`, `url`, `network` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 1",
16 dbesc(normalise_link($url))
19 logger("gprobe start for ".normalise_link($url), LOGGER_DEBUG);
21 if (!dbm::is_result($r)) {
23 // Is it a DDoS attempt?
24 $urlparts = parse_url($url);
26 $result = Cache::get("gprobe:".$urlparts["host"]);
27 if (!is_null($result)) {
28 if (in_array($result["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) {
29 logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG);
34 $arr = probe_url($url);
37 Cache::set("gprobe:".$urlparts["host"], $arr);
39 if (!in_array($arr["network"], array(NETWORK_FEED, NETWORK_PHANTOM)))
40 update_gcontact($arr);
42 $r = q("SELECT `id`, `url`, `network` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 1",
43 dbesc(normalise_link($url))
46 if (dbm::is_result($r)) {
47 // Check for accessibility and do a poco discovery
48 if (poco_last_updated($r[0]['url'], true) AND ($r[0]["network"] == NETWORK_DFRN))
49 poco_load(0,0,$r[0]['id'], str_replace('/profile/','/poco/',$r[0]['url']));
52 logger("gprobe end for ".normalise_link($url), LOGGER_DEBUG);