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