Forum Moderators: coopster

Message Too Old, No Replies

link checker and validator

link checker

         

varunkrish

9:38 am on Nov 30, 2005 (gmt 0)

10+ Year Member



i am working on a commercial script package which needs to have a link back to our site.

Some people are removing the link to the script in the skin of our script

We have the following information with us in our database

client_name
client_url
client_status

i run a foreach loop after fetching data from the table
open the url using fopen and check for occurence of a link to "http://www.domain.com"

$urlContents = file($client_url);
for ($i=0; $i<count($urlContents ); $i++) {
$text = $text . $urlContents [$i];
}
if (eregi($client_url, $text)) {
true
}
else {
false
}

this part is working

i need to check for 404 errors on invalid domains

if i run this script when a domain is down i get this error

Warning: file() [function.file]: php_network_getaddresses: getaddrinfo failed: No such host is known. in validate.php on line 24

line 24 is $urlContents = file($client_url);

any way to handle this error

coopster

3:04 pm on Nov 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You could monitor for FALSE in the returned variable. Also, to suppress the warning message in this particular case you can use the PHP Error Control Operator [php.net].
if ($urlContents = @file($client_url)) { 
// all is well, do your stuff here ...
} else {
// FALSE was returned, handle accordingly
}

varunkrish

12:36 am on Dec 1, 2005 (gmt 0)

10+ Year Member



wow great...

totally forgot about this

thanks a ton :)