<?php
// homepage www.samscripts.com/scripts/voxinfo
header("Content-disposition: text/xml");
echo '<?xml version="1.0"?>'."\n".'<info>'."\n";
ini_set("track_errors", 1);
//$fp = @fopen("http://info.voxtreme.com/index.php","r");
$fp = @fopen("./serverstatus.htm","r");
if( $fp ){
$txt = "";
$in = "";
while( ($txt = @fread($fp, 4096)) ){
$in .= $txt;
}
fclose($fp);
$f = "|<td><FONT SIZE=1 COLOR=#000000 face='Verdana, Arial, Helvetica, sans-serif'><B>(.*?)</B><BR><I>(.*?)</I></FONT>(<td.*?</FONT></td></tr>)|is";
$ff = "|<tr bgcolor=\".*?\"><td align=left bgcolor=\".*?\"><FONT SIZE=2 COLOR=.*? face='Verdana, Arial, Helvetica, sans-serif'><B>(.*?)</B>(.*?)</font></td></tr>|is";
if( preg_match_all( $ff, $in, $matches) ){
for( $i = 0; $i < count($matches[1]); $i++){
$announcements[$matches[1][$i]] = preg_replace("|^.*?-\s*(.*)|is", '$1',$matches[2][$i]);
}
}else{
$announcements = array();
}
if( preg_match_all( $f, $in, $matches) ){
$servers = array();
for( $i = 0; $i < count($matches[0]); $i++){
$servers[$matches[1][$i]]["ip"] = $matches[2][$i];
$m = "|.*?/images/(.*?)\.gif.*?|is";
if( preg_match_all($m, $matches[3][$i], $statuses) ){
$servers[$matches[1][$i]]["status"] = true;
$s = &$servers[$matches[1][$i]];
list($s["ftp"], $s["http"], $s["MySql"], $s["pop3"], $s["smtp"]) = $statuses[1];
$s["uptime"] = preg_replace("|.*<FONT SIZE=1 COLOR=#000000 face='Verdana, Arial, Helvetica, sans-serif'>(.*?)</FONT></td></tr>|is", '$1', $matches[3][$i]);
}else{
$servers[$matches[1][$i]]["status"] = false;
}
}
}
if( isset($HTTP_GET_VARS["servers"]) ){
$sv = $HTTP_GET_VARS["servers"];
$wantservers = explode("-", $sv);
$serversearch = "/(".join("|", $wantservers).")/i";
}
if( isset($HTTP_GET_VARS["iwant"]) ){
$iwant = $HTTP_GET_VARS["iwant"];
}
if( !isset($iwant) || preg_match("|announcements|i", $iwant) ){
echo " <announcements>\n";
foreach( $announcements as $date=>$value){
if( !isset($serversearch) || preg_match($serversearch, $value) ){
echo " <announcement date=\"$date\" text=\"$value\" />\n";
}
}
echo " </announcements>\n";
}
if( !isset($iwant) || preg_match("|servers|i", $iwant) ){
echo " <servers>\n";
foreach( $servers as $name => $status){
if( !isset($serversearch) || preg_match($serversearch, $name) ){
echo "\t\t<server name=\"$name\"";
foreach( $status as $k=>$v) echo " $k=\"".str_replace("\n","",$v)."\"";
echo " />\n";
}
}
echo " </servers>\n";
}
}else{
?>
<error><?php echo urlencode($php_errormsg);?></error>
<?php
}
?>
</info>