From f8fa64feb0a33b5712c8822a6fc58de918dcdaa4 Mon Sep 17 00:00:00 2001
From: chriskl Host=".$argHostname." Host=".$argHostname." \$HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']} Session Update: '.$ADODB_SESS_CONN->ErrorMsg().' Session Insert: '.$ADODB_SESS_CONN->ErrorMsg().' \$HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']}
version=$dbc->version
version=$dbc->version
';
+ $adors->MoveNext();
+ }
+ $adors->Close();
+ }
+
+ return $arr;
+ }
+
+ function MetaColumns($table)
+ {
+ $table = strtoupper($table);
+ $arr= array();
+ $dbc = $this->_connectionID;
+
+ $adors=@$dbc->OpenSchema(4);//tables
+
+ if ($adors){
+ $t = $adors->Fields(2);//table/view name
+ while (!$adors->EOF){
+
+
+ if (strtoupper($t->Value) == $table) {
+
+ $fld = new ADOFieldObject();
+ $c = $adors->Fields(3);
+ $fld->name = $c->Value;
+ $fld->type = 'CHAR'; // cannot discover type in ADO!
+ $fld->max_length = -1;
+ $arr[strtoupper($fld->name)]=$fld;
+ }
+
+ $adors->MoveNext();
+ }
+ $adors->Close();
+ }
+
+ return $arr;
+ }
+
+ /* returns queryID or false */
+ function &_query($sql,$inputarr=false)
+ {
+
+ $dbc = $this->_connectionID;
+
+ // return rs
+ if ($inputarr) {
+ $oCmd = new COM('ADODB.Command');
+ $oCmd->ActiveConnection = $dbc;
+ $oCmd->CommandText = $sql;
+ $oCmd->CommandType = 1;
+
+ foreach($inputarr as $val) {
+ // name, type, direction 1 = input, len,
+ $this->adoParameterType = 130;
+ $p = $oCmd->CreateParameter('name',$this->adoParameterType,1,strlen($val),$val);
+ //print $p->Type.' '.$p->value;
+ $oCmd->Parameters->Append($p);
+ }
+ $p = false;
+ $rs = $oCmd->Execute();
+ $e = $dbc->Errors;
+ if ($dbc->Errors->Count > 0) return false;
+ return $rs;
+ }
+
+ $rs = @$dbc->Execute($sql,$this->_affectedRows);
+
+ if ($dbc->Errors->Count > 0) return false;
+ return $rs;
+ }
+
+
+ function BeginTrans()
+ {
+ $o = $this->_connectionID->Properties("Transaction DDL");
+ if (!$o) return false;
+ @$this->_connectionID->BeginTrans();
+ return true;
+ }
+ function CommitTrans() {
+ @$this->_connectionID->CommitTrans();
+ return true;
+ }
+ function RollbackTrans() {
+ @$this->_connectionID->RollbackTrans();
+ return true;
+ }
+
+ /* Returns: the last error message from previous database operation */
+
+ function ErrorMsg()
+ {
+ $errc = $this->_connectionID->Errors;
+ if ($errc->Count == 0) return '';
+ $err = $errc->Item($errc->Count-1);
+ return $err->Description;
+ }
+
+ function ErrorNo()
+ {
+ $errc = $this->_connectionID->Errors;
+ if ($errc->Count == 0) return 0;
+ $err = $errc->Item($errc->Count-1);
+ return $err->NativeError;
+ }
+
+ // returns true or false
+ function _close()
+ {
+ if ($this->_connectionID) $this->_connectionID->Close();
+ $this->_connectionID = false;
+ return true;
+ }
+
+
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordSet_ado extends ADORecordSet {
+
+ var $bind = false;
+ var $databaseType = "ado";
+ var $dataProvider = "ado";
+ var $_tarr = false; // caches the types
+ var $_flds; // and field objects
+ var $canSeek = true;
+ var $hideErrors = true;
+
+ function ADORecordSet_ado(&$id)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $this->fetchMode = $ADODB_FETCH_MODE;
+ return $this->ADORecordSet($id);
+ }
+
+
+ // returns the field object
+ function FetchField($fieldOffset = -1) {
+ $off=$fieldOffset+1; // offsets begin at 1
+
+ $o= new ADOFieldObject();
+ $rs = $this->_queryID;
+ $f = $rs->Fields($fieldOffset);
+ $o->name = $f->Name;
+ $o->type = $f->Type;
+ $o->max_length = $f->DefinedSize;
+
+ //print "off=$off name=$o->name type=$o->type len=$o->max_length
";
+ return $o;
+ }
+
+ /* Use associative array to get fields array */
+ function Fields($colname)
+ {
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ $this->bind[strtoupper($o->name)] = $i;
+ }
+ }
+
+ return $this->fields[$this->bind[strtoupper($colname)]];
+ }
+
+
+ function _initrs()
+ {
+ $rs = $this->_queryID;
+ $this->_numOfRows = $rs->RecordCount;
+
+ $f = $rs->Fields;
+ $this->_numOfFields = $f->Count;
+ }
+
+
+ // should only be used to move forward as we normally use forward-only cursors
+ function _seek($row)
+ {
+ $rs = $this->_queryID;
+ // absoluteposition doesn't work -- my maths is wrong ?
+ // $rs->AbsolutePosition->$row-2;
+ // return true;
+ if ($this->_currentRow > $row) return false;
+ $rs->Move((integer)$row - $this->_currentRow-1); //adBookmarkFirst
+ return true;
+ }
+
+/*
+ OLEDB types
+
+ enum DBTYPEENUM
+ { DBTYPE_EMPTY = 0,
+ DBTYPE_NULL = 1,
+ DBTYPE_I2 = 2,
+ DBTYPE_I4 = 3,
+ DBTYPE_R4 = 4,
+ DBTYPE_R8 = 5,
+ DBTYPE_CY = 6,
+ DBTYPE_DATE = 7,
+ DBTYPE_BSTR = 8,
+ DBTYPE_IDISPATCH = 9,
+ DBTYPE_ERROR = 10,
+ DBTYPE_BOOL = 11,
+ DBTYPE_VARIANT = 12,
+ DBTYPE_IUNKNOWN = 13,
+ DBTYPE_DECIMAL = 14,
+ DBTYPE_UI1 = 17,
+ DBTYPE_ARRAY = 0x2000,
+ DBTYPE_BYREF = 0x4000,
+ DBTYPE_I1 = 16,
+ DBTYPE_UI2 = 18,
+ DBTYPE_UI4 = 19,
+ DBTYPE_I8 = 20,
+ DBTYPE_UI8 = 21,
+ DBTYPE_GUID = 72,
+ DBTYPE_VECTOR = 0x1000,
+ DBTYPE_RESERVED = 0x8000,
+ DBTYPE_BYTES = 128,
+ DBTYPE_STR = 129,
+ DBTYPE_WSTR = 130,
+ DBTYPE_NUMERIC = 131,
+ DBTYPE_UDT = 132,
+ DBTYPE_DBDATE = 133,
+ DBTYPE_DBTIME = 134,
+ DBTYPE_DBTIMESTAMP = 135
+
+ ADO Types
+
+ adEmpty = 0,
+ adTinyInt = 16,
+ adSmallInt = 2,
+ adInteger = 3,
+ adBigInt = 20,
+ adUnsignedTinyInt = 17,
+ adUnsignedSmallInt = 18,
+ adUnsignedInt = 19,
+ adUnsignedBigInt = 21,
+ adSingle = 4,
+ adDouble = 5,
+ adCurrency = 6,
+ adDecimal = 14,
+ adNumeric = 131,
+ adBoolean = 11,
+ adError = 10,
+ adUserDefined = 132,
+ adVariant = 12,
+ adIDispatch = 9,
+ adIUnknown = 13,
+ adGUID = 72,
+ adDate = 7,
+ adDBDate = 133,
+ adDBTime = 134,
+ adDBTimeStamp = 135,
+ adBSTR = 8,
+ adChar = 129,
+ adVarChar = 200,
+ adLongVarChar = 201,
+ adWChar = 130,
+ adVarWChar = 202,
+ adLongVarWChar = 203,
+ adBinary = 128,
+ adVarBinary = 204,
+ adLongVarBinary = 205,
+ adChapter = 136,
+ adFileTime = 64,
+ adDBFileTime = 137,
+ adPropVariant = 138,
+ adVarNumeric = 139
+*/
+ function MetaType($t,$len=-1)
+ {
+ switch ($t) {
+ case 12: // variant
+ case 8: // bstr
+ case 129: //char
+ case 130: //wc
+ case 200: // varc
+ case 202:// varWC
+ case 128: // bin
+ case 204: // varBin
+ case 72: // guid
+ if ($len <= $this->blobSize) return 'C';
+
+ case 201:
+ case 203:
+ return 'X';
+ case 128:
+ case 204:
+ case 205:
+ return 'B';
+ case 7:
+ case 133: return 'D';
+
+ case 134:
+ case 135: return 'T';
+
+ case 11: return 'L';
+
+ case 16:// adTinyInt = 16,
+ case 2://adSmallInt = 2,
+ case 3://adInteger = 3,
+ case 4://adBigInt = 20,
+ case 17://adUnsignedTinyInt = 17,
+ case 18://adUnsignedSmallInt = 18,
+ case 19://adUnsignedInt = 19,
+ case 20://adUnsignedBigInt = 21,
+ return 'I';
+ default: return 'N';
+ }
+ }
+
+ // time stamp not supported yet
+ function _fetch()
+ {
+ $rs = $this->_queryID;
+ if ($rs->EOF) return false;
+ $this->fields = array();
+
+ if (!$this->_tarr) {
+ $tarr = array();
+ $flds = array();
+ for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) {
+ $f = $rs->Fields($i);
+ $flds[] = $f;
+ $tarr[] = $f->Type;
+ }
+ // bind types and flds only once
+ $this->_tarr = $tarr;
+ $this->_flds = $flds;
+ }
+ $t = reset($this->_tarr);
+ $f = reset($this->_flds);
+
+ if ($this->hideErrors) $olde = error_reporting(E_ERROR|E_CORE_ERROR);// sometimes $f->value be null
+ for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) {
+
+ switch($t) {
+
+ case 133:// A date value (yyyymmdd)
+ $val = $f->value;
+ $this->fields[] = substr($val,0,4).'-'.substr($val,4,2).'-'.substr($val,6,2);
+ break;
+ case 7: // adDate
+ $this->fields[] = date('Y-m-d',(integer)$f->value);
+ break;
+ case 1: // null
+ $this->fields[] = false;
+ break;
+ case 6: // currency is not supported properly;
+ print '
'.$f->Name.': currency type not supported by PHP
';
+ $this->fields[] = (float) $f->value;
+ break;
+ default:
+ $this->fields[] = $f->value;
+ break;
+ }
+ //print " $f->value $t, ";
+ $f = next($this->_flds);
+ $t = next($this->_tarr);
+ } // for
+ if ($this->hideErrors) error_reporting($olde);
+ @$rs->MoveNext(); // @ needed for some versions of PHP!
+
+ if ($this->fetchMode == ADODB_FETCH_ASSOC) {
+ $this->fields = $this->GetRowAssoc(false);
+ }
+ return true;
+ }
+
+
+ function _close() {
+ $this->_flds = false;
+ $this->_queryID = false;
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/libraries/adodb/adodb-ado_access.inc.php b/libraries/adodb/adodb-ado_access.inc.php
new file mode 100755
index 00000000..3a087e3b
--- /dev/null
+++ b/libraries/adodb/adodb-ado_access.inc.php
@@ -0,0 +1,38 @@
+ADORecordSet_ado($id);
+ }
+}
+?>
\ No newline at end of file
diff --git a/libraries/adodb/adodb-ado_mssql.inc.php b/libraries/adodb/adodb-ado_mssql.inc.php
new file mode 100755
index 00000000..024da4ca
--- /dev/null
+++ b/libraries/adodb/adodb-ado_mssql.inc.php
@@ -0,0 +1,36 @@
+ADORecordSet_ado($id);
+ }
+}
+?>
\ No newline at end of file
diff --git a/libraries/adodb/adodb-cryptsession.php b/libraries/adodb/adodb-cryptsession.php
new file mode 100755
index 00000000..e13c2e42
--- /dev/null
+++ b/libraries/adodb/adodb-cryptsession.php
@@ -0,0 +1,245 @@
+
+ Set tabs to 4 for best viewing.
+
+ Latest version of ADODB is available at http://php.weblogs.com/adodb
+ ======================================================================
+
+ This file provides PHP4 session management using the ADODB database
+wrapper library.
+
+ Example
+ =======
+
+ GLOBAL $HTTP_SESSION_VARS;
+ include('adodb.inc.php');
+ include('adodb-session.php');
+ session_start();
+ session_register('AVAR');
+ $HTTP_SESSION_VARS['AVAR'] += 1;
+ print "Session Error: PHP.INI setting session.gc_maxlifetimenot set: $ADODB_SESS_LIFE
";
+ $ADODB_SESS_LIFE=1440;
+}
+
+function adodb_sess_open($save_path, $session_name)
+{
+GLOBAL $ADODB_SESSION_CONNECT,
+ $ADODB_SESSION_DRIVER,
+ $ADODB_SESSION_USER,
+ $ADODB_SESSION_PWD,
+ $ADODB_SESSION_DB,
+ $ADODB_SESS_CONN,
+ $ADODB_SESS_DEBUG;
+
+ $ADODB_SESS_INSERT = false;
+
+ if (isset($ADODB_SESS_CONN)) return true;
+
+ $ADODB_SESS_CONN = ADONewConnection($ADODB_SESSION_DRIVER);
+ if (!empty($ADODB_SESS_DEBUG)) {
+ $ADODB_SESS_CONN->debug = true;
+ print" conn=$ADODB_SESSION_CONNECT user=$ADODB_SESSION_USER pwd=$ADODB_SESSION_PWD db=$ADODB_SESSION_DB ";
+ }
+ return $ADODB_SESS_CONN->PConnect($ADODB_SESSION_CONNECT,
+ $ADODB_SESSION_USER,$ADODB_SESSION_PWD,$ADODB_SESSION_DB);
+
+}
+
+function adodb_sess_close()
+{
+global $ADODB_SESS_CONN;
+
+ if ($ADODB_SESS_CONN) $ADODB_SESS_CONN->Close();
+ return true;
+}
+
+function adodb_sess_read($key)
+{
+$Crypt = new MD5Crypt;
+global $ADODB_SESS_CONN,$ADODB_SESS_INSERT,$ADODB_SESSION_TBL;
+ $rs = $ADODB_SESS_CONN->Execute("SELECT data FROM $ADODB_SESSION_TBL WHERE sesskey = '$key' AND expiry >= " . time());
+ if ($rs) {
+ if ($rs->EOF) {
+ $ADODB_SESS_INSERT = true;
+ $v = '';
+ } else {
+ // Decrypt session data
+ $v = rawurldecode($Crypt->Decrypt($rs->fields[0], ADODB_Session_Key()));
+ }
+ $rs->Close();
+ return $v;
+ }
+ else $ADODB_SESS_INSERT = true;
+
+ return false;
+}
+
+function adodb_sess_write($key, $val)
+{
+$Crypt = new MD5Crypt;
+ global $ADODB_SESS_INSERT,$ADODB_SESS_CONN, $ADODB_SESS_LIFE, $ADODB_SESSION_TBL;
+
+ $expiry = time() + $ADODB_SESS_LIFE;
+
+ // encrypt session data..
+ $val = $Crypt->Encrypt(rawurlencode($val), ADODB_Session_Key());
+ $qry = "UPDATE $ADODB_SESSION_TBL SET expiry=$expiry,data='$val' WHERE sesskey='$key'";
+ $rs = $ADODB_SESS_CONN->Execute($qry);
+ if ($rs) $rs->Close();
+ else print '
$err
";
+
+ $at = strpos($err,'::::');
+ if ($at === false) {
+ $this->_errorMsg = $err;
+ $this->_errorNo = (integer)$err;
+ } else {
+ $this->_errorMsg = substr($err,$at+4,1024);
+ $this->_errorNo = -9999;
+ }
+ if (is_object($rs)) {
+ $rs->databaseType='csv';
+ }
+ return $rs;
+ }
+
+ // returns queryID or false
+ function Execute($sql,$inputarr=false,$arg3=false)
+ {
+ $url = $this->_url.'?sql='.urlencode($sql);
+ if ($arg3) $url .= "&arg3=".urlencode($arg3);
+ $err = false;
+
+ $rs = csv2rs($url,$err,false);
+ if ($this->debug) print urldecode($url)."
$err
";
+ $at = strpos($err,'::::');
+ if ($at === false) {
+ $this->_errorMsg = $err;
+ $this->_errorNo = (integer)$err;
+ } else {
+ $this->_errorMsg = substr($err,$at+4,1024);
+ $this->_errorNo = -9999;
+ }
+ if (is_object($rs)) {
+ $this->_affectedrows = $rs->affectedrows;
+ $this->_insertid = $rs->insertid;
+ $rs->databaseType='csv';
+ }
+ return $rs;
+ }
+
+ /* Returns: the last error message from previous database operation */
+ function ErrorMsg()
+ {
+ return $this->_errorMsg;
+ }
+
+ /* Returns: the last error number from previous database operation */
+ function ErrorNo()
+ {
+ return $this->_errorNo;
+ }
+
+ // returns true or false
+ function _close()
+ {
+ return true;
+ }
+} // class
+
+class ADORecordset_csv extends ADORecordset {
+ function ADORecordset_csv($id)
+ {
+ $this->ADORecordset($id);
+ }
+
+ function _close()
+ {
+ return true;
+ }
+}
+
+} // define
+
+?>
\ No newline at end of file
diff --git a/libraries/adodb/adodb-db2.inc.php b/libraries/adodb/adodb-db2.inc.php
new file mode 100755
index 00000000..7bf57026
--- /dev/null
+++ b/libraries/adodb/adodb-db2.inc.php
@@ -0,0 +1,163 @@
+_connectionID = odbc_connect($argDSN,$argUsername,$argPassword);
+ $this->_errorMsg = $php_errormsg;
+
+ //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
+ return $this->_connectionID != false;
+ }
+ // returns true or false
+ function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
+ {
+ global $php_errormsg;
+ $php_errormsg = '';
+ $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword);
+ $this->_errorMsg = $php_errormsg;
+
+ //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
+ return $this->_connectionID != false;
+ }
+
+ function &SelectLimit($sql,$nrows=-1,$offset=-1,$arg3=false)
+ {
+ if ($offset <= 0) {
+ // could also use " OPTIMIZE FOR $nrows ROWS "
+ $sql .= " FETCH FIRST $nrows ROWS ONLY ";
+ return $this->Execute($sql,false,$arg3);
+ } else
+ return ADOConnection::SelectLimit($sql,$nrows,$offset,$arg3);
+ }
+
+};
+
+
+class ADORecordSet_db2 extends ADORecordSet_odbc {
+
+ var $databaseType = "db2";
+
+ function ADORecordSet_db2($id)
+ {
+ $this->ADORecordSet_odbc($id);
+ }
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ switch (strtoupper($t)) {
+ case 'VARCHAR':
+ case 'CHAR':
+ case 'CHARACTER':
+ if ($len <= $this->blobSize) return 'C';
+
+ case 'LONGCHAR':
+ case 'TEXT':
+ case 'CLOB':
+ case 'DBCLOB': // double-byte
+ return 'X';
+
+ case 'BLOB':
+ case 'GRAPHIC':
+ case 'VARGRAPHIC':
+ return 'B';
+
+ case 'DATE':
+ return 'D';
+
+ case 'TIME':
+ case 'TIMESTAMP':
+ return 'T';
+
+ //case 'BOOLEAN':
+ //case 'BIT':
+ // return 'L';
+
+ //case 'COUNTER':
+ // return 'R';
+
+ case 'INT':
+ case 'INTEGER':
+ case 'BIGINT':
+ case 'SMALLINT':
+ return 'I';
+
+ default: return 'N';
+ }
+ }
+}
+
+} //define
+?>
\ No newline at end of file
diff --git a/libraries/adodb/adodb-errorhandler.inc.php b/libraries/adodb/adodb-errorhandler.inc.php
new file mode 100755
index 00000000..71e7449c
--- /dev/null
+++ b/libraries/adodb/adodb-errorhandler.inc.php
@@ -0,0 +1,73 @@
+$s
Too many parameters to ibase query $sql
"; + case 5: $ret = ibase_query($this->_transactionID,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4]); break; + } + } else $ret = ibase_query($this->_transactionID,$sql); + } else { + if (is_array($iarr)) { + switch(sizeof($iarr)) { + case 1: $ret = ibase_query($this->_connectionID,$sql,$iarr[0]); break; + case 2: $ret = ibase_query($this->_connectionID,$sql,$iarr[0],$iarr[1]); break; + case 3: $ret = ibase_query($this->_connectionID,$sql,$iarr[0],$iarr[1],$iarr[2]); break; + case 4: $ret = ibase_query($this->_connectionID,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3]); break; + default: print "Too many parameters to ibase query $sql
"; + case 5: $ret = ibase_query($this->_connectionID,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4]); break; + + } + } else $ret = ibase_query($this->_connectionID,$sql); + if ($ret === true) ibase_commit($this->_connectionID); + } + $this->_handleerror(); + return $ret; + } + + // returns true or false + function _close() + { + if ($this->autoCommit) ibase_commit($this->_connectionID); + else ibase_rollback($this->_connectionID); + + return @ibase_close($this->_connectionID); + } + + // returns array of ADOFieldObjects for current table + function &MetaColumns($table) + { + + if ($this->metaColumnsSQL) { + + $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table))); + if ($rs === false) return false; + + $retarr = array(); + while (!$rs->EOF) { //print_r($rs->fields); + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[0]; + $tt = $rs->fields[1]; + switch($tt) + { + case 7: + case 8: + case 9:$tt = 'INTEGER'; break; + case 10: + case 27: + case 11:$tt = 'FLOAT'; break; + default: + case 40: + case 14:$tt = 'CHAR'; break; + case 35:$tt = 'DATE'; break; + case 37:$tt = 'VARCHAR'; break; + case 261:$tt = 'BLOB'; break; + case 13: + case 35:$tt = 'TIMESTAMP'; break; + } + $fld->type = $tt; + $fld->max_length = $rs->fields[2]; + $retarr[strtoupper($fld->name)] = $fld; + + $rs->MoveNext(); + } + $rs->Close(); + return $retarr; + } + return false; + } + + // warning - this code is experimental and might not be available in the future + function &BlobEncode( $blob ) + { + $blobid = ibase_blob_create( $this->_connectionID); + ibase_blob_add( $blobid, $blob ); + return ibase_blob_close( $blobid ); + } + + // warning - this code is experimental and might not be available in the future + function &BlobDecode( $blob ) + { + $blobid = ibase_blob_open( $blob ); + $realblob = ibase_blob_get( $blobid,299999); // 2nd param is max size of blob -- Kevin BoilletConnect: 1st argument should be left blank for $this->databaseType
"; + $this->_connectionID = OCIlogon($argUsername,$argPassword, $argDatabasename); + if ($this->_connectionID === false) return false; + if ($this->_initdate) { + $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'"); + } + return true; + } + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + if($argHostname) { // added by Jorma TuomainenConnect: 1st argument should be left blank for $this->databaseType
"; + $this->_connectionID = ora_logon($argUsername,$argPassword); + if ($this->_connectionID === false) return false; + if ($this->autoCommit) ora_commiton($this->_connectionID); + if ($this->_initdate) $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'"); + + return true; + } + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + if ($argHostname) putenv("ORACLE_HOME=$argHostname"); + //if ($argHostname) print "PConnect: 1st argument should be left blank for $this->databaseType
"; + $this->_connectionID = ora_plogon($argUsername,$argPassword); + if ($this->_connectionID === false) return false; + if ($this->autoCommit) ora_commiton($this->_connectionID); + if ($this->_initdate) $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'"); + + return true; + } + + // returns query ID if successful, otherwise false + function _query($sql,$inputarr) + { + $curs = ora_open($this->_connectionID); + + if ($curs === false) return false; + $this->_curs = $curs; + if (!ora_parse($curs,$sql)) return false; + if (ora_exec($curs)) return $curs; + + @ora_close($curs); + return false; + } + + // returns true or false + function _close() + { + if (!$this->autoCommit) ora_rollback($this->_connectionID); + return @ora_close($this->_connectionID); + } + + +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordset_oracle extends ADORecordSet { + + var $databaseType = "oracle"; + var $bind = false; + + function ADORecordset_oracle($queryID) + { + $this->_queryID = $queryID; + + $this->_inited = true; + $this->fields = array(); + if ($queryID) { + $this->_currentRow = 0; + $this->EOF = !$this->_fetch(); + @$this->_initrs(); + } else { + $this->_numOfRows = 0; + $this->_numOfFields = 0; + $this->EOF = true; + } + + return $this->_queryID; + } + + + + /* Returns: an object containing field information. + Get column information in the Recordset object. fetchField() can be used in order to obtain information about + fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by + fetchField() is retrieved. */ + + function FetchField($fieldOffset = -1) + { + $fld = new ADOFieldObject; + $fld->name = ora_columnname($this->_queryID, $fieldOffset); + $fld->type = ora_columntype($this->_queryID, $fieldOffset); + $fld->max_length = ora_columnsize($this->_queryID, $fieldOffset); + return $fld; + } + + /* Use associative array to get fields array */ + function Fields($colname) + { + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + + return $this->fields[$this->bind[strtoupper($colname)]]; + + } + + function _initrs() + { + $this->_numOfRows = -1; + $this->_numOfFields = @ora_numcols($this->_queryID); + } + + + function _seek($row) + { + return false; + } + + function _fetch($ignore_fields=false) { + // should remove call by reference, but ora_fetch_into requires it in 4.0.3pl1 + return @ora_fetch_into($this->_queryID,&$this->fields,ORA_FETCHINTO_NULLS); + } + + /* close() only needs to be called if you are worried about using too much memory while your script + is running. All associated result memory for the specified result identifier will automatically be freed. */ + + function _close() { + return @ora_close($this->_queryID); + } + + function MetaType($t,$len=-1) + { + switch (strtoupper($t)) { + case 'VARCHAR': + case 'VARCHAR2': + case 'CHAR': + case 'VARBINARY': + case 'BINARY': + if ($len <= $this->blobSize) return 'C'; + case 'LONG': + case 'LONG VARCHAR': + case 'CLOB': + return 'X'; + case 'LONG RAW': + case 'LONG VARBINARY': + case 'BLOB': + return 'B'; + + case 'DATE': return 'D'; + + //case 'T': return 'T'; + + case 'BIT': return 'L'; + case 'INT': + case 'SMALLINT': + case 'INTEGER': return 'I'; + default: return 'N'; + } + } +} +?> \ No newline at end of file diff --git a/libraries/adodb/adodb-pear.inc.php b/libraries/adodb/adodb-pear.inc.php new file mode 100755 index 00000000..6d8385d9 --- /dev/null +++ b/libraries/adodb/adodb-pear.inc.php @@ -0,0 +1,348 @@ + | + * and Tomas V.V.CoxSession Update: '.$ADODB_SESS_CONN->ErrorMsg().'
'; + + if ($ADODB_SESS_INSERT || $rs === false) { + $qry = "INSERT INTO $ADODB_SESSION_TBL(sesskey,expiry,data) VALUES ('$key',$expiry,'$val')"; + $rs = $ADODB_SESS_CONN->Execute($qry); + if ($rs) $rs->Close(); + else print 'Session Insert: '.$ADODB_SESS_CONN->ErrorMsg().'
'; + } + // bug in access driver (could be odbc?) means that info is not commited + // properly unless select statement executed in Win2000 + if ($ADODB_SESS_CONN->databaseType == 'access') $rs = $ADODB_SESS_CONN->Execute("select sesskey from $ADODB_SESSION_TBL WHERE sesskey='$key'"); + + return isset($rs); +} + +function adodb_sess_destroy($key) +{ + global $ADODB_SESS_CONN, $ADODB_SESSION_TBL; + + $qry = "DELETE FROM $ADODB_SESSION_TBL WHERE sesskey = '$key'"; + $rs = $ADODB_SESS_CONN->Execute($qry); + if ($rs) $rs->Close(); + return $rs; +} + +function adodb_sess_gc($maxlifetime) { + global $ADODB_SESS_CONN, $ADODB_SESSION_TBL; + + $qry = "DELETE FROM $ADODB_SESSION_TBL WHERE expiry < " . time(); + $rs = $ADODB_SESS_CONN->Execute($qry); + if ($rs) $rs->Close(); + + // suggested by Cameron, "GaM3R"\$HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']}
"; +} + +?> diff --git a/libraries/adodb/adodb-sybase.inc.php b/libraries/adodb/adodb-sybase.inc.php new file mode 100755 index 00000000..1bd01b00 --- /dev/null +++ b/libraries/adodb/adodb-sybase.inc.php @@ -0,0 +1,215 @@ +Execute('select @@identity'); + if ($rs == false || $rs->EOF) return false; + $id = $rs->fields[0]; + $rs->Close(); + return $id; + } + // might require begintrans -- committrans + function _affectedrows() + { + $rs = $this->Execute('select @@rowcount'); + if ($rs == false || $rs->EOF) return false; + $id = $rs->fields[0]; + $rs->Close(); + return $id; + } + + + function BeginTrans() + { + $this->Execute('BEGIN TRAN'); + return true; + } + + function CommitTrans() + { + $this->Execute('COMMIT TRAN'); + return true; + } + + function RollbackTrans() + { + $this->Execute('ROLLBACK TRAN'); + return true; + } + + + function SelectDB($dbName) { + $this->databaseName = $dbName; + if ($this->_connectionID) { + return @sybase_select_db($dbName); + } + else return false; + } + + /* Returns: the last error message from previous database operation + Note: This function is NOT available for Microsoft SQL Server. */ + + function ErrorMsg() { + $this->_errorMsg = sybase_get_last_message(); + return $this->_errorMsg; + } + + // returns true or false + function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + $this->_connectionID = sybase_connect($argHostname,$argUsername,$argPassword); + if ($this->_connectionID === false) return false; + if ($argDatabasename) return $this->SelectDB($argDatabasename); + return true; + } + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + $this->_connectionID = sybase_pconnect($argHostname,$argUsername,$argPassword); + if ($this->_connectionID === false) return false; + if ($argDatabasename) return $this->SelectDB($argDatabasename); + return true; + } + + // returns query ID if successful, otherwise false + function _query($sql,$inputarr) + { + //@sybase_free_result($this->_queryID); + return sybase_query($sql,$this->_connectionID); + } + + // returns true or false + function _close() + { + return @sybase_close($this->_connectionID); + } + + +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ +global $ADODB_sybase_mths; +$ADODB_sybase_mths = array('JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12); + +class ADORecordset_sybase extends ADORecordSet { + + var $databaseType = "sybase"; + var $canSeek = true; + // _mths works only in non-localised system + var $_mths = array('JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12); + + function ADORecordset_sybase($id) + { + return $this->ADORecordSet($id); + } + + + /* Returns: an object containing field information. + Get column information in the Recordset object. fetchField() can be used in order to obtain information about + fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by + fetchField() is retrieved. */ + function &FetchField($fieldOffset = -1) + { + if ($fieldOffset != -1) { + $o = @sybase_fetch_field($this->_queryID, $fieldOffset); + } + else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */ + $o = @sybase_fetch_field($this->_queryID); + } + // older versions of PHP did not support type, only numeric + if ($o && !isset($o->type)) $o->type = ($o->numeric) ? 'float' : 'varchar'; + return $o; + } + + function _initrs() + { + global $ADODB_COUNTRECS; + $this->_numOfRows = ($ADODB_COUNTRECS)? @sybase_num_rows($this->_queryID):-1; + $this->_numOfFields = @sybase_num_fields($this->_queryID); + } + + function _seek($row) + { + return @sybase_data_seek($this->_queryID, $row); + } + + function _fetch($ignore_fields=false) { + $this->fields = @sybase_fetch_array($this->_queryID); + return ($this->fields == true); + } + + /* close() only needs to be called if you are worried about using too much memory while your script + is running. All associated result memory for the specified result identifier will automatically be freed. */ + function _close() { + return @sybase_free_result($this->_queryID); + } + + // sybase/mssql uses a default date like Dec 30 2000 12:00AM + function UnixDate($v) + { + global $ADODB_sybase_mths; + //Dec 30 2000 12:00AM + // added fix by Toni for day 15 Mar 2001 + if (!ereg( "([A-Za-z]{3})[-/\. ]([0-9 ]{1,2})[-/\. ]([0-9]{4}))" + ,$v, $rr)) return parent::UnixDate($v); + + if ($rr[3] <= 1970) return 0; + + $themth = substr(strtoupper($rr[1]),0,3); + $themth = $ADODB_sybase_mths[$themth]; + if ($themth <= 0) return false; + // h-m-s-MM-DD-YY + return mktime(0,0,0,$themth,$rr[2],$rr[3]); + } + + function UnixTimeStamp($v) + { + global $ADODB_sybase_mths; + //Dec 30 2000 12:00AM + if (!ereg( "([A-Za-z]{3})[-/\. ]([0-9]{1,2})[-/\. ]([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})" + ,$v, $rr)) return parent::UnixTimeStamp($v); + if ($rr[3] <= 1970) return 0; + + $themth = substr(strtoupper($rr[1]),0,3); + $themth = $ADODB_sybase_mths[$themth]; + if ($themth <= 0) return false; + + if (strtoupper($rr[6]) == 'P') { + if ($rr[4]<12) $rr[4] += 12; + } else { + if ($rr[4]==12) $rr[4] = 0; + } + // h-m-s-MM-DD-YY + return mktime($rr[4],$rr[5],0,$themth,$rr[2],$rr[3]); + } + +} +?> \ No newline at end of file diff --git a/libraries/adodb/adodb-vfp.inc.php b/libraries/adodb/adodb-vfp.inc.php new file mode 100755 index 00000000..dcde32cf --- /dev/null +++ b/libraries/adodb/adodb-vfp.inc.php @@ -0,0 +1,79 @@ +replaceQuote,$s))."'"; + return "'".$s."'"; + } + + // TOP requires ORDER BY for VFP + function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$arg3=false,$secs2cache=0) + { + if (!preg_match('/ORDER[ \t\r\n]+BY/i',$sql)) $sql .= ' ORDER BY 1'; + return ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$arg3,$secs2cache); + } + +}; + + +class ADORecordSet_vfp extends ADORecordSet_odbc { + + var $databaseType = "vfp"; + + + function ADORecordSet_vfp($id) + { + return $this->ADORecordSet_odbc($id); + } + + function MetaType($t,$len=-1) + { + switch (strtoupper($t)) { + case 'C': + if ($len <= $this->blobSize) return 'C'; + case 'M': + return 'X'; + + case 'D': return 'D'; + + case 'T': return 'T'; + + case 'L': return 'L'; + + case 'I': return 'I'; + + default: return 'N'; + } + } +} + +} //define +?> \ No newline at end of file diff --git a/libraries/adodb/adodb.gif b/libraries/adodb/adodb.gif new file mode 100755 index 0000000000000000000000000000000000000000..47b6f2d42a1b530ce904b99a2b932fdbd6f5c27b GIT binary patch literal 1089 zcmb7<{ZrC+0DwP$3Wz4Y<_juc6{5tq^p-kn%3Qv$J5D{dW|GM8B}HfRimHS}m1Y3jkHAd|OoX(8s52a8SkLJ=19R z8H_pr;>^u6uvjJlp_!SY>S}RVSPdG@Adw1UVj5(!1rLv6ESBZ#TMht4BAHE16+%#c zYwJXQe$TOE46%5TN^P{V$^yXeGYo!|^FM(;=;)dOS3o}Uj-G&?R&u@cK|om`uRZH| zns1A;(<{!MK*n7ls%On0b#HFCYlC8C&nhzMJMSuhfYEZo51te#w*Jww3k%R_2xo3i zLE)pxWQfDD)7MA+Qp>I567aRPc#^Tby|rC)2V}!-f(YEsP6PsJXo#}G5~03+$ss
Insert_ID error
'; + return false; + } + + /** + * @return # rows affected by UPDATE/DELETE + */ + function Affected_Rows() + { + if ($this->hasAffectedRows) { + $val = $this->_affectedrows(); + return ($val < 0) ? false : $val; + } + + if ($this->debug) print 'Affected_Rows error
'; + return false; + } + + /** + * @return the last error message + */ + function ErrorMsg() + { + return '!! '.strtoupper($this->dataProvider.' '.$this->databaseType).': '.$this->_errorMsg; + } + + + /** + * @return the last error number. Normally 0 means no error. + */ + function ErrorNo() + { + return ($this->_errorMsg) ? -1 : 0; + } + + /** + * @returns an array with the primary key columns in it. + */ + function MetaPrimaryKeys($table) + { + return false; + } + + /** + * Choose a database to connect to. Many databases do not support this. + * + * @param dbName is the name of the database to select + * @return true or false + */ + function SelectDB($dbName) + {return false;} + + + /** + * Will select, getting rows from $offset (1-based), for $nrows. + * This simulates the MySQL "select * from table limit $offset,$nrows" , and + * the PostgreSQL "select * from table limit $nrows offset $offset". Note that + * MySQL and PostgreSQL parameter ordering is the opposite of the other. + * eg. + * SelectLimit('select * from table',3); will return rows 1 to 3 (1-based) + * SelectLimit('select * from table',3,2); will return rows 3 to 5 (1-based) + * + * Uses SELECT TOP for Microsoft databases, and FIRST_ROWS CBO hint for Oracle 8+ + * BUG: Currently SelectLimit fails with $sql with LIMIT or TOP clause already set + * + * @param sql + * @param [offset] is the row to start calculations from (1-based) + * @param [rows] is the number of rows to get + * @param [inputarr] array of bind variables + * @param [arg3] is a private parameter only used by jlim + * @param [secs2cache] is a private parameter only used by jlim + * @return the recordset ($rs->databaseType == 'array') + */ + function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$arg3=false,$secs2cache=0) + { + if ($this->hasTop && $nrows > 0 && $offset <= 0) { + // suggested by Reinhard Balling. Access requires top after distinct + $sql = eregi_replace( + '(^select[\\t\\n ]*(distinct|distinctrow )?)','\\1 top '.$nrows.' ',$sql); + if ($secs2cache>0) return $this->CacheExecute($secs2cache, $sql,$inputarr,$arg3); + else return $this->Execute($sql,$inputarr,$arg3); + } else if ($this->dataProvider == 'oci8') { + $sql = eregi_replace('^select','SELECT /*+FIRST_ROWS*/',$sql); + if ($offset <= 0) { + /*if (preg_match('/\bwhere\b/i',$sql)) { + $sql = preg_replace('/where/i',"where rownum <= $nrows and ",$sql); + } else*/ + // doesn't work becoz sort is after rownum is executed - also preg_replace + // is a heuristic that might not work if there is an or + $sql = "select * from ($sql) where rownum <= :lens_sellimit_rownum"; + $inputarr['lens_sellimit_rownum'] = $nrows; + }/* else { + # THIS DOES NOT WORK -- WHY? + $sql = "select * from ($sql) where rownum between :lens_sellimit_rownum1 and :lens_sellimit_rownum2"; + $end = $offset+$nrows; + if ($offset < $end) { + $inputarr['lens_sellimit_rownum1'] = $offset; + $inputarr['lens_sellimit_rownum2'] = $end; + } else { + $inputarr['lens_sellimit_rownum1'] = $end; + $inputarr['lens_sellimit_rownum2'] = $offset; + } + $offset = -1; + $this->debug=true; + }*/ + } + if ($secs2cache>0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr,$arg3); + else $rs = &$this->Execute($sql,$inputarr,$arg3); + if ($rs && !$rs->EOF) { + return $this->_rs2rs($rs,$nrows,$offset); + } + //print_r($rs); + return $rs; + } + + /** + * Convert recordset to an array recordset + * input recordset's cursor should be at beginning, and + * old $rs will be closed. + * + * @param rs the recordset to copy + * @param [nrows] number of rows to retrieve (optional) + * @param [offset] offset by number of rows (optional) + * @return the new recordset + */ + function &_rs2rs(&$rs,$nrows=-1,$offset=-1) + { + + $arr = &$rs->GetArrayLimit($nrows,$offset); + $flds = array(); + for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) + $flds[] = &$rs->FetchField($i); + + $rs->Close(); + $rs2 = new ADORecordSet_array(); + + $rs2->InitArrayFields($arr,$flds); + return $rs2; + } + + /** + * Return first element of first row of sql statement. Recordset is disposed + * for you. + * + * @param sql SQL statement + * @param [inputarr] input bind array + */ + function GetOne($sql,$inputarr=false) + { + $rs = $this->Execute($sql,$inputarr); + if ($rs && !$rs->EOF) { + $rs->Close(); + return $rs->fields[0]; + } + return false; + } + + /** + * Return all rows. Compat with PEAR DB + * + * @param sql SQL statement + * @param [inputarr] input bind array + */ + function GetAll($sql,$inputarr=false) + { + $rs = $this->Execute($sql,$inputarr); + if (!$rs) + if (defined('ADODB_PEAR')) return ADODB_PEAR_Error(); + else return false; + return $rs->GetArray(); + } + + /** + * Return one row of sql statement. Recordset is disposed for you. + * + * @param sql SQL statement + * @param [inputarr] input bind array + */ + function GetRow($sql,$inputarr=false) + { + $rs = $this->Execute($sql,$inputarr); + if ($rs && !$rs->EOF) { + $rs->Close(); + return $rs->fields; + } + return false; + } + + + + /** + * Will select, getting rows from $offset (1-based), for $nrows. + * This simulates the MySQL "select * from table limit $offset,$nrows" , and + * the PostgreSQL "select * from table limit $nrows offset $offset". Note that + * MySQL and PostgreSQL parameter ordering is the opposite of the other. + * eg. + * CacheSelectLimit(15,'select * from table',3); will return rows 1 to 3 (1-based) + * CacheSelectLimit(15,'select * from table',3,2); will return rows 3 to 5 (1-based) + * + * BUG: Currently CacheSelectLimit fails with $sql with LIMIT or TOP clause already set + * + * @param secs2cache seconds to cache data, set to 0 to force query + * @param sql + * @param [offset] is the row to start calculations from (1-based) + * @param [nrows] is the number of rows to get + * @param [inputarr] array of bind variables + * @param [arg3] is a private parameter only used by jlim + * @return the recordset ($rs->databaseType == 'array') + */ + function &CacheSelectLimit($secs2cache,$sql,$nrows=-1,$offset=-1,$inputarr=false, $arg3=false) + { + return $this->SelectLimit($sql,$nrows,$offset,$inputarr,$arg3,$secs2cache); + } + + function CacheFlush($sql) + { + $f = $this->_gencachename($sql); + adodb_write_file($f,''); + @unlink($f); + } + + function _gencachename($sql) + { + global $ADODB_CACHE_DIR; + + return $ADODB_CACHE_DIR.'/adodb_'.md5($sql.$this->databaseType.$this->database.$this->user).'.cache'; + } + /** + * Execute SQL, caching recordsets. + * + * @param secs2cache seconds to cache data, set to 0 to force query + * @param sql SQL statement to execute + * @param [inputarr] holds the input data to bind to + * @param [arg3] reserved for john lim for future use + * @return RecordSet or false + */ + function &CacheExecute($secs2cache,$sql,$inputarr=false,$arg3=false) + { + // cannot cache if $inputarr set + if ($inputarr) return $this->Execute($sql, $inputarr, $arg3); + + $md5file = $this->_gencachename($sql); + $err = ''; + + if ($secs2cache > 0)$rs = &csv2rs($md5file,$err,$secs2cache); + else { + $err='Timeout 1'; + $rs = false; + } + + if (!$rs) { + if ($this->debug) print " $md5file cache failure: $err