3 * @file src/Worker/GProbe.php
6 namespace Friendica\Worker;
8 use Friendica\Core\Cache;
9 use Friendica\Core\Config;
10 use Friendica\Database\DBM;
11 use Friendica\Model\GlobalContact;
12 use Friendica\Network\Probe;
13 use Friendica\Protocol\PortableContact;
15 require_once 'include/datetime.php';
18 public static function execute($url = '')
25 "SELECT `id`, `url`, `network` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 1",
26 dbesc(normalise_link($url))
29 logger("gprobe start for ".normalise_link($url), LOGGER_DEBUG);
31 if (!DBM::is_result($r)) {
32 // Is it a DDoS attempt?
33 $urlparts = parse_url($url);
35 $result = Cache::get("gprobe:".$urlparts["host"]);
36 if (!is_null($result)) {
37 if (in_array($result["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) {
38 logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG);
43 $arr = Probe::uri($url);
45 if (is_null($result)) {
46 Cache::set("gprobe:".$urlparts["host"], $arr);
49 if (!in_array($arr["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) {
50 GlobalContact::update($arr);
54 "SELECT `id`, `url`, `network` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 1",
55 dbesc(normalise_link($url))
58 if (DBM::is_result($r)) {
59 // Check for accessibility and do a poco discovery
60 if (PortableContact::lastUpdated($r[0]['url'], true) && ($r[0]["network"] == NETWORK_DFRN)) {
61 PortableContact::loadWorker(0, 0, $r[0]['id'], str_replace('/profile/', '/poco/', $r[0]['url']));
65 logger("gprobe end for ".normalise_link($url), LOGGER_DEBUG);