Larry ... PHP for radio station stopped working.

.

Hi Larry ... long time no see !

Hope you can help me with below

The PHP script (or the Html script) that you made for our radiostation a few years ago
stopped working as you can see on our website:

https://tinyurl.com/c7dvqzf

the song-titles (time,artist,track) are no longer displayed and its all black now.



The info for that is taken from the radiosoftware called Shoutcast
which is running at my host .. it generates a XML feed which is used by our HTML & PHP scripts
to show the artist - title info on our page.

Last week they (my host) made an update to Shoutcast ... as soon as i used that update
the song info was no longer shown.
now im trying to locate the problem and hope it can be repaired.


First thing i asked my host was is to revert back to the previous shoutcast-version
he did so ... but the problem stays .. shouldn´t be .. no idea why.

I had not touched my website for over a year.
so it has to be on my host´s side that causes the problem.
or something in my scripts suddenly is not compatible anymore.

Hope you can help me .. what do you need from me to find the cause of the problem ?


The complete thread where we made the scripts is here:

http://virtualmechanics.infopo...591/m/3647033336/p/1

there we tried a few approaches ... the final script im still using now is on page 4
of that thread in your post of: September 21, 2013 12:48 AM


-----
PHP
-----



<?php

// Set there variables
$password = "xxxxxxx";
$host = "xx.xx.xx.xxx";
$port = xxxx;

// Connect to Shoutcast Sever
$sp = fsockopen($host, $port, $errno, $errstr, 10);
if (!$sp) die("Could not contact $host:$port - $errstr\n");

// Send request to get song history
fputs($sp,"GET /admin.cgi?pass=$password&mode=viewxml&sid=1&page=4 HTTP/1.1\nUser-Agent:Mozilla\n\n");

// Fetch response
$sp_data = "";
while (!feof($sp)) {
$sp_data .= fread($sp, 2048);
}

$pattern = '/<shoutcastserver>.*<\/shoutcastserver>/i';
preg_match($pattern, $sp_data, $matches);

echo $matches[0];

?>



Password was replaced for xxxxxxx if you need it for testing
tell me if i should send it to you (emailadress)


---------
XML feed
---------

The XMl feed where the info is taken from:
is here: http://mediaserv30.live-stream...&mode=viewxml&page=4
not shure if you can see that so below is what that looks like:



<?xml version="1.0" encoding="UTF-8" standalone="true"?>
-<SHOUTCASTSERVER>
-<SONGHISTORY>
-<SONG>
<PLAYEDAT>1509296316</PLAYEDAT>
<TITLE>Shydeeh - Wooh She Who</TITLE>
-<METADATA>
<TALB>Wooh She's Who?</TALB>
<TCON>R&B/Soul</TCON>
<TENC>TRANSCast DNAS/posix(linux x64) v2.0.0.54</TENC>
<TIT2>Wooh She Who</TIT2>
<TPE1>Shydeeh</TPE1>
<TRCK>1</TRCK>
-<extension>
<title seq="1">Shydeeh - Wooh She Who</title>
<title seq="2">nextsong salsaradioamsterdam 869c08792d9c19feda0c9ad32edef689 sctrans2next</title>
<title seq="3">nextsong salsaradioamsterdam 869c08792d9c19feda0c9ad32edef689 sctrans2next</title>
<title seq="4">nextsong salsaradioamsterdam 869c08792d9c19feda0c9ad32edef689 sctrans2next</title>
<soon>nextsong salsaradioamsterdam 869c08792d9c19feda0c9ad32edef689 sctrans2next</soon>
</extension>
</METADATA>
</SONG>
-<SONG>
<PLAYEDAT>1509296053</PLAYEDAT>
<TITLE>Patty Padilla - Hello (Salsa Version)</TITLE>
-<METADATA>
<COMM language="eng">Gale Sound & David Carl Productions</COMM>
<COMM language="eng">Gale Sound & David Carl Productions</COMM>
<TALB>Tributo A La Guarachera</TALB>
-<TDRC>
<year>2016</year>
</TDRC>
<TENC>TRANSCast DNAS/posix(linux x64) v2.0.0.54</TENC>
<TIT2>Hello (Salsa Version)</TIT2>
<TPE1>Patty Padilla</TPE1>
<TRCK>1</TRCK>
<TYER>2016</TYER>
-<extension>
<title seq="1">Patty Padilla - Hello (Salsa Version)</title>
<title seq="2">nextsong salsaradioamsterdam 869c08792d9c19feda0c9ad32edef689 sctrans2next</title>
<title seq="3">nextsong salsaradioamsterdam 869c08792d9c19feda0c9ad32edef689 sctrans2next</title>
<title seq="4">nextsong salsaradioamsterdam 869c08792d9c19feda0c9ad32edef689 sctrans2next</title>
<soon>nextsong salsaradioamsterdam 869c08792d9c19feda0c9ad32edef689 sctrans2next</soon>
</extension>
</METADATA>
</SONG>




-----
HTML
-----



<script type="text/javascript">
var updatePeriod = 19000; // How often the playlist is updated, in msec.

function getSongPlayList() {
$.ajax({
type: "GET",
url: "songhistory.php",
dataType: "xml",
success: xmlParser
});
};

