From 6d9533844cf95de3f7e013600b7eb84f0518dded Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Thu, 20 Apr 2006 19:09:23 +0000 Subject: new get_song_id_from_file function for Infamy --- lib/song.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lib/song.php') diff --git a/lib/song.php b/lib/song.php index b24c94db..81095cc1 100644 --- a/lib/song.php +++ b/lib/song.php @@ -87,4 +87,28 @@ function get_popular_songs( $threshold, $type, $user_id = '' ) { } // get_popular_songs() + +/** + * get_song_id_from_file + * This function takes a filename and returns it's best guess for a song id + */ +function get_song_id_from_file($filename) { + + $filename = sql_escape($filename); + + $sql = "SELECT id FROM song WHERE file='$filename'"; + $db_results = mysql_query($sql, dbh()); + + $results = mysql_fetch_assoc($db_results); + + if (!$results['id']) { + $sql = "SELECT id FROM song WHERE file='%$filename%'"; + $db_results = mysql_query($sql, dbh()); + $results = mysql_fetch_assoc($db_results); + } + + return $results['id']; + +} // get_song_id_from_file + ?> -- cgit