<?php
 
/*
 
 Class Backlinkchecker
 
 by T. Wehowski http://webfan.de
 
 License: Do What The Fuck You Want To Public License
 
 
 
 Example of use:
 
 
 
       $BCHECK = new LP_backlinkchecker('http://www.example.com', 'http://mydomain.de');
 
       $BCHECK->getContents();
 
       $BCHECK->lpFetchLinks();
 
       
 
       if($BCHECK->check() !== TRUE)
 
         {
 
           echo 'Backlink not found.';
 
         }else{
 
               echo 'Backlink found';
 
              }  
 
      
 
*/
 
 
 
class LP_backlinkchecker
 
{
 
var $url;
 
var $content;
 
var $links;
 
var $linktocheck;
 
 
  function __construct($url, $linktocheck)
 
   {
 
    $this->url = $url;
 
    $this->linktocheck = $linktocheck;
 
   }
 
   
 
  function SetLinktocheck($link)
 
   {
 
    $this->linktocheck = $link;
 
   } 
 
   
 
   
 
  function getContents()
 
   {
 
    $this->content = file_get_contents($this->url);
 
   } 
 
 
 
  function lpFetchLinks()
 
  {
 
   $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
 
   preg_match_all("/$regexp/siU", $this->content, $matches);
 
   $this->links = $matches;
 
   return $matches;
 
   }
 
   
 
   
 
   function check()
 
   {
 
    foreach($this->links[2] as $key => $url)
 
      {
 
       if($url == $this->linktocheck)return TRUE;
 
      }
 
    return FALSE;  
 
   }
 
   
 
}
 
 
 
?>
 
 |