php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3940 Virtual changes current directory - php4RC1!!
Submitted: 2000-03-28 01:22 UTC Modified: 2000-07-31 10:42 UTC
From: rwidmer at developersdesk dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0 Beta 4 Patch Level 1 OS: Red Hat Linux 5.2
Private report: No CVE-ID: None
 [2000-03-28 01:22 UTC] rwidmer at developersdesk dot com
If the file executed by virtual() is in a different
directory, the current directory is changed to the directory containing the virtual() file.

See it for yourself at:

   http://ns2.developersdesk.com/virtual/test.php3


Download a copy of the files in a tarball at:

   http://ns2.developersdesk.com/virtual/virtualtest.tar.gz   


Untar this file in a directory that is document root.  It will create a directory  virtual  and two files virtual.html and virtual.inc.


Here are the contents:

/virtual.html
----------------------------------------
Hello from the virtual.html file in document root
----------------------------------------


/virtual.inc
----------------------------------------
hello from the virtual.inc file in document root
----------------------------------------


/virtual/firstvirtual.html
----------------------------------------
hello from the first virtual.inc in the subdirectory
----------------------------------------


/virtual/virtual.html
----------------------------------------
hello from virtual.html in the subdirectory<BR>
----------------------------------------


/virtual/virtual.inc
----------------------------------------
hello from virtual.inc in the subdirectory
----------------------------------------


/virtual/test/php3
----------------------------------------
OK, lets try calling the include file, you should get the one in the subdirectory.
<BR><BR>
<? include( 'virtual.inc' ) ?>
<BR><BR>
Now lets call the virtual.html in the root directory and see what happens
<BR><BR>
<? virtual( '/virtual.html' ) ?>
<BR><BR>
Finally lets see what happens when we call the include file again.
<BR><BR>
<? include( 'virtual.inc' ) ?>
<BR><BR>
Oops, it looks like virtual() changed the current directory and did not change it back...
<BR><BR>
<? phpinfo() ?>
----------------------------------------


The current directory ./ will have to be in your include path for this
to work.

My system is:      
Apache         1.3.12
mod_SSL        2.6.2
openssl        0.9.5
php4rc1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-30 12:40 UTC] zak@php.net
Have you tried a current release of PHP?  If so, does the problem still occur?
 [2000-07-30 14:09 UTC] zak@php.net
Email from user:

"I just checked it with PHP Version 4.0.2-dev   from  php4-200007300345

Virtual still messes up the current directory.

The extra headers problem mentioned in the test programs for this bug has been fixed.


   http://ns2.developersdesk.com/virtual/test.php3
-------------------------------------------------------------------------------
hello from virtual.html in the subdirectory

Do you see headers after this virtual call? With php4rc1 I do, but not
with php3.0.12. Somehow I don't think they belong there. They only
appear if virtual is the first html sent to the browser. Even a single
space sent before the virtual call will prevent it. 

OK, lets try calling the include file, you should get the one in the
subdirectory. 

hello from virtual.inc in the subdirectory 

Now lets call the virtual.html in the root directory and see what
happens 

Hello from the virtual.html file in document root 

Finally lets see what happens when we call the include file again. 

hello from the virtual.inc file in document root 

Oops, it looks like virtual() changed the current directory and did not
change it back... 

     PHP Version 4.0.2-dev



     System
                             Linux lessa.developersdesk.com 2.0.36 #1
Tue Oct 13
                             22:17:11 EDT 1998 i586 unknown
     Build Date
                             Jul 30 2000
     Configure Command
                             './configure' '--with-apache=../apache'
                             '--with-mysql=../mysql'
'--enable-track-vars'
                             '--with-config-file-path=/web/conf'
'--with-gd'
     Server API
                             Apache"
 [2000-07-30 14:16 UTC] stas@php.net
Works for me. Are you sure you don't have some include_path or apache seetting that is interferring?
 [2000-07-31 10:42 UTC] stas@php.net
User reports it working in another configuration, closing.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 13 10:01:32 2024 UTC