open_basedir_file_put_contents.phpt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --TEST--
  2. Test open_basedir configuration
  3. --INI--
  4. open_basedir=.
  5. --FILE--
  6. <?php
  7. require_once "open_basedir.inc";
  8. $initdir = getcwd();
  9. test_open_basedir_before("file_put_contents");
  10. var_dump(file_put_contents("../bad/bad.txt", "Hello World!"));
  11. var_dump(file_put_contents(".././bad/bad.txt", "Hello World!"));
  12. var_dump(file_put_contents("../bad/../bad/bad.txt", "Hello World!"));
  13. var_dump(file_put_contents("./.././bad/bad.txt", "Hello World!"));
  14. var_dump(file_put_contents($initdir."/test/bad/bad.txt", "Hello World!"));
  15. test_open_basedir_after("file_put_contents");
  16. ?>
  17. --CLEAN--
  18. <?php
  19. require_once "open_basedir.inc";
  20. delete_directories();
  21. ?>
  22. --EXPECTF--
  23. *** Testing open_basedir configuration [file_put_contents] ***
  24. bool(true)
  25. bool(true)
  26. bool(true)
  27. bool(true)
  28. bool(true)
  29. Warning: file_put_contents(): open_basedir restriction in effect. File(../bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
  30. Warning: file_put_contents(../bad/bad.txt): failed to open stream: %s in %s on line %d
  31. bool(false)
  32. Warning: 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. Warning: file_put_contents(.././bad/bad.txt): failed to open stream: %s in %s on line %d
  34. bool(false)
  35. Warning: 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
  36. Warning: file_put_contents(../bad/../bad/bad.txt): failed to open stream: %s in %s on line %d
  37. bool(false)
  38. Warning: file_put_contents(): open_basedir restriction in effect. File(./.././bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
  39. Warning: file_put_contents(./.././bad/bad.txt): failed to open stream: %s in %s on line %d
  40. bool(false)
  41. Warning: 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
  42. Warning: file_put_contents%s/test/bad/bad.txt): failed to open stream: %s in %s on line %d
  43. bool(false)
  44. *** Finished testing open_basedir configuration [file_put_contents] ***