www.webdeveloper.com
Results 1 to 4 of 4

Thread: View server space

  1. #1
    Join Date
    Jun 2009
    Posts
    20

    View server space

    Hello,

    My web hosting company has suggested that I write a script to see how much space the files on my web hosting account take up...

    Anyone have any links/suggestions for making this happen??

    Thanks,

    Sam

  2. #2
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    what OS is the server?

  3. #3
    Join Date
    Jun 2009
    Posts
    20
    Quote Originally Posted by chazzy View Post
    what OS is the server?
    It's a shared Linux server.

  4. #4
    Join Date
    Jun 2009
    Posts
    98
    I would think they had shell scripts to watch the disk space or use Perl.
    You dont say what server sides they have and you want to do this with a web based language?

    If you have PHP this will get you in the right direction:

    Code:
    <?
    function directorySpace( $dir ) 
    { 
        if( !$dir or !is_dir( $dir ) ) 
        { 
            return 0; 
        } 
    
        $ret = 0; 
        $sub = opendir( $dir ); 
        while( $file = readdir( $sub ) ) 
        { 
            if( is_dir( $dir . '/' . $file ) && $file !== ".." && $file !== "." ) 
            { 
                $ret += directorySpace( $dir . '/' . $file ); 
                unset( $file ); 
            } 
            elseif( !is_dir( $dir . '/' . $file ) ) 
            { 
                $stats = stat( $dir . '/' . $file ); 
                $ret += $stats['size']; 
                unset( $file ); 
            } 
        } 
        closedir( $sub ); 
        unset( $sub ); 
        return $ret; 
    } 
    ?>
    Last edited by JavaServlet; 06-20-2009 at 11:33 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles