TreeSize for PHP-Webspace © RTOL.de

Gehe nach: Tools

Download: treesize.zip (lizenzfrei) 10.01.2022

001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
018:
019:
020:
021:
022:
023:
024:
025:
026:
027:
028:
029:
030:
031:
032:
033:
034:
035:
036:
037:
038:
039:
040:
041:
042:
043:
044:
045:
046:
047:
048:
049:
050:
051:
052:
053:
054:
055:
056:
057:
058:
059:
060:
061:
062:
063:
064:
065:
066:
067:
068:
069:
070:
071:
072:
073:
074:
075:
076:
077:
078:
079:
080:
081:
082:
083:
084:
085:
086:
087:
088:
089:
090:
091:
092:
093:
094:
095:
096:
097:
098:
099:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
<?php 
ini_set
('max_execution_time'900);
$Seite 'TreeSize for PHP-Webspace'
?>
<!doctype html>
<html lang="de-DE">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $Seite?></title>

<style type="text/css">
@import url("Ubuntu.css");
html {font-size:100.001%;}
body {font-size:80%; background-color:white;}
h1 {font-size:130%;}
h2 {font-size:110%;}
small {font-size:80%;}
table {font-size:100%; border-collapse: collapse; margin: 0.5em 0;}
td,th {text-align:left; white-space: nowrap; padding: 0 1em; border: 0px solid #ddd;}
td.zahl {text-align:right; white-space: nowrap;}
td.fett {font-weight: bold;}
a, a:link, a:visited {COLOR: rgb(0,0,138);}
a:hover {COLOR: rgb(0,0,238); text-decoration: none;}
.silver {color:silver;}
.silver a, .silver a:link, .silver a:visited {COLOR: rgb(90,90,138);}
.silver a:hover {COLOR: rgb(0,0,238); text-decoration: none;}
</style>

</head>
<body>
<?php
if(isset($_GET['directory']) AND $_GET['directory'] > '') {$directory $_SERVER['DOCUMENT_ROOT'].$_GET['directory'];} 
else {
$directory $_SERVER['DOCUMENT_ROOT'];}
function 
dirsize($path)
{
    
$s 0;
    
$result[$path] = 0;
    
$handle = @opendir($path);
    if (
$handle)
    {
        while (
false !== ($file readdir($handle)))
        {
            if (
$file != "." && $file != "..")
            {
                
$name $path "/" $file;
                if (
is_dir($name))
                {
                    
$ar dirsize($name);
                    while (list(
$key$value) = each ($ar)) {$s++; $result[$key] = $value;}
                }
                else {
$result[$path] += filesize($name);}
            }
        }
        
closedir($handle);
    }
    return 
$result;
}
$data dirsize($directory);
$data1 $data;

while (list(
$key$value) = each ($data))
{
    if (!
preg_match("'\/'",str_replace($directory.'/','',$key))) 
    {
        
$verzeichnis[str_replace($directory.'/','',$key)] = $value;
        
$dir1 str_replace($directory.'/','',$key);
        while (list(
$key1$value1) = each ($data1))
        {
            
$key2 str_replace($directory.'/','',$key1);
            
$subdir preg_split('/\//',$key2);
            if (
preg_match("'\/'",str_replace($directory.'/','',$key1)) AND $dir1 == $subdir[0])
            {
                
$verzeichnis[$subdir[0]] += $value1;
            }
        }
        
reset($data1);
    }
}
@
reset($data);
@
arsort($verzeichnis);
@
reset($verzeichnis);
$handle1 = @opendir($directory);
if (
$handle1)
{
    while (
false !== ($file readdir($handle1)))
    {
        if (
$file != "." && $file != "..")
        {
            
$name $directory "/" $file;
            if (!
is_dir($name)) {$Dateien[$file] = filesize($name);}
        }
    }
    
closedir($handle1);
}
arsort($Dateien);
reset($Dateien);
?>
<div class="silver">
<h1 id="oben"><?php echo $Seite?><small> &copy; <a href="http://rtol.de/tools/treesize/" target="_blank">RTOL.de</a></small></h1>
<h2><?php echo str_replace('//','/',$directory); ?></h2>
</div>
<?php 
if(isset($_GET['directory']) AND !empty($_GET['directory'])) {
    
$vordir $_GET['directory'];
    
$Verzeichnis_GET explode('/',$vordir);
    
$Verzeichnis_GET_ende end($Verzeichnis_GET);
    
$Verzeichnis_GET_ende '\/'.$Verzeichnis_GET_ende;
    
$vor_dir preg_replace('/'.$Verzeichnis_GET_ende.'/','',$vordir);
//    $vordir = preg_split('/\//', $_GET['directory']);
//    $vordir_array = rsort($vordir);
//    $vor_dir = $vordir[1];
?>
<?php 
if(isset($vor_dir) AND !empty(§vor_dir) ) {
//if(isset($vor_dir) AND !empty(§vor_dir) AND ctype_print($vor_dir)) {
//if(isset($vor_dir) AND !empty(§vor_dir) AND preg_match([:print:],$vor_dir)) { 
?>
<a href="<?php print $_SERVER['PHP_SELF'].'?directory='.$vor_dir?>">Zurück</a>
<?php ?>
<?php 
/* ?>
 - <a href="javascript:history.back()">Zurück</a>
<?php */ 
?>
<?php 
} else { ?>
<?php 
$SumDirs =0?>
<table>
    <tr>
        <th>Bytes</th><th>kB</th><th>MB</th><th>GB</th><th>Unterordner</th>
    </tr>
<?php while (list($key$value) = @each ($verzeichnis)) {$Summe += $value$SumDirs ++; ?>
<?php
$dir_size_kB 
$value 1024;
$dir_size_MB $dir_size_kB 1024;
$dir_size_GB $dir_size_MB 1024;
?>
    <tr>
        <td class="zahl"><?php echo number_format($value0",""."); ?></td>
<?php if (intval($dir_size_kB) > 0) { ?>        <td class="zahl"><?php echo number_format($dir_size_kB0",""."); ?></td>
<?php } else { ?>        <td class="zahl"></td><?php ?>
<?php 
if (intval($dir_size_MB) > 0) { ?>        <td class="zahl"><?php echo number_format($dir_size_MB0",""."); ?></td>
<?php } else { ?>        <td class="zahl"></td><?php ?>
<?php 
if (intval($dir_size_GB) > 0) { ?>        <td class="zahl"><?php echo number_format($dir_size_GB3",""."); ?></td>
<?php } else { ?>        <td class="zahl"></td><?php ?>
        <td><a href="<?php echo $_SERVER['PHP_SELF']; ?>?directory=<?php echo $_GET['directory']; ?>/<?php echo str_replace($_SERVER['DOCUMENT_ROOT'].'/','',$key); ?>">
        <?php echo str_replace($directory,'',$key); ?></a></td>
    </tr>
<?php $SumFiles =0?>
</table>
<table>
<?php while (list($key$value) = @each ($Dateien)) {$Summe1 += $value$SumFiles ++; ?>
    <tr>
        <td class="zahl"><?php echo number_format($value0",""."); ?></td>
        <td><?php echo $key?></td>
        <td><?php echo date("d.m.Y"filemtime($directory.'/'.$key)); ?></td>
    </tr>
<?php ?>
</table>
<?php
$SumDirs_Bytes 
intval($Summe) + intval($Summe1);
$SumDirs_kB $SumDirs_Bytes 1024;
$SumDirs_MB $SumDirs_kB 1024;
$SumDirs_GB $SumDirs_MB 1024;
//$SumDirs_MB = $dir_size_kB / 1024;
//$SumDirs_GB = $dir_size_MB / 1024;
?>
<p>Summe - <?php echo $SumFiles?> Dateien: 
<?php echo number_format($Summe1 10243",""."); ?> kB<br>
Summe - <?php echo $SumDirs?> Ordner: 
<table>
    <tr>
        <th>Bytes</th><th>kB</th><th>MB</th><th>GB</th>
    </tr>
    <tr>
        <td class="zahl fett"><?php echo number_format($SumDirs_Bytes0",""."); ?></td>
<?php if (intval($SumDirs_kB) > 0) { ?>        <td class="zahl fett"><?php echo number_format($SumDirs_kB2",""."); ?></td>
<?php } else { ?>        <td></td><?php ?>
<?php 
if (intval($SumDirs_MB) > 0) { ?>        <td class="zahl fett"><?php echo number_format($SumDirs_MB2",""."); ?></td>
<?php } else { ?>        <td></td><?php ?>
<?php 
if (intval($SumDirs_GB) > 0) { ?>        <td class="zahl fett"><?php echo number_format($SumDirs_GB2",""."); ?></td>
<?php } else { ?>        <td></td><?php ?>
    </tr>
</table>
<?php /* ?>
<hr>
<?php 
$Sum_Dirs = 9016084596;
$SumDirs_kB = intval($Sum_Dirs) / 1024;
$SumDirs_MB = $SumDirs_kB / 1024;
$SumDirs_GB = $SumDirs_MB / 1024;
?>
<table>
    <tr>
        <th>Bytes</th><th>kB</th><th>MB</th><th>GB</th>
    </tr>
    <tr>
        <td class="zahl fett"><?php echo number_format($Sum_Dirs, 0, ",", "."); ?></td>
<?php if (intval($SumDirs_kB) > 0) { ?>        <td class="zahl fett"><?php echo number_format($SumDirs_kB, 3, ",", "."); ?></td>
<?php } else { ?>        <td></td><?php } ?>
<?php if (intval($SumDirs_MB) > 0) { ?>        <td class="zahl fett"><?php echo number_format($SumDirs_MB, 3, ",", "."); ?></td>
<?php } else { ?>        <td></td><?php } ?>
<?php if (intval($SumDirs_GB) > 0) { ?>        <td class="zahl fett"><?php echo number_format($SumDirs_GB, 3, ",", "."); ?></td>
<?php } else { ?>        <td></td><?php } ?>
    </tr>
</table>
<?php */ 
?>
<?php
if(isset($vordir) AND !empty(§vordir)) {print '<hr>vordir: '; print ($vordir);}
if(isset(
$vor_dir) AND !empty(§vor_dir)) {print '<hr>vor_dir: 'print_r ($vor_dir);}
if(isset(
$Verzeichnis_GET) AND !empty(§Verzeichnis_GET)) {print '<hr>Verzeichnis_GET: 'print_r ($Verzeichnis_GET);}
if(isset(
$Verzeichnis_GET_ende) AND !empty(§Verzeichnis_GET_ende)) {print '<hr>Verzeichnis_GET_ende: 'print_r ($Verzeichnis_GET_ende);}
?>
<p></p>
</body>
</html>