| | 59 | * Checks whether access to a given directory is allowed. |
| | 60 | * |
| | 61 | * This is used when detecting version control checkouts. Takes into account |
| | 62 | * the PHP open_basedir restrictions, so that WordPress does not try to access |
| | 63 | * directories it is not allowed to. |
| | 64 | * |
| | 65 | * @since 6.1.0 |
| | 66 | * |
| | 67 | * @param string $dir The directory to check. |
| | 68 | * @return bool True if access to the directory is allowed, false otherwise. |
| | 69 | */ |
| | 70 | public function is_allowed_dir( $dir ) { |
| | 71 | $open_basedir = ini_get( 'open_basedir' ); |
| | 72 | |
| | 73 | if ( ! $open_basedir ) { |
| | 74 | return true; |
| | 75 | } |
| | 76 | |
| | 77 | $open_basedir_list = explode( PATH_SEPARATOR, $open_basedir ); |
| | 78 | |
| | 79 | foreach ( $open_basedir_list as $basedir ) { |
| | 80 | if ( str_starts_with( $dir, $basedir ) ) { |
| | 81 | return true; |
| | 82 | } |
| | 83 | } |
| | 84 | |
| | 85 | return false; |
| | 86 | } |
| | 87 | |
| | 88 | /** |