+ // Get all id from locks within the timestamp
+ $result = SQL_QUERY_ESC("SELECT id, url_id, UNIX_TIMESTAMP(last_surfed)
+FROM
+ "._MYSQL_PREFIX."_surfbar_locks
+WHERE
+ userid=%s
+ORDER BY
+ id ASC", array($GLOBALS['userid']),
+ __FILE__, __LINE__);
+
+ // Load all entries
+ $IDs = array(); $USE = array();
+ $ignored = array();
+ while (list($id, $url, $last) = SQL_FETCHROW($result)) {
+ //* DEBUG: */ echo __FUNCTION__.": next - id={$id},url={$url},last={$last}<br />\n";
+ // Skip entries that are too old
+ if (($last < (time() - SURFBAR_GET_DATA('surf_lock'))) && (!in_array($url, $ignored))) {
+ //* DEBUG: */ echo __FUNCTION__.": okay - id={$id},url={$url},last={$last}<br />\n";
+ // Add only if missing or bigger
+ if ((!isset($IDs[$url])) || ($IDs[$url] <= $last)) {
+ // Add this ID
+ //* DEBUG: */ echo __FUNCTION__.": ADD - id={$id},url={$url},last={$last}<br />\n";
+ $IDs[$url] = $last;
+ $USE[$url] = $id;
+ } // END - if
+ } else {
+ // Ignore these old entries!
+ //* DEBUG: */ echo __FUNCTION__.": ignore - id={$id},url={$url},last={$last}<br />\n";
+ $ignored[] = $url;
+ unset($IDs[$url]);
+ unset($USE[$url]);
+ }
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result);
+