A lot while() conditions rewritten to SQL_FETCHARRAY(), see bug #107, @TODO tags...
[mailer.git] / inc / autopurge / purge-unconfirmed.php
index dd6c7fedeee0b5e9cde1b8c60c21fd1c971c5231..4929f2d97403ea1c9b596d9b6329f18fb39fa5b8 100644 (file)
  ************************************************************************/
 
 // Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
+if (!defined('__SECURITY')) {
        $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")) {
+if ((!EXT_IS_ACTIVE("autopurge")) || (getConfig('auto_purge_active') != "Y")) {
        // Abort here
        return false;
 } // END - if
 
 // Shall I auto-purge unconfirmed accounts?
-if ($_CONFIG['ap_unconfirmed'] == "Y") {
+if (getConfig('autopurge_unconfirmed') == "Y") {
        // Init variables and find unconfirmed accounts which I shall auto-purge
-       $time = bigintval($_CONFIG['ap_un_time']);
+       $time = getConfig(('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)
+FROM `{!_MYSQL_PREFIX!}_user_data`
+WHERE `status`='UNCONFIRMED' AND joined < (UNIX_TIMESTAMP() - %s)
 ORDER BY userid ASC",
-        array($time), __FILE__, __LINE__);
+               array($time), __FILE__, __LINE__);
        if (SQL_NUMROWS($result_uncon) > 0) {
                // Prepare variable...
                $UIDs = "";
-               define('__UNCONFIRMED_TIME' , ($_CONFIG['ap_un_time']  / 60 / 60));
+               define('__UNCONFIRMED_TIME' , (getConfig('ap_un_time')  / 60 / 60));
 
                // Delete inactive accounts
-               while (list($uid, $email, $joined) = SQL_FETCHROW($result_uncon)) {
+               while ($content = SQL_FETCHARRAY($result_uncon)) {
                        // Remember userids for the admin
-                       $UIDs .= $uid.", ";
+                       $UIDs .= $content['userid'].", ";
 
                        // Get date/time from timestamp
-                       $joined = MAKE_DATETIME($joined, "0");
+                       $content['joined'] = MAKE_DATETIME($content['joined'], "0");
 
                        // Finnaly delete this inactive account
-                       DELETE_USER_ACCOUNT($uid, LOAD_EMAIL_TEMPLATE("member_autopurge_unconfirmed", $joined, ""));
+                       DELETE_USER_ACCOUNT($content['userid'], LOAD_EMAIL_TEMPLATE("member_autopurge_unconfirmed", $content['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, "");
+               if (getConfig('ap_un_notify') == "Y") {
+                       SEND_ADMIN_NOTIFICATION(getMessage('AUTOPURGE_ADMIN_UNCONFIRMED_SUBJECT'), "admin_autopurge_unconfirmed", $UIDs, "");
                } // END - if
        } // END - if