hassank1 Posted May 5, 2008 Share Posted May 5, 2008 what's open_basedir ... I've read about it .. however I am still a bit confused .. so can some1 give me a simple definiton with an example plz .. thx Quote Link to comment https://forums.phpfreaks.com/topic/104192-open_basedir/ Share on other sites More sharing options...
MadTechie Posted May 5, 2008 Share Posted May 5, 2008 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); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/104192-open_basedir/#findComment-533383 Share on other sites More sharing options...
MadTechie Posted May 5, 2008 Share Posted May 5, 2008 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'] Quote Link to comment https://forums.phpfreaks.com/topic/104192-open_basedir/#findComment-533391 Share on other sites More sharing options...
hassank1 Posted May 5, 2008 Author Share Posted May 5, 2008 Okay thx .. one more thing .. if the subdirs are placed inside "public_htm" .. they'll be executed right ?? btw I've asked a question related to directories can u help me with it . here's the link : http://www.phpfreaks.com/forums/index.php/topic,195677.0.html Quote Link to comment https://forums.phpfreaks.com/topic/104192-open_basedir/#findComment-533393 Share on other sites More sharing options...
MadTechie Posted May 5, 2008 Share Posted May 5, 2008 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/" Quote Link to comment https://forums.phpfreaks.com/topic/104192-open_basedir/#findComment-533397 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.