note 45775 added to function.readdir
| From: | barron dot james at gmail dot com | Date: | Sat, 18 Sep 2004 03:45:13 +0000 |
| Subject: | note 45775 added to function.readdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-76901@lists.php.net to get a copy of this message | ||
I made this for my control panel. It will list all directories and tell how much space is being
used.
<?
if ( $_POST ) {
$base = "/home/santium/public_html/"; /* Change this */
$dir = $_POST['dir'];
$place = $base.$dir;
$d =
cd $place && du -sh;
echo "Disk space used in ".$place.":";
echo str_replace(" .", "",$d);
echo "<p><p>";
}
else {
echo "<form action=\"t.php\" method=\"post\">\n";
$g = "/home/santium/public_html"; /* Change this */
echo "<select name=\"dir\">\n";
if ($handle = opendir($g)) {
while (false !== ($file = readdir($handle))) {
$completepath="$g/$file";
if ($file != "." && $file != "..") {
if (is_dir($completepath)) {
echo "<option value=\"$file\">$file\n";
}
}
}
closedir($handle);
}
echo "</select><br>\n";
echo "<input type=\"submit\" value=\"Submit\">";
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.readdir.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45775
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45775&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45775&report=yes
Search -- http://master.php.net/manage/user-notes.php