diff options
author | Andrew Dolgov <[email protected]> | 2011-01-11 12:20:00 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2011-01-11 12:20:00 +0300 |
commit | 8fc26c419b6b5f948f57b7a4ee9e27962d43af5e (patch) | |
tree | fa7842f6707a293acefc4151b1d283215a30dacf | |
parent | 0efa586a10509c59d30835f23978bb29a8f1a6f5 (diff) |
properly check whether all constants are defined in config.php
-rw-r--r-- | sanity_check.php | 11 | ||||
-rw-r--r-- | sanity_config.php | 3 | ||||
-rwxr-xr-x | utils/regen_config_checks.sh | 17 |
3 files changed, 31 insertions, 0 deletions
diff --git a/sanity_check.php b/sanity_check.php index 35d5c2a7f..d70445e02 100644 --- a/sanity_check.php +++ b/sanity_check.php @@ -11,6 +11,7 @@ } require_once "config.php"; + require_once "sanity_config.php"; if (CONFIG_VERSION != EXPECTED_CONFIG_VERSION) { $err_msg = "config: your config file version is incorrect. See config.php-dist.\n"; @@ -22,6 +23,16 @@ $err_msg = "config: HTMLPurifier cache directory should be writable by anyone (chmod -R 777 $purifier_cache_dir)"; } + if (GENERATED_CONFIG_CHECK != EXPECTED_CONFIG_VERSION) { + $err_msg = "config: your sanity_config.php is outdated, please recreate it using ./utils/regen_config_checks.sh"; + } + + foreach ($requred_defines as $d) { + if (!defined($d)) { + $err_msg = "config: required constant $d is not defined. Please check config.php"; + } + } + if (defined('RSS_BACKEND_TYPE')) { print "<b>Fatal error</b>: RSS_BACKEND_TYPE is deprecated. Please remove this option from config.php\n"; diff --git a/sanity_config.php b/sanity_config.php new file mode 100644 index 000000000..6410c5407 --- /dev/null +++ b/sanity_config.php @@ -0,0 +1,3 @@ +<?php # This file has been generated at: Tue Jan 11 12:10:54 MSK 2011 +define('GENERATED_CONFIG_CHECK', 21); +$requred_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'DB_PORT', 'MAGPIE_FETCH_TIME_OUT', 'MAGPIE_CACHE_DIR', 'MAGPIE_CACHE_AGE', 'ICONS_DIR', 'ICONS_URL', 'SINGLE_USER_MODE', 'TMP_DIRECTORY', 'ENABLE_UPDATE_DAEMON', 'DAEMON_SLEEP_INTERVAL', 'DATABASE_BACKED_SESSIONS', 'SESSION_CHECK_ADDRESS', 'SESSION_COOKIE_LIFETIME', 'SESSION_EXPIRE_TIME', 'DAEMON_UPDATE_LOGIN_LIMIT', 'CHECK_FOR_NEW_VERSION', 'USE_CURL', 'DIGEST_ENABLE', 'DIGEST_EMAIL_LIMIT', 'DAEMON_SENDS_DIGESTS', 'ENABLE_TRANSLATIONS', 'MYSQL_CHARSET', 'DEFAULT_UPDATE_METHOD', 'SIMPLEPIE_CACHE_DIR', 'SIMPLEPIE_CACHE_IMAGES', 'COUNTERS_MAX_AGE', 'DIGEST_FROM_NAME', 'DIGEST_FROM_ADDRESS', 'DIGEST_SUBJECT', 'DIGEST_SMTP_HOST', 'DIGEST_SMTP_LOGIN', 'DIGEST_SMTP_PASSWORD', 'DAEMON_FEED_LIMIT', 'ALLOW_REMOTE_USER_AUTH', 'AUTO_LOGIN', 'LOCK_DIRECTORY', 'ENABLE_GZIP_OUTPUT', 'PHP_EXECUTABLE', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'FEEDBACK_URL', 'FORCE_ARTICLE_PURGE', 'SPHINX_ENABLED', 'SPHINX_INDEX', 'ENABLE_TWEET_BUTTON', 'CONSUMER_KEY', 'CONSUMER_SECRET', 'CONFIG_VERSION'); ?> diff --git a/utils/regen_config_checks.sh b/utils/regen_config_checks.sh new file mode 100755 index 000000000..78f2dbfba --- /dev/null +++ b/utils/regen_config_checks.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +DESTINATION="sanity_config.php" + +echo "<?php # This file has been generated at: " `date` > $DESTINATION + +echo -n "define('GENERATED_CONFIG_CHECK', " >> $DESTINATION +grep CONFIG_VERSION config.php-dist | awk -F ' |)' '{ print $2 }' | xargs echo -n >> $DESTINATION +echo ");" >> $DESTINATION + +echo -n "\$requred_defines = array( " >> $DESTINATION + +grep define\( config.php-dist | awk -F\' '{ print "*" $2 "*," }' | xargs echo -n | sed -e s/,$// -e s/*/\'/g >> $DESTINATION + +echo "); ?>" >> $DESTINATION + + |