2012-05-01 08:07:52 +02:00
|
|
|
<?php
|
|
|
|
|
2017-04-30 06:29:14 +02:00
|
|
|
use Friendica\Core\Config;
|
2017-01-18 22:45:32 +01:00
|
|
|
|
2017-05-07 20:45:19 +02:00
|
|
|
require_once 'include/probe.php';
|
2017-05-07 20:40:23 +02:00
|
|
|
require_once 'include/socgraph.php';
|
|
|
|
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){
|
2017-03-14 16:17:21 +01:00
|
|
|
if ($argc != 2) {
|
2012-05-01 08:07:52 +02:00
|
|
|
return;
|
2017-03-14 16:17:21 +01:00
|
|
|
}
|
2017-07-06 07:48:02 +02:00
|
|
|
$url = $argv[1];
|
2012-05-01 08:07:52 +02:00
|
|
|
|
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
|
|
|
|
2017-04-04 19:47:45 +02:00
|
|
|
if (is_null($result)) {
|
2016-11-04 16:44:49 +01:00
|
|
|
Cache::set("gprobe:".$urlparts["host"], $arr);
|
2017-04-04 19:47:45 +02:00
|
|
|
}
|
2015-03-28 08:29:01 +01:00
|
|
|
|
2017-04-04 19:47:45 +02:00
|
|
|
if (!in_array($arr["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) {
|
2016-01-23 22:36:15 +01:00
|
|
|
update_gcontact($arr);
|
2017-04-04 19:47:45 +02:00
|
|
|
}
|
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 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
|
2017-06-08 04:00:59 +02:00
|
|
|
if (poco_last_updated($r[0]['url'], true) && ($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;
|
|
|
|
}
|