]> git.mxchange.org Git - friendica.git/blobdiff - include/discover_poco.php
merged 2 if() into one as requested by CR
[friendica.git] / include / discover_poco.php
index c13f89894474ef5de3dd74449440b324228d10a2..2923cd01f127489ca07276df210ef4538d05a5e2 100644 (file)
@@ -14,6 +14,8 @@ function discover_poco_run(&$argv, &$argc) {
        - suggestions: Discover other servers for their contacts.
        - server <poco url>: Searches for the poco server list. "poco url" is base64 encoded.
        - update_server: Frequently check the first 250 servers for vitality.
+       - update_server_directory: Discover the given server id for their contacts
+       - poco_load: Load POCO data from a given POCO address
        */
 
        if (($argc > 2) && ($argv[1] == "dirsearch")) {
@@ -27,6 +29,10 @@ function discover_poco_run(&$argv, &$argc) {
                $mode = 4;
        } elseif (($argc == 2) && ($argv[1] == "update_server")) {
                $mode = 5;
+       } elseif (($argc == 3) && ($argv[1] == "update_server_directory")) {
+               $mode = 6;
+       } elseif (($argc > 5) && ($argv[1] == "poco_load")) {
+               $mode = 7;
        } elseif ($argc == 1) {
                $search = "";
                $mode = 0;
@@ -36,7 +42,16 @@ function discover_poco_run(&$argv, &$argc) {
 
        logger('start '.$search);
 
-       if ($mode == 5) {
+       if ($mode == 7) {
+               if ($argc == 6) {
+                       $url = base64_decode($argv[5]);
+               } else {
+                       $url = '';
+               }
+               poco_load_worker(intval($argv[2]), intval($argv[3]), intval($argv[4]), $url);
+       } elseif ($mode == 6) {
+               poco_discover_single_server(intval($argv[2]));
+       } elseif ($mode == 5) {
                update_server();
        } elseif ($mode == 4) {
                $server_url = base64_decode($argv[2]);
@@ -174,10 +189,10 @@ function discover_directory($search) {
        $j = json_decode($x);
 
        if (count($j->results)) {
-               foreach ($j->results as $jj) {
+               foreach($j->results as $jj) {
                        // Check if the contact already exists
                        $exists = q("SELECT `id`, `last_contact`, `last_failure`, `updated` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($jj->url));
-                       if (dbm::is_result($exists)) {
+                       if ($exists) {
                                logger("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG);
 
                                if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) AND