ID: 11326
Updated by: cardinal
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: Scripting Engine problem
Operating system: 
PHP Version: 4.0.5
Assigned To: 
Comments:

Without addressing the server-side issues, I'll point out
why the client side ones are almost certain not to change.

<script src="js/myscript.js"> and <img src="images/php_logo.gif">
are both ignored by the PHP interpreter.

The browser (Which will be processing the tags) does not
konw PHP was involved in the document's creation.

> Of course, the image is not showing up because the server
> thinks it is located at /images/php_logo.gif. When it is
> really located at /b/images/php_logo.gif!

As mentioned above, the server isn't thinking anything
about the image.  The browser thinks it's in the images
subdirectory, relative to the path of the html page it's
parsing.  The fact that this <img> tag came from a file
that's in a subdirectory (On the server) wouldn't be
relevant even if PHP was changing the working directory as
you want it to, because PHP won't be interpreting the html
code (Nor should it).

Previous Comments:
---------------------------------------------------------------------------

[2001-06-07 07:16:26] [EMAIL PROTECTED]
Please do not immediately file this bug as a duplicate of 
#9673. Although my bug's goal is reporting the same 
problem, it appears that #9673 was last 'Anylized' three 
months ago with no reply to the last comment made by the 
bug's author.

PHP desperately needs a way to do nested includes, 
preserving not only php relative paths transparently, but 
server side paths as well. By server side path, I am 
refering to <script src="js/myscript.js"> and <img 
src="images/myimage.gif">. Currently, if one includes a 
file by means of include(), include_once(), etc., the 
working directory of the included file, no matter where it 
is located, is of the calling file. One can circumvent 
this obstacle a couple of ways. The easiest appears to be 
the method of changing one's working directory as you move 
into an included file. Of course, one must always remember 
to change the working directory back to the original 
location after the file has been included.

Unfortunately, this work around breaks down when one 
wishes to use server side paths in an included file. 
Although the working directory has been changed, the 
server working directory is the same. The following is an 
example that completely illustrates the problem.

EXAMPLE DIRCTORY STUCTURE:
        / --> a.php
        /b/ --> b1.php
        /b/ --> b2.php
        /b/images/ --> php_logo.gif
        

BUG:
        /*-- /a.php --*/
        print( "<p>a.php " . getcwd() . "</p>");
        include_once( "b/b1.php" );

        /*-- /b/b1.php --*/
        print( "<p>b1.php " . getcwd() . "</p>" );
        include_once( "b2.php" );

        /*-- /b/b2.php --*/
        print( "<p>b2.php " . getcwd() . "</p>" );
        print( "<img src=images/php_logo.gif>" );

ACCESS: http://server/a.php
RESULT:
        a.php /
        b1.php /
        Warning: Failed opening 'b2.php' for inclusion
        (include_path='.:/usr/lib/php4') in
        /b/b1.php on line 3

WORK AROUND:
        /*-- /a.php --*/
        print( "<p>a.php " . getcwd() . "</p>");
        chdir( "b" );
        include_once( "b1.php" );
        chdir( ".." );

        /*-- /b/b1.php --*/
        print( "<p>b1.php " . getcwd() . "</p>" );
        include_once( "b2.php" );

        /*-- /b/b2.php --*/
        print( "<p>b2.php " . getcwd() . "</p>" );
        print( "<img src=images/php_logo.gif>" );

ACCESS: http://server/a.php
RESULT:
        a.php /var/www/php_work_around
        b1.php /var/www/php_work_around/b
        b2.php /var/www/php_work_around/b
        [image not found]

Of course, the image is not showing up because the server 
thinks it is located at /images/php_logo.gif. When it is 
really located at /b/images/php_logo.gif!

In bug #9673, on 2001-03-15 09:08:11 [EMAIL PROTECTED] writes 
"Now, all relative pathes are resolved against the current 
directory of the including script (which is the directory 
where it's located). This is a known issue. Use 
include_pathes in the meantime."

Unfortunately, three months later "This is [still] a known 
issue" and [EMAIL PROTECTED] is still correct!


---------------------------------------------------------------------------



ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=11326&edit=2


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to