1--TEST--
2Test open_basedir configuration
3--INI--
4open_basedir=.
5--FILE--
6<?php
7require_once "open_basedir.inc";
8$initdir = getcwd();
9
10test_open_basedir_before("dir");
11test_open_basedir_error("dir");
12
13var_dump(dir($initdir."/test/ok/"));
14var_dump(dir($initdir."/test/ok"));
15var_dump(dir($initdir."/test/ok/../ok"));
16
17test_open_basedir_after("dir");?>
18--CLEAN--
19<?php
20require_once "open_basedir.inc";
21delete_directories();
22?>
23--EXPECTF--
24*** Testing open_basedir configuration [dir] ***
25bool(true)
26bool(true)
27bool(true)
28bool(true)
29bool(true)
30
31Warning: dir(): open_basedir restriction in effect. File(../bad) is not within the allowed path(s): (.) in %s on line %d
32
33Warning: dir(../bad): failed to open dir: %s in %s on line %d
34bool(false)
35
36Warning: dir(): open_basedir restriction in effect. File(../bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
37
38Warning: dir(../bad/bad.txt): failed to open dir: %s in %s on line %d
39bool(false)
40
41Warning: dir(): open_basedir restriction in effect. File(..) is not within the allowed path(s): (.) in %s on line %d
42
43Warning: dir(..): failed to open dir: %s in %s on line %d
44bool(false)
45
46Warning: dir(): open_basedir restriction in effect. File(../) is not within the allowed path(s): (.) in %s on line %d
47
48Warning: dir(../): failed to open dir: %s in %s on line %d
49bool(false)
50
51Warning: dir(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (.) in %s on line %d
52
53Warning: dir(/): failed to open dir: %s in %s on line %d
54bool(false)
55
56Warning: dir(): open_basedir restriction in effect. File(../bad/.) is not within the allowed path(s): (.) in %s on line %d
57
58Warning: dir(../bad/.): failed to open dir: %s in %s on line %d
59bool(false)
60
61Warning: dir(): open_basedir restriction in effect. File(%s/test/bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
62
63Warning: dir(%s/test/bad/bad.txt): failed to open dir: %s in %s on line %d
64bool(false)
65
66Warning: dir(): open_basedir restriction in effect. File(%s/test/bad/../bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
67
68Warning: dir(%s/test/bad/../bad/bad.txt): failed to open dir: %s in %s on line %d
69bool(false)
70object(Directory)#%d (2) {
71  ["path"]=>
72  string(%d) "%s/test/ok/"
73  ["handle"]=>
74  resource(%d) of type (stream)
75}
76object(Directory)#%d (2) {
77  ["path"]=>
78  string(%d) "%s/test/ok"
79  ["handle"]=>
80  resource(%d) of type (stream)
81}
82object(Directory)#%d (2) {
83  ["path"]=>
84  string(%d) "%s/test/ok/../ok"
85  ["handle"]=>
86  resource(%d) of type (stream)
87}
88*** Finished testing open_basedir configuration [dir] ***
89