#20742 [NEW]: function to check if dir is allowed through open_basedir-directive

From: Date: Sun, 01 Dec 2002 08:51:57 +0000
Subject: #20742 [NEW]: function to check if dir is allowed through open_basedir-directive
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-26274@lists.php.net to get a copy of this message
From: bugs.php@jensthebrain.de Operating system: Linux PHP version: 4.2.3 PHP Bug Type: Feature/Change Request Bug description: function to check if dir is allowed through open_basedir-directive I needed to check, whether a directory is allowed through open_basedir.. This should be in the php-functions. My solution (not tested under windows): function inOpenBasedir($dir) { $openBasedir = ini_get('open_basedir'); if (empty($openBasedir)) { return true; } foreach (explode(':', $openBasedir) as $basedir) { if( strlen($basedir) > strlen($dir) ) { // Check, if only a '\' is needed at the end of $dir if( $basedir == ($dir . "/") ) { return true; } } else { // Check if basedir and dir are the same.. if( $basedir == $dir ) { return true; } else { // open_basedir can be a prefix -> checking whether // dir starts with basedir or not if( strncmp($basedir, $dir, strlen($basedir)) == 0) { return true; } } } } return false; } -- Edit bug report at http://bugs.php.net/?id=20742&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=20742&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=20742&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=20742&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=20742&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=20742&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=20742&r=support Expected behavior: http://bugs.php.net/fix.php?id=20742&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=20742&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=20742&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=20742&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20742&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=20742&r=dst IIS Stability: http://bugs.php.net/fix.php?id=20742&r=isapi

« previous php.bugs (#26274) next »