From 88d968dfaa1cd93185db0e92ed20af0f250aa62a Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Tue, 21 Aug 2007 04:35:01 +0000 Subject: updated lastfm protocol to 1.2, improved the logic behind it does not require a logout, also fixed duplicate stats collection of greedy players --- lib/class/stats.class.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'lib/class/stats.class.php') diff --git a/lib/class/stats.class.php b/lib/class/stats.class.php index ab6896fb..a687cd69 100644 --- a/lib/class/stats.class.php +++ b/lib/class/stats.class.php @@ -66,6 +66,28 @@ class Stats { } } // insert + + /** + * get_last_song + * This returns the full data for the last song that was played, including when it + * was played, this is used by, among other things, the LastFM plugin to figure out + * if we should re-submit or if this is a duplicate / if it's too soon. This takes an + * optional user_id because when streaming we don't have $GLOBALS() + */ + public static function get_last_song($user_id='') { + + $user_id = $user_id ? $user_id : $GLOBALS['user']->id; + + $user_id = Dba::escape($user_id); + + $sql = "SELECT * FROM `object_count` WHERE `user`='$user_id' AND `object_type`='song' ORDER BY `date` DESC LIMIT 1"; + $db_results = Dba::query($sql); + + $results = Dba::fetch_assoc($db_results); + + return $results; + + } // get_last_song /** * get_top -- cgit