FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Help needed link/page checker





billybob
Right...
Well i need a script/s that can do the following:



* Check whether a webpage still exsists

*
Check whether there is a link to that webpage from its own website

*
Check wheather a certain line of code or a key is in that page

*
Then if any of the above comes back negative create an output ie an emails me saying whitch site has removed the page, link or removed code from that page.

I do have some ideas of how to achive this but they are very very vaige, does anyone have an idea that could help me achieve this?

Thanks
Ryan
dandelion
You can check whether the page exists using the PHP file_get_contents() function (the open_wrappers must be enabled), then check whether there is the key there using the strpos() function (please note on the tripled equation mark).
Code:
<?php

$page = 'http://www.example.com/example.html';
$key = 'test';

$email = 'you@example.net';
$subject = 'Alert';
$page_alert_message = "The $page page was removed.";
$key_alert_message = "The $key key was removed from the $page page.";

$contents = file_get_contents(urlencode($page));
if ($contents) {
    if (strpos($contents, $key) === false) {
        mail($email, $subject, $key_alert_message);
    }
} else {
    mail($email, $subject, $page_alert_message);
}

?>

See also:
file_get_contents
strpos
mail

You can check whether there is the link to the page on other pages in the similar way (just replace the $page variable with the url of the certain page and the $key variable with the example page url).
billybob
thanks for the help i will take alook at the weekend
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.