<?php
function server_online(){
	$verbinden = @fsockopen ("www.jesite.be", 80, $errno, $errstr, 10);
		if ($verbinden){
			return TRUE;
		}
		else{
			return FALSE;
		}
}

function server_antwoord(){ 
	$aantal = 20; 
		for ($i=0;$i<=$aantal;$i++){ 
			$ping1 = substr(microtime(),11,9) + substr(microtime(),0,10); 
			$sock = @fsockopen("www.jesite.be", 80, $errno, $errstr, 10); 
 			$ping2 = substr(microtime(),11,9) + substr(microtime(),0,10); 
			
			$ping = $ping + round(($ping2 - $ping1) * 1000); 
			@fclose($sock); 
		} 
		$ping = ($ping/$aantal) . " ms"; 
	return $ping; 
} 


function mysql_online_1(){
	$verbinden = @fsockopen ("www.jesite.be", 3306, $errno, $errstr, 10);
		if ($verbinden){
			return TRUE;
		}
		else{
			return FALSE;
		}
}

function mysql_online_2(){
	if( (!@mysql_connect ('localhost','****','****')) || (!@mysql_select_db ('online')) ){
		return FALSE;
	}
	else{
		return TRUE;
	}
}

function mysql_online_3(){
	if( (!@mysql_connect ('localhost','****','****')) || (!@mysql_select_db ('online')) ){
		return FALSE;
	}
	else{
		return mysql_ping($sql);
	}
}

function mysql_queries(){
	if( (!@mysql_connect ('localhost','****','****')) || (!@mysql_select_db ('online')) ){
		return FALSE;
	}
	else{
		$aantal = explode('  ', mysql_stat($sql));
		$aantal = explode(': ',$aantal[7]);
		echo $aantal[1] . " queries per seconde";
	}
}

function mysql_antwoord(){ 
	$aantal = 20; 
		for ($i=0;$i<=$aantal;$i++){ 
			$ping1 = substr(microtime(),11,9) + substr(microtime(),0,10); 
			$sock = @fsockopen("www.jesite.be", 3306, $errno, $errstr, 10); 
 			$ping2 = substr(microtime(),11,9) + substr(microtime(),0,10); 
			
			$ping = $ping + round(($ping2 - $ping1) * 1000); 
			@fclose($sock); 
		} 
		$ping = ($ping/$aantal) . " ms"; 
	return $ping; 
}

function mysql_grootte(){
	$tabellen = mysql_list_tables("JE DB NAAM"); 
	$grootte = 0;
		while (list($tabelnaam) = mysql_fetch_array($tabellen)) { 
			$sql = mysql_query("SHOW TABLE STATUS LIKE '" . $tabelnaam . "'"); 
			$rij = mysql_fetch_assoc($sql); 
 
    		$grootte = $grootte + $rij['Data_length'];
    	}
    $grootte = round($grootte / (1024 * 1024), 2) . " mB";
 
    return $grootte;
}
?> 