File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / security / open_basedir_file_get_contents.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:06 2012 UTC (12 years, 5 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>