Jump to content

open_basedir


hassank1

Recommended Posts

i assume you mean opendir

Opens up a directory handle to be used in subsequent closedir(), readdir(), and rewinddir() calls.

 

<?php
$dir = "/etc/php5/";

// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
        }
        closedir($dh);
    }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/104192-open_basedir/#findComment-533383
Share on other sites

Sorry I Totally missed the point of your post!

 

okay the directive  open_basedir, is used as a restriction,

 

When a script tries to open a file with' date=' for example, fopen() or gzopen(), the location of the file is checked. When the file is outside the specified directory-tree, PHP will refuse to open it. All symbolic links are resolved, so it's not possible to avoid this restriction with a symlink. If the file doesn't exist then the symlink couldn't be resolved and the filename is compared to (a resolved) open_basedir .[/quote']

 

Link to comment
https://forums.phpfreaks.com/topic/104192-open_basedir/#findComment-533391
Share on other sites

yes, its not a path it's a prefix, like a regex "^/dir/inc"

The restriction specified with open_basedir is actually a prefix, not a directory name. This means that "open_basedir = /dir/incl" also allows access to "/dir/include" and "/dir/incls" if they exist. When you want to restrict access to only the specified directory, end with a slash. For example: "open_basedir = /dir/incl/"

Link to comment
https://forums.phpfreaks.com/topic/104192-open_basedir/#findComment-533397
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.