PDA

View Full Version : Code to prevent linking from specific site(s)


amykhar
04-21-2003, 05:07 PM
I know this is possible because I have seen it done on a commercial site.

What I need is code to prevent somebody from linking to my board (any where on my board) from a given site. If somebody clicks on a link to my board from that site, they should get a custom error message that says something along the lines of "We do not welcome traffic from this site" or whatever.

Every once in a while, I get "freebied" by some of the major freebie boards. They descend and kill my server and I would like to shoo them off.

Amy

Logician
04-21-2003, 05:24 PM
amy I guess the samples in this page might help to ban sites in .htaccess according to referrer info:
http://diveintomark.org/mobile/002210.html

amykhar
04-21-2003, 05:33 PM
Thanks, Logician. I tested by blocking one of my own sites, and it worked. Hopefully, it will solve my problem :)

Amy

Zzed
04-21-2003, 07:22 PM
You can just play with the $url that gets defined in global.php.

I disallow guest access to my forums at peek times. But I have made an exception to allow people who visit my board from VB.org to come in at any time, and I display a welcome note at the top of the loaded page. :cool:

Click on my profile link and check it out. ;)

http://www.ls1.com/forums/member.php?action=getinfo&userid=4112

Boofo
04-22-2003, 02:31 AM
Today at 02:22 PM Zzed said this in Post #4 (https://vborg.vbsupport.ru/showthread.php?postid=385252#post385252)
You can just play with the $url that gets defined in global.php.

I disallow guest access to my forums at peek times. But I have made an exception to allow people who visit my board from VB.org to come in at any time, and I display a welcome note at the top of the loaded page. :cool:

Click on my profile link and check it out. ;)

http://www.ls1.com/forums/member.php?action=getinfo&userid=4112

How do you do that exactly?

Zzed
04-22-2003, 09:31 AM
Yesterday at 07:31 PM Boofo said this in Post #5 (https://vborg.vbsupport.ru/showthread.php?postid=385393#post385393)
How do you do that exactly?

In global.php:
Look for:

// check to see if server is too busy. this is checked at the end of session.php


And insert this right above it:

if(strstr($url, "http://www.vbulletin.org")) {
// Insert code here...
}


;)

Boofo
04-22-2003, 10:29 AM
Today at 04:31 AM Zzed said this in Post #6 (https://vborg.vbsupport.ru/showthread.php?postid=385454#post385454)
In global.php:
Look for:

// check to see if server is too busy. this is checked at the end of session.php


And insert this right above it:

if(strstr($url, "http://www.vbulletin.org")) {
// Insert code here...
}


;)

I don't allow guests to view threads or messages at all. How would I make it so if I linked to something on my site from vb.org here, the link would show, but only for this site?

Zzed
04-22-2003, 11:01 AM
Today at 03:29 AM Boofo said this in Post #7 (https://vborg.vbsupport.ru/showthread.php?postid=385463#post385463)
I don't allow guests to view threads or messages at all. How would I make it so if I linked to something on my site from vb.org here, the link would show, but only for this site?


Ok, I have not tested this but here it goes.

change the if() statement from my previous post to this:

$vb_org = 0;
if(strstr($url, "http://www.vbulletin.org")) {
$vb_org = 1;
}


In showthread.php there are 2 instances of the following code:

$getperms=getpermissions($thread['forumid'],-1,-1,$forum['parentlist']);


Insert the following code directly below both of them:

if($vb_org == 1) {
$getperms['canview'] = 1;
}


This should allow a one time temporary view permission to VB.org visitors. ;)

amykhar
04-22-2003, 02:53 PM
Thank you zzed. :)

You gave me the info I need to track what people are searching for at Google that makes them wind up at my site.

Instead of checking for vbulletin.org, I check for google. Then, I update a new table with the url. I use webtemplates to display the table to me and let me see what people were searching for. (the search term is in the url)

Amy

ps, How I did it is here: https://vborg.vbsupport.ru/showthread.php?postid=385526#post385526

Zzed
04-22-2003, 04:03 PM
You're very welcome Amy. :)

Boofo
04-22-2003, 06:33 PM
Today at 06:01 AM Zzed said this in Post #8 (https://vborg.vbsupport.ru/showthread.php?postid=385464#post385464)
Ok, I have not tested this but here it goes.

change the if() statement from my previous post to this:

$vb_org = 0;
if(strstr($url, "http://www.vbulletin.org")) {
$vb_org = 1;
}


In showthread.php there are 2 instances of the following code:

$getperms=getpermissions($thread['forumid'],-1,-1,$forum['parentlist']);


Insert the following code directly below both of them:

if($vb_org == 1) {
$getperms['canview'] = 1;
}


This should allow a one time temporary view permission to VB.org visitors. ;)

Thank you, sir. ;)

Will this allow the view of the link only from here or can they view the rest of the site after getting in this way?

Zzed
04-22-2003, 06:35 PM
Just the link. The visitor gets a one time permission to view the contents of the link. Any further navigation will be prevented. ;)

Boofo
04-22-2003, 06:56 PM
Ok, installed and will test. ;)

Zzed
04-22-2003, 06:58 PM
Cool. :)

Please let me know how it works.

Boofo
04-22-2003, 07:11 PM
Ok, I just tried it it I get a "No hot linking allowed" because I have that in my attachment.php and avatar.php at the top. Anyway to bypass that just for the link?

Zzed
04-22-2003, 07:23 PM
avatar.php is not using global.php. So you may want to add the same logic as in global.php. Except that you have to use $REMOTE_ADDR instead of $url.

In attachment php:
Look for:

$permissions=getpermissions($getforuminfo[forumid]);


And add this directly below it:

if($vb_org == 1) {
$permissions['canview'] = 1;
$permissions['cangetattachment'] = 1;
}

Boofo
04-22-2003, 07:35 PM
Still giving me the same error. Here is the code at the top of the file to prevent hot-linking.

/////////////////////////////////// Start of Avatar/Attachment Protector ///////////////////////////////////

$referers = array ('www.bearfacts2.com','bearfacts2.com','66.250.216 .66');

function check_referer($referers){
if (count($referers)){
$found = false;
$temp = explode('/',getenv("HTTP_REFERER"));
$referer = $temp[2];
for ($x=0; $x < count($referers); $x++){
if (ereg ($referers[$x], $referer)) {
$found = true;
}
}
if (!$found){
echo "No hot linking allowed!";
exit;
}
return $found;
} else {
return true;
}
}

check_referer($referers);

Zzed
04-22-2003, 07:58 PM
You may want to add 205.214.66.221 and www.vbulletin.org to your list of referrers.

Boofo
04-22-2003, 08:22 PM
Still couldn't get it to work for messages. Thanks anyway, buddy. ;)

Edit: Finally got it working. Thanks Edwin. ;) I have the "guests not allowed to view threads" hack by PPN installed and had to work around that.

One last question. How do I add more than one IP or site address to the line so I can add more instead of having to do it for each separate address?

Guru
11-15-2003, 06:38 PM
<a href="https://vborg.vbsupport.ru/showthread.php?threadid=35399" target="_blank">https://vborg.vbsupport.ru/showt...threadid=35399</a>

gmarik
11-15-2003, 10:12 PM
Any way to write down it in the MySQL DB, not the php file all the sites that are "bad"?