diegolamonica / EUCookieLaw

A Javascript and PHP solution to the European Cookie Law Issue
GNU Lesser General Public License v3.0
48 stars 13 forks source link

Check for wp-config.php location before writing #82

Closed jaanush closed 8 years ago

jaanush commented 9 years ago

Currently you presume wp-config.php is located in ABSPATH but that is not allways the case. In my case i user Bedrock from toots to develop my site and then the config is outside the wp folder. Wordpress checks for this and so should you.

At least check for the file before you use file_put_contents. That creates an empty file which totally breaks wp since that empty file is loaded instead of the proper wp-config.php.

diegolamonica commented 9 years ago

Hi @jaanush I will investigate about this issue.

jaanush commented 9 years ago

I did this quick-fix to make it work temporarily:

Changed:

if (!@file_put_contents(ABSPATH . 'wp-config.php', implode("", $newWPConfig))) {

to:

if (!file_exists(ABSPATH . 'wp-config.php') || !@file_put_contents(ABSPATH . 'wp-config.php', implode("", $newWPConfig))) {
diegolamonica commented 9 years ago

Thanks @jaanush, I will deeply check the issue to ensure that the contents will be written however in the wp-config.php file. Wherever it would be.

diegolamonica commented 8 years ago

Hi @jaanush sorry for the delay, I've made changes checking for existence of wp-config.php before writing data into it. However according to the best practice about Securing wp-config.php the file should be however generate with a simple line of include about the wp-config.php new path. In the next release this changes will be available.