Cache loader and autopurge rewritten
authorRoland Häder <roland@mxchange.org>
Sun, 14 Sep 2008 18:13:33 +0000 (18:13 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 14 Sep 2008 18:13:33 +0000 (18:13 +0000)
24 files changed:
.gitattributes
inc/autopurge.php
inc/autopurge/.htaccess [new file with mode: 0644]
inc/autopurge/purge- [new file with mode: 0644]
inc/autopurge/purge-general.php [new file with mode: 0644]
inc/autopurge/purge-inact.php [new file with mode: 0644]
inc/autopurge/purge-mails.php [new file with mode: 0644]
inc/autopurge/purge-tsks.php [new file with mode: 0644]
inc/autopurge/purge-unconfirmed.php [new file with mode: 0644]
inc/databases.php
inc/extensions/ext-nickname.php
inc/load_cache-admin.php [deleted file]
inc/load_cache-config.php [deleted file]
inc/load_cache-modreg.php [deleted file]
inc/load_cache-refdepths.php [deleted file]
inc/load_cache-refsystem.php [deleted file]
inc/load_cache.php
inc/loader/.htaccess [new file with mode: 0644]
inc/loader/load_cache-admin.php [new file with mode: 0644]
inc/loader/load_cache-config.php [new file with mode: 0644]
inc/loader/load_cache-modreg.php [new file with mode: 0644]
inc/loader/load_cache-refdepths.php [new file with mode: 0644]
inc/loader/load_cache-refsystem.php [new file with mode: 0644]
templates/de/html/admin/admin_config_nickname.tpl

index 49b0ff6..05e0196 100644 (file)
@@ -78,6 +78,13 @@ DOCS/validator.sh -text
 inc/.htaccess -text
 inc/.secret/.htaccess -text
 inc/autopurge.php -text
+inc/autopurge/.htaccess -text
+inc/autopurge/purge- -text
+inc/autopurge/purge-general.php -text
+inc/autopurge/purge-inact.php -text
+inc/autopurge/purge-mails.php -text
+inc/autopurge/purge-tsks.php -text
+inc/autopurge/purge-unconfirmed.php -text
 inc/cache/.htaccess -text
 inc/check-reset.php -text
 inc/config.php -text
@@ -209,13 +216,14 @@ inc/libs/task_functions.php -text
 inc/libs/transfer_functions.php -text
 inc/libs/user_functions.php -text
 inc/libs/wernis_functions.php -text
-inc/load_cache-admin.php -text
-inc/load_cache-config.php -text
-inc/load_cache-modreg.php -text
-inc/load_cache-refdepths.php -text
-inc/load_cache-refsystem.php -text
 inc/load_cache.php -text
 inc/load_extensions.php -text
+inc/loader/.htaccess -text
+inc/loader/load_cache-admin.php -text
+inc/loader/load_cache-config.php -text
+inc/loader/load_cache-modreg.php -text
+inc/loader/load_cache-refdepths.php -text
+inc/loader/load_cache-refsystem.php -text
 inc/mails/.htaccess -text
 inc/mails/_mails.php -text
 inc/mails/beg_mails.php -text
index a0896be..c01be28 100644 (file)
  ************************************************************************/
 
 // Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
-{
+if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
        require($INC);
-}
-
-if (($_CONFIG['auto_purge_active'] == "Y") && ($_CONFIG['auto_purge'] > 0))
-{
-       // First calculate the timestamp
-       if (function_exists('CREATE_TIME_SELECTIONS'))
-       {
-               $PURGE = time() - $_CONFIG['auto_purge'];
-       }
-        else
-       {
-               $PURGE = time() - $_CONFIG['auto_purge'] * 24 * 60 * 60;
-       }
-
-       // Init variables
-       $admin_points = 0;
-
-       // Then check for outdated mail order. We don't delete them just the confirmation links will be deleted.
-       $result = SQL_QUERY_ESC("SELECT s.id, s.userid, s.pool_id, t.price
-FROM "._MYSQL_PREFIX."_user_stats AS s
-LEFT JOIN "._MYSQL_PREFIX."_payments AS t
-ON s.payment_id=t.id
-WHERE s.timestamp_ordered <= %s ORDER BY s.userid",
-        array(bigintval($PURGE)), __FILE__, __LINE__);
-       if (SQL_NUMROWS($result) > 0)
-       {
-               // Start deleting procedure
-               $uid = 0; $points = 0;
-               while(list($mid, $sender, $pool, $price) = SQL_FETCHROW($result))
-               {
-                       // Check if confirmation links are purged or not
-                       $result_links = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%s LIMIT 1",
-                        array(bigintval($mid)), __FILE__, __LINE__);
-                       if (SQL_NUMROWS($result_links) == 1)
-                       {
-                               // Free memory
-                               SQL_FREERESULT($result_links);
-
-                               // At least one link was found, enougth to pay back the points
-                               if (($uid != $sender) && ($uid > 0) && ($points > 0))
-                               {
-                                       // Directly add points back to senders account
-                                       AUTOPURGE_ADD_POINTS($uid, $points);
-                                       $points = 0;
-                               }
-                               // Add points
-                               $uid = $sender; $points += $price; $admin_points += $price;
-
-                               // Remove confirmation links from queue
-                               $result_del = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%s",
-                                array(bigintval($mid)), __FILE__, __LINE__);
-
-                               // Update status of order
-                               $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='DELETED' WHERE id=%s LIMIT 1",
-                                array(bigintval($pool)), __FILE__, __LINE__);
-                       }
-               }
-
-               // Add last points to last user account
-               if ($points > 0) AUTOPURGE_ADD_POINTS($uid, $points);
-       }
-
-       // Free memory
-       SQL_FREERESULT($result);
-
-       // Is the 'bonus' extension installed and activated?
-       if (EXT_IS_ACTIVE("bonus", true))
-       {
-               // Check for bonus campaigns
-               $result = SQL_QUERY_ESC("SELECT id, points FROM "._MYSQL_PREFIX."_bonus WHERE data_type='SEND' AND timestamp <= %s ORDER BY id",
-                array(bigintval($PURGE)), __FILE__, __LINE__);
-               if (SQL_NUMROWS($result) > 0)
-               {
-                       // Start deleting procedure
-                       $points = 0;
-                       while (list($bid, $price) = SQL_FETCHROW($result))
-                       {
-                               // Check if confirmation links are purged or not
-                               $result_links = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_links WHERE bonus_id=%s",
-                                array(bigintval($bid)), __FILE__, __LINE__);
-                               if (SQL_NUMROWS($result_links) > 0)
-                               {
-                                       // At least one link was found, enougth to pay back the points
-                                       $points += $price * SQL_NUMROWS($result_links);
-
-                                       // Free memory
-                                       SQL_FREERESULT($result_links);
-
-                                       // Remove confirmation links from queue
-                                       $result_del = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE bonus_id=%s",
-                                        array(bigintval($bid)), __FILE__, __LINE__);
-
-                                       // Update status of order
-                                       $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_bonus SET data_type='DELETED' WHERE id=%s LIMIT 1",
-                                        array(bigintval($bid)), __FILE__, __LINE__);
-                               }
-                       }
-
-                       // Add points to jackpot
-                       ADD_JACKPOT($points);
-
-                       // Add points for the admin
-                       $admin_points += $points;
-               }
-
-               // Free memory
-               SQL_FREERESULT($result);
-       }
-
-       // Add points from deleted accounts to jackpot, but here just add to notify mail
-       if ($admin_points > 0)
-       {
-               // Send mail to admin
-               SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_SUBJECT, "admin_autopurge_points", TRANSLATE_COMMA($points), "0");
-       }
-}
-
-// Shall I look for inactive accounts and autopurge inactive accounts?
-if ($_CONFIG['ap_inactive'] == "Y")
-{
-       // Ok, let's have a look...
-       $since = bigintval(time() - $_CONFIG['ap_in_since']);
-       $EXCLUDE_LIST = " AND d.userid != c.def_refid";
-
-       // Check for more extensions
-       if (EXT_IS_ACTIVE("beg"))     $EXCLUDE_LIST .= " AND d.userid != c.beg_uid";
-       if (EXT_IS_ACTIVE("bonus"))   $EXCLUDE_LIST .= " AND d.userid != c.bonus_uid";
-       if (EXT_IS_ACTIVE("doubler")) $EXCLUDE_LIST .= " AND d.userid != c.doubler_uid";
-
-       // Check for new holiday extension
-       if (GET_EXT_VERSION("holiday") >= "0.1.3")
-       {
-               $EXCLUDE_LIST .= " AND d.holiday_active = 'N'";
-       }
-
-       // Check for all accounts
-       $result_inactive = SQL_QUERY_ESC("SELECT DISTINCT d.userid, d.email, d.last_online
-FROM "._MYSQL_PREFIX."_user_data AS d, "._MYSQL_PREFIX."_config AS c
-WHERE d.status='CONFIRMED' AND d.joined < %s AND d.last_online < %s AND d.ap_notified < %s
-".$EXCLUDE_LIST."
-ORDER BY d.userid", array($since, $since, $since), __FILE__, __LINE__);
-
-       if (SQL_NUMROWS($result_inactive) > 0)
-       {
-               // Prepare variables and constants...
-               $UIDs = "";
-               define('__INACTIVE_SINCE', ($_CONFIG['ap_in_since'] / 60 / 60));
-               define('__INACTIVE_TIME' , ($_CONFIG['ap_in_time']  / 60 / 60));
-
-               // Mark found accounts as inactive and send an email
-               while(list($uid, $email, $last) = SQL_FETCHROW($result_inactive))
-               {
-                       // Remember userids for the admin
-                       $UIDs .= $uid.", ";
-
-                       // Get date/time from timestamp
-                       $last = MAKE_DATETIME($last, "0");
-
-                       // Load mail template
-                       $msg = LOAD_EMAIL_TEMPLATE("member_autopurge_inactive", $last, bigintval($uid));
-                       SEND_EMAIL($email, AUTOPURGE_MEMBER_INACTIVE_SUBJECT, $msg);
-
-                       // Update this account
-                       $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET ap_notified=UNIX_TIMESTAMP() WHERE userid=%s LIMIT 1",
-                        array(bigintval($uid)), __FILE__, __LINE__);
-               }
-
-               // Remove last comma
-               $UIDs = str_replace(", ", "\n", substr($UIDs, 0, -2));
-
-               // Send mail notification to admin
-               SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_INACTIVE_SUBJECT, "admin_autopurge_inactive", $UIDs, "");
-       }
+} // END - if
 
