Topic: Checking used diskspace (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=28397" title="Pages that link to Topic: Checking used diskspace (Page 1 of 1)" rel="nofollow" >Topic: Checking used diskspace <span class="small">(Page 1 of 1)</span>\

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



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu