CSS Protection With PHP

CSS which stands for Cascading Style Sheets is a collection of code that is used to beautify the appearance of a website, css regulates what an object should look like, what color, what shape, how big it is, and so on. CSS Usually used in html, php, asp, and others.

Image Credit by Telegraph.co.uk
Image Credit by Telegraph.co.uk

Creating CSS is quite easy. And one day I missed my CSS, where someone easily copied and pasted the css code with the View Page Source feature in the browser, I looked for ways to protect css on google. Finally I found it :D. Okay, let’s start studying it here.

For example I use css below:

.class { key:value; }
filename style.css

We rename the file to end in .php (example: style.css to style.php)

Next we change the code above to the following code:

fill css here
CSS has been protected with the help of a php session, where if the session is not found or does not match then the css code will not be displayed, but the browser will only display the words “CSS PROTECTED”, until here this code is okay, but can’t be used yet.

:: How to use

If you want to use the following code. (Put it in index.php / other), here we protect the contents of style.php whose contents are css code by using sessions in php.

Fill index / header or other
🙂 Please try.

For a demo please see here.

To use the CSS is quite easy. But don’t use the href link, but use @import like the following.

Disguising style.php to style.css
and a little more. The trick is to remove the .php extension and replace it with .css so that the code can be protected using .htaccess ( mod_rewrite ). How to?

Here’s How:

RewriteEngine on
RewriteRule style.css style.php
How ? You can ? Try first. Please comment if there is a problem, or do not understand.


There is no perfect system, even this trick does not fully protect our css files, for example with the help of firebug the css code can still be seen, this is because the browser has downloaded the css script first and saved it on our computer to be processed by the browser. But this trick is still useful, even though we can’t completely make it safe, at least this is enough to make it difficult for people to copy-paste the code at will, especially those who don’t understand tools like firebug.

Reference: Sourced from a friend, DozaCrack.org, whether it’s called doza crack. hehe I asked on facebook.