open_basedir_touch.phpt 2.0 KB

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