beh se il server risponde con una rischiesta di autenticazione vuol dire che è attivo
forse l'esempio cho eho postato andrebbe raffinato, ma non so neanche io come...
in alternativa puoi provare con "file_exist"
mi pare di aver capito se il server Icecast crei dinamicamente questo file su richiesta:
http://serverort/admin/stats.xml
in teoria basterebbe controllarne l'esistenza con file_exist per capire se il server è online:
esempio:
<?php
$filename = '/path/to/foo.txt';
if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
?>
che applicato al tuo caso dovrebbe essere così:
Codice PHP:<?php
include("icecast.current.class.php");
$icecast = new icecast();
if (file_exists("http://stream.lanostraradio1.com:8000/admin/stats.xml"))
{
$icecast->host = "stream.lanostraradio1.com";
$icecast->port = 8000;
$icecast->mount = "mount1";
$icecast->user = "user";
$icecast->passwd = "passwd";
}
else
{
//impostazioni secondo server
$icecast->host = "stream.lanostraradio2.com";
$icecast->port = 8000;
$icecast->mount = "mount1";
$icecast->user = "user";
$icecast->passwd = "passwd";
}
function elapsedtime($seconds) {
if ($seconds > 86400) {
eccetera....
}


ort/admin/stats.xml
Rispondi quotando