Forum Moderators: coopster
Things such as?>, <?, ' and ", as well as HEREDOC syntax can play havoc with the config.php file.
How do you sanitise things so that they only result in the string themselves when placed between ' ' marks in a file?
i.e. if $language is a user supplied variable, and I write into config.php:
$fh=fopen("config.php","w");
fwrite($fh,"\$language='$language');
The reason I am concerned is that I am providing a hosted service which users will be able to configure themselves. To save database use, I want to write the configuration settings to a flat file and include it directly with PHP. I cannot control what the users type in the configuration file - so I want to sanitise it.
Are there better solutions which still avoid having to read the database for configuration with each page load?