Sto' cercando di adattare un plugin per wp in modo che possa essere usato anche fuori da questa piattaforma. Il plugin svolge la funzione che quando un visitatore entra nel vs. sito attraverso un MdR mostra un avviso con questi termini

'Benvenuto. Sei arrivato qui' con www.gxxxxe.it cercando xxxxx Ti consiglio allora di vedere anche questi articoli xxxxx:'

questo e' lo script nel file landingsites131.php :

codice:
<?php
/*
Plugin Name: Landing sites
Plugin URI: http://theundersigned.net
Description: When visitors is referred to your site from a search engine, they are definitely looking for something specific - often they just roughly check the page they land on and then closes the window if what they are looking for isn't there. Why not help them by showing them related posts to their search on your blog? This plugin/guide lets you do that, works with a long list of search engines! Plugin is made with help from these scripts: http://www.w-a-s-a-b-i.com/archives/...ed-entries-20/ - http://textsnippets.com/posts/show/231 - http://www.lazaryn.com/entry-28.html
Version: 1.31
Author: The undersigned
*/

function ls_get_delim($ref) {
    static $delim;
    if (isset($delim)) return $delim;

    // Search engine match array
    // Used for fast delimiter lookup for single host search engines.
    // Non .com Google/MSN/Yahoo referrals are checked for after this array is checked
    // Search engines that send the term as a path are flagged with a delim of '&'

    $search_engines = array('google.com' => 'q',
			'go.google.com' => 'q',
			'maps.google.com' => 'q',
			'local.google.com' => 'q',
			'search.yahoo.com' => 'p',
			'search.msn.com' => 'q',
			'msxml.excite.com' => '&',
			'a9.com' => '&',
			'search.lycos.com' => 'query',
			'alltheweb.com' => 'q',
			'search.aol.com' => 'query',
			'search.iwon.com' => 'searchfor',
			'ask.com' => 'q',
			'ask.co.uk' => 'ask',
			'search.cometsystems.com' => 'qry',
			'hotbot.com' => 'query',
			'overture.com' => 'Keywords',
			'metacrawler.com' => 'qkw',
			'search.netscape.com' => 'query',
			'looksmart.com' => 'key',
			'dpxml.webcrawler.com' => 'qkw',
			'search.earthlink.net' => 'q',
			'search.viewpoint.com' => 'k',
			'mamma.com' => 'query');

    $delim = false;

    // Check to see if we have a host match in our lookup array
    if (isset($search_engines[$ref])) {
        $delim = $search_engines[$ref];
    } else {
        // Lets check for referrals for international TLDs and sites with strange formats

        // Optimizations
        $sub13 = substr($ref, 0, 13);

        // Search string for engine
        if(substr($ref, 0, 7) == 'google.')
            $delim = "q";
        elseif($sub13 == 'search.atomz.')
            $delim = "sp-q";
        elseif(substr($ref, 0, 11) == 'search.msn.')
            $delim = "q";
        elseif($sub13 == 'search.yahoo.')
            $delim = "p";
        elseif(preg_match('/home\.bellsouth\.net\/s\/s\.dll/i', $ref))
            $delim = "bellsouth";
    }

    return $delim;
}

function ls_get_terms($d) {
    static $terms;
    if (isset($terms)) return $terms;

    $query_array = array();
    $query_terms = null;

    // A few search engines include the query as a URL path, not a variable (Excite/A9, etc)
    if ($d == '&') {
        $query = urldecode(substr(strrchr($_SERVER['HTTP_REFERER'], '/'), 1));
    } else {
        // Get raw query
        $query = explode($d.'=', $_SERVER['HTTP_REFERER']);
        $query = explode('&', $query[1]);
        $query = urldecode($query[0]);
    }

    // Remove quotes, split into words, and format for HTML display
    $query = str_replace("'", '', $query);
    $query = str_replace('"', '', $query);
    $query_array = preg_split('/[\s,\+\.]+/',$query);
    $query_terms = implode(' ', $query_array);
    $terms = htmlspecialchars(urldecode($query_terms));

    return $terms;
}

function ls_get_refer() {
    static $referer;
    if (isset($referer)) return $referer;

    // Break out quickly so we don't waste CPU cycles on non referrals
    if (!isset($_SERVER['HTTP_REFERER']) || ($_SERVER['HTTP_REFERER'] == '')) return false;

    $referer_info = parse_url($_SERVER['HTTP_REFERER']);
    $referer = $referer_info['host'];

    // Remove www. is it exists
    if(substr($referer, 0, 4) == 'www.')
        $referer = substr($referer, 4);

    return $referer;
}

