I have been thinking from a long time that how can I edit the css files using php very safely and securely as we know css files are easily accessible and any one get the data using file_get_contents.
My question is can anyone edit the css file using file_get_contents?
Or is it safe to use while editing css file using this code?
$filename = "stylesheets/".$_POST['filename'];
$code = $_POST['code'];
if( file_exists($filename) ){
file_put_contents( $filename, stripslashes($code) );
echo 1;
}
I am just curious about it that I am using a very insecure way and anyone can access my css file and make changes even can destroy all my styling. I searching for the best and secure way to edit css files.
Please let me know if it is a possible duplicate or not a good question to ask, so I can close it my self and not by down votes.
Thank you.