-
-
Save hakanbulgurlu/9a0f21a1b6c70c7b97a62341f3210882 to your computer and use it in GitHub Desktop.
Backlink Checker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
Example of use: | |
$bl_check = new Fb_Backlink_Checker( 'http://www.example.com', 'http://other.com' ); | |
$bl_check->get_contents(); | |
$bl_check->fetch_links(); | |
if ( TRUE !== $bl_check->check() ) { | |
echo 'Backlink not found.'; | |
}else{ | |
echo 'Backlink found'; | |
} | |
*/ | |
class Fb_Backlink_Checker { | |
var $url; | |
var $content; | |
var $links; | |
var $link_to_check; | |
function __construct( $url, $link_to_check ) { | |
$this->url = $url; | |
$this->link_to_check = $link_to_check; | |
} | |
function set_link_to_check( $link ) { | |
$this->link_to_check = $link; | |
} | |
function get_contents() { | |
$this->content = file_get_contents( $this->url ); | |
} | |
function fetch_links() { | |
$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 ( $this->link_to_check == $url | |
return TRUE; | |
} | |
return FALSE; | |
} | |
} // end class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Example of use: | |
$bl_check = new Fb_Backlink_Checker( 'http://www.example.com', 'http://other.com' ); | |
$bl_check->get_contents(); | |
$bl_check->fetch_links(); | |
if ( TRUE !== $bl_check->check() ) { | |
echo 'Backlink not found.'; | |
}else{ | |
echo 'Backlink found'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment