|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-10-28 07:48 UTC] krakjoe@php.net
-Status: Open
+Status: Closed
-Package: Feature/Change Request
+Package: *General Issues
-Assigned To:
+Assigned To: krakjoe
[2013-10-28 07:48 UTC] krakjoe@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 10:00:01 2025 UTC |
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; }