<?php

         // ini contoh isinya 
         $data = <<< EOT
<html>
<head>
  <title>Test</title>
</head>
<body>
Halo, selamat datang di BengkelProgram.com
kunjungi situsnya di http://www.bengkelprogram.com
atau situs kampusku: <a href='http://www.stiki.ac.id'>STIKI Malang</a>
<br>
<br>
Aryo Sanjaya<br>
aryo.sanjaya@gmail.com
</body>
</html>
EOT;
         
         $doc_ref = $_SERVER['HTTP_REFERER'];
         $host_info = parse_url($doc_ref);
         $query = isset($host_info['query']) ? $host_info['query'] : "";

         if ($query)
         {
             $querylist = explode("&", $query);
             foreach($querylist as $item)
             {
                     list($param, $value) = explode("=", $item);
                     if (testParam(strtolower($host_info['host']), $param))
                     {
                         $value = rawurldecode($value);
                         $value = str_replace("'", "", $value);
                         $value = str_replace("\"", "", $value);
                         $value = str_replace("'", "", $value);
                         $value = str_replace("+", " ", $value);
                         $searchlist = explode(" ", $value);
                         break;
                     }
             }
         }

         if (is_array($searchlist))
         {
               $cols = array( "#000000" => "#ffff00",
                              "#ffffff" => "#0000ff",
                              "#ffffff" => "#00ff00",
                              "#ffffff" => "#ff0000",
                              "#ff0000" => "#ffff00");

               foreach($searchlist as $list)
               {
                       $fg = key($cols);
                       $bg = current($cols);
                       $data = preg_replace("/(.*)($list)(.*)/i", 
                                        "\\1<span style=\"color: $fg; background-color: $bg\">\\2</span>\\3", 
                                        $data);
                       if (!next($cols))
                            reset($cols);
               }
         }
         
         echo $data;

function testParam($host, $param)
{
        $listparam = array("yahoo." => "p",
                           "google." => "q",
                           "msn." => "q");
        foreach($listparam as $part => $val)
        {
                if ((strpos($host, $part, 0)) && ($param == $val)) return 1;
        }
        return 0;
}

?>