PHP Code to hide css source

/*
This goes at the top of the page
Settings - Edit this...
*/
$server = array("server"=>"localhost","username"=>"root","password"=>"root","database"=>"table");

mysql_connect ($server['server'], $server['username'], $server['password']);
mysql_select_db($server['database']) or die('Cannot select database');

$filename = 'style.css'; //This is where we write the style to!
$rewrite = "Oh no sorry, not going to reveal my source for the CSS!";
$table = 'site';

if ($style=mysql_fetch_array(mysql_query("SELECT style FROM ".$table))) {
if (!is_writable($filename)) { die("Can't write to $filename"); }else {
if (!$handle = fopen($filename, 'w')) { die("Cannot open file ($filename)"); }
if (fwrite($handle, $style['style']) === FALSE) { die("Cannot write to file ($filename)"); }
fclose($handle);
}
}
/*
thats it, it, then in the header tag just add

and whola
*/
?>



YOUR HTML GOES HERE

if (!is_writable($filename)) { die("Can't write to $filename"); }else {
if (!$handle = fopen($filename, 'w')) { die("Cannot open file ($filename)"); }
if (fwrite($handle, $rewrite) === FALSE) { die("Cannot write to file ($filename)"); }
fclose($handle);
}
?>

Posted in Labels: |