mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-16 20:05:14 +02:00
Merge pull request #1926 from annando/1510-permit-crawler
New option to permit crawlers
This commit is contained in:
commit
05b2836d66
3 changed files with 44 additions and 7 deletions
|
@ -95,10 +95,29 @@ function search_content(&$a) {
|
|||
}
|
||||
|
||||
if(get_config('system','local_search') AND !local_user()) {
|
||||
notice(t('Public access denied.').EOL);
|
||||
return;
|
||||
//http_status_exit(403);
|
||||
//killme();
|
||||
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');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue