phpfilestream.php

Gesponsorde koppelingen

PHP script bestanden

  1. phpfilestream.php

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php

class PHPFileStream
{
    private $stream;
    
    public function stream_open($path, $mode, $options, &$opened_path)
    {

        $this->stream = fopen($this->_stripProtocol($path), $mode);
        
        return (bool) $this->stream;
    }

    
    public function stream_read($count)
    {

        // Als dit maar goed gaat, zo met $count niet kloppend.
        return str_replace('<?=', '<?php echo ', fread($this->stream, $count));
    }

    
    public function stream_write($data)
    {

        return fwrite($this->stream, $data);
    }

    
    public function stream_tell()
    {

        return ftell($this->stream);
    }

    
    public function stream_eof()
    {

        return feof($this->stream);
    }

    
    public function stream_seek($offset, $whence)
    {

        return fseek($this->stream, $offset, $whence);
    }

    
    public function stream_stat()
    {

        return fstat($this->stream);
    }

    
    public function url_stat($path, $flags)
    {

        return stat($this->_stripProtocol($path));
    }

    
    private function _stripProtocol($path)
    {

        return preg_replace('{^\w+://}', '', $path);
    }
}


stream_wrapper_register('phpfile', 'PHPFileStream');

function
phtml_file($file)
{

    if (ini_get('short_open_tags'))
        return $file;
    
    return 'phpfile://' . $file;
}

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.