Hi guys,

Attached is a patch which I worked up quickly (could probably use some
improving) which should solve the problem with includes of relative
includes :)
Simpler said:

a.php
-----
<?php include "../b.php"; ?>

b.php
-----
<?php include "c.php"; ?>

c.php
-----
<?php print "Yay!" ?>

This example should work when c.php is in the same directory as b.php and
PHP is ran on a.php.

Please check this patch. It might crash in certain cases, I barely tested
it.
Let me know...

Andi
--- fopen_wrappers.c    2001/06/06 13:05:53     1.117
+++ fopen_wrappers.c    2001/07/10 17:20:27
@@ -443,8 +443,39 @@
                }
                ptr = end;
        }
+
        efree(pathbuf);
-       return NULL;
+
+       {
+               char *exec_fname;
+               int exec_fname_len;
+               char *filename_dir;
+               ELS_FETCH();
+
+               exec_fname = zend_get_executed_filename(ELS_C);
+               exec_fname_len = strlen(exec_fname);
+
+               pathbuf = (char *) emalloc(exec_fname_len+filename_length+1+1); /* 
+Over allocate to save time */
+               memcpy(pathbuf, exec_fname, exec_fname_len+1);
+
+               while ((--exec_fname_len >= 0) && !IS_SLASH(pathbuf[exec_fname_len])) 
+{
+               }
+               pathbuf[exec_fname_len] = DEFAULT_SLASH;
+               memcpy(&pathbuf[exec_fname_len+1], filename, filename_length+1);
+
+               fprintf(stderr,"Trying to open %s\n", pathbuf);
+
+               if (PG(safe_mode)) {
+                       if (VCWD_STAT(pathbuf, &sb) == 0 && (!php_checkuid(pathbuf, 
+mode, CHECKUID_CHECK_MODE_PARAM))) {
+                               efree(pathbuf);
+                               return NULL;
+                       }
+               }
+               fp = php_fopen_and_set_opened_path(pathbuf, mode, opened_path);
+               efree(pathbuf);
+               return fp;
+       }
+       return NULL; /* Not really needed anymore */
 }
 /* }}} */
  
-- 
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