3 * @file src/Worker/GProbe.php
6 namespace Friendica\Worker;
8 use Friendica\Core\Cache;
9 use Friendica\Database\DBM;
10 use Friendica\Model\GContact;
11 use Friendica\Network\Probe;
12 use Friendica\Protocol\PortableContact;
15 public static function execute($url = '')
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"], [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"], [NETWORK_FEED, NETWORK_PHANTOM])) {
47 GContact::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);