php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24611 is_dir /!is_file won't work quite right.
Submitted: 2003-07-11 14:37 UTC Modified: 2003-07-18 23:46 UTC
From: itamarc at rogers dot com Assigned:
Status: Not a bug Package: *Directory/Filesystem functions
PHP Version: 4.3.1 OS: Windows XP
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: itamarc at rogers dot com
New email:
PHP Version: OS:

 

 [2003-07-11 14:37 UTC] 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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-13 22:08 UTC] 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-13 22:09 UTC] sniper@php.net
And you should update to PHP 4.3.2 first too..

 [2003-07-13 23:09 UTC] 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-18 23:34 UTC] 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-18 23:46 UTC] fmk@php.net
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();
	}
}
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 09 05:01:27 2024 UTC