HMMMM
Active member
Yes, Dimitri Post would be better and more reliable you could be correct about image size but they have not changed in size, and this did work on another website, but currently I am forced into picking up FTP XML and artwork.png which is working reading in PHP with a fetch timer from the website which gets over this but has to have website loaded This is reading from XMP. Something strange is happening with the output of the Setting>>FileType SID to exclude the image. It would be nice to have %lyrics created in this XML Play file?
<?php
// $remote_server is a returned value to check steam is active.
include "mp3/check_remote_server.php";
$remote_server = checkRemoteServerStatus(
"http://server.net:27757574/",
19200,
0
);
if ($remote_server == true) {
$xml=simplexml_load_file("images/nowplaying.xml");
if( $xml == false) {ReturnError(500, "Failed to open ("."images/nowplaying.xml".") bytes of XML from file XML.");}
//$artist= iconv( "UTF-8", "ISO-8859-1//TRANSLIT", $artist); //TO REMOVE THE ISO-8859-1 ISSUE
// print_r($xml);
$title = implode($xml->xpath('//PLAYER/TRACK/@TITLE'));
$artist = implode($xml->xpath('//PLAYER/TRACK/@ARTIST'));
$album = implode($xml->xpath('//PLAYER/TRACK/@ALBUM'));
$genre = implode($xml->xpath('//PLAYER/TRACK/@GENRE'));
$comment = implode($xml->xpath('//PLAYER/TRACK/@COMMENT'));
$bpm = implode($xml->xpath('//PLAYER/TRACK/@BPM'));
$length = implode($xml->xpath('//PLAYER/TRACK/@DURATION'));
$listeners =implode($xml->xpath('//PLAYER/TRACK/@LISTENERS'));
$rating = implode($xml->xpath('//PLAYER/TRACK/@RATING'));
$exit_old = false;
$xml = null; // clear the used class XML.
// note there is now num_rows in PDO so we have to calculate a new one to get record number.
try {
$n = 0;
$conn = new PDO( "mysql:host=$servername;dbname=$dbname", $username, $password );
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT * FROM `played_songs` ORDER BY `datetime` DESC LIMIT 1";
$result = $conn->query($sql); // Use query as we are returning records.
$row = $result->fetch();
$conn = null;
} catch (PDOException $e) {
ReturnError(500, "Failed to write /read from SQL." . $e->getMessage() );
}
if ($artist != $row['artist'] && $title != $row['song']) {
$exit_old = true;
$t = fopen("images/nowplaying_artwork_2.png", "r");
if ($t !== false) {
$artwork = fread($t, filesize("images/nowplaying_artwork_2.png"));
fclose($t);
} else {
fclose($t);
ReturnError(500, "Failed to write artwork to a file.");
}
$base64artwork = base64_encode($artwork);
$sql3 = "INSERT INTO `played_songs` (`song`, `artist`, `album`, `length`, `bpm`,`genre`, `listeners`,`track_user_rating`,`track_user_num`,`comment`,`ImageBase64`) VALUES ('$title','$artist', '$album', '$length', '$bpm', '$genre','$listeners','0','0', '$comment','$base64artwork') ON DUPLICATE KEY UPDATE `listeners`='$listeners'";
$conn= null;
$conn = new PDO( "mysql:host=$servername;dbname=$dbname", $username, $password );
$conn->exec($sql3);
/>
<?php
// $remote_server is a returned value to check steam is active.
include "mp3/check_remote_server.php";
$remote_server = checkRemoteServerStatus(
"http://server.net:27757574/",
19200,
0
);
if ($remote_server == true) {
$xml=simplexml_load_file("images/nowplaying.xml");
if( $xml == false) {ReturnError(500, "Failed to open ("."images/nowplaying.xml".") bytes of XML from file XML.");}
//$artist= iconv( "UTF-8", "ISO-8859-1//TRANSLIT", $artist); //TO REMOVE THE ISO-8859-1 ISSUE
// print_r($xml);
$title = implode($xml->xpath('//PLAYER/TRACK/@TITLE'));
$artist = implode($xml->xpath('//PLAYER/TRACK/@ARTIST'));
$album = implode($xml->xpath('//PLAYER/TRACK/@ALBUM'));
$genre = implode($xml->xpath('//PLAYER/TRACK/@GENRE'));
$comment = implode($xml->xpath('//PLAYER/TRACK/@COMMENT'));
$bpm = implode($xml->xpath('//PLAYER/TRACK/@BPM'));
$length = implode($xml->xpath('//PLAYER/TRACK/@DURATION'));
$listeners =implode($xml->xpath('//PLAYER/TRACK/@LISTENERS'));
$rating = implode($xml->xpath('//PLAYER/TRACK/@RATING'));
$exit_old = false;
$xml = null; // clear the used class XML.
// note there is now num_rows in PDO so we have to calculate a new one to get record number.
try {
$n = 0;
$conn = new PDO( "mysql:host=$servername;dbname=$dbname", $username, $password );
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT * FROM `played_songs` ORDER BY `datetime` DESC LIMIT 1";
$result = $conn->query($sql); // Use query as we are returning records.
$row = $result->fetch();
$conn = null;
} catch (PDOException $e) {
ReturnError(500, "Failed to write /read from SQL." . $e->getMessage() );
}
if ($artist != $row['artist'] && $title != $row['song']) {
$exit_old = true;
$t = fopen("images/nowplaying_artwork_2.png", "r");
if ($t !== false) {
$artwork = fread($t, filesize("images/nowplaying_artwork_2.png"));
fclose($t);
} else {
fclose($t);
ReturnError(500, "Failed to write artwork to a file.");
}
$base64artwork = base64_encode($artwork);
$sql3 = "INSERT INTO `played_songs` (`song`, `artist`, `album`, `length`, `bpm`,`genre`, `listeners`,`track_user_rating`,`track_user_num`,`comment`,`ImageBase64`) VALUES ('$title','$artist', '$album', '$length', '$bpm', '$genre','$listeners','0','0', '$comment','$base64artwork') ON DUPLICATE KEY UPDATE `listeners`='$listeners'";
$conn= null;
$conn = new PDO( "mysql:host=$servername;dbname=$dbname", $username, $password );
$conn->exec($sql3);
/>
Last edited: