From ef93474b89c9e51dd97f4eb79b260630f05216f2 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 8 Apr 2014 21:11:57 +0200 Subject: [PATCH] Introduced some wrapper functions, the extension for cache files is now .cache.php to make them executed on servers like Lighttpd. This will make the data "invisible" to the client as the script only contains an array. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .gitignore | 1 + inc/classes/cachesystem.class.php | 5 ++++- inc/config-global.php | 5 ++++- inc/filters.php | 4 ++-- inc/gen_sql_patches.php | 7 ++++--- inc/template-functions.php | 5 +++-- inc/wrapper-functions.php | 18 ++++++++++++++++++ 7 files changed, 36 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 6fa01dbc2b..7a1324326a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ DOCS/doxygen/*.tmp DOCS/doxygen/html inc/.secret inc/cache/*.cache +inc/cache/*.cache.php inc/cache/*.log inc/cache/*.rss inc/cache/.revision diff --git a/inc/classes/cachesystem.class.php b/inc/classes/cachesystem.class.php index 6a2ca4e134..a5ea7261d1 100644 --- a/inc/classes/cachesystem.class.php +++ b/inc/classes/cachesystem.class.php @@ -62,13 +62,16 @@ class CacheSystem { var $rebuilt = array(); // File extension - var $extension = '.cache'; + var $extension = ''; var $status = array(); var $readable = array(); var $fullPath = ''; // Constructor function CacheSystem () { + // Set extension + $this->extension = getCacheExtension(); + // Construct full path $this->fullPath = getPath() . getCachePath(); diff --git a/inc/config-global.php b/inc/config-global.php index 37b8adebac..a493b1a926 100644 --- a/inc/config-global.php +++ b/inc/config-global.php @@ -102,11 +102,14 @@ setConfigEntry('AUTHOR' , 'Roland Häder'); setConfigEntry('TITLE', 'Mailer-Project'); // CFG: COPY -setConfigEntry('COPY', 'Copyright © 2003 - 2009, by Roland Häder,
2009 - 2013 by Mailer Developer Team'); +setConfigEntry('COPY', 'Copyright © 2003 - 2009, by Roland Häder,
2009 - 2014 by Mailer Developer Team'); // CFG: CACHE-PATH setConfigEntry('CACHE_PATH', 'inc/cache/'); +// CFG: CACHE-EXTENSION +setConfigEntry('CACHE_EXTENSION', '.cache.php'); + // CFG: INTERNAL-STATS (This setting is overwritten by ext-other equal and prior version 0.2.7) setConfigEntry('internal_stats', 'N'); diff --git a/inc/filters.php b/inc/filters.php index 239d9048c1..15f5c00d46 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -1296,7 +1296,7 @@ function FILTER_GENERATE_FILE_SECRET_HASH ($filterData) { setConfigEntry('secret_key', ''); // File hash was generated so we can also file the secret file... hopefully. - $hashFile = sprintf('%s%s.%s.cache', getPath(), getCachePath(), getFileHash()); + $hashFile = getGenericHashFileName(); // Read key from secret file if ((getFileHash() == '') || (getMasterSalt() == '') || (getPassScramble() == '') || (!isFileReadable($hashFile))) { @@ -1304,7 +1304,7 @@ function FILTER_GENERATE_FILE_SECRET_HASH ($filterData) { loadIncludeOnce('inc/gen_sql_patches.php'); // Generate file name again - $hashFile = sprintf('%s%s.%s.cache', getPath(), getCachePath(), getFileHash()); + $hashFile = getGenericHashFileName(); } // END - if // Test again diff --git a/inc/gen_sql_patches.php b/inc/gen_sql_patches.php index b2b984b4e5..1e3f278d58 100644 --- a/inc/gen_sql_patches.php +++ b/inc/gen_sql_patches.php @@ -65,13 +65,14 @@ if (getMasterSalt() == '') { unset($masterSalt); } // END - if -if ((getFileHash() == '') || (!isFileReadable(getPath() . getCachePath() . '.' . getFileHash() . '.cache'))) { +if ((getFileHash() == '') || (!isFileReadable(getGenericHashFileName()))) { // Create filename from hashed random string $fileHash = sha1(generatePassword(mt_rand(128, 256))); - $FQFN = sprintf('%s%s.%s.cache', + $FQFN = sprintf('%s%s.%s%s', getPath(), getCachePath(), - $fileHash + $fileHash, + getCacheExtension() ); // Generate secret key from a randomized string diff --git a/inc/template-functions.php b/inc/template-functions.php index 70ffd792b1..56eb35dc84 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -1931,10 +1931,11 @@ function generateCacheFqfn ($prefix, $template) { if (!isset($GLOBALS['template_cache_fqfn'][$prefix][$template])) { // Generate the FQFN $GLOBALS['template_cache_fqfn'][$prefix][$template] = sprintf( - '%s_compiled/%s/%s.tpl.cache', + '%s_compiled/%s/%s.tpl%s', getCachePath(), $prefix, - $template + $template, + getCacheExtension() ); } // END - if diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index e20a4abd21..b315b3cb68 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -1793,6 +1793,18 @@ function getCachePath () { return $GLOBALS[__FUNCTION__]; } +// "Getter" for cache_extension +function getCacheExtension () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('CACHE_EXTENSION'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + // "Getter" for WRITE_FOOTER function getWriteFooter () { // Is there cache? @@ -3578,5 +3590,11 @@ function convertApiResponseToArray ($responseString, $keyDelimiter, $valueDelimi return $returned; } +// Getter for full (generic) hash file name +function getGenericHashFileName () { + // Return result + return sprintf('%s%s.%s%s', getPath(), getCachePath(), getFileHash(), getCacheExtension()); +} + // [EOF] ?> -- 2.39.5