<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1001095" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1001095</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/anti-leech-script#comment-1004764</link>
    <description> &lt;p&gt;Here&#039;s something a pretty cool snippet of code I found.&lt;/p&gt;
&lt;p&gt;This is one of the best ways I know to hide a files location.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;code:&lt;/p&gt;
&lt;pre&gt;
sub DownloadFile {

	# $filepath is the directory
	# $filename is the name of the file
	my ($filepath,$filename) = @_;

	chdir($filepath) | | return(0);
	my $filesize = -s $filename;

	# print full header
	print &quot;Content-disposition: inline; filename=$filename\n&quot;;
	print &quot;Content-Length: $filesize\n&quot;;
	print &quot;Content-Type: application/octet-stream\n\n&quot;;

	# open in binmode
	open(READ,$filename) | | die;
	binmode READ;

	# stream it out
	binmode STDOUT;
	while (&amp;lt;READ&amp;gt; ) { print;	}
	close(READ);

	# should always return true
	return(1);
}
[/code]

[This message has been edited by Orpheus (edited 15 May 2000).] &lt;/pre&gt;&lt;/blockquote&gt;</description>
     <pubDate>Mon, 15 May 2000 23:33:00 +0000</pubDate>
 <dc:creator>Orpheus</dc:creator>
 <guid isPermaLink="false">comment 1004764 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/anti-leech-script#comment-1004763</link>
    <description> &lt;p&gt;On Apache, you can accomplish the same thing with .htaccess if mod_rewrite is installed&lt;/p&gt;
&lt;p&gt;Add the following to .htaccess:&lt;/p&gt;
&lt;p&gt;RewriteEngine on&lt;br /&gt;
RewriteCond %{HTTP_REFERER} !^$&lt;br /&gt;
RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com/.*$ [NC]&lt;br /&gt;
RewriteCond %{HTTP_REFERER} !^http://yourdomain.com/.*$ [NC]&lt;br /&gt;
RewriteRule .*\.wav$ stolen.php3&lt;br /&gt;
RewriteRule .*\.jpg$ stolen.php3&lt;br /&gt;
RewriteRule .*\.gif$ stolen.php3&lt;/p&gt;
&lt;p&gt;That checks to see if the HTTP_REFERER is from your domain when the listed file extensions are requested. If the referer field is valid, the file loads, if the referer isn&#039;t valid it forwards to some other page or image.&lt;/p&gt;
&lt;p&gt;For example, try loading a sound file from my site: &lt;a href=&quot;http://www.montypython.net/sounds/lob/joke.wav&quot; class=&quot;bb-url&quot;&gt;http://www.montypython.net/sounds/lob/joke.wav&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;It&#039;ll forward you to a different page without letting you grab the file. This method has several advantages over an anti-leech script, the most prominent being that you don&#039;t have to edit any pages or links. You can easily select which file types or directories you want to protect by adding an .htaccess file to them.&lt;/p&gt;
&lt;p&gt;Just a warning, with mod_rewrite, make sure to test in a subdirectory first before applying the code sitewide. A simple typo can make your entire site unreachable. It&#039;s a little like playing with explosives, a useful tool, but a small boo-boo can hurt you a whole lot.&lt;/p&gt;
&lt;p&gt;Oops, forgot to mention a couple of things:&lt;/p&gt;
&lt;p&gt;RewriteRule .*\.gif$ stolen.php3&lt;/p&gt;
&lt;p&gt;change .gif to whatever file type you want to protect like .jpg   .wav   .mid    etc&lt;/p&gt;
&lt;p&gt;change stolen.php3 to the file name you want bad referers forwarded to. I use a file named stolen.php3, but you might want to use an image to replace a pirated image, so you&#039;d use the line&lt;br /&gt;
RewriteRule .*\.gif$ bandwidth.gif&lt;/p&gt;
&lt;p&gt;Also, IE doesn&#039;t send an HTTP_REFERER field on right clicks, only on left clicks. So if anyone tries to grab a file by right-clicking and using &quot;save picture as...&quot; you can&#039;t prevent it, but then again, a CGI script wouldn&#039;t prevent it either since it checks the same field.&lt;/p&gt;
&lt;p&gt;[This message has been edited by Maverick (edited 15 May 2000).]&lt;/p&gt;
 </description>
     <pubDate>Mon, 15 May 2000 20:07:00 +0000</pubDate>
 <dc:creator>Maverick</dc:creator>
 <guid isPermaLink="false">comment 1004763 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/anti-leech-script#comment-1004762</link>
    <description> &lt;p&gt;I did take a look around CGI Resource and hotscipts.com, FM, etc. None of those script I like. I have over 300 files I need to protect and if I use those script it will take me forever to protect those files. What I want is a sript that give me protection for the whole site instead of typing one file at a time. Anyone know a script for that?&lt;/p&gt;
 </description>
     <pubDate>Mon, 15 May 2000 18:32:00 +0000</pubDate>
 <dc:creator>orlando_5</dc:creator>
 <guid isPermaLink="false">comment 1004762 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/anti-leech-script#comment-1004761</link>
    <description> &lt;p&gt;Orlando,&lt;/p&gt;
&lt;p&gt;Take a look at CGI Resources. I found a few within a few seconds of looking around.&lt;br /&gt;
 &lt;a href=&quot;http://www.sponsorfind.com/Scripts/LeechThis/&quot; class=&quot;bb-url&quot;&gt;http://www.sponsorfind.com/Scripts/LeechThis/&lt;/a&gt;&lt;br /&gt;
 &lt;a href=&quot;http://www.confine.com/programs.shtml&quot; class=&quot;bb-url&quot;&gt;http://www.confine.com/programs.shtml&lt;/a&gt;&lt;br /&gt;
 &lt;a href=&quot;http://www.cgi.com.hk/scripts/getitex/&quot; class=&quot;bb-url&quot;&gt;http://www.cgi.com.hk/scripts/getitex/&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;------------------&lt;br /&gt;
Adam&lt;br /&gt;
AIS Internet Solutions&lt;br /&gt;
 &lt;a href=&quot;mailto:adam@aisinternet.com&quot; class=&quot;bb-email&quot;&gt;adam@aisinternet.com&lt;/a&gt;&lt;br /&gt;
 &lt;a href=&quot;http://www.aisinternet.com&quot; class=&quot;bb-url&quot;&gt;www.aisinternet.com&lt;/a&gt;&lt;/p&gt;
 </description>
     <pubDate>Mon, 15 May 2000 17:56:00 +0000</pubDate>
 <dc:creator />
 <guid isPermaLink="false">comment 1004761 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/anti-leech-script#comment-1004760</link>
    <description> &lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;just write it yourself, it should be a ten liner.&lt;/p&gt;
&lt;p&gt;- Check the referer. If it wasn&#039;t your site send back the &quot;no-leech&quot;-pic.&lt;br /&gt;
Some clients can fake the referer, but the user would have to know what the original site was.&lt;br /&gt;
- Optional: Check if the refering page has been loaded by the client before. (http-log or another script)&lt;br /&gt;
- Send the data.&lt;/p&gt;
&lt;p&gt;ciao&lt;br /&gt;
Anti&lt;/p&gt;
 </description>
     <pubDate>Mon, 15 May 2000 08:32:00 +0000</pubDate>
 <dc:creator>anti</dc:creator>
 <guid isPermaLink="false">comment 1004760 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
