News:

Wondering if this will always be free?  See why free is better.

Main Menu

Limit number of searches for guests

Started by spiros, September 24, 2021, 06:34:45 AM

Previous topic - Next topic

spiros

Is this possible? I mean not the number of search results, but the number of times they can search without logging in. I use Sphinx.

Doug Heffernan

Quote from: spiros on September 24, 2021, 06:34:45 AMIs this possible? I mean not the number of search results, but the number of times they can search without logging in. I use Sphinx.

This will require a custom mod.

shadav

as Doug mentioned that would require a custom mod

however in your admin under forum then under search go to settings
you can limit the time in between searches

Time required between searches from same user
(0 for no limit, in seconds)
I usually set mine to 20 seconds

and as well in your admin under configuration then under Security and Moderation go to Anti-Spam
and you can require guests to use verification on searches as well
Require verification on all guest searches

so with these 2 in place will help limit guests/bots from spamming the search function

spiros

Thanks, I got an e-mail notification (post deleted?) with a reply by @Shambles with some code that limits number of results, it can be useful, it seems to be something like this, not sure where exactly in Search.php function PlushSearch2() function that should go .

function PlushSearch2()
    if ($user_info['is_guest'] == 1)
        $modSettings['search_max_results'] = 3;

Shambles

^ Yeah I posted that then reread your query - what I posted didn't answer it, so I removed it.

It goes just after this block of code:

// Zero weight.  Weightless :P.
if (empty($weight_total))
fatal_lang_error('search_invalid_weights');

if ($user_info['is_guest'] == 1)
        $modSettings['search_max_results'] = 3;

spiros

Well, it is a clever and easy solution, thanks for reposting; if not useful to me, it could be useful to many other people!

spiros

Interesting, does not appear to change the number of results for guests. Maybe due to Sphinx or other setting?

Shambles

Possibly your sphinx implementation.

You can see it in action on one of my forums (use the "standard search")...

https://www.i30ownersclub.com/forum/index.php?action=search

spiros

Yes, works great there! (I tried the custom Google first, I think you can customize its colour scheme/css to make it blend in with your theme).

spiros

This worked in SearchAPI-Sphinxql.php.

Find
// Make sure we have a max results.
if (!isset($modSettings['sphinx_max_results']))
$modSettings['sphinx_max_results'] = '1000';

Replace
// Make sure we have a max results.
if ($user_info['is_guest'] == 1)
$modSettings['sphinx_max_results'] = 30;

if (!isset($modSettings['sphinx_max_results']))
$modSettings['sphinx_max_results'] = '1000';

Advertisement: