985 posts It's in the pipeline!
  • Elite Author
  • Has been a member for 5-6 years
  • Bought between 100 and 499 items
  • Referred between 200 and 499 users
  • Exclusive Author
  • Envato Studio (Microlancer) Beta Tester
  • Author had a Free File of the Month
+2 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!

985 posts It's in the pipeline!
  • Elite Author
  • Has been a member for 5-6 years
  • Bought between 100 and 499 items
  • Referred between 200 and 499 users
  • Exclusive Author
  • Envato Studio (Microlancer) Beta Tester
  • Author had a Free File of the Month
+2 more
purethemes says

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

2441 posts
  • Has been a member for 5-6 years
  • Exclusive Author
  • Europe
  • Bought between 10 and 49 items
  • Referred between 100 and 199 users
  • Sold between 100 and 1 000 dollars
  • Envato Studio (Microlancer) Beta Tester
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
  • Bought between 100 and 499 items
  • Canada
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 100 and 199 users
OurWebMedia says

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

307 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Envato Studio (Microlancer) Beta Tester
  • United States
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
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
  • Bought between 100 and 499 items
  • Canada
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 100 and 199 users
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!

2954 posts
  • Australia
  • Community Moderator
  • Elite Author
  • Author had a Free File of the Month
  • Most Wanted Bounty Winner
  • Author had a File in an Envato Bundle
  • Has been a member for 5-6 years
  • Contributed a Blog Post
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+10 more
dtbaker Volunteer 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
  • Bought between 100 and 499 items
  • Canada
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 100 and 199 users
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