1012 posts It's in the pipeline!
  • Has sold $500,000+ on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has been part of the Envato Community for over 6 years
  • Sells items exclusively on Envato Market
+7 more
purethemes says

There is a problem with certain thing all Envato authors keep figthing with. I’ve got quick tip for all of you. If you’ve got google analytics on your demo sites, you probably see visits from pages you don’t want. How to show them that they are not welcome? By simple php:

<?php if ( $_SERVER[‘HTTP_REFERER’]==”Link to the website you’ve got visits from” ){ header( ‘Location: http://www.LINK.com/’ ) ; } ?>

Just put it at the begining of your index file, and change LINK to some websites with special scary message or whatever you want ;) Works great!

1012 posts It's in the pipeline!
  • Has sold $500,000+ on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has been part of the Envato Community for over 6 years
  • Sells items exclusively on Envato Market
+7 more
purethemes says

Ups, I’ve noticed typo in title but it’s too late to edit..

2459 posts
  • Has been part of the Envato Community for over 5 years
  • Has sold $100+ on Envato Market
  • Has referred 100+ members
  • Has been a beta tester for an Envato feature
+3 more
digitalimpact says

Hehe

I guess one would need to create a variable with an array to check against multiple websites, right?

Nice idea :)

552 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 100+ members
  • Located in Canada
  • Has collected 100+ items on Envato Market
+1 more
OurWebMedia says

What exactly does this do? Not quite certain I understand…?

308 posts
  • Has referred 1+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+4 more
brainbuzzmedia says

It redirects visitors coming from specified sites that illegally offer your work to a page of your choosing, such as one that might say “Hello, the website you have visited is offering illegal content. Your IP address is X.”

552 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 100+ members
  • Located in Canada
  • Has collected 100+ items on Envato Market
+1 more
OurWebMedia says
It redirects visitors coming from specified sites that illegally offer your work to a page of your choosing, such as one that might say “Hello, the website you have visited is offering illegal content. Your IP address is X.”

That’s pretty nifty! I’m going to have to look into this. Thanks a lot OP for posting this. And thank you BrainBuzz (LOVE the name) for the explanation!

3110 posts
  • Located in Australia
  • Helps us moderate the forums
  • Has been part of the Envato Community for over 5 years
  • Helped several times protecting Envato Market against copyright violations
+16 more
dtbaker Moderator says

Really your theme previews should only come from a few places, or just 1, themeforest.

So if there is no “themeforest.net” in the provided referral address then redirect the user to google.

PHP Version


 &lt;?php (i wish they would fix php tags)

$allowed_referral_websites = array(
   "themeforest.net",
   "yourportfoliosite.net",
);
$referral_allowed = (!isset($_SERVER['HTTP_REFERER']) || !$_SERVER['HTTP_REFERER']);
foreach($allowed_referral_websites as $site_to_check){
  if(preg_match('#'.preg_quote($site_to_check,'#').'#', $_SERVER['HTTP_REFERER'])){
    // referer is set to one of the allowed sites
    $referral_allowed = true;
}
if(!$referral_allowed){
  header("Location: http://www.google.com");
  exit;
}

?&gt; (i wish they would fix php tags)

of course if the user has “internet security” software it will most likely disable referral addresses, so this will only catch those who have it set.

Javascript Version

something similar would be possible in javascript as well, using the “document.referrer” address. this would be easier to add to your static html theme preview.

meh, i’ve got a few mins, here’s the javascript version:

var allowed_referral_websites = [
   "themeforest.net",
   "yourportfoliosite.net" 
];
var referral_allowed = (typeof document.referrer == 'undefined' || document.referrer == '');
for(var i in allowed_referral_websites){
  if(document.referrer.match(allowed_referral_websites[i])){ // probably an issue here with regex "." 
    // referer is set to one of the allowed sites
    referral_allowed = true;
}
if(!referral_allowed){
  window.location.href="http://www.google.com";
}

you would save this as yourwebsite.com/redirect.js and then link to it from your theme <script type="text/javascript" src="http://yourwebsite.com/redirect.js"></script>

the javascript one would be easier to add to html themes, where you cannot use the php method.

again if they have referral addresses disabled in preferences or from a virus protector this will not work.

disclaimer: wrote the above code without testing, it probably will have some errors in it :P

552 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 100+ members
  • Located in Canada
  • Has collected 100+ items on Envato Market
+1 more
OurWebMedia says

@ dtbaker

Awesome, thanks so much for this! I’m sure I’ll be making use of this soon.

by
by
by
by
by
by