sqlite3_21_security.phpt 870 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --TEST--
  2. SQLite3 open_basedir checks
  3. --EXTENSIONS--
  4. sqlite3
  5. --INI--
  6. open_basedir=.
  7. --FILE--
  8. <?php
  9. chdir(__DIR__);
  10. $directory = __DIR__ . '/';
  11. $file = uniqid() . '.db';
  12. echo "Within test directory\n";
  13. $db = new SQLite3($directory . $file);
  14. var_dump($db);
  15. var_dump($db->close());
  16. unlink($directory . $file);
  17. echo "Above test directory\n";
  18. try {
  19. $db = new SQLite3('../bad' . $file);
  20. } catch (Exception $e) {
  21. echo $e . "\n";
  22. }
  23. echo "Done\n";
  24. ?>
  25. --EXPECTF--
  26. Within test directory
  27. object(SQLite3)#%d (0) {
  28. }
  29. bool(true)
  30. Above test directory
  31. Warning: SQLite3::__construct(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (.) in %ssqlite3_21_security.php on line %d
  32. Exception: open_basedir prohibits opening %s in %ssqlite3_21_security.php:%d
  33. Stack trace:
  34. #0 %ssqlite3_21_security.php(%d): SQLite3->__construct('%s')
  35. #1 {main}
  36. Done