MANUAL DE PHP

(y algo mas)windsurf pozo izquierdo
Google
search for in the  
ELMARRAJO.COM mysql bulma desarrollo web linux fedora html ayuda

windsurf mercedes camper

disk_free_space

(PHP 4 >= 4.1.0, PHP 5)

disk_free_space -- Devuelve el espacio disponible en el directorio

Descripción

float disk_free_space ( string directorio )

Dada una cadena que contiene un directorio, esta función devolverá el número de bytes disponibles en el sistema de archivos o partición de disco correspondiente.

Ejemplo 1. Ejemplo de disk_free_space()

<?php
// $df contiene el numero de bytes disponibles en "/"
$df = disk_free_space("/");

// En Windows:
disk_free_space("C:");
disk_free_space("D:");
?>

Nota: Esta funcion no funcionara con ficheros remotos ya que el fichero a examinar tiene que estar disponible desde el sistema de ficheros del servidor.

Vea también disk_total_space()



add a note add a note User Contributed Notes
disk_free_space
djneoform at gmail dot com
12-Jul-2006 07:13
List all drives, free space, total space and percentage free.

<?
  
for ($i = 67; $i <= 90; $i++)
   {
      
$drive = chr($i);
       if (
is_dir($drive.':'))
       {
          
$freespace            = disk_free_space($drive.':');
          
$total_space        = disk_total_space($drive.':');
          
$percentage_free    = $freespace ? round($freespace / $total_space, 2) * 100 : 0;
           echo
$drive.': '.to_readble_size($freespace).' / '.to_readble_size($total_space).' ['.$percentage_free.'%]<br />';
       }
   }

   function
to_readble_size($size)
   {
       switch (
true)
       {
           case (
$size > 1000000000000):
              
$size /= 1000000000000;
              
$suffix = 'TB';
               break;
           case (
$size > 1000000000):
              
$size /= 1000000000;
              
$suffix = 'GB';
               break;
           case (
$size > 1000000):
              
$size /= 1000000;
              
$suffix = 'MB';   
               break;
           case (
$size > 1000):
              
$size /= 1000;
              
$suffix = 'KB';
               break;
           default:
              
$suffix = 'B';
       }
       return
round($size, 2).$suffix;
   }
?>
flobee
12-May-2006 12:05
you may check this out working with % of disk usage (log object may comes from pear or just remove the log lines)
, flobee
<?php
// return true on error!
// on false: fine :-)
function check_disk_free_space($path) {
   global
$oLog;
  
// seconds a time-compare will be OK during the process (if it takes longer)
   // (limit the number if you have huge file movements to beware crashes
   // or "disk-full"- errors)
  
$secCmp = 60;
  
// max allowed/free size compare Value
  
$sizeCmp = 92;
  
// windows user get www.cygwin.com
  
$cmd = 'c:/cygwin/bin/df.exe -a '. $path;
  
$now = time();
  
$_v = array();
  
   static
$paths = null;
   static
$sizes = null;
   static
$times = null;
   if (
$paths===null) {
      
$paths = array();
      
$sizes = array();
      
$times = array();
   }

  
   if ((
$i=array_search($path,$paths)) && (($now-$times[$i]) < $secCmp)) {
       if(
$sizes[$i] >= $sizeCmp) {
          
$oLog->log('disc space overflow: '.$sizes[$i].' ('.$sizeCmp.' is max limit!) for path: '.$path, 3);
           return
false;
       } else {
          
$oLog->log('disc space OK: '.$sizes[$i].'% ('.$sizeCmp.' is max limit!) for path: '.$path, 6);
           return
true;
       }
   }

  
$oLog->log('getting free space for: '. $path, 6);

  
  
$result = exec($cmd, $data, $return);
  
$oLog->log('cmd: '. $cmd, 7);
  
   if (
$result) {
      
$r = explode(' ', $data[1]);
       while(list(
$a,$b) = each($r)) {
          
$b = trim($b);
           if (
$b != '') {
              
$_v[] = $b;
           }
       }
      
$oLog->log($_v, 7);
      
      
$size = intval($_v[4]);
      
      
$paths[] = $path;
      
$sizes[] = $size;
      
$times[] = time();
      
       if(
$size >= $sizeCmp) {
          
$oLog->log('disc space overflow: '.$sizes[$i].' ('.$sizeCmp.' is max limit!) for path: '.$path, 3);
           return
false;
       } else {
          
$oLog->log('disc space OK: '.$sizes[$i].' ('.$sizeCmp.' is max limit!) for path: '.$path, 6);
           return
true;
       }
      
      
/*
       echo '$return: ' . $return .'<br><pre>';
       echo  print_r($data);
       echo '</pre>';
       */
  
} else {
    
$oLog->log('error can not get size', 3);
     return
true;
   }
}

