<?php
/* PHP4 hack by Michael Kimsal -- modified to remove sourceforge html escape by TDavid 1/31/06
    see: http://sourceforge.net/forum/forum.php?thread_id=1431063&forum_id=52655
*/
 
header("Content-Type: text/xml"); 
 
//include db connection 
include 'dbconfig.inc.php'
$xmlString "<?xml version='1.0'?>\n"
 
$result mysql_query("show processlist",$db) or die(mysql_error($db)); 
 
//init filters. 
$filters = array("Host","db"); 
 
while(
$row mysql_fetch_assoc($result)) { 
 
//check the current thread against filter rules. 
$insertFlag=1// 1=Insert 0=No Insert 
//format Host. 
$hostValue chopHost($row['Host']); 
 
foreach(
$filters as $currentFilter) { 
if(
$insertFlag != 0) { 
if(
$currentFilter == "Host") { 
$insertFlag filter($hostValue,$_GET[$currentFilter]); 
} else { 
$insertFlag filter($row[$currentFilter],$_GET[$currentFilter]); 
}
//end if/else. 
}//end if. 
 
}//end for/each. 
 
if($insertFlag == 1) { 
//create a new thread element. 
$string "<div class='Columns'>\n"
$xmlString .= $string
 
//insert thread into DOM object. 
foreach($row as $fieldname => $fieldvalue) { 
 
//format Host. 
if($fieldname == "Host") { 
$fieldvalue $hostValue
}
//end if. 
 
//this for/each loop assigns the values 
//to the DOM object for later use as XML. 
$string "<div class='Column dataDetail'>\n"
$xmlString .= $string
$xmlString .= $fieldvalue
$xmlString.="</div>\n"
 
}
//end for/each. 
$xmlString .= "</div>\n"
}
//end if. 
 
 
}//end while. 
 
echo $xmlString
 
function 
filter($fieldValue,$filterValue) { 
 
//check for wildcard * 
//wildcard will allow substring results, like mp* would return mp3 and mp333, etc. 
/* 
if($array_wild = count(explode("*",$filterValue)) > 0) { 
//a wild card was used. 
//return positive if the fieldValue is a substring of $filterValue. 
//now, check to see if there is a substring match. 
if(strpos($fieldValue,$filterValue) != FALSE) { 
//a substring match was found. 
return 1; 
} else { 
return 0; 
}//end if/else. 
}//end if/else. 
*/ 
 
if($filterValue == "ALL") { 
 
return 
1
}
//end if. 
 
if($fieldValue == $filterValue) { 
return 
1
}
//end if. 
 
return 0//nothing matched up. 
 
}//end filter. 
 
 
function chopHost($host) { 
//this function will return the appropriate hostname 
//or IP address without the port specifications. 
 
//strip the port. 
$chopped_fieldvalue explode(":",$host); 
$chopped_fieldvalueNoPort $chopped_fieldvalue[0]; 
 
$chopped_array explode(".",$chopped_fieldvalueNoPort); 
 
//now determine what to return. 
if(count($chopped_array) == 4) { 
//this is an IP address. (red-man specific hack.) 
return($chopped_fieldvalueNoPort); 
} else { 
//return the first host name. 
return($chopped_array[0]); //return first element in explode list. 
}//end if/else. 
 
}//end chopHost. 
 
 
?>