<commit_before>class ProxyEngine::UtilsController < ApplicationController
  
  def proxy
    
    # We want to grab params that are part of the requested URL, but ignore ones that are supplied by Rails
    ignored_params = ["proxy_url", "action", "controller"]
    url_params = params.reject{|param, val| ignored_params.include?(param) }.collect{ |param, val| param + '=' + CGI.escape(val) }.join('&')
    url = params[:proxy_url]
    if url.blank?
      render :text => ''
      return
    end
    url += '&' + url_params unless url_params.blank?
    url = "http://www.thlib.org" + url if url[0,1] == "/"
    
    # Any "&"s in the url sent to wiki_reader.php need to be replaced by "%26"
    if url =~ /wiki_reader\.php\?url=/
      url_split = url.split("wiki_reader.php?url=")
      url_split[1].gsub!("&", "%26")
      url = url_split.join("wiki_reader.php?url=")
    end
    
    # Parse the URL with URI.parse() so we can work with its parts more easily
    uri = URI.parse(URI.encode(url));
    requested_host = uri.host
    headers = {}
    
    # Check to see if the request is for a URL on thlib.org or a subdomain; if so, and if
    # this is being run on sds[3-8], make the appropriate changes to headers and uri.host
    if requested_host =~ /thlib.org/
      server_host = Socket.gethostname.downcase
      if server_host =~ /sds[3-8].itc.virginia.edu/
        headers = { 'Host' => requested_host }
        uri.host = '127.0.0.1'
      end
    end
    <commit_msg>using dinamic thl site from thl integration<commit_after>class ProxyEngine::UtilsController < ApplicationController
  
  def proxy
    
    # We want to grab params that are part of the requested URL, but ignore ones that are supplied by Rails
    ignored_params = ["proxy_url", "action", "controller"]
    url_params = params.reject{|param, val| ignored_params.include?(param) }.collect{ |param, val| param + '=' + CGI.escape(val) }.join('&')
    url = params[:proxy_url]
    if url.blank?
      render :text => ''
      return
    end
    url += '&' + url_params unless url_params.blank?
    url = ThlSite.get_url + url if url[0,1] == "/"
    
    # Any "&"s in the url sent to wiki_reader.php need to be replaced by "%26"
    if url =~ /wiki_reader\.php\?url=/
      url_split = url.split("wiki_reader.php?url=")
      url_split[1].gsub!("&", "%26")
      url = url_split.join("wiki_reader.php?url=")
    end
    
    # Parse the URL with URI.parse() so we can work with its parts more easily
    uri = URI.parse(URI.encode(url));
    requested_host = uri.host
    headers = {}
    
    # Check to see if the request is for a URL on thlib.org or a subdomain; if so, and if
    # this is being run on sds[3-8], make the appropriate changes to headers and uri.host
    if requested_host =~ /thlib.org/
      server_host = Socket.gethostname.downcase
      if server_host =~ /sds[3-8].itc.virginia.edu/
        headers = { 'Host' => requested_host }
        uri.host = '127.0.0.1'
      end
    end
    
{'fraction_non_alphanumeric': 0.12738853503184713, 'fraction_numerical': 0.011397921555481059, 'mean_word_length': 2.7393483709273183, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 2, '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': '5388308', 'n_tokens_mistral': 995, 'n_tokens_neox': 988, 'n_words': 300}