Hi all,
I'm new to php but I have a problem with a remote connection to Google regarding SEO. Instead of fopen I would need to use curl. Can anybody give me the changed code for:
$file = @fopen($filename, "r");
if (!$file)
{
echo "<p>Unable to open remote file $filename.\n";
}
else
{
while (!feof($file)) // load the file into a variable line at a time
{
$var = fgets($file, 1024);
if (eregi($conditions,$var,$out)) // find the html code this SE uses to show the site URL
{
// highlight search terms within URLS
$out[1] = strtolower(strip_tags($out[1]));
// Get the domain name by looking for the first /
if (($x = strpos($out[1],"/")) !== FALSE)
{
if (strstr($out[1], "https"))
{
$x += 2;
$x = strpos($out[1],"/", $x);
}
}
else
$x = strlen($out[1]);
// and get the URL
$url = substr($out[1],0,$x);
$url = substr($url, 0, strlen($searchurl));
$position++;
// If you want to see the hits, set $showlinks_msn to something
if($showlinks)
$siteresults[] = $url;
// If the last result process is the same as this one, it
// is a nest or internal domain result, so don't count it
// on $real_position
if(strcmp($lastURL,$url)<>0)
$real_position++;
$lastURL = $url;
// Else if the sites match we have found it!!!
if(strcmp($searchurl,$url)==0)
{
$found = $position;
break; // We quit out, we don't need to go any further.
}
else
{
if (strpos($searchurl, "www") !== FALSE)
$search_alt = substr($searchurl, 4, strlen($searchurl) - 4);
else
$search_alt = sprintf("www.%s",$searchurl);
$url_alt = substr($out[1],0,$x);
$url_alt = substr($url_alt, 0, strlen($search_alt));
if(strcmp($search_alt,$url_alt)==0)
{
$found = $position;
break; // We quit out, we don't need to go any further.
}
}
}
}
}
fclose($file);
Thanks.