check_disk_free_space(getcwd());
?>
chicaboo at punkass dot com
09-May-2006 06:04
Just to let you know, 1 kilobyte = 1024 bytes, so from that perspective the code is alright
Martin Lindhe
24-Feb-2006 08:42
blow, your code is broken. it returns 1 kilobyte as "1024 bytes"

<?
function formatDataSize($bytes) {
  
$units = array('bytes', 'KiB', 'MiB', 'GiB', 'TiB');
   foreach (
$units as $unit) {
       if (
$bytes < 1024) break;
      
$bytes = round($bytes/1024, 1);
   }
   return
$bytes.' '.$unit;
}
?>
blow
04-Jan-2006 03:46
quiet the same

<?
function readable_size($lenght) {
  
$units = array('B', 'kB', 'MB', 'GB', 'TB');
   foreach (
$units as $unit) {
       if(
$lenght>1024) $lenght = round($lenght/1024, 1);
       else break;
   }
   return
$lenght.' '.$unit;
}
?>
Nick H
21-Nov-2005 08:08
This is probably what the previous poster indended to write:

<?php
function readable_size($size) {
   if (
$size < 1024) {
       return
$size . ' B';
   }
  
$units = array("kB", "MiB", "GB", "TB");
   foreach (
$units as $unit) {
      
$size = $size / 1024;
       if (
$size < 1024) {
           break;
       }
   }
   return
$size . ' ' . $unit;
}
?>
ludvig dot ericson at gmail dot com
26-Sep-2005 12:28
On the first note by aidan: it does not work.

