我需要一些帮助来理解并可能解决php文件的问题,这个文件是旧的whmsonic模板的一部分,没有更多的下载,我有一个全新的安装,但即使有它也没有解决方案。
这是文件
<?php
include("language/en.php");
include('config_radio.php');
$ctx = stream_context_create(array(
'http' => array(
'timeout' => 10
)
)
);
@ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 WHMSonic/2.0.1');
$d = @file_get_contents("http://".$GLOBALS['scip'] . ":" . $GLOBALS['scport'] . "/admin.cgi?mode=viewxml&pass=" . $GLOBALS['scpass'], 10, $GLOBALS['ctx']);
if (!$d) {
echo "<font color=66CCFF><b>$GLOBALS[lang9]<br>$GLOBALS[lang8]</b></font>"; exit; } else {
$shoutcast_xml = new SimpleXMLElement($d);
$bitrate = utf8_decode($shoutcast_xml->BITRATE);
$streamstatus = utf8_decode($shoutcast_xml->STREAMSTATUS);
$currentlisteners = utf8_decode($shoutcast_xml->CURRENTLISTENERS);
$servertitle = utf8_decode($shoutcast_xml->SERVERTITLE);
$songtitle = utf8_decode($shoutcast_xml->SONGTITLE);
?>
<html>
<head>
<META HTTP-EQUIV="Refresh" CONTENT="25; URL=stats.php">
<link type="text/css" rel="stylesheet" href="template/style2.css">
</head>
<body style="margin:0px;">
<div align="center">
<?php if($streamstatus == "1"){ echo ""; } else { echo "<font color=66CCFF><b>$GLOBALS[lang7]<br>$GLOBALS[lang8]</b></font>"; exit;} ?>
<br>
</div>
<table width="90%" border="0" cellspacing="2" cellpadding="0" align="center">
<tr>
<td width="25%">
<div align="right"><b><font color="#999999"><?php echo $GLOBALS['lang3'];?>:</font></b></div>
</td>
<td width="75%">
<?php echo "<font color=FFFFFF><b>$GLOBALS[servertitle]</b></font>"; ?>
</td>
</tr>
<tr>
<td width="25%">
<div align="right"><b><font color="#999999"><?php echo$GLOBALS['servertitle'];?>:</font></b>
</div>
</td>
<td width="75%">
<?php echo "<font color=FFFFFF><b>$GLOBALS[songtitle]</b></font>"; ?>
</td>
</tr>
<tr>
<td width="25%">
<div align="right"><b><font color="#999999"><?php echo$GLOBALS['lang5'];?>:</font></b></div>
</td>
<td width="75%">
<?php echo "<font color=FFFFFF><b>$GLOBALS[bitrate] KBPS</b></font>"; ?>
</td>
</tr>
<tr>
<td width="25%">
<div align="right"><b><font color="#999999"><?php echo$GLOBALS['lang6'];?>:</font></b><font color="#999999"></font>
</div>
</td>
<td width="75%">
<?php echo "<font color=FFFFFF><b>$GLOBALS[currentlisteners]</b></font>"; ?>
</td>
</tr>
</table>
</body>
</html>
<?php } ?>
蚂蚁,这是我在日志中的错误
PHP Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/radionet/public_html/stats.php:17
Stack trace:
#0 /home/radionet/public_html/stats.php(17): SimpleXMLElement->__construct('<?xml version="...')
#1 {main}
thrown in /home/radionet/public_html/stats.php on line 17
第17行将是
echo "<font color=66CCFF><b>$GLOBALS[lang9]<br>$GLOBALS[lang8]</b></font>"; exit; } else {
我问你一些解决方案的建议,我已经尝试了一些alredy关于XML语法文件的指南,没有解决方案。
非常感谢, 问候
答案 0 :(得分:0)
您忘记了代码$GLOBALS[]
试试这个:
echo "<font color=66CCFF><b>$GLOBALS['lang9']<br>$GLOBALS['lang8']</b></font>"; exit; } else {