(Back) link checker

olaf olaf is offline Offline Feb 14th, 2006, 5:47 pm |
0
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
Quick reply to this message  
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. ?>
0
gezilistesi gezilistesi is offline Offline | Oct 16th, 2008
this is not working

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

http://www.gezilistesi.com
 
 

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC