Welcome to WebmasterWorld Guest from 54.227.110.209

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

reciprocal link checker

a sample code or hints please

     

webon

10:43 pm on Nov 2, 2004 (gmt 0)

10+ Year Member



Hello Everyone,

I am coding the reciprocal link exchange form which there is function to check if my site info and link already been add on the partner site page or not.

Please anyone who works on similar function gives me a hint how it works or any sample code would be a great appreciation.

Thanks in advance.

webon

mincklerstraat

10:03 am on Nov 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



try using
file_get_contents()
to load up the page that the user designates as the one where they've added your url, and then
strpos()
or
preg_match()
(more difficult, but able to find links if they've done weird stuff like <a class="links" href="ht*p://yoursite.com">, or if they've used single quotes - though this doesn't happen so much - you could always put a note on an error page explaining this).

$myurl = 'ht*p://www.mysite.com';
$checkhtml = file_get_contents($submittedurl);
if(preg_match('#<a[^>]*href[\s]*=[\s]*['"]?'.$myurl.'#', $checkhtml)) {
echo 'thanks for the link!';
/* do your processing stuff */
} else {
echo 'freeloader #(}@!';
/* do your error stuff */
}

the line with 'preg_match' might not work - I have to correct my regexes all the time - if not, a simple
strpos()
will work, though more limited, but if you don't understand regexes, it has the extra benefit of being easily understandable. So if this doesn't work, replace the preg_match line with this:
if(strpos($myurl, $checkhtml)!== false) {

Note that this won't find javascript links, or redirect links, common in directories. This could also go on your error page - that the link needs to be an ordinary HTML link.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month