<?php $ip = "server ip"; //your server address in the form of mydomain.com or 192.161.1.1 $port = "port"; //the port of your server $ice2_station = "name"; // your station or stream name $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="" width="22" height="22"> <b><font face="Arial" size="2" color="#FFFFF">'.$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]; $test2= $numbers[9]; $test3 = $numbers[10]; $mount = $numbers[11]; $connections = $numbers[12]; $station =$numbers[13]; $listeners = $numbers[14]; $description = $numbers[15]; $cur_song = $numbers[16]; $www_url = $numbers[17]; echo' <table width="100%" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0"> <tr> <td width="100%"><b><font face="Arial" size="2" color="white"> <img border="0" src="" width="22" height="18"> Слушателей: '.$listeners.'</font></b></td> </tr> <tr> <td width="100%"><b><font face="Arial" size="2" color="white"> <img border="0" src="" width="21" height="21"> Играет: '.$cur_song.'</font></b></td> </tr> <tr> <td width="100%"><b><font face="Arial" size="2" color="white"> <img border="0" src="" width="15" height="15"> <a href="http://'.$ip.':'.$port.''.$mount.'.m3u"><center><img border="0" src="" width="129" height="45"></center></a></font></b></td> </tr> </table>'; } ?>
<? if(isset($mount) && $mount == "") { echo "0"; // если переменная моунт существует и её значение равно "null" то выводить "0" } if(isset($mount) && $mount == "/play") { echo "1"; // если переменная моунт существует и её значение равно "/play" то выводить "1" } if(isset($mount) && $mount == "/dj") { echo "2"; // если переменная моунт существует и её значение равно "/dj" то выводить "2" } ?>
<? if(!$mount) { echo "0"; } else { echo "1"; } ?>
<?php $file_name='http://www.domain.com:8000/status2.xsl?mount=/listen'; $r=fopen($file_name,'r'); $text=fread($r,1000); fclose($r); $mass=explode(",", $text); $current=$mass [16]; $description=$mass [13]; $cm=explode(" - ", $current); ?> <ul class="song"> <li><strong>?????????»???????µ?»??:</strong> <? echo $cm[1]?> </li> <li><strong>???°?·???°?????µ ?????µ???°:</strong> <? echo $cm[2]?></li> </ul>
echo substr(iconv("UTF-8","cp1251",$mass [16]),3);
<? $file_name='http://localhost:8000/status2.xsl'; $m_name='/listen'; ##???°?·???°?????µ ???????????° if($r=@fopen($file_name,'r')) { $text=fread($r,1000); fclose($r); if (strpos($text,$m_name)) {$m_output.="?????????? ???????µ?????????µ??";} else {$m_output.="?????????? ???????????????????µ??";} } else {echo "???????±???°."; exit();} ?> <!-- html --> <? echo $m_output; ?>
<li><strong>?????????»???????µ?»??:</strong> <? echo substr(iconv("UTF-8","cp1251",$cm[1],0);?> </li> <li><strong>???°?·???°?????µ ?????µ???°:</strong> <? echo substr(iconv("UTF-8","cp1251",$cm[2],0);?></li>
<? $file_name='http://localhost:8000/status2.xsl'; $m_name='/listen'; ##название моунта if($r=@fopen($file_name,'r')) { $text=fread($r,1000); fclose($r); if (strpos($text,$m_name)) {$m_output.="Поток существует";} else {$m_output.="Поток отсутствует";} } else {echo "Ошибка."; exit();} ?> <!-- html --> <? echo $m_output; ?>