- Impact
- 24
- 8K views
- 15 replies
This article is written to those who have tried to find a solution on how to prevent people from using up your bandwidth of flash files.
Almost everybody who are making web sites knows that you can easily display images and even flash files from other sites simply by writing the URL:
<embed src="http://www.yoursite.com/swf/yourflashfile.swf"></embed>
You have perhaps also realised this and tried to hide your URL from being viewed. Maybe you inserted a javascript that made it impossible to right click only to find out that you can easily click on View -> Source in the menubar. Then maybe you made with the help of javascript that the flash file opens in a new window with turned off right click and with no menubar. When you then found out that you can simply click on SHIFT + F10 -> View source you maybe took one step further. You made the flash file open up in an iframe that had the exact size as the flash file but you probably realized that you can simply see the source URL in the code and open up that in the browser and then find the URL of the flash file.
You looked on other solutions and you maybe saw those programs that maybe costed hundreds of dollars that made it possible to encrypt the flash files. You looked at it a while, saw the work of it, your thin wallet and went in apathy about the whole thing and skipped it. “It’s cheaper to pay my webhosting the stolen bandwidth than those programs”, maybe you thought.
Now recently I have found a new solution that is very simple, good, works and is free.
Let’s say you have your flash files in a directory called swf and on your index.html the flash file opens.
Step 1:
Create a file called .htaccess in your swf directory (if windows refuses to change the file locally change it when you have uploaded it with your FTP program.)
Cut and paste the following lines (change “nameofyourdomain”):
It is the last 3 lines that are important here and I will explain them here in simple english:
1. If the request is not coming from your own domain.
2. Or if there is no cookie.
3. Redirect to copy.html
On other guides on the internet you will find the above but without the second last line. Without the second last line it works perfectly in Firefox but in Internet Explorer the flash file will not load on your own site. The solution to this is the cookie.
Step 2:
Insert the following in the HEAD of your index.html (or the file in which you have the flash file):
This will make a cookie when the visitor comes to the site and if the cookie exist internet explorer will load the flash file. Now if you see the above you will see that the cookie will expire very fast, like in 2 seconds or something. The time is just enough for internet explorer to start to load the flash file and way to short for the stealer to find the URL and try to download it.
If now the stealer goes to your site, copies the URL and writes it in the browser, guess what will happen, he will be directed to copy.html and there you can write a surprise for him! If he makes a link to your flash URL on a local html file, right clicks to “save target as ...”, guess what he will download, the copy.html file with the surprice!
Hotlinking also doesn’t work as there is no cookie and the flash file simply will not load.
This method works both in Internet Explorer and Firefox.
Good luck.
Copyright © 2005 Jim Westergren
Almost everybody who are making web sites knows that you can easily display images and even flash files from other sites simply by writing the URL:
<embed src="http://www.yoursite.com/swf/yourflashfile.swf"></embed>
You have perhaps also realised this and tried to hide your URL from being viewed. Maybe you inserted a javascript that made it impossible to right click only to find out that you can easily click on View -> Source in the menubar. Then maybe you made with the help of javascript that the flash file opens in a new window with turned off right click and with no menubar. When you then found out that you can simply click on SHIFT + F10 -> View source you maybe took one step further. You made the flash file open up in an iframe that had the exact size as the flash file but you probably realized that you can simply see the source URL in the code and open up that in the browser and then find the URL of the flash file.
You looked on other solutions and you maybe saw those programs that maybe costed hundreds of dollars that made it possible to encrypt the flash files. You looked at it a while, saw the work of it, your thin wallet and went in apathy about the whole thing and skipped it. “It’s cheaper to pay my webhosting the stolen bandwidth than those programs”, maybe you thought.
Now recently I have found a new solution that is very simple, good, works and is free.
Let’s say you have your flash files in a directory called swf and on your index.html the flash file opens.
Step 1:
Create a file called .htaccess in your swf directory (if windows refuses to change the file locally change it when you have uploaded it with your FTP program.)
Cut and paste the following lines (change “nameofyourdomain”):
Code:
Options +FollowSymLinks
RewriteEngine on
RewriteOptions inherit
RewriteCond %{HTTP_REFERER} !^http://([a-z0-9-]+\.)* nameofyourdomain.com/ [NC]
RewriteCond %{HTTP_COOKIE} !(^|(.+;)*)id=valid(;.*|$)
RewriteRule /*$ http://www.nameofyourdomain.com/copy.html [L,R]
1. If the request is not coming from your own domain.
2. Or if there is no cookie.
3. Redirect to copy.html
On other guides on the internet you will find the above but without the second last line. Without the second last line it works perfectly in Firefox but in Internet Explorer the flash file will not load on your own site. The solution to this is the cookie.
Step 2:
Insert the following in the HEAD of your index.html (or the file in which you have the flash file):
Code:
<SCRIPT LANGUAGE="javascript">
// Calculate the expiration date
var expires = new Date ();
expires.setTime(expires.getTime() + 1 * 1 * 20 * 60);
document.cookie = "id=valid; path=/" + "; expires=" + expires.toGMTString();
</SCRIPT>
If now the stealer goes to your site, copies the URL and writes it in the browser, guess what will happen, he will be directed to copy.html and there you can write a surprise for him! If he makes a link to your flash URL on a local html file, right clicks to “save target as ...”, guess what he will download, the copy.html file with the surprice!
Hotlinking also doesn’t work as there is no cookie and the flash file simply will not load.
This method works both in Internet Explorer and Firefox.
Good luck.
Copyright © 2005 Jim Westergren