![]() Topic awaiting preservation: Checking used diskspace (Page 1 of 1) |
|
|---|---|
|
Paranoid (IV) Inmate From: Australia |
posted 09-06-2006 04:01
Currently i am checking the used diskspace on my shared hosting accounts by using a php script which uses php functions such as ftp_rawlist, and then performing regular expressions on each line (file/directory) to extract the diskspace information. code: $rawList = ftp_rawlist ($this->objFtpconn, '-alR '.$dir);
$Totalsize = 0;
$TotalsizeOnDisk = 0;
$blockSize = 512;
$str = '';
foreach ($rawList as $file)
{
if( $file == '' ) continue;
if(ereg("([-dl][rwxstST-]+).* ?([0-9 ]* )?([a-zA-Z0-9]+).* ([a-zA-Z0-9]+).* ([0-9]*) ([a-zA-Z]+[0-9: ]*[0-9])[ ]+(([0-9]{2}:[0-9]{2})|[0-9]{4}) (.+)", $file, $regs))
{
$paramString = $regs[0];
$attributes = $regs[1];
$number = $regs[2]; // file or directory number
$owner = $regs[3];
$group = $regs[4];
$size = $regs[5];
$date = $regs[6];
$time = $regs[7];
$name = $regs[8];
$sizeOnDisk = ceil($size/$blockSize) * $blockSize;
$Totalsize += $size; // add the size even if its a dir
$TotalsizeOnDisk += $sizeOnDisk;
$str .= 'Name: '.$name .' Size: '.$size.' ('.$sizeOnDisk.') <br />';
}
else
{
$str .= ' --------------------------------------------- ';
$str .= $file. '(Not Counted!)<br />';
}
} |