]> git.mxchange.org Git - mailer.git/commitdiff
Hourly reset introduced
authorquix0r <quix0r@mxchange.org>
Mon, 7 Feb 2011 00:26:20 +0000 (00:26 +0000)
committerquix0r <quix0r@mxchange.org>
Mon, 7 Feb 2011 00:26:20 +0000 (00:26 +0000)
13 files changed:
.gitattributes
inc/extensions/ext-sql_patches.php
inc/filter-functions.php
inc/filters.php
inc/functions.php
inc/hourly/.htaccess [new file with mode: 0644]
inc/hourly/hourly_ [new file with mode: 0644]
inc/monthly/monthly_
inc/monthly/monthly_beg.php
inc/monthly/monthly_bonus.php
inc/monthly/monthly_newsletter.php
inc/monthly/monthly_surfbar.php
inc/wrapper-functions.php

index 73a840f4434457beb4d86332fef77c272a0f07aa..01a58d6ce4825d41c22aaf90c2dbad25fd7b5301 100644 (file)
@@ -225,6 +225,8 @@ inc/gen_refback.php -text svneol=unset#text/plain
 inc/gen_sql_patches.php -text svneol=unset#text/plain
 inc/handler.php -text svneol=unset#text/plain
 inc/header.php -text svneol=unset#text/plain
+inc/hourly/.htaccess svneol=native#text/plain
+inc/hourly/hourly_ -text
 inc/img/.htaccess -text svneol=unset#text/plain
 inc/inc-functions.php svneol=native#text/plain
 inc/install-functions.php -text svneol=unset#text/plain
index 6c292f952ea203f39c9b32f9741208bda0957e6f..16a13801477fafcc942180df9e35735c3be95a5b 100644 (file)
@@ -41,10 +41,10 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Version number
-setThisExtensionVersion('0.7.4');
+setThisExtensionVersion('0.7.5');
 
 // Version history array (add more with , '0.1.0' and so on)
-setExtensionVersionHistory(array('0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3', '0.7.4'));
+setExtensionVersionHistory(array('0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.5'));
 
 // Keep this extension always active!
 setExtensionAlwaysActive('Y');
@@ -761,6 +761,13 @@ INDEX (`ip`)
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Spalten in Filtertabelle gek&uuml;rzt (SQL-Fehler wegen zu grossem Schl&uuml;ssel).");
                                break;
+
+                       case '0.7.5': // SQL queries for v0.7.5
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `last_hour` TINYINT(2) UNSIGNED NOT NULL DEFAULT 00");
+
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Aktuelle Stunde hinzugef&uuml;gt (ist nicht konfigurierbar).");
+                               break;
                } // END - switch
                break;
 
index e2f2b84694c7b4241b204fd34ad7157ff3f5026e..613760b858d69661d6eabe8d930d92c6b8de7942 100644 (file)
@@ -105,6 +105,7 @@ ORDER BY
        registerFilter('init', 'SET_CURRENT_DATE');
        registerFilter('init', 'INIT_RANDOM_NUMBER');
        registerFilter('init', 'CHECK_REPOSITORY_REVISION');
+       registerFilter('init', 'RUN_HOURLY_RESET');
        registerFilter('init', 'RUN_DAILY_RESET');
        registerFilter('init', 'TRIGGER_SENDING_POOL');
        registerFilter('init', 'DETERMINE_USERNAME');
@@ -158,6 +159,9 @@ ORDER BY
        // Generic extension update filters
        registerFilter('extension_update', 'UPDATE_EXTENSION_DATA');
 
+       // Do hourly reset stuff, keep this entry first in this chain:
+       registerFilter('hourly', 'RUN_HOURLY_INCLUDES');
+
        // Do reset stuff, keep this entry first in this chain:
        registerFilter('reset', 'RUN_RESET_INCLUDES');
 
index 9a42401776dee630449587843b186aacdfdc7966..5de86582f375e749a9e7b5e147ca8cc684e4d6ea 100644 (file)
@@ -558,6 +558,26 @@ function FILTER_UPDATE_EXTENSION_DATA ($ext_name) {
        unset($GLOBALS['update_ver'][$ext_name]);
 }
 
