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("fopen");
10
11var_dump(fopen("../bad", "r"));
12var_dump(fopen("../bad/bad.txt", "r"));
13var_dump(fopen("..", "r"));
14var_dump(fopen("../", "r"));
15var_dump(fopen("/", "r"));
16var_dump(fopen("../bad/.", "r"));
17var_dump(fopen("../bad/./bad.txt", "r"));
18var_dump(fopen("./../.", "r"));
19
20var_dump(fopen($initdir."/test/ok/ok.txt", "r"));
21var_dump(fopen("./ok.txt", "r"));
22var_dump(fopen("ok.txt", "r"));
23var_dump(fopen("../ok/ok.txt", "r"));
24var_dump(fopen("../ok/./ok.txt", "r"));
25
26test_open_basedir_after("fopen");
27?>
28--CLEAN--
29<?php
30require_once "open_basedir.inc";
31delete_directories();
32?>
33--EXPECTF--
34*** Testing open_basedir configuration [fopen] ***
35bool(true)
36bool(true)
37bool(true)
38bool(true)
39bool(true)
40
41Warning: fopen(): open_basedir restriction in effect. File(../bad) is not within the allowed path(s): (.) in %s on line %d
42
43Warning: fopen(../bad): Failed to open stream: %s in %s on line %d
44bool(false)
45
46Warning: fopen(): open_basedir restriction in effect. File(../bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
47
48Warning: fopen(../bad/bad.txt): Failed to open stream: %s in %s on line %d
49bool(false)
50
51Warning: fopen(): open_basedir restriction in effect. File(..) is not within the allowed path(s): (.) in %s on line %d
52
53Warning: fopen(..): Failed to open stream: %s in %s on line %d
54bool(false)
55
56Warning: fopen(): open_basedir restriction in effect. File(../) is not within the allowed path(s): (.) in %s on line %d
57
58Warning: fopen(../): Failed to open stream: %s in %s on line %d
59bool(false)
60
61Warning: fopen(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (.) in %s on line %d
62
63Warning: fopen(/): Failed to open stream: %s in %s on line %d
64bool(false)
65
66Warning: fopen(): open_basedir restriction in effect. File(../bad/.) is not within the allowed path(s): (.) in %s on line %d
67
68Warning: fopen(../bad/.): Failed to open stream: %s in %s on line %d
69bool(false)
70
71Warning: fopen(): open_basedir restriction in effect. File(../bad/./bad.txt) is not within the allowed path(s): (.) in %s on line %d
72
73Warning: fopen(../bad/./bad.txt): Failed to open stream: %s in %s on line 12
74bool(false)
75
76Warning: fopen(): open_basedir restriction in effect. File(./../.) is not within the allowed path(s): (.) in %s on line %d
77
78Warning: fopen(./../.): Failed to open stream: %s in %s on line %d
79bool(false)
80resource(%d) of type (stream)
81resource(%d) of type (stream)
82resource(%d) of type (stream)
83resource(%d) of type (stream)
84resource(%d) of type (stream)
85*** Finished testing open_basedir configuration [fopen] ***
86