On the second note, this is better:
<?
function readable_size($size) {
   if (
$size < 1024) {
       return
$size . ' B';
   }
  
$units = array("kB", "MiB", "GB", "TB");
   foreach (
$units as $unit) {
      
$size = size / 1024;
       if (
$size / 1024 > 1024) {
           break;
   }
   return
$size . ' ' . $unit;
}
?>
mat
19-Aug-2005 03:36
Note that in the previous two examples by Ashraf M Kaabi, calling the function in such a manner as disk_used_space(C) is in error and will give you a warning.  Should be disk_used_space('C'), otherwise it will look for a constant C, fail, and then act as if you had wrote 'C' instead.
Ashraf M Kaabi
01-Mar-2005 08:38
and also you can know the used space , in this
example :
<?
function disk_used_space($drive)
         {
         return
disk_total_space("$drive:") - disk_free_space("$drive:");
         }

echo
disk_used_space(C);
?>
Ashraf M Kaabi
01-Mar-2005 09:55
and also you can get Human Disk Free Space result in GB in This Example :
<?
function dfs_gb($drive)
{
       if(
$drive)
       {
       return
round(diskfreespace("$drive:")/1024/1024/1024,2); //To Get Human Result in GB we divid it By 1024 Byte & 1024 KiloByte & 1024 MegaByte
      
}
}

echo
dfs_gb(D); //(D) is a drive letter
?>
aidan at php dot net
15-Oct-2004 05:49
To make human readable file sizes, see this function:

http://aidan.dotgeek.org/lib/?file=function.size_readable.php

Citas célebres

No se preocupe por sus dificultades en las matemáticas. Las mías son todavía mayores.

Albert Einstein
Físico estadounidense
(1879-1955)
Citas en tu mail
©Contenidos Gratis

Ilusiones Opticas
ilusion_optica_043.jpg
Contenidos Web

Chiste de... Relaciones laborales
Escritor reconocido

- ¿A qué se dedica tu hijo?

- Es escritor, y muy bueno, te aseguro que todo lo que escribe es leído con mucho interés.

- ¿Escribe novelas?

- No, menús de restaurantes.
Chistes en tu mail
©ContenidosGratis

Humor Gráfico
humor_grafico_056.jpg
Contenidos Web

Inicio | Acción | Estrategia | Palabras | Puzzles | Solitarios | Foro Trucos
Cake ManiaCake Mania
Jugadores: 6835
Categoría del juego: Acción
Objetivo del juego: Ayuda a Jill a recuperar la pastelería de su abuela llevando su propia pastelería; consigue clientes y gana dinero.
Rainbow WebRainbow Web
Jugadores: 2199
Categoría del juego: Puzzles
Objetivo del juego: Rompe un pegajoso hechizo y salva un reino de fantasía en Rainbow Web. Tendrás toneladas de diversión mientras juegas a este mágico desafío para la mente.
Mahjongg FortunaMahjongg Fortuna
Jugadores: 12462
Categoría del juego: Solitarios
Objetivo del juego: Velocidad y habilidad mental son las armas más importantes en esta versión de un antiguo juego asiático. Despeja el tablero lo antes posible haciendo clic en las fichas iguales y gánate la fama eterna de la puntuación más alta.
Chainz 2Chainz 2
Jugadores: 6955
Categoría del juego: Puzzles
Objetivo del juego: Entra en el mundo de las combinaciones con Chainz 2: Relinked, emocionante secuela del exitazo del año pasado, Chainz. Gira eslabones y crea combinaciones de 3 ó más.
DeliciousDelicious
Jugadores: 4405
Categoría del juego: Acción
Objetivo del juego: ¿Eres un as de la multitarea? ¿Quieres que tus clientes estén contentos? ¡Pues Delicious es tu juego! Sacia el apetito de los clientes y tenlos contentos; ¡no te arriesgues!
BookwormBookworm
Jugadores: 4568
Categoría del juego: Palabras
Objetivo del juego: Junta las letras para formar palabras. ¡Las palabras más largas valen más puntos!
ZumaZuma
Jugadores: 4976
Categoría del juego: Acción
Objetivo del juego: Controla el ídolo de la rana de piedra de los antiguos Zuma en este intrigante enigma de acción. ¡Dispara bolas para formar conjuntos de tres, pero si dejas que lleguen a la calavera dorada morirás!
Jewel of AtlantisJewel of Atlantis
Jugadores: 3798
Categoría del juego: Puzzles
Objetivo del juego: Descubre la ciudad hundida de la Atlántida y busca valiosos tesoros. Viaja más allá de las profundidades del mar y vive trepidantes aventuras en Jewel of Atlantis.
Jewel QuestJewel Quest
Jugadores: 3727
Categoría del juego: Puzzles
Objetivo del juego: Convierte la arena de la antigua selva en oro tan rápido como puedas juntando grupos de 3 elementos. ¡Los grupos más grandes valen más puntos!
Bejeweled 2Bejeweled 2
Jugadores: 3659
Categoría del juego: Puzzles
Objetivo del juego: Con cuatro modos de juego únicos y fascinantes, nuevas piezas de juego explosivas e imponentes fondos planetarios, Bejeweled 2 es mucho más adictivo que nunca.
Contenidos gratis en tu webSiguiente >>

Fotos divertidas
fotos_increibles_0045.jpg
Contenidos Web
microrobots avion deportes riesgo recetas cocina canaria juegos online gratis moto motociclismo horoscopos naranjas valencianas surf canarias montañismo ciudades turismo postales gratis library Horoscopos Diarios Windsurf Canarias
fregadero microondas placa electrica bañopreparar camper pantalla plananevera compresor electricacamper fiat ducato camper baño quimicomampara enrollable bañocamper aire climatizadofurgoneta surf windsurffurgoneta surf windsurftelevisor furgonetas camperfurgonetas camper cama

Sudoku del día
Nivel de dificultad: Fácil



Cómo jugar:
El juego consiste en colocar los números del 1 al nueve de tal forma que no se repita el mismo número en la columna, fila y caja (bloques 3x3 enmarcados).

©Contenidos Gratis | Sudoku en tu mail
Sucedió el...

30 de agosto de 1617

Fallece Santa Rosa de Lima, por la que se celebra el "Día de la Patrona de América".
Efemérides en tu mail
©Contenidos Gratis
windsurf canarias youtube porno canarias baleares valencia madrid fallera mayor campus party alcacer feria valencia fernando alonso loterias dinero inversiones violencia de genero makro empresas cartera soledad tolerancia metro valencia gobierno de españa violencia de genero UIMP navidad