6
I’m recording an HTML file with part of a page, to be used later by HTMLDocX
in the generation of a file .docx
(vine this question related).
To record use ob_start
and ob_get_clean
to put the content in a variable:
ob_start();
// parte da página aqui
$var = ob_get_clean();
And then with file_put_contents
save the file to a server directory:
file_put_contents('/pasta/arquivo'.$id.'.html', $var); // cria o arquivo com o id criado antes.
So, in the Htmldocx template just take the file with file_get_contents
:
$html = file_get_contents('../../pasta/arquivo'.$id.'.html');
But then every time I test this on localhost (I haven’t passed the server yet), I have to change the directory permission on the nail (with chmod
and such). I know there must be a way to make this permission definitive, I haven’t seen it yet... but then I kept thinking that there may be serious security risks, since I’m giving permission to write to a directory (777).
In short, the question is:
What are the risks involved in the recording process and subsequent access to a file
.hmtl
an Apache server with PHP, and how to avoid them? There is a best practice for this?
In case it would be better to just save the HTML in the database and then access through the mysql query (I do so to generate the pdf, but pro docx I found it easier to just write the file and access it later through Htmldocx...)?