{"id":41,"date":"2004-07-24T16:50:59","date_gmt":"2004-07-24T14:50:59","guid":{"rendered":"http:\/\/www.maratz.com\/blog\/archives\/2004\/07\/24\/script-theft\/"},"modified":"2004-12-21T00:48:17","modified_gmt":"2004-12-20T22:48:17","slug":"script-theft","status":"publish","type":"post","link":"http:\/\/www.maratz.com\/blog\/archives\/2004\/07\/24\/script-theft\/","title":{"rendered":"Script Theft"},"content":{"rendered":"<p>This morning i checked my stats, and i came across interesting <a href=\"http:\/\/dev.blackcluster.net\/scroll.html\">web site<\/a> which is linking to my <a href=\"http:\/\/webdesign.maratz.com\/\">web design section<\/a>. Since nothing was there, just some internal links, i <a href=\"\/img\/stolen.gif\">right clicked<\/a> and saw that it&#8217;s in fact calling JavaScript file from my server. What courage this guy has!<\/p>\n<h3>Why it&#8217;s not working on his website?<\/h3>\n<p>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 &#8212; some referrer conditioning (or any other you find more appropriate) and simple <code>switch<\/code>\/<code>case<\/code>  deploying. If willing trying save following as <code>externals.php<\/code><\/p>\n<pre>\r\n&#60;?php\r\n$q=$_GET[\"q\"];\r\nif (strpos($_SERVER['HTTP_REFERER'], \"http:\/\/www.yourdomain.com\/\") === false) { \r\n\techo \"\/* Thanks for being interested in my work. Please contact me if you want to know more about how it's done. *\/\";\r\n} else {\r\n\tswitch ($q) {\r\n\t\tcase \"css\":\r\n\t\t\theader (\"Content-type: text\/css\");\r\n\t\t\treadfile(\"style.css\");\r\n\t\t\tbreak;\r\n\t\tcase \"js\":\r\n\t\t\theader (\"Content-type: text\/javascript\");\r\n\t\t\treadfile(\"script.js\");\r\n                \/\/ and even more cases if desired : )\r\n\t} \r\n}\r\n?&#62;\r\n<\/pre>\n<p>and modify your HTML code somewhere in <code>&#60;head&#62;<\/code> section:<\/p>\n<pre>&#60;link rel=\"stylesheet\" type=\"text\/css\" href=\"http:\/\/www.yourdomain.com\/externals.php?q=css\" \/&#62;\r\n&#60;script type=\"text\/javascript\" src=\"http:\/\/www.yourdomain.com\/externals.php?q=js\"&#62;&#60;\/script&#62;<\/pre>\n<p>Above is of course simplified version of the original script and it&#8217;s left to you to customize it however you want (<strong>hint:<\/strong> this page could send you an e-mail whenever conditions are not matched).<\/p>\n<p>I&#8217;d be glad to hear how you solved yours.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This morning i checked my stats, and i came across interesting <a href=\"http:\/\/dev.blackcluster.net\/scroll.html\">web site<\/a> which is linking to my <a href=\"http:\/\/webdesign.maratz.com\/\">web design section<\/a>. Since nothing was there, just some internal links, i <a href=\"\/img\/stolen.gif\">right clicked<\/a> and saw that it&#8217;s in fact calling JavaScript file from my server. What courage this guy has!<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts\/41"}],"collection":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":0,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts\/41\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/media?parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/categories?post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/tags?post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}