Script Theft
This morning i checked my stats, and i came across interesting web site which is linking to my web design section. Since nothing was there, just some internal links, i right clicked and saw that it’s in fact calling JavaScript file from my server. What courage this guy has!
Why it’s not working on his website?
Fortunately, when building this website, i set all CSS and JavaScript going through serverside (PHP) script which will not pass these files outside my website – some referrer conditioning (or any other you find more appropriate) and simple switch/case deploying. If willing trying save following as externals.php
<?php
$q=$_GET["q"];
if (strpos($_SERVER['HTTP_REFERER'], "http://www.yourdomain.com/") === false) {
echo "/* Thanks for being interested in my work. Please contact me if you want to know more about how it's done. */";
} else {
switch ($q) {
case "css":
header ("Content-type: text/css");
readfile("style.css");
break;
case "js":
header ("Content-type: text/javascript");
readfile("script.js");
// and even more cases if desired : )
}
}
?>
and modify your HTML code somewhere in <head> section:
<link rel="stylesheet" type="text/css" href="http://www.yourdomain.com/externals.php?q=css" /> <script type="text/javascript" src="http://www.yourdomain.com/externals.php?q=js"></script>
Above is of course simplified version of the original script and it’s left to you to customize it however you want (hint: this page could send you an e-mail whenever conditions are not matched).
I’d be glad to hear how you solved yours.

3 Comments
Pozdrav Mare,
nije ti loše ovo predloženo rešenje, ali mnogo je bolje delovati u pravcu prevencije i time zaštititi ponekad skupi bandwidth. Rešenje je u izmeni HTACCESS fajla, a evo i kvalitetnog uputstva u vidu članka HTACCESS for Fun and Profit.
Comment (#) by Goran Aničić — 3rd August 2004.
Hvala! Ovaj način koji je opisan u tom članku nedorađen je za još jednu liniju u
.htaccessdatoteci, a više se može naći u članku na Webmajstori.Net.U osnovi kod oba se načina radi o detekciji preko
HTTP_REFERERserverske varijable, međutim s PHP-om su otvorene i neke druge opcije, osim pukog blokiranja datoteka s određenim ekstenzijama, kao npr. slanje e-mail-a administratoru kad god skripta ne vrati traženu datoteku; zatim, može se prevenirati spremanje datoteke ucachebrowsera (posebno korisno za IE) itd, itd.Comment (#) by marko — 3rd August 2004.
i don’t have anything to contribute to this article, but i just came across your site and can’t go without saying how beautiful it is (and all of your others)…. excellent job.
Comment (#) by ericville — 7th November 2004.
Sorry, the comment form is closed at this time, but if you have anything to say, please send me a message.