X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fsearch.php;h=c15dfae3fea8d981cf74efe685f9fef59078413f;hb=d80888842926eba272ae0e86d7666daeef201dc3;hp=d5e0dfb208992af0f91f65745fad772add2b9312;hpb=3ff196f00dbad7e1efe6bb32cefbd7ece24127d4;p=friendica.git diff --git a/mod/search.php b/mod/search.php index d5e0dfb208..c15dfae3fe 100644 --- a/mod/search.php +++ b/mod/search.php @@ -94,6 +94,32 @@ function search_content(&$a) { return; } + if(get_config('system','local_search') AND !local_user()) { + http_status_exit(403, + array("title" => t("Public access denied."), + "description" => t("Only logged in users are permitted to perform a search."))); + killme(); + //notice(t('Public access denied.').EOL); + //return; + } + + if (get_config('system','permit_crawling') AND !local_user()) { + // To-Do: + // - 10 requests are "free", after the 11th only a call per minute is allowed + + $remote = $_SERVER["REMOTE_ADDR"]; + $result = Cache::get("remote_search:".$remote); + if (!is_null($result)) { + if ($result > (time() - 60)) { + http_status_exit(429, + array("title" => t("Too Many Requests"), + "description" => t("Only one search per minute is permitted for not logged in users."))); + killme(); + } + } + Cache::set("remote_search:".$remote, time(), CACHE_HOUR); + } + nav_set_selected('search'); @@ -111,7 +137,7 @@ function search_content(&$a) { } - $o .= search($search,'search-box','/search',((local_user()) ? true : false)); + $o .= search($search,'search-box','/search',((local_user()) ? true : false), false); if(strpos($search,'#') === 0) { $tag = true;