X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fdiscover_poco.php;h=dd208d492f753c96bbe32b338f87c2fb93b7fe57;hb=791fc1d8b3c3cc6bb4e62ef4b6f81bb99c1d45ed;hp=bb53efb5ccc125b37097c0d1112338d4b7269b1e;hpb=632d77cfb1ffce8aaddc0134ee232df29f267162;p=friendica.git diff --git a/include/discover_poco.php b/include/discover_poco.php index bb53efb5cc..dd208d492f 100644 --- a/include/discover_poco.php +++ b/include/discover_poco.php @@ -1,9 +1,10 @@ 0)) { + } elseif (($mode == 0) && ($search == "") && (get_config('system','poco_discovery') > 0)) { // Query Friendica and Hubzilla servers for their users poco_discover(); @@ -118,7 +118,7 @@ function update_server() { } logger('Update server status for server '.$server["url"], LOGGER_DEBUG); - proc_run(PRIORITY_LOW, "include/discover_poco.php", "server", base64_encode($server["url"])); + proc_run(PRIORITY_LOW, "include/discover_poco.php", "server", $server["url"]); if (++$updated > 250) { return; @@ -175,9 +175,9 @@ function discover_users() { $server_url = $user["server_url"]; } - if ((($server_url == "") AND ($user["network"] == NETWORK_FEED)) OR $force_update OR poco_check_server($server_url, $user["network"])) { + if ((($server_url == "") && ($user["network"] == NETWORK_FEED)) || $force_update || poco_check_server($server_url, $user["network"])) { logger('Check profile '.$user["url"]); - proc_run(PRIORITY_LOW, "include/discover_poco.php", "check_profile", base64_encode($user["url"])); + proc_run(PRIORITY_LOW, "include/discover_poco.php", "check_profile", $user["url"]); if (++$checked > 100) { return; @@ -209,13 +209,13 @@ 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 ($exists) { + if (dbm::is_result($exists)) { logger("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG); - if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) AND + if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) && ($exists[0]["updated"] < $exists[0]["last_failure"])) { continue; } @@ -272,12 +272,16 @@ function gs_search_user($search) { if (!$result["success"]) { return false; } + $contacts = json_decode($result["body"]); if ($contacts->status == 'ERROR') { return false; } - foreach($contacts->data AS $user) { + + /// @TODO AS is considered as a notation for constants (as they usually being written all upper-case) + /// @TODO find all those and convert to all lower-case which is a keyword then + foreach ($contacts->data AS $user) { $contact = probe_url($user->site_address."/".$user->name); if ($contact["network"] != NETWORK_PHANTOM) { $contact["about"] = $user->description;