To help out those of you with shoutcast stations and want to show them off! You can use this code in Drupal or any CMS or page that accepts PHP code. Just fill in the IP address of your shoutcast server and the port in which it listens on and this script will output the current song and the number of listeners. There are variations of it floating around the internet. Its weakness is that if your song contains any commas (,) then the song title will stop at the comma.
<?php
$ip = "127.0.0.1";
$port = "8000";
$fp = @fsockopen($ip,$port,$errno,$errstr,1);
if (!$fp)
{
echo "Connection refused"; // Diaplays when sever is offline
}
else
{
fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
while (!feof($fp))
{
$info = fgets($fp);
}
$info = str_replace('', "", $info);
$split = explode(',', $info);
if (empty($split[6]) )
{
echo "The current song is not available"; // Displays when sever is online but no song title
}
else
{
$title = str_replace('\'', '`', $split[6]);
$title = str_replace(',', ' ', $title);
echo "$title - Listeners: $split[0]"; // Displays song
}
}
?>
Comments 3
Hello World
Posted 12 Apr 2009 at 9:33 pm ¶God dag! Kan jag ladda ner en bild fran din blogg. Av sak med hanvisning till din webbplats!
Posted 19 Apr 2009 at 12:57 am ¶God dag! Det krävs för att översätta din kommentar. Vilken bild vill du länka till? Om du tar webbadressen för bilden och lägga till ordet snabbt istället för www, så får du en bild snabbt utan några dåliga effekter för mig. Du kan också använda någon av mina fria gallerier! & http://www.hardcoredreamer.com/gallery/
Posted 19 Apr 2009 at 1:01 pm ¶Post a Comment