Fixes for various bugs (e.g.: 'secret file could not be read', SQL error and more)
[mailer.git] / inc / filters.php
index e20d71821634e5103137441b894e0df7916b74cd..ceaf0e0ac9c47e6332df05342cf8a914989f7848 100644 (file)
@@ -1302,27 +1302,34 @@ function FILTER_ADD_HISTORY_ENTRY ($filterData) {
 
 // Filter for initializing ext-sql_patches
 function FILTER_GENERATE_FILE_SECRET_HASH ($filterData) {
-       // Transfer POINTS word
-       if (isExtensionInstalledAndNewer('sql_patches', '0.0.3')) {
-               // Okay, recent enough, so transfer the word for POINTS
-               setConfigEntry('POINTS', getPointsWord());
+       // Is ext-sql_patches installed and transfer POINTS word?
+       if ((!isExtensionInstalled('sql_patches')) || (!isExtensionInstalledAndNewer('sql_patches', '0.9.0'))) {
+               // Extension ext-sql_patches is missing, so better abort here
+               return;
        } // END - if
 
+       // Okay, recent enough, so transfer the word for POINTS
+       setConfigEntry('POINTS', getPointsWord());
+
        // Init key
        setConfigEntry('secret_key', '');
 
-       // File hash fas generated so we can also file the secret file... hopefully.
+       // File hash was generated so we can also file the secret file... hopefully.
        $hashFile = sprintf('%s%s.%s.cache', getPath(), getCachePath(), getFileHash());
 
        // Read key from secret file
        if ((getFileHash() == '') || (getMasterSalt() == '') || (getPassScramble() == '') || (!isFileReadable($hashFile))) {
                // Maybe need setup of secret key!
                loadIncludeOnce('inc/gen_sql_patches.php');
+
+               // Generate file name again
+               $hashFile = sprintf('%s%s.%s.cache', getPath(), getCachePath(), getFileHash());
        } // END - if
 
        // Test again
        if ((getFileHash() != '') && (getMasterSalt() != '') && (getPassScramble() != '')) {
                // Is the secret key file readable?
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'hashFile=' . $hashFile);
                if (isFileReadable($hashFile)) {
                        // Read file
                        setConfigEntry('secret_key', readFromFile($hashFile));
@@ -1365,7 +1372,7 @@ function FILTER_HANDLE_REFERRER_BANNER_CLICK ($filterData) {
        // Check required parameters
        if ((isGetRequestElementSet('user')) && (isGetRequestElementSet('banner'))) {
                // Update clicks counter...
-               sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1",
+               sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1',
                        array(bigintval(getRequestElement('banner'))), __FUNCTION__, __LINE__);
 
                // A line has been updated?
@@ -1384,7 +1391,7 @@ function FILTER_HANDLE_REFERRER_BANNER_VIEW ($filterData) {
        // Are all required parameters set
        if ((isGetRequestElementSet('user')) && (isGetRequestElementSet('banner'))) {
                // For later things... ;-)
-               $result = sqlQueryEscaped("SELECT `url` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `id`=%s LIMIT 1",
+               $result = sqlQueryEscaped('SELECT `url` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `id`=%s LIMIT 1',
                        array(bigintval(getRequestElement('banner'))), __FUNCTION__, __LINE__);
 
                // Is there the banner?
@@ -1393,7 +1400,7 @@ function FILTER_HANDLE_REFERRER_BANNER_VIEW ($filterData) {
                        $data = sqlFetchArray($result);
 
                        // Update counter
-                       sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `counter`=`counter`+1 WHERE `id`=%s LIMIT 1",
+                       sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `counter`=`counter`+1 WHERE `id`=%s LIMIT 1',
                                array(bigintval(getRequestElement('banner'))), __FUNCTION__, __LINE__);
 
                        // Set header and ...