1058 posts It's in the pipeline!
  • Has sold $500,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
  • Elite Author: Sold more than $75,000 on Envato Market
  • 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!

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

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

2468 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
+2 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!

3319 posts
  • Provided great contribution to our forums
  • Nominated Community Superstar of the month
  • Helps us moderate the forums
  • Has been part of the Envato Community for over 5 years
+18 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.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by