• Welcome to Valhalla Legends Archive.
 

[PHP] Shoutcast Hook

Started by AssassinRC, December 01, 2003, 10:59 AM

Previous topic - Next topic

AssassinRC

This is a simple hook allowing users to have automatically updated realtime information exported from their ShoutCast server. It's fairly easy to setup.

If, for example I wanted to hook into the {RC} radio Shoutcast server, i'd change this line:
$fp = @fsockopen("localhost", 8000, $errno, $errstr, 30);
To:
$fp = @fsockopen("royal-council.com", 1337, $errno, $errstr, 30);
Changing localhost with royal-council.com, and the standard 8000 port with the one {RC} radio resides on (1337).


<?php 
$fp 
= @fsockopen("localhost"8000$errno$errstr30); 
if(
$fp) { 
fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Reader(Mozilla Compatible)\r\n\r\n"); 
while(!
feof($fp)) { 
  
$dataset .= fgets($fp1000); 

fclose($fp); 
$dataset1 $dataset
$headerinfo ereg_replace("<body>.*","",$dataset); 
$dataset ereg_replace(".*<body>"""$dataset); 
$dataset ereg_replace("</body>.*"","$dataset); 
$entries explode(",",$dataset); 
unset(
$entries[7]); 
$listener=$entries[0]; 
$radiostatus=$entries[1]; //1 online, 0 offline 
$uniquelisteners=$entries[2]; 
$maxlisteners=$entries[3]; 
$totallisteners=$entries[4]; 
$bitrate=$entries[5]; 
$songtitle=$entries[6]; 



print 
"".$listener." Total Listenters<br>";
if(
$radiostatus == 1) {
print 
"Server Online!<br>";
} else {
print 
"Server Offline!<br>";
}
print 
"".$uniquelisteners." Unique Listeners<br>";
print 
"".$totallisteners." Total Listeners<br>";
print 
"".$bitrate."kbs<br>";
print 
"Currently Playing: ".$songtitle." <br>";

?>


This will print a plain text output. It's very easy to integrate into a web page. An example of integration is visible on the Right sidebar of the {RC} site. (http://www.royal-council.com).

Banana fanna fo fanna


Crypticflare

I think his mind is full of Echos, and includes now :P

+1 for some great material bud.