Web Hosting Talk







View Full Version : Preventing cheaters from loading site in iframe


jon31
08-19-2005, 04:31 AM
Hey guys,

I've got this silly little game website going, called www.bedthem.com. It's very simple. You get a link, you get people to click the link, and that's it. But some people are cheating and loading the site in an invisible iframe on their popular site/blog. Is there any way I can stop this? Or check if it's being loaded on an external site? Then run a PHP or javascript function. I'd really like to be able to prevent this form of cheating.

Please let me know if you have any ideas.

Thanks,
Jon Marus

Xenatino
08-19-2005, 05:46 AM
<script language="Javascript">
if (top.location != self)
{
alert('This person is cheating on my game. Please inform them of this alert and make them aware that none of these visits are counted!');
window.location = 'about:blank';
}
</script>


That should work

mrFoce
08-19-2005, 10:35 AM
Why not redirect it to a page which logs the ID ;)

<script language="Javascript">
if (top.location != self)
{
alert('This person is cheating on my game. Please inform them of this alert and make them aware that none of these visits are counted!');
window.location = http://www.yourhost.com/cheater.php?id=<?php echo $ID; ?> ';
}
</script>

also you might want to log the 'refering url'..
However, please take note that if I want to 'screw' someone, I can do the same trick with someone else his 'id' and you might think he is cheating while actually i'm just eliminating the compitition ;)

he could be a she too ofcourse

jon31
08-19-2005, 11:54 AM
If I try top.locaiton != self, even when you're at the page properly, it still displays the alert message. Any ideas?

Xlusive
08-19-2005, 12:58 PM
you can try PHP


<?php
// Set this to your domain name
$referer = "domain.com";

// Explode the HTTP_REFERRER address to split up the string
$ref = explode('/', $_SERVER['HTTP_REFERER']);

// next piece of code checks for the 'www.'
// Some people use http://domain.com and others use http://www.domain.com. This will remove the 'www.' as to let users have their choice
if (strstr($ref['2'], 'www.')) { $ref['2'] = str_replace('www.', '', $ref['2']); }

// check if they match or not
if ($ref['2'] != $referer)
{
echo "You are not allowed to enter information from an external form.";
}
else
{
// Continue with script
}

source : h--p://www.namepros.com/showthread.php?t=115187

azizny
08-19-2005, 10:35 PM
Originally posted by Xlusive
you can try PHP


<?php
// Set this to your domain name
$referer = "domain.com";

// Explode the HTTP_REFERRER address to split up the string
$ref = explode('/', $_SERVER['HTTP_REFERER']);

// next piece of code checks for the 'www.'
// Some people use http://domain.com and others use http://www.domain.com. This will remove the 'www.' as to let users have their choice
if (strstr($ref['2'], 'www.')) { $ref['2'] = str_replace('www.', '', $ref['2']); }

// check if they match or not
if ($ref['2'] != $referer)
{
echo "You are not allowed to enter information from an external form.";
}
else
{
// Continue with script
}

source : h--p://www.namepros.com/showthread.php?t=115187

Thats not a good thing to do...

Lets say I link to your site here:

http://www.sitename.com

Now, anyone that tries to use this url from WHT will get this message... I am sure you dont want that to happen..

With the javascript code, it will remove HIS site and load your site instead...

Peace,

Xlusive
08-20-2005, 10:58 AM
i think thats what he wants. people from cheating, then people shouldnt direct link it. much harder to get " votes" but creates a gap so other people get a chance aswell.

Xenatino
08-20-2005, 11:45 AM
It's very simple. You get a link, you get people to click the link, and that's it.

i think thats what he wants. people from cheating, then people shouldnt direct link it. much harder to get " votes" but creates a gap so other people get a chance aswell.

If they are given a link and are to get people to click it, how are they supposed to distribute that link without posting it places.

The way you are describing it, people could only link to this "game" from the actual site that the game is located on, which totally takes away the whole aim of the game surely?