|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-03-01 18:00 UTC] itamarc at rogers dot com
is_dir doesn't work unless I use it as !is_dir and even then a few directories are still read as files. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 14:00:01 2025 UTC |
Yes, you said that already. Let's see the script you used which exposes this bug. For example - this works for me, using 4.3.1 on Windows 2k with apache: <?php header('Content-Type: text/plain'); $dir = opendir('.'); while($entry = readdir($dir)) { if(is_dir($entry)) echo "$entry is a dir\n"; else echo "$entry is NOT a dir\n"; } ?>let's see. using apache2 on win xp pro <? if (!empty($_GET['directory'])) { $temp = $_GET['directory']; $d = dir("d:/inetpub/wwwroot/$temp"); $old = $_GET['old']; } else { $d = dir("d:/inetpub/wwwroot"); $old = ""; } echo "<h3>Path: ".$d->path."</h3><br>\n"; $dir = $d->path; $totaldirsize = 0; $mark = 1; print "<table width=\"100%\"><tr><td width=\"10%\"><u>File Name:</u></td><td><u>File Size:</u></td></tr>\n"; print "<tr><td colspan=2><hr></td></tr>\n"; while (false !== ($entry = $d->read())) { if (!is_dir($entry)) { chdir($dir); $file = filesize($entry); $totaldirsize = $totaldirsize + $file; if ($file > 1023) { $file = $file / 1024; $mark++; if ($file > 1023) { $file = $file / 1024; $mark++; if ($file > 1023) { $file = $file / 1024; $mark++; } } } $file = round($file, 3); print "<tr><td><a href=\"$dir/$entry\">$entry</a></td>\n"; if ($mark == 1) print "<td>$file Bytes</td></tr>\n"; elseif ($mark == 2) print "<td>$file KBytes</td></tr>\n"; elseif ($mark == 3) print "<td>$file MBytes</td></tr>\n"; elseif ($mark == 4) print "<td>$file GBytes</td></tr>\n"; else print "<td>\"$file\" \"$mark\" UNKNOWN FILE SIZE</td></tr>\n"; $mark = 1; } else { if ($entry == ".") { print "<tr><td><a href=\"siteadmin.php?directory=\">$entry</a></td><td>directory</td></tr>\n"; } elseif ($entry == "..") { print "<tr><td><a href=\"siteadmin.php?directory=$old\">$entry</a></td><td>directory</td></tr>\n"; } else { $direc = "$dir/$entry"; for ($i = 19; $i <= (strlen($direc) - 1); $i++) { $direct = $direc{$i}; $dire = "$dire$direct"; } for ($i = 19; $i <= (strlen($dir) - 1); $i++) { $temp = $dir{$i}; $dirtemp = "$dirtemp$temp"; } $old = $dirtemp; print "<tr><td><a href=\"siteadmin.php?directory=$dire&old=$old\">$entry</a></td><td>directory</td></tr>\n"; $dire = ""; } } } print "</table><hr><br>\n"; if ($totaldirsize > 1023) { $totaldirsize = $totaldirsize / 1024; $mark++; if ($totaldirsize > 1023) { $totaldirsize = $totaldirsize / 1024; $mark++; if ($totaldirsize > 1023) { $totaldirsize = $totaldirsize / 1024; $mark++; } } } $totaldirsize = round($totaldirsize, 3); if ($mark == 1) print "<td>$totaldirsize Bytes</td></tr>\n"; elseif ($mark == 2) print "$totaldirsize KBytes Total\n"; elseif ($mark == 3) print "$totaldirsize MBytes Total\n"; elseif ($mark == 4) print "$totaldirsize GBytes Total\n"; else print "\"$totaldirsize\" \"$mark\" UNKNOWN TOTAL FILE SIZE\n"; $d->close(); ?>