From 2126db84accbc303e0420cac2bda19b199b2d76b Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Tue, 6 Nov 2018 18:35:40 +0100 Subject: [PATCH] core: Replace CACHE_DIR by PATH_CACHE Move CACHE_DIR from index.php to /lib/RssBridge.php and change name to PATH_CACHE. PATH_CACHE is one of the core paths of RSS-Bridge and should therefore be defined in the core file RssBridge.php. --- bridges/ElloBridge.php | 2 +- bridges/PixivBridge.php | 2 +- bridges/WordPressPluginUpdateBridge.php | 2 +- index.php | 5 +---- lib/Configuration.php | 4 ++-- lib/RssBridge.php | 1 + lib/contents.php | 2 +- 7 files changed, 8 insertions(+), 10 deletions(-) diff --git a/bridges/ElloBridge.php b/bridges/ElloBridge.php index 07a91085..b51fed77 100644 --- a/bridges/ElloBridge.php +++ b/bridges/ElloBridge.php @@ -121,7 +121,7 @@ class ElloBridge extends BridgeAbstract { private function getAPIKey() { $cache = Cache::create('FileCache'); - $cache->setPath(CACHE_DIR); + $cache->setPath(PATH_CACHE); $cache->setParameters(['key']); $key = $cache->loadData(); diff --git a/bridges/PixivBridge.php b/bridges/PixivBridge.php index 21261b31..4e4cf652 100644 --- a/bridges/PixivBridge.php +++ b/bridges/PixivBridge.php @@ -53,7 +53,7 @@ class PixivBridge extends BridgeAbstract { $url = str_replace('_master1200', '', $url); $url = str_replace('c/240x240/img-master/', 'img-original/', $url); - $path = CACHE_DIR . '/pixiv_img'; + $path = PATH_CACHE . '/pixiv_img'; if(!is_dir($path)) mkdir($path, 0755, true); diff --git a/bridges/WordPressPluginUpdateBridge.php b/bridges/WordPressPluginUpdateBridge.php index cb57df84..fb4a57e9 100644 --- a/bridges/WordPressPluginUpdateBridge.php +++ b/bridges/WordPressPluginUpdateBridge.php @@ -77,7 +77,7 @@ class WordPressPluginUpdateBridge extends BridgeAbstract { debugMessage('getting pubdate from url ' . $url . ''); // Initialize cache $cache = Cache::create('FileCache'); - $cache->setPath(CACHE_DIR . '/pages'); + $cache->setPath(PATH_CACHE . '/pages'); $params = [$url]; $cache->setParameters($params); // Get cachefile timestamp diff --git a/index.php b/index.php index 0bafbf7d..e2e97267 100644 --- a/index.php +++ b/index.php @@ -28,9 +28,6 @@ if(file_exists('DEBUG')) { require_once __DIR__ . '/lib/RssBridge.php'; -// Specify directory for cached files (using FileCache) -define('CACHE_DIR', __DIR__ . '/cache'); - // Specify path for whitelist file define('WHITELIST_FILE', __DIR__ . '/whitelist.txt'); @@ -222,7 +219,7 @@ try { // Initialize cache $cache = Cache::create('FileCache'); - $cache->setPath(CACHE_DIR); + $cache->setPath(PATH_CACHE); $cache->purgeCache(86400); // 24 hours $cache->setParameters($cache_params); diff --git a/lib/Configuration.php b/lib/Configuration.php index bc7b5895..ed2c9436 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -31,8 +31,8 @@ class Configuration { die('"json" extension not loaded. Please check "php.ini"'); // Check cache folder permissions (write permissions required) - if(!is_writable(CACHE_DIR)) - die('RSS-Bridge does not have write permissions for ' . CACHE_DIR . '!'); + if(!is_writable(PATH_CACHE)) + die('RSS-Bridge does not have write permissions for ' . PATH_CACHE . '!'); // Check whitelist file permissions (only in DEBUG mode) if(!file_exists(WHITELIST_FILE) && !is_writable(dirname(WHITELIST_FILE))) diff --git a/lib/RssBridge.php b/lib/RssBridge.php index 3044339c..2293ed35 100644 --- a/lib/RssBridge.php +++ b/lib/RssBridge.php @@ -2,6 +2,7 @@ define('PATH_VENDOR', __DIR__ . '/../vendor'); // Path for vendor library define('PATH_LIB', __DIR__ . '/../lib'); // Path for core library +define('PATH_CACHE', __DIR__ . '/../cache'); // Path to cache folder // Classes require_once PATH_LIB . '/Exceptions.php'; diff --git a/lib/contents.php b/lib/contents.php index a1343da9..3f3d36c5 100644 --- a/lib/contents.php +++ b/lib/contents.php @@ -113,7 +113,7 @@ $defaultSpanText = DEFAULT_SPAN_TEXT){ // Initialize cache $cache = Cache::create('FileCache'); - $cache->setPath(CACHE_DIR . '/pages'); + $cache->setPath(PATH_CACHE . '/pages'); $cache->purgeCache(86400); // 24 hours (forced) $params = [$url];