Exclude directories now
[mailer.git] / inc / wrapper-functions.php
index ad438537284caee8426dee8900fe0f69baef1b08..0969cf0bc5579c6d4b6197fe561d0d80bb54ba78 100644 (file)
@@ -16,7 +16,7 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -88,8 +88,7 @@ function writeToFile ($FQFN, $content, $aquireLock = FALSE) {
                }
        } else {
                // Write it with fopen
-               $fp = fopen($FQFN, 'w')
-                       or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
+               $fp = fopen($FQFN, 'w') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
 
                // Aquire a lock?
                if ($aquireLock === TRUE) {
@@ -200,7 +199,7 @@ function isDirectory ($FQFN) {
                $baseName = basename($FQFN);
 
                // Check it
-               $GLOBALS[__FUNCTION__][$FQFN] = ((is_dir($FQFN)) && ($baseName != '.') && ($baseName != '..') && ($baseName != '.svn'));
+               $GLOBALS[__FUNCTION__][$FQFN] = ((is_dir($FQFN)) && (!in_array($baseName, array('.', '..', '.svn'))));
        } // END - if
 
        // Return the result
@@ -389,10 +388,28 @@ function isHourlyResetEnabled () {
        return ((isset($GLOBALS['hourly_enabled'])) && ($GLOBALS['hourly_enabled'] === TRUE));
 }
 
-// Checks whether the reset mode is active
+// Checks whether the daily reset mode is active
+function isDailyResetEnabled () {
+       // Now simply check it
+       return ((isset($GLOBALS['daily_enabled'])) && ($GLOBALS['daily_enabled'] === TRUE));
+}
+
+// Checks whether the weekly reset mode is active
+function isWeeklyResetEnabled () {
+       // Now simply check it
+       return ((isset($GLOBALS['weekly_enabled'])) && ($GLOBALS['weekly_enabled'] === TRUE));
+}
+
+// Checks whether the monthly reset mode is active
+function isMonthlyResetEnabled () {
+       // Now simply check it
+       return ((isset($GLOBALS['monthly_enabled'])) && ($GLOBALS['monthly_enabled'] === TRUE));
+}
+
+// Checks whether one of the reset modes is enabled
 function isResetModeEnabled () {
        // Now simply check it
-       return ((isset($GLOBALS['reset_enabled'])) && ($GLOBALS['reset_enabled'] === TRUE));
+       return ((isHourlyResetEnabled()) || (isDailyResetEnabled()) || (isWeeklyResetEnabled()) || (isMonthlyResetEnabled()));
 }
 
 // Checks whether the debug mode is enabled
@@ -419,12 +436,36 @@ function isDebugHourlyEnabled () {
        return $GLOBALS[__FUNCTION__];
 }
 
-// Checks whether the debug reset is enabled
-function isDebugResetEnabled () {
+// Checks whether the debug daily is enabled
+function isDebugDailyEnabled () {
+       // Is cache set?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Simply check it
+               $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_DAILY')) && (getConfig('DEBUG_DAILY') == 'Y'));
+       } // END - if
+
+       // Return it
+       return $GLOBALS[__FUNCTION__];
+}
+
+// Checks whether the debug weekly is enabled
+function isDebugWeeklyEnabled () {
+       // Is cache set?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Simply check it
+               $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
+       } // END - if
+
+       // Return it
+       return $GLOBALS[__FUNCTION__];
+}
+
+// Checks whether the debug monthly is enabled
+function isDebugMonthlyEnabled () {
        // Is cache set?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Simply check it
-               $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_RESET')) && (getConfig('DEBUG_RESET') == 'Y'));
+               $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
        } // END - if
 
        // Return it
@@ -1577,7 +1618,7 @@ function isDisplayDebugSqlEnabled () {
        // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
-               $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
+               $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getDisplayDebugSqls() == 'Y'));
        } // END - if
 
        // Return cache
@@ -1608,12 +1649,24 @@ function isWhatTitleEnabled () {
        return $GLOBALS[__FUNCTION__];
 }
 
+// "Getter" for internal_stats
+function getInternalStats () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('internal_stats');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
 // Checks whether stats are enabled
 function ifInternalStatsEnabled () {
        // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
-               // Then determine it
-               $GLOBALS[__FUNCTION__] = (getConfig('internal_stats') == 'Y');
+               // Then determine it, do not add isExtensionInstalledAndNewer() here as it breaks very first SQL query
+               $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('internal_stats')) && (getInternalStats() == 'Y'));
        } // END - if
 
        // Return cached value
@@ -1625,7 +1678,7 @@ function isAdminNotificationEnabled () {
        // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
-               $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y');
+               $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.3.0')) && (getAdminNotify() == 'Y'));
        } // END - if
 
        // Return cache
@@ -2171,96 +2224,96 @@ function getOneDay () {
        return $GLOBALS[__FUNCTION__];
 }
 
