(Back) link checker

Feb 14th, 2006
Views: 3,591
Thread Rating: 2 votes, 4.5000 average.
AddThis Social Bookmark Button
This function is usefull for peoples with a link directory where the links are stored inside a (MySQL) database. The PHP script is easy to use to find out if a reciprocal link still exists on the corresponding webpage. It takes care about the trailing slash in urls and can be used with (almost) every url. Inside the function is a check against a regular expression pattern and the result is a simple boolean. Check the example here
php Syntax
  1. <?php
  2. function check_back_link($remote_url, $your_link) {
  3. $match_pattern = preg_quote(rtrim($your_link, "/"), "/");
  4. $found = false;
  5. if ($handle = @fopen($remote_url, "r")) {
  6. while (!feof($handle)) {
  7. $part = fread($handle, 1024);
  8. if (preg_match("/<a(.*)href=[\"']".$match_pattern.
  9. "(\/?)[\"'](.*)>(.*)<\/a>/", $part)) {
  10. $found = true;
  11. break;
  12. }
  13. }
  14. fclose($handle);
  15. }
  16. return $found;
  17. }
  18. // example:
  19. //if (check_back_link("http://www.all4yourwebsite.com", "http://www.finalwebsites.com")) echo "link exists";
  20. ?>
gezilistesi | Newbie Poster | Oct 16th, 2008
this is not working

You have any code for baclink checker code for my web site

http://www.gezilistesi.com  

Only community members can submit or comment on code snippets. You must register or log in to contribute.

Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:13 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC