Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Possible to limit search requests?

50sQuiff50sQuiff ✭✭
edited October 2012 in Vanilla 2.0 - 2.8

Hi guys, I've been putting together a self-hosted Vanilla forum and I'm really happy with how it's going so far. I have one question: is it possible to restrict search to logged-in members only and/or limit the number of search requests in a given period?

I've seen this functionality elsewhere as a forum user. I'd mainly like to guard against excessive server load or a vindictive flood attack (if indeed Vanilla has such a vulnerability). Any help appreciated.

Regards,
Quiff

Best Answers

  • Options
    mcu_hqmcu_hq yippie ki-yay ✭✭✭
    Answer ✓

    Yes it is possible, you need to put a few lines in the search model to limit requests to logged in users. Copy and paste the original into a plugin and modify it there.

  • Options
    peregrineperegrine MVP
    edited October 2012 Answer ✓

    mcu_hq's solution would stop people if they know the link.

    and this would just not show the link

    or in a theme that has default.master.tpl - you can prevent option from showing on page (I find it highly unlikely someone would flood search.)

     <div id="Body">
            <div class="Wrapper">
              <div id="Panel">
               {if $User.SignedIn}
                 <div class="SearchBox">{searchbox}</div>
                {/if}
                 {asset name="Panel"}
              </div>
              <div id="Content">
                 {asset name="Content"}
              </div>
            </div>
    

    or modify the default.master.php in theme

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Answers

  • Options
    mcu_hqmcu_hq yippie ki-yay ✭✭✭
    Answer ✓

    Yes it is possible, you need to put a few lines in the search model to limit requests to logged in users. Copy and paste the original into a plugin and modify it there.

  • Options
    peregrineperegrine MVP
    edited October 2012 Answer ✓

    mcu_hq's solution would stop people if they know the link.

    and this would just not show the link

    or in a theme that has default.master.tpl - you can prevent option from showing on page (I find it highly unlikely someone would flood search.)

     <div id="Body">
            <div class="Wrapper">
              <div id="Panel">
               {if $User.SignedIn}
                 <div class="SearchBox">{searchbox}</div>
                {/if}
                 {asset name="Panel"}
              </div>
              <div id="Content">
                 {asset name="Content"}
              </div>
            </div>
    

    or modify the default.master.php in theme

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    Thanks you two. I just added if (!$Session->IsValid()) return FALSE; to the search model, then handled it in search's index.php:

    if ($this->SearchResults == FALSE) { echo '<p class="NoResults">', sprintf('You must be logged in to search.'), '</p>'; }

    I decided to keep the search box visible so visitors know the feature exists. They also get an incentive to register.

    Perhaps I'll turn it into a plugin once I've figured out how. I'm a bit of an amateur hacking around to be honest. I'll probably end up doing something similar once I get around to installing the Sphinx plugin.

  • Options
    mcu_hqmcu_hq yippie ki-yay ✭✭✭

    Yes, precisely - good job. That was really all there was to it.

    I get around to installing the Sphinx plugin

    You can issue a pull request here once you implement a feature like this.

  • Options

    Cool, just reading your github page now. I'd like to use your plugin as a straightforward replacement for the Vanilla Search. I'd rather go without the various widgets and UI dropdowns, etc. Would you consider making a 'barebones' edition?

  • Options
    mcu_hqmcu_hq yippie ki-yay ✭✭✭

    you can disable them in the plugin's dashboard

  • Options
    50sQuiff50sQuiff ✭✭
    edited October 2012

    (I find it highly unlikely someone would flood search.)

    I recently witnessed a DDoS using search queries that took down one of my employer's biggest sites. Search had to be disabled until the attackers gave up. So I do think this issue is worth exploring. Now I'm wondering if a flood of POST requests (to /getnew for example) could do some damage too.

    you can disable them in the plugin's dashboard

    Thank you.

Sign In or Register to comment.