$index = 1;
global $bgcolor2;
/////////////////////////
// SECTION 1 :: CONFIG //
/////////////////////////
error_reporting (E_ALL ^ E_WARNING ^ E_NOTICE);
//Radyonuzun ayarlarını Girin
$shout_server = "radyo ip sini yada adresini giriniz ";
$shout_port = "radyo portunu giriniz";
$shout_password = "radyo yayın şifresini giriniz";
//Set this to whatever the bitrate you are streaming at is ( BitraTE yAYIN Kalitesi)
$bitrate="96";
//Default Album Cover
//$default_album_cover="";
//Stream Name
$streamname="";
//////////////////////////////////////
// SECTION 2 :: CONNECT AND RECEIVE //
//////////////////////////////////////
$shout_socket = fsockopen ($shout_server, $shout_port, $errno, $errstr,30);
if (!$shout_socket)
{
echo "Error: Radio is currently unavailable(Yayın Yok)";
}
else
{
$xml_load = "";
// Let's say hello
fputs ($shout_socket, "GET /admin.cgi?pass=".$shout_password."&mode=viewxml HTTP/1.1\nUser-Agent:Mozilla\n\n");
// Now get the XML
while (!feof($shout_socket)) {
$xml_load .= fgets ($shout_socket, 1000);
}
}
if ($shout_socket) {
//////////////////////////////
// SECTION 3 :: PERPARE XML //
//////////////////////////////
// For my own sanity, I'm getting OUT of XML here, replacing tags with [ ] brackets, so that
// becomes [SONG], etc...
$xml_load = strtr ($xml_load, '<', '[');
$xml_load = strtr ($xml_load, '>', ']');
$tag_separated = explode ("]", $xml_load);
foreach ($tag_separated as $key => $value) {
$tag_separated[$key] = $value."]\n";
if (substr_count($value, "Content-Type")) {$tag_separated[$key] = "";}
}
//////////////////////////////
// SECTION 4 :: PARSING XML //
//////////////////////////////
// $titles array will hold the last 10 songs played
// Note that $titles[0] will give you the currently playing song
// -- the following are provided to let you know which stats are being grabbed by this script
$titles = array();
$currentlisteners=0;
$peaklisteners=0;
$maxlisteners=0;
$reportedlisteners=0;
$averagetime=0;
$servergenre="";
$serverurl="";
$servertitle="";
foreach ($tag_separated as $value) {
if (substr_count($value, "[/TITLE]")) {
$value = str_replace ("[/TITLE]","", $value);
array_push ($titles, $value);
}
if (substr_count ($value, "[/CURRENTLISTENERS]")) {
$value = str_replace ("[/CURRENTLISTENERS]","", $value);
$currentlisteners=$value;
}
if (substr_count ($value, "[/PEAKLISTENERS]")) {
$value = str_replace ("[/PEAKLISTENERS]","", $value);
$peaklisteners=$value;
}
if (substr_count ($value, "[/MAXLISTENERS]")) {
$value = str_replace("[/MAXLISTENERS]","", $value);
$maxlisteners=$value;
}
if (substr_count ($value, "[/REPORTEDLISTENERS]")) {
$value = str_replace("[/REPORTEDLISTENERS]","", $value);
$reportedlisteners=$value;
}
if (substr_count ($value, "[/AVERAGETIME]")) {
$value = str_replace("[/AVERAGETIME]","", $value);
$averagetime=$value;
$tmp=$averagetime / 60;
$averagesec=$averagetime % 60;
if ($averagesec < 10) {$averagesec = "0".$averagesec;}
$averagemin = sprintf ("%d",$tmp);
$averagehour = $averagemin / 60;
$averagemin = $averagemin % 60;
$averagehour = sprintf ("%d", $averagehour);
}
if (substr_count ($value, "[/SERVERGENRE]")) {
$value = str_replace("[/SERVERGENRE]","", $value);
$servergenre=$value;
}
if (substr_count ($value, "[/SERVERURL]")) {
$value = str_replace("[/SERVERURL]","", $value);
$serverurl=$value;
}
if (substr_count ($value, "[/SERVERTITLE]")) {
$value = str_replace("[/SERVERTITLE]","", $value);
$servertitle=$value;
if (substr_count ($servertitle, "N/A")) {$servertitle = "Radio is currently offline!";}
}
if (substr_count ($value, "[/STREAMHITS]")) {
$value = str_replace("[/STREAMHITS]","", $value);
$streamhits=$value;
}
}
// $nowplaying[0] = currently playing artist
// $nowplaying[1] = currently playing title
// Obviously, use of this requires that titles be named like so:
// Artist - Title
// If not, just use $titles[0] for the current song
$temp = $titles[0];
$nowplaying = explode (" - ",$temp);
//////////////////////////////////
// SECTION 5 :: OUTPUT THE PAGE //
//////////////////////////////////
//Show if on or off -added by bodhisattva//
$fp = fsockopen("$shout_server", $shout_port, &$errno, &$errstr, 30);
if(!$fp) {
$success=2;
}
if($success!=2){ //if connection
fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n");
while(!feof($fp)) {
$page .= fgets($fp, 1000);
}
fclose($fp);
$page = ereg_replace(".*", "", $page); //extract data
$page = ereg_replace(".*", ",", $page); //extract data
$numbers = explode(",",$page);
$currentlisteners=$numbers[0];
$connected=$numbers[1];
if($connected==1)
$wordconnected="yes";
else
$wordconnected="no";
}
if($success!=2 && $connected==1){
print "Yayındaki DJ:
$servertitle
";
print "Suanda Çalan Sarki:
$nowplaying[0] - $nowplaying[1]
";
print "Suanda Radyomuzda: $currentlisteners Dinleyici Mevcut...
";
}
else{
print "Time: ".date ("h:i:s A")."
";
print "Stream is currently down.
";
}
}
?>
Yıkarıdaki kodlarda Radyonuzun ayarlarını Girin satırı altında bulunan bağlantı bilgilerini doğru bir şekilde girerek sayfayı baglan.php olarak kaydedin ve sunucunuza gönderiniz.
Daha sonra siteadresi.com/baglan.php diyerek kodların çalışıp çalışmadığını test ediniz. Olumlu test sonuçlarından sonra iframe kodları ile sitenizde istediğiniz yere ekleyebilirsiniz.
Örnek İframe Kodu:
Demo: Radyo Dinle