我在一个论坛上找到了这个脚本(在2008年的帖子上),但我无法使其正常工作。
我尝试过:
1-删除
if($status[0] == 0)
{
die('<center>Our radio is currently <font color=red><b>offline</b>! </font></center>');
}
2-交换
fputs ($fp, "GET /admin.cgi?pass={$adminpass}&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n");
对于
fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
脚本:
$host = "111.111.1.11"; # the IP address of your server
$port = "8000"; #the port your server's on
$adminpass = "changeme"; #the ADMINISTRATOR password
$fp = fsockopen ($host, $port, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br>\n";
} else {
fputs ($fp, "GET /admin.cgi?pass={$adminpass}&mode=viewxml
HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n");
while (!feof($fp)) {
$content .= fgets ($fp,128);
}
fclose ($fp);
}
$status = explode('<STREAMSTATUS>',$content);
$status = explode('</STREAMSTATUS>',$status[1]);
if($status[0] == 0)
{
die('<center>Our radio is currently <font color=red><b>offline</b>! </font></center>');
}
$listeners = explode('<CURRENTLISTENERS>',$content);
$listeners = explode('</CURRENTLISTENERS>',$listeners[1]);
$maxlisteners = explode('<MAXLISTENERS>',$content);
$maxlisteners = explode('</MAXLISTENERS>',$maxlisteners[1]);
$servertitle = explode('<SERVERTITLE>',$content);
$servertitle = explode('</SERVERTITLE>',$servertitle[1]);
$song = explode('<TITLE>',$content);
for($i=1; $i<=10; $i++)
{
$song[$i] = explode('</TITLE>',$song[$i]);
$song[$i] = $song[$i][0];
}
echo '<center>';
echo "<b>Listeners:</b> {$listeners[0]} / {$maxlisteners[0]}<br><br>";
echo "<b>Current DJ:</b> {$servertitle[0]}<br><br>";
echo "<b>Current Song:</b> {$song[1]}<br><br>";
echo "<b>Recent Songs:</b><br>";
foreach($song as $id => $value)
{
if($id != 0 && $id != 1)
{
$display = $id - 1;
echo "<b>{$display}</b>. {$value}<br>";
}
}
echo '</center>';
?>
它应该显示收听者的数量,DJ,当前歌曲和最近的歌曲,而只是显示“我们的收音机当前离线!”。
我非常确定IP地址和端口正确无误,就像我在WHMSonic提供的“无线电管理员密码”中输入的“管理员密码”一样。
答案 0 :(得分:-1)
此处的第二行覆盖了之前的行:
$status = explode('<STREAMSTATUS>',$content);
$status = explode('</STREAMSTATUS>',$status[1]);
似乎在多个地方都可以做到。不确定是否行得通。