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_put_contents");
10
11var_dump(file_put_contents("../bad/bad.txt", "Hello World!"));
12var_dump(file_put_contents(".././bad/bad.txt", "Hello World!"));
13var_dump(file_put_contents("../bad/../bad/bad.txt", "Hello World!"));
14var_dump(file_put_contents("./.././bad/bad.txt", "Hello World!"));
15var_dump(file_put_contents($initdir."/test/bad/bad.txt", "Hello World!"));
16
17test_open_basedir_after("file_put_contents");
18?>
19--CLEAN--
20<?php
21require_once "open_basedir.inc";
22delete_directories();
23?>
24--EXPECTF--
25*** Testing open_basedir configuration [file_put_contents] ***
26bool(true)
27bool(true)
28bool(true)
29bool(true)
30bool(true)
31
32Warning: file_put_contents(): open_basedir restriction in effect. File(../bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
33
34Warning: file_put_contents(../bad/bad.txt): Failed to open stream: %s in %s on line %d
35bool(false)
36
37Warning: file_put_contents(): open_basedir restriction in effect. File(.././bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
38
39Warning: file_put_contents(.././bad/bad.txt): Failed to open stream: %s in %s on line %d
40bool(false)
41
42Warning: file_put_contents(): open_basedir restriction in effect. File(../bad/../bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
43
44Warning: file_put_contents(../bad/../bad/bad.txt): Failed to open stream: %s in %s on line %d
45bool(false)
46
47Warning: file_put_contents(): open_basedir restriction in effect. File(./.././bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
48
49Warning: file_put_contents(./.././bad/bad.txt): Failed to open stream: %s in %s on line %d
50bool(false)
51
52Warning: file_put_contents(): open_basedir restriction in effect. File%s/test/bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
53
54Warning: file_put_contents%s/test/bad/bad.txt): Failed to open stream: %s in %s on line %d
55bool(false)
56*** Finished testing open_basedir configuration [file_put_contents] ***
57