Code for meta crawler!
if you are thinking of putting up an "link exchage" page in your site it will be nice if you'll know if they did exchange your link...
<?php
function check_reciprocal($url,$title)
{
$contents = getUrlContents($url);
if (isset($contents) && is_string($contents))
{
if(preg_match("/\b".$title."\b/", $contents))
{
return true;
}
else return false;
}
}
function getUrlContents($url, $maximumRedirections = null, $currentRedirection = 0)
{
$result = false;
$contents = @file_get_contents($url);
// Check if we need to go somewhere else
if (isset($contents) && is_string($contents))
{
preg_match_all('/<[\s]*meta[\s]*http-equiv="?REFRESH"?' . '[\s]*content="?[0-9]*;[\s]*URL[\s]*=[\s]*([^>"]*)"?' . '[\s]*[\/]?[\s]*>/si', $contents, $match);
if (isset($match) && is_array($match) && count($match) == 2 && count($match[1]) == 1)
{
if (!isset($maximumRedirections) || $currentRedirection < $maximumRedirections)
{
return getUrlContents($match[1][0], $maximumRedirections, ++$currentRedirection);
}
$result = false;
}
else
{
$result = $contents;
}
}
return $contents;
}
?>
this code will come in handy.......!!!!!!
|