2012-05-01 08:07:52 +02:00
|
|
|
<?php
|
|
|
|
|
2017-01-18 22:45:32 +01:00
|
|
|
use \Friendica\Core\Config;
|
|
|
|
|
2012-05-01 08:07:52 +02:00
|
|
|
require_once('include/Scrape.php');
|
2012-05-02 05:11:35 +02:00
|
|
|
require_once('include/socgraph.php');
|
2017-02-27 00:16:49 +01:00
|
|
|
require_once('include/datetime.php');
|
2012-05-01 08:07:52 +02:00
|
|
|
|
2012-11-05 09:28:54 +01:00
|
|
|
function gprobe_run(&$argv, &$argc){
|
2012-05-01 08:07:52 +02:00
|
|
|
if($argc != 2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
$url = hex2bin($argv[1]);
|
|
|
|
|
2016-01-23 22:36:15 +01:00
|
|
|
$r = q("SELECT `id`, `url`, `network` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 1",
|
2012-05-01 08:07:52 +02:00
|
|
|
dbesc(normalise_link($url))
|
|
|
|
);
|
|
|
|
|
2014-12-08 11:02:03 +01:00
|
|
|
logger("gprobe start for ".normalise_link($url), LOGGER_DEBUG);
|
|
|
|
|
2016-11-04 16:44:49 +01:00
|
|
|
if (!dbm::is_result($r)) {
|
2012-05-01 08:07:52 +02:00
|
|
|
|
2015-03-28 08:29:01 +01:00
|
|
|
// Is it a DDoS attempt?
|
|
|
|
$urlparts = parse_url($url);
|
|
|
|
|
|
|
|
$result = Cache::get("gprobe:".$urlparts["host"]);
|
|
|
|
if (!is_null($result)) {
|
2015-10-04 00:28:15 +02:00
|
|
|
if (in_array($result["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) {
|
2015-03-28 08:49:24 +01:00
|
|
|
logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG);
|
2015-03-28 08:29:01 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-01 10:34:47 +02:00
|
|
|
$arr = probe_url($url);
|
2015-03-28 08:29:01 +01:00
|
|
|
|
|
|
|
if (is_null($result))
|
2016-11-04 16:44:49 +01:00
|
|
|
Cache::set("gprobe:".$urlparts["host"], $arr);
|
2015-03-28 08:29:01 +01:00
|
|
|
|
2016-04-20 07:58:52 +02:00
|
|
|
if (!in_array($arr["network"], array(NETWORK_FEED, NETWORK_PHANTOM)))
|
2016-01-23 22:36:15 +01:00
|
|
|
update_gcontact($arr);
|
|
|
|
|
|
|
|
$r = q("SELECT `id`, `url`, `network` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 1",
|
2012-05-01 10:34:47 +02:00
|
|
|
dbesc(normalise_link($url))
|
2012-05-01 08:07:52 +02:00
|
|
|
);
|
|
|
|
}
|
2016-12-14 09:42:36 +01:00
|
|
|
if (dbm::is_result($r)) {
|
2016-04-23 10:46:16 +02:00
|
|
|
// Check for accessibility and do a poco discovery
|
|
|
|
if (poco_last_updated($r[0]['url'], true) AND ($r[0]["network"] == NETWORK_DFRN))
|
2016-01-23 22:36:15 +01:00
|
|
|
poco_load(0,0,$r[0]['id'], str_replace('/profile/','/poco/',$r[0]['url']));
|
2016-04-23 10:46:16 +02:00
|
|
|
}
|
2014-12-08 11:02:03 +01:00
|
|
|
|
|
|
|
logger("gprobe end for ".normalise_link($url), LOGGER_DEBUG);
|
2012-05-01 08:07:52 +02:00
|
|
|
return;
|
|
|
|
}
|