Ver Mensaje Individual
  #8 (permalink)  
Antiguo 09/09/2005, 02:17
Avatar de DINASEN
DINASEN
 
Fecha de Ingreso: marzo-2003
Mensajes: 997
Antigüedad: 21 años, 1 mes
Puntos: 1
le he adaptado un trozo de codigo que vi en php.net asi ahora ademas calcula el tamaño menor del mega y mayor , pone la unidad que le corresponda

Código PHP:
<?

//        http://localhost/Space_Used.php


//-------------------------------------------------------------------------------------------------

    
error_reportingE_ALL );
    @
set_time_limit);

//-------------------------------------------------------------------------------------------------
//  funciones

    
function SpaceUsed($dir) {

        global    
$nivel$total;

        for( 
$i=0$i<$nivel$i++ )    echo( "    " );
        
$folder substr$dir0strrpos($dir'/') );
        
$folder substr$folderstrrpos($folder'/' ) + 1);
        echo( 
$folder "<br>" );

        
$nivel++;

        if (
is_dir($dir)) {
            if (
$dh opendir($dir)) {
                while ((
$file readdir($dh)) !== false) {
                    if (
is_dir($dir.$file) && $file != '.' && $file != '..') {
                        
spaceUsed$dir.$file.'/' );
                    }
                    else {
                        if( 
$file != '.' && $file != '..' ) {
                            
$total += filesize($dir.$file);
                            for( 
$i=0$i<$nivel$i++ )    echo( "    " );
                            echo( 
$file "<br>" );
                        }
                    }
                }
                
closedir($dh);
                
$nivel--;
            }
        }
    }

//-------------------------------------------------------------------------------------------------
//  main


    
$path "./ordena/";

    
$total 0;
    
$nivel 0;
    echo( 
"<br><pre>" );
    
SpaceUsed$path );
    if( 
$total != ) {
         
$unidad "bytes";
         if (
$total 1024) {
             
$total = ($total 1024);
               
$unidad "kB"; }// kilobyte
          
if ($total 1024) {
              
$total = ($total 1024);
              
$unidad "MB"; }// megabyte
           
if ($total 1024) {
               
$total = ($total 1024);
               
$unidad "GB"; }// gigabyte
           
if ($total 1024) {
               
$total = ($total 1024);
            
$unidad "TB"; }// terabyte
        
if ($total 1024) {
               
$total = ($total 1024);
            
$unidad "PB"; }// petabyte
        
if ($total 1024) {
               
$total = ($total 1024);
            
$unidad "EB"; }// exabyte
        
if ($total 1024) {
               
$total = ($total 1024);
            
$unidad "ZB"; }   // zettabyte    
      
if ($total 1024) {
               
$total = ($total 1024);
            
$unidad "YB"; }// yottabyte
   
$total round($total0);
   echo 
"<br><br> Tamaño total : ".$total." ".$unidad."<br>";
    }
    echo( 
"</pre><br>" );



//-------------------------------------------------------------------------------------------------
//  end
?>
Un Saludo

Última edición por DINASEN; 09/09/2005 a las 02:40