last songs played

Posted:
Wed 20th Jan, 2010 6:41 am
by prideplay
Hiya
I've noticed that the only way listernes can see the 10 last songs played are on a page where there's also a logon and other things.
Is it possible to get ONLY the 10 last songs played?
Re: last songs played

Posted:
Thu 21st Jan, 2010 2:26 pm
by Ferik
PHP Shoutcast Class with example
http://devshed.excudo.net/scripts/php/s ... cast+classDownload the Shoutcast class and try this php script.
- Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Shoutcast Test Page</title>
<style type="text/css">
.songOverview {
width:30%;
border:1px solid black;
background-color: #EEE;
}
.songOverview td {
padding: 1px 10px 1px 1px;
}
</style>
</head>
<body>
<?php
require_once ('shoutcast_class.php');
///YOUR RADIO CONFIGURATION IP & PORT///
$ip = "stream_address_here";
$port = "port_here";
////////////////////////////////////////
$radio = new Radio($ip.":".$port);
// ALL POSSIBLE INFORMATION //
$display_array = array(
"Stream Title",
"Stream Genre",
"Stream URL",
"Current Song",
"Server Status",
"Stream Status",
"Listener Peak",
"Average Listen Time",
"Content Type",
"Stream AIM",
"Stream IRC"
);
$data_array = $radio->getServerInfo($display_array);
echo "<table style=\"background-color: #CCC; border: 1px solid black;\">\n";
if (is_array($data_array))
{
foreach ($display_array AS $i => $text)
{
if ($text == "Stream Genre")
{
$datastring = "<span style=\"color: lightgrey; background-color: black;\">".$data_array[$i]."</span>";
}
elseif ($text == "Stream URL")
{
$datastring = "<a href=\"".$data_array[$i]."\" target=\"_blank\">".$data_array[$i]."</a>";
}
else
{
$datastring = $data_array[$i];
}
echo "<tr>\n <td>".$text.":</td>\n";
echo " <td>".$datastring."</td>\n</tr>\n";
}
}
else
{
echo "<tr>\n <td colspan=\"2\" style=\"color: red;\">".$data_array."</td>\n</tr>\n";
}
echo "</table>\n";
/*SONG HISTORY*/
echo "<h2>Song History</h2>\n";
echo $radio->getHistoryTable("/played.html", "<b>Played At</b>", "<b>Song</b>", "songOverview");
?>
</body>
</html>
Re: last songs played

Posted:
Thu 21st Jan, 2010 2:55 pm
by Gavin
That looks like a decent script, thanks for posting

Re: last songs played

Posted:
Thu 21st Jan, 2010 5:33 pm
by Ferik
if you want History Song only, this is the code, remember to download the shoutcast class ........ very simple

- Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>myRadio Test Page</title>
<style type="text/css">
.myRadio {
width:30%;
border:1px solid black;
background-color: #EEE;
}
.myRadio td {
padding: 1px 10px 1px 1px;
}
</style>
</head>
<body>
<?php
require_once ('shoutcast_class.php');
///YOUR RADIO CONFIGURATION IP & PORT///
$radio_ip = "stream_address_here";
$radio_port = "port_here";
$my_radio = new Radio($radio_ip.":".$radio_port);
/*SONG HISTORY*/
echo "<h2>Song History</h2>\n";
echo $my_radio->getHistoryTable("/played.html", "<b>Played At</b>", "<b>Song</b>", "myRadio");
?>
</body>
</html>
Re: last songs played

Posted:
Fri 13th Aug, 2010 7:59 am
by djboro88
Hi good morning.
I would like that same code, make some kind of script or the same code but I only extracted the Strem Genre and also to change the name of that variable, for example: instead of Stream Genre to display: PROGRAM:
Greetings and thanks.
Re: last songs played

Posted:
Fri 13th Aug, 2010 2:55 pm
by Gavin
Thanks for posting your script. Here's an alternative one that I made a few weeks ago which doesn't require the Shoutcast_class (which I'm getting a 'forbidden' error on when following the link). The results are inside a table which is formatted in the same way as played.html:
- Code: Select all
<?php
$server_ip = "YOUR SERVER ADDRESS";
$portbase = "YOUR SERVER PORT";
if (!is_numeric($portbase)) {
print "Invalid port";
exit;
}
$fp = @fsockopen($server_ip,$portbase,$errno,$errstr,1);
if (!$fp) {
print "<p>Connection refused, the server appears to be offline.</p>";
exit;
} else {
fputs($fp, "GET /played.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
while (!feof($fp)) {
$info = fgets($fp);
}
$content = get_string_between($info, "Admin Login</a></font></td></tr></table></td></tr></table><br>", "<br><br><table");
print $content;
fclose($fp);
}
function get_string_between($string, $start, $end) {
$string = " " . $string;
$ini = strpos($string, $start);
if ($ini == 0)
return "";
$ini += strlen($start);
$len = strpos($string, $end, $ini) - $ini;
return substr($string, $ini, $len);
}
?>