diff --git a/lib/adodb/adodb-csvlib.inc.php b/lib/adodb/adodb-csvlib.inc.php index b4c497f0661..28295272772 100644 --- a/lib/adodb/adodb-csvlib.inc.php +++ b/lib/adodb/adodb-csvlib.inc.php @@ -8,7 +8,7 @@ $ADODB_INCLUDED_CSV = 1; /* - V4.66 28 Sept 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved. + V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. See License.txt. diff --git a/lib/adodb/adodb-datadict.inc.php b/lib/adodb/adodb-datadict.inc.php index e4b75a540c9..d96cacf6759 100644 --- a/lib/adodb/adodb-datadict.inc.php +++ b/lib/adodb/adodb-datadict.inc.php @@ -1,7 +1,7 @@ Connect(...); + $cnt = _adodb_getcount($conn, $sql); + */ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0) { @@ -595,9 +603,11 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq $discard = false; // not a good hack, improvements? if ($whereClause) { + #var_dump($whereClause); if (preg_match('/\s(ORDER\s.*)/is', $whereClause[1], $discard)); else if (preg_match('/\s(LIMIT\s.*)/is', $whereClause[1], $discard)); - else preg_match('/\s(FOR UPDATE.*)/is', $whereClause[1], $discard); + else if (preg_match('/\s(FOR UPDATE.*)/is', $whereClause[1], $discard)); + else preg_match('/\s.*(\) WHERE .*)/is', $whereClause[1], $discard); # see http://sourceforge.net/tracker/index.php?func=detail&aid=1379638&group_id=42718&atid=433976 } else $whereClause = array(false,false); @@ -919,11 +929,13 @@ function _adodb_debug_execute(&$zthis, $sql, $inputarr) $dbt = $zthis->databaseType; if (isset($zthis->dsnType)) $dbt .= '-'.$zthis->dsnType; if ($inBrowser) { - $ss = htmlspecialchars($ss); + if ($ss) { + $ss = ''.htmlspecialchars($ss).''; + } if ($zthis->debug === -1) - ADOConnection::outp( "
\n($dbt): ".htmlspecialchars($sqlTxt)."   $ss\n
\n",false); + ADOConnection::outp( "
\n($dbt): ".htmlspecialchars($sqlTxt)."   $ss\n
\n",false); else - ADOConnection::outp( "
\n($dbt): ".htmlspecialchars($sqlTxt)."   $ss\n
\n",false); + ADOConnection::outp( "
\n($dbt): ".htmlspecialchars($sqlTxt)."   $ss\n
\n",false); } else { ADOConnection::outp("-----\n($dbt): ".$sqlTxt."\n-----\n",false); } diff --git a/lib/adodb/adodb-pager.inc.php b/lib/adodb/adodb-pager.inc.php index d163e6a8d88..b9cce73751a 100644 --- a/lib/adodb/adodb-pager.inc.php +++ b/lib/adodb/adodb-pager.inc.php @@ -1,7 +1,7 @@ RenderGrid(); $footer = $this->RenderPageCount(); - $rs->Close(); - $this->rs = false; $this->RenderLayout($header,$grid,$footer); + + $rs->Close(); + $this->rs = false; } //------------------------------------------------------ diff --git a/lib/adodb/adodb-pear.inc.php b/lib/adodb/adodb-pear.inc.php index dc56c2d7577..1e0937d6e17 100644 --- a/lib/adodb/adodb-pear.inc.php +++ b/lib/adodb/adodb-pear.inc.php @@ -1,6 +1,6 @@ dataProvider == 'oci8' && $dbT != 'oci8po') { $isql = "insert into $perf_table values($d,:b,:c,:d,:e,:f)"; - } else if ($dbT == 'odbc_mssql' || $dbT == 'informix') { + } else if ($dbT == 'odbc_mssql' || $dbT == 'informix' || $dbT == 'odbtp') { $timer = $arr['f']; if ($dbT == 'informix') $sql2 = substr($sql2,0,230); @@ -588,7 +588,7 @@ Committed_AS: 348732 kB $rs = $this->conn->Execute($sql1); - if (isset($savem)) $this->SetFetchMode($savem); + if (isset($savem)) $this->conn->SetFetchMode($savem); $ADODB_FETCH_MODE = $save; if ($rs) { while (!$rs->EOF) { @@ -949,7 +949,7 @@ Committed_AS: 348732 kB return $arr; } - function undomq(&$m) + function undomq($m) { if (get_magic_quotes_gpc()) { // undo the damage diff --git a/lib/adodb/adodb-php4.inc.php b/lib/adodb/adodb-php4.inc.php index 626ef7b4141..76c00c6a3db 100644 --- a/lib/adodb/adodb-php4.inc.php +++ b/lib/adodb/adodb-php4.inc.php @@ -1,7 +1,7 @@ 1500; $i--) { -echo "
$i "; +echo "
$i "; adodb_date_test_date($i,1,1); } diff --git a/lib/adodb/adodb-xmlschema.inc.php b/lib/adodb/adodb-xmlschema.inc.php index 586c0df3950..c925f0b53d7 100644 --- a/lib/adodb/adodb-xmlschema.inc.php +++ b/lib/adodb/adodb-xmlschema.inc.php @@ -17,6 +17,20 @@ * @package axmls * @tutorial getting_started.pkg */ + +function _file_get_contents($file) +{ + if (function_exists('file_get_contents')) return file_get_contents($file); + + $f = fopen($file,'r'); + if (!$f) return ''; + $t = ''; + + while ($s = fread($f,100000)) $t .= $s; + fclose($f); + return $t; +} + /** * Debug on or off @@ -1429,6 +1443,10 @@ class adoSchema { if ( $returnSchema ) { + $xmlstring = ''; + while( $data = fread( $fp, 100000 ) ) { + $xmlstring .= $data; + } return $xmlstring; } @@ -1572,6 +1590,7 @@ class adoSchema { * @return array Array of SQL statements or FALSE if an error occurs */ function PrintSQL( $format = 'NONE' ) { + $sqlArray = null; return $this->getSQL( $format, $sqlArray ); } diff --git a/lib/adodb/adodb.inc.php b/lib/adodb/adodb.inc.php index 57b949b8655..de00b90ec94 100644 --- a/lib/adodb/adodb.inc.php +++ b/lib/adodb/adodb.inc.php @@ -14,7 +14,7 @@ /** \mainpage - @version V4.66 28 Sept 2005 (c) 2000-2005 John Lim (jlim#natsoft.com.my). All rights reserved. + @version V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. You can choose which license you prefer. @@ -171,7 +171,7 @@ /** * ADODB version as a string. */ - $ADODB_vers = 'V4.66 28 Sept 2005 (c) 2000-2005 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.'; + $ADODB_vers = 'V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.'; /** * Determines whether recordset->RecordCount() is used. @@ -314,7 +314,6 @@ var $_evalAll = false; var $_affected = false; var $_logsql = false; - /** @@ -1497,11 +1496,67 @@ return $rs; } + /** * Flush cached recordsets that match a particular $sql statement. * If $sql == false, then we purge all files in the cache. */ - function CacheFlush($sql=false,$inputarr=false) + + /** + * Flush cached recordsets that match a particular $sql statement. + * If $sql == false, then we purge all files in the cache. + */ + function CacheFlush($sql=false,$inputarr=false) + { + global $ADODB_CACHE_DIR; + + if (strlen($ADODB_CACHE_DIR) > 1 && !$sql) { + /*if (strncmp(PHP_OS,'WIN',3) === 0) + $dir = str_replace('/', '\\', $ADODB_CACHE_DIR); + else */ + $dir = $ADODB_CACHE_DIR; + + if ($this->debug) { + ADOConnection::outp( "CacheFlush: $dir
\n", $this->_dirFlush($dir),"
"); + } else { + $this->_dirFlush($dir); + } + return; + } + + global $ADODB_INCLUDED_CSV; + if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php'); + + $f = $this->_gencachename($sql.serialize($inputarr),false); + adodb_write_file($f,''); // is adodb_write_file needed? + if (!@unlink($f)) { + if ($this->debug) ADOConnection::outp( "CacheFlush: failed for $f"); + } + } + + /** + * Private function to erase all of the files and subdirectories in a directory. + * + * Just specify the directory, and tell it if you want to delete the directory or just clear it out. + * Note: $kill_top_level is used internally in the function to flush subdirectories. + */ + function _dirFlush($dir, $kill_top_level = false) { + if(!$dh = @opendir($dir)) return; + + while (($obj = readdir($dh))) { + if($obj=='.' || $obj=='..') + continue; + + if (!@unlink($dir.'/'.$obj)) + $this->_dirFlush($dir.'/'.$obj, true); + } + if ($kill_top_level === true) + @rmdir($dir); + return true; + } + + + function xCacheFlush($sql=false,$inputarr=false) { global $ADODB_CACHE_DIR; @@ -2032,13 +2087,13 @@ * List columns in a database as an array of ADOFieldObjects. * See top of file for definition of object. * - * @param table table name to query - * @param upper uppercase table name (required by some databases) + * @param $table table name to query + * @param $normalize makes table name case-insensitive (required by some databases) * @schema is optional database schema to use - not supported by all databases. * * @return array of ADOFieldObjects for current table. */ - function &MetaColumns($table,$upper=true) + function &MetaColumns($table,$normalize=true) { global $ADODB_FETCH_MODE; @@ -2052,7 +2107,7 @@ $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); - $rs = $this->Execute(sprintf($this->metaColumnsSQL,($upper)?strtoupper($table):$table)); + $rs = $this->Execute(sprintf($this->metaColumnsSQL,($normalize)?strtoupper($table):$table)); if (isset($savem)) $this->SetFetchMode($savem); $ADODB_FETCH_MODE = $save; if ($rs === false || $rs->EOF) return $false; @@ -3367,7 +3422,7 @@ return 'B'; case 'D': - if (!empty($this->datetime)) return 'T'; + if (!empty($this->connection) && !empty($this->connection->datetime)) return 'T'; return 'D'; default: @@ -3669,9 +3724,23 @@ if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2); $errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false; $false = false; - if (strpos($db,'://')) { + if ($at = strpos($db,'://')) { $origdsn = $db; - $dsna = @parse_url($db); + if (PHP_VERSION < 5) $dsna = @parse_url($db); + else { + $fakedsn = 'fake'.substr($db,$at); + $dsna = @parse_url($fakedsn); + $dsna['scheme'] = substr($db,0,$at); + + if (strncmp($db,'pdo',3) == 0) { + $sch = explode('_',$dsna['scheme']); + if (sizeof($sch)>1) { + $dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : ''; + $dsna['host'] = rawurlencode($sch[1].':host='.rawurldecode($dsna['host'])); + $dsna['scheme'] = 'pdo'; + } + } + } if (!$dsna) { // special handling of oracle, which might not have host @@ -3792,7 +3861,14 @@ } switch($drivername) { - case 'mysqli': $drivername='mysql'; break; + case 'mysqlt': + case 'mysqli': + $drivername='mysql'; + break; + case 'postgres7': + case 'postgres8': + $drivername = 'postgres'; + break; case 'firebird15': $drivername = 'firebird'; break; case 'oracle': $drivername = 'oci8'; break; case 'access': if ($perf) $drivername = ''; break; diff --git a/lib/adodb/datadict/datadict-access.inc.php b/lib/adodb/datadict/datadict-access.inc.php index 280d4de04c6..946be4fe4d5 100644 --- a/lib/adodb/datadict/datadict-access.inc.php +++ b/lib/adodb/datadict/datadict-access.inc.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/lib/adodb/datadict/datadict-sapdb.inc.php b/lib/adodb/datadict/datadict-sapdb.inc.php index de6fe35bb43..8458a64a332 100644 --- a/lib/adodb/datadict/datadict-sapdb.inc.php +++ b/lib/adodb/datadict/datadict-sapdb.inc.php @@ -1,7 +1,7 @@ FetchRow()) { $index = $row[0]; if (!isset($indexes[$index])) { @@ -225,7 +225,7 @@ class ADODB_ibase extends ADOConnection { 'columns' => array() ); } - $sql = "SELECT * FROM RDB\$INDEX_SEGMENTS WHERE RDB\$INDEX_NAME = '".$name."' ORDER BY RDB\$FIELD_POSITION ASC"; + $sql = "SELECT * FROM RDB\$INDEX_SEGMENTS WHERE RDB\$INDEX_NAME = '".$index."' ORDER BY RDB\$FIELD_POSITION ASC"; $rs1 = $this->Execute($sql); while ($row1 = $rs1->FetchRow()) { $indexes[$index]['columns'][$row1[2]] = $row1[1]; diff --git a/lib/adodb/drivers/adodb-informix.inc.php b/lib/adodb/drivers/adodb-informix.inc.php index 0ffc21aba4c..fa5368cfa59 100644 --- a/lib/adodb/drivers/adodb-informix.inc.php +++ b/lib/adodb/drivers/adodb-informix.inc.php @@ -1,6 +1,6 @@ _has_mssql_init) { ADOConnection::outp( "Parameter: mssql_bind only available since PHP 4.1.0"); - return $sql; + return false; } $isNull = is_null($var); // php 4.0.4 and above... diff --git a/lib/adodb/drivers/adodb-mssqlpo.inc.php b/lib/adodb/drivers/adodb-mssqlpo.inc.php index 4d47c1911dc..8a72bcd5d7c 100644 --- a/lib/adodb/drivers/adodb-mssqlpo.inc.php +++ b/lib/adodb/drivers/adodb-mssqlpo.inc.php @@ -1,6 +1,6 @@ metaTablesSQL; @@ -308,6 +309,10 @@ class ADODB_mysql extends ADOConnection { $s .= '%w'; break; + case 'W': + $s .= '%U'; + break; + case 'l': $s .= '%W'; break; @@ -534,7 +539,7 @@ class ADODB_mysql extends ADOConnection { } // "Innox - Juan Carlos Gonzalez" - function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $asociative = FALSE ) + function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $associative = FALSE ) { if ( !empty($owner) ) { $table = "$owner.$table"; @@ -560,7 +565,7 @@ class ADODB_mysql extends ADOConnection { $foreign_keys[$ref_table] = array(); $num_fields = count($my_field); for ( $j = 0; $j < $num_fields; $j ++ ) { - if ( $asociative ) { + if ( $associative ) { $foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j]; } else { $foreign_keys[$ref_table][] = "{$my_field[$j]}={$ref_field[$j]}"; @@ -622,8 +627,8 @@ class ADORecordSet_mysql extends ADORecordSet{ } else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */ $o = @mysql_fetch_field($this->_queryID); - $o->max_length = @mysql_field_len($this->_queryID); // suggested by: Jim Nicholson (jnich@att.com) - //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable + $o->max_length = @mysql_field_len($this->_queryID); // suggested by: Jim Nicholson (jnich@att.com) + //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable } return $o; diff --git a/lib/adodb/drivers/adodb-mysqli.inc.php b/lib/adodb/drivers/adodb-mysqli.inc.php index 89b40eb303b..47830391186 100644 --- a/lib/adodb/drivers/adodb-mysqli.inc.php +++ b/lib/adodb/drivers/adodb-mysqli.inc.php @@ -1,6 +1,6 @@ transCnt==0) $this->BeginTrans(); + if ($where) $where = ' where '.$where; + $rs =& $this->Execute("select $flds from $tables $where for update"); + return !empty($rs); + } + // if magic quotes disabled, use mysql_real_escape_string() // From readme.htm: // Quotes a string to be sent to the database. The $magic_quotes_enabled @@ -433,7 +443,7 @@ class ADODB_mysqli extends ADOConnection { } // "Innox - Juan Carlos Gonzalez" - function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $asociative = FALSE ) + function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $associative = FALSE ) { if ( !empty($owner) ) { $table = "$owner.$table"; @@ -459,7 +469,7 @@ class ADODB_mysqli extends ADOConnection { $foreign_keys[$ref_table] = array(); $num_fields = count($my_field); for ( $j = 0; $j < $num_fields; $j ++ ) { - if ( $asociative ) { + if ( $associative ) { $foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j]; } else { $foreign_keys[$ref_table][] = "{$my_field[$j]}={$ref_field[$j]}"; @@ -659,6 +669,45 @@ class ADODB_mysqli extends ADOConnection { } + + // this is a set of functions for managing client encoding - very important if the encodings + // of your database and your output target (i.e. HTML) don't match + // for instance, you may have UTF8 database and server it on-site as latin1 etc. + // GetCharSet - get the name of the character set the client is using now + // Under Windows, the functions should work with MySQL 4.1.11 and above, the set of charsets supported + // depends on compile flags of mysql distribution + + function GetCharSet() + { + //we will use ADO's builtin property charSet + if (!is_callable($this->_connectionID,'character_set_name')) + return false; + + $this->charSet = @$this->_connectionID->character_set_name(); + if (!$this->charSet) { + return false; + } else { + return $this->charSet; + } + } + + // SetCharSet - switch the client encoding + function SetCharSet($charset_name) + { + if (!is_callable($this->_connectionID,'set_charset')) + return false; + + if ($this->charSet !== $charset_name) { + $if = @$this->_connectionID->set_charset($charset_name); + if ($if == "0" & $this->GetCharSet() == $charset_name) { + return true; + } else return false; + } else return true; + } + + + + } /*-------------------------------------------------------------------------------------- @@ -704,22 +753,50 @@ class ADORecordSet_mysqli extends ADORecordSet{ $this->_numOfFields = @mysqli_num_fields($this->_queryID); } +/* +1 = MYSQLI_NOT_NULL_FLAG +2 = MYSQLI_PRI_KEY_FLAG +4 = MYSQLI_UNIQUE_KEY_FLAG +8 = MYSQLI_MULTIPLE_KEY_FLAG +16 = MYSQLI_BLOB_FLAG +32 = MYSQLI_UNSIGNED_FLAG +64 = MYSQLI_ZEROFILL_FLAG +128 = MYSQLI_BINARY_FLAG +256 = MYSQLI_ENUM_FLAG +512 = MYSQLI_AUTO_INCREMENT_FLAG +1024 = MYSQLI_TIMESTAMP_FLAG +2048 = MYSQLI_SET_FLAG +32768 = MYSQLI_NUM_FLAG +16384 = MYSQLI_PART_KEY_FLAG +32768 = MYSQLI_GROUP_FLAG +65536 = MYSQLI_UNIQUE_FLAG +131072 = MYSQLI_BINCMP_FLAG +*/ + function &FetchField($fieldOffset = -1) { - $fieldnr = $fieldOffset; - if ($fieldOffset != -1) { - $fieldOffset = mysqli_field_seek($this->_queryID, $fieldnr); - } - $o = mysqli_fetch_field($this->_queryID); - return $o; + $fieldnr = $fieldOffset; + if ($fieldOffset != -1) { + $fieldOffset = mysqli_field_seek($this->_queryID, $fieldnr); + } + $o = mysqli_fetch_field($this->_queryID); + /* Properties of an ADOFieldObject as set by MetaColumns */ + $o->primary_key = $o->flags & MYSQLI_PRI_KEY_FLAG; + $o->not_null = $o->flags & MYSQLI_NOT_NULL_FLAG; + $o->auto_increment = $o->flags & MYSQLI_AUTO_INCREMENT_FLAG; + $o->binary = $o->flags & MYSQLI_BINARY_FLAG; + // $o->blob = $o->flags & MYSQLI_BLOB_FLAG; /* not returned by MetaColumns */ + $o->unsigned = $o->flags & MYSQLI_UNSIGNED_FLAG; + + return $o; } function &GetRowAssoc($upper = true) { - if ($this->fetchMode == MYSQLI_ASSOC && !$upper) - return $this->fields; - $row =& ADORecordSet::GetRowAssoc($upper); - return $row; + if ($this->fetchMode == MYSQLI_ASSOC && !$upper) + return $this->fields; + $row =& ADORecordSet::GetRowAssoc($upper); + return $row; } /* Use associative array to get fields array */ diff --git a/lib/adodb/drivers/adodb-mysqlt.inc.php b/lib/adodb/drivers/adodb-mysqlt.inc.php index af74cae0b4f..4e5ad64a4eb 100644 --- a/lib/adodb/drivers/adodb-mysqlt.inc.php +++ b/lib/adodb/drivers/adodb-mysqlt.inc.php @@ -1,7 +1,7 @@ transCnt==0) $this->BeginTrans(); - return $this->GetOne("select $flds from $tables where $where for update"); + if ($where) $where = ' where '.$where; + $rs =& $this->Execute("select $flds from $tables $where for update"); + return !empty($rs); } } diff --git a/lib/adodb/drivers/adodb-netezza.inc.php b/lib/adodb/drivers/adodb-netezza.inc.php index d238de330aa..ef4dced5fa7 100644 --- a/lib/adodb/drivers/adodb-netezza.inc.php +++ b/lib/adodb/drivers/adodb-netezza.inc.php @@ -1,6 +1,6 @@ port)? "1521" : $this->port; } if ($this->connectSID) { @@ -504,6 +504,10 @@ NATSOFT.DOMAIN = $s .= 'DAY'; break; + case 'W': + $s .= 'WW'; + break; + default: // handle escape characters... if ($ch == '\\') { @@ -793,6 +797,7 @@ NATSOFT.DOMAIN = if (is_array($stmt) && sizeof($stmt) >= 5) { $hasref = true; + $ignoreCur = false; $this->Parameter($stmt, $ignoreCur, $cursorName, false, -1, OCI_B_CURSOR); if ($params) { foreach($params as $k => $v) { diff --git a/lib/adodb/drivers/adodb-oci805.inc.php b/lib/adodb/drivers/adodb-oci805.inc.php index d795577621b..64824c571fe 100644 --- a/lib/adodb/drivers/adodb-oci805.inc.php +++ b/lib/adodb/drivers/adodb-oci805.inc.php @@ -1,6 +1,6 @@ Execute(sprintf($this->metaColumnsSQL,strtoupper($table))); if ($rs === false) { $false = false; diff --git a/lib/adodb/drivers/adodb-odbtp.inc.php b/lib/adodb/drivers/adodb-odbtp.inc.php index c7d068ddba0..cffb2f95641 100644 --- a/lib/adodb/drivers/adodb-odbtp.inc.php +++ b/lib/adodb/drivers/adodb-odbtp.inc.php @@ -1,6 +1,6 @@ EOF) { //print_r($rs->fields); if (strtoupper($rs->fields[2]) == $table) { @@ -326,7 +327,7 @@ class ADODB_odbtp extends ADOConnection{ $fld->default_value = $rs->fields[12]; } $retarr[strtoupper($fld->name)] = $fld; - } else if (sizeof($retarr)>0) + } else if (!empty($retarr)) break; $rs->MoveNext(); } @@ -518,6 +519,8 @@ class ADODB_odbtp extends ADOConnection{ function _query($sql,$inputarr=false) { + global $php_errormsg; + if ($inputarr) { if (is_array($sql)) { $stmtid = $sql[1]; diff --git a/lib/adodb/drivers/adodb-odbtp_unicode.inc.php b/lib/adodb/drivers/adodb-odbtp_unicode.inc.php index 65a5b27e5be..acc3393017d 100644 --- a/lib/adodb/drivers/adodb-odbtp_unicode.inc.php +++ b/lib/adodb/drivers/adodb-odbtp_unicode.inc.php @@ -1,6 +1,6 @@ _bindInputArray = false; + $parentDriver->_bindInputArray = true; #$parentDriver->_connectionID->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true); } @@ -77,7 +81,7 @@ class ADODB_pdo_base extends ADODB_pdo { return ADOConnection::ServerInfo(); } - function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) + function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) { $ret = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); return $ret; @@ -135,6 +139,12 @@ class ADODB_pdo extends ADOConnection { function Time() { + if (!empty($this->_driver->_hasdual)) $sql = "select $this->sysTimeStamp from dual"; + else $sql = "select $this->sysTimeStamp"; + + $rs =& $this->_Execute($sql); + if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields)); + return false; } @@ -144,6 +154,9 @@ class ADODB_pdo extends ADOConnection { $at = strpos($argDSN,':'); $this->dsnType = substr($argDSN,0,$at); + if ($argDatabasename) { + $argDSN .= ';dbname='.$argDatabasename; + } try { $this->_connectionID = new PDO($argDSN, $argUsername, $argPassword); } catch (Exception $e) { @@ -171,6 +184,7 @@ class ADODB_pdo extends ADOConnection { case 'oci': case 'mysql': case 'pgsql': + case 'mssql': include_once(ADODB_DIR.'/drivers/adodb-pdo_'.$this->dsnType.'.inc.php'); break; } @@ -196,10 +210,11 @@ class ADODB_pdo extends ADOConnection { /*------------------------------------------------------------------------------*/ - function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) + function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) { $save = $this->_driver->fetchMode; $this->_driver->fetchMode = $this->fetchMode; + $this->_driver->debug = $this->debug; $ret = $this->_driver->SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); $this->_driver->fetchMode = $save; return $ret; @@ -321,6 +336,7 @@ class ADODB_pdo extends ADOConnection { } if ($stmt) { + $this->_driver->debug = $this->debug; if ($inputarr) $ok = $stmt->execute($inputarr); else $ok = $stmt->execute(); } diff --git a/lib/adodb/drivers/adodb-pdo_mssql.inc.php b/lib/adodb/drivers/adodb-pdo_mssql.inc.php new file mode 100644 index 00000000000..f888982c136 --- /dev/null +++ b/lib/adodb/drivers/adodb-pdo_mssql.inc.php @@ -0,0 +1,50 @@ +hasTransactions = false; ## <<< BUG IN PDO mssql driver + $parentDriver->_bindInputArray = false; + $parentDriver->hasInsertID = true; + } + + function ServerInfo() + { + return ADOConnection::ServerInfo(); + } + + function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) + { + $ret = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); + return $ret; + } + + function MetaTables() + { + return false; + } + + function MetaColumns() + { + return false; + } + +} +?> \ No newline at end of file diff --git a/lib/adodb/drivers/adodb-pdo_mysql.inc.php b/lib/adodb/drivers/adodb-pdo_mysql.inc.php index a968f865d35..76ba0ce0986 100644 --- a/lib/adodb/drivers/adodb-pdo_mysql.inc.php +++ b/lib/adodb/drivers/adodb-pdo_mysql.inc.php @@ -2,7 +2,7 @@ /* -V4.66 28 Sept 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved. +V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. @@ -21,7 +21,7 @@ class ADODB_pdo_mysql extends ADODB_pdo { { $parentDriver->hasTransactions = false; - $parentDriver->_bindInputArray = false; + $parentDriver->_bindInputArray = true; $parentDriver->hasInsertID = true; $parentDriver->_connectionID->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true); } diff --git a/lib/adodb/drivers/adodb-pdo_oci.inc.php b/lib/adodb/drivers/adodb-pdo_oci.inc.php index 6167daa70a3..1f73a44896f 100644 --- a/lib/adodb/drivers/adodb-pdo_oci.inc.php +++ b/lib/adodb/drivers/adodb-pdo_oci.inc.php @@ -2,7 +2,7 @@ /* -V4.66 28 Sept 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved. +V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. @@ -21,10 +21,11 @@ class ADODB_pdo_oci extends ADODB_pdo_base { var $metaColumnsSQL = "select cname,coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"; var $_initdate = true; + var $_hasdual = true; function _init($parentDriver) { - $parentDriver->_bindInputArray = false; + $parentDriver->_bindInputArray = true; if ($this->_initdate) { $parentDriver->Execute("ALTER SESSION SET NLS_DATE_FORMAT='".$this->NLS_DATE_FORMAT."'"); diff --git a/lib/adodb/drivers/adodb-pdo_pgsql.inc.php b/lib/adodb/drivers/adodb-pdo_pgsql.inc.php index f4644a5fb6a..7e0ec362bd6 100644 --- a/lib/adodb/drivers/adodb-pdo_pgsql.inc.php +++ b/lib/adodb/drivers/adodb-pdo_pgsql.inc.php @@ -1,7 +1,7 @@ hasTransactions = false; + $parentDriver->hasTransactions = false; ## <<< BUG IN PDO pgsql driver $parentDriver->hasInsertID = true; } diff --git a/lib/adodb/drivers/adodb-postgres.inc.php b/lib/adodb/drivers/adodb-postgres.inc.php index 2424574b907..597b8794070 100644 --- a/lib/adodb/drivers/adodb-postgres.inc.php +++ b/lib/adodb/drivers/adodb-postgres.inc.php @@ -1,6 +1,6 @@ replaceQuote[0] == '\\'){ - $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s); + $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\\000"),$s); } return "'".str_replace("'",$this->replaceQuote,$s)."'"; } @@ -250,7 +250,7 @@ select viewname,'V' from pg_views where viewname like $mask"; $s = str_replace('\\"','"',$s); return "'$s'"; } - */ + // Format date column in sql string given an input format that understands Y M D @@ -312,7 +312,11 @@ select viewname,'V' from pg_views where viewname like $mask"; case 'l': $s .= 'DAY'; break; - + + case 'W': + $s .= 'WW'; + break; + default: // handle escape characters... if ($ch == '\\') { @@ -357,6 +361,22 @@ select viewname,'V' from pg_views where viewname like $mask"; return $rez; } + /* + * Deletes/Unlinks a Blob from the database, otherwise it + * will be left behind + * + * Returns TRUE on success or FALSE on failure. + * + * contributed by Todd Rogers todd#windfox.net + */ + function BlobDelete( $blob ) + { + pg_exec ($this->_connectionID, "begin"); + $result = @pg_lo_unlink($blob); + pg_exec ($this->_connectionID, "commit"); + return( $result ); + } + /* Hueristic - not guaranteed to work. */ @@ -393,7 +413,7 @@ select viewname,'V' from pg_views where viewname like $mask"; @pg_loclose($fd); if ($hastrans) @pg_exec($this->_connectionID,"commit"); return $realblob; - } + } /* See http://www.postgresql.org/idocs/index.php?datatype-binary.html @@ -439,6 +459,7 @@ select viewname,'V' from pg_views where viewname like $mask"; // for schema support, pass in the $table param "$schema.$tabname". // converts field names to lowercase, $upper is ignored + // see http://phplens.com/lens/lensforum/msgs.php?id=14018 for more info function &MetaColumns($table,$normalize=true) { global $ADODB_FETCH_MODE; @@ -525,9 +546,8 @@ select viewname,'V' from pg_views where viewname like $mask"; } //Freek - if ($rs->fields[4] == 't') { - $fld->not_null = true; - } + $fld->not_null = $rs->fields[4] == 't'; + // Freek if (is_array($keys)) { @@ -621,7 +641,7 @@ WHERE (c2.relname=\'%s\' or c2.relname=lower(\'%s\'))'; function _connect($str,$user='',$pwd='',$db='',$ctype=0) { - if (!function_exists('pg_pconnect')) return null; + if (!function_exists('pg_connect')) return null; $this->_errorMsg = false; diff --git a/lib/adodb/drivers/adodb-postgres7.inc.php b/lib/adodb/drivers/adodb-postgres7.inc.php index 644dc83e47a..aac39603cb1 100644 --- a/lib/adodb/drivers/adodb-postgres7.inc.php +++ b/lib/adodb/drivers/adodb-postgres7.inc.php @@ -1,6 +1,6 @@ _connectionID,substr($sql, 0, strlen($sql)-2), $inputarr); + + $rez = pg_query_params($this->_connectionID,$sql, $inputarr); } else { $rez = pg_query($this->_connectionID,$sql); } diff --git a/lib/adodb/drivers/adodb-postgres8.inc.php b/lib/adodb/drivers/adodb-postgres8.inc.php index 88fae3be80e..9de5a04f869 100644 --- a/lib/adodb/drivers/adodb-postgres8.inc.php +++ b/lib/adodb/drivers/adodb-postgres8.inc.php @@ -1,6 +1,6 @@ Execute("select * from $tab limit 1"); - if (!$rs) { - $false = false; - return $false; - } - $arr = array(); - for ($i=0,$max=$rs->_numOfFields; $i < $max; $i++) { - $fld =& $rs->FetchField($i); - if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] =& $fld; - else $arr[strtoupper($fld->name)] =& $fld; - } - $rs->Close(); - return $arr; - } function _createFunctions() { diff --git a/lib/adodb/drivers/adodb-sqlitepo.inc.php b/lib/adodb/drivers/adodb-sqlitepo.inc.php index ae72d034db5..9edc0f61dfb 100644 --- a/lib/adodb/drivers/adodb-sqlitepo.inc.php +++ b/lib/adodb/drivers/adodb-sqlitepo.inc.php @@ -1,6 +1,6 @@ Connect($host,$uid,$pwd,$database)) err($conn->ErrorNo(). $sep . $conn->ErrorMsg()); +$sql = undomq($_REQUEST['sql']); + +if (isset($_REQUEST['fetch'])) + $ADODB_FETCH_MODE = $_REQUEST['fetch']; + +if (isset($_REQUEST['nrows'])) { + $nrows = $_REQUEST['nrows']; + $offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : -1; + $rs = $conn->SelectLimit($sql,$nrows,$offset); +} else + $rs = $conn->Execute($sql); +if ($rs){ + //$rs->timeToLive = 1; + echo _rs2serialize($rs,$conn,$sql); + $rs->Close(); +} else + err($conn->ErrorNo(). $sep .$conn->ErrorMsg()); ?> \ No newline at end of file diff --git a/lib/adodb/session/adodb-compress-bzip2.php b/lib/adodb/session/adodb-compress-bzip2.php index d184a03ad39..230993cbf7e 100644 --- a/lib/adodb/session/adodb-compress-bzip2.php +++ b/lib/adodb/session/adodb-compress-bzip2.php @@ -1,7 +1,7 @@ quote($key); $binary = $conn->dataProvider === 'mysql' ? '/*! BINARY */' : ''; - $sql = "SELECT $data FROM $table WHERE $binary sesskey = $qkey AND expiry >= " . time(); + $sql = "SELECT $data FROM $table WHERE sesskey = $binary $qkey AND expiry >= " . time(); /* Lock code does not work as it needs to hold transaction within whole page, and we don't know if developer has commited elsewhere... :( */ @@ -901,7 +901,7 @@ class ADODB_Session { } ADODB_Session::_init(); - +register_shutdown_function('session_write_close'); // for backwards compatability only function adodb_sess_open($save_path, $session_name, $persist = true) { diff --git a/lib/adodb/session/crypt.inc.php b/lib/adodb/session/crypt.inc.php index 7266ab619df..41cb06a5ad7 100644 --- a/lib/adodb/session/crypt.inc.php +++ b/lib/adodb/session/crypt.inc.php @@ -1,64 +1,161 @@ - -class MD5Crypt{ - function keyED($txt,$encrypt_key) - { - $encrypt_key = md5($encrypt_key); - $ctr=0; - $tmp = ""; - for ($i=0;$ikeyED($tmp,$key)); - } - - function Decrypt($txt,$key) - { - $txt = $this->keyED(base64_decode($txt),$key); - $tmp = ""; - for ($i=0;$i= 58 && $randnumber <= 64) || ($randnumber >= 91 && $randnumber <= 96)) - { - $randnumber = rand(48,120); - } - - $randomPassword .= chr($randnumber); - } - return $randomPassword; - } - -} + +class MD5Crypt{ + function keyED($txt,$encrypt_key) + { + $encrypt_key = md5($encrypt_key); + $ctr=0; + $tmp = ""; + for ($i=0;$ikeyED($tmp,$key)); + } + + function Decrypt($txt,$key) + { + $txt = $this->keyED(base64_decode($txt),$key); + $tmp = ""; + for ($i=0;$i= 58 && $randnumber <= 64) || ($randnumber >= 91 && $randnumber <= 96)) + { + $randnumber = rand(48,120); + } + + $randomPassword .= chr($randnumber); + } + return $randomPassword; + } + +} + + +class SHA1Crypt{ + + function keyED($txt,$encrypt_key) + { + + $encrypt_key = sha1($encrypt_key); + $ctr=0; + $tmp = ""; + + for ($i=0;$ikeyED($tmp,$key)); + + } + + + + function Decrypt($txt,$key) + { + + $txt = $this->keyED(base64_decode($txt),$key); + + $tmp = ""; + + for ($i=0;$i= 58 && $randnumber <= 64) || ($randnumber >= 91 && $randnumber <= 96)) + { + $randnumber = rand(48,120); + } + + $randomPassword .= chr($randnumber); + } + + return $randomPassword; + + } + + + +} ?> \ No newline at end of file diff --git a/lib/adodb/toexport.inc.php b/lib/adodb/toexport.inc.php index d02ed4831c8..b9195d2c0a2 100644 --- a/lib/adodb/toexport.inc.php +++ b/lib/adodb/toexport.inc.php @@ -1,7 +1,7 @@