PDA

View Full Version : PHP - space


alexillsley
10th February 2007, 20:18
How can I get how much space a site has left in php? Is it in the sql database?
Thanks,
Alex

till
10th February 2007, 20:35
Every site has its own group. You can either use the repquota command for the group or you use the du command on the website directory.

alexillsley
10th February 2007, 21:33
Thanks till,

I made a function to get how big a site is

<?php
echo site_space("test.com");


function site_space($site) {
$site=str_replace("..","",$site);
return shell_exec("du -s /srv/www/".$site."/");
}
?>


Just need to get the users total space and subtract that off it

alexillsley
10th February 2007, 22:40
Why wont the following php code return the users total allowed space??
<?php
echo total_space("***","***");

function total_space($host,$domain) {
mysql_connect("localhost","***","*****");
mysql_selectdb("ispconfig_db");
$sql = 'SELECT `web_traffic` FROM `isp_isp_web` WHERE `web_domain`=\''.$domain.'\' and `web_host`=\''.$host.'\'';
return mysql_query($sql);
mysql_close();
}
?>

alexillsley
10th February 2007, 22:53
FIXED:)
Thanks,
Alex