Forum Moderators: not2easy
<?php
$myURL = "http://foo.com/style.php";
$currentURL = $_SERVER['PHP_SELF'];
if (strlen($_SERVER['QUERY_STRING']) > 0) $currentURL .='?'.$_SERVER['QUERY_STRING'];
$currentURL = "http://foo.com" . strtolower($currentURL);
$myURL = strtolower($myURL);
if($currentURL == $myURL){
die("Please, don't insult us by trying to rip our css!");
}
else{
header('Content-type: text/css');
} ?>
css code here
Good news: if you directly access the page, you just get "Please, don't insult us by trying to rip our css!"
Bad news: both <link> and @import don't return the css.
Is there another solution that will allow us to use the css without adding it into the source code of the page?
piece of code I was using above is to try and stop people from directly visiting the css stylesheet, so they can't just copy/paste and rip the layout & use it themselves
This is hilarious. You can't do anthing about it. HTML, CSS, Javascript...you can't protect that stuff. Is your layout so amazing that people want to steal it though?
People don't care about that stuff as much as you think, the important part is how the site functions...which should be with a server side language that's already protected. If someone does copy your site layout you can always tell their host to shut them down, not too hard.
Aside from what is already mentioned that there are numerous ways to "view" a stylesheet, CSS on its own is not particularly useful for "ripping" layouts, you need the HTML structure and the background image/sprite structure.
Most who are even interested in viewing the source to and "copying" code are usually learners trying to figure out techniques or advanced users looking to compliment. Full site rips are usually ripped for their content before code. And then there's the "imitation is the sincerest form of flattery" notion.. Fashion designers and artists have to cope with it all the time, and they still get big money commissions - so as has been said many times before if you don't want it copied don't put it on the Web :)
hmmm. rather than spending time fighting a useless corner, You could turn it into a money making exercise.. Sell your template, minus the custom graphics, internal custom classes etc, that way if someone really wants the layout, I'm pretty sure they will pay a few bucks for the zip file to save them having to weed out your site specific code, just let them know the sizes of the images they will need to replace your custom ones for minimal effort ;)
I don't want to antagonize dawmail333. No one likes their stuff stolen, and I can understand where he's coming from, but if the page is open in the browser, there's just no way to protect what's on it. I agree with SuzyUK, zip up the layout and sell it. You can make a bundle with templates.
:)
There's nothing you can do to stop them, and the more you try, the more interesting it is to get it anyway.
Although I'd advise against it, the best you can achieve (but it's like shooting in your own foot) is to obfuscate the names of the classes and IDs.
Using e.g. classes and IDs that are like
SSSSS
SSS55
55SSS
S5S5S
...
makes understanding it all pretty impossible (but that goes for yourself just as well).
But your potential copycat will have a computer too and could easily revert all the changes.