Valhalla Legends Forums Archive | Web Development | [PHP] Shoutcast Hook

AuthorMessageTime
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:
[code]$fp = @fsockopen("localhost", 8000, $errno, $errstr, 30);[/code]
To:
[code]$fp = @fsockopen("royal-council.com", 1337, $errno, $errstr, 30);[/code]
Changing localhost with royal-council.com, and the standard 8000 port with the one {RC} radio resides on (1337).

[code]
<?php
$fp = @fsockopen("localhost", 8000, $errno, $errstr, 30);
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($fp, 1000);
}
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>";

?>
[/code]
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).
December 1, 2003, 4:59 PM
St0rm.iD
That's very handy. +1
December 1, 2003, 9:09 PM
Crypticflare
I think his mind is full of Echos, and includes now :P

+1 for some great material bud.
December 2, 2003, 3:59 AM

Search