Save css code via admin [closed]

1

I have a function in PHP that will show me all the CSS code in the front end before HTML. Only admin can see this CSS code printed on the screen, using the "include" method.

What I'm trying to figure out is how do I copy all of this CSS displayed on the screen to a new CSS file.

Given that this CSS file appears on the screen it contains PHP variables, but on the screen it does not show these variables, but rather the value of them printed (colors, font size, etc). exit displayed by the browser .

What I want to avoid is that admin has to copy all of this CSS manually through the screen, and have it pasted into a new CSS file.

So now I do not know how to copy this CSS that is on the screen with some specific function for this, be it PHP or Javascript. There are about 2000 lines to be copied to a new CSS file.

Can anyone give me some insights on how I can achieve this? Since the intended one is not a function to copy content from one file to another with the copy method, in that case all PHP code inside the CSS would be copied. What I want is a way to copy the output code displayed by the browser already with all CSS values (colors, font sizes, etc.).

    
asked by anonymous 05.03.2015 / 19:43

1 answer

0

I think you could do more or less the following:

<?php

    $conteudoProcessado = '* { padding: 0; }';

?>

<form action="salvarArquivo.php" method="post">
    <input type="hidden" name="conteudoProcessado" value="<?php echo $conteudoProcessado; ?>" />

    <div>
        <?php echo $conteudoProcessado; ?>
    </div>

    <buttom type="submit"> Salvar </button>
</form>

And then in your file salvarArquivo.php you do the saving logic of a file with the contents of the $_POST['conteudoProcessado'] variable and you can return the saved file to the user.

If you want the user to be able to change the generated css you can use a textarea instead of a input hidden and remove the div with the contents of the file.

    
05.03.2015 / 20:15