DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   Code Snippet: (Back) link checker (http://www.daniweb.com/forums/thread216695.html)

olaf Feb 14th, 2006 5:47 pm
(Back) link checker
 
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

  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 Oct 16th, 2008 7:56 pm
this is not working

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

http://www.gezilistesi.com


All times are GMT -4. The time now is 1:22 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC