@@ -40,7 +40,7 @@ function recursive_delete_directory($directory) {
4040 if ($ item != '. ' ) {
4141 if ($ item != '.. ' ) {
4242 $ path = ($ directory .'/ ' .$ item );
43- if (is_dir ($ path ) == TRUE ) {
43+ if (is_dir ($ path ) == TRUE && ! is_link ( $ path ) ) {
4444 recursive_delete_directory ($ path );
4545 } else {
4646 @chmod ($ path , 0777 );
@@ -57,9 +57,24 @@ function recursive_delete_directory($directory) {
5757 return TRUE ;
5858}
5959
60+ function open_basedir_test_directory () {
61+ foreach (debug_backtrace (DEBUG_BACKTRACE_IGNORE_ARGS ) as $ frame ) {
62+ if (!isset ($ frame ["file " ]) || $ frame ["file " ] === __FILE__ ) {
63+ continue ;
64+ }
65+
66+ $ test = preg_replace ('/(?:\.clean)?\.php$/ ' , '' , basename ($ frame ["file " ]));
67+ return __DIR__ ."/open_basedir_test_ " .$ test ;
68+ }
69+
70+ return __DIR__ ."/open_basedir_test " ;
71+ }
72+
6073function create_directories () {
6174 delete_directories ();
62- $ directory = getcwd ();
75+ $ directory = open_basedir_test_directory ();
76+ mkdir ($ directory );
77+ chdir ($ directory );
6378
6479 var_dump (mkdir ($ directory ."/test " ));
6580 var_dump (mkdir ($ directory ."/test/ok " ));
@@ -69,8 +84,7 @@ function create_directories() {
6984}
7085
7186function delete_directories () {
72- $ directory = (getcwd ()."/test " );
73- recursive_delete_directory ($ directory );
87+ recursive_delete_directory (open_basedir_test_directory ());
7488}
7589
7690function test_open_basedir_error ($ function ) {
@@ -87,12 +101,15 @@ function test_open_basedir_error($function) {
87101}
88102
89103function test_open_basedir_before ($ function , $ change = TRUE ) {
90- global $ savedDirectory ;
104+ global $ initdir , $ savedDirectory ;
91105 echo "*** Testing open_basedir configuration [ $ function] *** \n" ;
106+ create_directories ();
92107 $ directory = getcwd ();
108+ if (isset ($ initdir )) {
109+ $ initdir = $ directory ;
110+ }
93111 $ savedDirectory = $ directory ;
94112 var_dump (chdir ($ directory ));
95- create_directories ();
96113
97114 // Optionally change directory
98115 if ($ change == TRUE ) {
0 commit comments