/** * ajaxPlaylistRemove: Returns the User flag. * * @param * @return * @author * @todo */ function ajaxPlaylistRemove($itemid) { grammafone_connect(); $id = substr($itemid, 3); $query = "DELETE FROM \n grammafone_playlist \n WHERE \n pl_id={$id} \n AND \n user_id={$_SESSION['sess_userid']}"; mysql_query($query); return $itemid; }
function stream($id, $rate = 0, $stereo = "s", $user = '', $ip = '') { grammafone_connect(); // check to see if IP is in the verified IP DB for that user if (verifyIP($user, $ip)) { //$query="SELECT filename,size,length FROM grammafone_songs WHERE song_id=$id"; $query = "SELECT grammafone_artists.artist_name, \n\t\tgrammafone_songs.name,\n\t\tgrammafone_songs.bitrate, \n\t\tgrammafone_songs.length as length, \n\t\tgrammafone_songs.filename as filename, \n\t\tgrammafone_songs.size as size \n\t\tFROM grammafone_songs,grammafone_artists \n\t\tWHERE grammafone_songs.song_id={$id} \n\t\tAND grammafone_artists.artist_id=grammafone_songs.artist_id"; $result = mysql_query($query); $row = mysql_fetch_array($result); fb($row); updateNumPlays($id, 0, $user, 'player'); clearstatcache(); // flush buffer $file['name'] = basename($row['filename']); $mp3out = ''; if (getSystemSetting("lamebin") != "" && $rate != 0) { $row['size'] = ($row['length'] + 1) * $rate * 1000 / 8; $mp3out = getSystemSetting("lamebin") . " -b {$rate} -s {$stereo} --silent --nores --mp3input -h \"" . addslashes($row['filename']) . "\" -"; } else { $mp3out = stripslashes($row['filename']); } $size = $row['size']; $mode = getSystemSetting("sample_mode"); if ($mode == 1) { $size = floor($row['size'] / 4); } header("Content-Type: audio/mpeg"); header("Content-Length: {$size}"); header("Content-Disposition: filename={$row['artist_name']} - {$row['name']}"); header('X-Pad: avoid browser bug'); header('Cache-Control: no-cache'); session_write_close(); // Run the command, and read back the results at the bitrate size + 1K. $blocksize = $row['bitrate'] * 1024 + 1024; $totaldata = 0; if ($rate != 0 && $mode == 1) { $temp = @popen($mp3out, "r"); while (($data = @fread($temp, $blocksize)) && $totaldata <= $size) { echo $data; $totaldata += $blocksize; } pclose($temp); } elseif ($rate != 0) { $temp = @popen($mp3out, "r"); while ($data = @fread($temp, $blocksize)) { echo $data; } pclose($temp); } elseif ($mode == 1) { $temp = @fopen($mp3out, "r"); while (!feof($temp) && $totaldata <= $size) { $data = @fread($temp, $blocksize); echo $data; $totaldata += $blocksize; } fclose($temp); } else { $temp = @fopen($mp3out, "r"); while (!feof($temp)) { $data = @fread($temp, $blocksize); echo $data; } fclose($temp); } } // end IF for verify IP exit; }
<?php // GrammaFone RSS Feed Creator include "base.inc.php"; grammafone_connect(); header("Content-Type: text/xml"); $query = "SELECT grammafone_albums.album_name,\ngrammafone_albums.album_art,\ngrammafone_artists.artist_name,grammafone_artists.prefix,\nDATE_FORMAT(grammafone_songs.date_entered,'%a, %d %b %Y %T') as pubdate \nFROM grammafone_songs,grammafone_albums,grammafone_artists \nWHERE grammafone_songs.album_id=grammafone_albums.album_id \nAND grammafone_artists.artist_id=grammafone_songs.artist_id \nGROUP BY grammafone_songs.album_id ORDER BY grammafone_songs.date_entered DESC LIMIT 10"; $result = mysql_query($query); echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"; ?> <rss version="2.0"> <channel> <title>GrammaFone - Recently Added Albums</title> <pubDate>Fri, 03 Jun 2005 10:23:45 +0000</pubDate> <link><?php echo "{$GLOBALS['http_url']}{$GLOBALS['uri_path']}/"; ?> </link> <description>A list of the 10 most recently added music albums to this GrammaFone server.</description> <generator><?php echo "{$GLOBALS['http_url']}{$GLOBALS['uri_path']}/feed.php"; ?> </generator> <language>en</language> <?php while ($row = @mysql_fetch_array($result)) { ?> <item>
function resetDatabase() { grammafone_connect(); $query = array(); $query[] = "TRUNCATE TABLE grammafone_songs"; $query[] = "TRUNCATE TABLE grammafone_artists"; $query[] = "TRUNCATE TABLE grammafone_albums"; $query[] = "TRUNCATE TABLE grammafone_playlist"; $query[] = "TRUNCATE TABLE grammafone_saved_playlists"; $query[] = "TRUNCATE TABLE grammafone_genres"; $query[] = "TRUNCATE TABLE grammafone_stats"; $query[] = "TRUNCATE TABLE grammafone_playhistory"; $query[] = "TRUNCATE TABLE grammafone_currentsong"; foreach ($query as $q) { mysql_query($q); } $path = $GLOBALS['abs_path'] . "/art/"; if (is_dir($path)) { if ($dh = opendir($path)) { while (($file = readdir($dh)) !== false) { if ($file != "." && $file != ".." && $file != ".svn") { unlink($path . $file); } } closedir($dh); } } return 1; }
function updateGenres() { grammafone_connect(); $query = "DELETE FROM grammafone_genres"; mysql_query($query); $query = "SELECT album_genre FROM grammafone_albums GROUP BY album_genre"; $result = mysql_query($query); while ($genre = mysql_fetch_assoc($result)) { $query = "INSERT INTO grammafone_genres VALUES (NULL,\"" . $genre['album_genre'] . "\")"; mysql_query($query); } }