From 152a6a9bdc0e7a54532c2ccf65234b843ce99a23 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 16 Dec 2017 22:48:46 +0100 Subject: Customisable constants.local.php (#1725) https://github.com/FreshRSS/FreshRSS/issues/1562 https://github.com/FreshRSS/FreshRSS/issues/1607 https://github.com/FreshRSS/FreshRSS/pull/1656 https://github.com/FreshRSS/FreshRSS/issues/1705 https://github.com/FreshRSS/FreshRSS/pull/1712 --- .gitignore | 1 + constants.php | 67 ++++++++++++++++++++++++++++++++++++----------------------- 2 files changed, 42 insertions(+), 26 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..cd2fd5d3a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +constants.local.php diff --git a/constants.php b/constants.php index 576be09b9..2c791c3c5 100644 --- a/constants.php +++ b/constants.php @@ -1,35 +1,50 @@ define('FRESHRSS_VERSION', '1.8.1-dev'); define('FRESHRSS_WEBSITE', 'https://freshrss.org'); define('FRESHRSS_WIKI', 'https://freshrss.github.io/FreshRSS/'); -define('FRESHRSS_USERAGENT', 'FreshRSS/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ')'); +define('FRESHRSS_PATH', __DIR__); +define('PUBLIC_PATH', FRESHRSS_PATH . '/p'); +define('PUBLIC_TO_INDEX_PATH', '/i'); +define('INDEX_PATH', PUBLIC_PATH . PUBLIC_TO_INDEX_PATH); +define('PUBLIC_RELATIVE', '..'); +define('LIB_PATH', FRESHRSS_PATH . '/lib'); +define('APP_PATH', FRESHRSS_PATH . '/app'); +define('EXTENSIONS_PATH', FRESHRSS_PATH . '/extensions'); +// + +function safe_define($name, $value) { + if (!defined($name)) { + return define($name, $value); + } +} + +if (file_exists(__DIR__ . '/constants.local.php')) { + //Include custom / local settings: + include(__DIR__ . '/constants.local.php'); +} + +safe_define('FRESHRSS_USERAGENT', 'FreshRSS/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ')'); // PHP text output compression http://php.net/ob_gzhandler (better to do it at Web server level) -define('PHP_COMPRESSION', false); +safe_define('PHP_COMPRESSION', false); // Maximum log file size in Bytes, before it will be divided by two -define('MAX_LOG_SIZE', 1048576); - -// Constantes de chemins -define('FRESHRSS_PATH', dirname(__FILE__)); - - define('PUBLIC_PATH', FRESHRSS_PATH . '/p'); - define('PUBLIC_TO_INDEX_PATH', '/i'); - define('INDEX_PATH', PUBLIC_PATH . PUBLIC_TO_INDEX_PATH); - define('PUBLIC_RELATIVE', '..'); - - define('DATA_PATH', FRESHRSS_PATH . '/data'); - define('UPDATE_FILENAME', DATA_PATH . '/update.php'); - define('USERS_PATH', DATA_PATH . '/users'); - define('ADMIN_LOG', USERS_PATH . '/_/log.txt'); - define('API_LOG', USERS_PATH . '/_/log_api.txt'); - define('CACHE_PATH', DATA_PATH . '/cache'); - define('PSHB_LOG', USERS_PATH . '/_/log_pshb.txt'); - define('PSHB_PATH', DATA_PATH . '/PubSubHubbub'); - - define('LIB_PATH', FRESHRSS_PATH . '/lib'); - define('APP_PATH', FRESHRSS_PATH . '/app'); - define('EXTENSIONS_PATH', FRESHRSS_PATH . '/extensions'); - -define('TMP_PATH', sys_get_temp_dir()); +safe_define('MAX_LOG_SIZE', 1048576); + +//This directory must be writable +safe_define('DATA_PATH', FRESHRSS_PATH . '/data'); + +safe_define('UPDATE_FILENAME', DATA_PATH . '/update.php'); +safe_define('USERS_PATH', DATA_PATH . '/users'); +safe_define('ADMIN_LOG', USERS_PATH . '/_/log.txt'); +safe_define('API_LOG', USERS_PATH . '/_/log_api.txt'); +safe_define('CACHE_PATH', DATA_PATH . '/cache'); +safe_define('PSHB_LOG', USERS_PATH . '/_/log_pshb.txt'); +safe_define('PSHB_PATH', DATA_PATH . '/PubSubHubbub'); + +//Directory used for feed mutex with *.freshrss.lock files. Must be writable. +safe_define('TMP_PATH', sys_get_temp_dir()); -- cgit v1.2.3