open_basedir_dir.phpt 2.6 KB

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