ID: 22499 Updated by: [EMAIL PROTECTED] Reported By: itamarc at rogers dot com -Status: Open +Status: Bogus Bug Type: Directory function related Operating System: windows xp PHP Version: 4.3.1 New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Thank you for your interest in PHP. Next time: make the script shorter, please! We don't need the size stuff. IIC - when the first entry is a directory it will always fail, because you only change dirs after you read a file. Make the test: if(!is_dir("$dir/$entry")) and you'll see it'll always work. Previous Comments: ------------------------------------------------------------------------ [2003-03-02 16:21:37] itamarc at rogers dot com 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(); ?> ------------------------------------------------------------------------ [2003-03-02 12:25:43] [EMAIL PROTECTED] 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"; } ?> ------------------------------------------------------------------------ [2003-03-02 11:50:18] itamarc at rogers dot com the is_dir is supposed to come back true if reading a directory and false if not. it doesn't. it always comes back false. if used as (not)!is_dir then it works right most of the time but still give the wrong answer for some directories. ------------------------------------------------------------------------ [2003-03-02 05:00:20] [EMAIL PROTECTED] Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.php.net/how-to-report.php If you can provide more information, feel free to add it to this bug and change the status back to "Open". Thank you for your interest in PHP. Let's see an example script, along with a directory listing. Keep it short please. ------------------------------------------------------------------------ [2003-03-01 18:00:30] 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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22499&edit=1
