Location: PHPKode > projects > web-cp - Web Hosting Control Panel > webcp/server/cron/quota.inc.phps
<?	/*
	// File:	quota.php
	// Purpose:	Scan HD, Users quotas, Domain Transfer
	// Creation:	2002-02-21
	// Author:	Felix <hide@address.com>
	*/
   
// Start User HD Quota check
$dbp = mysql_query("SELECT username FROM users WHERE type != 'demo'");
while ($data = mysql_fetch_array($dbp)) {
	
	unset($mysqlquota);
	unset($pgsqlquota);
	unset($quota);
	unset($quotatotal);
	
	exec($cfg['prog']['quota']." -u ".$data['username'], $quota);
	
	if (!$quota[3]) $num = 2;
	else $num = 3;
	
	$quota = explode(" ",trim(ereg_replace("[[:space:]]+", " ", $quota[$num])));
	/*
	if (is_dir($dbpath."mysql/".$data['username'])) { 
	exec("/usr/bin/du -s ".$dbpath."mysql/".$data['username'] ,$mysqlquota);
	$mysqlquota = explode(" ",trim(eregi_replace("[[:space:]]+", " ", $mysqlquota[0])));
	}
	if (is_dir($dbpath."pgsql/".$data['username'])) { 
	exec("/usr/bin/du -s ".$dbpath."pgsql/".$data['username'] ,$pgsqlquota);
	$pgsqlquota = explode(" ",trim(eregi_replace("[[:space:]]+", " ", $pgsqlquota[0])));
	}
	
	
	$quotatotal = $quota[1] + $mysqlquota[0] + $pgsqlquota[0];
	*/
	mysql_query("UPDATE users SET hd_used='".round($quota[1] / 1024)."' WHERE username='".$data['username']."'");
}

// Start Group(Domain) HD Quota check
$dbp = mysql_query("SELECT id,owner FROM domains WHERE type='domain'");
while ($data = mysql_fetch_array($dbp)) {
	
	unset($quota);

	if (strlen($data['owner']) < 10 ) {
	   	exec("/usr/bin/quota -g g".$data['id'] ,$quota);
	   
	   	if (!$quota[3]) $num = 2;
	   	else $num = 3;
	   	$quota = explode(" ",trim(eregi_replace("[[:space:]]+", " ", $quota[$num])));
	   	mysql_query("UPDATE domains SET hd_used='".round($quota[1] / 1024)."' WHERE id='".$data['id']."'");
	}
}


// Start Domain Transfer Check (using mod_watch)
unset($data);
$dbp = mysql_query("SELECT id,ip,host,domain,transfer_stat,transfer_used FROM domains");
while ($data = mysql_fetch_array($dbp)) {
	
	// Is the domain really hosted on that (supposedly) correct ip?
	$trueip = gethostbyname($data['host'].".".$data['domain']);
	if ($trueip == $data['ip'] OR $trueip == '127.0.0.1') {
		unset($transfer);
		$transfer = @explode(" ",@trim(@implode("",@file("http://".$data['host'].".".$data['domain']."/watch-info"))));
		if (is_array($transfer)) {
			if ($data['transfer_stat'] <= $transfer[3]) $webtransfer = $transfer[3] - $data['transfer_stat'];
			else $webtransfer = $transfer[3];
			mysql_query("UPDATE domains SET transfer_used = ".($data['transfer_used'] + round($webtransfer / 1024 / 1024 / 1024,5)).", transfer_stat = ".$transfer[3]." WHERE id='".$data['id']."'");
		}
	}
}

?>
Return current item: web-cp - Web Hosting Control Panel