1--TEST-- 2allow_url_fopen disabled 3--INI-- 4allow_url_fopen=0 5allow_url_include=1 6--FILE-- 7<?php 8class test { 9 private $data = '<?php echo "Hello World\n";?>'; 10 private $pos; 11 private $stream = null; 12 13 function stream_open($path, $mode, $options, &$opened_path) 14 { 15 if (strpos($path, "test2://") === 0) { 16 $this->stream = fopen("test1://".substr($path, 8), $mode); 17 return !empty($this->stream); 18 } 19 if (strchr($mode, 'a')) 20 $this->pos = strlen($this->data); 21 else 22 $this->po = 0; 23 24 return true; 25 } 26 27 function stream_read($count) 28 { 29 if (!empty($this->stream)) { 30 return fread($this->stream, $count); 31 } 32 $ret = substr($this->data, $this->pos, $count); 33 $this->pos += strlen($ret); 34 return $ret; 35 } 36 37 function stream_tell() 38 { 39 if (!empty($this->stream)) { 40 return ftell($this->stream); 41 } 42 return $this->pos; 43 } 44 45 function stream_eof() 46 { 47 if (!empty($this->stream)) { 48 return feof($this->stream); 49 } 50 return $this->pos >= strlen($this->data); 51 } 52 53 function stream_seek($offset, $whence) 54 { 55 if (!empty($this->stream)) { 56 return fseek($this->stream, $offset, $whence); 57 } 58 switch($whence) { 59 case SEEK_SET: 60 if ($offset < $this->data && $offset >= 0) { 61 $this->pos = $offset; 62 return true; 63 } else { 64 return false; 65 } 66 break; 67 case SEEK_CUR: 68 if ($offset >= 0) { 69 $this->pos += $offset; 70 return true; 71 } else { 72 return false; 73 } 74 break; 75 case SEEK_END: 76 if (strlen($this->data) + $offset >= 0) { 77 $this->pos = strlen($this->data) + $offset; 78 return true; 79 } else { 80 return false; 81 } 82 break; 83 default: 84 return false; 85 } 86 } 87 88} 89 90stream_register_wrapper("test1", "test", STREAM_IS_URL); 91stream_register_wrapper("test2", "test"); 92echo file_get_contents("test1://hello"),"\n"; 93include "test1://hello"; 94echo file_get_contents("test2://hello"),"\n"; 95include "test2://hello"; 96--EXPECTF-- 97Warning: file_get_contents(): test1:// wrapper is disabled in the server configuration by allow_url_fopen=0 in %sinclude_userstream_003.php on line 86 98 99Warning: file_get_contents(test1://hello): failed to open stream: no suitable wrapper could be found in %sinclude_userstream_003.php on line 86 100 101 102Warning: include(): test1:// wrapper is disabled in the server configuration by allow_url_fopen=0 in %sinclude_userstream_003.php on line 87 103 104Warning: include(test1://hello): failed to open stream: no suitable wrapper could be found in %sinclude_userstream_003.php on line 87 105 106Warning: include(): Failed opening 'test1://hello' for inclusion (include_path='%s') in %sinclude_userstream_003.php on line 87 107 108Warning: fopen(): test1:// wrapper is disabled in the server configuration by allow_url_fopen=0 in %sinclude_userstream_003.php on line 10 109 110Warning: fopen(test1://hello): failed to open stream: no suitable wrapper could be found in %sinclude_userstream_003.php on line 10 111 112Warning: file_get_contents(test2://hello): failed to open stream: "test::stream_open" call failed in %sinclude_userstream_003.php on line 88 113 114 115Warning: fopen(): test1:// wrapper is disabled in the server configuration by allow_url_fopen=0 in %sinclude_userstream_003.php on line 10 116 117Warning: fopen(test1://hello): failed to open stream: no suitable wrapper could be found in %sinclude_userstream_003.php on line 10 118 119Warning: include(test2://hello): failed to open stream: "test::stream_open" call failed in %sinclude_userstream_003.php on line 89 120 121Warning: include(): Failed opening 'test2://hello' for inclusion (include_path='%s') in %sinclude_userstream_003.php on line 89