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
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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>";

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.