Quantcast
Viewing latest article 21
Browse Latest Browse All 25

PHP backlink checker script

This is probably the simplest script that anyone knowing (or even learning) PHP can create in about 15seconds. But I will still post it here just in case anyone is a total noob at PHP.

Purpose of this script: To check a certain given backlink on hundreds of webpages provided you know the URL of every webpage.

<?php



$source = file_get_contents("source.txt");

$needle = "www.IamtryingtocheckThisPage";   //without http as I have imploded the http later in the script

$new = explode("n",$source);



foreach ($new as $check) {

$a = file_get_contents("http://".trim($check));



if (strpos($a,$needle)) {

$found[] = $check;

	 } else {

	 $notfound[] = $check;

			}

						}



echo "Matches that were found: n ".implode("n",$found)."n";

echo "Matches that were not found n". implode("n",$notfound);

?>


or Other way
<?php

function check_back_link($remote_url, $your_link) {

    $match_pattern = preg_quote(rtrim($your_link, "/"), "/");

    $found = false;

    if ($handle = @fopen($remote_url, "r")) {

        while (!feof($handle)) {

            $part = fread($handle, 1024);

            if (preg_match("/<a(.*)href=["']".$match_pattern.

"(/?)["'](.*)>(.*)</a>/", $part)) {

                $found = true;

                break;

            }

        }

        fclose($handle);

    }

    return $found;

}

// example:

//if (check_back_link("http://www.abc.com", "http://www.xyz.com")) echo "link exists";

?>

Viewing latest article 21
Browse Latest Browse All 25

Trending Articles