Code - getsteamstats

<?php


$fp 
fsockopen("stream.xrm.fm"80);

if (!
$fp)
{
    echo 
"Failed to connect to Steamcast";
    exit();
}

fputs($fp"GET /status.xml HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");

while(!
feof($fp))
{
    
$line fgets($fp512);
    if (
$line == "\r\n")
        break;
    
$line trim($line);
    if (
eregi("HTTP"$line))
    {
        
$header['Response'] = ereg_replace("HTTP/1.0 """$line);
    }
    else
    {
        
$header[ereg_replace(":.*"""$line)] = trim(ereg_replace(".*:"""$line));
    }
}

while(!
feof($fp))
{
    
$xml_data .= fread($fp512);
}
fclose($fp);

$xml_data ereg_replace("\r|\n|\t"""$xml_data);

$xm xml_parser_create("UTF-8");
xml_parse_into_struct($xm$xml_data$vals$index);
xml_parser_free($xm);


$in_source false;
$sources = array();
foreach(
$vals as $key => $val)
{
    if (
$val['tag'] == "SYSTEM_TIME")
    {
        
$st $val['value'];
    }
    else if (
$val['tag'] == "SOURCE")
    {
        if (
$val['type'] == "open")
        {
            
$i++;
            
$in_source true;
        }
    }
    else if (
$in_source == true)
    {
        if (
$val['tag'] == "MOUNT")
        {
            
$cur_mnt $val['value'];
        }
        else
        {
            
$sources[$cur_mnt][$val['tag']] = $val['value'];
        }
    }
}
?>
<html>
<head>
<title>Freaking Steamcast PHP XML Parser</title>
</head>
<body>

<table width="100%">
<th>Name</th><th>Playing</th><th>Time Online</th><th>Listeners</th><th>Action</th>
<?php
foreach($sources as $key => $val)
{
    echo 
'<tr>
<td>'
.$val['NAME'].'</td><td>'.$val['META_SONG'].'</td><td>'.$val['DESCRIPTION'].'</td><td>'.$val['NODES'].((isset($val['MAX_NODES']))?'/'.$val['MAX_NODES']:'').'</td><td><a href="'.$val['URL'].'">Visit Website</a></td>
</tr>'
;
}

?>
</table>
</body>
</html>