function ls_related($limit=5, $len=10, $before_title = '', $after_title = '', $before_post = '', $after_post = '', $show_pass_post = false, $show_excerpt = false) {
   
    global $wpdb, $id;

    // Did we come from a search engine? 
    $referer = ls_get_refer();
    if (!$referer) return false;

    $delimiter = ls_get_delim($referer);

    if($delimiter) 
    { 
        $terms = ls_get_terms($delimiter);

        $time_difference = get_settings('gmt_offset');
        $now = gmdate("Y-m-d H:i:s",(time()+($time_difference*3600)));

        // Primary SQL query
        $sql = "SELECT ID, post_title, post_content,"
             . "MATCH (post_name, post_content) "
             . "AGAINST ('$terms') AS score "
             . "FROM $wpdb->posts WHERE "
             . "MATCH (post_name, post_content) "
             . "AGAINST ('$terms') "
             . "AND post_date <= '$now' "
             . "AND (post_status IN ( 'publish',  'static' )) ";
        if ($id > 0) $sql .= "AND ID != " . $id . " ";
        if ($show_pass_post=='false') $sql .= "AND post_password ='' ";
        $sql .= "ORDER BY score DESC LIMIT $limit";
        $results = $wpdb->get_results($sql);
        $output = '';
        if ($results) {
            foreach ($results as $result) {
                $title = stripslashes(apply_filters('the_title', $result->post_title));
                $permalink = get_permalink($result->ID);
                $post_content = strip_tags($result->post_content);
                $post_content = stripslashes($post_content);
                $output .= $before_title .'' . $title . '' . $after_title;
                if ($show_excerpt=='true') {
                    $words=split(" ",$post_content); 
                    $post_strip = join(" ", array_slice($words,0,$len));
                    $output .= $before_post . $post_strip . $after_post;
                }
            }
            echo $output;
        } else {
            echo $before_title.'No related posts'.$after_title;
        }
    }
}

// Return true if the referer is a search engine
function ls_getinfo($what) {

    // Did we come from a search engine? 
    $referer = ls_get_refer();
    if (!$referer) return false;
    $delimiter = ls_get_delim($referer);

    if($delimiter) 
    { 
        $terms = ls_get_terms($delimiter);

        if($what == 'isref') { return true; }
        if($what == 'referrer') {
            $parsed = parse_url($_SERVER['HTTP_REFERER']);
            echo ''.$parsed['host'].'';
        }
        if($what == 'terms') { echo $terms; }
        
    } 
} 

function ls_install() {
    global $wpdb;
    global $table_prefix;
    
    $sql = 'ALTER TABLE `'.$table_prefix.'posts` ADD FULLTEXT `post_related` ( `post_name` ,'
    . ' `post_content` )';
    
    $wpdb->hide_errors();
    $sql_result = $wpdb->query($sql);
    $wpdb->show_errors();
}

// We need to quickly check the DB schema and support WP 1.5 and 2.0
// Once WP 1.5 is really gone ;) register_activation_hook can be used for a clean init
function ls_check_db_schema() {
    if (get_option('ls_schema_updated')) {
        return; // We already updated the schema so break out
    } else {
        ls_install();
        add_option('ls_schema_updated', 1, 'LandingSites DB Schema Added');
    }
}

function ls_set_header() {
	if (ls_getinfo('isref')) header('Vary: Referer', FALSE);
}



?>

e va richiamato con:

codice:
<?php if (ls_getinfo('isref')) { ?>


Benvenuto. Sei arrivato qui' con <?php ls_getinfo('referrer'); ?> cercando <?php ls_getinfo('terms'); ?>. Ti consiglio allora di vedere anche questi articoli:</p>

/* righe da elliminare perche' non e' un sito wp
<ul>
<?php ls_related(5, 10, '[*]', '', '', '', false, false); ?>[/list]
*/
<?php } ?>

Come dicevo vorrei adattarlo ad un sito non wp, ma sono digiuno di sintassi e ottengo molti errori.

Io ho messo lo script in un file chiamato landingsites131.php ma mi potete correggere le righe che lo richiamano in modo da metterle su una pagina , ad esempio test.php ?

Spero di essermi spiegato e ringrazio anticipatamente