open_basedir_copy.phpt 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. --TEST--
  2. Test open_basedir configuration
  3. --INI--
  4. open_basedir=.
  5. --FILE--
  6. <?php
  7. require_once "open_basedir.inc";
  8. test_open_basedir_before("copy");
  9. var_dump(copy("ok.txt", "../bad"));
  10. var_dump(copy("ok.txt", "../bad/bad.txt"));
  11. var_dump(copy("ok.txt", ".."));
  12. var_dump(copy("ok.txt", "../"));
  13. var_dump(copy("ok.txt", "/"));
  14. var_dump(copy("ok.txt", "../bad/."));
  15. var_dump(copy("ok.txt", "../bad/./bad.txt"));
  16. var_dump(copy("ok.txt", "./../."));
  17. var_dump(copy("ok.txt", "copy.txt"));
  18. var_dump(unlink("copy.txt"));
  19. test_open_basedir_after("copy");
  20. ?>
  21. --CLEAN--
  22. <?php
  23. require_once "open_basedir.inc";
  24. delete_directories();
  25. ?>
  26. --EXPECTF--
  27. *** Testing open_basedir configuration [copy] ***
  28. bool(true)
  29. bool(true)
  30. bool(true)
  31. bool(true)
  32. bool(true)
  33. Warning: copy(): open_basedir restriction in effect. File(../bad) is not within the allowed path(s): (.) in %s on line %d
  34. Warning: copy(../bad): Failed to open stream: %s in %s on line %d
  35. bool(false)
  36. Warning: copy(): open_basedir restriction in effect. File(../bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
  37. Warning: copy(../bad/bad.txt): Failed to open stream: %s in %s on line %d
  38. bool(false)
  39. Warning: copy(): open_basedir restriction in effect. File(..) is not within the allowed path(s): (.) in %s on line %d
  40. Warning: copy(..): Failed to open stream: %s in %s on line %d
  41. bool(false)
  42. Warning: copy(): open_basedir restriction in effect. File(../) is not within the allowed path(s): (.) in %s on line %d
  43. Warning: copy(../): Failed to open stream: %s in %s on line %d
  44. bool(false)
  45. Warning: copy(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (.) in %s on line %d
  46. Warning: copy(/): Failed to open stream: %s in %s on line %d
  47. bool(false)
  48. Warning: copy(): open_basedir restriction in effect. File(../bad/.) is not within the allowed path(s): (.) in %s on line %d
  49. Warning: copy(../bad/.): Failed to open stream: %s in %s on line %d
  50. bool(false)
  51. Warning: copy(): open_basedir restriction in effect. File(../bad/./bad.txt) is not within the allowed path(s): (.) in %s on line %d
  52. Warning: copy(../bad/./bad.txt): Failed to open stream: %s in %s on line %d
  53. bool(false)
  54. Warning: copy(): open_basedir restriction in effect. File(./../.) is not within the allowed path(s): (.) in %s on line %d
  55. Warning: copy(./../.): Failed to open stream: %s in %s on line %d
  56. bool(false)
  57. bool(true)
  58. bool(true)
  59. *** Finished testing open_basedir configuration [copy] ***