3 * @file src/Worker/DiscoverPoCo.php
5 namespace Friendica\Worker;
7 use Friendica\Core\Cache;
8 use Friendica\Core\Config;
9 use Friendica\Core\Logger;
10 use Friendica\Core\Protocol;
11 use Friendica\Core\Worker;
12 use Friendica\Database\DBA;
13 use Friendica\Model\GContact;
14 use Friendica\Model\Contact;
15 use Friendica\Model\GServer;
16 use Friendica\Network\Probe;
17 use Friendica\Protocol\PortableContact;
18 use Friendica\Util\DateTimeFormat;
19 use Friendica\Util\Network;
20 use Friendica\Util\Strings;
24 /// @todo Clean up this mess of a parameter hell and split it in several classes
25 public static function execute($command = '', $param1 = '', $param2 = '', $param3 = '', $param4 = '')
28 This function can be called in these ways:
29 - checkcontact: Updates gcontact entries
30 - server <poco url>: Searches for the poco server list. "poco url" is base64 encoded.
31 - PortableContact::load: Load POCO data from a given POCO address
36 if ($command == "server") {
37 $server_url = $param1;
38 if ($server_url == "") {
41 $server_url = filter_var($server_url, FILTER_SANITIZE_URL);
42 if (substr(Strings::normaliseLink($server_url), 0, 7) != "http://") {
45 $result = "Checking server ".$server_url." - ";
46 $ret = GServer::check($server_url);
52 Logger::log($result, Logger::DEBUG);
53 } elseif ($command == "load") {
54 if (!empty($param4)) {
59 PortableContact::load(intval($param1), intval($param2), intval($param3), $url);
60 } elseif ($command !== "") {
61 Logger::log("Unknown or missing parameter ".$command."\n");
65 Logger::log('start '.$search);
67 if (($mode == 0) && ($search == "") && (Config::get('system', 'poco_discovery') != PortableContact::DISABLED)) {
68 // Query Friendica and Hubzilla servers for their users
69 PortableContact::discover();
71 // Query GNU Social servers for their users ("statistics" addon has to be enabled on the GS server)
72 if (!Config::get('system', 'ostatus_disabled')) {
73 GContact::discoverGsUsers();
77 Logger::log('end '.$search);