This little function will check a given url for a backlink to another one. We have 2 variables that we need to define in order to make it work. "$siteurl" should be our url that should be present on "$recip".
The function will check both of them and return with a result. Very handy for webmasters with more than one websites or for web directories that allow only sites that put a reciprocal link on their pages.
<?php
// for a working example uncomment the lines bellow
/*
$siteurl = "http://auctions.shopping.yahoo.com/"; // this is the webpage the backlink should be found on
$recip = "http://www.yahoo.com/"; // this is the reciprocal url, text, image, ... that EXACTLY must match
if (backlinkCheck($siteurl, $recip)) {
echo "Backlink was FOUND on: ".$siteurl;
} else {
echo "Backlink was NOT FOUND on: ".$siteurl;
}
*/
function backlinkCheck($siteurl, $recip) {
$arrText = file($siteurl);
for ($i=0; $i<count($arrText); $i++) {
$text = $text . $arrText[$i];
}
if (eregi($recip, $text)) {
return true; // set true if there is a backlink
} else {
return false; // set false if backlink is missing
}
} ?>