DAVEROGERS Posted January 15, 2011 Share Posted January 15, 2011 Hi guys I have an old script here which I have tried to recode a bit to work now but still cant get it working. I am in no way a php guru only slightly educated on it here. <?php // simple.php - shoutcast information display utility // To use this script, save this page save simple.php then edit the information below as noted, uncomment what you need // To imbed the information on your php site use the include function on the page you wish to display the information // Edit the next three lines with your server information $host = "77.101.38.153"; $port = "8000"; $shoutcast_password = "liliarogers"; // Connect to server $fp = fsockopen( $host,$port,$errno,$errstr,10 ); if (!$fp) { echo "Unable to connect to server"; } else { // Get data from server fputs($fp,"GET /admin.cgi?mode=viewxml&SID=1&page=5&pass=$shoutcast_password HTTP/1.1\nUser-Agent:Mozilla\n\n"); // exit if connection broken for($i=0; $i<1; $i++) { if(feof($fp)) break; $fp_data=fread($fp,31337); usleep(500000); } // Strip useless junk from source data $fp_data=ereg_replace("^.*<body>","",$fp_data); $fp_data=ereg_replace("</body>.*","",$fp_data); // Place values from source into variable names list($currentlisteners,$streamstatus,$peaklisteners,$maxlisteners,$reportedlisteners,$bitrate,$songtitle) = explode(",", $fp_data, 7); $trackpattern = "/^[0-9][0-9] /"; $trackreplace = ""; $song = preg_replace($trackpattern, $trackreplace, $song); if ($streamstatus == "1") { // To use any of the outputs below just uncomment (remove the double forward slashes) that line. // Below is an example of all data available in the 7.html file made by the Shoutcast server // **ON BY DEFAULT - COMMENT OUT (put to forwards slashes in front of it) TO HIDE echo "<html>\n<head>\n<title></title>\n</head>\n<body>\nCurrent Listeners: $currentlisteners<br>\nServer Status: $streamstatus<br>\nListener Peak: $peaklisteners<br>\nMaximum Listener: $maxlisteners<br>\nReported Listeners: $reportedlisteners<br>\nBroadcast Bitrate: $bitrate<br>\nCurrent Song: $songtitle\n</body>\n</html>"; // Below is a basic one line value of the current song, perfect for front pages of sites // echo "<html>\n<head>\n<title></title>\n</head>\n<body>\nCurrently Playing: <a href=\"http://$host:$port/listen.pls\">$songtitle</a>\r\n</body>\n</html>"; } else { echo "The radio station is currently down"; } } ?> many thanks Link to comment https://forums.phpfreaks.com/topic/224524-shoutcast-script-recoded/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.