-       // Free memory
-       SQL_FREERESULT($result_inactive);
+// Load all includes
+$INC_POOL = GET_DIR_AS_ARRAY(PATH."inc/autopurge/", "purge-");
 
-       // Now let's have a look for inactive accounts we want to delete we newly use the same exclude list
-       // here for e.g. excluding holiday users
-       $time = bigintval(time() - $_CONFIG['ap_in_time']);
-       $result_inactive = SQL_QUERY_ESC("SELECT d.userid, d.email, d.last_online
-FROM "._MYSQL_PREFIX."_user_data AS d, "._MYSQL_PREFIX."_config AS c
-WHERE status='CONFIRMED' AND joined < %s AND last_online< %s AND ap_notified < %s
-".$EXCLUDE_LIST."
-ORDER BY userid",
-        array($since, $since, $time), __FILE__, __LINE__);
-       if (SQL_NUMROWS($result_inactive) > 0)
-       {
-               // Prepare variable...
-               $UIDs = "";
-
-               // Delete inactive accounts
-               while (list($uid, $email, $last) = SQL_FETCHROW($result_inactive))
-               {
-                       // Remember userids for the admin
-                       $UIDs .= $uid.", ";
-
-                       // Get date/time from timestamp
-                       $last = MAKE_DATETIME($last, "0");
-
-                       // Finnaly delete this inactive account
-                       DELETE_USER_ACCOUNT(bigintval($uid), LOAD_EMAIL_TEMPLATE("member_autopurge_delete", $last, ""));
-               }
-
-               // Remove last comma
-               $UIDs = str_replace(", ", "\n", substr($UIDs, 0, -2));
-
-               // Send mail notification to admin
-               if ($_CONFIG['ap_un_mail'] == "Y")
-               {
-                       SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_DELETE_SUBJECT, "admin_autopurge_delete", $UIDs, "");
-               }
-       }
-
-       // Free memory
-       SQL_FREERESULT($result_inactive);
-}
-
-// Shall I auto-purge unconfirmed accounts?
-if ($_CONFIG['ap_unconfirmed'] == "Y")
-{
-       // Init variables and find unconfirmed accounts which I shall auto-purge
-       $time = bigintval(time() - $_CONFIG['ap_un_time']);
-       $result_uncon = SQL_QUERY_ESC("SELECT userid, email, joined FROM "._MYSQL_PREFIX."_user_data WHERE status='UNCONFIRMED' AND joined < %s ORDER BY userid",
-        array($time), __FILE__, __LINE__);
-       if (SQL_NUMROWS($result_uncon) > 0)
-       {
-               // Prepare variable...
-               $UIDs = "";
-               define('__UNCONFIRMED_TIME' , ($_CONFIG['ap_un_time']  / 60 / 60));
-
-               // Delete inactive accounts
-               while (list($uid, $email, $joined) = SQL_FETCHROW($result_uncon))
-               {
-                       // Remember userids for the admin
-                       $UIDs .= $uid.", ";
-
-                       // Get date/time from timestamp
-                       $joined = MAKE_DATETIME($joined, "0");
-
-                       // Finnaly delete this inactive account
-                       DELETE_USER_ACCOUNT($uid, LOAD_EMAIL_TEMPLATE("member_autopurge_unconfirmed", $joined, ""));
-               }
-
-               // Remove last comma
-               $UIDs = str_replace(", ", "\n", substr($UIDs, 0, -2));
-
-               // Send mail notification to admin
-               if ($_CONFIG['ap_un_mail'] == "Y")
-               {
-                       SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_UNCONFIRMED_SUBJECT, "admin_autopurge_unconfirmed", $UIDs, "");
-               }
-       }
-
-       // Free memory
-       SQL_FREERESULT($result_uncon);
-}
-
-// Check version (must be > 0.0)
-if ((GET_EXT_VERSION("task") > "0.0") && ($_CONFIG['ap_tasks'] == "Y"))
-{
-       // Purge deleted tasks (no notification to admin)
-       $since = bigintval(time() - $_CONFIG['ap_tasks_time']);
-       $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_task_system WHERE status='DELETED' AND task_created <= %s",
-        array($since), __FILE__, __LINE__);
-       $DELETED = SQL_AFFECTEDROWS();
-
-       if (($DELETED > 0) && ($_CONFIG['ap_tasks_mail'] == "Y"))
-       {
-               // Send out email to admin
-               SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_TASKS_SUBJECT, "admin_autopurge_tsks", $DELETED, "");
-       }
-}
-
-// Search for mails from deleted members?
-if ($_CONFIG['ap_del_mails']) {
-       // Okay, let's check for them...
-       $since = bigintval(time() - $_CONFIG['ap_dm_timeout']);
-       $result_mails = SQL_QUERY_ESC("SELECT sender FROM "._MYSQL_PREFIX."_pool WHERE data_type='DELETED' AND timestamp <= %s ORDER BY sender",
-        array($since), __FILE__, __LINE__);
-
-       // Reset counter...
-       $DELETED = 0;
-
-       // Do we have "purged" mails?
-       if (SQL_NUMROWS($result_mails) > 0) {
-               // Okay, check for their sender's
-               while(list($sender) = SQL_FETCHROW($result_mails)) {
-                       // Check now...
-                       $fount = SQL_NUMROWS(SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array(bigintval($sender)), __FILE__, __LINE__));
-                       if ($found == 0) {
-                               // Okay we found some mails!
-                               $result_remove = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_pool WHERE sender=%s",
-                                array(bigintval($sender)), __FILE__, __LINE__);
-                               $DELETED += SQL_AFFECTEDROWS();
-
-                               // Reset query (to prevent possible errors) ...
-                               $since = bigintval(time() - $_CONFIG['ap_dm_timeout']);
-                               $result_mails = SQL_QUERY_ESC("SELECT sender FROM "._MYSQL_PREFIX."_pool WHERE data_type='DELETED' AND timestamp <= %s ORDER BY sender",
-                                array($since), __FILE__, __LINE__);
-                       }
-               }
-       }
-
-       // Free memory
-       SQL_FREERESULT($result_mails);
-
-       // Now let's check for stats entries as well
-       $since = bigintval(time() - $_CONFIG['ap_dm_timeout']);
-       $result_mails = SQL_QUERY_ESC("SELECT sender FROM "._MYSQL_PREFIX."_pool WHERE data_type='DELETED' AND timestamp <= %s ORDER BY sender",
-        array($since), __FILE__, __LINE__);
-
-       // Do we have "purged" mails?
-       if (SQL_NUMROWS($result_mails) > 0) {
-               // Okay, check for their sender's
-               while(list($sender) = SQL_FETCHROW($result_mails)) {
-                       // Check now...
-                       $found = SQL_NUMROWS(SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array(bigintval($sender)), __FILE__, __LINE__));
-                       if ($found == 0) {
-                               // Okay we found some mails!
-                               $result_remove = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_stats WHERE sender=%s", array(bigintval($sender)), __FILE__, __LINE__);
-                               $DELETED += SQL_AFFECTEDROWS();
-
-                               // Reset query (to prevent possible errors) ...
-                               $since = bigintval(time() - $_CONFIG['ap_dm_timeout']);
-                               $result_mails = SQL_QUERY_ESC("SELECT sender FROM "._MYSQL_PREFIX."_user_stats WHERE data_type='DELETED' AND timestamp_send <= %s ORDER BY sender",
-                                array($since), __FILE__, __LINE__);
-                       }
-               }
-       }
-
-       // Free memory
-       SQL_FREERESULT($result_mails);
-
-       // Do we have deleted mails and the admin want's to receive a notification
-       if (($DELETED > 0) && ($_CONFIG['ap_dm_notify'] == "Y")) {
-               // Send out email to admin
-               SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_DEL_MAILS_SUBJECT, "admin_autopurge_del_mails", $DELETED, "");
-       }
-}
+// Include them all
+foreach ($INC_POOL as $fqfn) {
+       // Load them only once
+       require_once($fqfn);
+} // END - foreach
 
 if (EXT_IS_ACTIVE("rallye")) {
        // Check expired rallyes (hard-coded 3 days limit for displaying expired rallyes!)
diff --git a/inc/autopurge/.htaccess b/inc/autopurge/.htaccess
new file mode 100644 (file)
index 0000000..14249c5
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
\ No newline at end of file
diff --git a/inc/autopurge/purge- b/inc/autopurge/purge-
new file mode 100644 (file)
index 0000000..7c83019
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 09/14/2008 *
+ * ===============                              Last change: 09/14/2008 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : purge-                                           *
+ * -------------------------------------------------------------------- *
+ * Short description :                                                  *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  :                                                  *
+ * -------------------------------------------------------------------- *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       require($INC);
+} // END - if
+
+// Abort if autopurge is not active or disabled by admin
+if ((!EXT_IS_ACTIVE("autopurge")) || ($_CONFIG['auto_purge_active'] == "N")) {
+       // Abort here
+       return false;
+} // END - if
+
+//
+?>
diff --git a/inc/autopurge/purge-general.php b/inc/autopurge/purge-general.php
new file mode 100644 (file)
index 0000000..95a88e9
--- /dev/null
@@ -0,0 +1,151 @@
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 09/14/2008 *
+ * ===============                              Last change: 09/14/2008 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : purge-general.php                                *
+ * -------------------------------------------------------------------- *
+ * Short description : General autopurging, nothing extension-specific  *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Allgemeine, nicht erweiterunsabhaengige Auto-    *
+ *                     Loeschung                                        *
+ * -------------------------------------------------------------------- *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       require($INC);
+}
+
+// Abort if autopurge is not active or disabled by admin
+if ((!EXT_IS_ACTIVE("autopurge")) || ($_CONFIG['auto_purge_active'] == "N")) {
+       // Abort here
+       return false;
+}
+
+if (($_CONFIG['auto_purge_active'] == "Y") && ($_CONFIG['auto_purge'] > 0)) {
+       // First calculate the timestamp
+       if (function_exists('CREATE_TIME_SELECTIONS')) {
+               $PURGE = $_CONFIG['auto_purge'];
+       } else {
+               $PURGE = $_CONFIG['auto_purge'] * 24 * 60 * 60;
+       }
+
+       // Init variables
+       $admin_points = 0;
+
+       // Then check for outdated mail order. We don't delete them just the confirmation links will be deleted.
+       $result = SQL_QUERY_ESC("SELECT s.id, s.userid, s.pool_id, t.price
+FROM "._MYSQL_PREFIX."_user_stats AS s
+LEFT JOIN "._MYSQL_PREFIX."_payments AS t
+ON s.payment_id=t.id
+WHERE s.timestamp_ordered <= (UNIX_TIMESTAMP() - %s) ORDER BY s.userid",
+        array(bigintval($PURGE)), __FILE__, __LINE__);
+       if (SQL_NUMROWS($result) > 0) {
+               // Start deleting procedure
+               $uid = 0; $points = 0;
+               while(list($mid, $sender, $pool, $price) = SQL_FETCHROW($result)) {
+                       // Check if confirmation links are purged or not
+                       $result_links = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%s LIMIT 1",
+                        array(bigintval($mid)), __FILE__, __LINE__);
+                       if (SQL_NUMROWS($result_links) == 1) {
+                               // Free memory
+                               SQL_FREERESULT($result_links);
+
+                               // At least one link was found, enougth to pay back the points
+                               if (($uid != $sender) && ($uid > 0) && ($points > 0)) {
+                                       // Directly add points back to senders account
+                                       AUTOPURGE_ADD_POINTS($uid, $points);
+                                       $points = 0;
+                               } // END - if
+
+                               // Add points
+                               $uid = $sender; $points += $price; $admin_points += $price;
+
+                               // Remove confirmation links from queue
+                               $result_del = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%s",
+                                array(bigintval($mid)), __FILE__, __LINE__);
+
+                               // Update status of order
+                               $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='DELETED' WHERE id=%s LIMIT 1",
+                                array(bigintval($pool)), __FILE__, __LINE__);
+                       } // END - if
+               } // END - while
+
+               // Add last points to last user account
+               if ($points > 0) AUTOPURGE_ADD_POINTS($uid, $points);
+       } // END - if
+
+       // Free memory
+       SQL_FREERESULT($result);
+
+       // Is the 'bonus' extension installed and activated?
+       if (EXT_IS_ACTIVE("bonus", true)) {
+               // Check for bonus campaigns
+               $result = SQL_QUERY_ESC("SELECT id, points FROM "._MYSQL_PREFIX."_bonus WHERE data_type='SEND' AND timestamp <= %s ORDER BY id",
+                array(bigintval($PURGE)), __FILE__, __LINE__);
+               if (SQL_NUMROWS($result) > 0) {
+                       // Start deleting procedure
+                       $points = 0;
+                       while (list($bid, $price) = SQL_FETCHROW($result)) {
+                               // Check if confirmation links are purged or not
+                               $result_links = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_links WHERE bonus_id=%s",
+                                array(bigintval($bid)), __FILE__, __LINE__);
+                               if (SQL_NUMROWS($result_links) > 0) {
+                                       // At least one link was found, enougth to pay back the points
+                                       $points += $price * SQL_NUMROWS($result_links);
+
+                                       // Free memory
+                                       SQL_FREERESULT($result_links);
+
+                                       // Remove confirmation links from queue
+                                       $result_del = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE bonus_id=%s",
+                                        array(bigintval($bid)), __FILE__, __LINE__);
+
+                                       // Update status of order
+                                       $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_bonus SET data_type='DELETED' WHERE id=%s LIMIT 1",
+                                        array(bigintval($bid)), __FILE__, __LINE__);
+                               } // END - if
+                       } // END - while
+
+                       // Add points to jackpot
+                       ADD_JACKPOT($points);
+
+                       // Add points for the admin
+                       $admin_points += $points;
+               } // END - if
+
+               // Free memory
+               SQL_FREERESULT($result);
+       } // END - if
+
+       // Add points from deleted accounts to jackpot, but here just add to notify mail
+       if ($admin_points > 0) {
+               // Send mail to admin
+               SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_SUBJECT, "admin_autopurge_points", TRANSLATE_COMMA($points), "0");
+       } // END - if
+} // END - if
+
+//
+?>
diff --git a/inc/autopurge/purge-inact.php b/inc/autopurge/purge-inact.php
new file mode 100644 (file)
index 0000000..ee36736
--- /dev/null
@@ -0,0 +1,142 @@
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 09/14/2008 *
+ * ===============                              Last change: 09/14/2008 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : purge-inactive.php                               *
+ * -------------------------------------------------------------------- *
+ * Short description : Purge of inactive users                          *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Auto-Loeschung von inaktiven Mitgliedern         *
+ * -------------------------------------------------------------------- *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       require($INC);
+}
+
+// Abort if autopurge is not active or disabled by admin
+if ((!EXT_IS_ACTIVE("autopurge")) || ($_CONFIG['auto_purge_active'] == "N")) {
+       // Abort here
+       return false;
+}
+
+// Shall I look for inactive accounts and autopurge inactive accounts?
+if ($_CONFIG['ap_inactive'] == "Y") {
+       // Ok, let's have a look...
+       $since = bigintval($_CONFIG['ap_in_since']);
+       $EXCLUDE_LIST = " AND d.userid != c.def_refid";
+
+       // Check for more extensions
+       if (EXT_IS_ACTIVE("beg"))     $EXCLUDE_LIST .= " AND d.userid != c.beg_uid";
+       if (EXT_IS_ACTIVE("bonus"))   $EXCLUDE_LIST .= " AND d.userid != c.bonus_uid";
+       if (EXT_IS_ACTIVE("doubler")) $EXCLUDE_LIST .= " AND d.userid != c.doubler_uid";
+
+       // Check for new holiday extension
+       if (GET_EXT_VERSION("holiday") >= "0.1.3") {
+               // Include only users with no active holiday
+               $EXCLUDE_LIST .= " AND d.holiday_active = 'N'";
+       } // END - if
+
+       // Check for all accounts
+       $result_inactive = SQL_QUERY_ESC("SELECT DISTINCT d.userid, d.email, d.last_online
+FROM "._MYSQL_PREFIX."_user_data AS d, "._MYSQL_PREFIX."_config AS c
+WHERE d.status='CONFIRMED' AND d.joined < (UNIX_TIMESTAMP() - %s) AND d.last_online < (UNIX_TIMESTAMP() - %s) AND d.ap_notified < (UNIX_TIMESTAMP() - %s)
+".$EXCLUDE_LIST."
+ORDER BY d.userid", array($since, $since, $since), __FILE__, __LINE__);
+
+       if (SQL_NUMROWS($result_inactive) > 0) {
+               // Prepare variables and constants...
+               $UIDs = "";
+               define('__INACTIVE_SINCE', ($_CONFIG['ap_in_since'] / 60 / 60));
+               define('__INACTIVE_TIME' , ($_CONFIG['ap_in_time']  / 60 / 60));
+
+               // Mark found accounts as inactive and send an email
+               while(list($uid, $email, $last) = SQL_FETCHROW($result_inactive)) {
+                       // Remember userids for the admin
+                       $UIDs .= $uid.", ";
+
+                       // Get date/time from timestamp
+                       $last = MAKE_DATETIME($last, "0");
+
+                       // Load mail template
+                       $msg = LOAD_EMAIL_TEMPLATE("member_autopurge_inactive", $last, bigintval($uid));
+                       SEND_EMAIL($email, AUTOPURGE_MEMBER_INACTIVE_SUBJECT, $msg);
+
+                       // Update this account
+                       $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET ap_notified=UNIX_TIMESTAMP() WHERE userid=%s LIMIT 1",
+                        array(bigintval($uid)), __FILE__, __LINE__);
+               } // END - while
+
+               // Remove last comma
+               $UIDs = str_replace(", ", "\n", substr($UIDs, 0, -2));
+
+               // Send mail notification to admin
+               SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_INACTIVE_SUBJECT, "admin_autopurge_inactive", $UIDs, "");
+       } // END - if
+
+       // Free memory
+       SQL_FREERESULT($result_inactive);
+
+       // Now let's have a look for inactive accounts we want to delete we newly use the same exclude list
+       // here for e.g. excluding holiday users
+       $time = bigintval($_CONFIG['ap_in_time']);
+       $result_inactive = SQL_QUERY_ESC("SELECT d.userid, d.email, d.last_online
+FROM "._MYSQL_PREFIX."_user_data AS d, "._MYSQL_PREFIX."_config AS c
+WHERE status='CONFIRMED' AND joined < (UNIX_TIMESTAMP() - %s) AND last_online < (UNIX_TIMESTAMP() - %s) AND ap_notified < (UNIX_TIMESTAMP() - %s)
+".$EXCLUDE_LIST."
+ORDER BY userid",
+        array($since, $since, $time), __FILE__, __LINE__);
+       if (SQL_NUMROWS($result_inactive) > 0) {
+               // Prepare variable...
+               $UIDs = "";
+
+               // Delete inactive accounts
+               while (list($uid, $email, $last) = SQL_FETCHROW($result_inactive)) {
+                       // Remember userids for the admin
+                       $UIDs .= $uid.", ";
+
+                       // Get date/time from timestamp
+                       $last = MAKE_DATETIME($last, "0");
+
+                       // Finnaly delete this inactive account
+                       DELETE_USER_ACCOUNT(bigintval($uid), LOAD_EMAIL_TEMPLATE("member_autopurge_delete", $last, ""));
+               } // END - while
+
+               // Remove last comma
+               $UIDs = str_replace(", ", "\n", substr($UIDs, 0, -2));
+
+               // Send mail notification to admin
+               if ($_CONFIG['ap_un_mail'] == "Y") {
+                       SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_DELETE_SUBJECT, "admin_autopurge_delete", $UIDs, "");
+               } // END - if
+       } // END - if
+
+       // Free memory
+       SQL_FREERESULT($result_inactive);
+} // END - if
+
+//
+?>
diff --git a/inc/autopurge/purge-mails.php b/inc/autopurge/purge-mails.php
new file mode 100644 (file)
index 0000000..ccedb84
--- /dev/null
@@ -0,0 +1,127 @@
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 05/29/2004 *
+ * ===============                              Last change: 11/26/2004 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : autopurge.php                                    *
+ * -------------------------------------------------------------------- *
+ * Short description : Automatical purging of outdated mail links       *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Auto-Loeschung von veralteten Mail-Links         *
+ * -------------------------------------------------------------------- *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       require($INC);
+} // END - if
+
+// Abort if autopurge is not active or disabled by admin
+if ((!EXT_IS_ACTIVE("autopurge")) || ($_CONFIG['auto_purge_active'] == "N")) {
+       // Abort here
+       return false;
+} // END - if
+
+// Search for mails from deleted members?
+if ($_CONFIG['ap_del_mails'] == "Y") {
+       // Okay, let's check for them...
+       $since = bigintval($_CONFIG['ap_dm_timeout']);
+       $result_mails = SQL_QUERY_ESC("SELECT sender\
+FROM "._MYSQL_PREFIX."_pool
+WHERE data_type='DELETED' AND timestamp <= (UNIX_TIMESTAMP() - %s)
+ORDER BY sender ASC",
+        array($since), __FILE__, __LINE__);
+
+       // Reset counter...
+       $DELETED = 0;
+
+       // Do we have "purged" mails?
+       if (SQL_NUMROWS($result_mails) > 0) {
+               // Okay, check for their sender's
+               while(list($sender) = SQL_FETCHROW($result_mails)) {
+                       // Check now...
+                       $fount = SQL_NUMROWS(SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
+                               array(bigintval($sender)), __FILE__, __LINE__));
+                       if ($found == 0) {
+                               // Okay we found some mails!
+                               $result_remove = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_pool WHERE sender=%s",
+                                       array(bigintval($sender)), __FILE__, __LINE__);
+                               $DELETED += SQL_AFFECTEDROWS();
+
+                               // Reset query (to prevent possible errors) ...
+                               $since = bigintval($_CONFIG['ap_dm_timeout']);
+                               $result_mails = SQL_QUERY_ESC("SELECT sender
+FROM "._MYSQL_PREFIX."_pool
+WHERE data_type='DELETED' AND timestamp <= (UNIX_TIMESTAMP() - %s)
+ORDER BY sender ASC",
+                                       array($since), __FILE__, __LINE__);
+                       }
+               }
+       }
+
+       // Free memory
+       SQL_FREERESULT($result_mails);
+
+       // Now let's check for stats entries as well
+       $since = bigintval($_CONFIG['ap_dm_timeout']);
+       $result_mails = SQL_QUERY_ESC("SELECT sender
+FROM "._MYSQL_PREFIX."_user_stats
+WHERE data_type='DELETED' AND timestamp_send <= (UNIX_TIMESTAMP() - %s)
+ORDER BY sender ASC",
+               array($since), __FILE__, __LINE__);
+
+       // Do we have "purged" mails?
+       if (SQL_NUMROWS($result_mails) > 0) {
+               // Okay, check for their sender's
+               while(list($sender) = SQL_FETCHROW($result_mails)) {
+                       // Check now...
+                       $found = SQL_NUMROWS(SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array(bigintval($sender)), __FILE__, __LINE__));
+                       if ($found == 0) {
+                               // Okay we found some mails!
+                               $result_remove = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_stats WHERE sender=%s", array(bigintval($sender)), __FILE__, __LINE__);
+                               $DELETED += SQL_AFFECTEDROWS();
+
+                               // Reset query (to prevent possible errors) ...
+                               $since = bigintval($_CONFIG['ap_dm_timeout']);
+                               $result_mails = SQL_QUERY_ESC("SELECT sender
+FROM "._MYSQL_PREFIX."_user_stats
+WHERE data_type='DELETED' AND timestamp_send <= (UNIX_TIMESTAMP() - %s)
+ORDER BY sender ASC",
+                                       array($since), __FILE__, __LINE__);
+                       }
+               }
+       }
+
+       // Free memory
+       SQL_FREERESULT($result_mails);
+
+       // Do we have deleted mails and the admin want's to receive a notification
+       if (($DELETED > 0) && ($_CONFIG['ap_dm_notify'] == "Y")) {
+               // Send out email to admin
+               SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_DEL_MAILS_SUBJECT, "admin_autopurge_del_mails", $DELETED, "");
+       }
+}
+
+//
+?>
diff --git a/inc/autopurge/purge-tsks.php b/inc/autopurge/purge-tsks.php
new file mode 100644 (file)
index 0000000..e862111
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 09/14/2008 *
+ * ===============                              Last change: 09/14/2008 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : purge-tsks.php                                   *
+ * -------------------------------------------------------------------- *
+ * Short description : Automatical purging of outdated mail links       *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Auto-Loeschung von veralteten Mail-Links         *
+ * -------------------------------------------------------------------- *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       require($INC);
+} // END - if
+
+// Abort if autopurge is not active or disabled by admin
+if ((!EXT_IS_ACTIVE("autopurge")) || ($_CONFIG['auto_purge_active'] == "N")) {
+       // Abort here
+       return false;
+} // END - if
+
+// Check version (must be > 0.0)
+if ((GET_EXT_VERSION("task") > "0.0") && ($_CONFIG['ap_tasks'] == "Y")) {
+       // Since when shall we purge?
+       $since = bigintval($_CONFIG['ap_tasks_time']);
+
+       // Purge deleted tasks (no notification to admin)
+       $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY
+FROM "._MYSQL_PREFIX."_task_system
+WHERE status='DELETED' AND task_created <= (UNIX_TIMESTAMP() - %s)",
+        array($since), __FILE__, __LINE__);
+       $DELETED = SQL_AFFECTEDROWS();
+
+       if (($DELETED > 0) && ($_CONFIG['ap_tasks_mail'] == "Y")) {
+               // Send out email to admin
+               SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_TASKS_SUBJECT, "admin_autopurge_tsks", $DELETED, "");
+       } // END - if
+} // END - if
+
+//
+?>
diff --git a/inc/autopurge/purge-unconfirmed.php b/inc/autopurge/purge-unconfirmed.php
new file mode 100644 (file)
index 0000000..dd6c7fe
--- /dev/null
@@ -0,0 +1,86 @@
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 05/29/2004 *
+ * ===============                              Last change: 11/26/2004 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : autopurge.php                                    *
+ * -------------------------------------------------------------------- *
+ * Short description : Automatical purging of outdated mail links       *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Auto-Loeschung von veralteten Mail-Links         *
+ * -------------------------------------------------------------------- *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       require($INC);
+} // END - if
+
+// Abort if autopurge is not active or disabled by admin
+if ((!EXT_IS_ACTIVE("autopurge")) || ($_CONFIG['auto_purge_active'] == "N")) {
+       // Abort here
+       return false;
+} // END - if
+
+// Shall I auto-purge unconfirmed accounts?
+if ($_CONFIG['ap_unconfirmed'] == "Y") {
+       // Init variables and find unconfirmed accounts which I shall auto-purge
+       $time = bigintval($_CONFIG['ap_un_time']);
+       $result_uncon = SQL_QUERY_ESC("SELECT userid, email, joined
+FROM "._MYSQL_PREFIX."_user_data
+WHERE status='UNCONFIRMED' AND joined < (UNIX_TIMESTAMP() - %s)
+ORDER BY userid ASC",
+        array($time), __FILE__, __LINE__);
+       if (SQL_NUMROWS($result_uncon) > 0) {
+               // Prepare variable...
+               $UIDs = "";
+               define('__UNCONFIRMED_TIME' , ($_CONFIG['ap_un_time']  / 60 / 60));
+
+               // Delete inactive accounts
+               while (list($uid, $email, $joined) = SQL_FETCHROW($result_uncon)) {
+                       // Remember userids for the admin
+                       $UIDs .= $uid.", ";
+
+                       // Get date/time from timestamp
+                       $joined = MAKE_DATETIME($joined, "0");
+
+                       // Finnaly delete this inactive account
+                       DELETE_USER_ACCOUNT($uid, LOAD_EMAIL_TEMPLATE("member_autopurge_unconfirmed", $joined, ""));
+               } // END - while
+
+               // Remove last comma
+               $UIDs = str_replace(", ", "\n", substr($UIDs, 0, -2));
+
+               // Send mail notification to admin
+               if ($_CONFIG['ap_un_mail'] == "Y") {
+                       SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_UNCONFIRMED_SUBJECT, "admin_autopurge_unconfirmed", $UIDs, "");
+               } // END - if
+       } // END - if
+
+       // Free memory
+       SQL_FREERESULT($result_uncon);
+}
+
+//
+?>
index 67b179c..6e1f7aa 100644 (file)
@@ -114,7 +114,7 @@ define('USAGE_BASE', "usage");
 define('SERVER_URL', "http://www.mxchange.org");
 
 // This current patch level
