#22499 [Fbk->NoF]: is_dir doesn't always work

From: Date: Fri, 09 May 2003 12:30:51 +0000
Subject: #22499 [Fbk->NoF]: is_dir doesn't always work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-39369@lists.php.net to get a copy of this message
ID: 22499 Updated by: sniper@php.net Reported By: itamarc at rogers dot com -Status: Feedback +Status: No Feedback Bug Type: Directory function related Operating System: windows xp PHP Version: 4.3.1 New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Open". Thank you. Previous Comments: ------------------------------------------------------------------------ [2003-05-01 19:45:49] sniper@php.net Please try using this CVS snapshot: http://snaps.php.net/php4-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-STABLE-latest.zip ------------------------------------------------------------------------ [2003-04-18 16:00:26] itamarc at rogers dot com new info has been found. I'm reopening this bug from bogus. ------------------------------------------------------------------------ [2003-04-17 16:47:35] mark_ford_uk at yahoo dot co dot uk (currently using php4.2.2) I too have discovered directories are not always recognised,. However, I have found they are correctly recognised provided I ensure the path has a '/' on the end. This bug appears to be widely reported and to my knowledge has not been fixed even in recent versions. Can someone please investigate? Thanks. ------------------------------------------------------------------------ [2003-03-02 19:05:36] msopacua@php.net 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. ------------------------------------------------------------------------ [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(); ?> ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/22499 -- Edit this bug report at http://bugs.php.net/?id=22499&edit=1

« previous php.bugs (#39369) next »