3 require_once("boot.php");
4 require_once('include/Scrape.php');
5 require_once('include/socgraph.php');
7 function gprobe_run(&$argv, &$argc){
15 @include(".htconfig.php");
16 require_once("include/dba.php");
17 $db = new dba($db_host, $db_user, $db_pass, $db_data);
18 unset($db_host, $db_user, $db_pass, $db_data);
21 require_once('include/session.php');
22 require_once('include/datetime.php');
24 load_config('config');
25 load_config('system');
27 $a->set_baseurl(get_config('system','url'));
34 $url = hex2bin($argv[1]);
36 $r = q("SELECT `id`, `url`, `network` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 1",
37 dbesc(normalise_link($url))
40 logger("gprobe start for ".normalise_link($url), LOGGER_DEBUG);
42 if (!dbm::is_result($r)) {
44 // Is it a DDoS attempt?
45 $urlparts = parse_url($url);
47 $result = Cache::get("gprobe:".$urlparts["host"]);
48 if (!is_null($result)) {
49 if (in_array($result["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) {
50 logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG);
55 $arr = probe_url($url);
58 Cache::set("gprobe:".$urlparts["host"], $arr);
60 if (!in_array($arr["network"], array(NETWORK_FEED, NETWORK_PHANTOM)))
61 update_gcontact($arr);
63 $r = q("SELECT `id`, `url`, `network` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 1",
64 dbesc(normalise_link($url))
67 if(dbm::is_result($r)) {
68 // Check for accessibility and do a poco discovery
69 if (poco_last_updated($r[0]['url'], true) AND ($r[0]["network"] == NETWORK_DFRN))
70 poco_load(0,0,$r[0]['id'], str_replace('/profile/','/poco/',$r[0]['url']));
73 logger("gprobe end for ".normalise_link($url), LOGGER_DEBUG);
77 if (array_search(__file__,get_included_files())===0){
78 gprobe_run($_SERVER["argv"],$_SERVER["argc"]);