<commit_before>class ApplicationController < ActionController::Base

  helper_method :terms_cookie

  protect_from_forgery with: :exception

  before_action :check_browser

  def not_found
    raise ActionController::RoutingError.new('Not Found')
  end

  def accept_terms
    session[:return_to] = params[:return_to] unless params[:return_to].nil?
    @title = 'Terms of Service'
  end

  private

    def check_browser
      unless UserAgentValidator.user_agent_supported? request.user_agent
        redirect_to "/notsupportedbrowser"
      end
    end

    def check_terms
      session[:return_to] = request.fullpath
      redirect_to accept_terms_path if show_terms?
    end

    def show_terms?
      !(is_ip_whitelisted_from_terms? ||
        is_embed_request? ||
        terms_cookie ||
        is_exempt_from_terms?)
    end

    def is_ip_whitelisted_from_terms?
      @whitelist = [
        '192.168.3.11',
        # '127.0.0.1'
      ]

      @whitelist.include?(request.remote_ip)<commit_msg>ToS: filter to appear only on PRO<commit_after>class ApplicationController < ActionController::Base

  helper_method :terms_cookie

  protect_from_forgery with: :exception

  before_action :check_browser

  def not_found
    raise ActionController::RoutingError.new('Not Found')
  end

  def accept_terms
    session[:return_to] = params[:return_to] unless params[:return_to].nil?
    @title = 'Terms of Service'
  end

  private

    def check_browser
      unless UserAgentValidator.user_agent_supported? request.user_agent
        redirect_to "/notsupportedbrowser"
      end
    end

    def check_terms
      puts request.original_url.to_s
      if request.original_url.to_s.include? "globalforestwatch.org"
        #Filtering accept terms only in PRO

        session[:return_to] = request.fullpath
        redirect_to accept_terms_path if show_terms?
      end
    end

    def show_terms?
      !(is_ip_whitelisted_from_terms? ||
        is_embed_request? ||
        terms_cookie ||
        is_exempt_from_terms?)
    end

    def is_ip_whitelisted_from_terms?
      @whitelist = [
        '192.168.3.11',
        # '127.0.0.1'
      ]

      @whitelist.include?(request.remote_ip)
{'fraction_non_alphanumeric': 0.0788514129443938, 'fraction_numerical': 0.013673655423883319, 'mean_word_length': 3.0054744525547443, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2545264', 'n_tokens_mistral': 730, 'n_tokens_neox': 677, 'n_words': 135}