PHP-Einfach.de PHP lernen leicht gemacht

Navigation
» Startseite
» Newsübersicht
» Kontakt
» Impressum

Community
» Forum
» Gästebuch

Tutorial
» PHP Tutorial
» MySQL Tutorial
» PHP
» MySQL
» Codeschnipsel

Downloads
» Einführung
» Scripts
» Command Board

Sonstiges
» md5-Generator
» Generator
» Wissenswertes

PHP lernen


Dieses Projekt wird unterstützt von
Lichteffekte Shop

 
Partner:
PHP Forum
Mathe Nachhilfe
Suchmaschinenoptimierung

Speicherplatz ausgeben

Zurück zur Übersicht

Ermittelt den freien Speicherplatz.

Ich weiß nicht ob das einer braucht!
Das hier ist ein script mitdem man den Speicherplatz in GB und % ausgeben kann:
 PHP 
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
<?php
function getByte($bytes) {
    
$symbol "Bytes";
    if (
$bytes 1024) {
        
$symbol "KiB";
        
$bytes /= 1024;
    }
    if (
$bytes 1024) {
        
$symbol "MiB";
        
$bytes /= 1024;
    }
    if (
$bytes 1024) {
        
$symbol "GiB";
        
$bytes /= 1024;
    }
    
$bytes round($bytes2);
    return 
$bytes.$symbol;
}
function 
getFreespace($path) {
    if (
preg_match("#^(https?|ftps?)://#si"$path)) {
        return 
false;
    }
    
    
$freeBytes disk_free_space($path);
    
$totalBytes disk_total_space($path);
    
$usedBytes $totalBytes $freeBytes;
    
    
$percentFree 100 $totalBytes $freeBytes;
    
$percentUsed 100 $totalBytes $usedBytes;
    
    echo 
"Speichertotal: ".getByte($totalBytes)."<br />";
    echo 
"Belegter Speicher: ".getByte($usedBytes);
    
printf(" (%01.2f%%)"$percentUsed);
    echo 
"<br />";
    echo 
"Freier Speicher: ".getByte($freeBytes);
    
printf(" (%01.2f%%)"$percentFree);
}

//Usage
getFreespace(".");
?>

Viel Spaß damit! ;)

Kommentare

Zurück zur Übersicht

Autor Wernch

News
13.08 - » Spam im Gästebuch
Endlich Schluss mit dem Spam

08.12 - » Clanletter 2.0
Clanletter wurde komplett neu programmiert

01.09 - » Command Board 1.0 - 2.0
Das Command Board 1.0 Beta 2.0 ist erschienen


Mehr

Forum
» Entwickler Forum

» insert nach login

» Tabellenzelle zu groß







© PHP-Einfach.de 2003 - 2012