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