function xmlParser(xml) {
var firstSong = "";
var songs = "";
var songClass = 'anySong';
$(xml).find('SONG').each(function(idx) {
var dtg = $(this).find('PLAYEDAT').text();
var date = new Date(dtg*1000);
var formattedTime = ('0' + date.getHours()).slice(-2) + ':' +
('0' + date.getMinutes()).slice(-2) + ':' +
('0' + date.getSeconds()).slice(-2);
var songTitle = $(this).find('TITLE').text();
if (songTitle.substr(0,29) == 'facebook dj-mambito amsterdam') songClass = 'stationCall';
else if (idx == 0) songClass = 'firstSong';
else songClass = 'anysong';
songHTML = "<p class='"+songClass+"'><span class='songTime'>"+formattedTime+"
"+
"<span class='songTitle'>"+songTitle+"</span></p>";
if (idx == 0) firstSong = songHTML;
else songs += songHTML;
});
$('#playing').html(firstSong);
$('#songList').html(songs);
};

var colonColor = $('.colon').css('color');

function updateClock() {

var currentTime = new Date();
var currentHours = currentTime.getHours();
var currentMinutes = currentTime.getMinutes();
var currentSeconds = currentTime.getSeconds();

// Pad the minutes and seconds with leading zeros, if required
currentHours = (currentHours < 10 ? "0" : "") + currentHours;
currentMinutes = (currentMinutes < 10 ? "0" : "") + currentMinutes;
currentSeconds = (currentSeconds < 10 ? "0" : "") + currentSeconds;

// Compose the string for display
var currentTimeString = currentHours + '<span class="colon">:</span>' +
currentMinutes + '<span class="colon">:</span>' +
currentSeconds ;
$("#clock").html(currentTimeString);
if (currentSeconds % 2 == 0) $('.colon').css({'color':'#952668','text-shadow':'0 0 0.3em #B16292,0 0 0.3em #B16292' });
else $('.colon').css('color',colonColor);


}

$(function() {
getSongPlayList();
setInterval("getSongPlayList()", updatePeriod);
setInterval('updateClock()', 1000);
});
</script>

</span>



------------------------------------------------------------------------
CSS to do some styling of the artist-song info and the clock on the page
------------------------------------------------------------------------




.stationCall
{
display: none;
}


#Oobj67,#Oobj170,#Oobj147 {line-height:1.15;}
/* same line-height for playlist-text */


.songTime
{
display: inline-block;
padding-left:0px;
padding-right:15px;
color: #5C688C;
font-family: 'droid_sans_monoregular', Arial, sans-serif;
font-size: 20px;
overflow: hidden;
white-space: nowrap;
text-overflow:ellipsis;
}


.songTitle
{
display: inline-block;
color: #717171;
font-family: 'droid_sans_monoregular',
Arial, sans-serif;
font-size: 20px;
overflow: hidden;
white-space: nowrap;
text-overflow:ellipsis;
width: 82%;
}


#songList p
{
margin:0px auto;
}


.firstSong .songTime
{
display:none;
}


.firstSong .songTitle
{
display: inline-block;
color: #717171;
font-family: 'droid_sans_monoregular', Arial, sans-serif;
font-size: 20px;
overflow: hidden;
white-space: nowrap;
text-overflow:ellipsis;
width: 82%;
}



#clock
{
display: inline-block;
font-family: 'droid_sans_monoregular', Arial, sans-serif;
font-size: 20px;
color: #5C688C;
text-shadow: 0 0 0.5em #000000;
}





Radiotechscan

.
Original Post
Larry .. hope you see this.

After some looking into it ..the problem might be that the XML format
as it is being put out by (my) Shoutcast server is not the same anymore as it was
at the time you wrote that "songhistory.php"

To clear that up ... i here include both:

1) A screenshot of what the xml output was before (this worked fine with your php script)

2) A screenshot of what the xml output is now (bviously php script cant handle that now)

3) Your songhistory.php script as i allways have used it fine.


My Question:

Since I know very little about both PHP and XML
I like to ask you if you can find out if your php script should still work
with that current XML feed ? ... if not can you make some changes so it wil work again please ?


Thanks Radiotechscan


----------------------------------------------------
Screenshot OLDER XML-feed when your PHP used to work
----------------------------------------------------

https://1drv.ms/i/s!AqtggOy7GUk2gXmykvlcGON_wxtz


-----------------------------------------------------------------
Screenshot CURRENT XML-feed that (maybe) your PHP cant handle now
-----------------------------------------------------------------

https://1drv.ms/i/s!AqtggOy7GUk2glvWqnTJ7kO5Qos2

---------------
Songhistory.php
---------------



<?php

// Set there variables
$password = "xxxxxxx";
$host = "82.94.166.107";
$port = 8067;

// Connect to Shoutcast Sever
$sp = fsockopen($host, $port, $errno, $errstr, 10);
if (!$sp) die("Could not contact $host:$port - $errstr\n");

// Send request to get song history
fputs($sp,"GET /admin.cgi?pass=$password&mode=viewxml&sid=1&page=4 HTTP/1.1\nUser-Agent:Mozilla\n\n");

// Fetch response
$sp_data = "";
while (!feof($sp)) {
$sp_data .= fread($sp, 2048);
}

$pattern = '/<shoutcastserver>.*<\/shoutcastserver>/i';
preg_match($pattern, $sp_data, $matches);

echo $matches[0];

?>



----------------------------
Official SHOUTCAST XML-specs
----------------------------

Link to the official Shoutcast XML-specs which obviously is not what im getting now
Said differently the current XML (Songhistory , page4) is not in accordance with what it officially should be
it appears as if they are now more or less mixing two different XML-streams into one unofficial (undocumented) one, namely:

Songhistory" (page 4)
+
Stream Metadata (page 5)

... this might be the cause of your php not working anymore.

http://wiki.shoutcast.com/wiki...erver_2_XML_Reponses



Radiotechscan

Add Reply

Likes (0)
×
×
×
×