Firefox PHP

Protect search against bots

Posted by elmotard 
Protect search against bots
February 01, 2021 02:39PM
Hello,

There a lot of request from bots against the internal phorum search, with attempts of sql inject, loading the server.

I would like to protect the search against bots with a simple rule, having the search working only if somebody is logged in.

the working code is :

Language: PHP
if(!$PHORUM["DATA"]["LOGGEDIN"]) { $search_request_data=""; }

if i add this in the search.php file, it is working fine except that it throws a lot of backend errors like Illegal string offset 'urlargs' or Invalid argument supplied for foreach().
I guess It's not at the right line.

Any idea ?

Thanks
Re: Protect search against bots
February 01, 2021 02:57PM
I found what sounds a solution by adding the test on an other line

Language: PHP
if(isset($PHORUM["args"]["search"]) && $PHORUM["DATA"]["LOGGEDIN"]){

Does block the search, except if loggedin.

If you think it is a bad modification or any idea to improve is welcome
Sorry, only registered users may post in this forum.

Click here to login