I came across a snippet that uses the meta_tags.txt as a database of meta tags for its website's pages. I was planning to implement it in one of my projects. I am also planning in using HTMLPurifier for the variables before "printing".
Being a security freak, is this method secure? or do I have to add additional security measures to prevent other malicious attacks? Maybe, a MySQL table instead of a text document?
The only risk I see in using this method is to make sure that you protect that file through Apache's .htaccess
if you wish to protect sensitive information, should that file contain any later on or that you want to build a database for other things such as a user base, newsletters, etc.
For example:
<files "file.txt">
deny from all
</files>
and placed outside the webroot of your server.
However, using a text file as a database is a lot of work though when it comes to modifying it such as updating, deleting, searching, etc., so you may want to think about your options.
One of which is using a database along with prepared statements is also a good bet and is a lot more manageable.
References:
Flat file database references:
JSON is also another option: