/** * Verifies configuration * * @access public * @return boolean * @throws FatalMisconfigurationException */ public static function CheckConfig() { // check the php version if (version_compare(phpversion(), '5.4.0') < 0) { throw new FatalException("The configured PHP version is too old. Please make sure at least PHP 5.4 is used."); } // some basic checks if (!defined('BASE_PATH')) { throw new FatalMisconfigurationException("The BASE_PATH is not configured. Check if the config.php file is in place."); } if (substr(BASE_PATH, -1, 1) != "/") { throw new FatalMisconfigurationException("The BASE_PATH should terminate with a '/'"); } if (!file_exists(BASE_PATH)) { throw new FatalMisconfigurationException("The configured BASE_PATH does not exist or can not be accessed."); } if (defined('BASE_PATH_CLI') && file_exists(BASE_PATH_CLI)) { define('REAL_BASE_PATH', BASE_PATH_CLI); } else { define('REAL_BASE_PATH', BASE_PATH); } if (!defined('LOGBACKEND')) { define('LOGBACKEND', 'filelog'); } if (strtolower(LOGBACKEND) == 'syslog') { define('LOGBACKEND_CLASS', 'Syslog'); if (!defined('LOG_SYSLOG_FACILITY')) { define('LOG_SYSLOG_FACILITY', LOG_LOCAL0); } if (!defined('LOG_SYSLOG_HOST')) { define('LOG_SYSLOG_HOST', false); } if (!defined('LOG_SYSLOG_PORT')) { define('LOG_SYSLOG_PORT', 514); } if (!defined('LOG_SYSLOG_PROGRAM')) { define('LOG_SYSLOG_PROGRAM', 'z-push'); } if (!is_numeric(LOG_SYSLOG_PORT)) { throw new FatalMisconfigurationException("The LOG_SYSLOG_PORT must a be a number."); } if (LOG_SYSLOG_HOST && LOG_SYSLOG_PORT <= 0) { throw new FatalMisconfigurationException("LOG_SYSLOG_HOST is defined but the LOG_SYSLOG_PORT does not seem to be valid."); } } elseif (strtolower(LOGBACKEND) == 'filelog') { define('LOGBACKEND_CLASS', 'FileLog'); if (!defined('LOGFILEDIR')) { throw new FatalMisconfigurationException("The LOGFILEDIR is not configured. Check if the config.php file is in place."); } if (substr(LOGFILEDIR, -1, 1) != "/") { throw new FatalMisconfigurationException("The LOGFILEDIR should terminate with a '/'"); } if (!file_exists(LOGFILEDIR)) { throw new FatalMisconfigurationException("The configured LOGFILEDIR does not exist or can not be accessed."); } if (!file_exists(LOGFILE) && !touch(LOGFILE) || !is_writable(LOGFILE)) { throw new FatalMisconfigurationException("The configured LOGFILE can not be modified."); } if (!file_exists(LOGERRORFILE) && !touch(LOGERRORFILE) || !is_writable(LOGERRORFILE)) { throw new FatalMisconfigurationException("The configured LOGERRORFILE can not be modified."); } // check ownership on the (eventually) just created files Utils::FixFileOwner(LOGFILE); Utils::FixFileOwner(LOGERRORFILE); } else { define('LOGBACKEND_CLASS', LOGBACKEND); } // set time zone // code contributed by Robert Scheck (rsc) if (defined('TIMEZONE') ? constant('TIMEZONE') : false) { if (!@date_default_timezone_set(TIMEZONE)) { throw new FatalMisconfigurationException(sprintf("The configured TIMEZONE '%s' is not valid. Please check supported timezones at http://www.php.net/manual/en/timezones.php", constant('TIMEZONE'))); } } else { if (!ini_get('date.timezone')) { date_default_timezone_set('Europe/Amsterdam'); } } // check if Provisioning is enabled and the default policies are available if (PROVISIONING) { if (file_exists(REAL_BASE_PATH . PROVISIONING_POLICYFILE)) { $policyfile = REAL_BASE_PATH . PROVISIONING_POLICYFILE; } else { $policyfile = PROVISIONING_POLICYFILE; } ZPush::$policies = parse_ini_file($policyfile, true); if (!isset(ZPush::$policies['default'])) { throw new FatalMisconfigurationException(sprintf("Your policies' configuration file doesn't contain the required [default] section. Please check the '%s' file.", $policyfile)); } } return true; }