/**
* @author Andrew Miller
* @copyright 2008
* @project Stoney The Cat
*/
require ($_SERVER['DOCUMENT_ROOT'].'/music/include/dbconnect.php');
require ($_SERVER['DOCUMENT_ROOT'].'/music/include/globals/functions.php');
if(! isset($_COOKIE['MUSICDB']))
{
$res = mysql_query("SELECT id FROM music GROUP BY artist, album", $Connection) or die(mysql_error());
$totalalbums = number_format(mysql_num_rows($res), 0);
$res1 = mysql_query("SELECT updated AS lastupdated FROM music ORDER BY updated DESC", $Connection) or die(mysql_error());
list($lastupdated) = mysql_fetch_row($res1);
$res2 = mysql_query("SELECT id FROM music", $Connection) or die(mysql_error());
$totalsongs = number_format(mysql_num_rows($res2), 0);
$res3 = mysql_query("SELECT id FROM music GROUP BY artist", $Connection) or die(mysql_error());
$totalartists = number_format(mysql_num_rows($res3), 0);
$res4 = mysql_query("SELECT filesize FROM music WHERE 1", $Connection) or die(mysql_error());
$filesize = 0;
while(list($fsize) = mysql_fetch_row($res4))
{
$filesize = $filesize + $fsize;
}
$totalfilesize = number_format(($filesize / 1073741824), 2);
setcookie("MUSICDB", "$totalalbums|$totalartists|$totalsongs|$totalfilesize|$lastupdated", 0, "/", $_SERVER['SERVER_NAME'], 0);
}
else
{
$MUSICDB = explode("|", $_COOKIE['MUSICDB']);
$totalalbums = $MUSICDB[0];
$totalartists = $MUSICDB[1];
$totalsongs = $MUSICDB[2];
$totalfilesize = $MUSICDB[3];
$lastupdated = $MUSICDB[4];
}
if(! isset($_COOKIE['DETAIL']))
{
setcookie("DETAIL", 1, 0, "/", $_SERVER['SERVER_NAME'], 0);
}
// view specific artist and album
if(isset($_GET['artist'], $_GET['album']))
{
$q = substr($_GET['artist'], 0, 1);
$query = "SELECT *
FROM music
WHERE artist = '".addslashes($_GET['artist'])."'
AND album = '".addslashes($_GET['album'])."'
ORDER BY tracknumber ASC";
$result = mysql_query($query, $Connection) or die(mysql_error()."
$query
");
$count = 0;
$rightcol = "";
if(isset($_COOKIE['DETAIL']))
{
$rightcol .= "showing artist detail [ hide this ]";
}
else
{
$rightcol .= "hiding artist detail [ show this ]";
}
$rightcol .= "
";
while(list($id, $artist, $album, $tracknumber, $title, $date, $length, $filesize, $codec, $bitrate, $samplerate, $archive_volume, $updated) = mysql_fetch_row($result))
{
if(! $noshow)
{
if(isset($_COOKIE['DETAIL']))
{
// get the album info from last.fm
$url = "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&user=subtlerage&api_key=b25b959554ed76058ac220b7b2e0a026&artist=".urlencode($artist)."&album=".urlencode($album);
$ch = curl_init($url) or die(curl_error());
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, "60");
curl_setopt($ch, CURLOPT_PORT, "80");
$data = curl_exec($ch) or die(curl_error($ch));
$debug = curl_getinfo($ch);
curl_close($ch);
$xml = new DOMDocument();
$xml->loadXML($data);
$items = $xml->getElementsByTagName('album');
foreach($items as $item)
{
$summaries = $item->getElementsByTagName('summary');
$albumsummary = $summaries->item(0)->nodeValue;
$images = $item->getElementsByTagName('image');
$image = $images->item(2)->nodeValue;
if(empty($albumsummary))
{
$albumsummary = "none available";
}
if(empty($image))
{
$image = "/images/na.gif";
}
$rightcol .= "- Album Information
$albumsummary
";
}
// get the artist info from last.fm
$url = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&user=subtlerage&api_key=b25b959554ed76058ac220b7b2e0a026&artist=".urlencode($artist)."&album=".urlencode($album);
$ch = curl_init($url) or die(curl_error());
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, "60");
curl_setopt($ch, CURLOPT_PORT, "80");
$data = curl_exec($ch) or die(curl_error($ch));
$debug = curl_getinfo($ch);
curl_close($ch);
$xml = new DOMDocument();
$xml->loadXML($data);
$artistsummaries = $xml->getElementsByTagName('summary');
$artistsummary = $artistsummaries->item(0)->nodeValue;
$artistimages = $xml->getElementsByTagName('image');
$image = $artistimages->item(2)->nodeValue;
if(empty($artistsummary))
{
$rightcol .= "- Artist Information
- none available
";
}
else
{
$rightcol .= "- Artist Information
$artistsummary
";
}
// get simiilar artist info from last.fm
$url = "http://ws.audioscrobbler.com/2.0/?method=artist.getsimilar&user=subtlerage&api_key=b25b959554ed76058ac220b7b2e0a026&limit=10&artist=".urlencode($artist)."&album=".urlencode($album);
$ch = curl_init($url) or die(curl_error());
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, "60");
curl_setopt($ch, CURLOPT_PORT, "80");
$data = curl_exec($ch) or die(curl_error($ch));
$debug = curl_getinfo($ch);
curl_close($ch);
$xml = new DOMDocument();
$xml->loadXML($data);
$items = $xml->getElementsByTagName('artist');
$rightcol .= "- Similar Artists
- ";
$sim = '';
foreach($items as $item)
{
$names = $item->getElementsByTagName('name');
$name = $names->item(0)->nodeValue;
$sim .= "$name, ";
}
$sim = preg_replace("/, $/", "", $sim);
$rightcol .= "$sim
";
}
// breadcrumbs
$nocol = "Music Collection >> ".strtoupper($q)." >> $artist >> $album ";
if($date > 0)
{
$nocol .= "[ $date ]";
}
$nocol .= "
\n";
$leftcol = "\n";
$pagetitle = "Music Collection >> ".strtoupper($q)." >> $artist >> $album";
}
$noshow = true;
if($count % 2)
{
$class = ' class="alt clearfix"';
}
else
{
$class = ' class="clearfix"';
}
$leftcol .= "
- $tracknumber - $title ( $length )
";
$fsize = $filesize / 1024;
$leftcol .= "- ".number_format($fsize)." KB $codec $bitrate kbps
\n";
$count++;
}
$leftcol .= "
\n";
}
// view specific artist's albums
elseif(isset($_GET['artist']))
{
$q = substr($_GET['artist'], 0, 1);
$query = "SELECT artist,
album,
date,
codec
FROM music
WHERE artist = '".addslashes($_GET['artist'])."'
GROUP BY artist,
album
ORDER BY date ASC";
$result = mysql_query($query, $Connection) or die(mysql_error()."$query
");
$nocol = "Music Collection >> ".strtoupper($q)." >> ".urldecode($_GET['artist'])."
\n";
$pagetitle = "Music Collection >> ".strtoupper($q)." >> ".urldecode($_GET['artist']);
$leftcol = "\n";
if(! mysql_num_rows($result))
{
$leftcol .= "- No results
";
}
else
{
while(list($artist, $album, $date, $codec) = mysql_fetch_row($result))
{
$leftcol .= "- $album";
if($date > 0)
{
$leftcol .= " ( $date )";
}
$leftcol .= "
\n";
}
}
$leftcol .= "
\n";
//$leftcol .= "$query
";
}
// view all artists beginning with...
elseif(isset($_GET['q']))
{
$q = strtolower($_GET['q']);
if($q == "all")
{
$query = "SELECT artist,
album,
date,
codec
FROM music
GROUP BY artist,
album";
$result = mysql_query($query, $Connection) or die(mysql_error()."$query
");
$nocol = "Music Collection >> all artists
\n";
$leftcol = "\n";
if(! mysql_num_rows($result))
{
$leftcol .= "- No results
";
}
else
{
while(list($artist, $album, $date, $codec) = mysql_fetch_row($result))
{
$leftcol .= '- '.$artist.' - '.$album.' ('.$date.')
'."\n";
}
$leftcol .= "
\n";
}
}
else
{
$query = "SELECT artist
FROM music
WHERE artist
LIKE '$q%'
GROUP BY artist";
$result = mysql_query($query, $Connection) or die(mysql_error()."$query
");
$nocol = "Music Collection >> ".strtoupper($q)."
\n";
$pagetitle = "Music Collection >> ".strtoupper($q);
$leftcol = "\n";
if(! mysql_num_rows($result))
{
$leftcol .= "- No results
";
}
else
{
while(list($artist, $album) = mysql_fetch_row($result))
{
$leftcol .= '- '.$artist.'
'."\n";
}
}
$leftcol .= "
\n";
}
}
else
{
$leftcol = "Click something.
";
$nocol = "Music Collection
";
}
if(! isset($pagetitle))
{
$pagetitle = 'Music Collection';
}
?>
Notice: Undefined variable: pagetitle in /var/vhosts/stoneythecat.com/httpdocs/music/index.php on line 304
require ($_SERVER['DOCUMENT_ROOT'].'/music/include/nav.php'); ?>
Notice: Undefined variable: nocol in
/var/vhosts/stoneythecat.com/httpdocs/music/index.php on line
317
Notice: Undefined variable: leftcol in /var/vhosts/stoneythecat.com/httpdocs/music/index.php on line 319
Notice: Undefined variable: rightcol in /var/vhosts/stoneythecat.com/httpdocs/music/index.php on line 321