// ini_set("display_errors","On");
$SONGDIR = "http://www.petetunes.com/songs/";
$link = mysql_connect('localhost', 'justpete.ca', 'justpete');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('justpete');
if (!$db_selected) {
die('Could not select database: ' . mysql_error());
}
if(!$_GET['id']) {
$query = 'SELECT * FROM songoftheday WHERE filename != "" ORDER BY id';
} else {
$query = 'SELECT * FROM songoftheday WHERE id = "'. $_GET['id'] .'"';
}
$result = mysql_query($query);
if (!$result) {
die('Query failed: ' . mysql_error());
}
/* fetch rows in reverse order */
for ($i = 0; $i < mysql_num_rows($result); $i++) {
if (!mysql_data_seek($result, $i)) {
echo "Cannot seek to row $i: " . mysql_error() . "\n";
continue;
}
if (!($row = mysql_fetch_assoc($result))) {
continue;
}
}
$query = "SELECT * FROM songoftheday WHERE id > 0 ORDER BY id DESC";
$result = mysql_query($query);
while($list = mysql_fetch_array($result, MYSQL_ASSOC))
{
$songselect .= "";
if($list['id'] != $row['id']) {
$playlist .= $SONGDIR . $list['filename'] ."|";
// $playlist .= $list['songurl'] ."|";
}
}
mysql_free_result($result);
$song = $SONGDIR . $row['filename'];
$songfile = $row['filename'];;
// $localfile = ereg_replace("http://www.thewalrus.ca/","../",$songfile);
$songimage = $row['songimage'];
$songid = $row['id'];
$videocode = $row['videocode'];
$playlist = $song .'|'. substr($playlist,0,-1);
if(!$row['songartist']) {
require_once('getid3/getid3.php');
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($localfile);
getid3_lib::CopyTagsToComments($ThisFileInfo);
// echo @$ThisFileInfo['comments_html']['artist'][0]; // artist from any/all available tag formats
// echo @$ThisFileInfo['tags']['id3v2']['title'][0]; // title from ID3v2
// echo @$ThisFileInfo['audio']['bitrate']; // audio bitrate
// echo @$ThisFileInfo['playtime_string']; // playtime in minutes:seconds, formatted string
$songartist = @$ThisFileInfo['comments_html']['artist'][0];
$songalbum = @$ThisFileInfo['tags']['id3v2']['album'][0];
$songtitle = @$ThisFileInfo['tags']['id3v2']['title'][0];
$query = "UPDATE justpete.songoftheday SET songartist=\"". $songartist ."\",songimage=\"". $songimage ."\",songtitle=\"". $songtitle ."\",songalbum=\"". $songalbum ."\" WHERE id=\"". $row['id'] ."\" ";
$result = mysql_query($query);
if (!$result) {
die('Query failed: ' . mysql_error());
}
} else {
$songartist = $row['songartist'];
$songalbum = $row['songalbum'];
$songtitle = $row['songtitle'];
$songimage = $row['songimage'];
$metatags = '
';
}
?>
My momentary tune: " echo $songtitle; ?>" by echo $songartist; ?>
echo $metatags; ?>