open_basedir_scandir.phpt 3.0 KB

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