Fix in CREATE_EXTENSION_DEACTIVATION_TASK() and coding-style updated
[mailer.git] / inc / profile-updte.php
index 759219abb154d0df4b6f761ab248dc1a2aa1d9b0..cad1433c9023d6a96f4ed36aca33e8648187b092 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);
 }
 
-if (($CONFIG['send_prof_update'] == 'Y') && ($CONFIG['profile_update'] > 0) && ($CONFIG['resend_profile_update']))
-{
-       // Ok, we shall send update notifications...
-       $TIMEOUT  = bigintval(time() - $CONFIG['profile_update']);
-       $TIMEOUT2 = bigintval(time() - $CONFIG['resend_profile_update']);
-
+if ((getConfig('send_prof_update') == "Y") && (getConfig('profile_update') > 0) && (getConfig('resend_profile_update'))) {
        // Load personal data              0      1     2      3        4          5         6
-       $result = SQL_QUERY_ESC("SELECT userid, email, sex, surname, family, last_update, joined
- FROM "._MYSQL_PREFIX."_user_data
- WHERE (last_update < %s AND last_update != '0' AND last_profile_sent < %s) OR (last_update='0' AND last_profile_sent='0' AND joined < %s)
- ORDER BY userid", array($TIMEOUT, $TIMEOUT2, $TIMEOUT), __FILE__, __LINE__);
+       $result = SQL_QUERY_ESC("SELECT userid, email, gender, surname, family, last_update, joined
+FROM
+       "._MYSQL_PREFIX."_user_data
+WHERE
+       (last_update < (UNIX_TIMESTAMP() - %s) AND last_update != 0 AND last_profile_sent < (UNIX_TIMESTAMP() - %s))
+OR
+       (last_update=0 AND last_profile_sent=0 AND joined < (UNIX_TIMESTAMP() - %s))
+ORDER BY userid", array(getConfig('profile_update'), getConfig('resend_profile_update'), getConfig('profile_update')), __FILE__, __LINE__);
        if (SQL_NUMROWS($result) > 0)
        {
                // We need to send-out notifications...
@@ -72,8 +70,8 @@ if (($CONFIG['send_prof_update'] == 'Y') && ($CONFIG['profile_update'] > 0) && (
                        SEND_EMAIL($DATA[1], PROFILE_OUTDATED, $msg);
 
                        // Update profile data
-                       $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET last_profile_sent=UNIX_TIMESTAMP(), notified='Y' WHERE userid=%d LIMIT 1",
-                        array(bigintval($DATA[0])), __FILE__, __LINE__);
+                       SQL_QUERY_ESC("UPDATE `"._MYSQL_PREFIX."_user_data` SET last_profile_sent=UNIX_TIMESTAMP(), notified='Y' WHERE userid=%s LIMIT 1",
+                               array(bigintval($DATA[0])), __FILE__, __LINE__);
                }
        }