djimpact Posted June 23, 2010 Share Posted June 23, 2010 Please can someone help me with a script? I've searched everywhere for ages now and have found a few but they do not do exactly what i'm after and i don't know php http://icecast.imux.net/images/smiles/icon_confused.gif Basically my host only allows some functions so the php needs to use "fsockopen" as i know it works. Just two rules: If fsockopen is open then display the song artist/title If fsockopen is closed then show Server Offline I've tried loads now but the closest i got to one doesn't use fsockopen and the page keeps trying to load when server is offline instead of just displaying Link to comment Share on other sites More sharing options...
djimpact Posted June 24, 2010 Author Share Posted June 24, 2010 The below would be perfect but it is for a shoutcast server and i need icecast: Can anyone convert? index.php <br /> function updateNowPlaying(){<br /> $.ajax({<br /> url: "./now-playing.php",<br /> cache: false,<br /> success: function(html){<br /> $("#nowPlaying").html(html);<br /> }<br /> });<br /> }<br /> updateNowPlaying();<br /> setInterval( "updateNowPlaying()", 10000 );<br /> now-playing.php /* Now Playing PHP script for SHOUTcast This script is (C) MixStream.net 2008 Feel free to modify this free script in any other way to suit your needs. Version: v1.1 */ /* ----------- Server configuration ---------- */ $ip = "host.host.net"; $port = "9999"; /* ----- No need to edit below this line ----- */ /* ------------------------------------------- */ $fp = @fsockopen($ip,$port,$errno,$errstr,1); if (!$fp) { echo "OFF AIR - Tune In At 6pm"; // 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"; // Diaplays when sever is online but no song title } else { $title = str_replace('\'', '`', $split[6]); $title = str_replace(',', ' ', $title); echo "$title"; // Diaplays song } } ?> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.