<?php $xml[1] = simplexml_load_file("http://линко:порт/radio.xspf"); //$xml[2] = simplexml_load_file("http://линко:порт/potok2.xspf"); //по необходимости увеличиваем $kp=1; //количество потоков $i=1; $vsego=0; while ($i <= $kp) { $ano = $xml[$i]->trackList->track->annotation; $mass=explode("\n", $ano); $kol=substr($mass[4],19); $i=$i+1; $vsego=$vsego+$kol; } echo "Слушают: " .$vsego; ?>
Listens: 1
Warning: simplexml_load_file(http://radio.telesweet.net:9000/absoluteclassicrock.xspf) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.0 404 File Not Found in /var/www/radio/1.php on line 2
<?php $xml[] = "http://ip:port/potok.xspf"; //добавляем по маске $kp=1; //количество потоков $i=0; $vsego=0; while ($i <= ($kp-1)) { $vizov=simplexml_load_file($xml[$i]); $ano = $vizov->trackList->track->annotation; $mass=explode("\n", $ano); $kol=substr($mass[4],19); $i=$i+1; $vsego=$vsego+$kol; } echo "Potokov: " .$kp. "<br>"; echo "Listens: " .$vsego; ?>
... [03/10/2009@14:45:19] 1 listeners - [CS: nadja - bliss torn from emptiness pt.1] (this log file generated by RTB v1.1.1) ...
<?php $y=date("Y",time()-86400); $m=date("m",time()-86400); $d=date("d",time()-86400); $file_name='C:/Radio Toolbox/logs/' .$m .'_' .$d. '_' .$y. '_rtb_log.txt'; //директория хранениея логов Radio Toolbox с выборкой нужной даты $r=fopen($file_name,'r'); $text=fread($r,filesize($file_name)); fclose($r); $massiv=explode("\r\n", $text); foreach ($massiv as $txt) { $h = substr($txt,12,2); $h=$h*1; $temp=explode(" ", $txt); $l[$h]=$l[$h]+$temp[1]; $s[$h]=$s[$h]+1; } $txtout='<?php'."\r\n"; for ($i=0; $i<=23; $i++) { $txtout=$txtout. '$ls[]=' .$l[$i]. '; $kz[]=' .$s[$i]. ";\r\n"; } $txtout=$txtout.'?>'; //запись в файл $fp = fopen ("C:/listens/".$y.$m.$d.".dat", "w"); fwrite($fp,$txtout); fclose($fp); ?>
<?php $ls[]=165; $kz[]=120; <sciped> $ls[]=360; $kz[]=120; ?>
<?php $font="fd.ttf"; //имя шрифта $dir='C:/listens/*.dat'; //путь к файлам БД =) $y=$_GET['y']; $m=$_GET['m']; $d=$_GET['d']; $in=$_GET['in']; $t=$_GET['t']; if ($y<2009) {$y=date("Y",time()-86500);} if ($y>2038) {$y=date("Y",time()-86500);} if ($m<1) {$m=date("m",time()-86500);} if ($m>12) {$m=date("m",time()-86500);} if ($d<1) {$d=date("d",time()-86500);} if ($d>31) {$d=date("d",time()-86500);} if ($in==0) {$in=1;} if ($in<0) {$in=1;} if ($in>3) {$in=1;} if ($t<1) {$t=1;} if ($t>3) {$t=1;} if ($t==1 && $in>2) {$in=2;} if ($t==2 && $in<2) {$in=2;} if ($t==3 && $in<3) {$in=3;} $d=substr("0000" .$d,-2,2); $m=substr("0000" .$m,-2,2); if ($in==1) { $d1=$y.$m.$d; $d2=$y.$m.$d; } if ($in==2) { $d1=$y.$m."01"; $d2=$y.$m."31"; } if ($in==3) { $d1=$y."0101"; $d2=$y."1231"; } $d1=$d1*1; $d2=$d2*1; if ($t<0) {$t=1;} if ($t>3) {$t=1;} $mass=glob($dir); $x=0; $td=0; $pem=0; $nachalo=mktime(0,0,0,substr($d1,4,2),substr($d1,6,2),substr($d1,0,4)); //обработка БД согласно вводным foreach ($mass as $filename){ $locfile= substr($filename,-12,8); $locfile=$locfile*1; if ($locfile >=$d1 && $locfile <=$d2) { $tm=1*substr($filename,-8,2); if ($pem==0) {$pem=1;$pm=$tm;} if ($t==3 && $pm<>$tm) { $pm=$tm; $l[$td]=array_sum($ls); $s[$td]=array_sum($kz); $ls=''; $kz=''; $td=$td+1; } include($filename); if ($t==2) { $l[$td]=array_sum($ls); $s[$td]=array_sum($kz); $ls=''; $kz=''; $td=$td+1; } } } if ($t==1) { $name="hours"; $l=$ls; $s=$kz; } if ($t==2) { $name="days"; } if ($t==3) { $name="months"; if ($t==3) { $l[$td]=array_sum($ls); $s[$td]=array_sum($kz); } } $k=sizeof($l); $vivod=0; if (array_sum($l)==0) {$vivod=2;} if ($k==0) {$vivod=1;} $vis=0; for ($i=0;$i<$k;$i++){ $r=$l[$i]/$s[$i]; if ($vis<$r) {$vis=$r;} } $vt=250; if ($t==1 && $in==2) {$vt=300;} if ($t==2 && $in==3) {$vt=300;} //генерация графика header("Content-type: image/png"); $image = imageCreate(800, $vt); $colorback = imageColorAllocate($image, 0, 0, 0); $color1 = imageColorAllocate($image, 0, 255, 0); $color2 = imageColorAllocate($image, 50, 160, 0); imageFilledRectangle($image, 0, 0, 99, 99, $colorback); imageLine($image,30,10,30, 240,$color2); $max=$k; if ($vivod==0) { if ($t==1 && $in==1) {$max=23;} if ($t==1 && $in==2) {$max=24*(date("t",$nachalo)-1);} if ($t==2 && $in==2) {$max=date("t",$nachalo)-1;} if ($t==2 && $in==3) {$max=365;} if ($t==3 && $in==3) {$max=11;} $sh=750/($max+1); $vd=round($vis); $st=1; if ($vis==0) {$rp=20;$st=1;} if ($vis<>0) { $rp=200*$st/$vis; while ($rp<10) { $st=$st+1; $rp=200*$st/$vis; } } $i=0; while ($i<=$vd) { $v=200*$i/$vis; $bbox=imagettfbbox(6, 0, $font, $i); imageLine($image,20,229-$v,780, 229-$v,$color2); imagettftext ($image, 6, 0, 30-$bbox[2]-3, 229-$v-2, $color2, $font,$i); $i=$i+$st; } for ($i=0;$i<$k;$i++){ $r=$l[$i]/$s[$i]; $v=200*$r/$vis; $nc=$i+1; if ($t==1) {$nc=$i;} imageFilledRectangle($image, 31+$sh*$i, 229-$v, 29+$sh*($i+1), 229, $color1); $bbox=imagettfbbox(6, 0, $font, $i); } $st=1;$oo=1;$u=0; if ($t==1 && $in==2) {$st=24;$oo=0;$u=-90;} if ($t==2 && $in==3) {$st=30;$oo=0;$u=-90;} $rp=750*$st/$max; while ($rp<10) { $st=$st+1; $rp=200*$sh; } $i=0; while ($i<=$max) { $v=750*$i/$max; $io=$i; if ($t<>1) {$io=$i+1;} if ($t==1 && $in==2) {$io=date("d-M",$nachalo+3600*$i);} if ($t==2 && $in==3) {$io=date("M",$nachalo+24*3600*$i);} if ($t==3) {$io=date("M",$nachalo+31*24*3600*$i);} if ($i<>0) {imagettftext ($image, 6, $u, 31+$sh+$sh*$i-$sh/2-$bbox[2]/2, 240-$bbox[3]/2, $color2, $font,$io);} if ($i==0 && $oo==1) {imagettftext ($image, 6, $u, 31+$sh+$sh*$i-$sh/2-$bbox[2]/2, 240-$bbox[3]/2, $color2, $font,$io);} $i=$i+$st; } } if ($vivod==1) {imagettftext ($image, 20, 0, 175, 150, $color1, $font,"NOT DATA IN STORAGE");} if ($vivod==2) {imagettftext ($image, 20, 0, 260, 150, $color1, $font,"Not Listens");} $dati=substr($d1,0,4).":".substr($d1,4,2).":".substr($d1,6,2)."-".substr($d2,0,4).":".substr($d2,4,2).":".substr($d2,6,2)." (" . date("T",$nachalo). ")"; if ($d1==$d2) {$dati=substr($d1,0,4).":".substr($d1,4,2).":".substr($d1,6,2)." (" . date("T",$nachalo). ")";} imagettftext ($image, 6, 0, 40, 10, $color2, $font,$dati); imagettftext ($image, 6, 0, 760, 10, $color2, $font,'V.2.8'); imagettftext ($image, 6, 0, 2, 247, $color2, $font,$name); imageInterlace($image, 1); imagepng($image); ?>
<?php $ls[]=0; $kz[]=120; <sciped> $ls[]=0; $kz[]=120; ?>
<?php $ip = "zloe.servemp3.com"; $port = "7000"; $ice2_station = "Rадио "; $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="Georgia" size="5" color="#FF0000">'.$ice2_station.' сейчас не работает</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 $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' <table width="100%" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0"> <tr> <td width="100%"><b><font face="Arial" size="2"> <tr> <td width="100%"><b><font face="Georgia" color="green" size="5"> <img border="0" src="images/ice2_status/tunes.gif" width="22" height="18"> '.$ice2_station.' работает! </font></b></td> </tr> <tr> <td width="100%"><b><font face="Georgia" color="green" size="5"> <img border="0" src="images/ice2_status/tunes.gif" width="22" height="18"> '.$listeners.' </font></b></td> </tr> </table>'; }
<pre> MountPoint,Connections,Stream Name,Current Listeners,Description,Currently Playing,Stream URL Global,Client:158157 Source: ,,0,, </pre>
<pre> MountPoint,Connections,Stream Name,Current Listeners,Description,Currently Playing,Stream URL Global,Client:158159 Source: ,,0,, /radio,,,19,, - , </pre>
<?php $ip = "zloe.servemp3.com"; $port = "7000"; $ice2_station = "Rадио "; $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="Georgia" size="5" color="#FF0000">'.$ice2_station.' сейчас не работает</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 $mount = $numbers[11]; $connections = $numbers[12]; $station =$numbers[13]; $listeners = $numbers[14]; $description = $numbers[15]; $cur_song = $numbers[16]; $www_url = $numbers[17]; if (strlen($mount)<2) echo '<table width="100%" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0"> <tr> <td width="100%"><b><font face="Arial" size="2"> <tr> <td width="100%"><b><font face="Georgia" color="green" size="5"> <img border="0" src="images/ice2_status/tunes.gif" width="22" height="18"> '.$ice2_station.' Не работает! </font></b></td> </tr> </tr> </table>'; //edit html to fit your stations site, this display is for online status else echo '<table width="100%" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0"> <tr> <td width="100%"><b><font face="Arial" size="2"> <tr> <td width="100%"><b><font face="Georgia" color="green" size="5"> <img border="0" src="images/ice2_status/tunes.gif" width="22" height="18"> '.$ice2_station.' работает! </font></b></td> </tr> <tr> <td width="100%"><b><font face="Georgia" color="green" size="5"> <img border="0" src="images/ice2_status/tunes.gif" width="22" height="18"> '.$listeners.' </font></b></td> </tr> </table>'; } ?>