function hilite($text)
{
    $search_engines = array('google', 'lycos', 'yahoo', 'fork');
    foreach ($search_engines as $null => $engine) {
        if (is_referer_search_engine($engine)) {
            $query_terms = get_search_query_terms($engine);
            foreach ($query_terms as $null => $term) {
                if (!empty($term) && $term != ' ') {
                    if (!preg_match('/<.+>/', $text)) {
                        $text = preg_replace('/(\\b' . $term . '\\b)/i', '<span class="hilite">$1</span>', $text);
                    } else {
                        $text = preg_replace('/(?<=>)([^<]+)?(\\b' . $term . '\\b)/i', '$1<span class="hilite">$2</span>', $text);
                    }
                }
            }
            break;
        }
    }
    return $text;
}
Example #2
0
function hilite_tags($tags)
{
    $query_terms = array_filter(array_map('trim', get_search_query_terms()));
    // tags are kept escaped in the db
    $query_terms = array_map('esc_html', $query_terms);
    foreach (array_filter((array) $tags) as $tag) {
        if (in_array(trim($tag->name), $query_terms)) {
            $tag->name = "<span class='hilite'>" . $tag->name . "</span>";
        }
    }
    return $tags;
}
Example #3
0
function cpg_determine_client($pid)
{
    global $CONFIG;
    /**
     * Populate the client stats
     */
    // Get the details of user browser, IP, OS, etc
    $os = "Unknown";
    if (eregi("Linux", $_SERVER["HTTP_USER_AGENT"])) {
        $os = "Linux";
    } else {
        if (eregi("Ubuntu", $_SERVER["HTTP_USER_AGENT"])) {
            $os = "Linux Ubuntu";
        } else {
            if (eregi("Debian", $_SERVER["HTTP_USER_AGENT"])) {
                $os = "Linux Debian";
            } else {
                if (eregi("Windows NT 5.0", $_SERVER["HTTP_USER_AGENT"])) {
                    $os = "Windows 2000";
                } else {
                    if (eregi("win98|Windows 98", $_SERVER["HTTP_USER_AGENT"])) {
                        $os = "Windows 98";
                    } else {
                        if (eregi("Windows NT 5.1", $_SERVER["HTTP_USER_AGENT"])) {
                            $os = "Windows XP";
                        } else {
                            if (eregi("Windows NT 5.2", $_SERVER["HTTP_USER_AGENT"])) {
                                $os = "Windows 2003 Server";
                            } else {
                                if (eregi("Windows NT 6.0", $_SERVER["HTTP_USER_AGENT"])) {
                                    $os = "Windows Vista";
                                } else {
                                    if (eregi("Windows CE", $_SERVER["HTTP_USER_AGENT"])) {
                                        $os = "Windows CE";
                                    } else {
                                        if (eregi("Windows", $_SERVER["HTTP_USER_AGENT"])) {
                                            $os = "Windows";
                                        } else {
                                            if (eregi("SunOS", $_SERVER["HTTP_USER_AGENT"])) {
                                                $os = "Sun OS";
                                            } else {
                                                if (eregi("Macintosh", $_SERVER["HTTP_USER_AGENT"])) {
                                                    $os = "Macintosh";
                                                } else {
                                                    if (eregi("Mac_PowerPC", $_SERVER["HTTP_USER_AGENT"])) {
                                                        $os = "Mac OS";
                                                    } else {
                                                        if (eregi("Mac_PPC", $_SERVER["HTTP_USER_AGENT"])) {
                                                            $os = "Macintosh";
                                                        } else {
                                                            if (eregi("OS/2", $_SERVER["HTTP_USER_AGENT"])) {
                                                                $os = "OS/2";
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $browser = 'Unknown';
    if (eregi("MSIE", $_SERVER["HTTP_USER_AGENT"])) {
        if (eregi("MSIE 5.5", $_SERVER["HTTP_USER_AGENT"])) {
            $browser = "IE5.5";
        } else {
            if (eregi("MSIE 6.0", $_SERVER["HTTP_USER_AGENT"])) {
                $browser = "IE6";
            } else {
                if (eregi("MSIE 7.0", $_SERVER["HTTP_USER_AGENT"])) {
                    $browser = "IE7";
                } else {
                    if (eregi("MSIE 3.0", $_SERVER["HTTP_USER_AGENT"])) {
                        $browser = "IE3";
                    } else {
                        if (eregi("MSIE 4.0", $_SERVER["HTTP_USER_AGENT"])) {
                            $browser = "IE4";
                        } else {
                            if (eregi("MSIE 5.0", $_SERVER["HTTP_USER_AGENT"])) {
                                $browser = "IE5.0";
                            }
                        }
                    }
                }
            }
        }
    } else {
        if (eregi("Firebird", $_SERVER["HTTP_USER_AGENT"])) {
            $browser = "Mozilla Firebird";
        } else {
            if (eregi("netscape", $_SERVER["HTTP_USER_AGENT"])) {
                $browser = "Netscape";
            } else {
                if (eregi("Firefox", $_SERVER["HTTP_USER_AGENT"])) {
                    $browser = "Firefox";
                } else {
                    if (eregi("Galeon", $_SERVER["HTTP_USER_AGENT"])) {
                        $browser = "Galeon";
                    } else {
                        if (eregi("Camino/", $_SERVER["HTTP_USER_AGENT"])) {
                            $browser = "Camino/";
                        } else {
                            if (eregi("Konqueror", $_SERVER["HTTP_USER_AGENT"])) {
                                $browser = "Konqueror";
                            } else {
                                if (eregi("Safari", $_SERVER["HTTP_USER_AGENT"])) {
                                    $browser = "Safari";
                                } else {
                                    if (eregi("OmniWeb", $_SERVER["HTTP_USER_AGENT"])) {
                                        $browser = "OmniWeb";
                                    } else {
                                        if (eregi("Opera", $_SERVER["HTTP_USER_AGENT"])) {
                                            $browser = "Opera";
                                        } else {
                                            if (eregi("amaya", $_SERVER["HTTP_USER_AGENT"])) {
                                                $browser = "Amaya";
                                            } else {
                                                if (eregi("iCab", $_SERVER["HTTP_USER_AGENT"])) {
                                                    $browser = "iCab";
                                                } else {
                                                    if (eregi("Lynx", $_SERVER["HTTP_USER_AGENT"])) {
                                                        $browser = "Lynx";
                                                    } else {
                                                        if (eregi("Googlebot", $_SERVER["HTTP_USER_AGENT"])) {
                                                            $browser = "Googlebot";
                                                        } else {
                                                            if (eregi("Lycos_Spider", $_SERVER["HTTP_USER_AGENT"])) {
                                                                $browser = "Lycos Spider";
                                                            } else {
                                                                if (eregi("Firefly", $_SERVER["HTTP_USER_AGENT"])) {
                                                                    $browser = "Fireball Spider";
                                                                } else {
                                                                    if (eregi("Advanced Browser", $_SERVER["HTTP_USER_AGENT"])) {
                                                                        $browser = "Avant";
                                                                    } else {
                                                                        if (eregi("Amiga-AWeb", $_SERVER["HTTP_USER_AGENT"])) {
                                                                            $browser = "AWeb";
                                                                        } else {
                                                                            if (eregi("Cyberdog", $_SERVER["HTTP_USER_AGENT"])) {
                                                                                $browser = "Cyberdog";
                                                                            } else {
                                                                                if (eregi("Dillo", $_SERVER["HTTP_USER_AGENT"])) {
                                                                                    $browser = "Dillo";
                                                                                } else {
                                                                                    if (eregi("DreamPassport", $_SERVER["HTTP_USER_AGENT"])) {
                                                                                        $browser = "DreamCast";
                                                                                    } else {
                                                                                        if (eregi("eCatch", $_SERVER["HTTP_USER_AGENT"])) {
                                                                                            $browser = "eCatch";
                                                                                        } else {
                                                                                            if (eregi("ANTFresco", $_SERVER["HTTP_USER_AGENT"])) {
                                                                                                $browser = "Fresco";
                                                                                            } else {
                                                                                                if (eregi("RSS", $_SERVER["HTTP_USER_AGENT"])) {
                                                                                                    $browser = "RSS";
                                                                                                } else {
                                                                                                    if (eregi("Avant", $_SERVER["HTTP_USER_AGENT"])) {
                                                                                                        $browser = "Avant";
                                                                                                    } else {
                                                                                                        if (eregi("HotJava", $_SERVER["HTTP_USER_AGENT"])) {
                                                                                                            $browser = "HotJava";
                                                                                                        } else {
                                                                                                            if (eregi("W3C-checklink|W3C_Validator|Jigsaw", $_SERVER["HTTP_USER_AGENT"])) {
                                                                                                                $browser = "W3C";
                                                                                                            } else {
                                                                                                                if (eregi("K-Meleon", $_SERVER["HTTP_USER_AGENT"])) {
                                                                                                                    $browser = "K-Meleon";
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    //Code to get the search string if the referrer is any of the following
    $search_engines = array('google', 'lycos', 'yahoo');
    foreach ($search_engines as $engine) {
        if (is_referer_search_engine($engine)) {
            $query_terms = get_search_query_terms($engine);
            break;
        }
    }
    $return_array = array('os' => $os, 'browser' => $browser, 'query_term' => $query_terms);
    return $return_array;
}
function cpg_determine_client()
{
    //Making Cage
    $superCage = Inspekt::makeSuperCage();
    /**
     * Populate the client stats
     */
    // Get the details of user browser, IP, OS, etc
    $server_agent = $superCage->server->getRaw('HTTP_USER_AGENT');
    $os = 'Unknown';
    if (preg_match('#Ubuntu#i', $server_agent)) {
        $os = 'Linux Ubuntu';
    } elseif (preg_match('#Debian#i', $server_agent)) {
        $os = 'Linux Debian';
    } elseif (preg_match('#CentOS#i', $server_agent)) {
        $os = 'Linux CentOS';
    } elseif (preg_match('#Fedora#i', $server_agent)) {
        $os = 'Linux Fedora';
    } elseif (preg_match('#Mandrake#i', $server_agent)) {
        $os = 'Linux Mandrake';
    } elseif (preg_match('#RedHat#i', $server_agent)) {
        $os = 'Linux RedHat';
    } elseif (preg_match('#Suse#i', $server_agent)) {
        $os = 'Linux Suse';
    } elseif (preg_match('#Linux#i', $server_agent)) {
        $os = 'Linux';
    } elseif (preg_match('#Windows NT 5.0#i', $server_agent)) {
        $os = 'Windows 2000';
    } elseif (preg_match('#win98|Windows 98#i', $server_agent)) {
        $os = 'Windows 98';
    } elseif (preg_match('#Windows NT 5\\.1#i', $server_agent)) {
        $os = 'Windows XP';
    } elseif (preg_match('#Windows NT 5\\.2#i', $server_agent)) {
        $os = 'Windows 2003 Server';
    } elseif (preg_match('#Windows NT 6\\.0#i', $server_agent)) {
        $os = 'Windows Vista';
    } elseif (preg_match('#Windows NT 6\\.1#i', $server_agent)) {
        $os = 'Windows 7';
    } elseif (preg_match('#Windows NT 6\\.2#i', $server_agent)) {
        $os = 'Windows 8';
    } elseif (preg_match('#Windows CE#i', $server_agent)) {
        $os = 'Windows CE';
    } elseif (preg_match('#Windows#i', $server_agent)) {
        $os = 'Windows';
    } elseif (preg_match('#SunOS#i', $server_agent)) {
        $os = 'Sun OS';
    } elseif (preg_match('#Macintosh#i', $server_agent)) {
        $os = 'Macintosh';
    } elseif (preg_match('#Mac_PowerPC#i', $server_agent)) {
        $os = 'Mac OS';
    } elseif (preg_match('#Mac_PPC#i', $server_agent)) {
        $os = 'Macintosh';
    } elseif (preg_match('#OS/2#i', $server_agent)) {
        $os = 'OS/2';
    } elseif (preg_match('#aix#i', $server_agent)) {
        $os = 'aix';
    } elseif (preg_match('#FreeBSD#i', $server_agent)) {
        $os = 'BSD FreeBSD';
    } elseif (preg_match('#Unix#i', $server_agent)) {
        $os = 'Unix';
    } elseif (preg_match('#iphone#i', $server_agent)) {
        $os = 'iPhone';
    } elseif (preg_match('#Nintendo Wii#i', $server_agent)) {
        $os = 'Nintendo Wii';
    } elseif (preg_match('#PalmOS#i', $server_agent)) {
        $os = 'PalmOS';
    } elseif (preg_match('#Symbian#i', $server_agent)) {
        $os = 'Symbian';
    } elseif (preg_match('#PLAYSTATION 3#i', $server_agent)) {
        $os = 'Playstation 3';
    } elseif (preg_match('#PlayStation Portable#i', $server_agent)) {
        $os = 'Playstation Portable';
    } elseif (preg_match('#Playstation#i', $server_agent)) {
        $os = 'Playstation';
    } elseif (preg_match('#Inferno#i', $server_agent)) {
        $os = 'Inferno';
    } elseif (preg_match('#BeOS#i', $server_agent)) {
        $os = 'beOS';
    }
    $browser = 'Unknown';
    if (preg_match('#MSIE#i', $server_agent)) {
        if (preg_match('#MSIE 10\\.0#i', $server_agent)) {
            $browser = 'IE10';
        } elseif (preg_match('#MSIE 9\\.0#i', $server_agent)) {
            $browser = 'IE9';
        } elseif (preg_match('#MSIE 8\\.0#i', $server_agent)) {
            $browser = 'IE8';
        } elseif (preg_match('#MSIE 7\\.0#i', $server_agent)) {
            $browser = 'IE7';
        } elseif (preg_match('#MSIE 6\\.0#i', $server_agent)) {
            $browser = 'IE6';
        } elseif (preg_match('#MSIE 5\\.5#i', $server_agent)) {
            $browser = 'IE5.5';
        } elseif (preg_match('#MSIE 5\\.0#i', $server_agent)) {
            $browser = 'IE5.0';
        } elseif (preg_match('#MSIE 4\\.0#i', $server_agent)) {
            $browser = 'IE4';
        } elseif (preg_match('#MSIE 3\\.0#i', $server_agent)) {
            $browser = 'IE3';
        } else {
            $browser = 'IE';
        }
    } elseif (preg_match('#Nitro#i', $server_agent)) {
        $browser = 'Nintendo DS';
    } elseif (preg_match('#Nokia#i', $server_agent)) {
        $browser = 'Nokia';
    } elseif (preg_match('#iPhone#i', $server_agent)) {
        $browser = 'iPhone';
    } elseif (preg_match('#Epiphany#i', $server_agent)) {
        $browser = 'Epiphany';
    } elseif (preg_match('#Flock#i', $server_agent)) {
        $browser = 'Flock';
    } elseif (preg_match('#SeaMonkey#i', $server_agent)) {
        $browser = 'SeaMonkey';
    } elseif (preg_match('#Phoenix#i', $server_agent)) {
        $browser = 'Phoenix';
    } elseif (preg_match('#Firebird#i', $server_agent)) {
        $browser = 'Mozilla Firebird';
    } elseif (preg_match('#NetSurf#i', $server_agent)) {
        $browser = 'NetSurf';
    } elseif (preg_match('#netscape#i', $server_agent)) {
        $browser = 'Netscape';
    } elseif (preg_match('#Chrome#i', $server_agent)) {
        $browser = 'Chrome';
    } elseif (preg_match('#Firefox#i', $server_agent)) {
        $browser = 'Firefox';
    } elseif (preg_match('#Galeon#i', $server_agent)) {
        $browser = 'Galeon';
    } elseif (preg_match('#Camino#i', $server_agent)) {
        $browser = 'Camino';
    } elseif (preg_match('#Konqueror#i', $server_agent)) {
        $browser = 'Konqueror';
    } elseif (preg_match('#Cheshire#i', $server_agent)) {
        $browser = 'AOL';
    } elseif (preg_match('#Safari#i', $server_agent)) {
        $browser = 'Safari';
    } elseif (preg_match('#OmniWeb#i', $server_agent)) {
        $browser = 'OmniWeb';
    } elseif (preg_match('#Opera#i', $server_agent)) {
        $browser = 'Opera';
    } elseif (preg_match('#HTTrack#i', $server_agent)) {
        $browser = 'HTTrack';
    } elseif (preg_match('#OffByOne#i', $server_agent)) {
        $browser = 'Off By One';
    } elseif (preg_match('#amaya#i', $server_agent)) {
        $browser = 'Amaya';
    } elseif (preg_match('#iCab#i', $server_agent)) {
        $browser = 'iCab';
    } elseif (preg_match('#Lynx#i', $server_agent)) {
        $browser = 'Lynx';
    } elseif (preg_match('#Googlebot#i', $server_agent)) {
        $browser = 'Googlebot';
    } elseif (preg_match('#Lycos_Spider#i', $server_agent)) {
        $browser = 'Lycos Spider';
    } elseif (preg_match('#Firefly#i', $server_agent)) {
        $browser = 'Fireball Spider';
    } elseif (preg_match('#Amiga-AWeb#i', $server_agent)) {
        $browser = 'AWeb';
    } elseif (preg_match('#Cyberdog#i', $server_agent)) {
        $browser = 'Cyberdog';
    } elseif (preg_match('#Dillo#i', $server_agent)) {
        $browser = 'Dillo';
    } elseif (preg_match('#DreamPassport#i', $server_agent)) {
        $browser = 'DreamCast';
    } elseif (preg_match('#eCatch#i', $server_agent)) {
        $browser = 'eCatch';
    } elseif (preg_match('#ANTFresco#i', $server_agent)) {
        $browser = 'Fresco';
    } elseif (preg_match('#RSS#i', $server_agent)) {
        $browser = 'RSS';
    } elseif (preg_match('#Avant#i', $server_agent)) {
        $browser = 'Avant';
    } elseif (preg_match('#HotJava#i', $server_agent)) {
        $browser = 'HotJava';
    } elseif (preg_match('#W3C-checklink|W3C_Validator|Jigsaw#i', $server_agent)) {
        $browser = 'W3C';
    } elseif (preg_match('#K-Meleon#i', $server_agent)) {
        $browser = 'K-Meleon';
    } elseif (preg_match('#Iceape#i', $server_agent)) {
        $browser = 'Iceape';
    } elseif (preg_match('#Iceweasel#i', $server_agent)) {
        $browser = 'Iceweasel';
    } elseif (preg_match('#Kazehakase#i', $server_agent)) {
        $browser = 'Kazehakase';
    } elseif (preg_match('#Minefield#i', $server_agent)) {
        $browser = 'Firefox';
    } elseif (preg_match('#Namoroka#i', $server_agent)) {
        $browser = 'Firefox';
    } elseif (preg_match('#MC680x0#i', $server_agent)) {
        $browser = 'Amiga Voyager';
    } elseif (preg_match('#AOL #i', $server_agent)) {
        $browser = 'AOL';
    } elseif (preg_match('#Beonex#i', $server_agent)) {
        $browser = 'Beonex';
    } elseif (preg_match('#BonEcho#i', $server_agent)) {
        $browser = 'Mozilla';
    } elseif (preg_match('#Charon#i', $server_agent)) {
        $browser = 'Charon';
    } elseif (preg_match('#Chimera#i', $server_agent)) {
        $browser = 'Chimera';
    } elseif (preg_match('#Crazy Browser#i', $server_agent)) {
        $browser = 'Crazy Browser';
    } elseif (preg_match('#Fennec#i', $server_agent)) {
        $browser = 'Firefox';
    } elseif (preg_match('#iNet Browser#i', $server_agent)) {
        $browser = 'iNet';
    } elseif (preg_match('#iSonyEricsson#i', $server_agent)) {
        $browser = 'Sony Ericsson';
    } elseif (preg_match('#MAXTHON#i', $server_agent)) {
        $browser = 'Maxthon';
    } elseif (preg_match('#NCSA Mosaic#i', $server_agent)) {
        $browser = 'Mosaic';
    } elseif (preg_match('#NetNewsWire#i', $server_agent)) {
        $browser = 'NetNewsWire';
    } elseif (preg_match('#NetPositive#i', $server_agent)) {
        $browser = 'NetPositive';
    } elseif (preg_match('#Shiira#i', $server_agent)) {
        $browser = 'Shiira';
    } elseif (preg_match('#Shiretoko#i', $server_agent)) {
        $browser = 'Firefox';
    } elseif (preg_match('#Sleipnir#i', $server_agent)) {
        $browser = 'Sleipnir';
    } elseif (preg_match('#Stainless#i', $server_agent)) {
        $browser = 'Stainless';
    } elseif (preg_match('#Sunrise#i', $server_agent)) {
        $browser = 'Sunrise';
    }
    // Information partially taken from http://www.useragentstring.com/
    //Code to get the search string if the referrer is any of the following
    $search_engines = array('google', 'lycos', 'yahoo');
    $query_array = array();
    foreach ($search_engines as $engine) {
        if (is_referer_search_engine($engine)) {
            $query_array = get_search_query_terms($engine);
            break;
        }
    }
    $query_terms = is_array($query_array) ? implode(',', $query_array) : '';
    $return_array = array('os' => $os, 'browser' => $browser, 'query_terms' => $query_terms);
    return $return_array;
}
Example #5
0
function hilite_tags($tags)
{
    $query_terms = get_search_query_terms();
    foreach ($query_terms as $term) {
        if (!empty($term) && $term != ' ' && !empty($tags)) {
            foreach ($tags as $tag) {
                if (!empty($tag) && $tag != ' ') {
                    if ($tag->name == $term) {
                        $tag->name = "<span class=\"hilite\">{$tag->name}</span>";
                    }
                }
            }
        }
    }
    return $tags;
}
function hilite($text)
{
    $search_engines = array('wordpress', 'google', 'lycos', 'yahoo', 'baidu');
    foreach ($search_engines as $engine) {
        if (is_referer_search_engine($engine)) {
            $query_terms = get_search_query_terms($engine);
            foreach ($query_terms as $term) {
                if (!empty($term) && $term != ' ') {
                    $term = preg_quote($term, '/');
                    if (!preg_match('/<.+>/', $text)) {
                        $text = preg_replace('/(' . $term . ')/i', '<span class="hilite">$1</span>', $text);
                    } else {
                        $text = preg_replace('/(?<=>)([^<]+)?(' . $term . ')/i', '$1<span class="hilite">$2</span>', $text);
                        //taken out the \b option to also mark substrings
                    }
                }
            }
            break;
        }
    }
    return $text;
}
Example #7
0
/**
 * add_hit()
 *
 * @param $pid
 * @return
 **/
function add_hit($pid)
{
    global $CONFIG, $raw_ip;
    cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET hits=hits+1, lasthit_ip='{$raw_ip}', mtime=CURRENT_TIMESTAMP WHERE pid='{$pid}'");
    /**
     * Code to record the details of hits for the picture, if the option is set in CONFIG
     */
    if ($CONFIG['hit_details']) {
        // Get the details of user browser, IP, OS, etc
        $os = "Unknown";
        if (eregi("Linux", $_SERVER["HTTP_USER_AGENT"])) {
            $os = "Linux";
        } else {
            if (eregi("Windows NT 5.0", $_SERVER["HTTP_USER_AGENT"])) {
                $os = "Windows 2000";
            } else {
                if (eregi("win98|Windows 98", $_SERVER["HTTP_USER_AGENT"])) {
                    $os = "Windows 98";
                } else {
                    if (eregi("Windows NT 5.1", $_SERVER["HTTP_USER_AGENT"])) {
                        $os = "Windows XP";
                    } else {
                        if (eregi("Windows", $_SERVER["HTTP_USER_AGENT"])) {
                            $os = "Windows";
                        }
                    }
                }
            }
        }
        $browser = 'Unknown';
        if (eregi("MSIE", $browser)) {
            if (eregi("MSIE 5.5", $browser)) {
                $browser = "Microsoft Internet Explorer 5.5";
            } else {
                if (eregi("MSIE 6.0", $browser)) {
                    $browser = "Microsoft Internet Explorer 6.0";
                }
            }
        } else {
            if (eregi("Mozilla Firebird", $browser)) {
                $browser = "Mozilla Firebird";
            } else {
                if (eregi("netscape", $browser)) {
                    $browser = "Netscape";
                } else {
                    if (eregi("Firefox", $browser)) {
                        $browser = "Firefox";
                    }
                }
            }
        }
        //Code to get the search string if the referrer is any of the following
        $search_engines = array('google', 'lycos', 'yahoo');
        foreach ($search_engines as $engine) {
            if (is_referer_search_engine($engine)) {
                $query_terms = get_search_query_terms($engine);
                break;
            }
        }
        $time = time();
        $referer = urlencode(addslashes($_SERVER['HTTP_REFERER']));
        // Insert the record in database
        $query = "INSERT INTO {$CONFIG['TABLE_HIT_STATS']}\n                          SET\n                            pid = {$pid},\n                            search_phrase = '{$query_terms}',\n                            Ip   = '{$raw_ip}',\n                            sdate = '{$time}',\n                            referer='{$referer}',\n                            browser = '{$browser}',\n                            os = '{$os}'";
        cpg_db_query($query);
    }
}