From: Michael Date: Fri, 17 Mar 2017 15:53:19 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/develop' into 1702-detect-server X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=87771cf6176df2b0fe4a2b5ea830aa8843279c12;p=friendica.git Merge remote-tracking branch 'upstream/develop' into 1702-detect-server Conflicts: include/discover_poco.php --- 87771cf6176df2b0fe4a2b5ea830aa8843279c12 diff --cc include/discover_poco.php index 91cc0b6083,0384483a40..8e392f67d3 --- a/include/discover_poco.php +++ b/include/discover_poco.php @@@ -2,43 -2,12 +2,21 @@@ use \Friendica\Core\Config; - require_once("boot.php"); - require_once("include/socgraph.php"); + require_once('include/socgraph.php'); + require_once('include/datetime.php'); function discover_poco_run(&$argv, &$argc){ - global $a, $db; - - if(is_null($a)) { - $a = new App; - } - - if(is_null($db)) { - @include(".htconfig.php"); - require_once("include/dba.php"); - $db = new dba($db_host, $db_user, $db_pass, $db_data); - unset($db_host, $db_user, $db_pass, $db_data); - }; - - require_once('include/session.php'); - require_once('include/datetime.php'); - - Config::load(); - - // Don't check this stuff if the function is called by the poller - if (App::callstack() != "poller_run") - if ($a->maxload_reached()) - return; + /* + This function can be called in these ways: + - dirsearch : Searches for "search pattern" in the directory. "search pattern" is url encoded. + - checkcontact: Updates gcontact entries + - suggestions: Discover other servers for their contacts. + - server : Searches for the poco server list. "poco url" is base64 encoded. + - update_server: Frequently check the first 250 servers for vitality. + */ + - if(($argc > 2) && ($argv[1] == "dirsearch")) { + if (($argc > 2) && ($argv[1] == "dirsearch")) { $search = urldecode($argv[2]); $mode = 1; } elseif(($argc == 2) && ($argv[1] == "checkcontact")) { @@@ -52,45 -17,16 +30,36 @@@ } elseif ($argc == 1) { $search = ""; $mode = 0; - } else + } else { die("Unknown or missing parameter ".$argv[1]."\n"); + } - // Don't check this stuff if the function is called by the poller - if (App::callstack() != "poller_run") - if (App::is_already_running('discover_poco'.$mode.urlencode($search), 'include/discover_poco.php', 1140)) - return; - - $a->set_baseurl(get_config('system','url')); - - load_hooks(); - logger('start '.$search); - if ($mode==3) + if ($mode == 5) { + update_server(); + } elseif ($mode == 4) { + $server_url = base64_decode($argv[2]); + if ($server_url == "") { + return; + } + $server_url = filter_var($server_url, FILTER_SANITIZE_URL); + if (substr(normalise_link($server_url), 0, 7) != "http://") { + return; + } + $result = "Checking server ".$server_url." - "; + $ret = poco_check_server($server_url); + if ($ret) { + $result .= "success"; + } else { + $result .= "failed"; + } + logger($result, LOGGER_DEBUG); + } elseif ($mode == 3) { update_suggestions(); - elseif (($mode == 2) AND get_config('system','poco_completion')) + } elseif (($mode == 2) AND get_config('system','poco_completion')) { discover_users(); - elseif (($mode == 1) AND ($search != "") and get_config('system','poco_local_search')) { + } elseif (($mode == 1) AND ($search != "") and get_config('system','poco_local_search')) { discover_directory($search); gs_search_user($search); } elseif (($mode == 0) AND ($search == "") and (get_config('system','poco_discovery') > 0)) {