开发者

Manage Website Configuration via CMS

开发者 https://www.devze.com 2023-03-01 17:32 出处:网络
I\'ve read questions on Stack Overflow very similar to this question, but not quite the same. Let\'s say that I had the following config.inc.php file included on every page of my website:

I've read questions on Stack Overflow very similar to this question, but not quite the same.

Let's say that I had the following config.inc.php file included on every page of my website:

<?php

    $site_name = 'Acme Inc.';

    $authenticate_with_ldap = true;

    $ldap_host = 'ldap.example.com';
    $ldap_port = 389;
    $ldap_rdn = 'ldap-user';
    $ldap_password = 'ldap-pass';
    $ldap_dn = 'ou=examp开发者_如何学运维le,dc=example,dc=com';

    $smtp_username = 'smtp-user';
    $smtp_password = 'smtp-pass';

    $recaptcha_publickey = 'my-recaptcha-publickey';
    $recaptcha_privatekey = 'my-recaptcha-privatekey';

?>

Note: I have chosen to keep the website configuration in a file instead of the database because the information is used all over the website and it would be a lot more code and, I'm guessing, a lot more overhead to have to query the database for the same information all the time.

Now let's say that the website administrator is the type of person who would prefer to edit the above information using a CMS as opposed to going in and editing the file manually. My fear is that when the website administrator clicks the "Update" button and the PHP script gets to the file_put_contents function that overwrites the config.inc.php file, something could go wrong and either corrupt the file or make it unusable due to a syntax error or something.

Is this a reasonable concern? Should I tell the website administrator that he should just tough it out and edit the file manually? Should I store the information in the database instead? Or should I store the information in both places so that if the file gets messed up, it can be regenerated using the information in the database?


If you store that info in the DB as a single row of data, wouldn't it be cached anyway?

0

精彩评论

暂无评论...
验证码 换一张
取 消