3 * @file include/gprobe.php
5 use Friendica\Core\Cache;
6 use Friendica\Core\Config;
7 use Friendica\Database\DBM;
8 use Friendica\Model\GlobalContact;
9 use Friendica\Network\Probe;
10 use Friendica\Protocol\PortableContact;
12 require_once 'include/datetime.php';
14 function gprobe_run(&$argv, &$argc)
22 "SELECT `id`, `url`, `network` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 1",
23 dbesc(normalise_link($url))
26 logger("gprobe start for ".normalise_link($url), LOGGER_DEBUG);
28 if (!DBM::is_result($r)) {
29 // Is it a DDoS attempt?
30 $urlparts = parse_url($url);
32 $result = Cache::get("gprobe:".$urlparts["host"]);
33 if (!is_null($result)) {
34 if (in_array($result["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) {
35 logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG);
40 $arr = Probe::uri($url);
42 if (is_null($result)) {
43 Cache::set("gprobe:".$urlparts["host"], $arr);
46 if (!in_array($arr["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) {
47 GlobalContact::update($arr);
51 "SELECT `id`, `url`, `network` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 1",
52 dbesc(normalise_link($url))
55 if (DBM::is_result($r)) {
56 // Check for accessibility and do a poco discovery
57 if (PortableContact::lastUpdated($r[0]['url'], true) && ($r[0]["network"] == NETWORK_DFRN)) {
58 PortableContact::loadWorker(0, 0, $r[0]['id'], str_replace('/profile/', '/poco/', $r[0]['url']));
62 logger("gprobe end for ".normalise_link($url), LOGGER_DEBUG);