From: Roland Häder Date: Sun, 14 Sep 2008 18:13:33 +0000 (+0000) Subject: Cache loader and autopurge rewritten X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=3e64a94e122e30dd66db07fd8c8cfae05871c460 Cache loader and autopurge rewritten --- diff --git a/.gitattributes b/.gitattributes index 49b0ff6bf4..05e01963af 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/inc/autopurge.php b/inc/autopurge.php index a0896be2c3..c01be28363 100644 --- a/inc/autopurge.php +++ b/inc/autopurge.php @@ -32,350 +32,19 @@ ************************************************************************/ // 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 index 0000000000..14249c50bd --- /dev/null +++ b/inc/autopurge/.htaccess @@ -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 index 0000000000..7c830194c2 --- /dev/null +++ b/inc/autopurge/purge- @@ -0,0 +1,47 @@ + diff --git a/inc/autopurge/purge-general.php b/inc/autopurge/purge-general.php new file mode 100644 index 0000000000..95a88e9a7b --- /dev/null +++ b/inc/autopurge/purge-general.php @@ -0,0 +1,151 @@ + 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 index 0000000000..ee36736c00 --- /dev/null +++ b/inc/autopurge/purge-inact.php @@ -0,0 +1,142 @@ += "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 index 0000000000..ccedb84110 --- /dev/null +++ b/inc/autopurge/purge-mails.php @@ -0,0 +1,127 @@ + 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 index 0000000000..e862111a45 --- /dev/null +++ b/inc/autopurge/purge-tsks.php @@ -0,0 +1,65 @@ + 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 index 0000000000..dd6c7fedee --- /dev/null +++ b/inc/autopurge/purge-unconfirmed.php @@ -0,0 +1,86 @@ + 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); +} + +// +?> diff --git a/inc/databases.php b/inc/databases.php index 67b179c029..6e1f7aa8e9 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -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); diff --git a/inc/extensions/ext-nickname.php b/inc/extensions/ext-nickname.php index 6a0dc98d9c..ce6a7078f1 100644 --- a/inc/extensions/ext-nickname.php +++ b/inc/extensions/ext-nickname.php @@ -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 index e6d2822e7d..0000000000 --- a/inc/load_cache-admin.php +++ /dev/null @@ -1,171 +0,0 @@ -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 "
";
-			//* 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 "
"; - //* 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 index 94d88621e0..0000000000 --- a/inc/load_cache-config.php +++ /dev/null @@ -1,87 +0,0 @@ -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 index d835fc6668..0000000000 --- a/inc/load_cache-modreg.php +++ /dev/null @@ -1,110 +0,0 @@ -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 index fc84d19627..0000000000 --- a/inc/load_cache-refdepths.php +++ /dev/null @@ -1,124 +0,0 @@ -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 index 4fd07642cc..0000000000 --- a/inc/load_cache-refsystem.php +++ /dev/null @@ -1,72 +0,0 @@ -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(); - -// -?> diff --git a/inc/load_cache.php b/inc/load_cache.php index 37449da665..c63d92561a 100644 --- a/inc/load_cache.php +++ b/inc/load_cache.php @@ -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 index 0000000000..14249c50bd --- /dev/null +++ b/inc/loader/.htaccess @@ -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 index 0000000000..e6d2822e7d --- /dev/null +++ b/inc/loader/load_cache-admin.php @@ -0,0 +1,171 @@ +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 "
";
+			//* 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 "
"; + //* 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 index 0000000000..94d88621e0 --- /dev/null +++ b/inc/loader/load_cache-config.php @@ -0,0 +1,87 @@ +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 index 0000000000..d835fc6668 --- /dev/null +++ b/inc/loader/load_cache-modreg.php @@ -0,0 +1,110 @@ +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 index 0000000000..fc84d19627 --- /dev/null +++ b/inc/loader/load_cache-refdepths.php @@ -0,0 +1,124 @@ +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 index 0000000000..4fd07642cc --- /dev/null +++ b/inc/loader/load_cache-refsystem.php @@ -0,0 +1,72 @@ +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(); + +// +?> diff --git a/templates/de/html/admin/admin_config_nickname.tpl b/templates/de/html/admin/admin_config_nickname.tpl index 07d0e99556..d015fc76f5 100644 --- a/templates/de/html/admin/admin_config_nickname.tpl +++ b/templates/de/html/admin/admin_config_nickname.tpl @@ -1,7 +1,5 @@ -
- + +
@@ -12,9 +10,9 @@ - + @@ -22,9 +20,9 @@ - + @@ -32,18 +30,18 @@ - + - +
{--NICKNAME_ADMIN_CONFIG_HEADER--}
{--ADMIN_NICKNAME_MIN_LENGTH--}:   + +
 
{--ADMIN_NICKNAME_PATTERN--}:   + +
 
{--ADMIN_NICKNAME_LANG_CHARS--}:   + +