#24611 [Bgs]: is_dir /!is_file won't work quite right.

From: Date: Sat, 19 Jul 2003 04:46:07 +0000
Subject: #24611 [Bgs]: is_dir /!is_file won't work quite right.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-44293@lists.php.net to get a copy of this message
ID: 24611 Updated by: fmk@php.net Reported By: itamarc at rogers dot com Status: Bogus Bug Type: *Directory/Filesystem functions Operating System: Windows XP PHP Version: 4.3.1 New Comment: I guess I should test a bit more before I post :-) This is the code that works. function getDirList($pop, $log) { if (false !== ($directory = dir("$pop"))) { $dir = $directory->path; while (false !== ($entry = $directory->read())) { $path = "$dir/$entry"; if (!is_file($path) && !is_link($path) && file_exists($path)) { if ($entry !== "." && $entry !== "..") { if ($dir == $log) { print "<option value='$entry'>$entry</option>\n"; } else { print "<option value='$dir/$entry'>$dir/$entry</option>\n"; } getDirList($path, $log); } } else { print "<option value='$dir/$entry'>file: $dir/$entry</option>\n"; } } $directory->close(); } } Previous Comments: ------------------------------------------------------------------------ [2003-07-18 23:34:38] fmk@php.net After testing your function on my system, and modifying it a bit I made it work (as I think it should work). With this new function I can list the content of any folder on my XP system. function getDirList($pop, $log) { if (false !== ($directory = dir("$pop"))) { $dir = $directory->path; while (false !== ($entry = $directory->read())) { if (!is_file($dir."/".$entry) && !is_link($entry) && file_exists($entry)) { if ($entry !== "." && $entry !== "..") { if ($dir == $log) { print "<option value='$entry'>$entry</option>\n"; getDirList($entry, $log); } else { print "<option value='$dir/$entry'>$dir/$entry</option>\n"; getDirList($entry, $log); } } } else { print "<option value='$dir/$entry'>file: $dir/$entry</option>\n"; } } $directory->close(); } } ------------------------------------------------------------------------ [2003-07-13 23:09:22] itamarc at rogers dot com function getDirList($pop, $log) { $path = ""; if (false !== ($directory = dir("$pop"))) { $dir = $directory->path; print "$dir"; chdir($dir); while (false !== ($entry = $directory->read())) { $path = "$entry"; if (!is_file($dir."/".$entry) && !is_link($path) && file_exists($path)) { if ($entry !== "." && $entry !== "..") { if ($dir == $log) { print "<option value='/$entry'>/$entry</option>\n"; getDirList($entry, $log); } else { print "<option value='/$dir/$entry'>/$dir/$entry</option>\n"; getDirList($entry, $log); } } $j++; } else { print "<option value='$dir/$entry'>file: $dir/$entry</option>\n"; } } $directory->close(); } } ------------------------------------------------------------------------ [2003-07-13 22:09:32] sniper@php.net And you should update to PHP 4.3.2 first too.. ------------------------------------------------------------------------ [2003-07-13 22:08:53] sniper@php.net Without seeing the sources it's impossible to start even guessing what you're doing wrong. Seems like user error to me. And DO NOT send me any emails. Add the short but complete example script, max. 20 lines, which clearly shows the problem at hand. ------------------------------------------------------------------------ [2003-07-11 14:37:33] itamarc at rogers dot com Description: ------------ some directories don't show as such. even when using chdir() and looking at all notes on the subject. I have had and reprocudes this problem for months. so please don't just say it's crap. Reproduce code: --------------- goto http://zabber.portredirect.com/ login as php password is net goto 'Members Options' goto 'User Files' goto 'Manage Folders' I used the site to make 3 folders. Click on "Make New Directory" See what it says in the file list. source code used is available to anyone who E-mails me at: zabber@rogers.com Expected result: ---------------- should who first folder and subfolder as such. but second folder and any uploaded files show wrong. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24611&edit=1

« previous php.bugs (#44293) next »