<?php
/* Including the NEEDED files */
include './classes.php';
//
// Please edit the information below (so the script may login and get the xml status)
//
$server['domain'] = 'blabla.com'; // Server domain name (yourdomain.com) DO NOT ADD HTTP:// OR
WWW.
$server['pass'] = '****************************'; // Shoutcast server password
$server['port'] = '8000'; // Server port
//
// Please do not EDIT anything below this
// unless you know WHAT YOU ARE DOING!
//
function GetElementByName ($xml, $start, $end) {
global $pos;
$startpos = strpos($xml, $start);
if ($startpos === false) {
return false;
}
$endpos = strpos($xml, $end);
$endpos = $endpos+strlen($end);
$pos = $endpos;
$endpos = $endpos-$startpos;
$endpos = $endpos - strlen($end);
$tag = substr ($xml, $startpos, $endpos);
$tag = substr ($tag, strlen($start));
return $tag;
}
/* Setting the server url */
$server_url = 'http://'.$server['domain'].':'.$server['port'].'/admin.cgi?pass='.$server['pass'].'&mode=viewxml';
/* Below we will get the the info from the XML status page :D */
$pos = 0;
$Nodes = array();
if (!($fp = fopen("$server_url", "r"))) {
die("could not open XML input");
}
while ($getline = fread($fp, 4096)) {
$data = $data . $getline;
}
$count = 0;
$pos = 0;
// Goes throw XML file and creates an array of all <XML_TAG> tags.
while ($node = GetElementByName($data, "<SHOUTCASTSERVER>", "</SHOUTCASTSERVER>")) {
$Nodes[$count] = $node;
$count++;
$data = substr($data, $pos);
}
// Gets infomation from tag siblings.
for ($i=0; $i<$count; $i++) {
$title = GetElementByName($Nodes[$i], "<SERVERTITLE>", "</SERVERTITLE>");
}
echo $title;
?>