ОсновноеRadiotalkПользовательское
Общие вопросы по интернет радио вещанию
6   •   Посмотреть все темы

Вывод статистики icecast

 

8
rattlesneyk @rattlesneyk
Добрый день. Есть следующий скритп вывода статистики на сайт
<?php
///////////////////////////////////////////////////
//icecast2 status refined v1.1 xsl refined
// Author: that dude over there at casterclub.com
// Bugs: post in the forums at casterclub
//////////////////////////////////////////////////
//start the madness already
//////////////////////////////////////////////////
//start the configurations
$ip = "192.168.1.1"; //your server address in the form of mydomain.com or 192.161.1.1
$port = "8000"; //the port of your server
$ice2_station = "L2KING FM"; // your station or stream name






////////////////start the parsin action\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//opening socket
$fp = fsockopen("$ip", $port, &$errno, &$errstr, 30); //open connection
if(!$fp) {
$success=2; //set if no connection



//edit html to fit your stations site, this display is for offline status
echo'<table>
<tr>
<td width="100%" colspan="2">
<img border="0" src="images/offline.gif" width="22" height="22">
<b><font face="Arial" size="2" color="#FF0000">'.$ice2_station.' is currently offline</font></b></td>
</tr>
</table>';
}




if($success!=2){ //if connection
fputs($fp,"GET /status2.xsl HTTP/1.0\r\nUser-Agent: Icecast2 XSL Parser (Mozilla Compatible)\r\n\r\n"); //get status2.xsl
while(!feof($fp)) {
$page .= fgets($fp, 1000);
}
fclose($fp); //close connection
$page = ereg_replace(".*<pre>", "", $page); //extract data
$page = ereg_replace("</pre>.*", ",", $page); //extract data

$numbers = explode(",",$page); //bomb it and extract data
$mount = $numbers[0];
$connections = $numbers[1];
$stream_n = $numbers[2];
$listeners = $numbers[3];
$desc = $numbers[4];
$cur_song = $numbers[5];
$str_url = $numbers[6];
$client_info = $numbers[7];
$test1 = $numbers[8]; //set vars that where empty and still dont know what the heck those values are ;-)
$test2 = $numbers[9]; //set vars that where empty and still dont know what the heck those values are ;-)
$test3 = $numbers[10]; //set vars that where empty and still dont know what the heck those values are ;-)
$mount = $numbers[11];
$connections = $numbers[12];
$station =$numbers[13];
$listeners = $numbers[14];
$description = $numbers[15];
$cur_song = $numbers[16];
$www_url = $numbers[17];


//edit html to fit your stations site, this display is for online status
echo'


<fieldset><legend>Информация о радио</legend>
<html>
<head>

</head>
<body>
<font size=1><font color=#cf8422>Радиостанция:</font></font><font size=1>&nbsp;<font color=#0ee63b><b>Работает</b></font><div class=line></div><font color=#cf8422>Cлушает: </font><font color=#cf8422> - '.$listeners.' - </font><div class=line></div><font color=#cf8422>В эфире:</font> <font color=red><b>RJ</b></font> <div class=line></div><center><marquee scrolldelay=20 scrollamount=1 truespeed width=100%><font color=#00FF00 style=font-size:11px;font-family: tahoma;><b><font color=#fff></font></b></font></marquee></font></center>
</body>
</html>

<center><marquee scrolldelay=20 scrollamount=1 truespeed width=100%><font color=#00FF00 style=font-size:11px;font-family: tahoma;><b><font color=#cf8422>'.$cur_song.'</font></b></font></marquee></center>
';
}


?>



Как к нему подключить авто обновление?
Пробовал
(function () {
var request = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTPP"),
callee = arguments.callee;
request.open("GET", location.href + "?rand=" + new Date(), true);
request.onreadystatechange = function () {
if (request.readyState === 4 && request.status === 200) {
var doc = document.createElement("DIV");
doc.innerHTML = request.responseText;
document.body.innerHTML = doc.getElementsByTagName("BODY")[0].innerHTML;
setTimeout(callee, 10000);
}
};
request.send(null);
})();


Подскажите....

Отредактировано rattlesneyk - 26.02.2012
6245
Тарас @tarasian666
сделайте чтоб первый скрипт выводил инфу в валидном xml
тогда проблем не будет


а почему вся функция в скобках?

8
rattlesneyk @rattlesneyk
tarasian666 пишет:

сделайте чтоб первый скрипт выводил инфу в валидном xml
тогда проблем не будет


а почему вся функция в скобках?


Я конечно начал читать, но просто времени нет. Нужно сейчас сделать.
Подскажите как=)

6245
Тарас @tarasian666
судя по этой строчке request.open("GET", location.href + "?rand=" + new Date(), true); вы запрашиваете эту же страницу, но в первом скрипте функции аякс нет. Слишком много непоняток. Сделайте все четко по порядку отдельными страницами, а тогда экспериментируйте. Скачайте плагин дебагинга яваскрипта и будете знать точно где косяк

201
burn @burn
tarasian666 пишет:

а почему вся функция в скобках?
Это "замыкание". Здесь, полагаю, используется чтобы не засорять неймспейс.


tarasian666 пишет:

Скачайте плагин дебагинга яваскрипта и будете знать точно где косяк

Присоединяюсь. Отлично справляется **********.

8
rattlesneyk @rattlesneyk
Да я вот думаю. Может проще готовый скрипт поставить?-)))
Только на форуме норм статистики не нашел.

201
burn @burn
rattlesneyk пишет:

Да я вот думаю. Может проще готовый скрипт поставить?-)))
Только на форуме норм статистики не нашел.

Icecast свой или арендуете?

8
rattlesneyk @rattlesneyk
Свой.

888
Falcon @Falcon
Зачем все делать так сложно? jQuery и обычный аякс запрос.
Javascript:
function getcurrenttitle()
{
$.ajax({
url: "getcurrenttitle.php", //Тут указываем файл со скриптами
cache: false,
success: function(html){
$("#getcurrenttitle").html(html);
}
});
}

$(document).ready(function(){
getcurrenttitle();
setInterval('getcurrenttitle()',30000); //Время в милесекундах
});

HTML:
<div id="getcurrenttitle"></div>

6245
Тарас @tarasian666
помоему что этот скрипт что у автора по размеру практически одинаковы, так что нет смысла подключать еще библиотеку jquery если она больше нигде не будет использоваться

Да я вот думаю. Может проще готовый скрипт поставить?-)))
Только на форуме норм статистики не нашел.

я б свой скрипт дал, но он парсит с шоуткаста и мускула