<?PHP
function server_info($request,$id) {
$conn = _MYSQL_CONNECT;
$sql = "SELECT * FROM servers WHERE id = '".$id."' LIMIT 1";
$result = mysql_query($sql,$conn);
$data = mysql_fetch_array($result);
if($request == "id") {
$value = $data['id'];
}
if($request == "conf") {
$value = $data['conf'];
}
if($request == "name") {
$value = $data['name'];
}
if($request == "pid") {
$value = $data['pid'];
}
if($request == "status") {
$value = $data['status'];
}
if(isset($value)) {
return $value;
}
else
{
return FALSE;
}
}
function searchdir ( $path , $maxdepth = -1 , $mode = "FULL" , $d = 0 )
{
if ( substr ( $path , strlen ( $path ) - 1 ) != '/' ) { $path .= '/' ; }
$dirlist = array () ;
if ( $mode != "FILES" ) { $dirlist[] = $path ; }
if ( $handle = opendir ( $path ) )
{
while ( false !== ( $file = readdir ( $handle ) ) )
{
if ( $file != '.' && $file != '..' )
{
$file = $path . $file ;
if ( ! is_dir ( $file ) ) { if ( $mode != "DIRS" ) { $dirlist[] = $file ; } }
elseif ( $d >=0 && ($d < $maxdepth || $maxdepth < 0) )
{
$result = searchdir ( $file . '/' , $maxdepth , $mode , $d + 1 ) ;
$dirlist = array_merge ( $dirlist , $result ) ;
}
}
}
closedir ( $handle ) ;
}
if ( $d == 0 ) { natcasesort ( $dirlist ) ; }
return ( $dirlist ) ;
}
function conf_port($conf) {
$wholefile = file($conf);
$variable = "PortBase=";
$length = strlen($variable);
foreach($wholefile as $line) {
if(substr($line,0,$length) == $variable) {
$value = substr($line,$length);
}
}
return $value;
}
function conf_ip($conf) {
$wholefile = file($conf);
$variable = "DestIP=";
$length = strlen($variable);
foreach($wholefile as $line) {
if(substr($line,0,$length) == $variable) {
$value = substr($line,$length);
}
if(substr($line,1,$length) == $variable) {
$value = gethostbyname($_SERVER['HTTP_HOST']);
}
}
return $value;
}
//////////////////////////////////////////////////////
// MUST CONTAIN NO WHITE SPACE AFTER CLOSING TAG!!! //
//////////////////////////////////////////////////////
?>