-define('CURR_SVN_REVISION', "325");
+define('CURR_SVN_REVISION', "326");
 
 // Take a prime number which is long (if you know a longer one please try it out!)
 define('_PRIME', 591623);
index 6a0dc98..ce6a707 100644 (file)
@@ -39,13 +39,13 @@ if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])))
 }
 
 // Version number
-$EXT_VERSION = "0.1.7";
+$EXT_VERSION = "0.1.9";
 
 // Auto-set extension version
 if (empty($EXT_VER)) $EXT_VER = $EXT_VERSION;
 
 // Version history array (add more with , "0.1" and so on)
-$EXT_VER_HISTORY = 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");
+$EXT_VER_HISTORY = 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");
 
 switch ($EXT_LOAD_MODE)
 {
@@ -61,8 +61,9 @@ case "register": // Do stuff when installtion is running (modules.php?module=adm
 
 case "remove": // Do stuff when removing extension
        // SQL commands to run
-       $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_member_menu WHERE action='main' AND what='nickname' LIMIT 1";
-       $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admin_menu WHERE what='config_nickname' LIMIT 1";
+       $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_member_menu WHERE what='nickname' LIMIT 1";
+       $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admin_menu WHERE what IN ('config_nickname','list_nickname') LIMIT 2";
+       $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_nickname_history";
        break;
 
 case "activate": // Do stuff when admin activates this extension
@@ -178,10 +179,16 @@ case "update": // Update an extension
                break;
 
        case "0.1.9": // SQL queries for v0.1.9
-               $SQLs[] = "DROP TABLE "._MYSQL_PREFIX."_nickname_history";
+               $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES('user', 'list_nickname', 'Nickname-Historie', 'Listet alle verwendeten Nicknames der Mitglieder auf.', 12)";
+               $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_nickname_history";
                $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_nickname_history (
 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
 userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+nickname VARCHAR(255) NOT NULL DEFAULT '',
+added TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+last_used TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
+INDEX userid (userid),
+INDEX (last_used DESC),
 PRIMARY KEY(id)
 ) TYPE=MyISAM COMMENT='History of used nicknames'";
 
diff --git a/inc/load_cache-admin.php b/inc/load_cache-admin.php
deleted file mode 100644 (file)
index e6d2822..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-<?php
-/************************************************************************
- * MXChange v0.2.1                                    Start: 09/09/2008 *
- * ===============                              Last change: 09/09/2008 *
- *                                                                      *
- * -------------------------------------------------------------------- *
- * File              : load_cache-config.php                            *
- * -------------------------------------------------------------------- *
- * Short description : Load more cache files                            *
- * -------------------------------------------------------------------- *
- * Kurzbeschreibung  : Mehr Cache-Dateien nachladen                     *
- * -------------------------------------------------------------------- *
- *                                                                      *
- * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
- * 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
-}
-
-// Let's start with the admins table...
-if (($cacheInstance->cache_file("admins", true) == true)) {
-       // Load cache
-       global $cacheArray;
-       $cacheArray['admins'] = $cacheInstance->cache_load();
-
-       // Check if valid
-       if ((is_array($cacheArray['admins']['login'])) && (is_array($cacheArray['admins']['aid']))) {
-               // Check count
-               if (count($cacheArray['admins']['login']) == count($cacheArray['admins']['aid'])) {
-                       //* DEBUG: */ echo "<PRE>";
-                       //* DEBUG: */ print_r($cacheArray['admins']);
-
-                       // The cache file seems to be fine
-                       foreach ($cacheArray['admins']['login'] as $k => $login) {
-                               // Rewrite default_acl
-                               $cacheArray['admins']['aid'][$login]      = $cacheArray['admins']['aid'][$k];
-                               $cacheArray['admins']['password'][$login] = $cacheArray['admins']['password'][$k];
-                               $cacheArray['admins']['email'][$login]    = $cacheArray['admins']['email'][$k];
-
-                               // Some extra data depening on version
-                               if (GET_EXT_VERSION("admins") >= "0.3") {
-                                       $cacheArray['admins']['def_acl'][$login]  = $cacheArray['admins']['def_acl'][$k];
-                                       if (GET_EXT_VERSION("admins") >= "0.6.7") {
-                                               $cacheArray['admins']['la_mode'][$login]  = $cacheArray['admins']['la_mode'][$k];
-                                       }
-                               }
-
-                               //* DEBUG: */ print_r($cacheArray['admins']);
-
-                               // Clear array
-                               if (isset($cacheArray['admins']['aid'][$k]))            unset($cacheArray['admins']['aid'][$k]);
-                               if (isset($cacheArray['admins']['def_acl'][$k]))        unset($cacheArray['admins']['def_acl'][$k]);
-                               if (isset($cacheArray['admins']['la_mode'][$k]))        unset($cacheArray['admins']['la_mode'][$k]);
-                               if (isset($cacheArray['admins']['password'][$k]))       unset($cacheArray['admins']['password'][$k]);
-                               if (isset($cacheArray['admins']['email'][$k]))  unset($cacheArray['admins']['email'][$k]);
-                       }
-
-                       //* DEBUG: */ print_r($cacheArray['admins']);
-
-                       // Rewrite Login
-                       foreach ($cacheArray['admins']['login'] as $k => $login) {
-                               $cacheArray['admins']['login'][$cacheArray['admins']['aid'][$login]] = $login;
-                               if (!in_array($k, $cacheArray['admins']['aid'])) {
-                                       unset($cacheArray['admins']['login'][$k]);
-                               }
-                       }
-
-                       //* DEBUG: */ echo "****\n";
-                       //* DEBUG: */ print_r($cacheArray['admins']);
-                       //* DEBUG: */ echo "</PRE>";
-                       //* DEBUG: */ die();
-               } else {
-                       // Nope, cache file is corrupted!
-                       $cacheInstance->cache_destroy();
-               }
-       } else {
-               // Nope, cache file is corrupted!
-               $cacheInstance->cache_destroy();
-               unset($cacheArray['admins']);
-       }
-} elseif (($_CONFIG['cache_admins'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
-       // Create cache file
-       $cacheInstance->cache_init("ADMINS");
-
-       // Load every data from DB to cache file
-       $ADD = ", id, id";
-       if (GET_EXT_VERSION("admins") >= "0.3")   $ADD  = ", default_acl AS def_acl";
-       if (GET_EXT_VERSION("admins") >= "0.6.7") $ADD .= ", la_mode";
-
-       // Query the database about this
-       $result_admins = SQL_QUERY("SELECT id AS aid, login, password, email".$ADD."
-FROM "._MYSQL_PREFIX."_admins
-ORDER BY login", __FILE__, __LINE__);
-       while($dummy = SQL_FETCHARRAY($result_admins)) {
-               // Save row
-               $cacheInstance->add_row($dummy);
-       }
-
-       // Free memory
-       SQL_FREERESULT($result_admins);
-}
-
-// Close file
-$cacheInstance->cache_close();
-
-// Next cached table are the admins_acls...
-if (GET_EXT_VERSION("admins") >= "0.3") {
-       // Check for cache file
-       if ($cacheInstance->cache_file("admins_acls", true) == true) {
-               // Load referral system from cache
-               global $cacheArray;
-               $cacheArray['admin_acls'] = $cacheInstance->cache_load();
-
-               // Valid cache file
-               $CNT = 0;
-               foreach ($cacheArray['admin_acls'] as $k => $array) {
-                       $CNT += count($array);
-               }
-
-               // When there is a period (.) in the result this test will fail and so the cache file is
-               // damaged/corrupted
-               if (count($cacheArray['admin_acls']) > 0) {
-                       $TEST = "failed";
-                       if (count($cacheArray['admin_acls']) > 0 ) $TEST = ($CNT / (count($cacheArray['admin_acls'])));
-                       if ($TEST != bigintval($TEST)) {
-                               // Cache file is corrupted!
-                               $cacheInstance->cache_destroy();
-                               unset($cacheArray['admin_acls']);
-                       }
-               }
-       } elseif (($_CONFIG['cache_acls'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
-               // Create cache file here
-               $cacheInstance->cache_init("ADMINS_ACLS");
-
-               // Load all modules and their data
-               $result = SQL_QUERY("SELECT id, admin_id, action_menu, what_menu, access_mode FROM "._MYSQL_PREFIX."_admins_acls ORDER BY admin_id, action_menu, what_menu", __FILE__, __LINE__);
-               while ($DATA = SQL_FETCHARRAY($result)) {
-                       // Add row to cache file
-                       $cacheInstance->add_row($DATA);
-               }
-
-               // Free memory
-               SQL_FREERESULT($result);
-       }
-
-       // Close file
-       $cacheInstance->cache_close();
-}
-
-//
-?>
diff --git a/inc/load_cache-config.php b/inc/load_cache-config.php
deleted file mode 100644 (file)
index 94d8862..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-<?php
-/************************************************************************
- * MXChange v0.2.1                                    Start: 09/09/2008 *
- * ===============                              Last change: 09/09/2008 *
- *                                                                      *
- * -------------------------------------------------------------------- *
- * File              : load_cache-config.php                            *
- * -------------------------------------------------------------------- *
- * Short description : Load more cache files                            *
- * -------------------------------------------------------------------- *
- * Kurzbeschreibung  : Mehr Cache-Dateien nachladen                     *
- * -------------------------------------------------------------------- *
- *                                                                      *
- * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
- * 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
-}
-
-// Next cached table is the configuration (config)...
-if ($cacheInstance->cache_file("config", true) == true) {
-       // Load config from cache
-       global $cacheArray;
-       $cacheArrayConfig = $cacheInstance->cache_load();
-
-       // Valid cache file
-       $CNT = 0; $newCache = array();
-       foreach ($cacheArrayConfig as $key => $array) {
-               foreach ($array as $key2 => $value) {
-                       $newCache[$key2][$key] = $value;
-               }
-               $CNT += count($array);
-       }
-
-       // Overwrite the config with the cache version
-       $cacheArray['config'] = $newCache;
-       unset($newCache);
-
-       // When there is a period (.) in the result this test will fail and so the cache file is
-       // damaged/corrupted
-       $TEST = "failed";
-       if (count($cacheArray['config']) > 0 ) $TEST = ($CNT / (count($cacheArray['config'])));
-       if ($TEST != bigintval($TEST)) {
-               // Cache file is corrupted!
-               $cacheInstance->cache_destroy();
-               unset($cacheArray['config']);
-       }
-} elseif (($_CONFIG['cache_config'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
-       // Create cache file here
-       $cacheInstance->cache_init("CONFIG");
-
-       // Load all modules and their data
-       $result = SQL_QUERY("SELECT * FROM "._MYSQL_PREFIX."_config ORDER BY config", __FILE__, __LINE__);
-       while ($DATA = SQL_FETCHARRAY($result)) {
-               // Add row to cache file
-               $cacheInstance->add_row($DATA);
-       }
-
-       // Free memory
-       SQL_FREERESULT($result);
-}
-
-// Close file
-$cacheInstance->cache_close();
-
-//
-?>
diff --git a/inc/load_cache-modreg.php b/inc/load_cache-modreg.php
deleted file mode 100644 (file)
index d835fc6..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-<?php
-/************************************************************************
- * MXChange v0.2.1                                    Start: 09/09/2008 *
- * ===============                              Last change: 09/09/2008 *
- *                                                                      *
- * -------------------------------------------------------------------- *
- * File              : load_cache-config.php                            *
- * -------------------------------------------------------------------- *
- * Short description : Load more cache files                            *
- * -------------------------------------------------------------------- *
- * Kurzbeschreibung  : Mehr Cache-Dateien nachladen                     *
- * -------------------------------------------------------------------- *
- *                                                                      *
- * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
- * 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
-}
-
-// Next cached table is the module registry (mod_reg)...
-if ($cacheInstance->cache_file("mod_reg", true) == true) {
-       // Load cache
-       global $cacheArray;
-       $cacheArray['modules'] = $cacheInstance->cache_load();
-
-       // Valid cache file
-       $CNT = 0;
-       foreach ($cacheArray['modules'] as $k => $array) {
-               $CNT += count($array);
-       }
-
-       // When there is a period (.) in the result this test will fail and so the cache file is
-       // damaged/corrupted
-       $TEST = "failed";
-       if (count($cacheArray['modules']) > 0 ) $TEST = ($CNT / (count($cacheArray['modules'])));
-       if ($TEST != bigintval($TEST)) {
-               // Cache file is corrupted!
-               $cacheInstance->cache_destroy();
-               unset($cacheArray['modules']);
-       } else {
-               // Rewrite module cache
-               $modArray = $cacheArray['modules'];
-               foreach ($modArray['module'] as $key => $mod) {
-                       $cacheArray['modules']['id'][$mod] = $modArray['id'][$key];
-                       unset($cacheArray['modules']['id'][$key]);
-                       $cacheArray['modules']['title'][$mod] = $modArray['title'][$key];
-                       unset($cacheArray['modules']['title'][$key]);
-                       $cacheArray['modules']['locked'][$mod] = $modArray['locked'][$key];
-                       unset($cacheArray['modules']['locked'][$key]);
-                       $cacheArray['modules']['hidden'][$mod] = $modArray['hidden'][$key];
-                       unset($cacheArray['modules']['hidden'][$key]);
-                       $cacheArray['modules']['admin_only'][$mod] = $modArray['admin_only'][$key];
-                       unset($cacheArray['modules']['admin_only'][$key]);
-                       $cacheArray['modules']['mem_only'][$mod] = $modArray['mem_only'][$key];
-                       unset($cacheArray['modules']['mem_only'][$key]);
-                       if (isset($cacheArray['modules']['has_menu'][$key])) {
-                               $cacheArray['modules']['has_menu'][$mod] = $modArray['has_menu'][$key];
-                               unset($cacheArray['modules']['has_menu'][$key]);
-                       } // END - if
-               }
-               unset($modArray);
-       }
-} elseif (($_CONFIG['cache_modreg'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
-       // Create cache file here
-       $cacheInstance->cache_init("MODULES");
-
-       // Load all modules and their data
-       if (GET_EXT_VERSION("sql_patches") >= "0.3.6") {
-               // Load has_menu
-               $result = SQL_QUERY("SELECT id, module, title, locked, hidden, admin_only, title, mem_only, has_menu
-FROM "._MYSQL_PREFIX."_mod_reg ORDER BY id", __FILE__, __LINE__);
-       } else {
-               // Don't load has_menu
-               $result = SQL_QUERY("SELECT id, module, title, locked, hidden, admin_only, title, mem_only
-FROM "._MYSQL_PREFIX."_mod_reg ORDER BY id", __FILE__, __LINE__);
-       }
-       while ($DATA = SQL_FETCHARRAY($result)) {
-               // Add row to cache file
-               $cacheInstance->add_row($DATA);
-       }
-
-       // Free memory
-       SQL_FREERESULT($result);
-}
-
-// Close file
-$cacheInstance->cache_close();
-
-//
-?>
diff --git a/inc/load_cache-refdepths.php b/inc/load_cache-refdepths.php
deleted file mode 100644 (file)
index fc84d19..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-<?php
-/************************************************************************
- * MXChange v0.2.1                                    Start: 09/09/2008 *
- * ===============                              Last change: 09/09/2008 *
- *                                                                      *
- * -------------------------------------------------------------------- *
- * File              : load_cache-config.php                            *
- * -------------------------------------------------------------------- *
- * Short description : Load more cache files                            *
- * -------------------------------------------------------------------- *
- * Kurzbeschreibung  : Mehr Cache-Dateien nachladen                     *
- * -------------------------------------------------------------------- *
- *                                                                      *
- * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
- * 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
-}
-
-// Next cached table is the referral system (refdepths)...
-if ($cacheInstance->cache_file("refdepths", true) == true) {
-       // Load referral system from cache
-       global $cacheArray;
-       $cacheArray['ref_depths'] = $cacheInstance->cache_load();
-
-       // Valid cache file
-       $CNT = 0;
-       foreach ($cacheArray['ref_depths'] as $k => $array) {
-               $CNT += count($array);
-       }
-
-       // When there is a period (.) in the result this test will fail and so the cache file is
-       // damaged/corrupted
-       $TEST = "failed";
-       if (count($cacheArray['ref_depths']) > 0 ) $TEST = ($CNT / (count($cacheArray['ref_depths'])));
-       if ($TEST != bigintval($TEST)) {
-               // Cache file is corrupted!
-               $cacheInstance->cache_destroy();
-               unset($cacheArray['ref_depths']);
-       }
-} elseif (($_CONFIG['cache_refdepth'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
-       // Create cache file here
-       $cacheInstance->cache_init("REFDEPTHS");
-
-       // Load all modules and their data
-       $result = SQL_QUERY("SELECT id, level, percents FROM "._MYSQL_PREFIX."_refdepths ORDER BY level", __FILE__, __LINE__);
-       while ($DATA = SQL_FETCHARRAY($result)) {
-               // Add row to cache file
-               $cacheInstance->add_row($DATA);
-       }
-
-       // Free memory
-       SQL_FREERESULT($result);
-}
-
-// Close file
-$cacheInstance->cache_close();
-
-// Next cached table is the referral system (admins_acls)...
-if (GET_EXT_VERSION("admins") >= "0.3") {
-       // Check for cache file
-       if ($cacheInstance->cache_file("admins_acls", true) == true) {
-               // Load referral system from cache
-               global $cacheArray;
-               $cacheArray['admin_acls'] = $cacheInstance->cache_load();
-
-               // Valid cache file
-               $CNT = 0;
-               foreach ($cacheArray['admin_acls'] as $k => $array) {
-                       $CNT += count($array);
-               }
-
-               // When there is a period (.) in the result this test will fail and so the cache file is
-               // damaged/corrupted
-               if (count($cacheArray['admin_acls']) > 0) {
-                       $TEST = "failed";
-                       if (count($cacheArray['admin_acls']) > 0 ) $TEST = ($CNT / (count($cacheArray['admin_acls'])));
-                       if ($TEST != bigintval($TEST)) {
-                               // Cache file is corrupted!
-                               $cacheInstance->cache_destroy();
-                               unset($cacheArray['admin_acls']);
-                       }
-               }
-       } elseif (($_CONFIG['cache_acls'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
-               // Create cache file here
-               $cacheInstance->cache_init("ADMINS_ACLS");
-
-               // Load all modules and their data
-               $result = SQL_QUERY("SELECT id, admin_id, action_menu, what_menu, access_mode FROM "._MYSQL_PREFIX."_admins_acls ORDER BY admin_id, action_menu, what_menu", __FILE__, __LINE__);
-               while ($DATA = SQL_FETCHARRAY($result)) {
-                       // Add row to cache file
-                       $cacheInstance->add_row($DATA);
-               }
-
-               // Free memory
-               SQL_FREERESULT($result);
-       }
-
-       // Close file
-       $cacheInstance->cache_close();
-}
-
-//
-?>
diff --git a/inc/load_cache-refsystem.php b/inc/load_cache-refsystem.php
deleted file mode 100644 (file)
index 4fd0764..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-/************************************************************************
- * MXChange v0.2.1                                    Start: 09/09/2008 *
- * ===============                              Last change: 09/09/2008 *
- *                                                                      *
- * -------------------------------------------------------------------- *
- * File              : load_cache-config.php                            *
- * -------------------------------------------------------------------- *
- * Short description : Load more cache files                            *
- * -------------------------------------------------------------------- *
- * Kurzbeschreibung  : Mehr Cache-Dateien nachladen                     *
- * -------------------------------------------------------------------- *
- *                                                                      *
- * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
- * 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
-}
-
-// Next cached table is the referral system (refsystem)...
-if ($cacheInstance->cache_file("refsystem", true) == true) {
-       // Load referral system from cache
-       global $cacheArray;
-       $cacheArray['ref_system'] = $cacheInstance->cache_load();
-
-       // Valid cache file
-       $CNT = 0;
-       foreach ($cacheArray['ref_system'] as $k => $array) {
-               $CNT += count($array);
-       }
-
-       // We now ignore empty cache here
-} elseif (($_CONFIG['cache_refsys'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
-       // Create cache file here
-       $cacheInstance->cache_init("refsystem");
-
-       // Load all modules and their data
-       $result = SQL_QUERY("SELECT id, userid, level, counter FROM "._MYSQL_PREFIX."_refsystem ORDER BY userid, level", __FILE__, __LINE__);
-       while ($DATA = SQL_FETCHARRAY($result)) {
-               // Add row to cache file
-               $cacheInstance->add_row($DATA);
-       }
-
-       // Free memory
-       SQL_FREERESULT($result);
-}
-
-// Close file
-$cacheInstance->cache_close();
-
-//
-?>
index 37449da..c63d925 100644 (file)
@@ -37,20 +37,14 @@ if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
        require($INC);
 }
 
-// Load admin cache
-require_once(PATH."inc/load_cache-admin.php");
+// Load more cache includes
+$INC_POOL = GET_DIR_AS_ARRAY(PATH."inc/loader/", "load_cache-");
 
-// Load mod_reg cache
-require_once(PATH."inc/load_cache-modreg.php");
-
-// Load config cache
-require_once(PATH."inc/load_cache-config.php");
-
-// Load refsystem cache
-require_once(PATH."inc/load_cache-refsystem.php");
-
-// Load refdepths cache
-require_once(PATH."inc/load_cache-refdepths.php");
+// Include all
+foreach ($INC_POOL as $fqfn) {
+       // Include the file
+       require_once($fqfn);
+} // END - foreach
 
 //
 ?>
diff --git a/inc/loader/.htaccess b/inc/loader/.htaccess
new file mode 100644 (file)
index 0000000..14249c5
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
\ No newline at end of file
diff --git a/inc/loader/load_cache-admin.php b/inc/loader/load_cache-admin.php
new file mode 100644 (file)
index 0000000..e6d2822
--- /dev/null
@@ -0,0 +1,171 @@
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 09/09/2008 *
+ * ===============                              Last change: 09/09/2008 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : load_cache-config.php                            *
+ * -------------------------------------------------------------------- *
+ * Short description : Load more cache files                            *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Mehr Cache-Dateien nachladen                     *
+ * -------------------------------------------------------------------- *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       require($INC);
+}
+
+// Let's start with the admins table...
+if (($cacheInstance->cache_file("admins", true) == true)) {
+       // Load cache
+       global $cacheArray;
+       $cacheArray['admins'] = $cacheInstance->cache_load();
+
+       // Check if valid
+       if ((is_array($cacheArray['admins']['login'])) && (is_array($cacheArray['admins']['aid']))) {
+               // Check count
+               if (count($cacheArray['admins']['login']) == count($cacheArray['admins']['aid'])) {
+                       //* DEBUG: */ echo "<PRE>";
+                       //* DEBUG: */ print_r($cacheArray['admins']);
+
+                       // The cache file seems to be fine
+                       foreach ($cacheArray['admins']['login'] as $k => $login) {
+                               // Rewrite default_acl
+                               $cacheArray['admins']['aid'][$login]      = $cacheArray['admins']['aid'][$k];
+                               $cacheArray['admins']['password'][$login] = $cacheArray['admins']['password'][$k];
+                               $cacheArray['admins']['email'][$login]    = $cacheArray['admins']['email'][$k];
+
+                               // Some extra data depening on version
+                               if (GET_EXT_VERSION("admins") >= "0.3") {
+                                       $cacheArray['admins']['def_acl'][$login]  = $cacheArray['admins']['def_acl'][$k];
+                                       if (GET_EXT_VERSION("admins") >= "0.6.7") {
+                                               $cacheArray['admins']['la_mode'][$login]  = $cacheArray['admins']['la_mode'][$k];
+                                       }
+                               }
+
+                               //* DEBUG: */ print_r($cacheArray['admins']);
+
+                               // Clear array
+                               if (isset($cacheArray['admins']['aid'][$k]))            unset($cacheArray['admins']['aid'][$k]);
+                               if (isset($cacheArray['admins']['def_acl'][$k]))        unset($cacheArray['admins']['def_acl'][$k]);
+                               if (isset($cacheArray['admins']['la_mode'][$k]))        unset($cacheArray['admins']['la_mode'][$k]);
+                               if (isset($cacheArray['admins']['password'][$k]))       unset($cacheArray['admins']['password'][$k]);
+                               if (isset($cacheArray['admins']['email'][$k]))  unset($cacheArray['admins']['email'][$k]);
+                       }
+
+                       //* DEBUG: */ print_r($cacheArray['admins']);
+
+                       // Rewrite Login
+                       foreach ($cacheArray['admins']['login'] as $k => $login) {
+                               $cacheArray['admins']['login'][$cacheArray['admins']['aid'][$login]] = $login;
+                               if (!in_array($k, $cacheArray['admins']['aid'])) {
+                                       unset($cacheArray['admins']['login'][$k]);
+                               }
+                       }
+
+                       //* DEBUG: */ echo "****\n";
+                       //* DEBUG: */ print_r($cacheArray['admins']);
+                       //* DEBUG: */ echo "</PRE>";
+                       //* DEBUG: */ die();
+               } else {
+                       // Nope, cache file is corrupted!
+                       $cacheInstance->cache_destroy();
+               }
+       } else {
+               // Nope, cache file is corrupted!
+               $cacheInstance->cache_destroy();
+               unset($cacheArray['admins']);
+       }
+} elseif (($_CONFIG['cache_admins'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
+       // Create cache file
+       $cacheInstance->cache_init("ADMINS");
+
+       // Load every data from DB to cache file
+       $ADD = ", id, id";
+       if (GET_EXT_VERSION("admins") >= "0.3")   $ADD  = ", default_acl AS def_acl";
+       if (GET_EXT_VERSION("admins") >= "0.6.7") $ADD .= ", la_mode";
+
+       // Query the database about this
+       $result_admins = SQL_QUERY("SELECT id AS aid, login, password, email".$ADD."
+FROM "._MYSQL_PREFIX."_admins
+ORDER BY login", __FILE__, __LINE__);
+       while($dummy = SQL_FETCHARRAY($result_admins)) {
+               // Save row
+               $cacheInstance->add_row($dummy);
+       }
+
+       // Free memory
+       SQL_FREERESULT($result_admins);
+}
+
+// Close file
+$cacheInstance->cache_close();
+
+// Next cached table are the admins_acls...
+if (GET_EXT_VERSION("admins") >= "0.3") {
+       // Check for cache file
+       if ($cacheInstance->cache_file("admins_acls", true) == true) {
+               // Load referral system from cache
+               global $cacheArray;
+               $cacheArray['admin_acls'] = $cacheInstance->cache_load();
+
+               // Valid cache file
+               $CNT = 0;
+               foreach ($cacheArray['admin_acls'] as $k => $array) {
+                       $CNT += count($array);
+               }
+
+               // When there is a period (.) in the result this test will fail and so the cache file is
+               // damaged/corrupted
+               if (count($cacheArray['admin_acls']) > 0) {
+                       $TEST = "failed";
+                       if (count($cacheArray['admin_acls']) > 0 ) $TEST = ($CNT / (count($cacheArray['admin_acls'])));
+                       if ($TEST != bigintval($TEST)) {
+                               // Cache file is corrupted!
+                               $cacheInstance->cache_destroy();
+                               unset($cacheArray['admin_acls']);
+                       }
+               }
+       } elseif (($_CONFIG['cache_acls'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
+               // Create cache file here
+               $cacheInstance->cache_init("ADMINS_ACLS");
+
+               // Load all modules and their data
+               $result = SQL_QUERY("SELECT id, admin_id, action_menu, what_menu, access_mode FROM "._MYSQL_PREFIX."_admins_acls ORDER BY admin_id, action_menu, what_menu", __FILE__, __LINE__);
+               while ($DATA = SQL_FETCHARRAY($result)) {
+                       // Add row to cache file
+                       $cacheInstance->add_row($DATA);
+               }
+
+               // Free memory
+               SQL_FREERESULT($result);
+       }
+
+       // Close file
+       $cacheInstance->cache_close();
+}
+
+//
+?>
diff --git a/inc/loader/load_cache-config.php b/inc/loader/load_cache-config.php
new file mode 100644 (file)
index 0000000..94d8862
--- /dev/null
@@ -0,0 +1,87 @@
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 09/09/2008 *
+ * ===============                              Last change: 09/09/2008 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : load_cache-config.php                            *
+ * -------------------------------------------------------------------- *
+ * Short description : Load more cache files                            *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Mehr Cache-Dateien nachladen                     *
+ * -------------------------------------------------------------------- *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       require($INC);
+}
+
+// Next cached table is the configuration (config)...
+if ($cacheInstance->cache_file("config", true) == true) {
+       // Load config from cache
+       global $cacheArray;
+       $cacheArrayConfig = $cacheInstance->cache_load();
+
+       // Valid cache file
+       $CNT = 0; $newCache = array();
+       foreach ($cacheArrayConfig as $key => $array) {
+               foreach ($array as $key2 => $value) {
+                       $newCache[$key2][$key] = $value;
+               }
+               $CNT += count($array);
+       }
+
+       // Overwrite the config with the cache version
+       $cacheArray['config'] = $newCache;
+       unset($newCache);
+
+       // When there is a period (.) in the result this test will fail and so the cache file is
+       // damaged/corrupted
+       $TEST = "failed";
+       if (count($cacheArray['config']) > 0 ) $TEST = ($CNT / (count($cacheArray['config'])));
+       if ($TEST != bigintval($TEST)) {
+               // Cache file is corrupted!
+               $cacheInstance->cache_destroy();
+               unset($cacheArray['config']);
+       }
+} elseif (($_CONFIG['cache_config'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
+       // Create cache file here
+       $cacheInstance->cache_init("CONFIG");
+
+       // Load all modules and their data
+       $result = SQL_QUERY("SELECT * FROM "._MYSQL_PREFIX."_config ORDER BY config", __FILE__, __LINE__);
+       while ($DATA = SQL_FETCHARRAY($result)) {
+               // Add row to cache file
+               $cacheInstance->add_row($DATA);
+       }
+
+       // Free memory
+       SQL_FREERESULT($result);
+}
+
+// Close file
+$cacheInstance->cache_close();
+
+//
+?>
diff --git a/inc/loader/load_cache-modreg.php b/inc/loader/load_cache-modreg.php
new file mode 100644 (file)
index 0000000..d835fc6
--- /dev/null
@@ -0,0 +1,110 @@
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 09/09/2008 *
+ * ===============                              Last change: 09/09/2008 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : load_cache-config.php                            *
+ * -------------------------------------------------------------------- *
+ * Short description : Load more cache files                            *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Mehr Cache-Dateien nachladen                     *
+ * -------------------------------------------------------------------- *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       require($INC);
+}
+
+// Next cached table is the module registry (mod_reg)...
+if ($cacheInstance->cache_file("mod_reg", true) == true) {
+       // Load cache
+       global $cacheArray;
+       $cacheArray['modules'] = $cacheInstance->cache_load();
+
+       // Valid cache file
+       $CNT = 0;
+       foreach ($cacheArray['modules'] as $k => $array) {
+               $CNT += count($array);
+       }
+
+       // When there is a period (.) in the result this test will fail and so the cache file is
+       // damaged/corrupted
+       $TEST = "failed";
+       if (count($cacheArray['modules']) > 0 ) $TEST = ($CNT / (count($cacheArray['modules'])));
+       if ($TEST != bigintval($TEST)) {
+               // Cache file is corrupted!
+               $cacheInstance->cache_destroy();
+               unset($cacheArray['modules']);
+       } else {
+               // Rewrite module cache
+               $modArray = $cacheArray['modules'];
+               foreach ($modArray['module'] as $key => $mod) {
+                       $cacheArray['modules']['id'][$mod] = $modArray['id'][$key];
+                       unset($cacheArray['modules']['id'][$key]);
+                       $cacheArray['modules']['title'][$mod] = $modArray['title'][$key];
+                       unset($cacheArray['modules']['title'][$key]);
+                       $cacheArray['modules']['locked'][$mod] = $modArray['locked'][$key];
+                       unset($cacheArray['modules']['locked'][$key]);
+                       $cacheArray['modules']['hidden'][$mod] = $modArray['hidden'][$key];
+                       unset($cacheArray['modules']['hidden'][$key]);
+                       $cacheArray['modules']['admin_only'][$mod] = $modArray['admin_only'][$key];
+                       unset($cacheArray['modules']['admin_only'][$key]);
+                       $cacheArray['modules']['mem_only'][$mod] = $modArray['mem_only'][$key];
+                       unset($cacheArray['modules']['mem_only'][$key]);
+                       if (isset($cacheArray['modules']['has_menu'][$key])) {
+                               $cacheArray['modules']['has_menu'][$mod] = $modArray['has_menu'][$key];
+                               unset($cacheArray['modules']['has_menu'][$key]);
+                       } // END - if
+               }
+               unset($modArray);
+       }
+} elseif (($_CONFIG['cache_modreg'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
+       // Create cache file here
+       $cacheInstance->cache_init("MODULES");
+
+       // Load all modules and their data
+       if (GET_EXT_VERSION("sql_patches") >= "0.3.6") {
+               // Load has_menu
+               $result = SQL_QUERY("SELECT id, module, title, locked, hidden, admin_only, title, mem_only, has_menu
+FROM "._MYSQL_PREFIX."_mod_reg ORDER BY id", __FILE__, __LINE__);
+       } else {
+               // Don't load has_menu
+               $result = SQL_QUERY("SELECT id, module, title, locked, hidden, admin_only, title, mem_only
+FROM "._MYSQL_PREFIX."_mod_reg ORDER BY id", __FILE__, __LINE__);
+       }
+       while ($DATA = SQL_FETCHARRAY($result)) {
+               // Add row to cache file
+               $cacheInstance->add_row($DATA);
+       }
+
+       // Free memory
+       SQL_FREERESULT($result);
+}
+
+// Close file
+$cacheInstance->cache_close();
+
+//
+?>
diff --git a/inc/loader/load_cache-refdepths.php b/inc/loader/load_cache-refdepths.php
new file mode 100644 (file)
index 0000000..fc84d19
--- /dev/null
@@ -0,0 +1,124 @@
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 09/09/2008 *
+ * ===============                              Last change: 09/09/2008 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : load_cache-config.php                            *
+ * -------------------------------------------------------------------- *
+ * Short description : Load more cache files                            *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Mehr Cache-Dateien nachladen                     *
+ * -------------------------------------------------------------------- *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       require($INC);
+}
+
+// Next cached table is the referral system (refdepths)...
+if ($cacheInstance->cache_file("refdepths", true) == true) {
+       // Load referral system from cache
+       global $cacheArray;
+       $cacheArray['ref_depths'] = $cacheInstance->cache_load();
+
+       // Valid cache file
+       $CNT = 0;
+       foreach ($cacheArray['ref_depths'] as $k => $array) {
+               $CNT += count($array);
+       }
+
+       // When there is a period (.) in the result this test will fail and so the cache file is
+       // damaged/corrupted
+       $TEST = "failed";
+       if (count($cacheArray['ref_depths']) > 0 ) $TEST = ($CNT / (count($cacheArray['ref_depths'])));
+       if ($TEST != bigintval($TEST)) {
+               // Cache file is corrupted!
+               $cacheInstance->cache_destroy();
+               unset($cacheArray['ref_depths']);
+       }
+} elseif (($_CONFIG['cache_refdepth'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
+       // Create cache file here
+       $cacheInstance->cache_init("REFDEPTHS");
+
+       // Load all modules and their data
+       $result = SQL_QUERY("SELECT id, level, percents FROM "._MYSQL_PREFIX."_refdepths ORDER BY level", __FILE__, __LINE__);
+       while ($DATA = SQL_FETCHARRAY($result)) {
+               // Add row to cache file
+               $cacheInstance->add_row($DATA);
+       }
+
+       // Free memory
+       SQL_FREERESULT($result);
+}
+
+// Close file
+$cacheInstance->cache_close();
+
+// Next cached table is the referral system (admins_acls)...
+if (GET_EXT_VERSION("admins") >= "0.3") {
+       // Check for cache file
+       if ($cacheInstance->cache_file("admins_acls", true) == true) {
+               // Load referral system from cache
+               global $cacheArray;
+               $cacheArray['admin_acls'] = $cacheInstance->cache_load();
+
+               // Valid cache file
+               $CNT = 0;
+               foreach ($cacheArray['admin_acls'] as $k => $array) {
+                       $CNT += count($array);
+               }
+
+               // When there is a period (.) in the result this test will fail and so the cache file is
+               // damaged/corrupted
+               if (count($cacheArray['admin_acls']) > 0) {
+                       $TEST = "failed";
+                       if (count($cacheArray['admin_acls']) > 0 ) $TEST = ($CNT / (count($cacheArray['admin_acls'])));
+                       if ($TEST != bigintval($TEST)) {
+                               // Cache file is corrupted!
+                               $cacheInstance->cache_destroy();
+                               unset($cacheArray['admin_acls']);
+                       }
+               }
+       } elseif (($_CONFIG['cache_acls'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
+               // Create cache file here
+               $cacheInstance->cache_init("ADMINS_ACLS");
+
+               // Load all modules and their data
+               $result = SQL_QUERY("SELECT id, admin_id, action_menu, what_menu, access_mode FROM "._MYSQL_PREFIX."_admins_acls ORDER BY admin_id, action_menu, what_menu", __FILE__, __LINE__);
+               while ($DATA = SQL_FETCHARRAY($result)) {
+                       // Add row to cache file
+                       $cacheInstance->add_row($DATA);
+               }
+
+               // Free memory
+               SQL_FREERESULT($result);
+       }
+
+       // Close file
+       $cacheInstance->cache_close();
+}
+
+//
+?>
diff --git a/inc/loader/load_cache-refsystem.php b/inc/loader/load_cache-refsystem.php
new file mode 100644 (file)
index 0000000..4fd0764
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 09/09/2008 *
+ * ===============                              Last change: 09/09/2008 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : load_cache-config.php                            *
+ * -------------------------------------------------------------------- *
+ * Short description : Load more cache files                            *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Mehr Cache-Dateien nachladen                     *
+ * -------------------------------------------------------------------- *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       require($INC);
+}
+
+// Next cached table is the referral system (refsystem)...
+if ($cacheInstance->cache_file("refsystem", true) == true) {
+       // Load referral system from cache
+       global $cacheArray;
+       $cacheArray['ref_system'] = $cacheInstance->cache_load();
+
+       // Valid cache file
+       $CNT = 0;
+       foreach ($cacheArray['ref_system'] as $k => $array) {
+               $CNT += count($array);
+       }
+
+       // We now ignore empty cache here
+} elseif (($_CONFIG['cache_refsys'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
+       // Create cache file here
+       $cacheInstance->cache_init("refsystem");
+
+       // Load all modules and their data
+       $result = SQL_QUERY("SELECT id, userid, level, counter FROM "._MYSQL_PREFIX."_refsystem ORDER BY userid, level", __FILE__, __LINE__);
+       while ($DATA = SQL_FETCHARRAY($result)) {
+               // Add row to cache file
+               $cacheInstance->add_row($DATA);
+       }
+
+       // Free memory
+       SQL_FREERESULT($result);
+}
+
+// Close file
+$cacheInstance->cache_close();
+
+//
+?>
index 07d0e99..d015fc7 100644 (file)
@@ -1,7 +1,5 @@
-<FORM action="{!URL!}/modules.php?module=admin&amp;what=config_nickname"
-       method="POST">
-<TABLE border="0" cellspacing="0" cellpadding="0" width="580"
-       class="admin_table dashed">
+<FORM action="{!URL!}/modules.php?module=admin&amp;what=config_nickname" method="POST">
+<TABLE border="0" cellspacing="0" cellpadding="0" width="580" class="admin_table dashed">
        <TR>
                <TD colspan="3" align="center" class="admin_title bottom2" height="30">
                <STRONG>{--NICKNAME_ADMIN_CONFIG_HEADER--}</STRONG></TD>
@@ -12,9 +10,9 @@
        <TR>
                <TD width="400" align="right">{--ADMIN_NICKNAME_MIN_LENGTH--}:</TD>
                <TD class="seperator" width="10">&nbsp;</TD>
-               <TD width="170"><INPUT type="text" name="nickname_len"
-                       class="admin_normal" value="{!__NICKNAME_LENGTH!}" size="3"
-                       maxlength="4"></TD>
+               <TD width="170">
+                       <INPUT type="text" name="nickname_len" class="admin_normal" value="{!__NICKNAME_LENGTH!}" size="3" maxlength="4" />
+               </TD>
        </TR>
        <TR>
                <TD colspan="3" class="seperator" height="5">&nbsp;</TD>
@@ -22,9 +20,9 @@
        <TR>
                <TD width="400" align="right">{--ADMIN_NICKNAME_PATTERN--}:</TD>
                <TD class="seperator" width="10">&nbsp;</TD>
-               <TD width="170"><INPUT type="text" name="nickname_pattern"
-                       class="admin_normal" value="{!__NICKNAME_PATTERN!}" size="10"
-                       maxlength="255"></TD>
+               <TD width="170">
+                       <INPUT type="text" name="nickname_pattern" class="admin_normal" value="{!__NICKNAME_PATTERN!}" size="10" maxlength="255" />
+               </TD>
        </TR>
        <TR>
                <TD colspan="3" class="seperator" height="5">&nbsp;</TD>
        <TR>
                <TD width="400" align="right">{--ADMIN_NICKNAME_LANG_CHARS--}:</TD>
                <TD class="seperator" width="10">&nbsp;</TD>
-               <TD width="170"><INPUT type="text" name="nickname_chars"
-                       class="admin_normal" value="{!__NICKNAME_LANG_CHARS!}" size="15"
-                       maxlength="255"></TD>
+               <TD width="170">
+                       <INPUT type="text" name="nickname_chars" class="admin_normal" value="{!__NICKNAME_LANG_CHARS!}" size="15" maxlength="255" />
+               </TD>
        </TR>
        <TR>
                <TD colspan="3" class="bottom2 seperator" height="5">&nbsp;</TD>
        </TR>
        <TR>
-               <TD colspan="3" class="admin_footer"><INPUT
-                       type="reset" class="admin_reset" value="{--CLEAR_FORM--}">&nbsp;*&nbsp;<INPUT
-                       type="submit" name="ok" class="admin_submit"
-                       value="{--SAVE_SETTINGS--}"></TD>
+               <TD colspan="3" class="admin_footer">
+                       <INPUT type="reset" class="admin_reset" value="{--CLEAR_FORM--}" />&nbsp;*
+                       <INPUT type="submit" name="ok" class="admin_submit" value="{--SAVE_SETTINGS--}" />
+               </TD>
        </TR>
 </TABLE>
 </FORM>