-// "Getter" for activate_xchange
-function getActivateXchange () {
+// "Getter" for img_type
+function getImgType () {
        // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
-               $GLOBALS[__FUNCTION__] = getConfig('activate_xchange');
+               $GLOBALS[__FUNCTION__] = getConfig('img_type');
        } // END - if
 
        // Return cache
        return $GLOBALS[__FUNCTION__];
 }
 
-// "Getter" for img_type
-function getImgType () {
+// "Getter" for code_length
+function getCodeLength () {
        // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
-               $GLOBALS[__FUNCTION__] = getConfig('img_type');
+               $GLOBALS[__FUNCTION__] = getConfig('code_length');
        } // END - if
 
        // Return cache
        return $GLOBALS[__FUNCTION__];
 }
 
-// "Getter" for code_length
-function getCodeLength () {
+// "Getter" for pass_len
+function getPassLen () {
        // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
-               $GLOBALS[__FUNCTION__] = getConfig('code_length');
+               $GLOBALS[__FUNCTION__] = getConfig('pass_len');
        } // END - if
 
        // Return cache
        return $GLOBALS[__FUNCTION__];
 }
 
-// "Getter" for least_cats
-function getLeastCats () {
+// "Getter" for admin_menu
+function getAdminMenu () {
        // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
-               $GLOBALS[__FUNCTION__] = getConfig('least_cats');
+               $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
        } // END - if
 
        // Return cache
        return $GLOBALS[__FUNCTION__];
 }
 
-// "Getter" for pass_len
-function getPassLen () {
+// "Getter" for last_hourly
+function getLastHourly () {
        // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
-               $GLOBALS[__FUNCTION__] = getConfig('pass_len');
+               $GLOBALS[__FUNCTION__] = getConfig('last_hourly');
        } // END - if
 
        // Return cache
        return $GLOBALS[__FUNCTION__];
 }
 
-// "Getter" for admin_menu
-function getAdminMenu () {
+// "Getter" for last_daily
+function getLastDaily () {
        // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
-               $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
+               $GLOBALS[__FUNCTION__] = getConfig('last_daily');
        } // END - if
 
        // Return cache
        return $GLOBALS[__FUNCTION__];
 }
 
-// "Getter" for last_month
-function getLastMonth () {
+// "Getter" for last_weekly
+function getLastWeekly () {
        // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
-               $GLOBALS[__FUNCTION__] = getConfig('last_month');
+               $GLOBALS[__FUNCTION__] = getConfig('last_weekly');
        } // END - if
 
        // Return cache
        return $GLOBALS[__FUNCTION__];
 }
 
-// "Getter" for max_send
-function getMaxSend () {
+// "Getter" for last_monthly
+function getLastMonthly () {
        // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
-               $GLOBALS[__FUNCTION__] = getConfig('max_send');
+               $GLOBALS[__FUNCTION__] = getConfig('last_monthly');
        } // END - if
 
        // Return cache
@@ -2471,30 +2524,6 @@ function getTitleMiddle () {
        return $GLOBALS[__FUNCTION__];
 }
 
-// Getter for 'check_double_email'
-function getCheckDoubleEmail () {
-       // Is the cache entry set?
-       if (!isset($GLOBALS[__FUNCTION__])) {
-               // No, so determine it
-               $GLOBALS[__FUNCTION__] = getConfig('check_double_email');
-       } // END - if
-
-       // Return cached entry
-       return $GLOBALS[__FUNCTION__];
-}
-
-// Checks whether 'check_double_email' is 'Y'
-function isCheckDoubleEmailEnabled () {
-       // Is the cache entry set?
-       if (!isset($GLOBALS[__FUNCTION__])) {
-               // No, so determine it
-               $GLOBALS[__FUNCTION__] = (getCheckDoubleEmail() == 'Y');
-       } // END - if
-
-       // Return cached entry
-       return $GLOBALS[__FUNCTION__];
-}
-
 // Getter for 'display_home_in_index'
 function getDisplayHomeInIndex () {
        // Is the cache entry set?
@@ -3305,7 +3334,7 @@ function getUsersTotalLockedReferrals ($userid, $level = NULL) {
                } // END - if
 
                // Check for all referrals
-               $result = SQL_QUERY_ESC("SELECT
+               $result = sqlQueryEscaped("SELECT
        COUNT(`d`.`userid`) AS `cnt`
 FROM
        `{?_MYSQL_PREFIX?}_user_data` AS `d`
@@ -3325,10 +3354,10 @@ LIMIT 1",
                        ), __FUNCTION__, __LINE__);
 
                // Load count
-               list($GLOBALS[__FUNCTION__][$userid][$level]) = SQL_FETCHROW($result);
+               list($GLOBALS[__FUNCTION__][$userid][$level]) = sqlFetchRow($result);
 
                // Free result
-               SQL_FREERESULT($result);
+               sqlFreeResult($result);
        } // END - if
 
        // Return it
@@ -3349,7 +3378,7 @@ function convertDollarDataToGetElement ($data) {
 }
 
 // Wrapper function for SQL layer to speed-up things
-function SQL_DEBUG_ENABLED () {
+function isSqlDebugEnabled () {
        // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it