Unconfirmed mails rewritten, mail confirmation saved in stats table
[mailer.git] / inc / mysql-manager.php
index bf54a9f45b5b4dff9450c065025295a88bdff584..2d187f0acd4079c7c44657c722b7cc3fa2ac856c 100644 (file)
@@ -1349,7 +1349,7 @@ function UPDATE_ONLINE_LIST($SID, $mod, $act, $wht) {
                $ADMIN = "Y";
        } // END - if
 
-       if (isSessionVariableSet('up_refid')) {
+       if (isSessionVariableSet('refid')) {
                // Check cookie
                if (get_session('refid') > 0) $rid = bigintval($GLOBALS['refid']);
        } // END - if
@@ -2147,5 +2147,60 @@ function GENERATE_RECEIVER_LIST ($cat, $receiver, $mode="") {
        return $receiverList;
 }
 
+// Get timestamp for given stats type and data
+function USER_STATS_GET_TIMESTAMP ($type, $data, $uid = 0) {
+       // Default timestamp is zero
+       $stamp = 0;
+
+       // User id set?
+       if ((isset($GLOBALS['userid'])) && ($uid == 0)) {
+               $uid = $GLOBALS['userid'];
+       } // END - if
+
+       // Is the extension installed and updated?
+       if ((!EXT_IS_ACTIVE("sql_patches")) || (EXT_VERSION_IS_OLDER("sql_patches", "0.5.6"))) {
+               // Return zero here
+               return $stamp;
+       } // END - if
+
+       // Try to find the entry
+       $result = SQL_QUERY_ESC("SELECT UNIX_TIMESTAMP(`inserted`) AS `stamp`
+FROM "._MYSQL_PREFIX."_user_stats_data
+WHERE userid=%s AND stats_type='%s' AND stats_data='%s'
+LIMIT 1",
+               array(bigintval($uid), $type, $data), __FILE__, __LINE__);
+
+       // Is the entry there?
+       if (SQL_NUMROWS($result) == 1) {
+               // Get this stamp
+               list($stamp) = SQL_FETCHROW($result);
+       } // END - if
+
+       // Free result
+       SQL_FREERESULT($result);
+
+       // Return stamp
+       return $stamp;
+}
+
+// Inserts user stats
+function USER_STATS_INSERT_RECORD ($uid, $type, $data) {
+       // Is the extension installed and updated?
+       if ((!EXT_IS_ACTIVE("sql_patches")) || (EXT_VERSION_IS_OLDER("sql_patches", "0.5.6"))) {
+               // Return zero here
+               return false;
+       } // END - if
+
+       // Does it exist?
+       if ((!USER_STATS_GET_TIMESTAMP($type, $data, $uid)) && (!is_array($data))) {
+               // Then insert it!
+               SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_stats_data (`userid`,`stats_type`,`stats_data`) VALUES (%s,'%s','%s')",
+                       array(bigintval($uid), $type, $data), __FILE__, __LINE__);
+       } elseif (is_array($data)) {
+               // Invalid data!
+               DEBUG_LOG(__FUNCTION__."(".__LINE__."): uid={$uid},type={$type},data={".gettype($data).": Invalid statistics data type!");
+       }
+}
+
 //
 ?>