app/controllers/search_controller.rb
# Same as #smart, but for abusing users or bots. (It uses a ReCAPTCHA verification.)
#
# === Params
# - 'q': the query string
# - 'u': '1' for an unlimited search, anything else forces RESULTS_LIMIT for each result block
# - 'e': entity type for the specialized search ('s': swimmers, 't': team, 'p': pool, 'm': meeting)
# - 'f': 1 == captcha fail (used only in the views)
#
Same as #smart, but for abusing users or bots.
Same as #smart but for abusing users or bots .
def smart_with_captcha
    redirect_to search_smart_path( q: params['q'], u: params['u'], e: params['e'] ) and return if Rails.application.secrets.recaptcha_site_key.nil?
    if request.xhr? && params['q'].present?
      @captcha_ok = verify_recaptcha
      @query = params['q']
      @limitless = ( params['u'] == '1' )
      if @captcha_ok
        prepare_query_results( params['q'], params['e'] )
      else
        @swimmers = []
        @teams = []
        @pools = []
        @meetings = []
      end
    end
    @title = I18n.t('general.smart_search')
    respond_to do |format|
      format.html
      format.js
    end
  end
def smart_with_captcha redirect_to search_smart_path ( q : params [ 'q' ] , u : params [ 'u' ] , e : params [ 'e' ] ) and return if Rails . application . secrets . recaptcha_site_key . nil? if request . xhr? && params [ 'q' ] . present? @captcha_ok = verify_recaptcha @query = params [ 'q' ] @limitless = ( params [ 'u' ] == '1' ) if @captcha_ok prepare_query_results ( params [ 'q' ] , params [ 'e' ] ) else @swimmers = [ ] @teams = [ ] @pools = [ ] @meetings = [ ] end end @title = I18n . t ( 'general.smart_search' ) respond_to do | format | format . html format . js end end
Same as #smart, but for abusing users or bots.
Same as #smart but for abusing users or bots .
# Avoid crashes if the captcha site key is nil: # DEBUG #    logger.debug( "\r\n\r\n!! ------ #{self.class.name} -----" ) #    logger.debug( "> #{params.inspect}" ) # AJAX request? Parse parameter and retrieve records range: # Respond according to requested format (GET request => .html, AJAX request => .js)