I Need To Be More Dorky

I just realized that it’s been weeks since I had something dorky to say (like programming or something to do with MySQL for example).

Just so you know that I am still dorky, here’s some PHP code for you (from my post over here)…

This will put the keywords that someone searched on to reach your site (works with Yahoo, AOL, MSN and Google) into the $keywords variable.

[code=php]$parse = parse_url($_SERVER[‘HTTP_REFERER’]);
$se = $parse[“host”];
$raw_var = explode(“&”, $parse[“query”] );
foreach ($raw_var as $one_var) {
$raw = explode(“=”, $one_var);
$var[$raw[0]] = urldecode ($raw[1]);
}
$se = explode (“.”, $se);
switch ($se[1]) {
case ‘yahoo’:
$keywords = $var[‘p’];
break;
case ‘aol’:
$keywords = $var[‘query’];
break;
default:
$keywords = $var[‘q’];
}
unset($parse, $se, $raw_var, $one_var, $var);[/code]

Weeeeeeeeeee! Can I go to bed now?

3 thoughts on “I Need To Be More Dorky”

  1. If you need more SE’s then here’s a bit of code from my scripts:

    [code=php]//** This part is the distinction for the search engine used to create the parameter string
    if(substr_count($l_strReferrer,”google”) || substr_count($l_strReferrer,”msn”) || substr_count($l_strReferrer,”wanadoo”) || strpos($l_strReferrer,”altavista”))
    $l_strDelimiter = “q=”;
    elseif(substr_count($l_strReferrer,”yahoo”))
    $l_strDelimiter = “p=”;
    elseif(substr_count($l_strReferrer,”aolsearch.aol”) || substr_count($l_strReferrer,”hotbot”))
    $l_strDelimiter = “query=”;
    elseif(substr_count($l_strReferrer,”uknetguide”))
    $l_strDelimiter = “Search=”;
    elseif(substr_count($l_strReferrer,”bellsouth”))
    $l_strDelimiter = “string=”;
    elseif(substr_count($l_strReferrer,”mywebsearch”) || substr_count($l_strReferrer,”mysearch.myway”))
    $l_strDelimiter = “searchfor=”;
    elseif(substr_count($l_strReferrer,”shopping”))
    $l_strDelimiter = “KW=”;
    else
    $l_strDelimiter = “q=”; [/code]

Leave a Reply

Your email address will not be published. Required fields are marked *