PHP Classes

File: backlinkcheck.php

Recommend this page to a friend!
  Classes of Till Wehowski   LP Backlink Checker   backlinkcheck.php   Download  
File: backlinkcheck.php
Role: Class source
Content type: text/plain
Description: Main Class and example comment
Class: LP Backlink Checker
Check if a page has a backlink to another page
Author: By
Last change:
Date: 12 years ago
Size: 1,302 bytes
 

Contents

Class file image Download
<?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;
   }
  
}


?>