From cb2bc809ef29f349d38c89e202d821e67bb4c947 Mon Sep 17 00:00:00 2001 From: thomascube <thomas@roundcube.net> Date: Tue, 21 Sep 2010 14:47:55 -0400 Subject: [PATCH] Fix db_mode check in insert_id() --- program/lib/MDB2/LOB.php | 152 +++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 135 insertions(+), 17 deletions(-) diff --git a/program/lib/MDB2/LOB.php b/program/lib/MDB2/LOB.php old mode 100755 new mode 100644 index c17abc9..ff2342d --- a/program/lib/MDB2/LOB.php +++ b/program/lib/MDB2/LOB.php @@ -2,7 +2,7 @@ // +----------------------------------------------------------------------+ // | PHP version 5 | // +----------------------------------------------------------------------+ -// | Copyright (c) 1998-2004 Manuel Lemos, Tomas V.V.Cox, | +// | Copyright (c) 1998-2006 Manuel Lemos, Tomas V.V.Cox, | // | Stig. S. Bakken, Lukas Smith | // | All rights reserved. | // +----------------------------------------------------------------------+ @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id$ +// $Id: LOB.php 222350 2006-10-25 11:52:21Z lsmith $ /** * @package MDB2 @@ -52,67 +52,144 @@ require_once 'MDB2.php'; +/** + * MDB2_LOB: user land stream wrapper implementation for LOB support + * + * @package MDB2 + * @category Database + * @author Lukas Smith <smith@pooteeweet.org> + */ class MDB2_LOB { + /** + * contains the key to the global MDB2 instance array of the associated + * MDB2 instance + * + * @var integer + * @access protected + */ var $db_index; - var $lob_index; - var $lob; + /** + * contains the key to the global MDB2_LOB instance array of the associated + * MDB2_LOB instance + * + * @var integer + * @access protected + */ + var $lob_index; + + // {{{ stream_open() + + /** + * open stream + * + * @param string specifies the URL that was passed to fopen() + * @param string the mode used to open the file + * @param int holds additional flags set by the streams API + * @param string not used + * + * @return bool + * @access public + */ function stream_open($path, $mode, $options, &$opened_path) { if (!preg_match('/^rb?\+?$/', $mode)) { return false; } $url = parse_url($path); - if (!array_key_exists('host', $url) && !array_key_exists('user', $url)) { + if (empty($url['host'])) { return false; } - $this->db_index = $url['host']; + $this->db_index = (int)$url['host']; if (!isset($GLOBALS['_MDB2_databases'][$this->db_index])) { return false; } $db =& $GLOBALS['_MDB2_databases'][$this->db_index]; - $this->lob_index = $url['user']; + $this->lob_index = (int)$url['user']; if (!isset($db->datatype->lobs[$this->lob_index])) { return false; } - $this->lob =& $db->datatype->lobs[$this->lob_index]; - $db->datatype->_retrieveLOB($this->lob); return true; } + // }}} + // {{{ stream_read() + + /** + * read stream + * + * @param int number of bytes to read + * + * @return string + * @access public + */ function stream_read($count) { if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) { $db =& $GLOBALS['_MDB2_databases'][$this->db_index]; + $db->datatype->_retrieveLOB($db->datatype->lobs[$this->lob_index]); - $data = $db->datatype->_readLOB($this->lob, $count); + $data = $db->datatype->_readLOB($db->datatype->lobs[$this->lob_index], $count); $length = strlen($data); if ($length == 0) { - $this->lob['endOfLOB'] = true; + $db->datatype->lobs[$this->lob_index]['endOfLOB'] = true; } - $this->lob['position'] += $length; + $db->datatype->lobs[$this->lob_index]['position'] += $length; return $data; } - } + } + // }}} + // {{{ stream_write() + + /** + * write stream, note implemented + * + * @param string data + * + * @return int + * @access public + */ function stream_write($data) { return 0; } + // }}} + // {{{ stream_tell() + + /** + * return the current position + * + * @return int current position + * @access public + */ function stream_tell() { - return $this->lob['position']; + if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) { + $db =& $GLOBALS['_MDB2_databases'][$this->db_index]; + return $db->datatype->lobs[$this->lob_index]['position']; + } } + // }}} + // {{{ stream_eof() + + /** + * Check if stream reaches EOF + * + * @return bool + * @access public + */ function stream_eof() { if (!isset($GLOBALS['_MDB2_databases'][$this->db_index])) { return true; } + $db =& $GLOBALS['_MDB2_databases'][$this->db_index]; - $result = $db->datatype->_endOfLOB($this->lob); + $result = $db->datatype->_endOfLOB($db->datatype->lobs[$this->lob_index]); if (version_compare(phpversion(), "5.0", ">=") && version_compare(phpversion(), "5.1", "<") ) { @@ -120,27 +197,68 @@ } return $result; } + // }}} + // {{{ stream_seek() + + /** + * Seek stream, not implemented + * + * @param int offset + * @param int whence + * + * @return bool + * @access public + */ function stream_seek($offset, $whence) { return false; } + // }}} + // {{{ stream_stat() + + /** + * return information about stream + * + * @access public + */ + function stream_stat() + { + if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) { + $db =& $GLOBALS['_MDB2_databases'][$this->db_index]; + return array( + 'db_index' => $this->db_index, + 'lob_index' => $this->lob_index, + ); + } + } + // }}} + + // {{{ stream_close() + + /** + * close stream + * + * @access public + */ function stream_close() { if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) { $db =& $GLOBALS['_MDB2_databases'][$this->db_index]; if (isset($db->datatype->lobs[$this->lob_index])) { - $db->datatype->_destroyLOB($this->lob_index); + $db->datatype->_destroyLOB($db->datatype->lobs[$this->lob_index]); unset($db->datatype->lobs[$this->lob_index]); } } } + // }}} } +// register streams wrapper if (!stream_wrapper_register("MDB2LOB", "MDB2_LOB")) { MDB2::raiseError(); return false; } -?> \ No newline at end of file +?> -- Gitblit v1.9.1