Click here to Skip to main content
15,888,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get keywords that you can find on my website

example me code

pcboxsearch.class.php

PHP
<?php

class search_keywords
{
    var $referer;
    var $search_engine;
    var $keys;
    var $sep;
    function search_keywords()
    {
        $this->referer = '';
        $this->sep = '';
        if ($_SERVER['HTTP_REFERER'] OR $_ENV['HTTP_REFERER'])
        {
            $this->referer = urldecode(($_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : $_ENV['HTTP_REFERER']));
            $this->sep = (eregi('(\?q=|\?qt=|\?p=)', $this->referer)) ? '\?' : '\&';
        }
    }

    function get_keys()
    {
        if (!empty($this->referer))
        {
            if (eregi('www\.google', $this->referer))
            {
                // Google
                preg_match("#{$this->sep}q=(.*?)\&#si", $this->referer, $this->keys);
                $this->search_engine = 'Google';
            }
            else if (eregi('(yahoo\.com|search\.yahoo)', $this->referer))
            {
                // Yahoo
                preg_match("#{$this->sep}p=(.*?)\&#si", $this->referer, $this->keys);
                $this->search_engine = 'Yahoo';
            }
            else if (eregi('search\.msn', $this->referer))
            {
                // MSN
                preg_match("#{$this->sep}q=(.*?)\&#si", $this->referer, $this->keys);
                $this->search_engine = 'MSN';
            }
            else if (eregi('www\.alltheweb', $this->referer))
            {
                // AllTheWeb
                preg_match("#{$this->sep}q=(.*?)\&#si", $this->referer, $this->keys);
                $this->search_engine = 'AllTheWeb';
            }
            else if (eregi('(looksmart\.com|search\.looksmart)', $this->referer))
            {
                // Looksmart
                preg_match("#{$this->sep}qt=(.*?)\&#si", $this->referer, $this->keys);
                $this->search_engine = 'Looksmart';
            }
            else if (eregi('(askjeeves\.com|ask\.com)', $this->referer))
            {
                // AskJeeves
                preg_match("#{$this->sep}q=(.*?)\&#si", $this->referer, $this->keys);
                $this->search_engine = 'AskJeeves';
            }
            else
            {
                $this-> keys = 'Not available';
                $this->search_engine = 'Unknown';
            }
            return array(
                $this->referer,
                (!is_array($this->keys) ? $this->keys : $this->keys[1]),
                $this->search_engine
            );
        }
        return array();
    }
}

?>


index.php
PHP
<?php
require_once('./pcboxsearch.class.php');
$keys =& new search_keywords();
$keys = $keys->get_keys();
$url ='a href="http://www.pcboxsearch.com/search.php?q="';
if (count($keys))
{
    echo "You're directed to this page from <b>$keys[2]</b> search engine, within Keywords <b>$url$keys[1]</a> </b> If   you Like Pcboxsearch Found You search<br>";
}
?>


output code index.php

You're directed to this page from "google" search engine, within Keywords "code poject" If you Like Pcboxsearch Found You search


I've tried this keyword not respont

$url ='href="http://www.pcboxsearch.com/search.php?q='+ $keys[1];

questions

how to combine keywords found make url

example, if found "projec code" becomes url = http://www.pcboxsearch.com/search.php?q=code projec

because me code not response keyword "http://www.pcboxsearch.com/search.php?q="

Can you help me where do I join as a url into my search engine
Posted
Updated 17-Feb-10 22:57pm
v5

1 solution

There is a Tip/Trick here on the code project which does what you want.

Catching Keyword from Search[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900