ID: 39198 Comment by: phpbugs at mainskill dot com Reported By: php dot spam at frogblender dot net Status: No Feedback Bug Type: Directory function related Operating System: Windows 2003 PHP Version: 5.1.6 New Comment:
<code> // this script runs under user www-data // Apache/2.2.3 (Debian) // PHP/5.2.0-8+etch11 ... echo "\$dirName is $dirName<br>\n"; $FullDirname = realpath( $dirName ); echo "\$FullDirname is $FullDirname<br>\n"; if (!is_dir( $FullDirname )) { // as the directory is there this should never // be displayed! echo "$FullDirname is not a directory<br>\n"; } </code> output: $dirName is mswbt_A6565897X3B91B $FullDirname is /var/www/V3.46-pre03/source/mswbt_A6565897X3B91B /var/www/V3.46-pre03/source/mswbt_A6565897X3B91B is not a directory this clearly shows that the directory is there $ ls -als /var/www/V3.46-pre03/source/ insgesamt 16 4 drwxrwsrwx 4 www-data www-data 4096 2008-07-07 16:17 . 4 drwxr-xr-x 14 root root 4096 2008-07-07 16:19 .. 4 drwxr-sr-x 5 www-data www-data 4096 2008-07-07 16:17 mswbt_A6565897X3B91B Msg to [EMAIL PROTECTED]: Please do not try to run this code on your machine. You will most probably *not* have this directory structure and the is_dir() function call would succeed on your machine as returning FALSE would be correct then! I hope this can help a bit to solve the problem. Previous Comments: ------------------------------------------------------------------------ [2007-06-04 22:12:57] sweston at lyon dot edu I having the same problem. OS: FreeBSD 6.2 PHP: 5.1.2 Server: Apache 2.2 Mount a windows share. Run the following on the windows share: $d = dir("Path/to/windows/share"); while (false !== ($entry = $d->read())) { echo "Entry: $entry<br>\n"; var_dump(is_dir($entry)); echo "<br>"; } All sub-directories on the windows share return: Entry: Sub_Dir_1 bool(false) Entry: Sub_Dir_2 bool(false) ------------------------------------------------------------------------ [2007-05-20 13:24:43] legolas558 at users dot sourceforge dot net The problem seems affecting only the temporary directory's subdirectories; please fix this bug because it is causing a lot of weird effects on scripts which verify paths existance and eventually create them. I am using PHP 5.2.0 and running this script: <?php // bug #39198 testcase, see http://bugs.php.net/bug.php?id=39198 // @author legolas558 if ( !function_exists('sys_get_temp_dir') ) { // Based on http://www.phpit.net/ // article/creating-zip-tar-archives-dynamically-php/2/ function sys_get_temp_dir() { // Try to get from environment variable if ( !empty($_ENV['TMP']) ) return realpath( $_ENV['TMP'] ); else if ( !empty($_ENV['TMPDIR']) ) return realpath( $_ENV['TMPDIR'] ); else if ( !empty($_ENV['TEMP']) ) return realpath( $_ENV['TEMP'] ); // Detect by creating a temporary file else { // Try to use system's temporary directory // as random name shouldn't exist $temp_file = tempnam( md5(uniqid(rand(), TRUE)), '' ); if ($temp_file) { $d_temp = realpath( dirname($temp_file) ); unlink( $temp_file ); return $d_temp; } else return FALSE; } } } $d_temp= sys_get_temp_dir(); if ($d_temp===false) die('Cannot retrieve temporary path'); $d_temp = str_replace('\\','/', $d_temp); if ($d_temp[strlen($d_temp)-1]!='/') $d_temp .= '/'; // now $d_temp contains a correctly formatted path e.g. C:/Windows/TEMP/ $my_temp_subdir = $d_temp.'39198_exists'; if (@rmdir($my_temp_subdir)) echo "I just removed a previous <strong>$my_temp_subdir</strong> folder, now "; // create a directory under the temporary path if (!mkdir($my_temp_subdir)) die("I could not create <strong>$my_temp_subdir</strong>"); else echo "<strong>$my_temp_subdir</strong> was created "; // use here temp_is_dir() to see how the script should work instead $b = is_dir($my_temp_subdir); if (!$b) echo "but the folder is not a dir (through is_dir())!"; else echo "and is recognized as a dir (through is_dir())"; // workaround function function temp_is_dir($dir) { // check directory existance under temp folder (tested on Windows) // see bug #31918 http://bugs.php.net/bug.php?id=39198 // by legolas558 if ([EMAIL PROTECTED]($dir)) return true; rmdir($dir); return false; } ?> I get this talkative output: [code] C:/WINDOWS/Temp/39198_exists was created but the folder is not a dir (through is_dir())! [/code] But the correct talkative output would be instead: [code] C:/WINDOWS/Temp/39198_exists was created and is recognized as a dir (through is_dir()) [/code] Note that using the workaround function "temp_is_dir()" in place of "is_dir()" the correct output would be returned instead. Please ask me more if necessary. ------------------------------------------------------------------------ [2006-11-17 01:00:00] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2006-11-09 10:06:54] [EMAIL PROTECTED] >I don't have your directory structure either so I can't > adapt the script for your machine. Surely you can. Just create all the required directories in the script itself, don't left us guessing which directories exist and which don't. ------------------------------------------------------------------------ [2006-11-09 09:58:45] php dot spam at frogblender dot net I don't have your directory structure either so I can't adapt the script for your machine. The Temp directory will be there in a standard installation of Windows. You then search and replace in my script to adapt to your environment. Finally you create one directory RP_Compile and give Everyone full rights on that directory. It shouldn't take more than five minutes for anyone who knows how to log in to Windows. ------------------------------------------------------------------------ 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/39198 -- Edit this bug report at http://bugs.php.net/?id=39198&edit=1