Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
letoDMS on a open_basedir system limitation
#1
Hallo ,

i've reached some problems with open_basedir , and the patch from alekseynfor , imho , doesn't fit well .
This is my patch , done with fury/dirt/quick phProgramming

PHP Code:
function makeDir($path) {
                 
                if (
strncmp($pathDIRECTORY_SEPARATOR1) == 0) {
                        
$mkfolder DIRECTORY_SEPARATOR;
                }
                else {
                        
$mkfolder "";
                }
/*
                $path = preg_split( "/[\\\\\/]/" , $path );
                for(  $i=0 ; isset( $path[$i] ) ; $i++ )
                {
                        if(!strlen(trim($path[$i])))continue;
                        $mkfolder .= $path[$i];
*/
$mkfolder $path;
                        if( !
is_dir$mkfolder ) ){
                                
$res=@mkdir($mkfolder,0777,true);
                                if (!
$res) return false;
                        }
                        
$mkfolder .= DIRECTORY_SEPARATOR;
//              }

                
return true;

                
// patch from alekseynfor safe_mod or open_basedir

                
global $settings;
                
$path substr_replace ($path"/"0strlen($settings->_contentDir));
                
$mkfolder $settings->_contentDir;

                
$path preg_split"/[\\\\\/]/" $path );

                for(  
$i=; isset( $path[$i] ) ; $i++ )
                {
                        if(!
strlen(trim($path[$i])))continue;
                        
$mkfolder .= $path[$i];

                        if( !
is_dir$mkfolder ) ){
                                
$res= @mkdir"$mkfolder,  0777);
                                if (!
$res) return false;
                        }
                        
$mkfolder .= DIRECTORY_SEPARATOR;
                }

                return 
true;

        } 

What was the problem ? simple :
The Open_basedir prevents the render to access all nodes that are behind the node that i "jail" it .
so if your script want to make / del a DIRECTORY that is :
/home/SITE/sub/DIRECTORY
and my basepath is fixed to sub , i cannot recurse directly using :
is_dir(/home) and then is_dir(/home/SITE) , and so on , tha restriction "kill" it at the first step .
But if i point the process directly to /home/SITE/sub/DIRECTORY and use the mkdir() option for recursion i'll fix directly the problem , also bypassing another problem , the making of the "track" directories , if i need to make a foo/bar/THIS , and foo/bar doesn't exists , using recursion the system will create the "intermediate" directoris autonomusly .
( http://php.net/manual/en/function.mkdir.php )
hope this "Italinglish" words help anyone Smile

Reply


Messages In This Thread
letoDMS on a open_basedir system limitation - by matteocisilino - 04-05-2011, 05:06 PM

Forum Jump:


Users browsing this thread: