Does anybody know how I would start to write a backlink validation script or can somebody point me to a site with instruction for this
Regards
Andy
Does anybody know how I would start to write a backlink validation script or can somebody point me to a site with instruction for this
Regards
Andy
here is the script ive been playing with
<?php
function check_back_link($siteURL, $recipUrl) {
$match_pattern = preg_quote(rtrim($recipUrl, "/"), "/");
$found = false;
if ($handle = @fopen($siteURL, "r")) {
while (!feof($handle)) {
$part = fread($handle, 1024);
if (preg_match("/<a(.*)href=["']".$match_pattern.
"(/?)["'](.*)>(.*)</a>/", $part)) {
$found = true;
break;
}
}
fclose($handle);
}
return $found;
}
$check = (check_back_link($recipUrl, $siteURL));
echo $check ? "Link exists on $recipUrl to $siteURL" : "link does not exists on $recipUrl to $siteURL";
?>
I want it to redirect to a page if it exists and back to the refering page if it doesnt
Here is the full code including the form. Still not working thogh
[php]<?php
function check_back_link($siteURL, $recipUrl) {
$match_pattern = preg_quote(rtrim($recipUrl, “/”), “/”);
$found = false;
if ($handle = @fopen($siteURL, “r”)) {
while (!feof($handle)) {
$part = fread($handle, 1024);
if (preg_match("/<a(.)href=["’]".$match_pattern.
"(/?)"’>(.)/", $part)) {
$found = true;
break;
}
}
fclose($handle);
}
return $found;
}
$check = (check_back_link($recipUrl, $siteURL));
?>
what is not working?
i thougt u just wanna check the existence of a page. this code is trying to find a link in there.
some things i have seen without knowing what to search fore are:
u flipped $recipUrl, $siteURL in the function definition and the function call.
this shoudnt cauese an misfunktionalaty but it is very confusing.
u allways read 1024 bytes. as a link may be over 100 bytes long, it may happen that only the beginning tag is inside the $part variable and the rest of the link will be in the next one. in that case ur script will always fail.
please echo out some vars like $match_pattern and remove the @ sign till the code is working.
and tell us whats not working right now.
Sorted it
The form field name was recipURL
and the script was $recipURL
Finished messing about with is now, heres the finished code
[php]
<?php $siteURL = "http://www.your-site.com"; function check_back_link($siteURL, $recipUrl) { $match_pattern = preg_quote(rtrim($recipUrl, "/"), "/"); $found = false; if ($handle = @fopen($siteURL, "r")) { while (!feof($handle)) { $part = fread($handle, 1024); if (preg_match("/(.*)/", $part)) { $found = true; break; } } fclose($handle); } return $found; } $check = (check_back_link($recipUrl, $siteURL)); echo $check ? "Link Title: | |
Link Text: | |
Link Email: | |