1--TEST-- 2Phar: test edge cases of file_get_contents() function interception 3--SKIPIF-- 4<?php 5if (!extension_loaded("phar")) die("skip"); 6if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required"); 7?> 8--INI-- 9phar.readonly=0 10--FILE-- 11<?php 12 13Phar::interceptFileFuncs(); 14 15$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; 16$pname = 'phar://' . $fname; 17 18file_get_contents(array()); 19chdir(dirname(__FILE__)); 20file_put_contents($fname, "blah\n"); 21file_put_contents("foob", "test\n"); 22echo file_get_contents($fname); 23unlink($fname); 24mkdir($pname . '/oops'); 25 26file_put_contents($pname . '/foo/hi', '<?php 27echo file_get_contents("foo/" . basename(__FILE__)); 28$context = stream_context_create(); 29file_get_contents("./hi", 0, $context, 0, -1); 30echo file_get_contents("foob"); 31set_include_path("' . addslashes(dirname(__FILE__)) . '"); 32echo file_get_contents("foob", true); 33echo file_get_contents("./hi", 0, $context); 34echo file_get_contents("../oops"); 35echo file_get_contents("./hi", 0, $context, 50000); 36ini_set("magic_quotes_runtime", 1); 37echo file_get_contents("./hi"); 38echo file_get_contents("./hi", 0, $context, 0, 0); 39?> 40'); 41 42include $pname . '/foo/hi'; 43 44?> 45===DONE=== 46--CLEAN-- 47<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> 48<?php rmdir(dirname(__FILE__) . '/poo'); ?> 49<?php unlink(dirname(__FILE__) . '/foob'); ?> 50--EXPECTF-- 51Warning: file_get_contents() expects parameter 1 to be string, array given in %sfgc_edgecases.php on line %d 52blah 53<?php 54echo file_get_contents("foo/" . basename(__FILE__)); 55$context = stream_context_create(); 56file_get_contents("./hi", 0, $context, 0, -1); 57echo file_get_contents("foob"); 58set_include_path("%stests"); 59echo file_get_contents("foob", true); 60echo file_get_contents("./hi", 0, $context); 61echo file_get_contents("../oops"); 62echo file_get_contents("./hi", 0, $context, 50000); 63ini_set("magic_quotes_runtime", 1); 64echo file_get_contents("./hi"); 65echo file_get_contents("./hi", 0, $context, 0, 0); 66?> 67 68Warning: file_get_contents(): length must be greater than or equal to zero in phar://%sfgc_edgecases.phar.php/foo/hi on line %d 69test 70test 71<?php 72echo file_get_contents("foo/" . basename(__FILE__)); 73$context = stream_context_create(); 74file_get_contents("./hi", 0, $context, 0, -1); 75echo file_get_contents("foob"); 76set_include_path("%stests"); 77echo file_get_contents("foob", true); 78echo file_get_contents("./hi", 0, $context); 79echo file_get_contents("../oops"); 80echo file_get_contents("./hi", 0, $context, 50000); 81ini_set("magic_quotes_runtime", 1); 82echo file_get_contents("./hi"); 83echo file_get_contents("./hi", 0, $context, 0, 0); 84?> 85 86Warning: file_get_contents(phar://%sfgc_edgecases.phar.php/oops): failed to open stream: phar error: path "oops" is a directory in phar://%sfgc_edgecases.phar.php/foo/hi on line %d 87 88Warning: file_get_contents(): Failed to seek to position 50000 in the stream in phar://%sfgc_edgecases.phar.php/foo/hi on line %d 89<?php 90echo file_get_contents(\"foo/\" . basename(__FILE__)); 91$context = stream_context_create(); 92file_get_contents(\"./hi\", 0, $context, 0, -1); 93echo file_get_contents(\"foob\"); 94set_include_path(\"%stests\"); 95echo file_get_contents(\"foob\", true); 96echo file_get_contents(\"./hi\", 0, $context); 97echo file_get_contents(\"../oops\"); 98echo file_get_contents(\"./hi\", 0, $context, 50000); 99ini_set(\"magic_quotes_runtime\", 1); 100echo file_get_contents(\"./hi\"); 101echo file_get_contents(\"./hi\", 0, $context, 0, 0); 102?> 103===DONE=== 104