Old 21st January 2016, 22:15   #1
swifterldn
Junior Member
 
Join Date: Jan 2016
Posts: 1
Need working radio stats script!

I have one but it aint working anymore it was working 2 years ago though but yeah
I need something similiar to this that works thanks!


this is the one that doesnt work anymore
<?php
$userip = $_SERVER['REMOTE_ADDR'];
$userip_enc = $core->encrypt($userip);
$time = time();
$time_check = $time - 3600;

$ip = "188.165.237.19";
$port = "8450";
$fp = @fsockopen($ip,$port,$errno,$errstr,1);
fputs($fp, "GET /index.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
while (!feof($fp)) {
$info = fgets($fp);
}
$info = str_replace('</body></html>', "", $info);
$split = explode('Stream Genre: </font></td><td><font class=default><b>', $info);
$split = explode('</b></td></tr>', $split[1]);
$streamgenre = $split[0];
swifterldn is offline   Reply With Quote
Old 21st January 2016, 23:52   #2
meun5
Junior Member
 
Join Date: Jan 2015
Posts: 13
You should get the stream information from the public /stats or /statistics. You can also get it from the private admin pages. Just get the xml or json file from the dnas and parse or decode it.
meun5 is offline   Reply With Quote
Old 22nd January 2016, 02:44   #3
djSpinnerCee
Forum King
 
djSpinnerCee's Avatar
 
Join Date: Aug 2004
Location: Hollis, Queens/The Bronx, NYC
Posts: 3,555
i assume your script isn't working anymore because you have a dnas v2 running now and it has different pages that you get the data from.

try http://djspinnercee.servemp3.com:11423/scStatus.html --- you can get now playing info, an rss/podcast formatted page or an html page with everything the dnas gives you.

to re-write your script, you have to change the page that the script gets, and then change how you extract what you want, since the /index.html is different (the v2 sends a redirect to /index.html?sid=1). you can use the xml /stats?sid=1 page, then you'll have to extract xml taginfo.

i'm working on code that recognizes the differences between v1 and v2 dnas, and i'll be posting some of my questions soon.
djSpinnerCee is offline   Reply With Quote
Old 31st January 2016, 13:52   #4
dopelabs
Major Dude
 
dopelabs's Avatar
 
Join Date: Oct 2006
Location: Silicon Valley
Posts: 539
Send a message via AIM to dopelabs
code:

<?php
// Shoutcast Simple PHP Stats
// dlnetworks.net

$dnas = "2"; // DNAS Version (1 or 2)
$ip = "123.123.123.123"; // IP or hostname (without http://)
$port = "8000"; // Port
$sid = "1"; // Stream ID (dans 2 only)
$timeout = "5"; // Number of seconds before connecton times out.

$fp = @fsockopen($ip,$port,$timeout);
if ($dnas == '1') {
fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla/5.0\r\n\r\n");
} else {
fputs($fp, "GET /7.html?sid=$sid HTTP/1.0\r\nUser-Agent: Mozilla/5.0\r\n\r\n");
}

while (!feof($fp)) {
$info = fgets($fp);
}

$info = str_replace('<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>', "", $info);
$info = str_replace('</body></html>', "", $info);
$stats = explode(',', $info,7);
$song = $stats[6];
$listeners = $stats[4];
$max = $stats[3];
$bitrate = $stats[5];
$peak = $stats[2];

?>
<html>
<head>
<title>Shoutcast Simple PHP Stats - dlnetworks.net</title>
</head>
<body>
<center><br>
<h1>Song: <?php print "$song";?></h1><br>
<h2>Listeners: <?php print "$listeners";?>/<?php print "$peak";?>/<?php print "$max";?></h2><br>
<h3>Bitrate: <?php print "$bitrate";?> Kbps</h3><br>
</center>
</body>
</html>

dopelabs is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Shoutcast > Shoutcast Technical Support

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump