open_basedir_file.phpt 2.5 KB

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