Backlink

I’ve been using a PHP backlinking script from Laze.Net for a while now to show the referrers to my site. Unfortunately, the script hasn’t been updated to reflect changes in Yahoo’s new search string. So, I updated the string parsing code to correctly show the search terms. You can find the code below.

Warning: Adding recent referrs to your blog has some interesting consequences, which you may want to consider before making them publicly visible.

PHP:




$recentfile
= "backlink.txt";

$mydomain = "rationalmind.net";

$displaynum = 10;

$displaychar = 30;

$recent = file($recentfile);

$start = 0;

$amount = count($recent);

if ($amount >= $displaynum) {

    
$start = 1;

    
$amount = $displaynum;

}

for (
$x = ($amount-1); $x >= 0; $x--) {

    if (eregi("google.", $recent[$x]) || eregi("search.msn.", $recent[$x]) ||

            eregi("atomz.com", $recent[$x]) || eregi("lycos.", $recent[$x]) || eregi("yahoo.", $recent[$x]) ||

            eregi("altavista.", $recent[$x])) {

        if (
eregi("google.yahoo", $recent[$x])  ) {  

            list($first, $rest) = split("p=", $recent[$x]);

        } elseif (
eregi("lycos.", $recent[$x])) {

            list($first, $rest) = split("query=", $recent[$x]);

        } elseif (
eregi("q=&q=", $recent[$x])) {

            list($first, $rest) = split("q=&q=", $recent[$x]);

        } elseif (
eregi("yahoo.", $recent[$x])) {

            list($first, $rest) = split("p=", $recent[$x]);

        } else {

            list(
$first, $rest) = split("q=", $recent[$x]);

        }

        list(
$temp, $toss) = split("&", $rest);

        $temp = eregi_replace ("+", " ", $temp);

        $temp = eregi_replace ("%22", """, $temp);

        
$temp = eregi_replace ("%27", "'", $temp);

        $temp = eregi_replace ("%26", "&", $temp);

        
$temp = eregi_replace ("%20", " ", $temp);

        if (eregi("atomz.com", $recent[$x])) {

            echo
"<b>ls: </b> ";

        } else {

            echo
"<b>s: </b> ";

        }

        echo
"<a href="" . rtrim($recent[$x]) . "">" . substr($temp, 0, $displaychar - 3);

        if (strlen($temp) > $displaychar - 3) {

            echo
"...";

        }

        echo
"</a><br />n";

    } else {

        
$temp = rtrim(substr((eregi_replace("www.", "", $recent[$x])), 7, $displaychar));

        echo "<a href="" . rtrim($recent[$x]) . "">" . $temp;

        if (
strlen($temp) > $displaychar - 1) {

            echo "...";

        }

        echo
"</a><br />n";

    }

}

$recent[$amount] = $HTTP_REFERER . "n";

if ($HTTP_REFERER && !(eregi($mydomain, $HTTP_REFERER)) && !(eregi("Outpost", $HTTP_REFERER))) {

    $fp = fopen ($recentfile, "w");

    for (
$y = $start; $y <= $amount; $y++) {

        fputs($fp, "$recent[$y]");

    }

    
fclose ($fp);

}

Leave a Comment

Filed under Uncategorized

Leave a Reply

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