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