1--TEST--
2User streams and include()
3--INI--
4allow_url_fopen=1
5allow_url_include=0
6--FILE--
7<?php
8class test {
9    private $data = '<?php echo "Hello World\n";?>';
10	private $pos;
11
12	function stream_open($path, $mode, $options, &$opened_path)
13	{
14		if (strchr($mode, 'a'))
15			$this->pos = strlen($this->data);
16		else
17			$this->po = 0;
18
19		return true;
20	}
21
22	function stream_read($count)
23	{
24		$ret = substr($this->data, $this->pos, $count);
25		$this->pos += strlen($ret);
26		return $ret;
27	}
28
29	function stream_tell()
30	{
31		return $this->pos;
32	}
33
34	function stream_eof()
35	{
36		return $this->pos >= strlen($this->data);
37	}
38
39	function stream_seek($offset, $whence)
40	{
41		switch($whence) {
42			case SEEK_SET:
43				if ($offset < $this->data && $offset >= 0) {
44					$this->pos = $offset;
45					return true;
46				} else {
47					return false;
48				}
49				break;
50			case SEEK_CUR:
51				if ($offset >= 0) {
52					$this->pos += $offset;
53					return true;
54				} else {
55					return false;
56				}
57				break;
58			case SEEK_END:
59				if (strlen($this->data) + $offset >= 0) {
60					$this->pos = strlen($this->data) + $offset;
61					return true;
62				} else {
63					return false;
64				}
65				break;
66			default:
67				return false;
68		}
69	}
70
71}
72
73stream_register_wrapper("test1", "test", STREAM_IS_URL);
74stream_register_wrapper("test2", "test");
75echo @file_get_contents("test1://hello"),"\n";
76@include "test1://hello";
77echo @file_get_contents("test2://hello"),"\n";
78@include "test2://hello";
79--EXPECT--
80<?php echo "Hello World\n";?>
81<?php echo "Hello World\n";?>
82Hello World
83