<?php
$dirName
=
"phpMyAdmin"
;
$dir
=opendir(
$dirName
);
while
(
$fileName
=readdir(
$dir
)){
$file
=
$dirName
.
"/"
.
$fileName
;
if
(
$fileName
!=
"."
&&
$fileName
!=
".."
){
if
(
is_dir
(
$file
)){
echo
"<font color='red'>"
.
$fileName
.
"==="
.
date
(
"Y-m-d H:i:s"
,
filectime
(
$file
)).
"=="
.
filetype
(
$file
).
"=="
.toSize(dirSize(
$file
)).
"</font><br/>"
;
}
else
{
echo
"<font color='green'>"
.
$fileName
.
"====="
.
date
(
"Y-m-d H:i:s"
,
filectime
(
$file
)).
"===="
.
filetype
(
$file
).
"===="
.toSize(
filesize
(
$file
)).
"</font><br/>"
;
}
}
}
closedir
(
$dir
);
function
toSize(
$size
){
$dw
;
if
(
$size
>pow(2,30)){
$dw
=
"GB"
;
$size
=
round
(
$size
/pow(2,30),2);
}
else
if
(
$size
>pow(2,20)){
$dw
=
"MB"
;
$size
=
round
(
$size
/pow(2,20),2);
}
else
if
(
$size
>pow(2,10)){
$dw
=
"KB"
;
$size
=
round
(
$size
/pow(2,10),2);
}
else
{
$dw
=
"bytes"
;
}
return
$size
.
$dw
;
}
function
dirSize(
$dirName
){
$dirsize
=0;
$dir
=opendir(
$dirName
);
while
(
$fileName
=readdir(
$dir
)){
$file
=
$dirName
.
"/"
.
$fileName
;
if
(
$fileName
!=
"."
&&
$fileName
!=
".."
){
if
(
is_dir
(
$file
)){
$dirsize
+=dirSize(
$file
);
}
else
{
$dirsize
+=
filesize
(
$file
);
}
}
}
closedir
(
$dir
);
return
$dirsize
;
}
?>