+// Load more hourly reset scripts
+function FILTER_RUN_HOURLY_INCLUDES () {
+       // Is the reset set or old sql_patches?
+       if (((!isHourlyResetEnabled()) || (!isExtensionInstalledAndNewer('sql_patches', '0.7.5'))) && (isHtmlOutputMode())) {
+               // Then abort here
+               debug_report_bug(__FUNCTION__, __LINE__, 'Cannot run reset! enabled='.intval(isHourlyResetEnabled()).',ext_newer[sql_patches:0.7.5]='.intval(isExtensionInstalledAndNewer('sql_patches', '0.7.5')).' Please report this bug. Thanks');
+       } // END - if
+
+       // Get more hourly reset scripts
+       setIncludePool('hourly', getArrayFromDirectory('inc/hourly/', 'hourly_'));
+
+       // Update database
+       if ((!isConfigEntrySet('DEBUG_RESET')) || (!isDebugResetEnabled())) {
+               updateConfiguration('last_hour', getHour());
+       } // END - if
+
+       // Run the filter
+       runFilterChain('load_includes', 'hourly');
+}
+
 // Load more reset scripts
 function FILTER_RUN_RESET_INCLUDES () {
        // Is the reset set or old sql_patches?
@@ -570,7 +590,9 @@ function FILTER_RUN_RESET_INCLUDES () {
        setIncludePool('reset', getArrayFromDirectory('inc/daily/', 'daily_'));
 
        // Update database
-       if ((!isConfigEntrySet('DEBUG_RESET')) || (getConfig('DEBUG_RESET') != 'Y')) updateConfiguration('last_update', 'UNIX_TIMESTAMP()');
+       if ((!isConfigEntrySet('DEBUG_RESET')) || (!isDebugResetEnabled())) {
+               updateConfiguration('last_update', 'UNIX_TIMESTAMP()');
+       } // END - if
 
        // Is the config entry set?
        if (isExtensionInstalledAndNewer('sql_patches', '0.4.2')) {
@@ -736,15 +758,31 @@ function FILTER_CHECK_REPOSITORY_REVISION () {
 // Filter for running daily reset
 function FILTER_RUN_DAILY_RESET () {
        // Only execute this filter if installed
-       if ((isInstallationPhase()) || (!isInstalled()) || (!isAdminRegistered()) || (!isExtensionInstalled('sql_patches'))) return;
+       if ((isInstallationPhase()) || (!isInstalled()) || (!isAdminRegistered()) || (!isExtensionInstalled('sql_patches'))) {
+               return;
+       } // END - if
 
        // Shall we run the reset scripts? If a day has changed, maybe also a week/month has changed... Simple! :D
-       if (((getDay(getConfig('last_update')) != getDay()) || ((isConfigEntrySet('DEBUG_RESET')) && (getConfig('DEBUG_RESET') == 'Y'))) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestParameterSet('register')) && (!isCssOutputMode())) {
+       if (((getDay(getConfig('last_update')) != getDay()) || (isDebugResetEnabled())) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestParameterSet('register')) && (!isCssOutputMode())) {
                // Tell every module we are in reset-mode!
                doReset();
        } // END - if
 }
 
+// Filter for running hourly reset
+function FILTER_RUN_HOURLY_RESET () {
+       // Only execute this filter if installed
+       if ((isInstallationPhase()) || (!isInstalled()) || (!isAdminRegistered()) || (!isExtensionInstalledAndNewer('sql_patches', '0.7.5'))) {
+               return;
+       } // END - if
+
+       // Shall we run the reset scripts? If a day has changed, maybe also a week/month has changed... Simple! :D
+       if (((getConfig('last_hour') != getHour()) || (isDebugResetEnabled())) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestParameterSet('register')) && (!isCssOutputMode())) {
+               // Tell every module we are in reset-mode!
+               doHourly();
+       } // END - if
+}
+
 // Filter for loading more runtime includes (not for installation)
 function FILTER_LOAD_RUNTIME_INCLUDES () {
        // Load more includes
index e07307acb584b51404c1ecd3a9d6b2de1ebd226f..1c748c4455fa419f6edf431ecba5cdd74b9fc585 100644 (file)
@@ -2005,6 +2005,15 @@ function doReset () {
        runFilterChain('reset');
 }
 
+// Enables the reset mode (hourly, weekly and monthly) and runs it
+function doHourly () {
+       // Enable the hourly reset mode
+       $GLOBALS['hourly_enabled'] = true;
+
+       // Run filters (one always!)
+       runFilterChain('hourly');
+}
+
 // Our shutdown-function
 function shutdown () {
        // Call the filter chain 'shutdown'
diff --git a/inc/hourly/.htaccess b/inc/hourly/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/hourly/hourly_ b/inc/hourly/hourly_
new file mode 100644 (file)
index 0000000..f46c742
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+/************************************************************************
+ * Mailer v0.2.1-FINAL                                Start: 03/04/2005 *
+ * ===================                          Last change: 06/20/2010 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : hourly_                                          *
+ * -------------------------------------------------------------------- *
+ * Short description :                                                  *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  :                                                  *
+ * -------------------------------------------------------------------- *
+ * $Revision:: 2247                                                   $ *
+ * $Date:: 2011-01-18 16:44:31 +0100 (Tue, 18 Jan 2011)               $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author:: quix0r                                                   $ *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
+ * For more information visit: http://www.mxchange.org                  *
+ *                                                                      *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or    *
+ * (at your option) any later version.                                  *
+ *                                                                      *
+ * This program is distributed in the hope that it will be useful,      *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+ * GNU General Public License for more details.                         *
+ *                                                                      *
+ * You should have received a copy of the GNU General Public License    *
+ * along with this program; if not, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+       die();
+} elseif ((isCssOutputMode()) || (isHourlyResetEnabled()) || (!isExtensionInstalledAndNewer('sql_patches', '0.7.5'))) {
+       // Do not execute when script is in CSS mode or no hourly reset
+       return;
+} elseif (!isExtensionActive('')) {
+       logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension disabled.');
+       return;
+}
+
+// Debug line
+//* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'hourly reset started.');
+
+// Do your hourly-reset things here
+
+// Debug line
+//* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'hourly reset ended.');
+
+// [EOF]
+?>
index a89ba3155a09f2feacc171ba6d1126ebd0ce843d..e2ba61f33a767de6a1ced16ab0b82b8c03f803cc 100644 (file)
@@ -39,7 +39,7 @@
 if (!defined('__SECURITY')) {
        die();
 } elseif ((isCssOutputMode()) || (isResetModeEnabled())) {
-       // Do not execute when script is in CSS mode or no daily reset
+       // Do not execute when script is in CSS mode or no hourly reset
        return;
 } elseif (!isExtensionActive('')) {
        logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension disabled.');
index 43f6a24111ab09193fc828cb510fec6531fdd5d2..b0478424df25c446550972be26a434278a6545e2 100644 (file)
@@ -39,7 +39,7 @@
 if (!defined('__SECURITY')) {
        die();
 } elseif ((isCssOutputMode()) || (!isResetModeEnabled())) {
-       // Do not execute when script is in CSS mode or no daily reset
+       // Do not execute when script is in CSS mode or no hourly reset
        return;
 } elseif ((!isExtensionActive('beg')) || (!isBegRallyeEnabled())) {
        logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension disabled.');
index df9512b6b388936f581ac2d20d85b144dcabc039..35d5b1e7d4c1ec1bd79cf45c575c26596c46b975 100644 (file)
@@ -39,7 +39,7 @@
 if (!defined('__SECURITY')) {
        die();
 } elseif ((isCssOutputMode()) || (!isResetModeEnabled())) {
-       // Do not execute when script is in CSS mode or no daily reset
+       // Do not execute when script is in CSS mode or no hourly reset
        return;
 } elseif (!isExtensionActive('bonus')) {
        logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension disabled.');
index 556d1dd761ba076db268631175a4e1e1a8a4d6af..462d6a65bbe249ecd6764506ff17f5b2a9c42652 100644 (file)
@@ -39,7 +39,7 @@
 if (!defined('__SECURITY')) {
        die();
 } elseif ((isCssOutputMode()) || (!isResetModeEnabled())) {
-       // Do not execute when script is in CSS mode or no daily reset
+       // Do not execute when script is in CSS mode or no hourly reset
        return;
 } elseif (!isExtensionActive('newsletter')) {
        logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension disabled.');
index e84c71c5afa4205fd31951d491d458848514aad4..83f98c95163a091f62a6cf334534a73722d7bee2 100644 (file)
@@ -39,7 +39,7 @@
 if (!defined('__SECURITY')) {
        die();
 } elseif ((isCssOutputMode()) || (!isResetModeEnabled())) {
-       // Do not execute when script is in CSS mode or no daily reset
+       // Do not execute when script is in CSS mode or no hourly reset
        return;
 } elseif (!isExtensionActive('surfbar')) {
        logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension disabled.');
index d2ff5ffdd6d5b623f7e484b4c4c73ed3429d3c8b..eee9e64f0be4a358dec5de6094e8a9647172db38 100644 (file)
@@ -370,6 +370,12 @@ function isAdminRegistered () {
        return $GLOBALS[__FUNCTION__];
 }
 
+// Checks wether the hourly reset mode is active
+function isHourlyResetEnabled () {
+       // Now simply check it
+       return ((isset($GLOBALS['hourly_enabled'])) && ($GLOBALS['hourly_enabled'] === true));
+}
+
 // Checks wether the reset mode is active
 function isResetModeEnabled () {
        // Now simply check it
@@ -388,6 +394,18 @@ function isDebugModeEnabled () {
        return $GLOBALS[__FUNCTION__];
 }
 
+// Checks wether the debug reset is enabled
+function isDebugResetEnabled () {
+       // Is cache set?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Simply check it
+               $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_RESET')) && (getConfig('DEBUG_RESET') == 'Y'));
+       } // END - if
+
+       // Return it
+       return $GLOBALS[__FUNCTION__];
+}
+
 // Checks wether SQL debugging is enabled
 function isSqlDebuggingEnabled () {
        // Is cache set?
@@ -1230,12 +1248,31 @@ function getMonth ($timestamp = null) {
        return $GLOBALS[__FUNCTION__][$timestamp];
 }
 
+// Getter for current hour (default)
+function getHour ($timestamp = null) {
+       // Is it cached?
+       if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
+               // null is time()
+               if (is_null($timestamp)) {
+                       $timestamp = time();
+               } // END - if
+
+               // Then create it
+               $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__][$timestamp];
+}
+
 // Getter for current day (default)
 function getDay ($timestamp = null) {
        // Is it cached?
        if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
                // null is time()
-               if (is_null($timestamp)) $timestamp = time();
+               if (is_null($timestamp)) {
+                       $timestamp = time();
+               } // END - if
 
                // Then create it
                $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);