[sync] stream seg fault test

Anthony Mills amills at gascard.net
Fri Dec 19 10:52:21 PST 2003


This doesn't work on my box.  I can send test.php or phpinfo() if need be.

Thanks,
Anthony
-------------- next part --------------
<?php
class Horde_RPC_GlobalVariableStream {

    var $_position;
    var $_varname;

    function stream_open($path, $mode, $options, &$opened_path)
    {
        $url = parse_url($path);
        $this->_varname = $url['host'];
        $this->_position = 0;

        return true;
    }

    function stream_read($count)
    {
        $ret = substr($GLOBALS[$this->_varname], $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($GLOBALS[$this->_varname]);
    }

    function stream_seek($offset, $whence)
    {
        switch ($whence) {
        case SEEK_SET:
            if ($offset < strlen($GLOBALS[$this->_varname]) && $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($GLOBALS[$this->_varname]) + $offset >= 0) {
                $this->_position = strlen($GLOBALS[$this->_varname]) + $offset;
                return true;
            } else {
                return false;
            }
            break;

        default:
            return false;
        }
    }

}

stream_wrapper_register('gvar', 'Horde_RPC_GlobalVariableStream');



        $GLOBALS['_wbxml'] = '';
        $fp = fopen('gvar://_wbxml', 'wb');
        
        $str = "GLOBALS[]fopen(gvar://_wbxml, wb)GLOBALS[]fopen(gvar://_wbxml, wb)GLOBALS[]fopen(gvar://_wbxml, wb)GLOBALS[]fopen(gvar://_wbxml, wb)GLOBALS[]fopen(gvar://_wbxml, wb)";
        fwrite($fp, $str);
        
        fclose();
        
        echo $_wbxml;
        
        
        
?>


More information about the sync mailing list