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