Location: PHPKode > projects > Pindorama > pindorama/active/components/streams.php
<?php
// streams
class pin_schemes { 
    var $position; 
    var $scheme; 
    var $content; 
    var $url; 
    var $request; 
    var $resource; 
    
    function stream_open($url, $mode, $options, &$opened_path) 
    { 
        $pathinfo = parse_url($url); 
        $this->scheme = $pathinfo["scheme"];
        $this->position = 0;
        $this->url = $url;
        $this->request = preg_replace("/^".$this->scheme."\:\/?/", "", $url);
        $this->resource = md5(rand() * time());
        if ($this->content[$this->url] == "") {
            $this->content[$this->url] = pin_xsl_schemes ($this->resource, $this->scheme, $this->request);
        }
        $mode = "read";
        if (function_exists("pin_".$mode."_".$this->scheme)) {
            return true;
        } else {
            return false;
        }
    } 
    
    function stream_read($count) 
    {
        $ret = substr($this->content[$this->url], $this->position, $count); 
        $this->position += strlen($ret);
        return $ret; 
    } 
    
    function stream_write($data) 
    { 
        $left = substr($GLOBALS[$this->varname], 0, $this->position); 
        $right = substr($GLOBALS[$this->varname], $this->position + strlen($data)); 
        $GLOBALS[$this->varname] = $left . $data . $right; 
        $this->position += strlen($data); 
        return strlen($data); 
    } 
    
    function stream_tell() 
    { 
        return $this->position; 
    } 
    
    function stream_eof() 
    { 
        return $this->position >= strlen($this->content[$this->url]); 
    } 
    function url_stat ($path) 
    { 
        return array(); 
    } 
    function stream_stat () 
    { 
        return array(); 
    } 
    
    function stream_seek($offset, $whence) 
    { 
        switch($whence) { 
            case SEEK_SET: 
                if ($offset < strlen($this->content[$this->url]) && $offset >= 0) { 
                     $this->position = $offset; 
                     return true; 
                } else { 
                     return false; 
                } 
                break; 
                 
            case SEEK_CUR: 
                if ($offset >= 0) { 
                     $this->position += $offset; 
                     return true; 
                } else { 
                     return false; 
                } 
                break; 
                 
            case SEEK_END: 
                if (strlen($this->content[$this->url]) + $offset >= 0) { 
                     $this->position = strlen($this->content[$this->url]) + $offset; 
                     return true; 
                } else { 
                     return false; 
                } 
                break; 
                 
            default: 
                return false; 
        } 
    } 
} 

$schemes = array("http", "odbc", "mysql", "tmp", "index", "styleshets", "content", "dtd", "db", "php", "phpxml", "include", "arg", "param");
foreach ($schemes as $scheme) {
    @stream_wrapper_register($scheme, "pin_schemes");
}
?>
Return current item: Pindorama