Closed Thread Icon

Topic awaiting preservation: Checking used diskspace Pages that link to <a href="https://ozoneasylum.com/backlink?for=28397" title="Pages that link to Topic awaiting preservation: Checking used diskspace" rel="nofollow" >Topic awaiting preservation: Checking used diskspace\

 
Author Thread
H][RO
Paranoid (IV) Inmate

From: Australia
Insane since: Oct 2002

posted 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.

Now i think probably mostly due to the regular expression checking so many files, this process is very slow.


Anyone know if there is a faster way to do this?

The code is something like this:

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 />';
            }                                        
        }

« BackwardsOnwards »

Show Forum Drop Down Menu