OK, here's a small UDF that includes Ryan's list of search URL's.  The list
is embedded in CFScript per Ray Camden's request so the UDF is not dependent
on an outside file.  The format for the data is pretty straightforward, url
and possible search criteria keys.

As of right not it creates the patterns structure outside the UDF and caches
it in Application scope, which violates some of cflib.org's standards, so I
may have to modify before submitting, moving the structKeyExists check
inside the UDF.

If anyone has time, please test it out.  I'll submit to cflib.org shortly.

Thanks,

Sam

----------------------------------------------
Blog:  http://www.rewindlife.com
Chart: http://www.blinex.com/products/charting
----------------------------------------------



<!---
      getReferringSearch

      Extracts the search criteria from the referrer, or a supplied URL.

      Thanks to Ryan Hagan for providing a detailed list of search urls.

      Samuel Neff ([EMAIL PROTECTED])
--->

<cfscript>


   if (not structKeyExists(application, "getReferringSearchPatterns")) {

      s = structNew();

      s["http://altavista.com/sites/search/web";] = "q";
      s["http://altavista.com/web/results";] = "q";
      s["http://br.altavista.com/web/results";] = "q";
      s["http://de.altavista.com/web/results";] = "q";
      s["http://de.altavista.com/web/results/";] = "aqa";
      s["http://es.altavista.com/web/results";] = "q";
      s["http://it.altavista.com/web/results";] = "q";
      s["http://se.altavista.com/web/results";] = "q";
      s["http://uk.altavista.com/web/results";] = "q";
      s["http://www.altavista.com/sites/search/web";] = "q";
      s["http://www.altavista.com/web/results";] = "q";
      s["http://www.altavista.cz/web/results";] = "q";
      s["http://aolsearch.aol.ca/dirsearch.adp";] = "query";
      s["http://search.dogpile.com/texis/search";] = "q";
      s["http://search.earthlink.net/search";] = "q";
      s["http://www.findology.com/2.php";] = "q";
      s["http://go.google.com/hws/search";] = "q";
      s["http://www.google.at/search";] = "q";
      s["http://www.google.be/search";] = "q";
      s["http://www.google.ca/search";] = "q,as_epq";
      s["http://www.google.ch/search";] = "q";
      s["http://www.google.cl/search";] = "q";
      s["http://www.google.co.cr/search";] = "q";
      s["http://www.google.co.hu/search";] = "q";
      s["http://www.google.co.il/search";] = "q";
      s["http://www.google.co.in/search";] = "q";
      s["http://www.google.co.nz/search";] = "q";
      s["http://www.google.co.th/search";] = "q";
      s["http://www.google.co.uk/search";] = "q";
      s["http://www.google.co.ve/search";] = "q";
      s["http://www.google.com.ar/search";] = "q";
      s["http://www.google.com.au/search";] = "as_epq";
      s["http://www.google.com.br/search";] = "q";
      s["http://www.google.com.hk/search";] = "q";
      s["http://www.google.com.mx/search";] = "q";
      s["http://www.google.com.pe/search";] = "q";
      s["http://www.google.com.ru/search";] = "q";
      s["http://www.google.com.tr/search";] = "q";
      s["http://www.google.com.tw/search";] = "q";
      s["http://www.google.com/custom";] = "q";
      s["http://www.google.com/ie";] = "q";
      s["http://www.google.com/search";] = "q,as_q,as_epq";
      s["http://www.google.de/search";] = "q,as_epq";
      s["http://www.google.fi/search";] = "q";
      s["http://www.google.fr/search";] = "q,as_q";
      s["http://www.google.ie/search";] = "q";
      s["http://www.google.it/search";] = "q,as_epq";
      s["http://www.google.nl/search";] = "q";
      s["http://www.google.pl/search";] = "q";
      s["http://www.google.pt/search";] = "q";
      s["http://search.iwon.com/commerce/google.jsp";] = "searchfor";
      s["http://search.lycos.com/default.asp";] = "query";
      s["http://search.metacrawler.com/texis/search";] = "q";
      s["http://auto.search.msn.com/results.asp";] = "q";
      s["http://search.msn.com.mx/results.aspx";] = "q";
      s["http://search.msn.com.tw/spresults.aspx";] = "q";
      s["http://search.msn.com/pass/results.aspx";] = "q";
      s["http://search.msn.com/preview.aspx";] = "q";
      s["http://search.msn.com/results.asp";] = "q";
      s["http://search.msn.com/results.aspx";] = "q";
      s["http://search.msn.com/spresults.aspx";] = "q";
      s["http://search.msn.nl/results.aspx";] = "q";
      s["http://search.netscape.com/nscp_results.adp";] = "query";
      s["http://aolsearch.aol.com/aol/search";] = "query";
      s["http://eplansekits.com/cgi-bin/smartsearch/smartsearch.cgi";] =
"keywords";
      s["http://ms108.mysearch.com/jsp/AVweb.jsp";] = "searchfor";
      s["http://rr.looksmart.com/r_search";] = "key";
      s["http://search.cometsystems.com/search.php";] = "qry";
      s["http://search.virgilio.it/search/cgi/search.cgi";] = "qs";
      s["http://www.1stblaze.com/rel_search.phtml";] = "xml_kwd";
      s["http://www.agoodsearch.com/find.php";] = "terms";
      s["http://www.att.net/cgi-bin/websearch";] = "qry,as_q";
      s["http://www.browserwise.com/search/search.cgi";] = "Terms";
      s["http://www.coolwebsearch.com/search.php";] = "qq";
      s["http://www.findtarget.com/cb/hotsheet.php";] = "q";
      s["http://www.go-in-search.com/selink.php";] = "terms";
      s["http://www.hotbot.com/default.asp";] = "query";
      s["http://www.mywebsearch.com/jsp/GGweb.jsp";] = "searchfor";
      s["http://www.overture.com/d/search/p/juno/";] = "Keywords";
      s["http://www.search.com/search";] = "q";
      s["http://www.searchalot.com/texis/open/meta";] = "q";
      s["http://www.search-casual.com/selink.php";] = "terms";
      s["http://www.searches-easy.com/selink.php";] = "terms";
      s["http://www.searchfiend.com/search.php";] = "keyword";
      s["http://www.searching-easy.com/selink.php";] = "terms";
      s["http://www.searching-ez.com/selink.php";] = "terms";
      s["http://www.searchit.com/search.php";] = "keywords";
      s["http://www.searchtopper.com/search.php";] = "s";
      s["http://www.sqwire.com/query.php";] = "kw";
      s["http://b.search.yahoo.com/bin/search";] = "p";
      s["http://ca.google.yahoo.com/bin/query_ca";] = "p";
      s["http://ca.search.yahoo.com/search/ca";] = "p";
      s["http://cn.websearch.yahoo.com/search/web_cn";] = "p";
      s["http://google.yahoo.com/bin/query";] = "p";
      s["http://search.yahoo.com/bin/query_msie";] = "p";
      s["http://search.yahoo.com/bin/search";] = "p";
      s["http://search.yahoo.com/search";] = "p,va";
      s["http://search.yahoo.com/search/msie";] = "p";

      application.getReferringSearchPatterns = s;
   }

</cfscript>

<cffunction name="getReferringSearch" returnType="string" output="false">

   <cfargument name="testUrl" type="string" required="false">

   <cfset var s ="">
   <cfset var refererSplit = "">
   <cfset var p = "">
   <cfset var i = "">

   <cfparam name="arguments.testUrl" default="#cgi.http_referer#">

   <cfif arguments.testUrl neq "">
      <cfset refererSplit = listToArray(arguments.testUrl, "?")>
      <cfif arrayLen(refererSplit) GTE 2 and
            structKeyExists(
               application.getReferringSearchPatterns,
               refererSplit[1])>

         <cfset u = listToArray(refererSplit[2],"&")>

         <cfloop
            index="p"

list="#application.getReferringSearchPatterns[refererSplit[1]]#">

            <cfloop index="i" from="1" to="#arrayLen(u)#">
               <cfif listGetAt(u[i], 1, "=") is p>
                  <cfset s = listGetAt(u[i], 2, "=")>
                  <cfbreak>
               </cfif>
            </cfloop>
         </cfloop>

      </cfif>
   </cfif>

   <cfreturn s>

</cffunction>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

Reply via email to