mam taky problem na stranke mi ukazuje status radioshoutcastu ale mam dva servery na ktorych vysielam. a chcel by som to tak spravit ze: ak nebude jeden vysielat tak ukaze status druheho, a ak nebude vysielat druhy ukaze status prveho samozrejme ked budu vypate ukaze OFFLINE - ako to spravit pri tomto php subore?
Kód:
<?php
include('config_radio.php');
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
if(!$scfp) {
$scsuccs=1;
}
if($scsuccs!=1){
fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n");
while(!feof($scfp)) {
$page .= fgets($scfp, 1000);
}
######################################################################################################################
/////////////////////////part 1 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//define xml elements
$loop = array("STREAMSTATUS", "BITRATE", "SERVERTITLE", "CURRENTLISTENERS", "MAXLISTENERS", "BITRATE");
$y=0;
while($loop[$y]!=''){
$pageed = ereg_replace(".*<$loop[$y]>", "", $page);
$scphp = strtolower($loop[$y]);
$$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed);
if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE || $loop[$y]==SERVERTITLE)
$$scphp = urldecode($$scphp);
// uncomment the next line to see all variables
//echo'$'.$scphp.' = '.$$scphp.'<br>';
$y++;
}
//end intro xml elements
######################################################################################################################
######################################################################################################################
/////////////////////////part 2\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//get song info and history
$pageed = ereg_replace(".*<SONGHISTORY>", "", $page);
$pageed = ereg_replace("<SONGHISTORY>.*", "", $pageed);
$songatime = explode("<SONG>", $pageed);
$r=1;
while($songatime[$r]!=""){
$t=$r-1;
$playedat[$t] = ereg_replace(".*<PLAYEDAT>", "", $songatime[$r]);
$playedat[$t] = ereg_replace("</PLAYEDAT>.*", "", $playedat[$t]);
$song[$t] = ereg_replace(".*<TITLE>", "", $songatime[$r]);
$song[$t] = ereg_replace("</TITLE>.*", "", $song[$t]);
$song[$t] = urldecode($song[$t]);
$dj[$t] = ereg_replace(".*<SERVERTITLE>", "", $page);
$dj[$t] = ereg_replace("</SERVERTITLE>.*", "", $pageed);
$r++;
}
//end song info
fclose($scfp);
}
//display stats
if($streamstatus == "1"){
//you may edit the html below, make sure to keep variable intact
echo'
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel=stylesheet href="" type="text/css">
<title>'.$scdef.'</title>
</head>
<body text="" bgcolor="">
<p align="center"><center>
<div><TABLE bgcolor="#000000" border=1 bordercolorlight="#C0C0C0" bordercolordark="#808080">
<TR valign=top>
<TD rowspan=7 width=113><div class="wpmd">
<div><img src="logoo.jpg"></div>
</div>
</TD>
<TD width=166><div class="wpmd">
<div><center><img src="online.jpg"></center><br></font></div>
</div>
</TD>
</TR>
<TR valign=top>
<TD width=166><div class="wpmd">
<div><font color=red><b>Názov:</b> '.$servertitle.'<br></font></div>
</div>
</TD>
</TR>
<TR valign=top>
<TD width=166><div class="wpmd">
<div><font color=red><b>Poslucháci:</b> '.$currentlisteners.' / '.$maxlisteners.'<br></font></div>
</div>
</TD>
</TR>
<TR valign=top>
<TD width=166><div class="wpmd">
<font color=red><div><b>Bitrate:</b> '.$bitrate.'kbps<br></font></div>
</div>
</TD>
</TR>
<TR valign=top>
<TD width=166><div class="wpmd">
<div><font color=red><MARQUE><b>Práve hrá:</b> '.$song[0].'</p><b></font></MARQUE></div>
</div>
</div></div>
</div>
</TD>
</TR>
</TABLE>
</div>
</div></div>
</p>
</body>
</html>';
}
if($streamstatus == "0")
{
//you may edit the html below, make sure to keep variable intact
echo'
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel=stylesheet href="" type="text/css">
<title>Radio je Offline</title>
</head>
<body text="" bgcolor="">
<center>
<img src="offline.jpg">
</body>
</html>';
}
?>