
05-02-2012, 14:12:09
|
| |
Shoutcast stats (yardım/ücretli) | | Merhabalar, adını vermek istemediğim bir firmadan hizmet alıyorum kendilerinden defalarca yardım istememe rağmen biraz vakit ayırıp ilgilenmediler benimle. İstediğim şey neredeyse tüm müşterilerinde var. Ben sitemde çalan şarkı adını ve online dinleyici sayısını göstermek istiyorum. 2 farklı php kod buldum. Birincisini hiç çalıştıramadım, ikincisi ise çoğu zaman kendi kendine kapanıyor yayın açık değildir yazıyor, ara sıra ise düzeliyor. Düzgün çalışan kodları arıyorum veya kodları yazabilecek olan varsa iletişim bilgilerini pm göndersin. Kod 1 Kod: <html>
<head>
<META HTTP-EQUIV="REFRESH" CONTENT="60">
<title>Yeni Sayfa 1</title>
</head>
<?
///---------------------\\
$ip = "radyo ip adresi";
$port = "radyo port";
$sifre = "radyosifre";
//\---------------------//
$d = fsockopen($ip, $port, $err, $errno, 30);
if ($d)
{
fputs($d, "GET /admin.cgi?pass=$sifre&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n");
while (!feof($d))
{
$sayfa .= fgets($d,1000);
}
preg_match("/<SERVERTITLE>(.+)<\/SERVERTITLE>/",$sayfa,$dj);
preg_match("/<SERVERGENRE>(.+)<\/SERVERGENRE>/",$sayfa,$radyo);
preg_match("/<SONGTITLE>(.+)<\/SONGTITLE>/",$sayfa,$sarki);
echo "Şuanki Radyo: $radyo[0] <br> Dj: $dj[0] <br> Şarkı: ".urldecode($sarki[0])."<br>";
fclose($d);
} else {
echo "Şuan Radyo Aktif Değildir.";
fclose($d);
}
?>
<body>
</body>
</html> Kod 2 Kod: <html>
<head>
<META HTTP-EQUIV="REFRESH" CONTENT="60">
<title>Yeni Sayfa 2</title>
</head>
<?php
$index = 1;
global $bgcolor2;
/////////////////////////
// SECTION 1 :: CONFIG //
/////////////////////////
error_reporting (E_ALL ^ E_WARNING ^ E_NOTICE);
//SHOUTcast server Dns Ayarları
$shout_server = "radyo ip adresi";
$shout_port = "radyo port";
$shout_password = "radyo sifre";
//Set this to whatever the bitrate you are streaming at is ( BitraTE yAYIN Kalitesi)
$bitrate="64";
//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 "Yayın Açık Değildir<br><br>Kısa bir süre sonra tekrar deneyiniz..";
}
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
// <SONG> 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(".*<body>", "", $page); //extract data
@$page = ereg_replace("</body>.*", ",", $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){
Echo "$nowplaying[0] - $nowplaying[1] ";
}
}
?>
<body>
</body>
</html>
Konu FurkanAyhan tarafından (05-02-2012 Saat 14:15:42 ) değiştirilmiştir..
|