Jump to content

reciprocal link checker


elyfrank

Recommended Posts

>:(Hi guys,

Maybe somebody can help me out here.

I have this php file that read urls from a text file where my link should be placed.

The script works fine with one link but when I add a second link I get this error:failed to open stream:

HTTP request failed! HTTP/1.1 404 Not Found in check.php  on line 8 RED> Missing or this one: all the links say missing.

 

This is the script:

<?php    $mydomain = "www.yourwebsite.com"; // Set this to your domain

$list = file_get_contents("sites.txt");

$urls = explode ("\n", $list);

echo "<B>Checking back links to $mydomain....</B><P><FONT SIZE=-1>";

foreach ($urls as $url) {

if (strlen ($url)) {

echo $url . "<B><FONT COLOR=";

if (strpos (file_get_contents($url), $mydomain) != FALSE) {

echo "GREEN> Found";

} else {

echo "RED> Missing";

}

echo "</FONT></B><BR>";

}

}

echo "</FONT>";

?>

Link to comment
https://forums.phpfreaks.com/topic/193845-reciprocal-link-checker/
Share on other sites

I'll go out on a limb and take a wild guess.

 

You built the sites.txt file by hand and hit enter after the last line giving you a blank line with a \n in it. When you explode on the \n you in fact add a blank entry as the last element in the array.

There is your error

 

(BTW) I dont really make wild guesses ;)

 

 

HTH

Teamatomic

I know all these three have my link.

 

http://for-the-love-of-dogsdotnet/index.cfm?id=4214&fuseaction=browse&pageid=95  Missing

http://www.information-about-dogsdotcom/pet-links-5.html Warning: file_get_contents(http://www.information-about-dogsdotcom/pet-links-5.html ) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /hermes/bosweb/check.php on line 9

RED> Missing

http://pipdoggy.com/catalog/linksdotphp?lPath=10 Found

 

 

I replaced .com for dotcom in case you wanted to check those pages.

Then it kinda works as expected??

 

Put the first url in a few times but alter the pageid

http://for-the-love-of-dogs.net/index.cfm?id=4214&fuseaction=browse&pageid=94

http://for-the-love-of-dogs.net/index.cfm?id=4214&fuseaction=browse&pageid=93

 

What happens. Do you still get the 404 error?

 

 

HTH

Teamatomic

I made a url file and eliminated the file_get_contents and it works OK if you use a true !==

if (strpos($url, $mydomain) !== FALSE)

so the problem lies within the use of file_get_contents in the strpos cause I tried the urls alone in a file_get_contents and they all work OK.

 

A few ideas, add double quotes in the file_get_contents("$url")

make it sleep for a few seconds in between gets of the url's.

If neither of those work you might have to break the combined if apart.

 

 

HTH

Teamatomic

Teamatomic,

Thanks for trying to help me.

still doesn't work.

this is what I got so far:

 

<?php    $mydomain = "www.yourwebsite.com"; // Set this to your domain

$list = file_get_contents("sites.txt");

$urls = explode ("\n", $list);

echo "<B>Checking back links to $mydomain....</B><P><FONT SIZE=-1>";

$urls = explode ("\n", $list);

foreach ($urls as $url) {

  if (strlen ($url)) {

  echo $url . "<B><FONT COLOR=";

sleep(10);

  if (strpos (file_get_contents("$url"), $mydomain) !== false) {

  echo "GREEN> Found";

  } else {

  echo "RED> Missing";

  }

  echo "</FONT></B><BR>";

  }

  }

  echo "</FONT>";

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.