3 * @file src/Worker/GProbe.php
6 namespace Friendica\Worker;
8 use Friendica\Core\Cache;
9 use Friendica\Core\Protocol;
10 use Friendica\Database\DBA;
11 use Friendica\Model\GContact;
12 use Friendica\Network\Probe;
13 use Friendica\Protocol\PortableContact;
16 public static function execute($url = '')
23 "SELECT `id`, `url`, `network` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 1",
24 DBA::escape(normalise_link($url))
27 logger("gprobe start for ".normalise_link($url), LOGGER_DEBUG);
29 if (!DBA::isResult($r)) {
30 // Is it a DDoS attempt?
31 $urlparts = parse_url($url);
33 $result = Cache::get("gprobe:".$urlparts["host"]);
34 if (!is_null($result)) {
35 if (in_array($result["network"], [Protocol::FEED, Protocol::PHANTOM])) {
36 logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG);
41 $arr = Probe::uri($url);
43 if (is_null($result)) {
44 Cache::set("gprobe:".$urlparts["host"], $arr);
47 if (!in_array($arr["network"], [Protocol::FEED, Protocol::PHANTOM])) {
48 GContact::update($arr);
52 "SELECT `id`, `url`, `network` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 1",
53 DBA::escape(normalise_link($url))
56 if (DBA::isResult($r)) {
57 // Check for accessibility and do a poco discovery
58 if (PortableContact::lastUpdated($r[0]['url'], true) && ($r[0]["network"] == Protocol::DFRN)) {
59 PortableContact::loadWorker(0, 0, $r[0]['id'], str_replace('/profile/', '/poco/', $r[0]['url']));
63 logger("gprobe end for ".normalise_link($url), LOGGER_DEBUG);