From 57079e6fd5806704b9106848c8045360189a40a0 Mon Sep 17 00:00:00 2001 From: vargenau Date: Fri, 31 Aug 2012 11:29:16 +0000 Subject: [PATCH] trailing_spaces git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@8276 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- ImageTile.php | 14 +- RPC2.php | 2 +- getimg.php | 2 +- lib/ASCIIMathPHP/ASCIIMathPHP-2.0.cfg.php | 2 +- lib/ASCIIMathPHP/ASCIIMathPHP-2.0.class.php | 396 +++++++-------- lib/ASCIIMathPHP/ASCIIMathPHP.cfg.php | 2 +- lib/ASCIIMathPHP/ASCIIMathPHP.class.php | 394 +++++++-------- lib/DbSession/PDO.php | 22 +- lib/DbSession/SQL.php | 20 +- lib/DbSession/dba.php | 6 +- lib/WikiDB/ADODB.php | 2 +- lib/WikiDB/PDO.php | 2 +- lib/WikiDB/SQL.php | 4 +- lib/WikiDB/adodb/adodb-csvlib.inc.php | 74 +-- lib/WikiDB/adodb/adodb-error.inc.php | 42 +- lib/WikiDB/adodb/adodb-errorhandler.inc.php | 4 +- lib/WikiDB/adodb/adodb-errorpear.inc.php | 32 +- lib/WikiDB/adodb/adodb-exceptions.inc.php | 12 +- lib/WikiDB/adodb/adodb-iterator.inc.php | 40 +- lib/WikiDB/adodb/adodb-lib.inc.php | 234 ++++----- lib/WikiDB/adodb/adodb-pear.inc.php | 20 +- lib/WikiDB/adodb/adodb-php4.inc.php | 6 +- lib/WikiDB/adodb/adodb-time.inc.php | 330 ++++++------ lib/WikiDB/adodb/adodb.inc.php | 128 ++--- lib/WikiDB/adodb/drivers/adodb-access.inc.php | 44 +- lib/WikiDB/adodb/drivers/adodb-ado.inc.php | 210 ++++---- .../adodb/drivers/adodb-ado_access.inc.php | 28 +- .../adodb/drivers/adodb-ado_mssql.inc.php | 38 +- .../adodb/drivers/adodb-borland_ibase.inc.php | 44 +- lib/WikiDB/adodb/drivers/adodb-csv.inc.php | 90 ++-- lib/WikiDB/adodb/drivers/adodb-db2.inc.php | 120 ++--- lib/WikiDB/adodb/drivers/adodb-fbsql.inc.php | 134 ++--- .../adodb/drivers/adodb-firebird.inc.php | 44 +- lib/WikiDB/adodb/drivers/adodb-ibase.inc.php | 354 ++++++------- .../adodb/drivers/adodb-informix72.inc.php | 52 +- lib/WikiDB/adodb/drivers/adodb-ldap.inc.php | 162 +++--- lib/WikiDB/adodb/drivers/adodb-mssql.inc.php | 384 +++++++------- .../adodb/drivers/adodb-mssqlnative.inc.php | 300 +++++------ .../adodb/drivers/adodb-mssqlpo.inc.php | 8 +- lib/WikiDB/adodb/drivers/adodb-mysql.inc.php | 68 +-- lib/WikiDB/adodb/drivers/adodb-mysqli.inc.php | 362 +++++++------- lib/WikiDB/adodb/drivers/adodb-mysqlt.inc.php | 38 +- .../adodb/drivers/adodb-netezza.inc.php | 62 +-- lib/WikiDB/adodb/drivers/adodb-oci8.inc.php | 450 ++++++++--------- lib/WikiDB/adodb/drivers/adodb-oci805.inc.php | 28 +- lib/WikiDB/adodb/drivers/adodb-oci8po.inc.php | 58 +-- lib/WikiDB/adodb/drivers/adodb-odbc.inc.php | 264 +++++----- .../adodb/drivers/adodb-odbc_mssql.inc.php | 102 ++-- .../adodb/drivers/adodb-odbc_oracle.inc.php | 60 +-- lib/WikiDB/adodb/drivers/adodb-odbtp.inc.php | 14 +- lib/WikiDB/adodb/drivers/adodb-oracle.inc.php | 70 +-- .../adodb/drivers/adodb-postgres.inc.php | 6 +- .../adodb/drivers/adodb-postgres64.inc.php | 430 ++++++++-------- .../adodb/drivers/adodb-postgres7.inc.php | 46 +- lib/WikiDB/adodb/drivers/adodb-proxy.inc.php | 18 +- lib/WikiDB/adodb/drivers/adodb-sapdb.inc.php | 38 +- .../adodb/drivers/adodb-sqlanywhere.inc.php | 18 +- lib/WikiDB/adodb/drivers/adodb-sqlite.inc.php | 114 ++--- lib/WikiDB/adodb/drivers/adodb-sybase.inc.php | 156 +++--- lib/WikiDB/adodb/drivers/adodb-vfp.inc.php | 48 +- lib/WikiDB/backend.php | 24 +- lib/WikiDB/backend/ADODB_mssql.php | 4 +- lib/WikiDB/backend/ADODB_mssqlnative.php | 8 +- lib/WikiDB/backend/ADODB_mysql.php | 18 +- lib/WikiDB/backend/ADODB_oci8po.php | 8 +- lib/WikiDB/backend/ADODB_postgres7.php | 2 +- lib/WikiDB/backend/ADODB_sqlite.php | 6 +- lib/WikiDB/backend/PearDB.php | 84 ++-- lib/WikiDB/backend/PearDB_ffpgsql.php | 28 +- lib/WikiDB/backend/PearDB_mysql.php | 12 +- lib/WikiDB/backend/PearDB_oci8.php | 6 +- lib/WikiDB/backend/PearDB_pgsql.php | 20 +- lib/WikiDB/backend/PearDB_sqlite.php | 4 +- lib/WikiDB/backend/cvs.php | 48 +- lib/WikiDB/backend/dba.php | 2 +- lib/WikiDB/backend/dbaBase.php | Bin 31301 -> 31221 bytes lib/WikiDB/backend/dumb/AllRevisionsIter.php | 12 +- lib/WikiDB/backend/dumb/BackLinkIter.php | 4 +- lib/WikiDB/backend/dumb/MostPopularIter.php | 2 +- lib/WikiDB/backend/dumb/MostRecentIter.php | 6 +- lib/WikiDB/backend/dumb/TextSearchIter.php | 8 +- lib/WikiDB/cvs.php | 4 +- lib/WikiDB/dba.php | 2 +- lib/WysiwygEdit/FCKeditor.php | 14 +- lib/WysiwygEdit/Wikiwyg.php | 90 ++-- lib/WysiwygEdit/htmlarea2.php | 2 +- lib/WysiwygEdit/htmlarea3.php | 10 +- lib/WysiwygEdit/spaw.php | 2 +- lib/WysiwygEdit/tinymce.php | 4 +- lib/XMLRPC/utils.php | 54 +- lib/fpdf/japanese.php | 4 +- lib/nusoap/nusoap.php | 472 +++++++++--------- lib/pear/Cache.php | 12 +- lib/pear/Cache/Container.php | 106 ++-- lib/pear/Cache/Container/file.php | 38 +- lib/pear/Cache/Container/imgfile.php | 42 +- lib/pear/Cache/Container/trifile.php | 18 +- lib/pear/Cache/Error.php | 14 +- lib/pear/Cache/Graphics.php | 124 ++--- lib/pear/DB/Pager.php | 2 +- lib/pear/DB/ifx.php | 2 +- lib/pear/DB/ldap.php | 38 +- lib/pear/File_Passwd.php | 28 +- lib/pear/JSON.php | 4 +- lib/plugin/AtomFeed.php | 16 +- lib/plugin/CreateToc.php | 10 +- lib/plugin/FacebookLike.php | 2 +- lib/removepage.php | 4 +- passencrypt.php | 12 +- tests/unit/lib/AtomParserTest.php | 50 +- tests/unit/lib/DumpHtml.php | 4 +- tests/unit/lib/HtmlParserTest.php | 2 +- tests/unit/lib/InlineParserTest.php | 8 +- tests/unit/lib/SetupWiki.php | 10 +- tests/unit/lib/TextSearchTest.php | 6 +- tests/unit/lib/XmlRpcTest.php | 2 +- tests/unit/lib/plugin/AllPagesTest.php | 4 +- tests/unit/lib/plugin/AtomFeedTest.php | 8 +- tests/unit/lib/plugin/IncludePageTest.php | 2 +- tests/unit/lib/plugin/atom-example.xml | 10 +- tests/unit/pcre-crash.php | 2 +- tests/xmlrpc/interop-client.php | 74 +-- tests/xmlrpc/interop-server.php | 10 +- tests/xmlrpc/validate-form.php | 50 +- tests/xmlrpc/validate.php | 112 ++--- tests/xmlrpc/xmlrpc-client.php | 66 +-- tests/xmlrpc/xmlrpc-introspect.php | 6 +- tests/xmlrpc/xmlrpc-servers.php | 12 +- themes/Hawaiian/lib/random.php | 2 +- themes/MacOSX/images/index.php | 2 +- themes/MacOSX/lib/RecentChanges.php | 4 +- themes/Portland/lib/RecentChanges.php | 2 +- themes/SpaceWiki/lib/RecentChanges.php | 4 +- themes/Wordpress/lib/RecentChanges.php | 2 +- themes/blog/lib/RecentChanges.php | 2 +- 135 files changed, 4072 insertions(+), 4072 deletions(-) diff --git a/ImageTile.php b/ImageTile.php index e584bd348..3dd40bf3c 100644 --- a/ImageTile.php +++ b/ImageTile.php @@ -4,10 +4,10 @@ require_once('lib/stdlib.php'); $remove = 0; if (preg_match('/^(http|ftp|https):\/\//i',$_REQUEST['url'])) { - + $data_path = ''; list($usec, $sec) = explode(" ", microtime()); - + $fp = fopen('config/config.ini','r'); while ($config = fgetcsv($fp,1024,';')) { if (preg_match('/DATA_PATH/',$config[0])) { @@ -28,12 +28,12 @@ if (preg_match('/^(http|ftp|https):\/\//i',$_REQUEST['url'])) { } fwrite($fp,$source); $remove = 1; - + } else { @$fp = fopen($_REQUEST['url'],"r"); - + if (!$fp) { - + header ("Content-type: text/html"); echo "Not an image"; exit(); @@ -106,14 +106,14 @@ switch ($type) { echo "Not an image"; exit(); break; -} +} $width = @imagesx($img); $height = @imagesy($img); $newwidth = $_REQUEST['width']; if (empty($newidth)) $newidth = 50; - + $newheight = $_REQUEST['height']; if (empty($newheight)) $newheight = round($newwidth * ($height / $width)) ; diff --git a/RPC2.php b/RPC2.php index 3aa8f80f6..47fdc125e 100644 --- a/RPC2.php +++ b/RPC2.php @@ -36,5 +36,5 @@ $server->service(); // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/getimg.php b/getimg.php index 42845f32b..6714244ce 100644 --- a/getimg.php +++ b/getimg.php @@ -1,4 +1,4 @@ - diff --git a/lib/ASCIIMathPHP/ASCIIMathPHP-2.0.cfg.php b/lib/ASCIIMathPHP/ASCIIMathPHP-2.0.cfg.php index e65a9a1db..9c2e78c09 100644 --- a/lib/ASCIIMathPHP/ASCIIMathPHP-2.0.cfg.php +++ b/lib/ASCIIMathPHP/ASCIIMathPHP-2.0.cfg.php @@ -68,7 +68,7 @@ $symbol_arr = array( '<=' => array( 'input'=>'<=','tag'=>'mo', 'output'=>'&#' . hexdec('2264') . ';'), 'lt=' => array( 'input'=>'lt=','tag'=>'mo', 'output'=>'&#' . hexdec('2264') . ';'), 'le' => array( 'input'=>'le','tag'=>'mo', 'output'=>'&#' . hexdec('2264') . ';'), /* 2005-06-05 wes */ -'>' => array( 'input'=>'>','tag'=>'mo', 'output'=>'>'), +'>' => array( 'input'=>'>','tag'=>'mo', 'output'=>'>'), '>=' => array( 'input'=>'>=','tag'=>'mo', 'output'=>'&#' . hexdec('2265') . ';'), 'qeq' => array( 'input'=>'geq','tag'=>'mo', 'output'=>'&#' . hexdec('2265') . ';'), '-<' => array( 'input'=>'-<','tag'=>'mo', 'output'=>'&#' . hexdec('227A') . ';'), diff --git a/lib/ASCIIMathPHP/ASCIIMathPHP-2.0.class.php b/lib/ASCIIMathPHP/ASCIIMathPHP-2.0.class.php index 513aab7c8..b484843e6 100644 --- a/lib/ASCIIMathPHP/ASCIIMathPHP-2.0.class.php +++ b/lib/ASCIIMathPHP/ASCIIMathPHP-2.0.class.php @@ -5,7 +5,7 @@ * -- XMLNode * -- MathMLNode extends XMLNode * - * These classes are a PHP port of ASCIIMath + * These classes are a PHP port of ASCIIMath * Version 1.3 Feb 19 2004, (c) Peter Jipsen http://www.chapman.edu/~jipsen * * ASCIIMathPHP Version 1.11, 26 April 2006, (c) Kee-Lin Steven Chan (kc56@cornell.edu) @@ -15,10 +15,10 @@ * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License (at http://www.gnu.org/copyleft/gpl.html) + * General Public License (at http://www.gnu.org/copyleft/gpl.html) * for more details. * * ChangeLog @@ -30,7 +30,7 @@ * -- Included the missing setCurrExpr() method * * Ver 1.12 - * -- Added changes that David Lippman made to bring ASCIIMathPHP up to + * -- Added changes that David Lippman made to bring ASCIIMathPHP up to * ASCIIMath 1.4.7 functionality. * -- Added parseIntExpr, for intermediate expression parsing rule, allowing x^2/x^3 to render as (x^2)/(x^3) * -- Added quotes as another way of designating text; "hello" is equivalent to text(hello) @@ -68,7 +68,7 @@ class XMLNode var $_nmspc_alias; var $_parent_id; var $_parent_node; - + function XMLNode($id = NULL) { $this->_id = isset($id) ? $id : md5(uniqid(rand(),1)); @@ -82,31 +82,31 @@ class XMLNode $this->_parent_id = FALSE; $this->_parent_node = NULL; } - + function addChild(&$node) { $this->_child_arr[$node->getId()] = $node; $node->setParentId($this->_id); $node->setParentNode($this); } - + function addChildArr(&$node_arr) { $key_arr = array_keys($node_arr); $num_key = count($key_arr); - + for ($i = 0; $i < $num_key; $i++) { $node = $node_arr[$key_arr[$i]]; $this->addChild($node); } } - + function insertChildBefore($idx,&$node) { $key_arr = array_keys($this->_child_arr); $num_key = count($key_arr); $tmp_arr = arry(); - + for ($i = 0;$i < $num_key;$i++) { if ($i == $idx) { $tmp_arr[$node->getId()] = $node; @@ -115,13 +115,13 @@ class XMLNode } $this->_child_arr = $tmp_arr; } - + function insertChildAfter($idx,&$node) { $key_arr = array_keys($this->_child_arr); $num_key = count($key_arr); $tmp_arr = arry(); - + for ($i = 0;$i < $num_key;$i++) { $tmp_arr[$key_arr[$i]] = $this->_child_arr[$key_arr[$i]]; if ($i == $idx) { @@ -130,82 +130,82 @@ class XMLNode } $this->_child_arr = $tmp_arr; } - + function setId($id) { $this->_id = $id; } - + function setName($name) { $this->_name = $name; } - + function setNamepace($nmspc) { $this->_nmspc = $nmspc; } - + function setNamespaceAlias($nmspc_alias) { $this->_nmspc_alias = $nmspc_alias; } - + function setContent($content) { $this->_content = $content; } - + function setEmptyElem($mt_elem_flg) { $this->_mt_elem_flg = $mt_elem_flg; } - + function setAttr($attr_nm,$attr_val) { $this->_attr_arr[$attr_nm] = $attr_val; } - + function setAttrArr($attr_arr) { $this->_attr_arr = $attr_arr; } - + function setParentId($id) { $this->_parent_id = $id; } - + function setParentNode(&$node) { $this->_parent_node = $node; } - + function getId() { return($this->_id); } - + function getName() { return($this->_name); } - + function getNamespace() { return($this->_nmspc); } - + function getNamespaceAlias() { return($this->_nmspc_alias); } - + function getContent() { return($this->_content); } - + function getAttr($attr_nm) { if (isset($this->_attr_arr[$attr_nm])) { @@ -214,22 +214,22 @@ class XMLNode return(NULL); } } - + function getAttrArr() { return($this->_attr_arr); } - + function getParentId() { return($this->parent_id); } - + function getParentNode() { return($this->_parent_node); } - + function getChild($id) { if (isset($this->_child_arr[$id])) { @@ -238,70 +238,70 @@ class XMLNode return(FALSE); } } - + function getFirstChild() { $id_arr = array_keys($this->_child_arr); $num_child = count($id_arr); - + if ($num_child > 0) { return($this->_child_arr[$id_arr[0]]); } else { return(FALSE); } } - + function getLastChild() { $id_arr = array_keys($this->_child_arr); $num_child = count($id_arr); - + if ($num_child > 0) { return($this->_child_arr[$id_arr[$num_child - 1]]); } else { return(FALSE); } } - + function getChildByIdx($idx) { $id_arr = array_keys($this->_child_arr); - + if (isset($this->_child_arr[$id_arr[$idx]])) { return($this->_child_arr[$id_arr[$idx]]); } else { return(FALSE); } } - + function getNumChild() { return(count($this->_child_arr)); } - + function removeChild($id) { unset($this->_child_arr[$id]); } - + function removeChildByIdx($idx) { $key_arr = array_keys($this->_child_arr); unset($this->_child_arr[$key_arr[$idx]]); } - + function removeFirstChild() { $key_arr = array_keys($this->_child_arr); unset($this->_child_arr[$key_arr[0]]); } - + function removeLastChild() { $key_arr = array_keys($this->_child_arr); unset($this->_child_arr[$key_arr[count($key_arr)-1]]); } - + function dumpXML($indent_str = "\t") { $attr_txt = $this->_dumpAttr(); @@ -309,42 +309,42 @@ class XMLNode $xmlns = $this->_dumpXmlns(); $lvl = $this->_getCurrentLevel(); $indent = str_pad('',$lvl,$indent_str); - + if ($this->_mt_elem_flg) { $tag = "$indent<$name$xmlns$attr_txt />"; return($tag); } else { $key_arr = array_keys($this->_child_arr); $num_child = count($key_arr); - + $tag = "$indent<$name$xmlns$attr_txt>$this->_content"; - + for ($i = 0;$i < $num_child;$i++) { $node = $this->_child_arr[$key_arr[$i]]; - + $child_txt = $node->dumpXML($indent_str); $tag .= "\n$child_txt"; } - + $tag .= ($num_child > 0 ? "\n$indent" : ""); return($tag); } } - + function _dumpAttr() { $id_arr = array_keys($this->_attr_arr); $id_arr_cnt = count($id_arr); $attr_txt = ''; - + for($i = 0;$i < $id_arr_cnt;$i++) { $key = $id_arr[$i]; $attr_txt .= " $key=\"{$this->_attr_arr[$key]}\""; } - + return($attr_txt); } - + function _dumpName() { $alias = $this->getNamespaceAlias(); @@ -354,12 +354,12 @@ class XMLNode return("$alias:" . $this->getName()); } } - + function _dumpXmlns() { $nmspc = $this->getNamespace(); $alias = $this->getNamespaceAlias(); - + if ($nmspc != '') { if ($alias == '') { return(" xmlns=\"" . $nmspc . "\""); @@ -370,7 +370,7 @@ class XMLNode return(''); } } - + function _getCurrentLevel() { if ($this->_parent_id === FALSE) { @@ -390,20 +390,20 @@ class MathMLNode extends XMLNode { parent::XMLNode($id); } - + function removeBrackets() { if ($this->_name == 'mrow') { if ($c_node_0 = $this->getFirstChild()) { $c_node_0->isLeftBracket() ? $this->removeFirstChild() : 0; } - + if ($c_node_0 = $this->getLastChild()) { $c_node_0->isRightBracket() ? $this->removeLastChild() : 0; } } } - + function isLeftBracket() { switch ($this->_content) { @@ -415,7 +415,7 @@ class MathMLNode extends XMLNode } return(FALSE); } - + function isRightBracket() { switch ($this->_content) { @@ -437,7 +437,7 @@ class ASCIIMathPHP var $_symbol_arr; var $_node_arr; var $_node_cntr; - + function ASCIIMathPHP($symbol_arr,$expr = NULL) { $this->_symbol_arr = $symbol_arr; @@ -445,10 +445,10 @@ class ASCIIMathPHP $this->setExpr($expr); } } - + /** * Returns an empty node (containing a non-breaking space) 26-Apr-2006 - * + * * Used when an expression is incomplete * * @return object @@ -462,7 +462,7 @@ class ASCIIMathPHP $tmp_node->setContent('&#' . hexdec('200B') . ';'); return $tmp_node; } - + function pushExpr($prefix) // 2005-06-11 wes { $this->_curr_expr = $prefix . $this->_curr_expr; @@ -473,59 +473,59 @@ class ASCIIMathPHP $this->_expr = $expr; $this->_curr_expr = $expr; $this->_prev_expr = $expr; - + $this->_node_arr = array(); $this->_node_cntr = 0; } - + function genMathML($attr_arr = NULL) { // node $node_0 = $this->createNode(); $node_0->setName('math'); $node_0->setNamepace('http://www.w3.org/1998/Math/MathML'); - + // node if (isset($attr_arr)) { $node_1 = $this->createNode(); $node_1->setName('mstyle'); $node_1->setAttrArr($attr_arr); - + $node_arr = $this->parseExpr(); - + $node_1->addChildArr($node_arr); $node_0->addChild($node_1); } else { $node_arr = $this->parseExpr(); $node_0->addChildArr($node_arr); } - + return TRUE; } - + /* function mergeNodeArr(&$node_arr_0,&$node_arr_1) { $key_arr_0 = array_keys($node_arr_0); $key_arr_1 = array_keys($node_arr_1); - + $num_key_0 = count($key_arr_0); $num_key_1 = count($key_arr_1); - + $merge_arr = array(); - + for ($i = 0;$i < $num_key_0;$i++) { $merge_arr[$key_arr_0[$i]] = $node_arr_0[$key_arr_0[$i]]; } - + for ($j = 0;$j < $num_key_1;$i++) { $merge_arr[$key_arr_1[$i]] = $node_arr_1[$key_arr_1[$i]]; } - + return($merge_arr); } */ - + //Broken out of parseExpr Sept 7, 2006 David Lippman for //ASCIIMathML 1.4.7 compatibility function parseIntExpr() @@ -533,45 +533,45 @@ class ASCIIMathPHP $sym_0 = $this->getSymbol(); $node_0 = $this->parseSmplExpr(); $sym = $this->getSymbol(); - + if (isset($sym['infix']) && $sym['input'] != '/') { $this->chopExpr($sym['symlen']); $node_1 = $this->parseSmplExpr(); - + if ($node_1 === FALSE) { //show box in place of missing argument $node_1 = $this->emptyNode();//?? } else { $node_1->removeBrackets(); } - + // If 'sub' -- subscript if ($sym['input'] == '_') { - + $sym_1 = $this->getSymbol(); - + // If 'sup' -- superscript - if ($sym_1['input'] == '^') { + if ($sym_1['input'] == '^') { $this->chopExpr($sym_1['symlen']); $node_2 = $this->parseSmplExpr(); $node_2->removeBrackets(); - + $node_3 = $this->createNode(); $node_3->setName(isset($sym_0['underover']) ? 'munderover' : 'msubsup'); $node_3->addChild($node_0); $node_3->addChild($node_1); $node_3->addChild($node_2); - + $node_4 = $this->createNode(); $node_4->setName('mrow'); $node_4->addChild($node_3); - + return $node_4; } else { $node_2 = $this->createNode(); $node_2->setName(isset($sym_0['underover']) ? 'munder' : 'msub'); $node_2->addChild($node_0); $node_2->addChild($node_1); - + return $node_2; } } else { @@ -579,7 +579,7 @@ class ASCIIMathPHP $node_2->setName($sym['tag']); $node_2->addChild($node_0); $node_2->addChild($node_1); - + return($node_2); } } elseif ($node_0 !== FALSE) { @@ -587,32 +587,32 @@ class ASCIIMathPHP } else { return $this->emptyNode(); } - + } - + function parseExpr() { // Child/Fragment array $node_arr = array(); - + // Deal whole expressions like 'ax + by + c = 0' etc. do { $sym_0 = $this->getSymbol(); $node_0 = $this->parseIntExpr(); $sym = $this->getSymbol(); // var_dump($sym); - + if (isset($sym['infix']) && $sym['input'] == '/') { $this->chopExpr($sym['symlen']); $node_1 = $this->parseIntExpr(); - + if ($node_1 === FALSE) { //should show box in place of missing argument $node_1 = $this->emptyNode(); continue; } $node_1->removeBrackets(); - + // If 'div' -- divide $node_0->removeBrackets(); $node_2 = $this->createNode(); @@ -620,18 +620,18 @@ class ASCIIMathPHP $node_2->addChild($node_0); $node_2->addChild($node_1); $node_arr[$node_2->getId()] = $node_2; - + } elseif ($node_0 !== FALSE) { $node_arr[$node_0->getId()] = $node_0; } } while (!isset($sym['right_bracket']) && $sym !== FALSE && $sym['output'] != ''); - + //var_dump($sym); // Possibly to deal with matrices if (isset($sym['right_bracket'])) { $node_cnt = count($node_arr); $key_node_arr = array_keys($node_arr); - + if ($node_cnt > 1) { $node_5 = $node_arr[$key_node_arr[$node_cnt-1]]; $node_6 = $node_arr[$key_node_arr[$node_cnt-2]]; @@ -639,56 +639,56 @@ class ASCIIMathPHP $node_5 = FALSE; $node_6 = FALSE; } - + // Dealing with matrices if ($node_5 !== FALSE && $node_6 !== FALSE && - $node_cnt > 1 && - $node_5->getName() == 'mrow' && + $node_cnt > 1 && + $node_5->getName() == 'mrow' && $node_6->getName() == 'mo' && $node_6->getContent() == ',') { - + // Checking if Node 5 has a LastChild if ($node_7 = $node_5->getLastChild()) { $node_7_cntnt = $node_7->getContent(); } else { $node_7_cntnt = FALSE; } - + // If there is a right bracket if ($node_7 !== FALSE && ($node_7_cntnt == ']' || $node_7_cntnt == ')')) { - + // Checking if Node 5 has a firstChild if ($node_8 = $node_5->getFirstChild()) { $node_8_cntnt = $node_8->getContent(); } else { $node_8_cntnt = FALSE; } - + // If there is a matching left bracket - if ($node_8 !== FALSE && + if ($node_8 !== FALSE && (($node_8_cntnt == '(' && $node_7_cntnt == ')' && $sym['output'] != '}') || ($node_8_cntnt == '[' && $node_7_cntnt == ']'))) { - + $is_mtrx_flg = TRUE; $comma_pos_arr = array(); - + $i = 0; - + while ($i < $node_cnt && $is_mtrx_flg) { $tmp_node = $node_arr[$key_node_arr[$i]]; - + if($tmp_node_first = $tmp_node->getFirstChild()) { $tnfc = $tmp_node_first->getContent(); } else { $tnfc = FALSE; } - + if($tmp_node_last = $tmp_node->getLastChild()) { $tnlc = $tmp_node_last->getContent(); } else { $tnlc = FALSE; } - + if (isset($key_node_arr[$i+1])) { $next_tmp_node = $node_arr[$key_node_arr[$i+1]]; $ntnn = $next_tmp_node->getName(); @@ -697,7 +697,7 @@ class ASCIIMathPHP $ntnn = FALSE; $ntnc = FALSE; } - + // Checking each node in node array for matrix criteria if ($is_mtrx_flg) { $is_mtrx_flg = $tmp_node->getName() == 'mrow' && @@ -708,27 +708,27 @@ class ASCIIMathPHP if ($is_mtrx_flg) { for ($j = 0;$j < $tmp_node->getNumChild();$j++) { $tmp_c_node = $tmp_node->getChildByIdx($j); - + if ($tmp_c_node->getContent() == ',') { $comma_pos_arr[$i][] = $j; } } - } - + } + if ($is_mtrx_flg && $i > 1) { - + $cnt_cpan = isset($comma_pos_arr[$i]) ? count($comma_pos_arr[$i]) : NULL; $cnt_cpap = isset($comma_pos_arr[$i-2]) ? count($comma_pos_arr[$i-2]) : NULL; $is_mtrx_flg = $cnt_cpan == $cnt_cpap; } - + $i += 2; } - + // If the node passes the matrix tests if ($is_mtrx_flg) { $tab_node_arr = array(); - + for ($i = 0;$i < $node_cnt;$i += 2) { $tmp_key_node_arr = array_keys($node_arr); if (!($tmp_node = $node_arr[$tmp_key_node_arr[0]])) { @@ -736,71 +736,71 @@ class ASCIIMathPHP } $num_child = $tmp_node->getNumChild(); $k = 0; - + $tmp_node->removeFirstChild(); - + $row_node_arr = array(); $row_frag_node_arr = array(); - + for ($j = 1;$j < ($num_child-1);$j++) { - if (isset($comma_pos_arr[$i][$k]) && + if (isset($comma_pos_arr[$i][$k]) && $j == $comma_pos_arr[$i][$k]) { - + $tmp_node->removeFirstChild(); - + $tmp_c_node = $this->createNode(); $tmp_c_node->setName('mtd'); $tmp_c_node->addChildArr($row_frag_node_arr); $row_frag_node_arr = array(); - + $row_node_arr[$tmp_c_node->getId()] = $tmp_c_node; - + $k++; } else { - + if ($tmp_c_node = $tmp_node->getFirstChild()) { $row_frag_node_arr[$tmp_c_node->getId()] = $tmp_c_node; $tmp_node->removeFirstChild(); } } } - + $tmp_c_node = $this->createNode(); $tmp_c_node->setName('mtd'); $tmp_c_node->addChildArr($row_frag_node_arr); - + $row_node_arr[$tmp_c_node->getId()] = $tmp_c_node; - + if (count($node_arr) > 2) { $tmp_key_node_arr = array_keys($node_arr); unset($node_arr[$tmp_key_node_arr[0]]); unset($node_arr[$tmp_key_node_arr[1]]); } - + $tmp_c_node = $this->createNode(); $tmp_c_node->setName('mtr'); $tmp_c_node->addChildArr($row_node_arr); - + $tab_node_arr[$tmp_c_node->getId()] = $tmp_c_node; } - + $tmp_c_node = $this->createNode(); $tmp_c_node->setName('mtable'); $tmp_c_node->addChildArr($tab_node_arr); - + if (isset($sym['invisible'])) { $tmp_c_node->setAttr('columnalign','left'); } - + $key_node_arr = array_keys($node_arr); $tmp_c_node->setId($key_node_arr[0]); - + $node_arr[$tmp_c_node->getId()] = $tmp_c_node; } } } } - + $this->chopExpr($sym['symlen']); if (!isset($sym['invisible'])) { $node_7 = $this->createNode(); @@ -809,19 +809,19 @@ class ASCIIMathPHP $node_arr[$node_7->getId()] = $node_7; } } - + return($node_arr); } - + function parseSmplExpr() { $sym = $this->getSymbol(); - - if (!$sym || isset($sym['right_bracket'])) //return FALSE; + + if (!$sym || isset($sym['right_bracket'])) //return FALSE; return $this->emptyNode(); - + $this->chopExpr($sym['symlen']); - + // 2005-06-11 wes: add definition type support if(isset($sym['definition'])) { $this->pushExpr($sym['output']); @@ -831,35 +831,35 @@ class ASCIIMathPHP if (isset($sym['left_bracket'])) { $node_arr = $this->parseExpr(); - + if (isset($sym['invisible'])) { $node_0 = $this->createNode(); $node_0->setName('mrow'); $node_0->addChildArr($node_arr); - + return($node_0); } else { $node_0 = $this->createNode(); $node_0->setName('mo'); $node_0->setContent($sym['output']); - + $node_1 = $this->createNode(); $node_1->setName('mrow'); $node_1->addChild($node_0); $node_1->addChildArr($node_arr); - + return($node_1); } } elseif (isset($sym['unary'])) { - + if ($sym['input'] == 'sqrt') { $node_0 = $this->parseSmplExpr(); $node_0->removeBrackets(); - + $node_1 = $this->createNode(); $node_1->setName($sym['tag']); $node_1->addChild($node_0); - + return($node_1); } elseif (isset($sym['func'])) { //added 2006-9-7 David Lippman $expr = ltrim($this->getCurrExpr()); @@ -904,52 +904,52 @@ class ASCIIMathPHP } $txt = substr($expr,1,strpos($expr,$end_brckt)-1); } - + //$txt = substr($expr,1,strpos($expr,$end_brckt)-1); $len = strlen($txt); - + $node_0 = $this->createNode(); $node_0->setName('mrow'); - + if ($len > 0) { if ($txt{0} == " ") { $node_1 = $this->createNode(); $node_1->setName('mspace'); $node_1->setAttr('width','1ex'); - + $node_0->addChild($node_1); } - + $node_3 = $this->createNode(); $node_3->setName($sym['tag']); $node_3->setContent(trim($txt)); - + $node_0->addChild($node_3); - + if ($len > 1 && $txt{$len-1} == " ") { $node_2 = $this->createNode(); $node_2->setName('mspace'); $node_2->setAttr('width','1ex'); - + $node_0->addChild($node_2); } - + $this->chopExpr($len+2); } return($node_0); - + } elseif (isset($sym['acc'])) { $node_0 = $this->parseSmplExpr(); $node_0->removeBrackets(); - + $node_1 = $this->createNode(); $node_1->setName($sym['tag']); $node_1->addChild($node_0); - + $node_2 = $this->createNode(); $node_2->setName('mo'); $node_2->setContent($sym['output']); - + $node_1->addChild($node_2); return($node_1); } else { @@ -957,13 +957,13 @@ class ASCIIMathPHP } } elseif (isset($sym['binary'])) { $node_arr = array(); - + $node_0 = $this->parseSmplExpr(); $node_0->removeBrackets(); - + $node_1 = $this->parseSmplExpr(); $node_1->removeBrackets(); - + /* 2005-06-05 wes: added stackrel */ if ($sym['input'] == 'root' || $sym['input'] == 'stackrel') { $node_arr[$node_1->getId()] = $node_1; @@ -972,78 +972,78 @@ class ASCIIMathPHP $node_arr[$node_0->getId()] = $node_0; $node_arr[$node_1->getId()] = $node_1; } - + $node_2 = $this->createNode(); $node_2->setName($sym['tag']); $node_2->addChildArr($node_arr); - + return($node_2); } elseif (isset($sym['infix'])) { $node_0 = $this->createNode(); $node_0->setName('mo'); $node_0->setContent($sym['output']); - + return($node_0); } elseif (isset($sym['space'])) { $node_0 = $this->createNode(); $node_0->setName('mrow'); - + $node_1 = $this->createNode(); $node_1->setName('mspace'); $node_1->setAttr('width',$sym['space']); - + $node_2 = $this->createNode(); $node_2->setName($sym['tag']); $node_2->setContent($sym['output']); - + $node_3 = $this->createNode(); $node_3->setName('mspace'); $node_3->setAttr('width',$sym['space']); - + $node_0->addChild($node_1); $node_0->addChild($node_2); $node_0->addChild($node_3); - + return($node_0); } else { - + // A constant $node_0 = $this->createNode(); $node_0->setName($sym['tag']); $node_0->setContent($sym['output']); return($node_0); } - + // Return an empty node return $this->emptyNode(); } - + function getMathML() { $root = $this->_node_arr[0]; return($root->dumpXML()); } - + function getCurrExpr() { return($this->_curr_expr); } - + function setCurrExpr($str) { $this->_curr_expr = $str; } - + function getExpr() { return($this->_expr); } - + function getPrevExpr() { return($this->_prev_expr); } - + function createNode() { $node = new MathMLNode($this->_node_cntr); @@ -1052,46 +1052,46 @@ class ASCIIMathPHP $this->_node_cntr++; return($node); } - + /** * Gets the largest symbol in the expression (greedy). Changed from non-greedy 26-Apr-2006 - * + * * @parameter boolean[optional] Chop original string? * * @return mixed - * + * * @access private */ function getSymbol($chop_flg = FALSE) { - // Implemented a reverse symbol matcher. + // Implemented a reverse symbol matcher. // Instead of going front to back, it goes back to front. Steven 26-Apr-2006 $chr_cnt = strlen($this->_curr_expr); - + if ($chr_cnt == 0) return FALSE; - + for ($i = $chr_cnt; $i > 0; $i--) { $sym_0 = substr($this->_curr_expr,0,$i); - + // Reading string for numeric values if (is_numeric($sym_0)) { - + if ($chop_flg) $this->chopExpr($i); return array('input'=>$sym_0, 'tag'=>'mn', 'output'=>$sym_0, 'symlen'=>$i); - + } elseif (isset($this->_symbol_arr[$sym_0])) { - + if ($chop_flg) $this->chopExpr($i); $sym_arr = $this->_symbol_arr[$sym_0]; $sym_arr['symlen'] = $i; return $sym_arr; } } - + // Reading string for alphabetic constants and the minus sign $char = $this->_curr_expr{0}; $len_left = $chop_flg ? $this->chopExpr(1) : strlen($this->_curr_expr)-1; - + // Deals with expressions of length 1 if ($len_left == 0 && isset($this->_symbol_arr[$char])) { $sym_arr = $this->_symbol_arr[$char]; @@ -1102,11 +1102,11 @@ class ASCIIMathPHP return array('input'=>$char, 'tag'=>$tag, 'output'=>$char, 'symlen'=>1); } } - + function chopExpr($strlen) { $this->_prev_expr = $this->_curr_expr; - + if ($strlen == strlen($this->_curr_expr)) { $this->_curr_expr = ''; return(0); @@ -1114,6 +1114,6 @@ class ASCIIMathPHP $this->_curr_expr = ltrim(substr($this->_curr_expr,$strlen)); return(strlen($this->_curr_expr)); } - } + } } ?> diff --git a/lib/ASCIIMathPHP/ASCIIMathPHP.cfg.php b/lib/ASCIIMathPHP/ASCIIMathPHP.cfg.php index c6c432e23..e380d6e0c 100644 --- a/lib/ASCIIMathPHP/ASCIIMathPHP.cfg.php +++ b/lib/ASCIIMathPHP/ASCIIMathPHP.cfg.php @@ -68,7 +68,7 @@ $symbol_arr = array( '<=' => array( 'input'=>'<=','tag'=>'mo', 'output'=>'&#' . hexdec('2264') . ';'), 'lt=' => array( 'input'=>'lt=','tag'=>'mo', 'output'=>'&#' . hexdec('2264') . ';'), 'le' => array( 'input'=>'le','tag'=>'mo', 'output'=>'&#' . hexdec('2264') . ';'), /* 2005-06-05 wes */ -'>' => array( 'input'=>'>','tag'=>'mo', 'output'=>'>'), +'>' => array( 'input'=>'>','tag'=>'mo', 'output'=>'>'), '>=' => array( 'input'=>'>=','tag'=>'mo', 'output'=>'&#' . hexdec('2265') . ';'), 'qeq' => array( 'input'=>'geq','tag'=>'mo', 'output'=>'&#' . hexdec('2265') . ';'), '-<' => array( 'input'=>'-<','tag'=>'mo', 'output'=>'&#' . hexdec('227A') . ';'), diff --git a/lib/ASCIIMathPHP/ASCIIMathPHP.class.php b/lib/ASCIIMathPHP/ASCIIMathPHP.class.php index a777bbda2..b508d7780 100644 --- a/lib/ASCIIMathPHP/ASCIIMathPHP.class.php +++ b/lib/ASCIIMathPHP/ASCIIMathPHP.class.php @@ -14,10 +14,10 @@ * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License (at http://www.gnu.org/copyleft/gpl.html) + * General Public License (at http://www.gnu.org/copyleft/gpl.html) * for more details. * * ChangeLog @@ -26,7 +26,7 @@ * -- Included the missing setCurrExpr() method * * Ver 1.12 - * -- Added changes that David Lippman made to bring ASCIIMathPHP up to + * -- Added changes that David Lippman made to bring ASCIIMathPHP up to * ASCIIMath 1.4.7 functionality. * -- Added parseIntExpr, for intermediate expression parsing rule, allowing x^2/x^3 to render as (x^2)/(x^3) * -- Added quotes as another way of designating text; "hello" is equivalent to text(hello) @@ -64,7 +64,7 @@ class XMLNode var $_nmspc_alias; var $_parent_id; var $_parent_node; - + function & XMLNode($id = NULL) { $this->_id = isset($id) ? $id : md5(uniqid(rand(),1)); @@ -79,31 +79,31 @@ class XMLNode $this->_parent_node = NULL; return $this; } - + function addChild(&$node) { $this->_child_arr[$node->getId()] =& $node; $node->setParentId($this->_id); $node->setParentNode($this); } - + function addChildArr(&$node_arr) { $key_arr = array_keys($node_arr); $num_key = count($key_arr); - + for ($i = 0; $i < $num_key; $i++) { $node =& $node_arr[$key_arr[$i]]; $this->addChild($node); } } - + function insertChildBefore($idx,&$node) { $key_arr = array_keys($this->_child_arr); $num_key = count($key_arr); $tmp_arr = arry(); - + for ($i = 0;$i < $num_key;$i++) { if ($i == $idx) { $tmp_arr[$node->getId()] =& $node; @@ -112,13 +112,13 @@ class XMLNode } $this->_child_arr =& $tmp_arr; } - + function insertChildAfter($idx,&$node) { $key_arr = array_keys($this->_child_arr); $num_key = count($key_arr); $tmp_arr = arry(); - + for ($i = 0;$i < $num_key;$i++) { $tmp_arr[$key_arr[$i]] =& $this->_child_arr[$key_arr[$i]]; if ($i == $idx) { @@ -127,82 +127,82 @@ class XMLNode } $this->_child_arr =& $tmp_arr; } - + function setId($id) { $this->_id = $id; } - + function setName($name) { $this->_name = $name; } - + function setNamepace($nmspc) { $this->_nmspc = $nmspc; } - + function setNamespaceAlias($nmspc_alias) { $this->_nmspc_alias = $nmspc_alias; } - + function setContent($content) { $this->_content = $content; } - + function setEmptyElem($mt_elem_flg) { $this->_mt_elem_flg = $mt_elem_flg; } - + function setAttr($attr_nm,$attr_val) { $this->_attr_arr[$attr_nm] = $attr_val; } - + function setAttrArr($attr_arr) { $this->_attr_arr = $attr_arr; } - + function setParentId($id) { $this->_parent_id = $id; } - + function setParentNode(&$node) { $this->_parent_node =& $node; } - + function getId() { return($this->_id); } - + function getName() { return($this->_name); } - + function getNamespace() { return($this->_nmspc); } - + function getNamespaceAlias() { return($this->_nmspc_alias); } - + function getContent() { return($this->_content); } - + function getAttr($attr_nm) { if (isset($this->_attr_arr[$attr_nm])) { @@ -211,22 +211,22 @@ class XMLNode return(NULL); } } - + function getAttrArr() { return($this->_attr_arr); } - + function getParentId() { return($this->parent_id); } - + function & getParentNode() { return($this->_parent_node); } - + function & getChild($id) { if (isset($this->_child_arr[$id])) { @@ -235,70 +235,70 @@ class XMLNode return(FALSE); } } - + function & getFirstChild() { $id_arr = array_keys($this->_child_arr); $num_child = count($id_arr); - + if ($num_child > 0) { return($this->_child_arr[$id_arr[0]]); } else { return(FALSE); } } - + function & getLastChild() { $id_arr = array_keys($this->_child_arr); $num_child = count($id_arr); - + if ($num_child > 0) { return($this->_child_arr[$id_arr[$num_child - 1]]); } else { return(FALSE); } } - + function & getChildByIdx($idx) { $id_arr = array_keys($this->_child_arr); - + if (isset($this->_child_arr[$id_arr[$idx]])) { return($this->_child_arr[$id_arr[$idx]]); } else { return(FALSE); } } - + function getNumChild() { return(count($this->_child_arr)); } - + function removeChild($id) { unset($this->_child_arr[$id]); } - + function removeChildByIdx($idx) { $key_arr = array_keys($this->_child_arr); unset($this->_child_arr[$key_arr[$idx]]); } - + function removeFirstChild() { $key_arr = array_keys($this->_child_arr); unset($this->_child_arr[$key_arr[0]]); } - + function removeLastChild() { $key_arr = array_keys($this->_child_arr); unset($this->_child_arr[$key_arr[count($key_arr)-1]]); } - + function dumpXML($indent_str = "\t") { $attr_txt = $this->_dumpAttr(); @@ -306,42 +306,42 @@ class XMLNode $xmlns = $this->_dumpXmlns(); $lvl = $this->_getCurrentLevel(); $indent = str_pad('',$lvl,$indent_str); - + if ($this->_mt_elem_flg) { $tag = "$indent<$name$xmlns$attr_txt />"; return($tag); } else { $key_arr = array_keys($this->_child_arr); $num_child = count($key_arr); - + $tag = "$indent<$name$xmlns$attr_txt>$this->_content"; - + for ($i = 0;$i < $num_child;$i++) { $node =& $this->_child_arr[$key_arr[$i]]; - + $child_txt = $node->dumpXML($indent_str); $tag .= "\n$child_txt"; } - + $tag .= ($num_child > 0 ? "\n$indent" : ""); return($tag); } } - + function _dumpAttr() { $id_arr = array_keys($this->_attr_arr); $id_arr_cnt = count($id_arr); $attr_txt = ''; - + for($i = 0;$i < $id_arr_cnt;$i++) { $key = $id_arr[$i]; $attr_txt .= " $key=\"{$this->_attr_arr[$key]}\""; } - + return($attr_txt); } - + function _dumpName() { $alias = $this->getNamespaceAlias(); @@ -351,12 +351,12 @@ class XMLNode return("$alias:" . $this->getName()); } } - + function _dumpXmlns() { $nmspc = $this->getNamespace(); $alias = $this->getNamespaceAlias(); - + if ($nmspc != '') { if ($alias == '') { return(" xmlns=\"" . $nmspc . "\""); @@ -367,7 +367,7 @@ class XMLNode return(''); } } - + function _getCurrentLevel() { if ($this->_parent_id === FALSE) { @@ -387,20 +387,20 @@ class MathMLNode extends XMLNode { return parent::XMLNode($id); } - + function removeBrackets() { if ($this->_name == 'mrow') { if ($c_node_0 =& $this->getFirstChild()) { $c_node_0->isLeftBracket() ? $this->removeFirstChild() : 0; } - + if ($c_node_0 =& $this->getLastChild()) { $c_node_0->isRightBracket() ? $this->removeLastChild() : 0; } } } - + function isLeftBracket() { switch ($this->_content) { @@ -412,7 +412,7 @@ class MathMLNode extends XMLNode } return(FALSE); } - + function isRightBracket() { switch ($this->_content) { @@ -434,7 +434,7 @@ class ASCIIMathPHP var $_symbol_arr; var $_node_arr; var $_node_cntr; - + function ASCIIMathPHP($symbol_arr,$expr = NULL) { $this->_symbol_arr = $symbol_arr; @@ -442,10 +442,10 @@ class ASCIIMathPHP $this->setExpr($expr); } } - + /** * Returns an empty node (containing a non-breaking space) 26-Apr-2006 - * + * * Used when an expression is incomplete * * @return object @@ -459,7 +459,7 @@ class ASCIIMathPHP $tmp_node->setContent('&#' . hexdec('200B') . ';'); return $tmp_node; } - + function pushExpr($prefix) // 2005-06-11 wes { $this->_curr_expr = $prefix . $this->_curr_expr; @@ -470,59 +470,59 @@ class ASCIIMathPHP $this->_expr = $expr; $this->_curr_expr = $expr; $this->_prev_expr = $expr; - + $this->_node_arr = array(); $this->_node_cntr = 0; } - + function genMathML($attr_arr = NULL) { // node $node_0 =& $this->createNode(); $node_0->setName('math'); $node_0->setNamepace('http://www.w3.org/1998/Math/MathML'); - + // node if (isset($attr_arr)) { $node_1 =& $this->createNode(); $node_1->setName('mstyle'); $node_1->setAttrArr($attr_arr); - + $node_arr = $this->parseExpr(); - + $node_1->addChildArr($node_arr); $node_0->addChild($node_1); } else { $node_arr = $this->parseExpr(); $node_0->addChildArr($node_arr); } - + return TRUE; } - + /* function & mergeNodeArr(&$node_arr_0,&$node_arr_1) { $key_arr_0 = array_keys($node_arr_0); $key_arr_1 = array_keys($node_arr_1); - + $num_key_0 = count($key_arr_0); $num_key_1 = count($key_arr_1); - + $merge_arr = array(); - + for ($i = 0;$i < $num_key_0;$i++) { $merge_arr[$key_arr_0[$i]] =& $node_arr_0[$key_arr_0[$i]]; } - + for ($j = 0;$j < $num_key_1;$i++) { $merge_arr[$key_arr_1[$i]] =& $node_arr_1[$key_arr_1[$i]]; } - + return($merge_arr); } */ - + //Broken out of parseExpr Sept 7, 2006 David Lippman for //ASCIIMathML 1.4.7 compatibility function & parseIntExpr() @@ -530,45 +530,45 @@ class ASCIIMathPHP $sym_0 = $this->getSymbol(); $node_0 =& $this->parseSmplExpr(); $sym = $this->getSymbol(); - + if (isset($sym['infix']) && $sym['input'] != '/') { $this->chopExpr($sym['symlen']); $node_1 =& $this->parseSmplExpr(); - + if ($node_1 === FALSE) { //show box in place of missing argument $node_1 =& $this->emptyNode();//?? } else { $node_1->removeBrackets(); } - + // If 'sub' -- subscript if ($sym['input'] == '_') { - + $sym_1 = $this->getSymbol(); - + // If 'sup' -- superscript - if ($sym_1['input'] == '^') { + if ($sym_1['input'] == '^') { $this->chopExpr($sym_1['symlen']); $node_2 =& $this->parseSmplExpr(); $node_2->removeBrackets(); - + $node_3 =& $this->createNode(); $node_3->setName(isset($sym_0['underover']) ? 'munderover' : 'msubsup'); $node_3->addChild($node_0); $node_3->addChild($node_1); $node_3->addChild($node_2); - + $node_4 =& $this->createNode(); $node_4->setName('mrow'); $node_4->addChild($node_3); - + return $node_4; } else { $node_2 =& $this->createNode(); $node_2->setName(isset($sym_0['underover']) ? 'munder' : 'msub'); $node_2->addChild($node_0); $node_2->addChild($node_1); - + return $node_2; } } else { @@ -576,7 +576,7 @@ class ASCIIMathPHP $node_2->setName($sym['tag']); $node_2->addChild($node_0); $node_2->addChild($node_1); - + return($node_2); } } elseif ($node_0 !== FALSE) { @@ -584,32 +584,32 @@ class ASCIIMathPHP } else { return $this->emptyNode(); } - + } - + function parseExpr() { // Child/Fragment array $node_arr = array(); - + // Deal whole expressions like 'ax + by + c = 0' etc. do { $sym_0 = $this->getSymbol(); $node_0 =& $this->parseIntExpr(); $sym = $this->getSymbol(); // var_dump($sym); - + if (isset($sym['infix']) && $sym['input'] == '/') { $this->chopExpr($sym['symlen']); $node_1 =& $this->parseIntExpr(); - + if ($node_1 === FALSE) { //should show box in place of missing argument $node_1 =& $this->emptyNode(); continue; } $node_1->removeBrackets(); - + // If 'div' -- divide $node_0->removeBrackets(); $node_2 =& $this->createNode(); @@ -617,18 +617,18 @@ class ASCIIMathPHP $node_2->addChild($node_0); $node_2->addChild($node_1); $node_arr[$node_2->getId()] =& $node_2; - + } elseif ($node_0 !== FALSE) { $node_arr[$node_0->getId()] =& $node_0; } } while (!isset($sym['right_bracket']) && $sym !== FALSE && $sym['output'] != ''); - + //var_dump($sym); // Possibly to deal with matrices if (isset($sym['right_bracket'])) { $node_cnt = count($node_arr); $key_node_arr = array_keys($node_arr); - + if ($node_cnt > 1) { $node_5 =& $node_arr[$key_node_arr[$node_cnt-1]]; $node_6 =& $node_arr[$key_node_arr[$node_cnt-2]]; @@ -636,56 +636,56 @@ class ASCIIMathPHP $node_5 = FALSE; $node_6 = FALSE; } - + // Dealing with matrices if ($node_5 !== FALSE && $node_6 !== FALSE && - $node_cnt > 1 && - $node_5->getName() == 'mrow' && + $node_cnt > 1 && + $node_5->getName() == 'mrow' && $node_6->getName() == 'mo' && $node_6->getContent() == ',') { - + // Checking if Node 5 has a LastChild if ($node_7 =& $node_5->getLastChild()) { $node_7_cntnt = $node_7->getContent(); } else { $node_7_cntnt = FALSE; } - + // If there is a right bracket if ($node_7 !== FALSE && ($node_7_cntnt == ']' || $node_7_cntnt == ')')) { - + // Checking if Node 5 has a firstChild if ($node_8 =& $node_5->getFirstChild()) { $node_8_cntnt = $node_8->getContent(); } else { $node_8_cntnt = FALSE; } - + // If there is a matching left bracket - if ($node_8 !== FALSE && + if ($node_8 !== FALSE && (($node_8_cntnt == '(' && $node_7_cntnt == ')' && $sym['output'] != '}') || ($node_8_cntnt == '[' && $node_7_cntnt == ']'))) { - + $is_mtrx_flg = TRUE; $comma_pos_arr = array(); - + $i = 0; - + while ($i < $node_cnt && $is_mtrx_flg) { $tmp_node =& $node_arr[$key_node_arr[$i]]; - + if($tmp_node_first =& $tmp_node->getFirstChild()) { $tnfc = $tmp_node_first->getContent(); } else { $tnfc = FALSE; } - + if($tmp_node_last =& $tmp_node->getLastChild()) { $tnlc = $tmp_node_last->getContent(); } else { $tnlc = FALSE; } - + if (isset($key_node_arr[$i+1])) { $next_tmp_node =& $node_arr[$key_node_arr[$i+1]]; $ntnn = $next_tmp_node->getName(); @@ -694,7 +694,7 @@ class ASCIIMathPHP $ntnn = FALSE; $ntnc = FALSE; } - + // Checking each node in node array for matrix criteria if ($is_mtrx_flg) { $is_mtrx_flg = $tmp_node->getName() == 'mrow' && @@ -705,27 +705,27 @@ class ASCIIMathPHP if ($is_mtrx_flg) { for ($j = 0;$j < $tmp_node->getNumChild();$j++) { $tmp_c_node =& $tmp_node->getChildByIdx($j); - + if ($tmp_c_node->getContent() == ',') { $comma_pos_arr[$i][] = $j; } } - } - + } + if ($is_mtrx_flg && $i > 1) { - + $cnt_cpan = isset($comma_pos_arr[$i]) ? count($comma_pos_arr[$i]) : NULL; $cnt_cpap = isset($comma_pos_arr[$i-2]) ? count($comma_pos_arr[$i-2]) : NULL; $is_mtrx_flg = $cnt_cpan == $cnt_cpap; } - + $i += 2; } - + // If the node passes the matrix tests if ($is_mtrx_flg) { $tab_node_arr = array(); - + for ($i = 0;$i < $node_cnt;$i += 2) { $tmp_key_node_arr = array_keys($node_arr); if (!($tmp_node =& $node_arr[$tmp_key_node_arr[0]])) { @@ -733,71 +733,71 @@ class ASCIIMathPHP } $num_child = $tmp_node->getNumChild(); $k = 0; - + $tmp_node->removeFirstChild(); - + $row_node_arr = array(); $row_frag_node_arr = array(); - + for ($j = 1;$j < ($num_child-1);$j++) { - if (isset($comma_pos_arr[$i][$k]) && + if (isset($comma_pos_arr[$i][$k]) && $j == $comma_pos_arr[$i][$k]) { - + $tmp_node->removeFirstChild(); - + $tmp_c_node =& $this->createNode(); $tmp_c_node->setName('mtd'); $tmp_c_node->addChildArr($row_frag_node_arr); $row_frag_node_arr = array(); - + $row_node_arr[$tmp_c_node->getId()] =& $tmp_c_node; - + $k++; } else { - + if ($tmp_c_node =& $tmp_node->getFirstChild()) { $row_frag_node_arr[$tmp_c_node->getId()] =& $tmp_c_node; $tmp_node->removeFirstChild(); } } } - + $tmp_c_node =& $this->createNode(); $tmp_c_node->setName('mtd'); $tmp_c_node->addChildArr($row_frag_node_arr); - + $row_node_arr[$tmp_c_node->getId()] =& $tmp_c_node; - + if (count($node_arr) > 2) { $tmp_key_node_arr = array_keys($node_arr); unset($node_arr[$tmp_key_node_arr[0]]); unset($node_arr[$tmp_key_node_arr[1]]); } - + $tmp_c_node =& $this->createNode(); $tmp_c_node->setName('mtr'); $tmp_c_node->addChildArr($row_node_arr); - + $tab_node_arr[$tmp_c_node->getId()] =& $tmp_c_node; } - + $tmp_c_node =& $this->createNode(); $tmp_c_node->setName('mtable'); $tmp_c_node->addChildArr($tab_node_arr); - + if (isset($sym['invisible'])) { $tmp_c_node->setAttr('columnalign','left'); } - + $key_node_arr = array_keys($node_arr); $tmp_c_node->setId($key_node_arr[0]); - + $node_arr[$tmp_c_node->getId()] =& $tmp_c_node; } } } } - + $this->chopExpr($sym['symlen']); if (!isset($sym['invisible'])) { $node_7 =& $this->createNode(); @@ -806,19 +806,19 @@ class ASCIIMathPHP $node_arr[$node_7->getId()] =& $node_7; } } - + return($node_arr); } - + function & parseSmplExpr() { $sym = $this->getSymbol(); - - if (!$sym || isset($sym['right_bracket'])) //return FALSE; + + if (!$sym || isset($sym['right_bracket'])) //return FALSE; return $this->emptyNode(); - + $this->chopExpr($sym['symlen']); - + // 2005-06-11 wes: add definition type support if(isset($sym['definition'])) { $this->pushExpr($sym['output']); @@ -828,35 +828,35 @@ class ASCIIMathPHP if (isset($sym['left_bracket'])) { $node_arr = $this->parseExpr(); - + if (isset($sym['invisible'])) { $node_0 =& $this->createNode(); $node_0->setName('mrow'); $node_0->addChildArr($node_arr); - + return($node_0); } else { $node_0 =& $this->createNode(); $node_0->setName('mo'); $node_0->setContent($sym['output']); - + $node_1 =& $this->createNode(); $node_1->setName('mrow'); $node_1->addChild($node_0); $node_1->addChildArr($node_arr); - + return($node_1); } } elseif (isset($sym['unary'])) { - + if ($sym['input'] == 'sqrt') { $node_0 =& $this->parseSmplExpr(); $node_0->removeBrackets(); - + $node_1 =& $this->createNode(); $node_1->setName($sym['tag']); $node_1->addChild($node_0); - + return($node_1); } elseif (isset($sym['func'])) { //added 2006-9-7 David Lippman $expr = ltrim($this->getCurrExpr()); @@ -901,52 +901,52 @@ class ASCIIMathPHP } $txt = substr($expr,1,strpos($expr,$end_brckt)-1); } - + //$txt = substr($expr,1,strpos($expr,$end_brckt)-1); $len = strlen($txt); - + $node_0 =& $this->createNode(); $node_0->setName('mrow'); - + if ($len > 0) { if ($txt{0} == " ") { $node_1 =& $this->createNode(); $node_1->setName('mspace'); $node_1->setAttr('width','1ex'); - + $node_0->addChild($node_1); } - + $node_3 =& $this->createNode(); $node_3->setName($sym['tag']); $node_3->setContent(trim($txt)); - + $node_0->addChild($node_3); - + if ($len > 1 && $txt{$len-1} == " ") { $node_2 =& $this->createNode(); $node_2->setName('mspace'); $node_2->setAttr('width','1ex'); - + $node_0->addChild($node_2); } - + $this->chopExpr($len+2); } return($node_0); - + } elseif (isset($sym['acc'])) { $node_0 =& $this->parseSmplExpr(); $node_0->removeBrackets(); - + $node_1 =& $this->createNode(); $node_1->setName($sym['tag']); $node_1->addChild($node_0); - + $node_2 =& $this->createNode(); $node_2->setName('mo'); $node_2->setContent($sym['output']); - + $node_1->addChild($node_2); return($node_1); } else { @@ -954,13 +954,13 @@ class ASCIIMathPHP } } elseif (isset($sym['binary'])) { $node_arr = array(); - + $node_0 =& $this->parseSmplExpr(); $node_0->removeBrackets(); - + $node_1 =& $this->parseSmplExpr(); $node_1->removeBrackets(); - + /* 2005-06-05 wes: added stackrel */ if ($sym['input'] == 'root' || $sym['input'] == 'stackrel') { $node_arr[$node_1->getId()] =& $node_1; @@ -969,78 +969,78 @@ class ASCIIMathPHP $node_arr[$node_0->getId()] =& $node_0; $node_arr[$node_1->getId()] =& $node_1; } - + $node_2 =& $this->createNode(); $node_2->setName($sym['tag']); $node_2->addChildArr($node_arr); - + return($node_2); } elseif (isset($sym['infix'])) { $node_0 =& $this->createNode(); $node_0->setName('mo'); $node_0->setContent($sym['output']); - + return($node_0); } elseif (isset($sym['space'])) { $node_0 =& $this->createNode(); $node_0->setName('mrow'); - + $node_1 =& $this->createNode(); $node_1->setName('mspace'); $node_1->setAttr('width',$sym['space']); - + $node_2 =& $this->createNode(); $node_2->setName($sym['tag']); $node_2->setContent($sym['output']); - + $node_3 =& $this->createNode(); $node_3->setName('mspace'); $node_3->setAttr('width',$sym['space']); - + $node_0->addChild($node_1); $node_0->addChild($node_2); $node_0->addChild($node_3); - + return($node_0); } else { - + // A constant $node_0 =& $this->createNode(); $node_0->setName($sym['tag']); $node_0->setContent($sym['output']); return($node_0); } - + // Return an empty node return $this->emptyNode(); } - + function getMathML() { $root =& $this->_node_arr[0]; return($root->dumpXML()); } - + function getCurrExpr() { return($this->_curr_expr); } - + function setCurrExpr($str) { $this->_curr_expr = $str; } - + function getExpr() { return($this->_expr); } - + function getPrevExpr() { return($this->_prev_expr); } - + function & createNode() { $node =& new MathMLNode($this->_node_cntr); @@ -1049,46 +1049,46 @@ class ASCIIMathPHP $this->_node_cntr++; return($node); } - + /** * Gets the largest symbol in the expression (greedy). Changed from non-greedy 26-Apr-2006 - * + * * @parameter boolean[optional] Chop original string? * * @return mixed - * + * * @access private */ function getSymbol($chop_flg = FALSE) { - // Implemented a reverse symbol matcher. + // Implemented a reverse symbol matcher. // Instead of going front to back, it goes back to front. Steven 26-Apr-2006 $chr_cnt = strlen($this->_curr_expr); - + if ($chr_cnt == 0) return FALSE; - + for ($i = $chr_cnt; $i > 0; $i--) { $sym_0 = substr($this->_curr_expr,0,$i); - + // Reading string for numeric values if (is_numeric($sym_0)) { - + if ($chop_flg) $this->chopExpr($i); return array('input'=>$sym_0, 'tag'=>'mn', 'output'=>$sym_0, 'symlen'=>$i); - + } elseif (isset($this->_symbol_arr[$sym_0])) { - + if ($chop_flg) $this->chopExpr($i); $sym_arr = $this->_symbol_arr[$sym_0]; $sym_arr['symlen'] = $i; return $sym_arr; } } - + // Reading string for alphabetic constants and the minus sign $char = $this->_curr_expr{0}; $len_left = $chop_flg ? $this->chopExpr(1) : strlen($this->_curr_expr)-1; - + // Deals with expressions of length 1 if ($len_left == 0 && isset($this->_symbol_arr[$char])) { $sym_arr = $this->_symbol_arr[$char]; @@ -1099,11 +1099,11 @@ class ASCIIMathPHP return array('input'=>$char, 'tag'=>$tag, 'output'=>$char, 'symlen'=>1); } } - + function chopExpr($strlen) { $this->_prev_expr = $this->_curr_expr; - + if ($strlen == strlen($this->_curr_expr)) { $this->_curr_expr = ''; return(0); @@ -1111,6 +1111,6 @@ class ASCIIMathPHP $this->_curr_expr = ltrim(substr($this->_curr_expr,$strlen)); return(strlen($this->_curr_expr)); } - } + } } ?> diff --git a/lib/DbSession/PDO.php b/lib/DbSession/PDO.php index 6eafc6ebc..289d7d758 100644 --- a/lib/DbSession/PDO.php +++ b/lib/DbSession/PDO.php @@ -1,6 +1,6 @@ _dbh; } - + function query($sql) { return $this->_backend->query($sql); } @@ -56,7 +56,7 @@ extends DbSession * Actually this function is a fake for session_set_save_handle. * @param string $save_path a path to stored files * @param string $session_name a name of the concrete file - * @return boolean true just a variable to notify PHP that everything + * @return boolean true just a variable to notify PHP that everything * is good. * @access private */ @@ -70,7 +70,7 @@ extends DbSession * * This function is called just after write call. * - * @return boolean true just a variable to notify PHP that everything + * @return boolean true just a variable to notify PHP that everything * is good. * @access private */ @@ -106,11 +106,11 @@ extends DbSession } return $res; } - + /** * Saves the session data into DB. * - * Just a comment: The "write" handler is not + * Just a comment: The "write" handler is not * executed until after the output stream is closed. Thus, * output from debugging statements in the "write" handler * will never be seen in the browser. If debugging output @@ -124,8 +124,8 @@ extends DbSession * @access private */ function write ($id, $sess_data) { - if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return; - + if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return; + $dbh = $this->_connect(); $table = $this->_table; $time = time(); @@ -183,7 +183,7 @@ extends DbSession * Removes a session from the table. * * @param string $id - * @return boolean true + * @return boolean true * @access private */ function destroy ($id) { @@ -193,7 +193,7 @@ extends DbSession $sth->bindParam(1, $id, PDO_PARAM_STR, 32); $sth->execute(); $this->_disconnect(); - return true; + return true; } /** @@ -214,7 +214,7 @@ extends DbSession return true; } - // WhoIsOnline support. + // WhoIsOnline support. // TODO: ip-accesstime dynamic blocking API function currentSessions() { $sessions = array(); diff --git a/lib/DbSession/SQL.php b/lib/DbSession/SQL.php index 3823c44d3..833052a63 100644 --- a/lib/DbSession/SQL.php +++ b/lib/DbSession/SQL.php @@ -42,7 +42,7 @@ extends DbSession } return $dbh; } - + function query($sql) { return $this->_dbh->query($sql); } @@ -62,7 +62,7 @@ extends DbSession * Actually this function is a fake for session_set_save_handle. * @param string $save_path a path to stored files * @param string $session_name a name of the concrete file - * @return boolean true just a variable to notify PHP that everything + * @return boolean true just a variable to notify PHP that everything * is good. * @access private */ @@ -76,7 +76,7 @@ extends DbSession * * This function is called just after write call. * - * @return boolean true just a variable to notify PHP that everything + * @return boolean true just a variable to notify PHP that everything * is good. * @access private */ @@ -97,7 +97,7 @@ extends DbSession $dbh = $this->_connect(); $table = $this->_table; $qid = $dbh->quote($id); - + $res = $dbh->getOne("SELECT sess_data FROM $table WHERE sess_id=$qid"); $this->_disconnect(); @@ -114,11 +114,11 @@ extends DbSession } return $res; } - + /** * Saves the session data into DB. * - * Just a comment: The "write" handler is not + * Just a comment: The "write" handler is not * executed until after the output stream is closed. Thus, * output from debugging statements in the "write" handler * will never be seen in the browser. If debugging output @@ -132,8 +132,8 @@ extends DbSession * @access private */ function write ($id, $sess_data) { - if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return; - + if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return; + $dbh = $this->_connect(); //$dbh->unlock(false,1); $table = $this->_table; @@ -178,7 +178,7 @@ extends DbSession * Removes a session from the table. * * @param string $id - * @return boolean true + * @return boolean true * @access private */ function destroy ($id) { @@ -189,7 +189,7 @@ extends DbSession $dbh->query("DELETE FROM $table WHERE sess_id=$qid"); $this->_disconnect(); - return true; + return true; } /** diff --git a/lib/DbSession/dba.php b/lib/DbSession/dba.php index a0f8004bb..7efd4ae90 100644 --- a/lib/DbSession/dba.php +++ b/lib/DbSession/dba.php @@ -5,7 +5,7 @@ * Index: session_id * Values: date : IP : data * Already open sessions, e.g. interim xmlrpc requests are - * are treated specially. see write(). + * are treated specially. see write(). * To avoid deadlocks in the session.db3 access, * the db is opened and closed for each access. * @author: Reini Urban. @@ -78,7 +78,7 @@ extends DbSession } return $packed; } - + function write ($id, $sess_data) { if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return; @@ -114,7 +114,7 @@ extends DbSession return true; } - // WhoIsOnline support. + // WhoIsOnline support. // TODO: ip-accesstime dynamic blocking API function currentSessions() { $sessions = array(); diff --git a/lib/WikiDB/ADODB.php b/lib/WikiDB/ADODB.php index b1cd8645e..c1e9ee779 100644 --- a/lib/WikiDB/ADODB.php +++ b/lib/WikiDB/ADODB.php @@ -37,7 +37,7 @@ class WikiDB_ADODB extends WikiDB if (!$backend->_dbh->_connectionID) return false; $this->WikiDB($backend, $dbparams); } - + /** * Determine whether page exists (in non-default form). * @see WikiDB::isWikiPage diff --git a/lib/WikiDB/PDO.php b/lib/WikiDB/PDO.php index 99dcf91d8..ce068e4a1 100644 --- a/lib/WikiDB/PDO.php +++ b/lib/WikiDB/PDO.php @@ -35,7 +35,7 @@ class WikiDB_PDO extends WikiDB $backend = new $backend_class($dbparams); $this->WikiDB($backend, $dbparams); } - + /** * Determine whether page exists (in non-default form). * @see WikiDB::isWikiPage diff --git a/lib/WikiDB/SQL.php b/lib/WikiDB/SQL.php index ae5d278c8..de48de0f2 100644 --- a/lib/WikiDB/SQL.php +++ b/lib/WikiDB/SQL.php @@ -26,7 +26,7 @@ class WikiDB_SQL extends WikiDB if (DB::isError($backend->_dbh)) return; $this->WikiDB($backend, $dbparams); } - + function view_dsn ($dsn = false) { if (!$dsn) $dsninfo = DB::parseDSN($GLOBALS['DBParams']['dsn']); @@ -40,7 +40,7 @@ class WikiDB_SQL extends WikiDB ); } - + /** * Determine whether page exists (in non-default form). * @see WikiDB::isWikiPage for the slow generic version diff --git a/lib/WikiDB/adodb/adodb-csvlib.inc.php b/lib/WikiDB/adodb/adodb-csvlib.inc.php index 17a606a3f..01ade4d9f 100644 --- a/lib/WikiDB/adodb/adodb-csvlib.inc.php +++ b/lib/WikiDB/adodb/adodb-csvlib.inc.php @@ -2,18 +2,18 @@ global $ADODB_INCLUDED_CSV; $ADODB_INCLUDED_CSV = 1; -/* +/* V4.22 15 Apr 2004 (c) 2000-2004 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. + 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. Set tabs to 4 for best viewing. - + Latest version is available at http://php.weblogs.com/ - - Library for CSV serialization. This is used by the csv/proxy driver and is the - CacheExecute() serialization format. - + + Library for CSV serialization. This is used by the csv/proxy driver and is the + CacheExecute() serialization format. + ==== NOTE ==== Format documented at http://php.weblogs.com/ADODB_CSV ============== @@ -29,55 +29,55 @@ $ADODB_INCLUDED_CSV = 1; function _rs2serialize(&$rs,$conn=false,$sql='') { $max = ($rs) ? $rs->FieldCount() : 0; - + if ($sql) $sql = urlencode($sql); // metadata setup - + if ($max <= 0 || $rs->dataProvider == 'empty') { // is insert/update/delete if (is_object($conn)) { $sql .= ','.$conn->Affected_Rows(); $sql .= ','.$conn->Insert_ID(); } else $sql .= ',,'; - + $text = "====-1,0,$sql\n"; return $text; } $tt = ($rs->timeCreated) ? $rs->timeCreated : time(); - + ## changed format from ====0 to ====1 $line = "====1,$tt,$sql\n"; - + if ($rs->databaseType == 'array') { $rows =& $rs->_array; } else { $rows = array(); - while (!$rs->EOF) { + while (!$rs->EOF) { $rows[] = $rs->fields; $rs->MoveNext(); - } + } } - + for($i=0; $i < $max; $i++) { $o =& $rs->FetchField($i); $flds[] = $o; } - + $rs =& new ADORecordSet_array(); $rs->InitArrayFields($rows,$flds); return $line.serialize($rs); } - + /** -* Open CSV file and convert it into Data. +* Open CSV file and convert it into Data. * * @param url file/ftp/http url * @param err returns the error message * @param timeout dispose if recordset has been alive for $timeout secs * * @return recordset, or false if error occured. If no -* error occurred in sql INSERT/UPDATE/DELETE, +* error occurred in sql INSERT/UPDATE/DELETE, * empty recordset is returned */ function &csv2rs($url,&$err,$timeout=0) @@ -91,7 +91,7 @@ $ADODB_INCLUDED_CSV = 1; flock($fp, LOCK_SH); $arr = array(); $ttl = 0; - + if ($meta = fgetcsv($fp, 32000, ",")) { // check if error message if (strncmp($meta[0],'****',4) === 0) { @@ -101,10 +101,10 @@ $ADODB_INCLUDED_CSV = 1; } // check for meta data // $meta[0] is -1 means return an empty recordset - // $meta[1] contains a time - + // $meta[1] contains a time + if (strncmp($meta[0], '====',4) === 0) { - + if ($meta[0] == "====-1") { if (sizeof($meta) < 5) { $err = "Corrupt first line for format -1"; @@ -112,7 +112,7 @@ $ADODB_INCLUDED_CSV = 1; return false; } fclose($fp); - + if ($timeout > 0) { $err = " Illegal Timeout $timeout "; return false; @@ -124,9 +124,9 @@ $ADODB_INCLUDED_CSV = 1; $rs->_numOfFields=0; $rs->sql = urldecode($meta[2]); $rs->affectedrows = (integer)$meta[3]; - $rs->insertid = $meta[4]; + $rs->insertid = $meta[4]; return $rs; - } + } # Under high volume loads, we want only 1 thread/process to _write_file # so that we don't have 50 processes queueing to write the same data. # We use probabilistic timeout, ahead of time. @@ -136,7 +136,7 @@ $ADODB_INCLUDED_CSV = 1; # -1 sec after timeout give processes 1/4 chance of timing out # +0 sec after timeout, give processes 100% chance of timing out if (sizeof($meta) > 1) { - if($timeout >0){ + if($timeout >0){ $tdiff = (integer)( $meta[1]+$timeout - time()); if ($tdiff <= 2) { switch($tdiff) { @@ -148,7 +148,7 @@ $ADODB_INCLUDED_CSV = 1; return false; } break; - case 2: + case 2: if ((rand() & 15) == 0) { fclose($fp); $err = "Timeout 2"; @@ -162,12 +162,12 @@ $ADODB_INCLUDED_CSV = 1; return false; } break; - default: + default: fclose($fp); $err = "Timeout 0"; return false; } // switch - + } // if check flush cache }// (timeout>0) $ttl = $meta[1]; @@ -177,7 +177,7 @@ $ADODB_INCLUDED_CSV = 1; if ($meta[0] === '====1') { // slurp in the data $MAXSIZE = 128000; - + $text = fread($fp,$MAXSIZE); if (strlen($text) === $MAXSIZE) { while ($txt = fread($fp,$MAXSIZE)) { @@ -189,7 +189,7 @@ $ADODB_INCLUDED_CSV = 1; if (is_object($rs)) $rs->timeCreated = $ttl; return $rs; } - + $meta = false; $meta = fgetcsv($fp, 32000, ","); if (!$meta) { @@ -219,15 +219,15 @@ $ADODB_INCLUDED_CSV = 1; $err = "Recordset had unexpected EOF 2"; return false; } - + // slurp in the data $MAXSIZE = 128000; - + $text = ''; while ($txt = fread($fp,$MAXSIZE)) { $text .= $txt; } - + fclose($fp); @$arr = unserialize($text); //var_dump($arr); diff --git a/lib/WikiDB/adodb/adodb-error.inc.php b/lib/WikiDB/adodb/adodb-error.inc.php index ea1be0a9c..f9e90e9fe 100644 --- a/lib/WikiDB/adodb/adodb-error.inc.php +++ b/lib/WikiDB/adodb/adodb-error.inc.php @@ -1,12 +1,12 @@ DB_ERROR_CONNECT_FAILED, -924 => DB_ERROR_CONNECT_FAILED ); - + return $MAP; } @@ -183,7 +183,7 @@ static $MAP = array( '-1210' => DB_ERROR_INVALID_DATE, '-1212' => DB_ERROR_INVALID_DATE ); - + return $MAP; } @@ -202,7 +202,7 @@ static $MAP = array( 2291 => DB_ERROR_CONSTRAINT, 2449 => DB_ERROR_CONSTRAINT ); - + return $MAP; } @@ -212,7 +212,7 @@ static $MAP = array( 208 => DB_ERROR_NOSUCHTABLE, 2601 => DB_ERROR_ALREADY_EXISTS ); - + return $MAP; } @@ -221,7 +221,7 @@ function adodb_error_sqlite() static $MAP = array( 1 => DB_ERROR_SYNTAX ); - + return $MAP; } @@ -247,7 +247,7 @@ static $MAP = array( 1048 => DB_ERROR_CONSTRAINT, 2002 => DB_ERROR_CONNECT_FAILED ); - + return $MAP; } ?> \ No newline at end of file diff --git a/lib/WikiDB/adodb/adodb-errorhandler.inc.php b/lib/WikiDB/adodb/adodb-errorhandler.inc.php index c5ed4cc30..1c2597ec8 100644 --- a/lib/WikiDB/adodb/adodb-errorhandler.inc.php +++ b/lib/WikiDB/adodb/adodb-errorhandler.inc.php @@ -12,7 +12,7 @@ */ // added Claudio Bustos clbustos#entelchile.net -if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR); +if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR); define('ADODB_ERROR_HANDLER','ADODB_Error_Handler'); @@ -73,6 +73,6 @@ function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnec //print "

$s

"; - trigger_error($s,ADODB_ERROR_HANDLER_TYPE); + trigger_error($s,ADODB_ERROR_HANDLER_TYPE); } ?> diff --git a/lib/WikiDB/adodb/adodb-errorpear.inc.php b/lib/WikiDB/adodb/adodb-errorpear.inc.php index 5eef52d17..f288d843d 100644 --- a/lib/WikiDB/adodb/adodb-errorpear.inc.php +++ b/lib/WikiDB/adodb/adodb-errorpear.inc.php @@ -1,14 +1,14 @@ !$s

"; } @@ -84,5 +84,5 @@ global $ADODB_Last_PEAR_Error; return $ADODB_Last_PEAR_Error; } - + ?> \ No newline at end of file diff --git a/lib/WikiDB/adodb/adodb-exceptions.inc.php b/lib/WikiDB/adodb/adodb-exceptions.inc.php index c4405db91..31db8091a 100644 --- a/lib/WikiDB/adodb/adodb-exceptions.inc.php +++ b/lib/WikiDB/adodb/adodb-exceptions.inc.php @@ -12,8 +12,8 @@ * * Exception-handling code using PHP5 exceptions (try-catch-throw). */ - -if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR); + +if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR); define('ADODB_ERROR_HANDLER','adodb_throw'); class ADODB_Exception extends Exception { @@ -23,7 +23,7 @@ var $sql = ''; var $params = ''; var $host = ''; var $database = ''; - + function __construct($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection) { switch($fn) { @@ -32,7 +32,7 @@ var $database = ''; $this->params = $p2; $s = "$dbms error: [$errno: $errmsg] in $fn(\"$p1\")\n"; break; - + case 'PCONNECT': case 'CONNECT': $user = $thisConnection->user; @@ -42,13 +42,13 @@ var $database = ''; $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n"; break; } - + $this->dbms = $dbms; $this->host = $thisConnection->host; $this->database = $thisConnection->database; $this->fn = $fn; $this->msg = $errmsg; - + if (!is_numeric($errno)) $errno = -1; parent::__construct($s,$errno); } diff --git a/lib/WikiDB/adodb/adodb-iterator.inc.php b/lib/WikiDB/adodb/adodb-iterator.inc.php index 7d8d03e0a..e21a8a431 100644 --- a/lib/WikiDB/adodb/adodb-iterator.inc.php +++ b/lib/WikiDB/adodb/adodb-iterator.inc.php @@ -2,61 +2,61 @@ /* V4.22 15 Apr 2004 (c) 2000-2004 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, + 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. - + Set tabs to 4. - + PHP5 Iterator Class: - + $rs = $db->Execute("select * from adoxyz"); foreach($rs as $k => $v) { echo $k; print_r($v); echo "
"; } - - + + Iterator code based on http://cvs.php.net/cvs.php/php-src/ext/spl/examples/cachingiterator.inc?login=2 */ - + class ADODB_Iterator implements Iterator { private $rs; - function __construct($rs) + function __construct($rs) { $this->rs = $rs; } - function rewind() + function rewind() { $this->rs->MoveFirst(); } - function valid() + function valid() { return !$this->rs->EOF; } - - function key() + + function key() { return $this->rs->_currentRow; } - - function current() + + function current() { return $this->rs->fields; } - - function next() + + function next() { $this->rs->MoveNext(); } - + function __call($func, $params) { return call_user_func_array(array($this->rs, $func), $params); } - + function __toString() { return 'ADODB Iterator'; @@ -70,6 +70,6 @@ class ADODB_BASE_RS implements IteratorAggregate { function getIterator() { return new ADODB_Iterator($this); } -} +} ?> \ No newline at end of file diff --git a/lib/WikiDB/adodb/adodb-lib.inc.php b/lib/WikiDB/adodb/adodb-lib.inc.php index 489996444..51b177117 100644 --- a/lib/WikiDB/adodb/adodb-lib.inc.php +++ b/lib/WikiDB/adodb/adodb-lib.inc.php @@ -3,18 +3,18 @@ global $ADODB_INCLUDED_LIB; $ADODB_INCLUDED_LIB = 1; -/* +/* @version V4.22 15 Apr 2004 (c) 2000-2004 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. + 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. Set tabs to 4 for best viewing. - - Less commonly used functions are placed here to reduce size of adodb.inc.php. -*/ + + Less commonly used functions are placed here to reduce size of adodb.inc.php. +*/ -// Force key to upper. +// Force key to upper. // See also http://www.php.net/manual/en/function.array-change-key-case.php function _array_change_key_case($an_array) { @@ -33,7 +33,7 @@ function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_ if (count($fieldArray) == 0) return 0; $first = true; $uSet = ''; - + if (!is_array($keyCol)) { $keyCol = array($keyCol); } @@ -43,35 +43,35 @@ function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_ $fieldArray[$k] = $v; } if (in_array($k,$keyCol)) continue; // skip UPDATE if is key - + if ($first) { - $first = false; + $first = false; $uSet = "$k=$v"; } else $uSet .= ",$k=$v"; } - + $where = false; foreach ($keyCol as $v) { if ($where) $where .= " and $v=$fieldArray[$v]"; else $where = "$v=$fieldArray[$v]"; } - + if ($uSet && $where) { $update = "UPDATE $table SET $uSet WHERE $where"; - + $rs = $zthis->Execute($update); if ($rs) { if ($zthis->poorAffectedRows) { /* - The Select count(*) wipes out any errors that the update would have returned. + The Select count(*) wipes out any errors that the update would have returned. http://phplens.com/lens/lensforum/msgs.php?id=5696 */ if ($zthis->ErrorNo()<>0) return 0; - + # affected_rows == 0 if update field values identical to old values - # for mysql - which is silly. - + # for mysql - which is silly. + $cnt = $zthis->GetOne("select count(*) from $table where $where"); if ($cnt > 0) return 1; // record already exists } else @@ -82,17 +82,17 @@ function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_ $first = true; foreach($fieldArray as $k => $v) { if ($has_autoinc && in_array($k,$keyCol)) continue; // skip autoinc col - + if ($first) { - $first = false; + $first = false; $iCols = "$k"; $iVals = "$v"; } else { $iCols .= ",$k"; $iVals .= ",$v"; - } + } } - $insert = "INSERT INTO $table ($iCols) VALUES ($iVals)"; + $insert = "INSERT INTO $table ($iCols) VALUES ($iVals)"; $rs = $zthis->Execute($insert); return ($rs) ? 2 : 0; } @@ -111,7 +111,7 @@ function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=f else $attr =''; $s = "\n"; } /* Count the number of records this sql statement will return by using query rewriting techniques... - + Does not work with UNIONs. */ -function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0) +function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0) { $qryRecs = 0; - + if (preg_match("/^\s*SELECT\s+DISTINCT/is", $sql) || preg_match('/\s+GROUP\s+BY\s+/is',$sql)) { // ok, has SELECT DISTINCT or GROUP BY so see if we can use a table alias // but this is only supported by oracle and postgresql... if ($zthis->dataProvider == 'oci8') { - + $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql); - $rewritesql = "SELECT COUNT(*) FROM ($rewritesql)"; - + $rewritesql = "SELECT COUNT(*) FROM ($rewritesql)"; + } else if ( $zthis->databaseType == 'postgres' || $zthis->databaseType == 'postgres7') { - + $info = $zthis->ServerInfo(); if (substr($info['version'],0,3) >= 7.1) { // good till version 999 $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql); $rewritesql = "SELECT COUNT(*) FROM ($rewritesql) _ADODB_ALIAS_"; } } - } else { + } else { // now replace SELECT ... FROM with SELECT COUNT(*) FROM - + $rewritesql = preg_replace( '/^\s*SELECT\s.*\s+FROM\s/Uis','SELECT COUNT(*) FROM ',$sql); - - // fix by alexander zhukov, alex#unipack.ru, because count(*) and 'order by' fails + + // fix by alexander zhukov, alex#unipack.ru, because count(*) and 'order by' fails // with mssql, access and postgresql. Also a good speedup optimization - skips sorting! - $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$rewritesql); + $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$rewritesql); } - + if (isset($rewritesql) && $rewritesql != $sql) { if ($secs2cache) { // we only use half the time of secs2cache because the count can quickly // become inaccurate if new records are added $qryRecs = $zthis->CacheGetOne($secs2cache/2,$rewritesql,$inputarr); - + } else { $qryRecs = $zthis->GetOne($rewritesql,$inputarr); } if ($qryRecs !== false) return $qryRecs; } - + //-------------------------------------------- // query rewrite failed - so try slower way... - + // strip off unneeded ORDER BY - $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql); + $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql); $rstest = &$zthis->Execute($rewritesql,$inputarr); if ($rstest) { $qryRecs = $rstest->RecordCount(); - if ($qryRecs == -1) { + if ($qryRecs == -1) { global $ADODB_EXTENSION; // some databases will return -1 on MoveLast() - change to MoveNext() if ($ADODB_EXTENSION) { @@ -232,58 +232,58 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0) $rstest->Close(); if ($qryRecs == -1) return 0; } - + return $qryRecs; } /* Code originally from "Cornel G" - This code will not work with SQL that has UNION in it - + This code will not work with SQL that has UNION in it + Also if you are using CachePageExecute(), there is a strong possibility that data will get out of synch. use CachePageExecute() only with tables that rarely change. */ -function &_adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page, - $inputarr=false, $secs2cache=0) +function &_adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page, + $inputarr=false, $secs2cache=0) { $atfirstpage = false; $atlastpage = false; $lastpageno=1; - // If an invalid nrows is supplied, + // If an invalid nrows is supplied, // we assume a default value of 10 rows per page if (!isset($nrows) || $nrows <= 0) $nrows = 10; $qryRecs = false; //count records for no offset - + $qryRecs = _adodb_getcount($zthis,$sql,$inputarr,$secs2cache); $lastpageno = (int) ceil($qryRecs / $nrows); $zthis->_maxRecordCount = $qryRecs; - + // If page number <= 1, then we are at the first page - if (!isset($page) || $page <= 1) { + if (!isset($page) || $page <= 1) { $page = 1; $atfirstpage = true; } - // ***** Here we check whether $page is the last page or - // whether we are trying to retrieve + // ***** Here we check whether $page is the last page or + // whether we are trying to retrieve // a page number greater than the last page number. if ($page >= $lastpageno) { $page = $lastpageno; $atlastpage = true; } - + // We get the data we want $offset = $nrows * ($page-1); - if ($secs2cache > 0) + if ($secs2cache > 0) $rsreturn = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr); - else + else $rsreturn = &$zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache); - + // Before returning the RecordSet, we set the pagination properties we need if ($rsreturn) { $rsreturn->_maxRecordCount = $qryRecs; @@ -297,19 +297,19 @@ function &_adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page, } // Iván Oliva version -function &_adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0) +function &_adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0) { $atfirstpage = false; $atlastpage = false; - + if (!isset($page) || $page <= 1) { // If page number <= 1, then we are at the first page $page = 1; $atfirstpage = true; } if ($nrows <= 0) $nrows = 10; // If an invalid nrows is supplied, we assume a default value of 10 rows per page - - // ***** Here we check whether $page is the last page or whether we are trying to retrieve a page number greater than + + // ***** Here we check whether $page is the last page or whether we are trying to retrieve a page number greater than // the last page number. $pagecounter = $page + 1; $pagecounteroffset = ($pagecounter * $nrows) - $nrows; @@ -331,12 +331,12 @@ function &_adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputar if ($page == 1) $atfirstpage = true; // We have to do this again in case the last page is the same as the first //... page, that is, the recordset has only 1 page. } - + // We get the data we want $offset = $nrows * ($page-1); if ($secs2cache > 0) $rsreturn = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr); else $rsreturn = &$zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache); - + // Before returning the RecordSet, we set the pagination properties we need if ($rsreturn) { $rsreturn->rowsPerPage = $nrows; @@ -353,13 +353,13 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq printf(ADODB_BAD_RS,'GetUpdateSQL'); return false; } - + $fieldUpdatedCount = 0; $arrFields = _array_change_key_case($arrFields); $hasnumeric = isset($rs->fields[0]); $setFields = ''; - + // Loop through all of the fields in the recordset for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) { // Get the field from the recordset @@ -374,14 +374,14 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq // is different from the value passed in then // go ahead and append the field name and new value to // the update query. - + if ($hasnumeric) $val = $rs->fields[$i]; else if (isset($rs->fields[$upperfname])) $val = $rs->fields[$upperfname]; else if (isset($rs->fields[$field->name])) $val = $rs->fields[$field->name]; else if (isset($rs->fields[strtolower($upperfname)])) $val = $rs->fields[strtolower($upperfname)]; else $val = ''; - - + + if ($forceUpdate || strcmp($val, $arrFields[$upperfname])) { // Set the counter for the number of fields that will be updated. $fieldUpdatedCount++; @@ -389,9 +389,9 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq // Based on the datatype of the field // Format the value properly for the database $type = $rs->MetaType($field->type); - + // is_null requires php 4.0.4 - if ((defined('ADODB_FORCE_NULLS') && is_null($arrFields[$upperfname])) || + if ((defined('ADODB_FORCE_NULLS') && is_null($arrFields[$upperfname])) || $arrFields[$upperfname] === 'null') { $setFields .= $field->name . " = null, "; } else { @@ -399,7 +399,7 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq $type = 'C'; } //we do this so each driver can customize the sql for - //DB specific column types. + //DB specific column types. //Oracle needs BLOB types to be handled with a returning clause //postgres has special needs as well $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, @@ -413,23 +413,23 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq if ($fieldUpdatedCount > 0 || $forceUpdate) { // Get the table name from the existing query. preg_match("/FROM\s+".ADODB_TABLE_REGEX."/is", $rs->sql, $tableName); - + // Get the full where clause excluding the word "WHERE" from // the existing query. preg_match('/\sWHERE\s(.*)/is', $rs->sql, $whereClause); - + $discard = false; // not a good hack, improvements? if ($whereClause) preg_match('/\s(LIMIT\s.*)/is', $whereClause[1], $discard); else $whereClause = array(false,false); - + if ($discard) $whereClause[1] = substr($whereClause[1], 0, strlen($whereClause[1]) - strlen($discard[1])); - + $sql = 'UPDATE '.$tableName[1].' SET '.substr($setFields, 0, -2); - if (strlen($whereClause[1]) > 0) + if (strlen($whereClause[1]) > 0) $sql .= ' WHERE '.$whereClause[1]; return $sql; @@ -456,8 +456,8 @@ function adodb_key_exists($key, &$arr) * There is a special case of this function for the oci8 driver. * The proper way to handle an insert w/ a blob in oracle requires * a returning clause with bind variables and a descriptor blob. - * - * + * + * */ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false) { @@ -467,32 +467,32 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false) $recordSet = null; $arrFields = _array_change_key_case($arrFields); $fieldInsertedCount = 0; - + if (is_string($rs)) { //ok we have a table name //try and get the column info ourself. - $tableName = $rs; - + $tableName = $rs; + //we need an object for the recordSet //because we have to call MetaType. //php can't do a $rsclass::MetaType() $rsclass = $zthis->rsPrefix.$zthis->databaseType; $recordSet =& new $rsclass(-1,$zthis->fetchMode); $recordSet->connection = &$zthis; - + $columns = $zthis->MetaColumns( $tableName ); } else if (is_subclass_of($rs, 'adorecordset')) { - for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) + for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) $columns[] = $rs->FetchField($i); $recordSet =& $rs; - + } else { printf(ADODB_BAD_RS,'GetInsertSQL'); return false; } // Loop through all of the fields in the recordset - foreach( $columns as $field ) { + foreach( $columns as $field ) { $upperfname = strtoupper($field->name); if (adodb_key_exists($upperfname,$arrFields)) { @@ -501,32 +501,32 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false) // Get the name of the fields to insert $fields .= $field->name . ", "; - + $type = $recordSet->MetaType($field->type); - - if ((defined('ADODB_FORCE_NULLS') && is_null($arrFields[$upperfname])) || + + if ((defined('ADODB_FORCE_NULLS') && is_null($arrFields[$upperfname])) || $arrFields[$upperfname] === 'null') { $values .= "null, "; } else { //we do this so each driver can customize the sql for - //DB specific column types. + //DB specific column types. //Oracle needs BLOB types to be handled with a returning clause //postgres has special needs as well $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $arrFields, $magicq); - } + } } } // If there were any inserted fields then build the rest of the insert query. if ($fieldInsertedCount <= 0) return false; - + // Get the table name from the existing query. if (!$tableName) { preg_match("/FROM\s+".ADODB_TABLE_REGEX."/is", $rs->sql, $tableName); $tableName = $tableName[1]; - } + } // Strip off the comma and space on the end of both the fields // and their values. @@ -543,20 +543,20 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false) * the update/sql which is generated by GetInsertSQL and GetUpdateSQL. * It handles the string construction of 1 column -> sql string based on * the column type. We want to do 'safe' handling of BLOBs - * + * * @param string the type of sql we are trying to create - * 'I' or 'U'. - * @param string column data type from the db::MetaType() method + * 'I' or 'U'. + * @param string column data type from the db::MetaType() method * @param string the column name * @param array the column value - * + * * @return string - * + * */ -function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $arrFields, $magicq) +function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $arrFields, $magicq) { $sql = ''; - + // Based on the datatype of the field // Format the value properly for the database switch($type) { @@ -564,7 +564,7 @@ function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $arrFields, $mag //in order to handle Blobs correctly, we need //to do some magic for Oracle - //we need to create a new descriptor to handle + //we need to create a new descriptor to handle //this properly if (!empty($zthis->hasReturningInto)) { if ($action == 'I') { @@ -591,7 +591,7 @@ function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $arrFields, $mag //to avoid conflicts w/ dupes. if (!empty($zthis->hasReturningInto)) { if ($action == 'I') { - $sql = ':xx'.$fname.'xx, '; + $sql = ':xx'.$fname.'xx, '; } else { $sql = $fname.'=:xx'.$fname.'xx, '; } @@ -603,18 +603,18 @@ function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $arrFields, $mag //this is to maintain compatibility //with older adodb versions. $sql = _adodb_column_sql($zthis, $action, $type, $fname, $arrFields, $magicq,false); - } + } break; - + default: $sql = _adodb_column_sql($zthis, $action, $type, $fname, $arrFields, $magicq,false); break; } - + return $sql; -} - -function _adodb_column_sql(&$zthis, $action, $type, $fname, $arrFields, $magicq, $recurse=true) +} + +function _adodb_column_sql(&$zthis, $action, $type, $fname, $arrFields, $magicq, $recurse=true) { if ($recurse) { @@ -624,10 +624,10 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $arrFields, $magicq, break; case 'oci8': return _adodb_column_sql_oci8($zthis, $action, $type, $fname, $arrFields, $magicq); - + } } - + $sql = ''; switch($type) { diff --git a/lib/WikiDB/adodb/adodb-pear.inc.php b/lib/WikiDB/adodb/adodb-pear.inc.php index 10263e47e..45d9c2543 100644 --- a/lib/WikiDB/adodb/adodb-pear.inc.php +++ b/lib/WikiDB/adodb/adodb-pear.inc.php @@ -1,12 +1,12 @@ | @@ -15,7 +15,7 @@ /* We support: - + DB_Common --------- query - returns PEAR_Error on error @@ -27,7 +27,7 @@ quote nextID disconnect - + DB_Result --------- numRows - returns -1 if not supported @@ -36,7 +36,7 @@ fetchRows - does not support passing of fetchmode free */ - + define('ADODB_PEAR',dirname(__FILE__)); include_once "PEAR.php"; include_once ADODB_PEAR."/adodb-errorpear.inc.php"; @@ -171,10 +171,10 @@ class DB if (isset($dsninfo['socket'])) $dsninfo['hostspec'] .= ':'.$dsninfo['socket']; else if (isset($dsninfo['port'])) $dsninfo['hostspec'] .= ':'.$dsninfo['port']; - + if($persist) $ok = $obj->PConnect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']); else $ok = $obj->Connect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']); - + if (!$ok) $obj = ADODB_PEAR_Error(); return $obj; } diff --git a/lib/WikiDB/adodb/adodb-php4.inc.php b/lib/WikiDB/adodb/adodb-php4.inc.php index 90ac18b97..dcdb10bca 100644 --- a/lib/WikiDB/adodb/adodb-php4.inc.php +++ b/lib/WikiDB/adodb/adodb-php4.inc.php @@ -2,10 +2,10 @@ /* V4.22 15 Apr 2004 (c) 2000-2004 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, + 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. - + Set tabs to 4. */ diff --git a/lib/WikiDB/adodb/adodb-time.inc.php b/lib/WikiDB/adodb/adodb-time.inc.php index 1f8d08b44..3454959fc 100644 --- a/lib/WikiDB/adodb/adodb-time.inc.php +++ b/lib/WikiDB/adodb/adodb-time.inc.php @@ -4,31 +4,31 @@ ADOdb Date Library, part of the ADOdb abstraction library Download: http://php.weblogs.com/adodb_date_time_library PHP native date functions use integer timestamps for computations. -Because of this, dates are restricted to the years 1901-2038 on Unix -and 1970-2038 on Windows due to integer overflow for dates beyond -those years. This library overcomes these limitations by replacing the -native function's signed integers (normally 32-bits) with PHP floating +Because of this, dates are restricted to the years 1901-2038 on Unix +and 1970-2038 on Windows due to integer overflow for dates beyond +those years. This library overcomes these limitations by replacing the +native function's signed integers (normally 32-bits) with PHP floating point numbers (normally 64-bits). Dates from 100 A.D. to 3000 A.D. and later have been tested. The minimum is 100 A.D. as <100 will invoke the -2 => 4 digit year conversion. The maximum is billions of years in the -future, but this is a theoretical limit as the computation of that year +2 => 4 digit year conversion. The maximum is billions of years in the +future, but this is a theoretical limit as the computation of that year would take too long with the current implementation of adodb_mktime(). This library replaces native functions as follows: -
	
+
 	getdate()  with  adodb_getdate()
-	date()     with  adodb_date() 
+	date()     with  adodb_date()
 	gmdate()   with  adodb_gmdate()
 	mktime()   with  adodb_mktime()
 	gmmktime() with  adodb_gmmktime()
 
- + The parameters are identical, except that adodb_date() accepts a subset -of date()'s field formats. Mktime() will convert from local time to GMT, -and date() will convert from GMT to local time, but daylight savings is +of date()'s field formats. Mktime() will convert from local time to GMT, +and date() will convert from GMT to local time, but daylight savings is not handled currently. This library is independant of the rest of ADOdb, and can be used @@ -37,18 +37,18 @@ as standalone code. PERFORMANCE For high speed, this library uses the native date functions where -possible, and only switches to PHP code when the dates fall outside +possible, and only switches to PHP code when the dates fall outside the 32-bit signed integer range. GREGORIAN CORRECTION -Pope Gregory shortened October of A.D. 1582 by ten days. Thursday, -October 4, 1582 (Julian) was followed immediately by Friday, October 15, -1582 (Gregorian). +Pope Gregory shortened October of A.D. 1582 by ten days. Thursday, +October 4, 1582 (Julian) was followed immediately by Friday, October 15, +1582 (Gregorian). Since 0.06, we handle this correctly, so: -adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582) +adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582) == 24 * 3600 (1 day) ============================================================================= @@ -87,45 +87,45 @@ outside the 1901 to 2038 range. The format fields that adodb_date supports:
-a - "am" or "pm" 
-A - "AM" or "PM" 
-d - day of the month, 2 digits with leading zeros; i.e. "01" to "31" 
-D - day of the week, textual, 3 letters; e.g. "Fri" 
-F - month, textual, long; e.g. "January" 
-g - hour, 12-hour format without leading zeros; i.e. "1" to "12" 
-G - hour, 24-hour format without leading zeros; i.e. "0" to "23" 
-h - hour, 12-hour format; i.e. "01" to "12" 
-H - hour, 24-hour format; i.e. "00" to "23" 
-i - minutes; i.e. "00" to "59" 
-j - day of the month without leading zeros; i.e. "1" to "31" 
-l (lowercase 'L') - day of the week, textual, long; e.g. "Friday"  
-L - boolean for whether it is a leap year; i.e. "0" or "1" 
-m - month; i.e. "01" to "12" 
-M - month, textual, 3 letters; e.g. "Jan" 
-n - month without leading zeros; i.e. "1" to "12" 
-O - Difference to Greenwich time in hours; e.g. "+0200" 
-Q - Quarter, as in 1, 2, 3, 4 
-r - RFC 822 formatted date; e.g. "Thu, 21 Dec 2000 16:01:07 +0200" 
-s - seconds; i.e. "00" to "59" 
-S - English ordinal suffix for the day of the month, 2 characters; 
-   			i.e. "st", "nd", "rd" or "th" 
+a - "am" or "pm"
+A - "AM" or "PM"
+d - day of the month, 2 digits with leading zeros; i.e. "01" to "31"
+D - day of the week, textual, 3 letters; e.g. "Fri"
+F - month, textual, long; e.g. "January"
+g - hour, 12-hour format without leading zeros; i.e. "1" to "12"
+G - hour, 24-hour format without leading zeros; i.e. "0" to "23"
+h - hour, 12-hour format; i.e. "01" to "12"
+H - hour, 24-hour format; i.e. "00" to "23"
+i - minutes; i.e. "00" to "59"
+j - day of the month without leading zeros; i.e. "1" to "31"
+l (lowercase 'L') - day of the week, textual, long; e.g. "Friday"
+L - boolean for whether it is a leap year; i.e. "0" or "1"
+m - month; i.e. "01" to "12"
+M - month, textual, 3 letters; e.g. "Jan"
+n - month without leading zeros; i.e. "1" to "12"
+O - Difference to Greenwich time in hours; e.g. "+0200"
+Q - Quarter, as in 1, 2, 3, 4
+r - RFC 822 formatted date; e.g. "Thu, 21 Dec 2000 16:01:07 +0200"
+s - seconds; i.e. "00" to "59"
+S - English ordinal suffix for the day of the month, 2 characters;
+   			i.e. "st", "nd", "rd" or "th"
 t - number of days in the given month; i.e. "28" to "31"
-T - Timezone setting of this machine; e.g. "EST" or "MDT" 
-U - seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)  
-w - day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday) 
-Y - year, 4 digits; e.g. "1999" 
-y - year, 2 digits; e.g. "99" 
-z - day of the year; i.e. "0" to "365" 
-Z - timezone offset in seconds (i.e. "-43200" to "43200"). 
-   			The offset for timezones west of UTC is always negative, 
-			and for those east of UTC is always positive. 
+T - Timezone setting of this machine; e.g. "EST" or "MDT"
+U - seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
+w - day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday)
+Y - year, 4 digits; e.g. "1999"
+y - year, 2 digits; e.g. "99"
+z - day of the year; i.e. "0" to "365"
+Z - timezone offset in seconds (i.e. "-43200" to "43200").
+   			The offset for timezones west of UTC is always negative,
+			and for those east of UTC is always positive.
 
Unsupported:
-B - Swatch Internet time 
+B - Swatch Internet time
 I (capital i) - "1" if Daylight Savings Time, "0" otherwise.
-W - ISO-8601 week number of year, weeks starting on Monday 
+W - ISO-8601 week number of year, weeks starting on Monday
 
 
@@ -160,13 +160,13 @@ NOTES Useful url for generating test timestamps: http://www.4webhelp.net/us/timestamp.php -Possible future optimizations include +Possible future optimizations include -a. Using an algorithm similar to Plauger's in "The Standard C Library" -(page 428, xttotm.c _Ttotm() function). Plauger's algorithm will not +a. Using an algorithm similar to Plauger's in "The Standard C Library" +(page 428, xttotm.c _Ttotm() function). Plauger's algorithm will not work outside 32-bit signed range, so i decided not to implement it. -b. Iterate over a block of years (say 12) when searching for the +b. Iterate over a block of years (say 12) when searching for the correct year. c. Implement daylight savings, which looks awfully complicated, see @@ -178,11 +178,11 @@ CHANGELOG Fixed month calculation error in adodb_date. 2102-June-01 appeared as 2102-May-32. - 26 Oct 2003 0.11 -Because of daylight savings problems (some systems apply daylight savings to +Because of daylight savings problems (some systems apply daylight savings to January!!!), changed adodb_get_gmt_diff() to ignore daylight savings. - 9 Aug 2003 0.10 -Fixed bug with dates after 2038. +Fixed bug with dates after 2038. See http://phplens.com/lens/lensforum/msgs.php?id=6980 - 1 July 2003 0.09 @@ -212,14 +212,14 @@ Day overflow for less than one month's days is supported. - 28 Jan 2003 0.04 -Gregorian correction handled. In PHP5, we might throw an error if +Gregorian correction handled. In PHP5, we might throw an error if mktime uses invalid dates around 5-14 Oct 1582. Released with ADOdb 3.10. Added limbo 5-14 Oct 1582 check, when we set to 15 Oct 1582. - 27 Jan 2003 0.03 Fixed some more month problems due to gmt issues. Added constant ADODB_DATE_VERSION. -Fixed calculation of days since start of year for <1970. +Fixed calculation of days since start of year for <1970. - 27 Jan 2003 0.02 @@ -241,13 +241,13 @@ define('ADODB_DATE_VERSION',0.12); /* We check for Windows as only +ve ints are accepted as dates on Windows. - + Apparently this problem happens also with Linux, RH 7.3 and later! - + glibc-2.2.5-34 and greater has been changed to return -1 for dates < 1970. This used to work. The problem exists with RedHat 7.3 and 8.0 echo (mktime(0, 0, 0, 1, 1, 1960)); // prints -1 - + References: http://bugs.php.net/bug.php?id=20048&edit=2 http://lists.debian.org/debian-glibc/2002/debian-glibc-200205/msg00010.html @@ -270,43 +270,43 @@ function adodb_date_test_date($y1,$m) */ function adodb_date_test() { - + error_reporting(E_ALL); print "

Testing adodb_date and adodb_mktime. version=".ADODB_DATE_VERSION. "

"; set_time_limit(0); $fail = false; - + // This flag disables calling of PHP native functions, so we can properly test the code if (!defined('ADODB_TEST_DATES')) define('ADODB_TEST_DATES',1); - + $t = adodb_mktime(0,0,0,6,1,2102); if (!(adodb_date('Y-m-d',$t) == '2102-06-01')) print 'Error in '.adodb_date('Y-m-d',$t).'
'; - + $t = adodb_mktime(0,0,0,2,1,2102); if (!(adodb_date('Y-m-d',$t) == '2102-02-01')) print 'Error in '.adodb_date('Y-m-d',$t).'
'; - - + + print "

Testing gregorian <=> julian conversion

"; $t = adodb_mktime(0,0,0,10,11,1492); //http://www.holidayorigins.com/html/columbus_day.html - Friday check if (!(adodb_date('D Y-m-d',$t) == 'Fri 1492-10-11')) print 'Error in Columbus landing
'; - + $t = adodb_mktime(0,0,0,2,29,1500); if (!(adodb_date('Y-m-d',$t) == '1500-02-29')) print 'Error in julian leap years
'; - + $t = adodb_mktime(0,0,0,2,29,1700); if (!(adodb_date('Y-m-d',$t) == '1700-03-01')) print 'Error in gregorian leap years
'; - + print adodb_mktime(0,0,0,10,4,1582).' '; print adodb_mktime(0,0,0,10,15,1582); $diff = (adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582)); if ($diff != 3600*24) print " Error in gregorian correction = ".($diff/3600/24)." days
"; - + print " 15 Oct 1582, Fri=".(adodb_dow(1582,10,15) == 5 ? 'Fri' : 'Error')."
"; print " 4 Oct 1582, Thu=".(adodb_dow(1582,10,4) == 4 ? 'Thu' : 'Error')."
"; - + print "

Testing overflow

"; - + $t = adodb_mktime(0,0,0,3,33,1965); if (!(adodb_date('Y-m-d',$t) == '1965-04-02')) print 'Error in day overflow 1
'; $t = adodb_mktime(0,0,0,4,33,1971); @@ -319,7 +319,7 @@ function adodb_date_test() if (!(adodb_date('Y-m-d',$t) == '1966-02-01')) print 'Error in day overflow 5 '.adodb_date('Y-m-d',$t).'
'; $t = adodb_mktime(0,0,0,13,3,1965); if (!(adodb_date('Y-m-d',$t) == '1966-01-03')) print 'Error in mth overflow 1
'; - + print "Testing 2-digit => 4-digit year conversion

"; if (adodb_year_digit_check(00) != 2000) print "Err 2-digit 2000
"; if (adodb_year_digit_check(10) != 2010) print "Err 2-digit 2010
"; @@ -328,7 +328,7 @@ function adodb_date_test() if (adodb_year_digit_check(40) != 1940) print "Err 2-digit 1940
"; if (adodb_year_digit_check(50) != 1950) print "Err 2-digit 1950
"; if (adodb_year_digit_check(90) != 1990) print "Err 2-digit 1990
"; - + // Test string formating print "

Testing date formating

"; $fmt = '\d\a\t\e T Y-m-d H:i:s a A d D F g G h H i j l L m M n O \R\F\C822 r s t U w y Y z Z 2003'; @@ -353,12 +353,12 @@ function adodb_date_test() break; } } - print "Error date(): $ts
 
+			print "Error date(): $ts
   \"$s1\" (date len=".strlen($s1).")
   \"$s2\" (adodb_date len=".strlen($s2).")

"; $fail = true; } - + $a1 = getdate($ts); $a2 = adodb_getdate($ts); $rez = array_diff($a1,$a2); @@ -371,7 +371,7 @@ function adodb_date_test() $fail = true; } } - + // Test generation of dates outside 1901-2038 print "

Testing random dates between 100 and 4000

"; adodb_date_test_date(100,1); @@ -379,7 +379,7 @@ function adodb_date_test() $y1 = 100+rand(0,1970-100); $m = rand(1,12); adodb_date_test_date($y1,$m); - + $y1 = 3000-rand(0,3000-1970); adodb_date_test_date($y1,$m); } @@ -390,11 +390,11 @@ function adodb_date_test() $offset = 36000+rand(10000,60000); $max = 365*$yrs*86400; $lastyear = 0; - + // we generate a timestamp, convert it to a date, and convert it back to a timestamp // and check if the roundtrip broke the original timestamp value. print "Testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: "; - + for ($max += $i; $i < $max; $i += $offset) { $ret = adodb_date('m,d,Y,H,i,s',$i); $arr = explode(',',$ret); @@ -410,71 +410,71 @@ function adodb_date_test() break; } } - + if (!$fail) print "

Passed !

"; else print "

Failed :-(

"; } /** - Returns day of week, 0 = Sunday,... 6=Saturday. + Returns day of week, 0 = Sunday,... 6=Saturday. Algorithm from PEAR::Date_Calc */ function adodb_dow($year, $month, $day) { /* -Pope Gregory removed 10 days - October 5 to October 14 - from the year 1582 and -proclaimed that from that time onwards 3 days would be dropped from the calendar +Pope Gregory removed 10 days - October 5 to October 14 - from the year 1582 and +proclaimed that from that time onwards 3 days would be dropped from the calendar every 400 years. -Thursday, October 4, 1582 (Julian) was followed immediately by Friday, October 15, 1582 (Gregorian). +Thursday, October 4, 1582 (Julian) was followed immediately by Friday, October 15, 1582 (Gregorian). */ if ($year <= 1582) { - if ($year < 1582 || + if ($year < 1582 || ($year == 1582 && ($month < 10 || ($month == 10 && $day < 15)))) $greg_correction = 3; else $greg_correction = 0; } else $greg_correction = 0; - + if($month > 2) $month -= 2; else { $month += 10; $year--; } - + $day = ( floor((13 * $month - 1) / 5) + $day + ($year % 100) + floor(($year % 100) / 4) + floor(($year / 100) / 4) - 2 * floor($year / 100) + 77); - + return (($day - 7 * floor($day / 7))) + $greg_correction; } /** - Checks for leap year, returns true if it is. No 2-digit year check. Also + Checks for leap year, returns true if it is. No 2-digit year check. Also handles julian calendar correctly. */ -function _adodb_is_leap_year($year) +function _adodb_is_leap_year($year) { if ($year % 4 != 0) return false; - + if ($year % 400 == 0) { return true; // if gregorian calendar (>1582), century not-divisible by 400 is not leap } else if ($year > 1582 && $year % 100 == 0 ) { return false; - } - + } + return true; } /** checks for leap year, returns true if it is. Has 2-digit year check */ -function adodb_is_leap_year($year) +function adodb_is_leap_year($year) { return _adodb_is_leap_year(adodb_year_digit_check($year)); } @@ -483,13 +483,13 @@ function adodb_is_leap_year($year) Fix 2-digit years. Works for any century. Assumes that if 2-digit is more than 30 years in future, then previous century. */ -function adodb_year_digit_check($y) +function adodb_year_digit_check($y) { if ($y < 100) { - + $yr = (integer) date("Y"); $century = (integer) ($yr /100); - + if ($yr%100 > 50) { $c1 = $century + 1; $c0 = $century; @@ -509,11 +509,11 @@ function adodb_year_digit_check($y) /** get local time zone offset from GMT */ -function adodb_get_gmt_diff() +function adodb_get_gmt_diff() { static $TZ; if (isset($TZ)) return $TZ; - + $TZ = mktime(0,0,0,1,2,1970,0) - gmmktime(0,0,0,1,2,1970,0); return $TZ; } @@ -541,23 +541,23 @@ function adodb_getdate($d=false,$fast=false) function _adodb_getdate($origd=false,$fast=false,$is_gmt=false) { $d = $origd - ($is_gmt ? 0 : adodb_get_gmt_diff()); - + $_day_power = 86400; $_hour_power = 3600; $_min_power = 60; - - if ($d < -12219321600) $d -= 86400*10; // if 15 Oct 1582 or earlier, gregorian correction - + + if ($d < -12219321600) $d -= 86400*10; // if 15 Oct 1582 or earlier, gregorian correction + $_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); $_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); - + if ($d < 0) { $origd = $d; - // The valid range of a 32bit signed timestamp is typically from + // The valid range of a 32bit signed timestamp is typically from // Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT for ($a = 1970 ; --$a >= 0;) { $lastd = $d; - + if ($leaf = _adodb_is_leap_year($a)) { $d += $_day_power * 366; } else @@ -567,9 +567,9 @@ function _adodb_getdate($origd=false,$fast=false,$is_gmt=false) break; } } - + $secsInYear = 86400 * ($leaf ? 366 : 365) + $lastd; - + $d = $lastd; $mtab = ($leaf) ? $_month_table_leaf : $_month_table_normal; for ($a = 13 ; --$a > 0;) { @@ -581,18 +581,18 @@ function _adodb_getdate($origd=false,$fast=false,$is_gmt=false) break; } } - + $d = $lastd; $day = $ndays + ceil(($d+1) / ($_day_power)); $d += ($ndays - $day+1)* $_day_power; $hour = floor($d/$_hour_power); - + } else { - + for ($a = 1970 ;; $a++) { $lastd = $d; - + if ($leaf = _adodb_is_leap_year($a)) { $d -= $_day_power * 366; } else @@ -619,7 +619,7 @@ function _adodb_getdate($origd=false,$fast=false,$is_gmt=false) $d = $d - ($day-1) * $_day_power; $hour = floor($d /$_hour_power); } - + $d -= $hour * $_hour_power; $min = floor($d/$_min_power); $secs = $d - $min * $_min_power; @@ -636,8 +636,8 @@ function _adodb_getdate($origd=false,$fast=false,$is_gmt=false) 'ndays' => $ndays ); } - - + + $dow = adodb_dow($year,$month,$day); return array( @@ -663,17 +663,17 @@ function adodb_gmdate($fmt,$d=false) function adodb_date2($fmt, $d=false, $is_gmt=false) { if ($d !== false) { - if (!preg_match( - "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", + if (!preg_match( + "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", ($d), $rr)) return adodb_date($fmt,false,$is_gmt); if ($rr[1] <= 100 && $rr[2]<= 1) return adodb_date($fmt,false,$is_gmt); - + // h-m-s-MM-DD-YY if (!isset($rr[5])) $d = adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); else $d = @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]); } - + return adodb_date($fmt,$d,$is_gmt); } @@ -690,7 +690,7 @@ function adodb_date($fmt,$d=false,$is_gmt=false) } } $_day_power = 86400; - + $arr = _adodb_getdate($d,true,$is_gmt); $year = $arr['year']; $month = $arr['mon']; @@ -698,10 +698,10 @@ function adodb_date($fmt,$d=false,$is_gmt=false) $hour = $arr['hours']; $min = $arr['minutes']; $secs = $arr['seconds']; - + $max = strlen($fmt); $dates = ''; - + /* at this point, we have the following integer vars to manipulate: $year, $month, $day, $hour, $min, $secs @@ -712,19 +712,19 @@ function adodb_date($fmt,$d=false,$is_gmt=false) // YEAR case 'L': $dates .= $arr['leap'] ? '1' : '0'; break; case 'r': // Thu, 21 Dec 2000 16:01:07 +0200 - - $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))).', ' + + $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))).', ' . ($day<10?' '.$day:$day) . ' '.date('M',mktime(0,0,0,$month,2,1971)).' '.$year.' '; - - if ($hour < 10) $dates .= '0'.$hour; else $dates .= $hour; - + + if ($hour < 10) $dates .= '0'.$hour; else $dates .= $hour; + if ($min < 10) $dates .= ':0'.$min; else $dates .= ':'.$min; - + if ($secs < 10) $dates .= ':0'.$secs; else $dates .= ':'.$secs; - + $gmt = adodb_get_gmt_diff(); $dates .= sprintf(' %s%04d',($gmt<0)?'+':'-',abs($gmt)/36); break; - + case 'Y': $dates .= $year; break; case 'y': $dates .= substr($year,strlen($year)-2,2); break; // MONTH @@ -741,45 +741,45 @@ function adodb_date($fmt,$d=false,$is_gmt=false) case 'D': $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))); break; case 'j': $dates .= $day; break; case 'd': if ($day<10) $dates .= '0'.$day; else $dates .= $day; break; - case 'S': + case 'S': $d10 = $day % 10; if ($d10 == 1) $dates .= 'st'; else if ($d10 == 2) $dates .= 'nd'; else if ($d10 == 3) $dates .= 'rd'; else $dates .= 'th'; break; - + // HOUR case 'Z': $dates .= ($is_gmt) ? 0 : -adodb_get_gmt_diff(); break; - case 'O': + case 'O': $gmt = ($is_gmt) ? 0 : adodb_get_gmt_diff(); $dates .= sprintf('%s%04d',($gmt<0)?'+':'-',abs($gmt)/36); break; - - case 'H': - if ($hour < 10) $dates .= '0'.$hour; - else $dates .= $hour; + + case 'H': + if ($hour < 10) $dates .= '0'.$hour; + else $dates .= $hour; break; - case 'h': - if ($hour > 12) $hh = $hour - 12; + case 'h': + if ($hour > 12) $hh = $hour - 12; else { - if ($hour == 0) $hh = '12'; + if ($hour == 0) $hh = '12'; else $hh = $hour; } - + if ($hh < 10) $dates .= '0'.$hh; else $dates .= $hh; break; - - case 'G': + + case 'G': $dates .= $hour; break; - + case 'g': - if ($hour > 12) $hh = $hour - 12; + if ($hour > 12) $hh = $hour - 12; else { - if ($hour == 0) $hh = '12'; - else $hh = $hour; + if ($hour == 0) $hh = '12'; + else $hh = $hour; } $dates .= $hh; break; @@ -801,7 +801,7 @@ function adodb_date($fmt,$d=false,$is_gmt=false) default: $dates .= $fmt[$i]; break; // ESCAPE - case "\\": + case "\\": $i++; if ($i < $max) $dates .= $fmt[$i]; break; @@ -811,7 +811,7 @@ function adodb_date($fmt,$d=false,$is_gmt=false) } /** - Returns a timestamp given a GMT/UTC time. + Returns a timestamp given a GMT/UTC time. Note that $is_dst is not implemented and is ignored. */ function adodb_gmmktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false) @@ -823,41 +823,41 @@ function adodb_gmmktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false) Return a timestamp given a local time. Originally by jackbbs. Note that $is_dst is not implemented and is ignored. */ -function adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false,$is_gmt=false) +function adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false,$is_gmt=false) { if (!defined('ADODB_TEST_DATES')) { - // for windows, we don't check 1970 because with timezone differences, + // for windows, we don't check 1970 because with timezone differences, // 1 Jan 1970 could generate negative timestamp, which is illegal - if (!defined('ADODB_NO_NEGATIVE_TS') || ($year >= 1971)) + if (!defined('ADODB_NO_NEGATIVE_TS') || ($year >= 1971)) if (1901 < $year && $year < 2038) return @mktime($hr,$min,$sec,$mon,$day,$year); } - + $gmt_different = ($is_gmt) ? 0 : adodb_get_gmt_diff(); - + $hr = intval($hr); $min = intval($min); $sec = intval($sec); $mon = intval($mon); $day = intval($day); $year = intval($year); - - + + $year = adodb_year_digit_check($year); - + if ($mon > 12) { $y = floor($mon / 12); $year += $y; $mon -= $y*12; } - + $_day_power = 86400; $_hour_power = 3600; $_min_power = 60; - + $_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); $_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); - + $_total_date = 0; if ($year >= 1970) { for ($a = 1970 ; $a <= $year; $a++) { @@ -869,7 +869,7 @@ function adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false,$is_gmt=false) $loop_table = $_month_table_normal; $_add_date = 365; } - if ($a < $year) { + if ($a < $year) { $_total_date += $_add_date; } else { for($b=1;$b<$mon;$b++) { @@ -879,7 +879,7 @@ function adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false,$is_gmt=false) } $_total_date +=$day-1; $ret = $_total_date * $_day_power + $hr * $_hour_power + $min * $_min_power + $sec + $gmt_different; - + } else { for ($a = 1969 ; $a >= $year; $a--) { $leaf = _adodb_is_leap_year($a); @@ -898,13 +898,13 @@ function adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false,$is_gmt=false) } } $_total_date += $loop_table[$mon] - $day; - + $_day_time = $hr * $_hour_power + $min * $_min_power + $sec; $_day_time = $_day_power - $_day_time; $ret = -( $_total_date * $_day_power + $_day_time - $gmt_different); if ($ret < -12220185600) $ret += 10*86400; // if earlier than 5 Oct 1582 - gregorian correction else if ($ret < -12219321600) $ret = -12219321600; // if in limbo, reset to 15 Oct 1582. - } + } //print " dmy=$day/$mon/$year $hr:$min:$sec => " .$ret; return $ret; } diff --git a/lib/WikiDB/adodb/adodb.inc.php b/lib/WikiDB/adodb/adodb.inc.php index a6ad8a6fe..5c35e2fa1 100644 --- a/lib/WikiDB/adodb/adodb.inc.php +++ b/lib/WikiDB/adodb/adodb.inc.php @@ -12,7 +12,7 @@ */ /** - \mainpage + \mainpage @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim\@natsoft.com.my). All rights reserved. @@ -139,7 +139,7 @@ die("Illegal path http:// or ftp://"); } - + // Initialize random number generator for randomizing cache flushes srand(((double)microtime())*1000000); @@ -208,7 +208,7 @@ // PUBLIC VARS // var $dataProvider = 'native'; - var $databaseType = ''; /// RDBMS currently in use, eg. odbc, mysql, mssql + var $databaseType = ''; /// RDBMS currently in use, eg. odbc, mysql, mssql var $database = ''; /// Name of database to be used. var $host = ''; /// The hostname of the database server var $user = ''; /// The username which is used to connect to the database server. @@ -280,7 +280,7 @@ var $_connectionID = false; /// The returned link identifier whenever a successful database connection is made. var $_errorMsg = false; /// A variable which was used to keep the returned last error message. The value will /// then returned by the errorMsg() function - var $_errorCode = false; /// Last error code, not guaranteed to be used - only by oci8 + var $_errorCode = false; /// Last error code, not guaranteed to be used - only by oci8 var $_queryID = false; /// This variable keeps the last created result link identifier var $_isPersistentConnection = false; /// A boolean variable to state whether its a persistent connection or normal connection. */ @@ -294,7 +294,7 @@ /** * Constructor */ - function ADOConnection() + function ADOConnection() { die('Virtual Class -- cannot instantiate'); } @@ -429,7 +429,7 @@ if ($argUsername != "") $this->user = $argUsername; if ($argPassword != "") $this->password = $argPassword; if ($argDatabaseName != "") $this->database = $argDatabaseName; - + $this->_isPersistentConnection = true; if ($fn = $this->raiseErrorFn) { @@ -751,10 +751,10 @@ $element0 = reset($inputarr); # is_object check is because oci8 descriptors can be passed in $array_2d = is_array($element0) && !is_object(reset($element0)); - + if (!is_array($sql) && !$this->_bindInputArray) { $sqlarr = explode('?',$sql); - + if (!$array_2d) $inputarr = array($inputarr); foreach($inputarr as $arr) { $sql = ''; $i = 0; @@ -771,7 +771,7 @@ $i += 1; } $sql .= $sqlarr[$i]; - + if ($i+1 != sizeof($sqlarr)) ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql)); @@ -810,10 +810,10 @@ $ss = "[ $ss ]"; } $sqlTxt = str_replace(',',', ',is_array($sql) ?$sql[0] : $sql); - + // check if running from browser or command-line $inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']); - + if ($inBrowser) { if ($this->debug === -1) ADOConnection::outp( "
\n($this->databaseType): ".htmlspecialchars($sqlTxt)."   $ss\n
\n",false); @@ -839,7 +839,7 @@ //**************************** // non-debug version of query //**************************** - + $this->_queryID =@$this->_query($sql,$inputarr); } @@ -854,7 +854,7 @@ if ($fn) { $fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr,$this); } - + return false; } @@ -971,7 +971,7 @@ $val = $this->_affectedrows(); return ($val < 0) ? false : $val; } - + if ($this->debug) ADOConnection::outp( '

Affected_Rows error

',false); return false; } @@ -1071,9 +1071,9 @@ $ismssql = (strpos($this->databaseType,'mssql') !== false); if ($ismssql) $isaccess = false; else $isaccess = (strpos($this->databaseType,'access') !== false); - + if ($offset <= 0) { - + // access includes ties in result if ($isaccess) { $sql = preg_replace( @@ -1110,7 +1110,7 @@ $savec = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; - + if ($offset>0){ if ($secs2cache>0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); else $rs = &$this->Execute($sql,$inputarr); @@ -1295,7 +1295,7 @@ Calculate the offset of a date for a particular database and generate appropriate SQL. Useful for calculating future/past dates and storing in a database. - + If dayFraction=1.5 means 1.5 days from now, 1.0/24 for 1 hour. */ function OffsetDate($dayFraction,$date=false) @@ -1522,7 +1522,7 @@ if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php'); if (is_array($sql)) $sql = $sql[0]; - + $md5file = $this->_gencachename($sql.serialize($inputarr),true); $err = ''; @@ -1559,13 +1559,13 @@ //$rs = &csv2rs($md5file,$err); $rs->connection = &$this; // Pablo suggestion } - + } else @unlink($md5file); } else { $this->_errorMsg = ''; $this->_errorCode = 0; - + if ($this->fnCacheExecute) { $fn = $this->fnCacheExecute; $fn($this, $secs2cache, $sql, $inputarr); @@ -1574,12 +1574,12 @@ $rs->connection = &$this; // Pablo suggestion if ($this->debug){ global $HTTP_SERVER_VARS; - + $inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']); $ttl = $rs->timeCreated + $secs2cache - time(); $s = is_array($sql) ? $sql[0] : $sql; if ($inBrowser) $s = ''.htmlspecialchars($s).''; - + ADOConnection::outp( " $md5file reloaded, ttl=$ttl [ $s ]"); } } @@ -1736,7 +1736,7 @@ $this->fmtDate="d-m-Y"; $this->fmtTimeStamp = "d-m-Y H:i:s"; break; - + case 'Ge': $this->fmtDate="d.m.Y"; $this->fmtTimeStamp = "d.m.Y H:i:s"; @@ -1769,13 +1769,13 @@ case 'X': return 'VARCHAR'; case 'B': - + case 'D': case 'T': case 'L': case 'R': - + case 'I': case 'N': return false; @@ -1837,16 +1837,16 @@ if ($this->metaDatabasesSQL) { $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); - + $arr = $this->GetCol($this->metaDatabasesSQL); if (isset($savem)) $this->SetFetchMode($savem); $ADODB_FETCH_MODE = $save; - + return $arr; } - + return false; } @@ -1870,21 +1870,21 @@ // complicated state saving by the need for backward compat $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); - + $rs = $this->Execute($this->metaTablesSQL); if (isset($savem)) $this->SetFetchMode($savem); $ADODB_FETCH_MODE = $save; - + if ($rs === false) return false; $arr =& $rs->GetArray(); $arr2 = array(); - + if ($hast = ($ttype && isset($arr[0][1]))) { $showt = strncmp($ttype,'T',1); } - + for ($i=0; $i < sizeof($arr); $i++) { if ($hast) { if ($showt == 0) { @@ -1948,7 +1948,7 @@ if ($fld->scale>0) $fld->max_length += 1; } else $fld->max_length = $rs->fields[2]; - + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; else $retarr[$fld->name] = $fld; $rs->MoveNext(); @@ -1988,7 +1988,7 @@ } return $arr; } - + /** * Different SQL databases used different methods to combine strings together. * This function provides a wrapper. @@ -1998,7 +1998,7 @@ * Usage: $db->Concat($str1,$str2); * * @return concatenated string - */ + */ function Concat() { $arr = func_get_args(); @@ -2077,7 +2077,7 @@ if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", ($v), $rr)) return false; - + if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0; // h-m-s-MM-DD-YY @@ -2355,7 +2355,7 @@ $this->_numOfFields = 0; } if ($this->_numOfRows != 0 && $this->_numOfFields && $this->_currentRow == -1) { - + $this->_currentRow = 0; if ($this->EOF = ($this->_fetch() === false)) { $this->_numOfRows = 0; // _numOfRows could be -1 @@ -2594,7 +2594,7 @@ if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|", ($v), $rr)) return false; - + if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0; // h-m-s-MM-DD-YY return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); @@ -2685,8 +2685,8 @@ function MoveFirst() { if ($this->_currentRow == 0) return true; - return $this->Move(0); - } + return $this->Move(0); + } /** @@ -2744,7 +2744,7 @@ if ($rowNumber == $this->_currentRow) return true; if ($rowNumber >= $this->_numOfRows) if ($this->_numOfRows != -1) $rowNumber = $this->_numOfRows-2; - + if ($this->canSeek) { if ($this->_seek($rowNumber)) { @@ -2764,10 +2764,10 @@ adodb_movenext($this); } } else { - + while (! $this->EOF && $this->_currentRow < $rowNumber) { $this->_currentRow++; - + if (!$this->_fetch()) $this->EOF = true; } } @@ -2909,7 +2909,7 @@ * @return the number of columns in the recordset. Some databases will set this to 0 * if no records are returned, others will return the number of columns in the query. */ - function FieldCount() {return $this->_numOfFields;} + function FieldCount() {return $this->_numOfFields;} /** @@ -2972,7 +2972,7 @@ $name = $this->_names[$i]; if ($isupper) $n = strtoupper($name); else $n = $name; - + $o->$n = $this->Fields($name); } return $o; @@ -3149,14 +3149,14 @@ return 'X'; } return 'C'; - + case 'I': if (!empty($fieldobj->primary_key)) return 'R'; return 'I'; case false: return 'N'; - + case 'B': if (isset($fieldobj->binary)) return ($fieldobj->binary) ? 'B' : 'X'; @@ -3165,7 +3165,7 @@ case 'D': if (!empty($this->datetime)) return 'T'; return 'D'; - + default: if ($t == 'LONG' && $this->dataProvider == 'oci8') return 'B'; return $tmap; @@ -3334,10 +3334,10 @@ $o->name = $this->_colnames[$fieldOffset]; $o->type = $this->_types[$fieldOffset]; $o->max_length = -1; // length not known - + return $o; } - + function _seek($row) { if (sizeof($this->_array) && 0 <= $row && $row < $this->_numOfRows) { @@ -3353,9 +3353,9 @@ { if (!$this->EOF) { $this->_currentRow++; - + $pos = $this->_currentRow; - + if ($this->_numOfRows <= $pos) { if (!$this->compat) $this->fields = false; } else { @@ -3365,14 +3365,14 @@ } $this->EOF = true; } - + return false; } function _fetch() { $pos = $this->_currentRow; - + if ($this->_numOfRows <= $pos) { if (!$this->compat) $this->fields = false; return false; @@ -3391,7 +3391,7 @@ //============================================================================================== // HELPER FUNCTIONS - //============================================================================================== + //============================================================================================== /** * Synonym for ADOLoadCode. Private function. Do not use. @@ -3475,7 +3475,7 @@ $db,false,$ignore); } else ADOConnection::outp( "

ADONewConnection: Unable to load database driver '$db'

",false); - + return false; } @@ -3578,7 +3578,7 @@ // getmypid() actually returns 0 on Win98 - never mind! $tmpname = $filename.uniqid($mtime).getmypid(); if (!($fd = fopen($tmpname,'a'))) return false; - $ok = ftruncate($fd,0); + $ok = ftruncate($fd,0); if (!fwrite($fd,$contents)) $ok = false; fclose($fd); chmod($tmpname,0644); @@ -3644,7 +3644,7 @@ foreach ($traceArr as $arr) { $levels -= 1; if ($levels < 0) break; - + $args = array(); for ($i=0; $i < $tabs; $i++) $s .= ($html) ? '   ' : "\t"; $tabs -= 1; @@ -3664,10 +3664,10 @@ } } $s .= $arr['function'].'('.implode(', ',$args).')'; - - + + $s .= @sprintf($fmt, $arr['line'],$arr['file'],basename($arr['file'])); - + $s .= "\n"; } if ($html) $s .= '
'; diff --git a/lib/WikiDB/adodb/drivers/adodb-access.inc.php b/lib/WikiDB/adodb/drivers/adodb-access.inc.php index ebaaf810b..2f77c3e99 100644 --- a/lib/WikiDB/adodb/drivers/adodb-access.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-access.inc.php @@ -1,13 +1,13 @@ ADODB_odbc(); } - + function Time() { return time(); } - + function BeginTrans() { return false;} - - function IfNull( $field, $ifNull ) + + function IfNull( $field, $ifNull ) { return " IIF(IsNull($field), $ifNull, $field) "; // if Access } @@ -49,16 +49,16 @@ class ADODB_access extends ADODB_odbc { function &MetaTables() { global $ADODB_FETCH_MODE; - + $savem = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; $qid = odbc_tables($this->_connectionID); $rs = new ADORecordSet_odbc($qid); $ADODB_FETCH_MODE = $savem; if (!$rs) return false; - + $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change; - + $arr = &$rs->GetArray(); //print_pre($arr); $arr2 = array(); @@ -70,15 +70,15 @@ class ADODB_access extends ADODB_odbc { }*/ } - -class ADORecordSet_access extends ADORecordSet_odbc { - - var $databaseType = "access"; - + +class ADORecordSet_access extends ADORecordSet_odbc { + + var $databaseType = "access"; + function ADORecordSet_access($id,$mode=false) { return $this->ADORecordSet_odbc($id,$mode); } }// class -} +} ?> \ No newline at end of file diff --git a/lib/WikiDB/adodb/drivers/adodb-ado.inc.php b/lib/WikiDB/adodb/drivers/adodb-ado.inc.php index 880cab44f..24cf613d3 100644 --- a/lib/WikiDB/adodb/drivers/adodb-ado.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-ado.inc.php @@ -1,26 +1,26 @@ _affectedRows = new VARIANT; } @@ -42,14 +42,14 @@ class ADODB_ado extends ADOConnection { if (!empty($this->_connectionID)) $desc = $this->_connectionID->provider; return array('description' => $desc, 'version' => ''); } - + function _affectedrows() { if (PHP_VERSION >= 5) return $this->_affectedRows; - + return $this->_affectedRows->value; } - + // you can also pass a connection string like this: // // $DB->Connect('USER ID=sa;PASSWORD=pwd;SERVER=mangrove;DATABASE=ai',false,false,'SQLOLEDB'); @@ -57,49 +57,49 @@ class ADODB_ado extends ADOConnection { { $u = 'UID'; $p = 'PWD'; - + if (!empty($this->charPage)) $dbc = new COM('ADODB.Connection',null,$this->charPage); else $dbc = new COM('ADODB.Connection'); - + if (! $dbc) return false; /* special support if provider is mssql or access */ if ($argProvider=='mssql') { $u = 'User Id'; //User parameter name for OLEDB - $p = 'Password'; + $p = 'Password'; $argProvider = "SQLOLEDB"; // SQL Server Provider - + // not yet //if ($argDatabasename) $argHostname .= ";Initial Catalog=$argDatabasename"; - + //use trusted conection for SQL if username not specified if (!$argUsername) $argHostname .= ";Trusted_Connection=Yes"; } else if ($argProvider=='access') $argProvider = "Microsoft.Jet.OLEDB.4.0"; // Microsoft Jet Provider - - if ($argProvider) $dbc->Provider = $argProvider; - + + if ($argProvider) $dbc->Provider = $argProvider; + if ($argUsername) $argHostname .= ";$u=$argUsername"; if ($argPassword)$argHostname .= ";$p=$argPassword"; - + if ($this->debug) ADOConnection::outp( "Host=".$argHostname."
\n version=$dbc->version"); // @ added below for php 4.0.1 and earlier @$dbc->Open((string) $argHostname); - + $this->_connectionID = $dbc; - + $dbc->CursorLocation = $this->_cursor_location; return $dbc->State > 0; } - + // returns true or false function _pconnect($argHostname, $argUsername, $argPassword, $argProvider='MSDASQL') { return $this->_connect($argHostname,$argUsername,$argPassword,$argProvider); - } - + } + /* adSchemaCatalogs = 1, adSchemaCharacterSets = 2, @@ -141,12 +141,12 @@ class ADODB_ado extends ADOConnection { adSchemaMembers = 38 */ - + function &MetaTables() { $arr= array(); $dbc = $this->_connectionID; - + $adors=@$dbc->OpenSchema(20);//tables if ($adors){ $f = $adors->Fields(2);//table/view name @@ -160,25 +160,25 @@ class ADODB_ado extends ADOConnection { } $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; @@ -186,27 +186,27 @@ class ADODB_ado extends ADOConnection { $fld->max_length = -1; $arr[strtoupper($fld->name)]=$fld; } - + $adors->MoveNext(); } $adors->Close(); } - + return $arr; } - - + + /* returns queryID or false */ - function &_query($sql,$inputarr=false) + function &_query($sql,$inputarr=false) { - + $dbc = $this->_connectionID; - - // return rs + + // return rs if ($inputarr) { - + if (!empty($this->charPage)) $oCmd = new COM('ADODB.Command',null,$this->charPage); else @@ -228,26 +228,26 @@ class ADODB_ado extends ADOConnection { if ($dbc->Errors->Count > 0) return false; return $rs; } - + $rs = @$dbc->Execute($sql,$this->_affectedRows, $this->_execute_option); /* $rs = new COM('ADODB.Recordset'); if ($rs) { - $rs->Open ($sql, $dbc, $this->_cursor_type,$this->_lock_type, $this->_execute_option); + $rs->Open ($sql, $dbc, $this->_cursor_type,$this->_lock_type, $this->_execute_option); } */ if ($dbc->Errors->Count > 0) return false; if (! $rs) return false; - + if ($rs->State == 0) return true; // 0 = adStateClosed means no records returned return $rs; } - - function BeginTrans() - { + + function BeginTrans() + { if ($this->transOff) return true; - + if (isset($this->_thisTransactions)) if (!$this->_thisTransactions) return false; else { @@ -259,11 +259,11 @@ class ADODB_ado extends ADOConnection { $this->transCnt += 1; return true; } - function CommitTrans($ok=true) - { + function CommitTrans($ok=true) + { if (!$ok) return $this->RollbackTrans(); if ($this->transOff) return true; - + @$this->_connectionID->CommitTrans(); if ($this->transCnt) @$this->transCnt -= 1; return true; @@ -274,18 +274,18 @@ class ADODB_ado extends ADOConnection { if ($this->transCnt) @$this->transCnt -= 1; return true; } - - /* Returns: the last error message from previous database operation */ - function ErrorMsg() + /* 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() + + function ErrorNo() { $errc = $this->_connectionID->Errors; if ($errc->Count == 0) return 0; @@ -300,27 +300,27 @@ class ADODB_ado extends ADOConnection { $this->_connectionID = false; return true; } - - + + } - + /*-------------------------------------------------------------------------------------- Class Name: Recordset --------------------------------------------------------------------------------------*/ -class ADORecordSet_ado extends ADORecordSet { - +class ADORecordSet_ado extends ADORecordSet { + var $bind = false; - var $databaseType = "ado"; - var $dataProvider = "ado"; + 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,$mode=false) { - if ($mode === false) { + if ($mode === false) { global $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE; } @@ -332,7 +332,7 @@ class ADORecordSet_ado extends ADORecordSet { // 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); @@ -341,12 +341,12 @@ class ADORecordSet_ado extends ADORecordSet { $o->type = $this->MetaType($t); $o->max_length = $f->DefinedSize; $o->ado_type = $t; - + //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) { @@ -358,25 +358,25 @@ class ADORecordSet_ado extends ADORecordSet { $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; + $rs = $this->_queryID; // absoluteposition doesn't work -- my maths is wrong ? // $rs->AbsolutePosition->$row-2; // return true; @@ -384,10 +384,10 @@ class ADORecordSet_ado extends ADORecordSet { @$rs->Move((integer)$row - $this->_currentRow-1); //adBookmarkFirst return true; } - + /* OLEDB types - + enum DBTYPEENUM { DBTYPE_EMPTY = 0, DBTYPE_NULL = 1, @@ -423,9 +423,9 @@ class ADORecordSet_ado extends ADORecordSet { DBTYPE_DBDATE = 133, DBTYPE_DBTIME = 134, DBTYPE_DBTIMESTAMP = 135 - + ADO Types - + adEmpty = 0, adTinyInt = 16, adSmallInt = 2, @@ -445,7 +445,7 @@ class ADORecordSet_ado extends ADORecordSet { adUserDefined = 132, adVariant = 12, adIDispatch = 9, - adIUnknown = 13, + adIUnknown = 13, adGUID = 72, adDate = 7, adDBDate = 133, @@ -474,9 +474,9 @@ class ADORecordSet_ado extends ADORecordSet { $t = $fieldobj->type; $len = $fieldobj->max_length; } - + if (!is_numeric($t)) return $t; - + switch ($t) { case 0: case 12: // variant @@ -489,7 +489,7 @@ class ADORecordSet_ado extends ADORecordSet { case 204: // varBin case 72: // guid if ($len <= $this->blobSize) return 'C'; - + case 201: case 203: return 'X'; @@ -499,12 +499,12 @@ class ADORecordSet_ado extends ADORecordSet { 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, @@ -517,17 +517,17 @@ class ADORecordSet_ado extends ADORecordSet { default: return 'N'; } } - + // time stamp not supported yet function _fetch() - { + { $rs = $this->_queryID; if (!$rs or $rs->EOF) { $this->fields = false; return false; } $this->fields = array(); - + if (!$this->_tarr) { $tarr = array(); $flds = array(); @@ -537,12 +537,12 @@ class ADORecordSet_ado extends ADORecordSet { $tarr[] = $f->Type; } // bind types and flds only once - $this->_tarr = $tarr; + $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++) { @@ -550,8 +550,8 @@ class ADORecordSet_ado extends ADORecordSet { case 135: // timestamp if (!strlen((string)$f->value)) $this->fields[] = false; else $this->fields[] = adodb_date('Y-m-d H:i:s',(float)$f->value); - break; - case 133:// A date value (yyyymmdd) + break; + case 133:// A date value (yyyymmdd) if ($val = $f->value) { $this->fields[] = substr($val,0,4).'-'.substr($val,4,2).'-'.substr($val,6,2); } else @@ -569,7 +569,7 @@ class ADORecordSet_ado extends ADORecordSet { $this->fields[] = (float) $f->value; break; default: - $this->fields[] = $f->value; + $this->fields[] = $f->value; break; } //print " $f->value $t, "; @@ -578,27 +578,27 @@ class ADORecordSet_ado extends ADORecordSet { } // 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(ADODB_ASSOC_CASE); } return true; } - + function NextRecordSet() { $rs = $this->_queryID; $this->_queryID = $rs->NextRecordSet(); //$this->_queryID = $this->_QueryId->NextRecordSet(); if ($this->_queryID == null) return false; - + $this->_currentRow = -1; $this->_currentPage = -1; $this->bind = false; $this->fields = false; $this->_flds = false; $this->_tarr = false; - + $this->_inited = false; $this->Init(); return true; @@ -607,7 +607,7 @@ class ADORecordSet_ado extends ADORecordSet { function _close() { $this->_flds = false; @$this->_queryID->Close();// by Pete Dishman (peterd@telephonetics.co.uk) - $this->_queryID = false; + $this->_queryID = false; } } diff --git a/lib/WikiDB/adodb/drivers/adodb-ado_access.inc.php b/lib/WikiDB/adodb/drivers/adodb-ado_access.inc.php index 36040ec16..fee7b3a21 100644 --- a/lib/WikiDB/adodb/drivers/adodb-ado_access.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-ado_access.inc.php @@ -1,13 +1,13 @@ ADODB_ado(); } - + function BeginTrans() { return false;} } - -class ADORecordSet_ado_access extends ADORecordSet_ado { - - var $databaseType = "ado_access"; - + +class ADORecordSet_ado_access extends ADORecordSet_ado { + + var $databaseType = "ado_access"; + function ADORecordSet_ado_access($id,$mode=false) { return $this->ADORecordSet_ado($id,$mode); diff --git a/lib/WikiDB/adodb/drivers/adodb-ado_mssql.inc.php b/lib/WikiDB/adodb/drivers/adodb-ado_mssql.inc.php index 7a186fdc5..527d9f6e5 100644 --- a/lib/WikiDB/adodb/drivers/adodb-ado_mssql.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-ado_mssql.inc.php @@ -1,17 +1,17 @@ ADODB_ado(); } - + function _insertid() { return $this->GetOne('select @@identity'); } - + function _affectedrows() { return $this->GetOne('select @@rowcount'); } - + } - -class ADORecordSet_ado_mssql extends ADORecordSet_ado { - + +class ADORecordSet_ado_mssql extends ADORecordSet_ado { + var $databaseType = 'ado_mssql'; - + function ADORecordSet_ado_mssql($id,$mode=false) { return $this->ADORecordSet_ado($id,$mode); diff --git a/lib/WikiDB/adodb/drivers/adodb-borland_ibase.inc.php b/lib/WikiDB/adodb/drivers/adodb-borland_ibase.inc.php index 208d5e7d9..c1fc31fa9 100644 --- a/lib/WikiDB/adodb/drivers/adodb-borland_ibase.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-borland_ibase.inc.php @@ -1,13 +1,13 @@ ADODB_ibase(); } - + function ServerInfo() { $arr['dialect'] = $this->dialect; switch($arr['dialect']) { - case '': + case '': case '1': $s = 'Interbase 6.5, Dialect 1'; break; case '2': $s = 'Interbase 6.5, Dialect 2'; break; default: @@ -36,41 +36,41 @@ class ADODB_borland_ibase extends ADODB_ibase { $arr['description'] = $s; return $arr; } - + // Note that Interbase 6.5 uses ROWS instead - don't you love forking wars! - // SELECT col1, col2 FROM table ROWS 5 -- get 5 rows + // SELECT col1, col2 FROM table ROWS 5 -- get 5 rows // SELECT col1, col2 FROM TABLE ORDER BY col1 ROWS 3 TO 7 -- first 5 skip 2 // Firebird uses // SELECT FIRST 5 SKIP 2 col1, col2 FROM TABLE function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) { if ($nrows > 0) { - if ($offset <= 0) $str = " ROWS $nrows "; + if ($offset <= 0) $str = " ROWS $nrows "; else { $a = $offset+1; $b = $offset+$nrows; $str = " ROWS $a TO $b"; } } else { - // ok, skip + // ok, skip $a = $offset + 1; $str = " ROWS $a TO 999999999"; // 999 million } $sql .= $str; - - return ($secs2cache) ? + + return ($secs2cache) ? $this->CacheExecute($secs2cache,$sql,$inputarr) : $this->Execute($sql,$inputarr); } - + }; - -class ADORecordSet_borland_ibase extends ADORecordSet_ibase { - - var $databaseType = "borland_ibase"; - + +class ADORecordSet_borland_ibase extends ADORecordSet_ibase { + + var $databaseType = "borland_ibase"; + function ADORecordSet_borland_ibase($id,$mode=false) { $this->ADORecordSet_ibase($id,$mode); diff --git a/lib/WikiDB/adodb/drivers/adodb-csv.inc.php b/lib/WikiDB/adodb/drivers/adodb-csv.inc.php index 3a1ac86ac..d6bb0c92f 100644 --- a/lib/WikiDB/adodb/drivers/adodb-csv.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-csv.inc.php @@ -1,26 +1,26 @@ _insertid; } - + function _affectedrows() { return $this->_affectedrows; } - + function &MetaDatabases() { return false; } - + // returns true or false function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) { if (strtolower(substr($argHostname,0,7)) !== 'http://') return false; $this->_url = $argHostname; - return true; + return true; } - + // returns true or false function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { @@ -64,24 +64,24 @@ class ADODB_csv extends ADOConnection { $this->_url = $argHostname; return true; } - - function &MetaColumns($table) + + function &MetaColumns($table) { return false; } - - + + // parameters use PostgreSQL convention, not MySQL function &SelectLimit($sql,$nrows=-1,$offset=-1) { global $ADODB_FETCH_MODE; - + $url = $this->_url.'?sql='.urlencode($sql)."&nrows=$nrows&fetch=". (($this->fetchMode !== false)?$this->fetchMode : $ADODB_FETCH_MODE). "&offset=$offset"; $err = false; $rs = csv2rs($url,$err,false); - + if ($this->debug) print "$url
$err
"; $at = strpos($err,'::::'); @@ -92,25 +92,25 @@ class ADODB_csv extends ADOConnection { $this->_errorMsg = substr($err,$at+4,1024); $this->_errorNo = -9999; } - if ($this->_errorNo) + if ($this->_errorNo) if ($fn = $this->raiseErrorFn) { $fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,''); } - - if (is_object($rs)) { - - $rs->databaseType='csv'; + + if (is_object($rs)) { + + $rs->databaseType='csv'; $rs->fetchMode = ($this->fetchMode !== false) ? $this->fetchMode : $ADODB_FETCH_MODE; $rs->connection = &$this; } return $rs; } - + // returns queryID or false function &_Execute($sql,$inputarr=false) { global $ADODB_FETCH_MODE; - + if (!$this->_bindInputArray && $inputarr) { $sqlarr = explode('?',$sql); $sql = ''; @@ -125,37 +125,37 @@ class ADODB_csv extends ADOConnection { else $sql .= $v; $i += 1; - + } $sql .= $sqlarr[$i]; - if ($i+1 != sizeof($sqlarr)) + if ($i+1 != sizeof($sqlarr)) print "Input Array does not match ?: ".htmlspecialchars($sql); $inputarr = false; } - + $url = $this->_url.'?sql='.urlencode($sql)."&fetch=". (($this->fetchMode !== false)?$this->fetchMode : $ADODB_FETCH_MODE); $err = false; - - + + $rs = csv2rs($url,$err,false); if ($this->debug) print urldecode($url)."
$err
"; $at = strpos($err,'::::'); - if ($at === false) { + if ($at === false) { $this->_errorMsg = $err; $this->_errorNo = (integer)$err; } else { $this->_errorMsg = substr($err,$at+4,1024); $this->_errorNo = -9999; } - - if ($this->_errorNo) + + if ($this->_errorNo) if ($fn = $this->raiseErrorFn) { $fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr); } if (is_object($rs)) { $rs->fetchMode = ($this->fetchMode !== false) ? $this->fetchMode : $ADODB_FETCH_MODE; - + $this->_affectedrows = $rs->affectedrows; $this->_insertid = $rs->insertid; $rs->databaseType='csv'; @@ -164,18 +164,18 @@ class ADODB_csv extends ADOConnection { return $rs; } - /* Returns: the last error message from previous database operation */ - function ErrorMsg() + /* 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() + + /* Returns: the last error number from previous database operation */ + function ErrorNo() { return $this->_errorNo; } - + // returns true or false function _close() { @@ -188,7 +188,7 @@ class ADORecordset_csv extends ADORecordset { { $this->ADORecordset($id,$mode); } - + function _close() { return true; @@ -196,5 +196,5 @@ class ADORecordset_csv extends ADORecordset { } } // define - + ?> \ No newline at end of file diff --git a/lib/WikiDB/adodb/drivers/adodb-db2.inc.php b/lib/WikiDB/adodb/drivers/adodb-db2.inc.php index 2eae6384c..f35b5e462 100644 --- a/lib/WikiDB/adodb/drivers/adodb-db2.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-db2.inc.php @@ -1,15 +1,15 @@ Connect($dsn, $userid, $pwd); USING CLI INTERFACE =================== -I have had reports that the $host and $database params have to be reversed in +I have had reports that the $host and $database params have to be reversed in Connect() when using the CLI interface. From Halmai Csongor csongor.halmai#nexum.hu: > The symptom is that if I change the database engine from postgres or any other to DB2 then the following -> connection command becomes wrong despite being described this version to be correct in the docs. +> connection command becomes wrong despite being described this version to be correct in the docs. > > $connection_object->Connect( $DATABASE_HOST, $DATABASE_AUTH_USER_NAME, $DATABASE_AUTH_PASSWORD, $DATABASE_NAME ) > -> In case of DB2 I had to swap the first and last arguments in order to connect properly. +> In case of DB2 I had to swap the first and last arguments in order to connect properly. */ @@ -89,30 +89,30 @@ if (!defined('ADODB_DB2')){ define('ADODB_DB2',1); class ADODB_DB2 extends ADODB_odbc { - var $databaseType = "db2"; + var $databaseType = "db2"; var $concat_operator = '||'; var $sysDate = 'CURRENT_DATE'; var $sysTimeStamp = 'CURRENT TIMESTAMP'; - // The complete string representation of a timestamp has the form + // The complete string representation of a timestamp has the form // yyyy-mm-dd-hh.mm.ss.nnnnnn. var $fmtTimeStamp = "'Y-m-d-H.i.s'"; var $ansiOuter = true; var $identitySQL = 'values IDENTITY_VAL_LOCAL()'; var $_bindInputArray = false; var $upperCase = 'upper'; - - + + function ADODB_DB2() { if (strncmp(PHP_OS,'WIN',3) === 0) $this->curmode = SQL_CUR_USE_ODBC; $this->ADODB_odbc(); } - - function IfNull( $field, $ifNull ) + + function IfNull( $field, $ifNull ) { return " COALESCE($field, $ifNull) "; // if DB2 UDB } - + function ServerInfo() { //odbc_setoption($this->_connectionID,1,101 /*SQL_ATTR_ACCESS_MODE*/, 1 /*SQL_MODE_READ_ONLY*/); @@ -120,52 +120,52 @@ class ADODB_DB2 extends ADODB_odbc { //odbc_setoption($this->_connectionID,1,101, 0 /*SQL_MODE_READ_WRITE*/); return array('description'=>'DB2 ODBC driver', 'version'=>$vers); } - + function _insertid() { return $this->GetOne($this->identitySQL); } - + function RowLock($tables,$where) { if ($this->_autocommit) $this->BeginTrans(); return $this->GetOne("select 1 as ignore from $tables where $where for update"); } - + function &MetaTables($ttype=false,$showSchema=false) { global $ADODB_FETCH_MODE; - + $savem = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; $qid = odbc_tables($this->_connectionID); - + $rs = new ADORecordSet_odbc($qid); - + $ADODB_FETCH_MODE = $savem; if (!$rs) return false; - + $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change; - + $arr =& $rs->GetArray(); //print_r($arr); - + $rs->Close(); $arr2 = array(); - + if ($ttype) { $isview = strncmp($ttype,'V',1) === 0; } for ($i=0; $i < sizeof($arr); $i++) { - + if (!$arr[$i][2]) continue; if (strncmp($arr[$i][1],'SYS',3) === 0) continue; - + $type = $arr[$i][3]; - + if ($showSchema) $arr[$i][2] = $arr[$i][1].'.'.$arr[$i][2]; - - if ($ttype) { + + if ($ttype) { if ($isview) { if (strncmp($type,'V',1) === 0) $arr2[] = $arr[$i][2]; } else if (strncmp($type,'T',1) === 0) $arr2[] = $arr[$i][2]; @@ -173,14 +173,14 @@ class ADODB_DB2 extends ADODB_odbc { } return $arr2; } - + // Format date column in sql string given an input format that understands Y M D function SQLDate($fmt, $col=false) - { + { // use right() and replace() ? if (!$col) $col = $this->sysDate; $s = ''; - + $len = strlen($fmt); for ($i=0; $i < $len; $i++) { if ($s) $s .= '||'; @@ -202,7 +202,7 @@ class ADODB_DB2 extends ADODB_odbc { break; case 'H': case 'h': - if ($col != $this->sysDate) $s .= "right(digits(hour($col)),2)"; + if ($col != $this->sysDate) $s .= "right(digits(hour($col)),2)"; else $s .= "''"; break; case 'i': @@ -226,9 +226,9 @@ class ADODB_DB2 extends ADODB_odbc { } } return $s; - } - - + } + + function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputArr=false) { if ($offset <= 0) { @@ -243,17 +243,17 @@ class ADODB_DB2 extends ADODB_odbc { } $rs =& ADOConnection::SelectLimit($sql,-1,$offset,$inputArr); } - + return $rs; } - + }; - -class ADORecordSet_db2 extends ADORecordSet_odbc { - - var $databaseType = "db2"; - + +class ADORecordSet_db2 extends ADORecordSet_odbc { + + var $databaseType = "db2"; + function ADORecordSet_db2($id,$mode=false) { $this->ADORecordSet_odbc($id,$mode); @@ -266,44 +266,44 @@ class ADORecordSet_db2 extends ADORecordSet_odbc { $t = $fieldobj->type; $len = $fieldobj->max_length; } - + 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 'BOOLEAN': //case 'BIT': // return 'L'; - + //case 'COUNTER': // return 'R'; - + case 'INT': case 'INTEGER': case 'BIGINT': case 'SMALLINT': return 'I'; - + default: return 'N'; } } diff --git a/lib/WikiDB/adodb/drivers/adodb-fbsql.inc.php b/lib/WikiDB/adodb/drivers/adodb-fbsql.inc.php index dbdfe7781..9da2f1f2f 100644 --- a/lib/WikiDB/adodb/drivers/adodb-fbsql.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-fbsql.inc.php @@ -1,12 +1,12 @@ . + 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. + Contribution by Frank M. Kromann . Set tabs to 8. -*/ +*/ if (! defined("_ADODB_FBSQL_LAYER")) { define("_ADODB_FBSQL_LAYER", 1 ); @@ -14,26 +14,26 @@ if (! defined("_ADODB_FBSQL_LAYER")) { class ADODB_fbsql extends ADOConnection { var $databaseType = 'fbsql'; var $hasInsertID = true; - var $hasAffectedRows = true; - var $metaTablesSQL = "SHOW TABLES"; + var $hasAffectedRows = true; + var $metaTablesSQL = "SHOW TABLES"; var $metaColumnsSQL = "SHOW COLUMNS FROM %s"; var $fmtTimeStamp = "'Y-m-d H:i:s'"; var $hasLimit = false; - - function ADODB_fbsql() - { + + function ADODB_fbsql() + { } - + function _insertid() { return fbsql_insert_id($this->_connectionID); } - + function _affectedrows() { return fbsql_affected_rows($this->_connectionID); } - + function &MetaDatabases() { $qid = fbsql_list_dbs($this->_connectionID); @@ -58,39 +58,39 @@ class ADODB_fbsql extends ADOConnection { if (sizeof($arr) > 0) return "CONCAT($s)"; else return ''; } - + // returns true or false function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) { $this->_connectionID = fbsql_connect($argHostname,$argUsername,$argPassword); if ($this->_connectionID === false) return false; if ($argDatabasename) return $this->SelectDB($argDatabasename); - return true; + return true; } - + // returns true or false function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { $this->_connectionID = fbsql_pconnect($argHostname,$argUsername,$argPassword); if ($this->_connectionID === false) return false; if ($argDatabasename) return $this->SelectDB($argDatabasename); - return true; + return true; } - - function &MetaColumns($table) + + function &MetaColumns($table) { if ($this->metaColumnsSQL) { - + $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table)); - + if ($rs === false) return false; - + $retarr = array(); while (!$rs->EOF){ $fld = new ADOFieldObject(); $fld->name = $rs->fields[0]; $fld->type = $rs->fields[1]; - + // split type into type(length): if (preg_match("/^(.+)\((\d+)\)$/", $fld->type, $query_array)) { $fld->type = $query_array[1]; @@ -102,66 +102,66 @@ class ADODB_fbsql extends ADOConnection { $fld->primary_key = ($rs->fields[3] == 'PRI'); $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false); $fld->binary = (strpos($fld->type,'blob') !== false); - - $retarr[strtoupper($fld->name)] = $fld; + + $retarr[strtoupper($fld->name)] = $fld; $rs->MoveNext(); } $rs->Close(); - return $retarr; + return $retarr; } return false; } - + // returns true or false - function SelectDB($dbName) + function SelectDB($dbName) { $this->databaseName = $dbName; if ($this->_connectionID) { - return @fbsql_select_db($dbName,$this->_connectionID); + return @fbsql_select_db($dbName,$this->_connectionID); } - else return false; + else return false; } - - + + // returns queryID or false function _query($sql,$inputarr) { return fbsql_query("$sql;",$this->_connectionID); } - /* Returns: the last error message from previous database operation */ - function ErrorMsg() + /* Returns: the last error message from previous database operation */ + function ErrorMsg() { $this->_errorMsg = @fbsql_error($this->_connectionID); return $this->_errorMsg; } - - /* Returns: the last error number from previous database operation */ - function ErrorNo() + + /* Returns: the last error number from previous database operation */ + function ErrorNo() { return @fbsql_errno($this->_connectionID); } - + // returns true or false function _close() { return @fbsql_close($this->_connectionID); } - + } - + /*-------------------------------------------------------------------------------------- Class Name: Recordset --------------------------------------------------------------------------------------*/ -class ADORecordSet_fbsql extends ADORecordSet{ - +class ADORecordSet_fbsql extends ADORecordSet{ + var $databaseType = "fbsql"; var $canSeek = true; - - function ADORecordSet_fbsql($queryID,$mode=false) + + function ADORecordSet_fbsql($queryID,$mode=false) { - if (!$mode) { + if (!$mode) { global $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE; } @@ -173,14 +173,14 @@ class ADORecordSet_fbsql extends ADORecordSet{ } return $this->ADORecordSet($queryID); } - + function _initrs() { GLOBAL $ADODB_COUNTRECS; $this->_numOfRows = ($ADODB_COUNTRECS) ? @fbsql_num_rows($this->_queryID):-1; $this->_numOfFields = @fbsql_num_fields($this->_queryID); } - + function &FetchField($fieldOffset = -1) { @@ -194,25 +194,25 @@ class ADORecordSet_fbsql extends ADORecordSet{ $o = @fbsql_fetch_field($this->_queryID);// fbsql returns the max length less spaces -- so it is unrealiable //$o->max_length = -1; } - + return $o; } - + function _seek($row) { return @fbsql_data_seek($this->_queryID,$row); } - + function _fetch($ignore_fields=false) { $this->fields = @fbsql_fetch_array($this->_queryID,$this->fetchMode); return ($this->fields == true); } - + function _close() { - return @fbsql_free_result($this->_queryID); + return @fbsql_free_result($this->_queryID); } - + function MetaType($t,$len=-1,$fieldobj=false) { if (is_object($t)) { @@ -223,36 +223,36 @@ class ADORecordSet_fbsql extends ADORecordSet{ $len = -1; // fbsql max_length is not accurate switch (strtoupper($t)) { case 'CHARACTER': - case 'CHARACTER VARYING': - case 'BLOB': - case 'CLOB': - case 'BIT': - case 'BIT VARYING': + case 'CHARACTER VARYING': + case 'BLOB': + case 'CLOB': + case 'BIT': + case 'BIT VARYING': if ($len <= $this->blobSize) return 'C'; - + // so we have to check whether binary... case 'IMAGE': - case 'LONGBLOB': + case 'LONGBLOB': case 'BLOB': case 'MEDIUMBLOB': return !empty($fieldobj->binary) ? 'B' : 'X'; - + case 'DATE': return 'D'; - + case 'TIME': case 'TIME WITH TIME ZONE': - case 'TIMESTAMP': + case 'TIMESTAMP': case 'TIMESTAMP WITH TIME ZONE': return 'T'; - + case 'PRIMARY_KEY': return 'R'; case 'INTEGER': - case 'SMALLINT': + case 'SMALLINT': case 'BOOLEAN': - + if (!empty($fieldobj->primary_key)) return 'R'; else return 'I'; - + default: return 'N'; } } diff --git a/lib/WikiDB/adodb/drivers/adodb-firebird.inc.php b/lib/WikiDB/adodb/drivers/adodb-firebird.inc.php index 556e1dee1..1ab67c87d 100644 --- a/lib/WikiDB/adodb/drivers/adodb-firebird.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-firebird.inc.php @@ -1,11 +1,11 @@ ADODB_ibase(); } - + function ServerInfo() { $arr['dialect'] = $this->dialect; switch($arr['dialect']) { - case '': + case '': case '1': $s = 'Firebird Dialect 1'; break; case '2': $s = 'Firebird Dialect 2'; break; default: @@ -34,33 +34,33 @@ class ADODB_firebird extends ADODB_ibase { $arr['description'] = $s; return $arr; } - + // Note that Interbase 6.5 uses this ROWS instead - don't you love forking wars! - // SELECT col1, col2 FROM table ROWS 5 -- get 5 rows + // SELECT col1, col2 FROM table ROWS 5 -- get 5 rows // SELECT col1, col2 FROM TABLE ORDER BY col1 ROWS 3 TO 7 -- first 5 skip 2 function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false, $secs=0) { $str = 'SELECT '; - if ($nrows >= 0) $str .= "FIRST $nrows "; + if ($nrows >= 0) $str .= "FIRST $nrows "; $str .=($offset>=0) ? "SKIP $offset " : ''; - - $sql = preg_replace('/^[ \t]*select/i',$str,$sql); + + $sql = preg_replace('/^[ \t]*select/i',$str,$sql); if ($secs) $rs =& $this->CacheExecute($secs,$sql,$inputarr); else $rs =& $this->Execute($sql,$inputarr); - + return $rs; } - - + + }; - -class ADORecordSet_firebird extends ADORecordSet_ibase { - - var $databaseType = "firebird"; - + +class ADORecordSet_firebird extends ADORecordSet_ibase { + + var $databaseType = "firebird"; + function ADORecordSet_firebird($id,$mode=false) { $this->ADORecordSet_ibase($id,$mode); diff --git a/lib/WikiDB/adodb/drivers/adodb-ibase.inc.php b/lib/WikiDB/adodb/drivers/adodb-ibase.inc.php index e9f5e8302..9aa293812 100644 --- a/lib/WikiDB/adodb/drivers/adodb-ibase.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-ibase.inc.php @@ -1,23 +1,23 @@ changed transaction handling and added experimental blob stuff - + Docs to interbase at the website http://www.synectics.co.za/php3/tutorial/IB_PHP3_API.html - + To use gen_id(), see http://www.volny.cz/iprenosil/interbase/ip_ib_code.htm#_code_creategen - + $rs = $conn->Execute('select gen_id(adodb,1) from rdb$database'); $id = $rs->fields[0]; $conn->Execute("insert into table (id, col1,...) values ($id, $val1,...)"); @@ -48,33 +48,33 @@ class ADODB_ibase extends ADOConnection { var $hasAffectedRows = false; var $poorAffectedRows = true; var $blobEncodeType = 'C'; - - function ADODB_ibase() + + function ADODB_ibase() { if (defined('IBASE_DEFAULT')) $this->ibasetrans = IBASE_DEFAULT; } - + function MetaPrimaryKeys($table,$owner_notused=false,$internalKey=false) - { + { if ($internalKey) return array('RDB$DB_KEY'); - + $table = strtoupper($table); - + $sql = 'SELECT S.RDB$FIELD_NAME AFIELDNAME - FROM RDB$INDICES I JOIN RDB$INDEX_SEGMENTS S ON I.RDB$INDEX_NAME=S.RDB$INDEX_NAME + FROM RDB$INDICES I JOIN RDB$INDEX_SEGMENTS S ON I.RDB$INDEX_NAME=S.RDB$INDEX_NAME WHERE I.RDB$RELATION_NAME=\''.$table.'\' and I.RDB$INDEX_NAME like \'RDB$PRIMARY%\' ORDER BY I.RDB$INDEX_NAME,S.RDB$FIELD_POSITION'; $a = $this->GetCol($sql,false,true); if ($a && sizeof($a)>0) return $a; - return false; + return false; } - + function ServerInfo() { $arr['dialect'] = $this->dialect; switch($arr['dialect']) { - case '': + case '': case '1': $s = 'Interbase 5.5 or earlier'; break; case '2': $s = 'Interbase 5.6'; break; default: @@ -86,16 +86,16 @@ class ADODB_ibase extends ADOConnection { } function BeginTrans() - { + { if ($this->transOff) return true; $this->transCnt += 1; $this->autoCommit = false; $this->_transactionID = $this->_connectionID;//ibase_trans($this->ibasetrans, $this->_connectionID); return $this->_transactionID; } - - function CommitTrans($ok=true) - { + + function CommitTrans($ok=true) + { if (!$ok) return $this->RollbackTrans(); if ($this->transOff) return true; if ($this->transCnt) $this->transCnt -= 1; @@ -108,25 +108,25 @@ class ADODB_ibase extends ADOConnection { $this->_transactionID = false; return $ret; } - + function RollbackTrans() { if ($this->transOff) return true; if ($this->transCnt) $this->transCnt -= 1; $ret = false; $this->autoCommit = true; - if ($this->_transactionID) + if ($this->_transactionID) $ret = ibase_rollback($this->_transactionID); - $this->_transactionID = false; - + $this->_transactionID = false; + return $ret; } - + function &MetaIndexes ($table, $primary = FALSE, $owner=false) { // save old fetch mode global $ADODB_FETCH_MODE; - + $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; if ($this->fetchMode !== FALSE) { @@ -149,7 +149,7 @@ class ADODB_ibase extends ADOConnection { $ADODB_FETCH_MODE = $save; return FALSE; } - + $indexes = array (); while ($row = $rs->FetchRow()) { $index = $row[0]; @@ -171,11 +171,11 @@ class ADODB_ibase extends ADOConnection { $this->SetFetchMode($savem); } $ADODB_FETCH_MODE = $save; - + return $indexes; } - + // See http://community.borland.com/article/0,1410,25844,00.html function RowLock($tables,$where,$col) { @@ -183,21 +183,21 @@ class ADODB_ibase extends ADOConnection { $this->Execute("UPDATE $table SET $col=$col WHERE $where "); // is this correct - jlim? return 1; } - - + + function CreateSequence($seqname,$startID=1) { $ok = $this->Execute(("INSERT INTO RDB\$GENERATORS (RDB\$GENERATOR_NAME) VALUES (UPPER('$seqname'))" )); if (!$ok) return false; return $this->Execute("SET GENERATOR $seqname TO ".($startID-1).';'); } - + function DropSequence($seqname) { $seqname = strtoupper($seqname); $this->Execute("delete from RDB\$GENERATORS where RDB\$GENERATOR_NAME='$seqname'"); } - + function GenID($seqname='adodbseq',$startID=1) { $getnext = ("SELECT Gen_ID($seqname,1) FROM RDB\$DATABASE"); @@ -209,13 +209,13 @@ class ADODB_ibase extends ADOConnection { } if ($rs && !$rs->EOF) $this->genID = (integer) reset($rs->fields); else $this->genID = 0; // false - + if ($rs) $rs->Close(); - + return $this->genID; } - function SelectDB($dbName) + function SelectDB($dbName) { return false; } @@ -225,20 +225,20 @@ class ADODB_ibase extends ADOConnection { $this->_errorMsg = ibase_errmsg(); } - function ErrorNo() + function ErrorNo() { if (preg_match('/error code = ([\-0-9]*)/i', $this->_errorMsg,$arr)) return (integer) $arr[1]; else return 0; } - function ErrorMsg() + function ErrorMsg() { return $this->_errorMsg; } // returns true or false function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) - { + { if (!function_exists('ibase_pconnect')) return false; if ($argDatabasename) $argHostname .= ':'.$argDatabasename; $this->_connectionID = ibase_connect($argHostname,$argUsername,$argPassword,$this->charSet,$this->buffers,$this->dialect); @@ -249,8 +249,8 @@ class ADODB_ibase extends ADOConnection { $this->_handleerror(); return false; } - - ibase_timefmt($this->ibase_timefmt); + + ibase_timefmt($this->ibase_timefmt); return true; } // returns true or false @@ -266,11 +266,11 @@ class ADODB_ibase extends ADOConnection { $this->_handleerror(); return false; } - + ibase_timefmt($this->ibase_timefmt); return true; - } - + } + function Prepare($sql) { $stmt = ibase_prepare($this->_connectionID,$sql); @@ -281,7 +281,7 @@ class ADODB_ibase extends ADOConnection { // returns query ID if successful, otherwise false // there have been reports of problems with nested queries - the code is probably not re-entrant? function _query($sql,$iarr=false) - { + { if (!$this->autoCommit && $this->_transactionID) { $conn = $this->_transactionID; @@ -293,7 +293,7 @@ class ADODB_ibase extends ADOConnection { if (is_array($sql)) { $fn = 'ibase_execute'; $sql = $sql[1]; - + if (is_array($iarr)) { if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4 if ( !isset($iarr[0]) ) $iarr[0] = ''; // PHP5 compat hack @@ -312,11 +312,11 @@ class ADODB_ibase extends ADOConnection { case 8: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6],$iarr[7]); break; } } - } else $ret = $fn($sql); + } else $ret = $fn($sql); } else { $fn = 'ibase_query'; - - if (is_array($iarr)) { + + if (is_array($iarr)) { if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4 if ( !isset($iarr[0]) ) $iarr[0] = ''; // PHP5 compat hack $fnarr =& array_merge( array($conn,$sql) , $iarr); @@ -334,7 +334,7 @@ class ADODB_ibase extends ADOConnection { case 8: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6],$iarr[7]); break; } } - } else $ret = $fn($conn,$sql); + } else $ret = $fn($conn,$sql); } if ($docommit && $ret === true) ibase_commit($this->_connectionID); @@ -344,11 +344,11 @@ class ADODB_ibase extends ADOConnection { // returns true or false function _close() - { + { if (!$this->autoCommit) @ibase_rollback($this->_connectionID); return @ibase_close($this->_connectionID); } - + //OPN STUFF start function _ConvertFieldType(&$fld, $ftype, $flen, $fscale, $fsubtype, $fprecision, $isInterbase6) { @@ -356,14 +356,14 @@ class ADODB_ibase extends ADOConnection { $fld->max_length = $flen; $fld->scale = null; switch($ftype){ - case 7: + case 7: case 8: if ($isInterbase6) { switch($fsubtype){ - case 0: + case 0: $fld->type = ($ftype == 7 ? 'smallint' : 'integer'); break; - case 1: + case 1: $fld->type = 'numeric'; $fld->max_length = $fprecision; $fld->scale = $fscale; @@ -384,15 +384,15 @@ class ADODB_ibase extends ADOConnection { } } break; - case 16: + case 16: if ($isInterbase6) { switch($fsubtype){ - case 0: + case 0: $fld->type = 'decimal'; $fld->max_length = 18; $fld->scale = 0; break; - case 1: + case 1: $fld->type = 'numeric'; $fld->max_length = $fprecision; $fld->scale = $fscale; @@ -445,17 +445,17 @@ class ADODB_ibase extends ADOConnection { } //OPN STUFF end // returns array of ADOFieldObjects for current table - function &MetaColumns($table) + function &MetaColumns($table) { global $ADODB_FETCH_MODE; - + if ($this->metaColumnsSQL) { - + $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - + $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table))); - + $ADODB_FETCH_MODE = $save; if ($rs === false) return false; @@ -470,16 +470,16 @@ class ADODB_ibase extends ADOConnection { $this->_ConvertFieldType($fld, $rs->fields[7], $rs->fields[3], $rs->fields[4], $rs->fields[5], $rs->fields[6], $isInterbase6); if (isset($rs->fields[1]) && $rs->fields[1]) { $fld->not_null = true; - } + } if (isset($rs->fields[2])) { - + $fld->has_default = true; $d = substr($rs->fields[2],strlen('default ')); switch ($fld->type) { case 'smallint': case 'integer': $fld->default_value = (int) $d; break; - case 'char': + case 'char': case 'blob': case 'text': case 'varchar': $fld->default_value = (string) substr($d,1,strlen($d)-2); break; @@ -495,110 +495,110 @@ class ADODB_ibase extends ADOConnection { $fld->sub_type = null; } //OPN STUFF end - if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; else $retarr[strtoupper($fld->name)] = $fld; - + $rs->MoveNext(); } $rs->Close(); - return $retarr; + return $retarr; } return false; } - - function BlobEncode( $blob ) + + function BlobEncode( $blob ) { $blobid = ibase_blob_create( $this->_connectionID); ibase_blob_add( $blobid, $blob ); return ibase_blob_close( $blobid ); } - - // since we auto-decode all blob's since 2.42, + + // since we auto-decode all blob's since 2.42, // BlobDecode should not do any transforms function BlobDecode($blob) { - return $blob; + return $blob; } - - - - + + + + // old blobdecode function // still used to auto-decode all blob's - function _BlobDecode( $blob ) + function _BlobDecode( $blob ) { $blobid = ibase_blob_open( $blob ); $realblob = ibase_blob_get( $blobid,$this->maxblobsize); // 2nd param is max size of blob -- Kevin Boillet - while($string = ibase_blob_get($blobid, 8192)){ - $realblob .= $string; + while($string = ibase_blob_get($blobid, 8192)){ + $realblob .= $string; } ibase_blob_close( $blobid ); return( $realblob ); - } - - function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB') - { - $fd = fopen($path,'rb'); - if ($fd === false) return false; - $blob_id = ibase_blob_create($this->_connectionID); - - /* fill with data */ - - while ($val = fread($fd,32768)){ - ibase_blob_add($blob_id, $val); - } - - /* close and get $blob_id_str for inserting into table */ - $blob_id_str = ibase_blob_close($blob_id); - - fclose($fd); - return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false; - } - + } + + function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB') + { + $fd = fopen($path,'rb'); + if ($fd === false) return false; + $blob_id = ibase_blob_create($this->_connectionID); + + /* fill with data */ + + while ($val = fread($fd,32768)){ + ibase_blob_add($blob_id, $val); + } + + /* close and get $blob_id_str for inserting into table */ + $blob_id_str = ibase_blob_close($blob_id); + + fclose($fd); + return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false; + } + /* Insert a null into the blob field of the table first. Then use UpdateBlob to store the blob. - + Usage: - + $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1'); */ - function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') - { - $blob_id = ibase_blob_create($this->_connectionID); - - // ibase_blob_add($blob_id, $val); - - // replacement that solves the problem by which only the first modulus 64K / - // of $val are stored at the blob field //////////////////////////////////// + function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') + { + $blob_id = ibase_blob_create($this->_connectionID); + + // ibase_blob_add($blob_id, $val); + + // replacement that solves the problem by which only the first modulus 64K / + // of $val are stored at the blob field //////////////////////////////////// // Thx Abel Berenstein aberenstein#afip.gov.ar - $len = strlen($val); - $chunk_size = 32768; - $tail_size = $len % $chunk_size; - $n_chunks = ($len - $tail_size) / $chunk_size; - - for ($n = 0; $n < $n_chunks; $n++) { - $start = $n * $chunk_size; - $data = substr($val, $start, $chunk_size); - ibase_blob_add($blob_id, $data); - } - + $len = strlen($val); + $chunk_size = 32768; + $tail_size = $len % $chunk_size; + $n_chunks = ($len - $tail_size) / $chunk_size; + + for ($n = 0; $n < $n_chunks; $n++) { + $start = $n * $chunk_size; + $data = substr($val, $start, $chunk_size); + ibase_blob_add($blob_id, $data); + } + if ($tail_size) { - $start = $n_chunks * $chunk_size; - $data = substr($val, $start, $tail_size); - ibase_blob_add($blob_id, $data); - } - // end replacement ///////////////////////////////////////////////////////// - - $blob_id_str = ibase_blob_close($blob_id); - - return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false; - - } - - + $start = $n_chunks * $chunk_size; + $data = substr($val, $start, $tail_size); + ibase_blob_add($blob_id, $data); + } + // end replacement ///////////////////////////////////////////////////////// + + $blob_id_str = ibase_blob_close($blob_id); + + return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false; + + } + + function OldUpdateBlob($table,$column,$val,$where,$blobtype='BLOB') { $blob_id = ibase_blob_create($this->_connectionID); @@ -606,15 +606,15 @@ class ADODB_ibase extends ADOConnection { $blob_id_str = ibase_blob_close($blob_id); return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false; } - + // Format date column in sql string given an input format that understands Y M D // Only since Interbase 6.0 - uses EXTRACT // problem - does not zero-fill the day and month yet function SQLDate($fmt, $col=false) - { + { if (!$col) $col = $this->sysDate; $s = ''; - + $len = strlen($fmt); for ($i=0; $i < $len; $i++) { if ($s) $s .= '||'; @@ -639,15 +639,15 @@ class ADODB_ibase extends ADOConnection { case 'H': case 'h': $s .= "(extract(hour from $col))"; - break; + break; case 'I': case 'i': $s .= "(extract(minute from $col))"; - break; + break; case 'S': case 's': $s .= "CAST((extract(second from $col)) AS INTEGER)"; - break; + break; default: if ($ch == '\\') { @@ -666,17 +666,17 @@ class ADODB_ibase extends ADOConnection { Class Name: Recordset --------------------------------------------------------------------------------------*/ -class ADORecordset_ibase extends ADORecordSet +class ADORecordset_ibase extends ADORecordSet { var $databaseType = "ibase"; var $bind=false; var $_cacheType; - + function ADORecordset_ibase($id,$mode=false) { global $ADODB_FETCH_MODE; - + $this->fetchMode = ($mode === false) ? $ADODB_FETCH_MODE : $mode; return $this->ADORecordSet($id); } @@ -701,12 +701,12 @@ class ADORecordset_ibase extends ADORecordSet { $this->_numOfRows = -1; $this->_numOfFields = @ibase_num_fields($this->_queryID); - + // cache types for blob decode check - for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { - $f1 = $this->FetchField($i); + for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { + $f1 = $this->FetchField($i); $this->_cacheType[] = $f1->type; - } + } } function _seek($row) @@ -714,39 +714,39 @@ class ADORecordset_ibase extends ADORecordSet return false; } - - - function _fetch() + + + function _fetch() { - $f = @ibase_fetch_row($this->_queryID); + $f = @ibase_fetch_row($this->_queryID); if ($f === false) { $this->fields = false; return false; } // OPN stuff start - optimized // fix missing nulls and decode blobs automatically - + global $ADODB_ANSI_PADDING_OFF; //$ADODB_ANSI_PADDING_OFF=1; $rtrim = !empty($ADODB_ANSI_PADDING_OFF); - - for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { + + for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { if ($this->_cacheType[$i]=="BLOB") { - if (isset($f[$i])) { - $f[$i] = $this->connection->_BlobDecode($f[$i]); - } else { - $f[$i] = null; - } - } else { - if (!isset($f[$i])) { - $f[$i] = null; + if (isset($f[$i])) { + $f[$i] = $this->connection->_BlobDecode($f[$i]); + } else { + $f[$i] = null; + } + } else { + if (!isset($f[$i])) { + $f[$i] = null; } else if ($rtrim && is_string($f[$i])) { $f[$i] = rtrim($f[$i]); } - } - } - // OPN stuff end - + } + } + // OPN stuff end + $this->fields = $f; if ($this->fetchMode == ADODB_FETCH_ASSOC) { $this->fields = &$this->GetRowAssoc(ADODB_ASSOC_CASE); @@ -767,13 +767,13 @@ class ADORecordset_ibase extends ADORecordSet $this->bind[strtoupper($o->name)] = $i; } } - + return $this->fields[$this->bind[strtoupper($colname)]]; - + } - - function _close() + + function _close() { return @ibase_free_result($this->_queryID); } @@ -788,7 +788,7 @@ class ADORecordset_ibase extends ADORecordSet switch (strtoupper($t)) { case 'CHAR': return 'C'; - + case 'TEXT': case 'VARCHAR': case 'VARYING': @@ -796,14 +796,14 @@ class ADORecordset_ibase extends ADORecordSet return 'X'; case 'BLOB': return 'B'; - + case 'TIMESTAMP': case 'DATE': return 'D'; - + //case 'T': return 'T'; //case 'L': return 'L'; - case 'INT': + case 'INT': case 'SHORT': case 'INTEGER': return 'I'; default: return 'N'; diff --git a/lib/WikiDB/adodb/drivers/adodb-informix72.inc.php b/lib/WikiDB/adodb/drivers/adodb-informix72.inc.php index d96b908ef..8109dfb37 100644 --- a/lib/WikiDB/adodb/drivers/adodb-informix72.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-informix72.inc.php @@ -27,9 +27,9 @@ class ADODB_informix72 extends ADOConnection { var $upperCase = 'upper'; var $substr = 'substr'; var $metaTablesSQL="select tabname from systables"; - var $metaColumnsSQL = -"select c.colname, c.coltype, c.collength, d.default - from syscolumns c, systables t,sysdefaults d + var $metaColumnsSQL = +"select c.colname, c.coltype, c.collength, d.default + from syscolumns c, systables t,sysdefaults d where c.tabid=t.tabid and d.tabid=t.tabid and d.colno=c.colno and tabname='%s'"; // var $metaColumnsSQL = "select colname, coltype, collength from syscolumns c, systables t where c.tabid=t.tabid and tabname='%s'"; @@ -43,7 +43,7 @@ class ADODB_informix72 extends ADOConnection { var $sysDate = 'TODAY'; var $sysTimeStamp = 'CURRENT'; var $cursorType = IFX_SCROLL; // IFX_SCROLL or IFX_HOLD or 0 - + function ADODB_informix72() { // alternatively, use older method: @@ -51,18 +51,18 @@ class ADODB_informix72 extends ADOConnection { // force ISO date format putenv('GL_DATE=%Y-%m-%d'); - + if (function_exists('ifx_byteasvarchar')) { - ifx_byteasvarchar(1); // Mode "0" will return a blob id, and mode "1" will return a varchar with text content. - ifx_textasvarchar(1); // Mode "0" will return a blob id, and mode "1" will return a varchar with text content. + ifx_byteasvarchar(1); // Mode "0" will return a blob id, and mode "1" will return a varchar with text content. + ifx_textasvarchar(1); // Mode "0" will return a blob id, and mode "1" will return a varchar with text content. ifx_blobinfile_mode(0); // Mode "0" means save Byte-Blobs in memory, and mode "1" means save Byte-Blobs in a file. } } - + function ServerInfo() { if (isset($this->version)) return $this->version; - + $arr['description'] = $this->GetOne("select DBINFO('version','full') from systables where tabid = 1"); $arr['version'] = $this->GetOne("select DBINFO('version','major')||"."||DBINFO('version','minor') from systables where tabid = 1"); $this->version = $arr; @@ -94,8 +94,8 @@ class ADODB_informix72 extends ADOConnection { return true; } - function CommitTrans($ok=true) - { + function CommitTrans($ok=true) + { if (!$ok) return $this->RollbackTrans(); if ($this->transOff) return true; if ($this->transCnt) $this->transCnt -= 1; @@ -122,7 +122,7 @@ class ADODB_informix72 extends ADOConnection { /* Returns: the last error message from previous database operation Note: This function is NOT available for Microsoft SQL Server. */ - function ErrorMsg() + function ErrorMsg() { if (!empty($this->_logsql)) return $this->_errorMsg; $this->_errorMsg = ifx_errormsg(); @@ -132,15 +132,15 @@ class ADODB_informix72 extends ADOConnection { function ErrorNo() { preg_match("/.*SQLCODE=([^\]]*)/",ifx_error(),$parse); //!EOS - if (is_array($parse) && isset($parse[1])) return (int)$parse[1]; + if (is_array($parse) && isset($parse[1])) return (int)$parse[1]; return 0; } - + function &MetaColumns($table) { global $ADODB_FETCH_MODE; - + if (!empty($this->metaColumnsSQL)) { $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; @@ -163,17 +163,17 @@ class ADODB_informix72 extends ADOConnection { $fld->has_default = 0; } - $retarr[strtolower($fld->name)] = $fld; + $retarr[strtolower($fld->name)] = $fld; $rs->MoveNext(); } $rs->Close(); - return $retarr; + return $retarr; } return false; } - + function &xMetaColumns($table) { return ADOConnection::MetaColumns($table,false); @@ -190,15 +190,15 @@ class ADODB_informix72 extends ADOConnection { { return function_exists('ifx_byteasvarchar') ? $blobid : @ifx_get_blob($blobid); } - + // returns true or false function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) { if (!function_exists('ifx_connect')) return false; - + $dbs = $argDatabasename . "@" . $argHostname; - if ($argHostname) putenv("INFORMIXSERVER=$argHostname"); - putenv("INFORMIXSERVER=".trim($argHostname)); + if ($argHostname) putenv("INFORMIXSERVER=$argHostname"); + putenv("INFORMIXSERVER=".trim($argHostname)); $this->_connectionID = ifx_connect($dbs,$argUsername,$argPassword); if ($this->_connectionID === false) return false; #if ($argDatabasename) return $this->SelectDB($argDatabasename); @@ -209,9 +209,9 @@ class ADODB_informix72 extends ADOConnection { function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { if (!function_exists('ifx_connect')) return false; - + $dbs = $argDatabasename . "@" . $argHostname; - putenv("INFORMIXSERVER=".trim($argHostname)); + putenv("INFORMIXSERVER=".trim($argHostname)); $this->_connectionID = ifx_pconnect($dbs,$argUsername,$argPassword); if ($this->_connectionID === false) return false; #if ($argDatabasename) return $this->SelectDB($argDatabasename); @@ -230,7 +230,7 @@ class ADODB_informix72 extends ADOConnection { function _query($sql,$inputarr) { global $ADODB_COUNTRECS; - + // String parameters have to be converted using ifx_create_char if ($inputarr) { foreach($inputarr as $v) { @@ -291,7 +291,7 @@ class ADORecordset_informix72 extends ADORecordSet { function ADORecordset_informix72($id,$mode=false) { - if ($mode === false) { + if ($mode === false) { global $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE; } diff --git a/lib/WikiDB/adodb/drivers/adodb-ldap.inc.php b/lib/WikiDB/adodb/drivers/adodb-ldap.inc.php index dda2bd210..88414335a 100644 --- a/lib/WikiDB/adodb/drivers/adodb-ldap.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-ldap.inc.php @@ -1,66 +1,66 @@ _connectionID = ldap_connect( $conn_info[0], $conn_info[1] ) + $this->_connectionID = ldap_connect( $conn_info[0], $conn_info[1] ) or die( 'Could not connect to ' . $this->_connectionID ); if ($username && $password) { - $bind = ldap_bind( $this->_connectionID, $username, $password ) + $bind = ldap_bind( $this->_connectionID, $username, $password ) or die( 'Could not bind to ' . $this->_connectionID . ' with $username & $password'); } else { - $bind = ldap_bind( $this->_connectionID ) + $bind = ldap_bind( $this->_connectionID ) or die( 'Could not bind anonymously to ' . $this->_connectionID ); } return $this->_connectionID; } - - + + /* returns _queryID or false */ function _query($sql,$inputarr) { $rs = ldap_search( $this->_connectionID, $this->database, $sql ); - return $rs; - + return $rs; + } /* closes the LDAP connection */ @@ -69,20 +69,20 @@ class ADODB_ldap extends ADOConnection { @ldap_close( $this->_connectionID ); $this->_connectionID = false; } - + function ServerInfo() { if( is_array( $this->version ) ) return $this->version; $version = array(); /* - Determines how aliases are handled during search. + Determines how aliases are handled during search. LDAP_DEREF_NEVER (0x00) LDAP_DEREF_SEARCHING (0x01) LDAP_DEREF_FINDING (0x02) LDAP_DEREF_ALWAYS (0x03) - The LDAP_DEREF_SEARCHING value means aliases are dereferenced during the search but - not when locating the base object of the search. The LDAP_DEREF_FINDING value means - aliases are dereferenced when locating the base object but not during the search. + The LDAP_DEREF_SEARCHING value means aliases are dereferenced during the search but + not when locating the base object of the search. The LDAP_DEREF_FINDING value means + aliases are dereferenced when locating the base object but not during the search. Default: LDAP_DEREF_NEVER */ ldap_get_option( $this->_connectionID, LDAP_OPT_DEREF, $version['LDAP_OPT_DEREF'] ) ; @@ -96,9 +96,9 @@ class ADODB_ldap extends ADOConnection { case 3: $version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_ALWAYS'; } - - /* - A limit on the number of entries to return from a search. + + /* + A limit on the number of entries to return from a search. LDAP_NO_LIMIT (0) means no limit. Default: LDAP_NO_LIMIT */ @@ -106,9 +106,9 @@ class ADODB_ldap extends ADOConnection { if ( $version['LDAP_OPT_SIZELIMIT'] == 0 ) { $version['LDAP_OPT_SIZELIMIT'] = 'LDAP_NO_LIMIT'; } - + /* - A limit on the number of seconds to spend on a search. + A limit on the number of seconds to spend on a search. LDAP_NO_LIMIT (0) means no limit. Default: LDAP_NO_LIMIT */ @@ -116,9 +116,9 @@ class ADODB_ldap extends ADOConnection { if ( $version['LDAP_OPT_TIMELIMIT'] == 0 ) { $version['LDAP_OPT_TIMELIMIT'] = 'LDAP_NO_LIMIT'; } - + /* - Determines whether the LDAP library automatically follows referrals returned by LDAP servers or not. + Determines whether the LDAP library automatically follows referrals returned by LDAP servers or not. LDAP_OPT_ON LDAP_OPT_OFF Default: ON @@ -128,10 +128,10 @@ class ADODB_ldap extends ADOConnection { $version['LDAP_OPT_REFERRALS'] = 'LDAP_OPT_OFF'; } else { $version['LDAP_OPT_REFERRALS'] = 'LDAP_OPT_ON'; - + } /* - Determines whether LDAP I/O operations are automatically restarted if they abort prematurely. + Determines whether LDAP I/O operations are automatically restarted if they abort prematurely. LDAP_OPT_ON LDAP_OPT_OFF Default: OFF @@ -141,7 +141,7 @@ class ADODB_ldap extends ADOConnection { $version['LDAP_OPT_RESTART'] = 'LDAP_OPT_OFF'; } else { $version['LDAP_OPT_RESTART'] = 'LDAP_OPT_ON'; - + } /* This option indicates the version of the LDAP protocol used when communicating with the primary LDAP server. @@ -154,56 +154,56 @@ class ADODB_ldap extends ADOConnection { $version['LDAP_OPT_PROTOCOL_VERSION'] = 'LDAP_VERSION2'; } else { $version['LDAP_OPT_PROTOCOL_VERSION'] = 'LDAP_VERSION3'; - + } /* The host name (or list of hosts) for the primary LDAP server. */ - ldap_get_option( $this->_connectionID, LDAP_OPT_HOST_NAME, $version['LDAP_OPT_HOST_NAME'] ); - ldap_get_option( $this->_connectionID, OPT_ERROR_NUMBER, $version['OPT_ERROR_NUMBER'] ); - ldap_get_option( $this->_connectionID, OPT_ERROR_STRING, $version['OPT_ERROR_STRING'] ); - ldap_get_option( $this->_connectionID, LDAP_OPT_MATCHED_DN, $version['LDAP_OPT_MATCHED_DN'] ); - + ldap_get_option( $this->_connectionID, LDAP_OPT_HOST_NAME, $version['LDAP_OPT_HOST_NAME'] ); + ldap_get_option( $this->_connectionID, OPT_ERROR_NUMBER, $version['OPT_ERROR_NUMBER'] ); + ldap_get_option( $this->_connectionID, OPT_ERROR_STRING, $version['OPT_ERROR_STRING'] ); + ldap_get_option( $this->_connectionID, LDAP_OPT_MATCHED_DN, $version['LDAP_OPT_MATCHED_DN'] ); + return $this->version = $version; - + } } - + /*-------------------------------------------------------------------------------------- Class Name: Recordset --------------------------------------------------------------------------------------*/ -class ADORecordSet_ldap extends ADORecordSet{ - +class ADORecordSet_ldap extends ADORecordSet{ + var $databaseType = "ldap"; var $canSeek = false; var $_entryID; /* keeps track of the entry resource identifier */ - - function ADORecordSet_ldap($queryID,$mode=false) + + function ADORecordSet_ldap($queryID,$mode=false) { - if ($mode === false) { + if ($mode === false) { global $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE; } switch ($mode) { - case ADODB_FETCH_NUM: - $this->fetchMode = LDAP_NUM; + case ADODB_FETCH_NUM: + $this->fetchMode = LDAP_NUM; break; - case ADODB_FETCH_ASSOC: - $this->fetchMode = LDAP_ASSOC; + case ADODB_FETCH_ASSOC: + $this->fetchMode = LDAP_ASSOC; break; default: case ADODB_FETCH_DEFAULT: - case ADODB_FETCH_BOTH: - $this->fetchMode = LDAP_BOTH; + case ADODB_FETCH_BOTH: + $this->fetchMode = LDAP_BOTH; break; } - - $this->ADORecordSet($queryID); + + $this->ADORecordSet($queryID); } - + function _initrs() { - /* + /* This could be teaked to respect the $COUNTRECS directive from ADODB It's currently being used in the _fetch() function and the GetAssoc() function @@ -215,7 +215,7 @@ class ADORecordSet_ldap extends ADORecordSet{ /* Return whole recordset as a multi-dimensional associative array */ - function &GetAssoc($force_array = false, $first2cols = false) + function &GetAssoc($force_array = false, $first2cols = false) { $records = $this->_numOfRows; $results = array(); @@ -227,14 +227,14 @@ class ADORecordSet_ldap extends ADORecordSet{ } else { array_shift( $v ); $results[$i][$k] = $v; - } + } } } } - - return $results; + + return $results; } - + function &GetRowAssoc() { $results = array(); @@ -245,13 +245,13 @@ class ADORecordSet_ldap extends ADORecordSet{ } else { array_shift( $v ); $results[$k] = $v; - } + } } } - - return $results; + + return $results; } - + function GetRowNums() { $results = array(); @@ -263,47 +263,47 @@ class ADORecordSet_ldap extends ADORecordSet{ } else { array_shift( $v ); $results[$i] = $v; - } + } $i++; } } return $results; } - + function _fetch() - { + { if ( $this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0 ) return false; - + if ( $this->_currentRow == 0 ) { $this->_entryID = ldap_first_entry( $this->connection->_connectionID, $this->_queryID ); } else { $this->_entryID = ldap_next_entry( $this->connection->_connectionID, $this->_entryID ); } - + $this->fields = ldap_get_attributes( $this->connection->_connectionID, $this->_entryID ); - $this->_numOfFields = $this->fields['count']; + $this->_numOfFields = $this->fields['count']; switch ( $this->fetchMode ) { - + case LDAP_ASSOC: $this->fields = $this->GetRowAssoc(); break; - + case LDAP_NUM: $this->fields = $this->GetRowNums(); break; - + case LDAP_BOTH: default: break; } - return ( is_array( $this->fields ) ); + return ( is_array( $this->fields ) ); } - + function _close() { - @ldap_free_result( $this->_queryID ); + @ldap_free_result( $this->_queryID ); $this->_queryID = false; } - + } ?> diff --git a/lib/WikiDB/adodb/drivers/adodb-mssql.inc.php b/lib/WikiDB/adodb/drivers/adodb-mssql.inc.php index d92d20c21..defa12e54 100644 --- a/lib/WikiDB/adodb/drivers/adodb-mssql.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-mssql.inc.php @@ -1,30 +1,30 @@ = 0x4300) { // docs say 4.2.0, but testing shows only since 4.3.0 does it work! - @ini_set('mssql.datetimeconvert',0); + @ini_set('mssql.datetimeconvert',0); } else { global $ADODB_mssql_mths; // array, months must be upper-case - $ADODB_mssql_date_order = 'mdy'; + $ADODB_mssql_date_order = 'mdy'; $ADODB_mssql_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); @@ -68,7 +68,7 @@ global $ADODB_mssql_date_order; } class ADODB_mssql extends ADOConnection { - var $databaseType = "mssql"; + var $databaseType = "mssql"; var $dataProvider = "mssql"; var $replaceQuote = "''"; // string to use to replace quotes var $fmtDate = "'Y-m-d'"; @@ -83,7 +83,7 @@ class ADODB_mssql extends ADOConnection { var $metaColumnsSQL = # xtype==61 is datetime "select c.name,t.name,c.length, (case when c.xusertype=61 then 0 else c.xprec end), - (case when c.xusertype=61 then 0 else c.xscale end) + (case when c.xusertype=61 then 0 else c.xscale end) from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='%s'"; var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE var $hasGenID = true; @@ -100,52 +100,52 @@ class ADODB_mssql extends ADOConnection { var $identitySQL = 'select @@IDENTITY'; // 'select SCOPE_IDENTITY'; # for mssql 2000 var $uniqueOrderBy = true; var $_bindInputArray = true; - - - function ADODB_mssql() - { + + + function ADODB_mssql() + { $this->_has_mssql_init = (strnatcmp(PHP_VERSION,'4.1.0')>=0); } function ServerInfo() { global $ADODB_FETCH_MODE; - + $stmt = $this->PrepareSP('sp_server_info'); $val = 2; if ($this->fetchMode === false) { $savem = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - } else + } else $savem = $this->SetFetchMode(ADODB_FETCH_NUM); - - + + $this->Parameter($stmt,$val,'attribute_id'); $row = $this->GetRow($stmt); - + //$row = $this->GetRow("execute sp_server_info 2"); - + if ($this->fetchMode === false) { $ADODB_FETCH_MODE = $savem; } else $this->SetFetchMode($savem); - + $arr['description'] = $row[2]; $arr['version'] = ADOConnection::_findvers($arr['description']); return $arr; } - - function IfNull( $field, $ifNull ) + + function IfNull( $field, $ifNull ) { return " ISNULL($field, $ifNull) "; // if MS SQL Server } - + function _insertid() { // SCOPE_IDENTITY() - // Returns the last IDENTITY value inserted into an IDENTITY column in - // the same scope. A scope is a module -- a stored procedure, trigger, - // function, or batch. Thus, two statements are in the same scope if + // Returns the last IDENTITY value inserted into an IDENTITY column in + // the same scope. A scope is a module -- a stored procedure, trigger, + // function, or batch. Thus, two statements are in the same scope if // they are in the same stored procedure, function, or batch. return $this->GetOne($this->identitySQL); } @@ -156,7 +156,7 @@ class ADODB_mssql extends ADOConnection { } var $_dropSeqSQL = "drop table %s"; - + function CreateSequence($seq='adodbseq',$start=1) { $start -= 1; @@ -166,7 +166,7 @@ class ADODB_mssql extends ADOConnection { $this->Execute('ROLLBACK TRANSACTION adodbseq'); return false; } - $this->Execute('COMMIT TRANSACTION adodbseq'); + $this->Execute('COMMIT TRANSACTION adodbseq'); return true; } @@ -182,17 +182,17 @@ class ADODB_mssql extends ADOConnection { $this->Execute('ROLLBACK TRANSACTION adodbseq'); return false; } - $this->Execute('COMMIT TRANSACTION adodbseq'); + $this->Execute('COMMIT TRANSACTION adodbseq'); return $start; } $num = $this->GetOne("select id from $seq"); - $this->Execute('COMMIT TRANSACTION adodbseq'); + $this->Execute('COMMIT TRANSACTION adodbseq'); return $num; - + // in old implementation, pre 1.90, we returned GUID... //return $this->GetOne("SELECT CONVERT(varchar(255), NEWID()) AS 'Char'"); } - + function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) { @@ -202,17 +202,17 @@ class ADODB_mssql extends ADOConnection { $rs =& $this->Execute($sql,$inputarr); } else $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); - + return $rs; } - - + + // Format date column in sql string given an input format that understands Y M D function SQLDate($fmt, $col=false) - { + { if (!$col) $col = $this->sysTimeStamp; $s = ''; - + $len = strlen($fmt); for ($i=0; $i < $len; $i++) { if ($s) $s .= '+'; @@ -239,11 +239,11 @@ class ADODB_mssql extends ADOConnection { case 'h': $s .= "substring(convert(char(14),$col,0),13,2)"; break; - + case 'H': $s .= "replace(str(datepart(hh,$col),2),' ','0')"; break; - + case 'i': $s .= "replace(str(datepart(mi,$col),2),' ','0')"; break; @@ -254,7 +254,7 @@ class ADODB_mssql extends ADOConnection { case 'A': $s .= "substring(convert(char(19),$col,0),18,2)"; break; - + default: if ($ch == '\\') { $i++; @@ -267,18 +267,18 @@ class ADODB_mssql extends ADOConnection { return $s; } - + function BeginTrans() { - if ($this->transOff) return true; + if ($this->transOff) return true; $this->transCnt += 1; $this->Execute('BEGIN TRAN'); return true; } - - function CommitTrans($ok=true) - { - if ($this->transOff) return true; + + function CommitTrans($ok=true) + { + if ($this->transOff) return true; if (!$ok) return $this->RollbackTrans(); if ($this->transCnt) $this->transCnt -= 1; $this->Execute('COMMIT TRAN'); @@ -286,39 +286,39 @@ class ADODB_mssql extends ADOConnection { } function RollbackTrans() { - if ($this->transOff) return true; + if ($this->transOff) return true; if ($this->transCnt) $this->transCnt -= 1; $this->Execute('ROLLBACK TRAN'); return true; } - + /* Usage: - + $this->BeginTrans(); $this->RowLock('table1,table2','table1.id=33 and table2.id=table1.id'); # lock row 33 for both tables - + # some operation on both tables table1 and table2 - + $this->CommitTrans(); - + See http://www.swynk.com/friends/achigrik/SQL70Locks.asp */ - function RowLock($tables,$where) + function RowLock($tables,$where) { if (!$this->transCnt) $this->BeginTrans(); return $this->GetOne("select top 1 null as ignore from $tables with (ROWLOCK,HOLDLOCK) where $where"); } - + function MetaForeignKeys($table, $owner=false, $upper=false) { global $ADODB_FETCH_MODE; - + $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; $table = $this->qstr(strtoupper($table)); - - $sql = + + $sql = "select object_name(constid) as constraint_name, col_name(fkeyid, fkey) as column_name, object_name(rkeyid) as referenced_table_name, @@ -326,20 +326,20 @@ class ADODB_mssql extends ADOConnection { from sysforeignkeys where upper(object_name(fkeyid)) = $table order by constraint_name, referenced_table_name, keyno"; - + $constraints =& $this->GetArray($sql); - + $ADODB_FETCH_MODE = $save; - + $arr = false; foreach($constraints as $constr) { //print_r($constr); - $arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3]; + $arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3]; } if (!$arr) return false; - + $arr2 = false; - + foreach($arr as $k => $v) { foreach($v as $a => $b) { if ($upper) $a = strtoupper($a); @@ -350,43 +350,43 @@ order by constraint_name, referenced_table_name, keyno"; } //From: Fernando Moreira - function MetaDatabases() - { - if(@mssql_select_db("master")) { - $qry=$this->metaDatabasesSQL; - if($rs=@mssql_query($qry)){ - $tmpAr=$ar=array(); - while($tmpAr=@mssql_fetch_row($rs)) - $ar[]=$tmpAr[0]; - @mssql_select_db($this->databaseName); - if(sizeof($ar)) - return($ar); - else - return(false); - } else { - @mssql_select_db($this->databaseName); - return(false); - } - } - return(false); - } + function MetaDatabases() + { + if(@mssql_select_db("master")) { + $qry=$this->metaDatabasesSQL; + if($rs=@mssql_query($qry)){ + $tmpAr=$ar=array(); + while($tmpAr=@mssql_fetch_row($rs)) + $ar[]=$tmpAr[0]; + @mssql_select_db($this->databaseName); + if(sizeof($ar)) + return($ar); + else + return(false); + } else { + @mssql_select_db($this->databaseName); + return(false); + } + } + return(false); + } // "Stein-Aksel Basma" // tested with MSSQL 2000 function MetaPrimaryKeys($table) { $sql = "select k.column_name from information_schema.key_column_usage k, - information_schema.table_constraints tc + information_schema.table_constraints tc where tc.constraint_name = k.constraint_name and tc.constraint_type = 'PRIMARY KEY' and k.table_name = '$table'"; - + $a = $this->GetCol($sql); if ($a && sizeof($a)>0) return $a; - return false; + return false; } - - function &MetaTables($ttype=false,$showSchema=false,$mask=false) + + function &MetaTables($ttype=false,$showSchema=false,$mask=false) { if ($mask) { $save = $this->metaTablesSQL; @@ -394,31 +394,31 @@ order by constraint_name, referenced_table_name, keyno"; $this->metaTablesSQL .= " AND name like $mask"; } $ret =& ADOConnection::MetaTables($ttype,$showSchema); - + if ($mask) { $this->metaTablesSQL = $save; } return $ret; } - - function SelectDB($dbName) + + function SelectDB($dbName) { $this->databaseName = $dbName; if ($this->_connectionID) { - return @mssql_select_db($dbName); + return @mssql_select_db($dbName); } - else return false; + else return false; } - - function ErrorMsg() + + function ErrorMsg() { if (empty($this->_errorMsg)){ $this->_errorMsg = mssql_get_last_message(); } return $this->_errorMsg; } - - function ErrorNo() + + function ErrorNo() { if ($this->_logsql && $this->_errorCode !== false) return $this->_errorCode; if (empty($this->_errorMsg)) { @@ -431,7 +431,7 @@ order by constraint_name, referenced_table_name, keyno"; if (is_array($arr)) return $arr[0]; else return -1; } - + // returns true or false function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) { @@ -439,26 +439,26 @@ order by constraint_name, referenced_table_name, keyno"; $this->_connectionID = mssql_connect($argHostname,$argUsername,$argPassword); if ($this->_connectionID === false) return false; if ($argDatabasename) return $this->SelectDB($argDatabasename); - return true; + return true; } - - + + // returns true or false function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { if (!function_exists('mssql_pconnect')) return false; $this->_connectionID = mssql_pconnect($argHostname,$argUsername,$argPassword); if ($this->_connectionID === false) return false; - + // persistent connections can forget to rollback on crash, so we do it here. if ($this->autoRollback) { $cnt = $this->GetOne('select @@TRANCOUNT'); - while (--$cnt >= 0) $this->Execute('ROLLBACK TRAN'); + while (--$cnt >= 0) $this->Execute('ROLLBACK TRAN'); } if ($argDatabasename) return $this->SelectDB($argDatabasename); - return true; + return true; } - + function Prepare($sql) { $sqlarr = explode('?',$sql); @@ -466,10 +466,10 @@ order by constraint_name, referenced_table_name, keyno"; $sql2 = $sqlarr[0]; for ($i = 1, $max = sizeof($sqlarr); $i < $max; $i++) { $sql2 .= '@P'.($i-1) . $sqlarr[$i]; - } + } return array($sql,$this->qstr($sql2),$max); } - + function PrepareSP($sql) { if (!$this->_has_mssql_init) { @@ -480,23 +480,23 @@ order by constraint_name, referenced_table_name, keyno"; if (!$stmt) return $sql; return array($sql,$stmt); } - - /* + + /* Usage: $stmt = $db->PrepareSP('SP_RUNSOMETHING'); -- takes 2 params, @myid and @group - + # note that the parameter does not have @ in front! $db->Parameter($stmt,$id,'myid'); $db->Parameter($stmt,$group,'group',false,64); $db->Execute($stmt); - + @param $stmt Statement returned by Prepare() or PrepareSP(). @param $var PHP variable to bind to. Can set to null (for isNull support). @param $name Name of stored procedure variable name to bind to. @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8. @param [$maxLen] Holds an maximum length of the variable. @param [$type] The data type of $var. Legal values depend on driver. - + See mssql_bind documentation at php.net. */ function Parameter(&$stmt, &$var, $name, $isOutput=false, $maxLen=4000, $type=false) @@ -507,8 +507,8 @@ order by constraint_name, referenced_table_name, keyno"; } $isNull = is_null($var); // php 4.0.4 and above... - - if ($type === false) + + if ($type === false) switch(gettype($var)) { default: case 'string': $type = SQLCHAR; break; @@ -516,7 +516,7 @@ order by constraint_name, referenced_table_name, keyno"; case 'integer': $type = SQLINT4; break; case 'boolean': $type = SQLINT1; break; # SQLBIT not supported in 4.1.0 } - + if ($this->debug) { $prefix = ($isOutput) ? 'Out' : 'In'; $ztype = (empty($type)) ? 'false' : $type; @@ -524,42 +524,42 @@ order by constraint_name, referenced_table_name, keyno"; } /* See http://phplens.com/lens/lensforum/msgs.php?id=7231 - + RETVAL is HARD CODED into php_mssql extension: - The return value (a long integer value) is treated like a special OUTPUT parameter, - called "RETVAL" (without the @). See the example at mssql_execute to - see how it works. - type: one of this new supported PHP constants. - SQLTEXT, SQLVARCHAR,SQLCHAR, SQLINT1,SQLINT2, SQLINT4, SQLBIT,SQLFLT8 + The return value (a long integer value) is treated like a special OUTPUT parameter, + called "RETVAL" (without the @). See the example at mssql_execute to + see how it works. - type: one of this new supported PHP constants. + SQLTEXT, SQLVARCHAR,SQLCHAR, SQLINT1,SQLINT2, SQLINT4, SQLBIT,SQLFLT8 */ if ($name !== 'RETVAL') $name = '@'.$name; return mssql_bind($stmt[1], $name, $var, $type, $isOutput, $isNull, $maxLen); } - - /* + + /* Unfortunately, it appears that mssql cannot handle varbinary > 255 chars So all your blobs must be of type "image". - + Remember to set in php.ini the following... - - ; Valid range 0 - 2147483647. Default = 4096. - mssql.textlimit = 0 ; zero to pass through - ; Valid range 0 - 2147483647. Default = 4096. - mssql.textsize = 0 ; zero to pass through + ; Valid range 0 - 2147483647. Default = 4096. + mssql.textlimit = 0 ; zero to pass through + + ; Valid range 0 - 2147483647. Default = 4096. + mssql.textsize = 0 ; zero to pass through */ function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') { $sql = "UPDATE $table SET $column=0x".bin2hex($val)." WHERE $where"; return $this->Execute($sql) != false; } - + // returns query ID if successful, otherwise false function _query($sql,$inputarr) { $this->_errorMsg = false; if (is_array($inputarr)) { - - # bind input params with sp_executesql: + + # bind input params with sp_executesql: # see http://www.quest-pipelines.com/newsletter-v3/0402_F.htm # works only with sql server 7 and newer if (!is_array($sql)) $sql = $this->Prepare($sql); @@ -570,11 +570,11 @@ order by constraint_name, referenced_table_name, keyno"; if ($decl) { $decl .= ', '; $params .= ', '; - } + } if (is_string($v)) { $len = strlen($v); if ($len == 0) $len = 1; - + if ($len > 4000 ) { // NVARCHAR is max 4000 chars. Let's use NTEXT $decl .= "@P$i NTEXT"; @@ -595,70 +595,70 @@ order by constraint_name, referenced_table_name, keyno"; $decl = $this->qstr($decl); if ($this->debug) ADOConnection::outp("sp_executesql N{$sql[1]},N$decl,$params"); $rez = mssql_query("sp_executesql N{$sql[1]},N$decl,$params"); - + } else if (is_array($sql)) { # PrepareSP() $rez = mssql_execute($sql[1]); - + } else { $rez = mssql_query($sql,$this->_connectionID); } return $rez; } - + // returns true or false function _close() - { + { if ($this->transCnt) $this->RollbackTrans(); $rez = @mssql_close($this->_connectionID); $this->_connectionID = false; return $rez; } - + // mssql uses a default date like Dec 30 2000 12:00AM function UnixDate($v) { return ADORecordSet_array_mssql::UnixDate($v); } - + function UnixTimeStamp($v) { return ADORecordSet_array_mssql::UnixTimeStamp($v); - } + } } - + /*-------------------------------------------------------------------------------------- Class Name: Recordset --------------------------------------------------------------------------------------*/ -class ADORecordset_mssql extends ADORecordSet { +class ADORecordset_mssql extends ADORecordSet { var $databaseType = "mssql"; var $canSeek = true; var $hasFetchAssoc; // see http://phplens.com/lens/lensforum/msgs.php?id=6083 // _mths works only in non-localised system - + function ADORecordset_mssql($id,$mode=false) { // freedts check... $this->hasFetchAssoc = function_exists('mssql_fetch_assoc'); - if ($mode === false) { + if ($mode === false) { global $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE; } $this->fetchMode = $mode; return $this->ADORecordSet($id,$mode); } - - + + function _initrs() { - GLOBAL $ADODB_COUNTRECS; + GLOBAL $ADODB_COUNTRECS; $this->_numOfRows = ($ADODB_COUNTRECS)? @mssql_num_rows($this->_queryID):-1; $this->_numOfFields = @mssql_num_fields($this->_queryID); } - + //Contributed by "Sven Axelsson" // get next resultset - requires PHP 4.0.5 or later @@ -683,16 +683,16 @@ class ADORecordset_mssql extends ADORecordSet { $this->bind[strtoupper($o->name)] = $i; } } - + return $this->fields[$this->bind[strtoupper($colname)]]; } - - /* Returns: an object containing field information. + + /* 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) + function FetchField($fieldOffset = -1) { if ($fieldOffset != -1) { return @mssql_fetch_field($this->_queryID, $fieldOffset); @@ -702,19 +702,19 @@ class ADORecordset_mssql extends ADORecordSet { } return null; } - - function _seek($row) + + function _seek($row) { return @mssql_data_seek($this->_queryID, $row); } // speedup - function MoveNext() + function MoveNext() { if ($this->EOF) return false; - + $this->_currentRow++; - + if ($this->fetchMode & ADODB_FETCH_ASSOC) { if ($this->fetchMode & ADODB_FETCH_NUM) { //ADODB_FETCH_BOTH mode @@ -736,7 +736,7 @@ class ADORecordset_mssql extends ADORecordSet { $this->fields = false; } } - + if (is_array($this->fields)) { if (ADODB_ASSOC_CASE == 0) { foreach($this->fields as $k=>$v) { @@ -753,14 +753,14 @@ class ADORecordset_mssql extends ADORecordSet { } if ($this->fields) return true; $this->EOF = true; - + return false; } - + // INSERT UPDATE DELETE returns false even if no error occurs in 4.0.4 // also the date format has been changed from YYYY-mm-dd to dd MMM YYYY in 4.0.4. Idiot! - function _fetch($ignore_fields=false) + function _fetch($ignore_fields=false) { if ($this->fetchMode & ADODB_FETCH_ASSOC) { if ($this->fetchMode & ADODB_FETCH_NUM) { @@ -781,7 +781,7 @@ class ADORecordset_mssql extends ADORecordSet { } } } - + if (!$this->fields) { } else if (ADODB_ASSOC_CASE == 0) { foreach($this->fields as $k=>$v) { @@ -797,13 +797,13 @@ class ADORecordset_mssql extends ADORecordSet { } return $this->fields; } - + /* 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() + function _close() { - $rez = mssql_free_result($this->_queryID); + $rez = mssql_free_result($this->_queryID); $this->_queryID = false; return $rez; } @@ -812,36 +812,36 @@ class ADORecordset_mssql extends ADORecordSet { { return ADORecordSet_array_mssql::UnixDate($v); } - + function UnixTimeStamp($v) { return ADORecordSet_array_mssql::UnixTimeStamp($v); } - + } class ADORecordSet_array_mssql extends ADORecordSet_array { - function ADORecordSet_array_mssql($id=-1,$mode=false) + function ADORecordSet_array_mssql($id=-1,$mode=false) { $this->ADORecordSet_array($id,$mode); } - + // mssql uses a default date like Dec 30 2000 12:00AM function UnixDate($v) { - + if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixDate($v); - + global $ADODB_mssql_mths,$ADODB_mssql_date_order; - - //Dec 30 2000 12:00AM + + //Dec 30 2000 12:00AM if ($ADODB_mssql_date_order == 'dmy') { if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4})|" ,$v, $rr)) { return parent::UnixDate($v); } if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0; - + $theday = $rr[1]; $themth = substr(strtoupper($rr[2]),0,3); } else { @@ -849,7 +849,7 @@ class ADORecordSet_array_mssql extends ADORecordSet_array { return parent::UnixDate($v); } if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0; - + $theday = $rr[2]; $themth = substr(strtoupper($rr[1]),0,3); } @@ -858,34 +858,34 @@ class ADORecordSet_array_mssql extends ADORecordSet_array { // h-m-s-MM-DD-YY return mktime(0,0,0,$themth,$theday,$rr[3]); } - + function UnixTimeStamp($v) { - + if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixTimeStamp($v); - + global $ADODB_mssql_mths,$ADODB_mssql_date_order; - + //Dec 30 2000 12:00AM if ($ADODB_mssql_date_order == 'dmy') { if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|" ,$v, $rr)) return parent::UnixTimeStamp($v); if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0; - + $theday = $rr[1]; $themth = substr(strtoupper($rr[2]),0,3); } else { if (!preg_match( "|^([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] <= TIMESTAMP_FIRST_YEAR) return 0; - + $theday = $rr[2]; $themth = substr(strtoupper($rr[1]),0,3); } - + $themth = $ADODB_mssql_mths[$themth]; if ($themth <= 0) return false; - + switch (strtoupper($rr[6])) { case 'P': if ($rr[4]<12) $rr[4] += 12; @@ -905,7 +905,7 @@ class ADORecordSet_array_mssql extends ADORecordSet_array { Code Example 1: select object_name(constid) as constraint_name, - object_name(fkeyid) as table_name, + object_name(fkeyid) as table_name, col_name(fkeyid, fkey) as column_name, object_name(rkeyid) as referenced_table_name, col_name(rkeyid, rkey) as referenced_column_name diff --git a/lib/WikiDB/adodb/drivers/adodb-mssqlnative.inc.php b/lib/WikiDB/adodb/drivers/adodb-mssqlnative.inc.php index d1c9d2273..256aabd4a 100644 --- a/lib/WikiDB/adodb/drivers/adodb-mssqlnative.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-mssqlnative.inc.php @@ -1,16 +1,16 @@ = 0x4300) { // docs say 4.2.0, but testing shows only since 4.3.0 does it work! - ini_set('mssql.datetimeconvert',0); + ini_set('mssql.datetimeconvert',0); } else { global $ADODB_mssql_mths; // array, months must be upper-case - $ADODB_mssql_date_order = 'mdy'; + $ADODB_mssql_date_order = 'mdy'; $ADODB_mssql_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); @@ -98,7 +98,7 @@ function AutoDetect_MSSQL_Date_Order($conn) } class ADODB_mssqlnative extends ADOConnection { - var $databaseType = "mssqlnative"; + var $databaseType = "mssqlnative"; var $dataProvider = "mssqlnative"; var $replaceQuote = "''"; // string to use to replace quotes var $fmtDate = "'Y-m-d'"; @@ -113,7 +113,7 @@ class ADODB_mssqlnative extends ADOConnection { var $metaColumnsSQL = # xtype==61 is datetime "select c.name,t.name,c.length, (case when c.xusertype=61 then 0 else c.xprec end), - (case when c.xusertype=61 then 0 else c.xscale end) + (case when c.xusertype=61 then 0 else c.xscale end) from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='%s'"; var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE var $hasGenID = true; @@ -129,9 +129,9 @@ class ADODB_mssqlnative extends ADOConnection { var $uniqueOrderBy = true; var $_bindInputArray = true; var $_dropSeqSQL = "drop table %s"; - - function ADODB_mssqlnative() - { + + function ADODB_mssqlnative() + { if ($this->debug) { error_log("
");
             sqlsrv_set_error_handling( SQLSRV_ERRORS_LOG_ALL );
@@ -152,25 +152,25 @@ class ADODB_mssqlnative extends ADOConnection {
 		if ($this->fetchMode === false) {
 			$savem = $ADODB_FETCH_MODE;
 			$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
-		} else 
+		} else
 			$savem = $this->SetFetchMode(ADODB_FETCH_NUM);
 		$arrServerInfo = sqlsrv_server_info($this->_connectionID);
 		$arr['description'] = $arrServerInfo['SQLServerName'].' connected to '.$arrServerInfo['CurrentDatabase'];
 		$arr['version'] = $arrServerInfo['SQLServerVersion'];//ADOConnection::_findvers($arr['description']);
 		return $arr;
 	}
-	
-	function IfNull( $field, $ifNull ) 
+
+	function IfNull( $field, $ifNull )
 	{
 		return " ISNULL($field, $ifNull) "; // if MS SQL Server
 	}
-	
+
 	function _insertid()
 	{
 	// SCOPE_IDENTITY()
-	// Returns the last IDENTITY value inserted into an IDENTITY column in 
-	// the same scope. A scope is a module -- a stored procedure, trigger, 
-	// function, or batch. Thus, two statements are in the same scope if 
+	// Returns the last IDENTITY value inserted into an IDENTITY column in
+	// the same scope. A scope is a module -- a stored procedure, trigger,
+	// function, or batch. Thus, two statements are in the same scope if
 	// they are in the same stored procedure, function, or batch.
 		return $this->GetOne($this->identitySQL);
 	}
@@ -179,7 +179,7 @@ class ADODB_mssqlnative extends ADOConnection {
 	{
 	   return sqlsrv_rows_affected($this->_queryID);
 	}
-	
+
 	function CreateSequence($seq='adodbseq',$start=1)
 	{
 		if($this->debug) error_log("
CreateSequence($seq,$start)"); @@ -217,13 +217,13 @@ class ADODB_mssqlnative extends ADOConnection { if($this->debug) error_log(" Returning: $num"); return $num; } - + // Format date column in sql string given an input format that understands Y M D function SQLDate($fmt, $col=false) - { + { if (!$col) $col = $this->sysTimeStamp; $s = ''; - + $len = strlen($fmt); for ($i=0; $i < $len; $i++) { if ($s) $s .= '+'; @@ -250,11 +250,11 @@ class ADODB_mssqlnative extends ADOConnection { case 'h': $s .= "substring(convert(char(14),$col,0),13,2)"; break; - + case 'H': $s .= "replace(str(datepart(hh,$col),2),' ','0')"; break; - + case 'i': $s .= "replace(str(datepart(mi,$col),2),' ','0')"; break; @@ -265,7 +265,7 @@ class ADODB_mssqlnative extends ADOConnection { case 'A': $s .= "substring(convert(char(19),$col,0),18,2)"; break; - + default: if ($ch == '\\') { $i++; @@ -278,19 +278,19 @@ class ADODB_mssqlnative extends ADOConnection { return $s; } - + function BeginTrans() { - if ($this->transOff) return true; + if ($this->transOff) return true; $this->transCnt += 1; if ($this->debug) error_log('
begin transaction'); sqlsrv_begin_transaction($this->_connectionID); return true; } - - function CommitTrans($ok=true) - { - if ($this->transOff) return true; + + function CommitTrans($ok=true) + { + if ($this->transOff) return true; if ($this->debug) error_log('
commit transaction'); if (!$ok) return $this->RollbackTrans(); if ($this->transCnt) $this->transCnt -= 1; @@ -299,14 +299,14 @@ class ADODB_mssqlnative extends ADOConnection { } function RollbackTrans() { - if ($this->transOff) return true; + if ($this->transOff) return true; if ($this->debug) error_log('
rollback transaction'); if ($this->transCnt) $this->transCnt -= 1; sqlsrv_rollback($this->_connectionID); return true; } - - function SetTransactionMode( $transaction_mode ) + + function SetTransactionMode( $transaction_mode ) { $this->_transmode = $transaction_mode; if (empty($transaction_mode)) { @@ -316,39 +316,39 @@ class ADODB_mssqlnative extends ADOConnection { if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode; $this->Execute("SET TRANSACTION ".$transaction_mode); } - + /* Usage: - + $this->BeginTrans(); $this->RowLock('table1,table2','table1.id=33 and table2.id=table1.id'); # lock row 33 for both tables - + # some operation on both tables table1 and table2 - + $this->CommitTrans(); - + See http://www.swynk.com/friends/achigrik/SQL70Locks.asp */ - function RowLock($tables,$where,$col='top 1 null as ignore') + function RowLock($tables,$where,$col='top 1 null as ignore') { if (!$this->transCnt) $this->BeginTrans(); return $this->GetOne("select $col from $tables with (ROWLOCK,HOLDLOCK) where $where"); } - - function SelectDB($dbName) + + function SelectDB($dbName) { $this->database = $dbName; $this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions if ($this->_connectionID) { - $rs = $this->Execute('USE '.$dbName); + $rs = $this->Execute('USE '.$dbName); if($rs) { return true; - } else return false; + } else return false; } - else return false; + else return false; } - - function ErrorMsg() + + function ErrorMsg() { $retErrors = sqlsrv_errors(SQLSRV_ERR_ALL); if($retErrors != null) { @@ -362,15 +362,15 @@ class ADODB_mssqlnative extends ADOConnection { } return $this->_errorMsg; } - - function ErrorNo() + + function ErrorNo() { if ($this->_logsql && $this->_errorCode !== false) return $this->_errorCode; $err = sqlsrv_errors(SQLSRV_ERR_ALL); if($err[0]) return $err[0]['code']; else return -1; } - + // returns true or false function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) { @@ -378,29 +378,29 @@ class ADODB_mssqlnative extends ADOConnection { $connectionInfo = array("Database"=>$argDatabasename,'UID'=>$argUsername,'PWD'=>$argPassword); if ($this->debug) error_log("
connecting... hostname: $argHostname params: ".var_export($connectionInfo,true)); //if ($this->debug) error_log("
_connectionID before: ".serialize($this->_connectionID)); - if(!($this->_connectionID = sqlsrv_connect($argHostname,$connectionInfo))) { + if(!($this->_connectionID = sqlsrv_connect($argHostname,$connectionInfo))) { if ($this->debug) error_log( "
errors: ".print_r( sqlsrv_errors(), true)); return false; } //if ($this->debug) error_log(" _connectionID after: ".serialize($this->_connectionID)); //if ($this->debug) error_log("
defined functions:
".var_export(get_defined_functions(),true)."
"); - return true; + return true; } - + // returns true or false function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { //return null;//not implemented. NOTE: Persistent connections have no effect if PHP is used as a CGI program. (FastCGI!) return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename); } - + function Prepare($sql) { $stmt = sqlsrv_prepare( $this->_connectionID, $sql); if (!$stmt) return $sql; return array($sql,$stmt); } - + // returns concatenated string // MSSQL requires integers to be cast as strings // automatically cast every datatype to VARCHAR(255) @@ -421,25 +421,25 @@ class ADODB_mssqlnative extends ADOConnection { array_walk($arr, create_function('&$v', '$v = "CAST(" . $v . " AS VARCHAR(255))";')); $s = implode('+',$arr); if (sizeof($arr) > 0) return "$s"; - + return ''; } - - /* + + /* Unfortunately, it appears that mssql cannot handle varbinary > 255 chars So all your blobs must be of type "image". - + Remember to set in php.ini the following... - - ; Valid range 0 - 2147483647. Default = 4096. - mssql.textlimit = 0 ; zero to pass through - ; Valid range 0 - 2147483647. Default = 4096. - mssql.textsize = 0 ; zero to pass through + ; Valid range 0 - 2147483647. Default = 4096. + mssql.textlimit = 0 ; zero to pass through + + ; Valid range 0 - 2147483647. Default = 4096. + mssql.textsize = 0 ; zero to pass through */ function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') { - + if (strtoupper($blobtype) == 'CLOB') { $sql = "UPDATE $table SET $column='" . $val . "' WHERE $where"; return $this->Execute($sql) != false; @@ -447,7 +447,7 @@ class ADODB_mssqlnative extends ADOConnection { $sql = "UPDATE $table SET $column=0x".bin2hex($val)." WHERE $where"; return $this->Execute($sql) != false; } - + // returns query ID if successful, otherwise false function _query($sql,$inputarr=false) { @@ -471,36 +471,36 @@ class ADODB_mssqlnative extends ADOConnection { if(!$rez) $rez = false; return $rez; } - + // returns true or false function _close() - { + { if ($this->transCnt) $this->RollbackTrans(); $rez = @sqlsrv_close($this->_connectionID); $this->_connectionID = false; return $rez; } - + // mssql uses a default date like Dec 30 2000 12:00AM function UnixDate($v) { return ADORecordSet_array_mssql::UnixDate($v); } - + function UnixTimeStamp($v) { return ADORecordSet_array_mssql::UnixTimeStamp($v); - } + } function &MetaIndexes($table,$primary=false) { $table = $this->qstr($table); - $sql = "SELECT i.name AS ind_name, C.name AS col_name, USER_NAME(O.uid) AS Owner, c.colid, k.Keyno, + $sql = "SELECT i.name AS ind_name, C.name AS col_name, USER_NAME(O.uid) AS Owner, c.colid, k.Keyno, CASE WHEN I.indid BETWEEN 1 AND 254 AND (I.status & 2048 = 2048 OR I.Status = 16402 AND O.XType = 'V') THEN 1 ELSE 0 END AS IsPK, CASE WHEN I.status & 2 = 2 THEN 1 ELSE 0 END AS IsUnique - FROM dbo.sysobjects o INNER JOIN dbo.sysindexes I ON o.id = i.id - INNER JOIN dbo.sysindexkeys K ON I.id = K.id AND I.Indid = K.Indid + FROM dbo.sysobjects o INNER JOIN dbo.sysindexes I ON o.id = i.id + INNER JOIN dbo.sysindexkeys K ON I.id = K.id AND I.Indid = K.Indid INNER JOIN dbo.syscolumns c ON K.id = C.id AND K.colid = C.Colid WHERE LEFT(i.name, 8) <> '_WA_Sys_' AND o.status >= 0 AND O.Name LIKE $table ORDER BY O.name, I.Name, K.keyno"; @@ -511,7 +511,7 @@ class ADODB_mssqlnative extends ADOConnection { if ($this->fetchMode !== FALSE) { $savem = $this->SetFetchMode(FALSE); } - + $rs = $this->Execute($sql); if (isset($savem)) { $this->SetFetchMode($savem); @@ -525,22 +525,22 @@ class ADODB_mssqlnative extends ADOConnection { $indexes = array(); while ($row = $rs->FetchRow()) { if (!$primary && $row[5]) continue; - + $indexes[$row[0]]['unique'] = $row[6]; $indexes[$row[0]]['columns'][] = $row[1]; } return $indexes; } - + function MetaForeignKeys($table, $owner=false, $upper=false) { global $ADODB_FETCH_MODE; - + $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; $table = $this->qstr(strtoupper($table)); - - $sql = + + $sql = "select object_name(constid) as constraint_name, col_name(fkeyid, fkey) as column_name, object_name(rkeyid) as referenced_table_name, @@ -548,20 +548,20 @@ class ADODB_mssqlnative extends ADOConnection { from sysforeignkeys where upper(object_name(fkeyid)) = $table order by constraint_name, referenced_table_name, keyno"; - + $constraints =& $this->GetArray($sql); - + $ADODB_FETCH_MODE = $save; - + $arr = false; foreach($constraints as $constr) { //print_r($constr); - $arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3]; + $arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3]; } if (!$arr) return false; - + $arr2 = false; - + foreach($arr as $k => $v) { foreach($v as $a => $b) { if ($upper) $a = strtoupper($a); @@ -572,8 +572,8 @@ class ADODB_mssqlnative extends ADOConnection { } //From: Fernando Moreira - function MetaDatabases() - { + function MetaDatabases() + { $this->SelectDB("master"); $rs =& $this->Execute($this->metaDatabasesSQL); $rows = $rs->GetRows(); @@ -584,38 +584,38 @@ class ADODB_mssqlnative extends ADOConnection { $this->SelectDB($this->database); if($ret) return $ret; - else + else return false; - } + } // "Stein-Aksel Basma" // tested with MSSQL 2000 function &MetaPrimaryKeys($table) { global $ADODB_FETCH_MODE; - + $schema = ''; $this->_findschema($table,$schema); if (!$schema) $schema = $this->database; - if ($schema) $schema = "and k.table_catalog like '$schema%'"; + if ($schema) $schema = "and k.table_catalog like '$schema%'"; $sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k, - information_schema.table_constraints tc + information_schema.table_constraints tc where tc.constraint_name = k.constraint_name and tc.constraint_type = 'PRIMARY KEY' and k.table_name = '$table' $schema order by ordinal_position "; - + $savem = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; $a = $this->GetCol($sql); $ADODB_FETCH_MODE = $savem; - + if ($a && sizeof($a)>0) return $a; $false = false; - return $false; + return $false; } - - function &MetaTables($ttype=false,$showSchema=false,$mask=false) + + function &MetaTables($ttype=false,$showSchema=false,$mask=false) { if ($mask) { $save = $this->metaTablesSQL; @@ -630,21 +630,21 @@ class ADODB_mssqlnative extends ADOConnection { return $ret; } } - + /*-------------------------------------------------------------------------------------- Class Name: Recordset --------------------------------------------------------------------------------------*/ -class ADORecordset_mssqlnative extends ADORecordSet { +class ADORecordset_mssqlnative extends ADORecordSet { var $databaseType = "mssqlnative"; var $canSeek = false; var $fieldOffset = 0; // _mths works only in non-localised system - + function ADORecordset_mssqlnative($id,$mode=false) { - if ($mode === false) { + if ($mode === false) { global $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE; @@ -652,11 +652,11 @@ class ADORecordset_mssqlnative extends ADORecordSet { $this->fetchMode = $mode; return $this->ADORecordSet($id,$mode); } - - + + function _initrs() { - global $ADODB_COUNTRECS; + global $ADODB_COUNTRECS; if ($this->connection->debug) error_log("(before) ADODB_COUNTRECS: {$ADODB_COUNTRECS} _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}"); /*$retRowsAff = sqlsrv_rows_affected($this->_queryID);//"If you need to determine the number of rows a query will return before retrieving the actual results, appending a SELECT COUNT ... query would let you get that information, and then a call to next_result would move you to the "real" results." error_log("rowsaff: ".serialize($retRowsAff)); @@ -666,7 +666,7 @@ class ADORecordset_mssqlnative extends ADORecordSet { $this->_numOfFields = ($fieldmeta)? count($fieldmeta):-1; if ($this->connection->debug) error_log("(after) _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}"); } - + //Contributed by "Sven Axelsson" // get next resultset - requires PHP 4.0.5 or later @@ -691,16 +691,16 @@ class ADORecordset_mssqlnative extends ADORecordSet { $this->bind[strtoupper($o->name)] = $i; } } - + return $this->fields[$this->bind[strtoupper($colname)]]; } - - /* Returns: an object containing field information. + + /* 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) + function &FetchField($fieldOffset = -1) { if ($this->connection->debug) error_log("
fetchfield: $fieldOffset, fetch array:
".print_r($this->fields,true)."
backtrace: ".adodb_backtrace(false)); if ($fieldOffset != -1) $this->fieldOffset = $fieldOffset; @@ -717,33 +717,33 @@ class ADORecordset_mssqlnative extends ADORecordSet { } return $f; } - - function _seek($row) + + function _seek($row) { return false;//There is no support for cursors in the driver at this time. All data is returned via forward-only streams. } // speedup - function MoveNext() + function MoveNext() { if ($this->connection->debug) error_log("movenext()"); //if ($this->connection->debug) error_log("eof (beginning): ".$this->EOF); if ($this->EOF) return false; - + $this->_currentRow++; if ($this->connection->debug) error_log("_currentRow: ".$this->_currentRow); - + if ($this->_fetch()) return true; $this->EOF = true; //if ($this->connection->debug) error_log("eof (end): ".$this->EOF); - + return false; } - + // INSERT UPDATE DELETE returns false even if no error occurs in 4.0.4 // also the date format has been changed from YYYY-mm-dd to dd MMM YYYY in 4.0.4. Idiot! - function _fetch($ignore_fields=false) + function _fetch($ignore_fields=false) { if ($this->connection->debug) error_log("_fetch()"); if ($this->fetchMode & ADODB_FETCH_ASSOC) { @@ -754,7 +754,7 @@ class ADORecordset_mssqlnative extends ADORecordSet { if ($this->connection->debug) error_log("fetch mode: assoc"); $this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_ASSOC); } - + if (ADODB_ASSOC_CASE == 0) { foreach($this->fields as $k=>$v) { $this->fields[strtolower($k)] = $v; @@ -768,7 +768,7 @@ class ADORecordset_mssqlnative extends ADORecordSet { if ($this->connection->debug) error_log("fetch mode: num"); $this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_NUMERIC); } - if(is_array($this->fields) && array_key_exists(1,$this->fields) && !array_key_exists(0,$this->fields)) {//fix fetch numeric keys since they're not 0 based + if(is_array($this->fields) && array_key_exists(1,$this->fields) && !array_key_exists(0,$this->fields)) {//fix fetch numeric keys since they're not 0 based $arrFixed = array(); foreach($this->fields as $key=>$value) { if(is_numeric($key)) { @@ -791,12 +791,12 @@ class ADORecordset_mssqlnative extends ADORecordSet { if ($this->connection->debug) error_log("
after _fetch, fields:
".print_r($this->fields,true)." backtrace: ".adodb_backtrace(false));
 		return $this->fields;
 	}
-	
+
     /*	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() 
+	function _close()
 	{
-		$rez = sqlsrv_free_stmt($this->_queryID);	
+		$rez = sqlsrv_free_stmt($this->_queryID);
 		$this->_queryID = false;
 		return $rez;
 	}
@@ -806,7 +806,7 @@ class ADORecordset_mssqlnative extends ADORecordSet {
 	{
 		return ADORecordSet_array_mssqlnative::UnixDate($v);
 	}
-	
+
 	 function UnixTimeStamp($v)
 	{
 		return ADORecordSet_array_mssqlnative::UnixTimeStamp($v);
@@ -815,26 +815,26 @@ class ADORecordset_mssqlnative extends ADORecordSet {
 
 
 class ADORecordSet_array_mssqlnative extends ADORecordSet_array {
-	function ADORecordSet_array_mssqlnative($id=-1,$mode=false) 
+	function ADORecordSet_array_mssqlnative($id=-1,$mode=false)
 	{
 		$this->ADORecordSet_array($id,$mode);
 	}
-	
+
 		// mssql uses a default date like Dec 30 2000 12:00AM
 	 function UnixDate($v)
 	{
-	
+
 		if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixDate($v);
-		
+
     	global $ADODB_mssql_mths,$ADODB_mssql_date_order;
-	
-		//Dec 30 2000 12:00AM 
+
+		//Dec 30 2000 12:00AM
 		if ($ADODB_mssql_date_order == 'dmy') {
 			if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4})|" ,$v, $rr)) {
 				return parent::UnixDate($v);
 			}
 			if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
-			
+
 			$theday = $rr[1];
 			$themth =  substr(strtoupper($rr[2]),0,3);
 		} else {
@@ -842,7 +842,7 @@ class ADORecordSet_array_mssqlnative extends ADORecordSet_array {
 				return parent::UnixDate($v);
 			}
 			if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
-			
+
 			$theday = $rr[2];
 			$themth = substr(strtoupper($rr[1]),0,3);
 		}
@@ -851,34 +851,34 @@ class ADORecordSet_array_mssqlnative extends ADORecordSet_array {
 		// h-m-s-MM-DD-YY
 		return  mktime(0,0,0,$themth,$theday,$rr[3]);
 	}
-	
+
 	 function UnixTimeStamp($v)
 	{
-	
+
 		if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixTimeStamp($v);
-		
+
 	    global $ADODB_mssql_mths,$ADODB_mssql_date_order;
-	
+
 		//Dec 30 2000 12:00AM
 		 if ($ADODB_mssql_date_order == 'dmy') {
 			 if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
 			,$v, $rr)) return parent::UnixTimeStamp($v);
 			if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
-		
+
 			$theday = $rr[1];
 			$themth =  substr(strtoupper($rr[2]),0,3);
 		} else {
 			if (!preg_match( "|^([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] <= TIMESTAMP_FIRST_YEAR) return 0;
-		
+
 			$theday = $rr[2];
 			$themth = substr(strtoupper($rr[1]),0,3);
 		}
-		
+
 		$themth = $ADODB_mssql_mths[$themth];
 		if ($themth <= 0) return false;
-		
+
 		switch (strtoupper($rr[6])) {
 		case 'P':
 			if ($rr[4]<12) $rr[4] += 12;
@@ -898,7 +898,7 @@ class ADORecordSet_array_mssqlnative extends ADORecordSet_array {
 Code Example 1:
 
 select 	object_name(constid) as constraint_name,
-       	object_name(fkeyid) as table_name, 
+       	object_name(fkeyid) as table_name,
         col_name(fkeyid, fkey) as column_name,
 	object_name(rkeyid) as referenced_table_name,
    	col_name(rkeyid, rkey) as referenced_column_name
diff --git a/lib/WikiDB/adodb/drivers/adodb-mssqlpo.inc.php b/lib/WikiDB/adodb/drivers/adodb-mssqlpo.inc.php
index c64119f14..cf2e4ea9f 100644
--- a/lib/WikiDB/adodb/drivers/adodb-mssqlpo.inc.php
+++ b/lib/WikiDB/adodb/drivers/adodb-mssqlpo.inc.php
@@ -18,13 +18,13 @@
 	The big difference between mssqlpo and it's parent mssql is that mssqlpo supports
 	the more standard || string concatenation operator.
 */
-	
+
 include_once(ADODB_DIR.'/drivers/adodb-mssql.inc.php');
 
 class ADODB_mssqlpo extends ADODB_mssql {
 	var $databaseType = "mssqlpo";
-	var $concat_operator = '||'; 
-	
+	var $concat_operator = '||';
+
 	function ADODB_mssqlpo()
 	{
 		ADODB_mssql::ADODB_mssql();
@@ -41,7 +41,7 @@ class ADODB_mssqlpo extends ADODB_mssql {
 		if (!$stmt)  return $sql;
 		return array($sql,$stmt);
 	}
-	
+
 	function _query($sql,$inputarr)
 	{
 		if (is_string($sql)) $sql = str_replace('||','+',$sql);
diff --git a/lib/WikiDB/adodb/drivers/adodb-mysql.inc.php b/lib/WikiDB/adodb/drivers/adodb-mysql.inc.php
index 138996b7e..e325c3848 100644
--- a/lib/WikiDB/adodb/drivers/adodb-mysql.inc.php
+++ b/lib/WikiDB/adodb/drivers/adodb-mysql.inc.php
@@ -38,7 +38,7 @@ class ADODB_mysql extends ADOConnection {
 	var $nameQuote = '`';		/// string to use to quote identifiers and names
 
 	function ADODB_mysql()
-	{	
+	{
 	}
 
 	function ServerInfo()
@@ -73,50 +73,50 @@ class ADODB_mysql extends ADOConnection {
 	{
         // save old fetch mode
         global $ADODB_FETCH_MODE;
-      
+
         $save = $ADODB_FETCH_MODE;
         $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
         if ($this->fetchMode !== FALSE) {
                $savem = $this->SetFetchMode(FALSE);
         }
-      
+
         // get index details
         $rs = $this->Execute(sprintf('SHOW INDEX FROM %s',$table));
-      
+
         // restore fetchmode
         if (isset($savem)) {
                 $this->SetFetchMode($savem);
         }
         $ADODB_FETCH_MODE = $save;
-      
+
         if (!is_object($rs)) {
                 return FALSE;
         }
-      
+
         $indexes = array ();
-      
+
         // parse index data into array
         while ($row = $rs->FetchRow()) {
                 if ($primary == FALSE AND $row[2] == 'PRIMARY') {
                         continue;
                 }
-              
+
                 if (!isset($indexes[$row[2]])) {
                         $indexes[$row[2]] = array(
                                 'unique' => ($row[1] == 0),
                                 'columns' => array()
                         );
                 }
-              
+
                 $indexes[$row[2]]['columns'][$row[3] - 1] = $row[4];
         }
-      
+
         // sort columns by order in the index
         foreach ( array_keys ($indexes) as $index )
         {
                 ksort ($indexes[$index]['columns']);
         }
-      
+
         return $indexes;
 	}
 
@@ -238,7 +238,7 @@ class ADODB_mysql extends ADOConnection {
 			case 'Q':
 			case 'q':
 				$s .= "'),Quarter($col)";
-		
+
 				if ($len > $i+1) $s .= ",DATE_FORMAT($col,'";
 				else $s .= ",('";
 				$concat = true;
@@ -246,7 +246,7 @@ class ADODB_mysql extends ADOConnection {
 			case 'M':
 				$s .= '%b';
 				break;
-		
+
 			case 'm':
 				$s .= '%m';
 				break;
@@ -254,30 +254,30 @@ class ADODB_mysql extends ADOConnection {
 			case 'd':
 				$s .= '%d';
 				break;
-	
+
 			case 'H':
 				$s .= '%H';
 				break;
-		
+
 			case 'h':
 				$s .= '%I';
 				break;
-		
+
 			case 'i':
 				$s .= '%i';
 				break;
-		
+
 			case 's':
 				$s .= '%s';
 				break;
-		
+
 			case 'a':
 			case 'A':
 				$s .= '%p';
 				break;
-		
+
 			default:
-		
+
 				if ($ch == '\\') {
 					$i++;
 					$ch = substr($fmt,$i,1);
@@ -356,21 +356,21 @@ class ADODB_mysql extends ADOConnection {
 			$save = $ADODB_FETCH_MODE;
 			$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
 			if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
-	
+
 			$rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
-	
+
 			if (isset($savem)) $this->SetFetchMode($savem);
 			$ADODB_FETCH_MODE = $save;
-	
+
 			if ($rs === false) return false;
-	
+
 			$retarr = array();
 			while (!$rs->EOF){
 				$fld = new ADOFieldObject();
 				$fld->name = $rs->fields[0];
 				$type = $rs->fields[1];
-		
-		
+
+
 				// split type into type(length):
 				$fld->scale = null;
 				if (strpos($type,',') && preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
@@ -397,7 +397,7 @@ class ADODB_mysql extends ADOConnection {
 				$fld->primary_key = ($rs->fields[3] == 'PRI');
 				$fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
 				$fld->binary = (strpos($fld->type,'blob') !== false);
-		
+
 				if (!$fld->binary) {
 					$d = $rs->fields[4];
 					if ($d != "" && $d != "NULL") {
@@ -545,7 +545,7 @@ class ADORecordSet_mysql extends ADORecordSet{
 			$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;
 	}
 
@@ -585,7 +585,7 @@ class ADORecordSet_mysql extends ADORecordSet{
 	//global $ADODB_EXTENSION;if ($ADODB_EXTENSION) return adodb_movenext($this);
 
 		if ($this->EOF) return false;
-		
+
 		$this->_currentRow++;
 		$this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode);
 		if (is_array($this->fields)) return true;
@@ -631,12 +631,12 @@ class ADORecordSet_mysql extends ADORecordSet{
 		case 'ENUM':
 		case 'SET':
 			if ($len <= $this->blobSize) return 'C';
-	
+
 		case 'TEXT':
 		case 'LONGTEXT':
 		case 'MEDIUMTEXT':
 			return 'X';
-	
+
 		// php_mysql extension always returns 'blob' even if 'text'
 		// so we have to check whether binary...
 		case 'IMAGE':
@@ -644,7 +644,7 @@ class ADORecordSet_mysql extends ADORecordSet{
 		case 'BLOB':
 		case 'MEDIUMBLOB':
 			return !empty($fieldobj->binary) ? 'B' : 'X';
-	
+
 		case 'YEAR':
 		case 'DATE': return 'D';
 
@@ -658,7 +658,7 @@ class ADORecordSet_mysql extends ADORecordSet{
 		case 'TINYINT':
 		case 'MEDIUMINT':
 		case 'SMALLINT':
-	
+
 			if (!empty($fieldobj->primary_key)) return 'R';
 			else return 'I';
 
@@ -675,5 +675,5 @@ class ADORecordSet_mysql extends ADORecordSet{
 // c-basic-offset: 4
 // c-hanging-comment-ender-p: nil
 // indent-tabs-mode: nil
-// End: 
+// End:
 ?>
diff --git a/lib/WikiDB/adodb/drivers/adodb-mysqli.inc.php b/lib/WikiDB/adodb/drivers/adodb-mysqli.inc.php
index 19ef81072..ca6f2514c 100644
--- a/lib/WikiDB/adodb/drivers/adodb-mysqli.inc.php
+++ b/lib/WikiDB/adodb/drivers/adodb-mysqli.inc.php
@@ -1,26 +1,26 @@
 GetOne("select version()");
 		$arr['version'] = ADOConnection::_findvers($arr['description']);
 		return $arr;
 	}
-	
-	
+
+
 	function BeginTrans()
-	{	  
+	{
 		if ($this->transOff) return true;
 		$this->transCnt += 1;
 		$this->Execute('SET AUTOCOMMIT=0');
 		$this->Execute('BEGIN');
 		return true;
 	}
-	
-	function CommitTrans($ok=true) 
+
+	function CommitTrans($ok=true)
 	{
-		if ($this->transOff) return true; 
+		if ($this->transOff) return true;
 		if (!$ok) return $this->RollbackTrans();
-		
+
 		if ($this->transCnt) $this->transCnt -= 1;
 		$this->Execute('COMMIT');
 		$this->Execute('SET AUTOCOMMIT=1');
 		return true;
 	}
-	
+
 	function RollbackTrans()
 	{
 		if ($this->transOff) return true;
@@ -88,14 +88,14 @@ class ADODB_mysqli extends ADOConnection {
 		$this->Execute('SET AUTOCOMMIT=1');
 		return true;
 	}
-	
+
 	// 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
-	// parameter may look funny, but the idea is if you are quoting a 
-	// string extracted from a POST/GET variable, then 
-	// pass get_magic_quotes_gpc() as the second parameter. This will 
-	// ensure that the variable is not quoted twice, once by qstr and once 
+	// parameter may look funny, but the idea is if you are quoting a
+	// string extracted from a POST/GET variable, then
+	// pass get_magic_quotes_gpc() as the second parameter. This will
+	// ensure that the variable is not quoted twice, once by qstr and once
 	// by the magic_quotes_gpc.
 	//
 	//Eg. $s = $db->qstr(HTTP_GET_VARS['name'],get_magic_quotes_gpc());
@@ -110,18 +110,18 @@ class ADODB_mysqli extends ADOConnection {
 	      {
 		trigger_error("phpver < 5 not implemented", E_USER_ERROR);
 	      }
-	    
+
 	    if ($this->replaceQuote[0] == '\\')
 	      {
 		$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
 	      }
-	    return  "'".str_replace("'",$this->replaceQuote,$s)."'"; 
+	    return  "'".str_replace("'",$this->replaceQuote,$s)."'";
 	  }
 	  // undo magic quotes for "
 	  $s = str_replace('\\"','"',$s);
 	  return "'$s'";
 	}
-	
+
 	function _insertid()
 	{
 //	  $this->_connectionID = $this->mysqli_resolve_link($this->_connectionID);
@@ -131,7 +131,7 @@ class ADODB_mysqli extends ADOConnection {
 	  }
 	  return $result;
 	}
-	
+
 	// Only works for INSERT, UPDATE and DELETE query's
 	function _affectedrows()
 	{
@@ -142,29 +142,29 @@ class ADODB_mysqli extends ADOConnection {
 	  }
 	  return $result;
 	}
-  
+
  	// See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
 	// Reference on Last_Insert_ID on the recommended way to simulate sequences
  	var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
 	var $_genSeqSQL = "create table %s (id int not null)";
 	var $_genSeq2SQL = "insert into %s values (%s)";
 	var $_dropSeqSQL = "drop table %s";
-	
+
 	function CreateSequence($seqname='adodbseq',$startID=1)
 	{
 		if (empty($this->_genSeqSQL)) return false;
 		$u = strtoupper($seqname);
-		
+
 		$ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname));
 		if (!$ok) return false;
 		return $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
 	}
-	
+
 	function GenID($seqname='adodbseq',$startID=1)
 	{
 		// post-nuke sets hasGenID to false
 		if (!$this->hasGenID) return false;
-		
+
 		$getnext = sprintf($this->_genIDSQL,$seqname);
 		$holdtransOK = $this->_transOK; // save the current status
 		$rs = @$this->Execute($getnext);
@@ -176,12 +176,12 @@ class ADODB_mysqli extends ADOConnection {
 			$rs = $this->Execute($getnext);
 		}
 		$this->genID = mysqli_insert_id($this->_connectionID);
-		
+
 		if ($rs) $rs->Close();
-		
+
 		return $this->genID;
 	}
-	
+
   	function &MetaDatabases()
 	  {
 	    $query = "SHOW DATABASES";
@@ -189,62 +189,62 @@ class ADODB_mysqli extends ADOConnection {
 		return $ret;
 	  }
 
-	  
+
 	function &MetaIndexes ($table, $primary = FALSE)
 	{
 	        // save old fetch mode
 	        global $ADODB_FETCH_MODE;
-	        
+
 	        $save = $ADODB_FETCH_MODE;
 	        $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
 	        if ($this->fetchMode !== FALSE) {
 	               $savem = $this->SetFetchMode(FALSE);
 	        }
-	        
+
 	        // get index details
 	        $rs = $this->Execute(sprintf('SHOW INDEXES FROM %s',$table));
-	        
+
 	        // restore fetchmode
 	        if (isset($savem)) {
 	                $this->SetFetchMode($savem);
 	        }
 	        $ADODB_FETCH_MODE = $save;
-	        
+
 	        if (!is_object($rs)) {
 	                return FALSE;
 	        }
-	        
+
 	        $indexes = array ();
-	        
+
 	        // parse index data into array
 	        while ($row = $rs->FetchRow()) {
 	                if ($primary == FALSE AND $row[2] == 'PRIMARY') {
 	                        continue;
 	                }
-	                
+
 	                if (!isset($indexes[$row[2]])) {
 	                        $indexes[$row[2]] = array(
 	                                'unique' => ($row[1] == 0),
 	                                'columns' => array()
 	                        );
 	                }
-	                
+
 	                $indexes[$row[2]]['columns'][$row[3] - 1] = $row[4];
 	        }
-	        
+
 	        // sort columns by order in the index
 	        foreach ( array_keys ($indexes) as $index )
 	        {
 	                ksort ($indexes[$index]['columns']);
 	        }
-	        
+
 	        return $indexes;
 	}
 
-	
+
 	// Format date column in sql string given an input format that understands Y M D
 	function SQLDate($fmt, $col=false)
-	{	
+	{
 		if (!$col) $col = $this->sysTimeStamp;
 		$s = 'DATE_FORMAT('.$col.",'";
 		$concat = false;
@@ -259,7 +259,7 @@ class ADODB_mysqli extends ADOConnection {
 			case 'Q':
 			case 'q':
 				$s .= "'),Quarter($col)";
-				
+
 				if ($len > $i+1) $s .= ",DATE_FORMAT($col,'";
 				else $s .= ",('";
 				$concat = true;
@@ -267,7 +267,7 @@ class ADODB_mysqli extends ADOConnection {
 			case 'M':
 				$s .= '%b';
 				break;
-				
+
 			case 'm':
 				$s .= '%m';
 				break;
@@ -275,30 +275,30 @@ class ADODB_mysqli extends ADOConnection {
 			case 'd':
 				$s .= '%d';
 				break;
-			
-			case 'H': 
+
+			case 'H':
 				$s .= '%H';
 				break;
-				
+
 			case 'h':
 				$s .= '%I';
 				break;
-				
+
 			case 'i':
 				$s .= '%i';
 				break;
-				
+
 			case 's':
 				$s .= '%s';
 				break;
-				
+
 			case 'a':
 			case 'A':
 				$s .= '%p';
 				break;
-				
+
 			default:
-				
+
 				if ($ch == '\\') {
 					$i++;
 					$ch = substr($fmt,$i,1);
@@ -311,43 +311,43 @@ class ADODB_mysqli extends ADOConnection {
 		if ($concat) $s = "CONCAT($s)";
 		return $s;
 	}
-	
+
 	// returns concatenated string
 	// much easier to run "mysqld --ansi" or "mysqld --sql-mode=PIPES_AS_CONCAT" and use || operator
 	function Concat()
 	{
 		$s = "";
 		$arr = func_get_args();
-		
+
 		// suggestion by andrew005@mnogo.ru
-		$s = implode(',',$arr); 
+		$s = implode(',',$arr);
 		if (strlen($s) > 0) return "CONCAT($s)";
 		else return '';
 	}
-	
+
 	// dayFraction is a day in floating point
 	function OffsetDate($dayFraction,$date=false)
-	{		
-		if (!$date) 
+	{
+		if (!$date)
 		  $date = $this->sysDate;
 		return "from_unixtime(unix_timestamp($date)+($dayFraction)*24*3600)";
 	}
-	
+
 	// returns true or false
 	// To add: parameter int $port,
 	//         parameter string $socket
-	function _connect($argHostname = NULL, 
-			  $argUsername = NULL, 
-			  $argPassword = NULL, 
+	function _connect($argHostname = NULL,
+			  $argUsername = NULL,
+			  $argPassword = NULL,
 			  $argDatabasename = NULL)
 	  {
 	    // @ means: error surpression on
 	    $this->_connectionID = @mysqli_init();
-	    
+
 	    if (is_null($this->_connectionID))
 	    {
 	      // mysqli_init only fails if insufficient memory
-	      if ($this->debug) 
+	      if ($this->debug)
 		ADOConnection::outp("mysqli_init() failed : "  . $this->ErrorMsg());
 	      return false;
 	    }
@@ -360,21 +360,21 @@ class ADODB_mysqli extends ADOConnection {
  				    $argPassword,
  				    $argDatabasename))
  	      {
- 		if ($argDatabasename) 
+ 		if ($argDatabasename)
 		  {
 		    return $this->SelectDB($argDatabasename);
 		  }
-		
+
  		return true;
  	      }
  	    else
 	      {
-		if ($this->debug) 
+		if ($this->debug)
 		  ADOConnection::outp("Could't connect : "  . $this->ErrorMsg());
 		return false;
 	      }
 	  }
-	
+
 	// returns true or false
 	// How to force a persistent connection
 	function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
@@ -387,18 +387,18 @@ class ADODB_mysqli extends ADOConnection {
 	    if ($this->_connectionID === false) return false;
 	    //	    if ($this->autoRollback) $this->RollbackTrans();
 	    if ($argDatabasename) return $this->SelectDB($argDatabasename);
-	    return true;	
+	    return true;
 	  }
-	
+
 	// When is this used? Close old connection first?
-	// In _connect(), check $this->forceNewConnect? 
+	// In _connect(), check $this->forceNewConnect?
 	function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
 	  {
 	    $this->forceNewConnect = true;
 	    $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
 	  }
-	
- 	function &MetaColumns($table) 
+
+ 	function &MetaColumns($table)
 	{
 	  if ($this->metaColumnsSQL) {
 	    global $ADODB_FETCH_MODE;
@@ -410,7 +410,7 @@ class ADODB_mysqli extends ADOConnection {
 		$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
 		$rs = $this->Execute(sprintf($this->metaColumnsSQL,
 					     $table));
-		
+
 		$ADODB_FETCH_MODE = $save;
 		if ($rs === false) break;
 		$retarr = array();
@@ -432,7 +432,7 @@ class ADODB_mysqli extends ADOConnection {
 		  $fld->primary_key = ($rs->fields[3] == 'PRI');
 		  $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
 		  $fld->binary = (strpos($fld->type,'blob') !== false);
-		  if (!$fld->binary) 
+		  if (!$fld->binary)
 		    {
 		      $d = $rs->fields[4];
 		      $d = $rs->fields['Default'];
@@ -440,13 +440,13 @@ class ADODB_mysqli extends ADOConnection {
 			{
 			  $fld->has_default = true;
 			  $fld->default_value = $d;
-			} 
-		      else 
+			}
+		      else
 			{
 			  $fld->has_default = false;
 			}
 		    }
-		  $retarr[strtoupper($fld->name)] = $fld;	
+		  $retarr[strtoupper($fld->name)] = $fld;
 		  $rs->MoveNext();
 		}
 		break;
@@ -463,7 +463,7 @@ class ADODB_mysqli extends ADOConnection {
 		  $fld = new ADOFieldObject();
 		  $fld->name = $rs->fields['Field'];
 		  $fld->type = $rs->fields['Type'];
-				
+
 		  // split type into type(length):
 		  if (preg_match("/^(.+)\((\d+)\)$/", $fld->type, $query_array))
 		    {
@@ -478,35 +478,35 @@ class ADODB_mysqli extends ADOConnection {
 		  $fld->primary_key = ($rs->fields['Key'] == 'PRI');
 		  $fld->auto_increment = (strpos($rs->fields['Extra'], 'auto_increment') !== false);
 		  $fld->binary = (strpos($fld->type,'blob') !== false);
-		  if (!$fld->binary) 
+		  if (!$fld->binary)
 		    {
 		      $d = $rs->fields['Default'];
 		      if ($d != "" && $d != "NULL")
 			{
 			  $fld->has_default = true;
 			  $fld->default_value = $d;
-			} 
-		      else 
+			}
+		      else
 			{
 			  $fld->has_default = false;
 			}
 		    }
-		  $retarr[strtoupper($fld->name)] = $fld;	
+		  $retarr[strtoupper($fld->name)] = $fld;
 		  $rs->MoveNext();
 		}
 		break;
 	      default:
 	      }
-	    
+
 	    if ($rs === false) return false;
 	    $rs->Close();
-	    return $retarr;	
+	    return $retarr;
 	  }
 	  return false;
 	}
-		
+
 	// returns true or false
-	function SelectDB($dbName) 
+	function SelectDB($dbName)
 	{
 //	    $this->_connectionID = $this->mysqli_resolve_link($this->_connectionID);
 	    $this->databaseName = $dbName;
@@ -515,52 +515,52 @@ class ADODB_mysqli extends ADOConnection {
 			if (!$result) {
 		    	ADOConnection::outp("Select of database " . $dbName . " failed. " . $this->ErrorMsg());
 			}
-			return $result;		
+			return $result;
 		}
-	    return false;	
+	    return false;
 	}
-	
+
 	// parameters use PostgreSQL convention, not MySQL
 	function &SelectLimit($sql,
 			      $nrows = -1,
 			      $offset = -1,
-			      $inputarr = false, 
+			      $inputarr = false,
 			      $arg3 = false,
 			      $secs = 0)
 	{
 		$offsetStr = ($offset >= 0) ? "$offset," : '';
-		
+
 		if ($secs)
 			$rs =& $this->CacheExecute($secs, $sql . " LIMIT $offsetStr$nrows" , $inputarr , $arg3);
 		else
 			$rs =& $this->Execute($sql . " LIMIT $offsetStr$nrows" , $inputarr , $arg3);
-			
+
 		return $rs;
 	}
-	
-	
+
+
 	function Prepare($sql)
 	{
 		return $sql;
-		
+
 		$stmt = mysqli_prepare($this->_connectionID,$sql);
 		if (!$stmt) return false;
 		return array($sql,$stmt);
 	}
-	
-	
+
+
 	// returns queryID or false
 	function _query($sql, $inputarr)
 	{
 	global $ADODB_COUNTRECS;
-	
+
 		if (is_array($sql)) {
 			$stmt = $sql[1];
 			foreach($inputarr as $k => $v) {
 				if (is_string($v)) $a[] = MYSQLI_BIND_STRING;
-				else if (is_integer($v)) $a[] = MYSQLI_BIND_INT; 
+				else if (is_integer($v)) $a[] = MYSQLI_BIND_INT;
 				else $a[] = MYSQLI_BIND_DOUBLE;
-				
+
 				$fnarr =& array_merge( array($stmt,$a) , $inputarr);
 				$ret = call_user_func_array('mysqli_bind_param',$fnarr);
 			}
@@ -571,29 +571,29 @@ class ADODB_mysqli extends ADOConnection {
 		    if ($this->debug) ADOConnection::outp("Query: " . $sql . " failed. " . $this->ErrorMsg());
 		    return false;
 		}
-		
+
 		return $mysql_res;
 	}
 
-	/*	Returns: the last error message from previous database operation	*/	
-	function ErrorMsg() 
+	/*	Returns: the last error message from previous database operation	*/
+	function ErrorMsg()
 	  {
-	    if (empty($this->_connectionID)) 
+	    if (empty($this->_connectionID))
 	      $this->_errorMsg = @mysqli_error();
-	    else 
+	    else
 	      $this->_errorMsg = @mysqli_error($this->_connectionID);
 	    return $this->_errorMsg;
 	  }
-	
-	/*	Returns: the last error number from previous database operation	*/	
-	function ErrorNo() 
+
+	/*	Returns: the last error number from previous database operation	*/
+	function ErrorNo()
 	  {
-	    if (empty($this->_connectionID))  
+	    if (empty($this->_connectionID))
 	      return @mysqli_errno();
-	    else 
+	    else
 	      return @mysqli_errno($this->_connectionID);
 	  }
-	
+
 	// returns true or false
 	function _close()
 	  {
@@ -606,53 +606,53 @@ class ADODB_mysqli extends ADOConnection {
 	*/
 	function CharMax()
 	{
-		return 255; 
+		return 255;
 	}
-	
+
 	/*
 	* Maximum size of X field
 	*/
 	function TextMax()
 	{
-	  return 4294967295; 
+	  return 4294967295;
 	}
 
 
 }
- 
+
 /*--------------------------------------------------------------------------------------
 	 Class Name: Recordset
 --------------------------------------------------------------------------------------*/
 
-class ADORecordSet_mysqli extends ADORecordSet{	
-	
+class ADORecordSet_mysqli extends ADORecordSet{
+
 	var $databaseType = "mysqli";
 	var $canSeek = true;
-	
-	function ADORecordSet_mysqli($queryID, $mode = false) 
+
+	function ADORecordSet_mysqli($queryID, $mode = false)
 	{
-	  if ($mode === false) 
-	    { 
+	  if ($mode === false)
+	    {
 	      global $ADODB_FETCH_MODE;
 	      $mode = $ADODB_FETCH_MODE;
 	    }
 	  switch ($mode)
 	    {
-	    case ADODB_FETCH_NUM: 
-	      $this->fetchMode = MYSQLI_NUM; 
+	    case ADODB_FETCH_NUM:
+	      $this->fetchMode = MYSQLI_NUM;
 	      break;
 	    case ADODB_FETCH_ASSOC:
-	      $this->fetchMode = MYSQLI_ASSOC; 
+	      $this->fetchMode = MYSQLI_ASSOC;
 	      break;
 	    case ADODB_FETCH_DEFAULT:
 	    case ADODB_FETCH_BOTH:
 	    default:
-	      $this->fetchMode = MYSQLI_ASSOC; 
+	      $this->fetchMode = MYSQLI_ASSOC;
 	      break;
 	    }
-	  $this->ADORecordSet($queryID);	
+	  $this->ADORecordSet($queryID);
 	}
-	
+
 	function _initrs()
 	{
 	    // mysqli_num_rows only return correct number, depens
@@ -666,9 +666,9 @@ class ADORecordSet_mysqli extends ADORecordSet{
 			$this->_numOfFields = 0;
 	    }
 	}
-	
-	function &FetchField($fieldOffset = -1) 
-	{	
+
+	function &FetchField($fieldOffset = -1)
+	{
 	  $fieldnr = $fieldOffset;
 	  if ($fieldOffset != -1) {
 	    $fieldOffset = mysqi_field_seek($this->_queryID, $fieldnr);
@@ -679,18 +679,18 @@ class ADORecordSet_mysqli extends ADORecordSet{
 
 	function &GetRowAssoc($upper = true)
 	{
-	  if ($this->fetchMode == MYSQLI_ASSOC && !$upper) 
+	  if ($this->fetchMode == MYSQLI_ASSOC && !$upper)
 	    return $this->fields;
 	  $row =& ADORecordSet::GetRowAssoc($upper);
 	  return $row;
 	}
-	
+
 	/* Use associative array to get fields array */
 	function Fields($colname)
-	{	
-	  if ($this->fetchMode != MYSQLI_NUM) 
+	{
+	  if ($this->fetchMode != MYSQLI_NUM)
 	    return @$this->fields[$colname];
-		
+
 	  if (!$this->bind) {
 	    $this->bind = array();
 	    for ($i = 0; $i < $this->_numOfFields; $i++) {
@@ -700,10 +700,10 @@ class ADORecordSet_mysqli extends ADORecordSet{
 	  }
 	  return $this->fields[$this->bind[strtoupper($colname)]];
 	}
-	
+
 	function _seek($row)
 	{
-	  if ($this->_numOfRows == 0) 
+	  if ($this->_numOfRows == 0)
 	    return false;
 
 	  if ($row < 0)
@@ -713,13 +713,13 @@ class ADORecordSet_mysqli extends ADORecordSet{
 	  $this->EOF = false;
 	  return true;
 	}
-		
+
 	// 10% speedup to move MoveNext to child class
 	// This is the only implementation that works now (23-10-2003).
 	// Other functions return no or the wrong results.
-	function MoveNext() 
+	function MoveNext()
 	{
-	  if ($this->EOF) 
+	  if ($this->EOF)
 	    return false;
 	  $this->_currentRow++;
 	  switch($this->fetchMode)
@@ -733,12 +733,12 @@ class ADORecordSet_mysqli extends ADORecordSet{
 	      break;
 	    default:
 	    }
-	  if (is_array($this->fields)) 
+	  if (is_array($this->fields))
 	    return true;
 	  $this->EOF = true;
 	  return false;
-	}	
-	
+	}
+
 	function _fetch()
 	{
 	  // mysqli_fetch_array($this->_queryID, MYSQLI_NUM) does not
@@ -747,64 +747,64 @@ class ADORecordSet_mysqli extends ADORecordSet{
 
 	  //	  $this->fields =  mysqli_fetch_fields($this->_queryID);
 	  //	  $this->fields =  mysqli_fetch_array($this->_queryID); //, $this->fetchMode);
-		  
+
 	  $this->fields =  mysqli_fetch_assoc($this->_queryID); // $this->fetchMode);
 	  return is_array($this->fields);
 	}
-	
-	function _close() 
+
+	function _close()
 	{
-	  mysqli_free_result($this->_queryID); 
-	  $this->_queryID = false;	
+	  mysqli_free_result($this->_queryID);
+	  $this->_queryID = false;
 	}
-	
+
 	function MetaType($t, $len = -1, $fieldobj = false)
 	{
-	  if (is_object($t)) 
+	  if (is_object($t))
 	    {
 	      $fieldobj = $t;
 	      $t = $fieldobj->type;
 	      $len = $fieldobj->max_length;
 	    }
-		
+
 	  $len = -1; // mysql max_length is not accurate
 	  switch (strtoupper($t)) {
-	  case 'STRING': 
+	  case 'STRING':
 	  case 'CHAR':
-	  case 'VARCHAR': 
-	  case 'TINYBLOB': 
-	  case 'TINYTEXT': 
-	  case 'ENUM': 
-	  case 'SET': 
+	  case 'VARCHAR':
+	  case 'TINYBLOB':
+	  case 'TINYTEXT':
+	  case 'ENUM':
+	  case 'SET':
 	    if ($len <= $this->blobSize) return 'C';
-	    
+
 	  case 'TEXT':
-	  case 'LONGTEXT': 
+	  case 'LONGTEXT':
 	  case 'MEDIUMTEXT':
 	    return 'X';
-			
+
 	    // php_mysql extension always returns 'blob' even if 'text'
 	    // so we have to check whether binary...
 	  case 'IMAGE':
-	  case 'LONGBLOB': 
+	  case 'LONGBLOB':
 	  case 'BLOB':
 	  case 'MEDIUMBLOB':
 	    return !empty($fieldobj->binary) ? 'B' : 'X';
 	  case 'YEAR':
-	  case 'DATE': 
+	  case 'DATE':
 	    return 'D';
-		
+
 	  case 'TIME':
 	  case 'DATETIME':
 	  case 'TIMESTAMP': return 'T';
-		
-	  case 'INT': 
+
+	  case 'INT':
 	  case 'INTEGER':
 	  case 'BIGINT':
 	  case 'TINYINT':
 	  case 'MEDIUMINT':
-	  case 'SMALLINT': 
-			
+	  case 'SMALLINT':
+
 	    if (!empty($fieldobj->primary_key)) return 'R';
 	    else return 'I';
 	    // Added floating-point types
@@ -815,14 +815,14 @@ class ADORecordSet_mysqli extends ADORecordSet{
 	  case 'DECIMAL':
 	  case 'DEC':
 	  case 'FIXED':
-	  default: 
+	  default:
 	    return 'N';
 	  }
 	}
-	
+
 
 }
- 
+
 }
 
 ?>
\ No newline at end of file
diff --git a/lib/WikiDB/adodb/drivers/adodb-mysqlt.inc.php b/lib/WikiDB/adodb/drivers/adodb-mysqlt.inc.php
index 6b8b39529..3f3633cd6 100644
--- a/lib/WikiDB/adodb/drivers/adodb-mysqlt.inc.php
+++ b/lib/WikiDB/adodb/drivers/adodb-mysqlt.inc.php
@@ -2,14 +2,14 @@
 
 /*
 V4.22 15 Apr 2004  (c) 2000-2004 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, 
+  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.
   Set tabs to 8.
-  
+
   MySQL code that supports transactions. For MySQL 3.23 or later.
   Code from James Poon 
-  
+
   Requires mysql client. Works on Windows and Unix.
 */
 
@@ -21,27 +21,27 @@ class ADODB_mysqlt extends ADODB_mysql {
 	var $databaseType = 'mysqlt';
 	var $ansiOuter = true; // for Version 3.23.17 or later
 	var $hasTransactions = true;
-	
+
 	function BeginTrans()
-	{	  
+	{
 		if ($this->transOff) return true;
 		$this->transCnt += 1;
 		$this->Execute('SET AUTOCOMMIT=0');
 		$this->Execute('BEGIN');
 		return true;
 	}
-	
-	function CommitTrans($ok=true) 
+
+	function CommitTrans($ok=true)
 	{
-		if ($this->transOff) return true; 
+		if ($this->transOff) return true;
 		if (!$ok) return $this->RollbackTrans();
-		
+
 		if ($this->transCnt) $this->transCnt -= 1;
 		$this->Execute('COMMIT');
 		$this->Execute('SET AUTOCOMMIT=1');
 		return true;
 	}
-	
+
 	function RollbackTrans()
 	{
 		if ($this->transOff) return true;
@@ -50,18 +50,18 @@ class ADODB_mysqlt extends ADODB_mysql {
 		$this->Execute('SET AUTOCOMMIT=1');
 		return true;
 	}
-	
+
 }
 
-class ADORecordSet_mysqlt extends ADORecordSet_mysql{	
+class ADORecordSet_mysqlt extends ADORecordSet_mysql{
 	var $databaseType = "mysqlt";
-	
+
 	function ADORecordSet_mysqlt($queryID,$mode=false) {
 		return $this->ADORecordSet_mysql($queryID,$mode);
 	}
-	
-	function MoveNext() 
-	{	
+
+	function MoveNext()
+	{
 		if ($this->EOF) return false;
 
 		$this->_currentRow++;
@@ -69,8 +69,8 @@ class ADORecordSet_mysqlt extends ADORecordSet_mysql{
 		$this->fields =  @mysql_fetch_array($this->_queryID,$this->fetchMode);
 		if ($this->fields) return true;
 		$this->EOF = true;
-		
+
 		return false;
-	}	
+	}
 }
 ?>
\ No newline at end of file
diff --git a/lib/WikiDB/adodb/drivers/adodb-netezza.inc.php b/lib/WikiDB/adodb/drivers/adodb-netezza.inc.php
index 3eaa48872..435dc513d 100644
--- a/lib/WikiDB/adodb/drivers/adodb-netezza.inc.php
+++ b/lib/WikiDB/adodb/drivers/adodb-netezza.inc.php
@@ -1,7 +1,7 @@
  0 ORDER BY attnum";
 	var $metaColumnsSQL1 = "SELECT attname, atttype FROM _v_relation_column_def WHERE name = '%s' AND attnum > 0 ORDER BY attnum";
-	// netezza doesn't have keys. it does have distributions, so maybe this is 
+	// netezza doesn't have keys. it does have distributions, so maybe this is
 	// something that can be pulled from the system tables
 	var $metaKeySQL = "";
 	var $hasAffectedRows = true;
-	var $hasLimit = true;	
+	var $hasLimit = true;
 	var $true = 't';		// string that represents TRUE for a database
 	var $false = 'f';		// string that represents FALSE for a database
 	var $fmtDate = "'Y-m-d'";	// used by DBDate() as the default date format used by the database
@@ -47,52 +47,52 @@ class ADODB_netezza extends ADODB_postgres64 {
 	var $autoRollback = true; // apparently pgsql does not autorollback properly before 4.3.4
 							// http://bugs.php.net/bug.php?id=25404
 
-							
-	function ADODB_netezza() 
+
+	function ADODB_netezza()
 	{
-	
+
 	}
-	
-	function &MetaColumns($table,$upper=true) 
+
+	function &MetaColumns($table,$upper=true)
 	{
-	
+
 	// Changed this function to support Netezza which has no concept of keys
 	// could posisbly work on other things from the system table later.
-	
+
 	global $ADODB_FETCH_MODE;
-	
+
 		$table = strtolower($table);
 
 		$save = $ADODB_FETCH_MODE;
 		$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
 		if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
-		
+
 		$rs =& $this->Execute(sprintf($this->metaColumnsSQL,$table,$table));
 		if (isset($savem)) $this->SetFetchMode($savem);
 		$ADODB_FETCH_MODE = $save;
-		
+
 		if ($rs === false) return false;
 
 		$retarr = array();
-		while (!$rs->EOF) { 	
+		while (!$rs->EOF) {
 			$fld = new ADOFieldObject();
 			$fld->name = $rs->fields[0];
-			
-			// since we're returning type and length as one string, 
+
+			// since we're returning type and length as one string,
 			// split them out here.
-			
+
 			if ($first = strstr($rs->fields[1], "(")) {
 			 $fld->max_length = trim($first, "()");
 			} else {
 			 $fld->max_length = -1;
 			}
-		
+
 			if ($first = strpos($rs->fields[1], "(")) {
 			 $fld->type = substr($rs->fields[1], 0, $first);
 			} else {
 			 $fld->type = $rs->fields[1];
 			}
-			
+
 			switch ($fld->type) {
 			 case "byteint":
 			 case "boolean":
@@ -116,20 +116,20 @@ class ADODB_netezza extends ADODB_postgres64 {
 			 $fld->max_length = 12;
 			 break;
 			}
-			
-			if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;	
+
+			if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
 			else $retarr[($upper) ? strtoupper($fld->name) : $fld->name] = $fld;
-			
+
 			$rs->MoveNext();
 		}
 		$rs->Close();
-		return $retarr;	
-		
+		return $retarr;
+
 	}
 
-		
+
 }
-	
+
 /*--------------------------------------------------------------------------------------
 	 Class Name: Recordset
 --------------------------------------------------------------------------------------*/
@@ -138,10 +138,10 @@ class ADORecordSet_netezza extends ADORecordSet_postgres64
 {
 	var $databaseType = "netezza";
 	var $canSeek = true;
-	
-	function ADORecordSet_netezza($queryID,$mode=false) 
+
+	function ADORecordSet_netezza($queryID,$mode=false)
 	{
-		if ($mode === false) { 
+		if ($mode === false) {
 			global $ADODB_FETCH_MODE;
 			$mode = $ADODB_FETCH_MODE;
 		}
@@ -155,7 +155,7 @@ class ADORecordSet_netezza extends ADORecordSet_postgres64
 		}
 		$this->ADORecordSet($queryID);
 	}
-	
+
 	// _initrs modified to disable blob handling
 	function _initrs()
 	{
diff --git a/lib/WikiDB/adodb/drivers/adodb-oci8.inc.php b/lib/WikiDB/adodb/drivers/adodb-oci8.inc.php
index 863e052d0..505b62605 100644
--- a/lib/WikiDB/adodb/drivers/adodb-oci8.inc.php
+++ b/lib/WikiDB/adodb/drivers/adodb-oci8.inc.php
@@ -3,14 +3,14 @@
 
   version V4.22 15 Apr 2004 (c) 2000-2004 John Lim. All rights reserved.
 
-  Released under both BSD license and Lesser GPL library license. 
-  Whenever there is any discrepancy between the two licenses, 
+  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.
 
   Latest version is available at http://php.weblogs.com/
-  
+
   Code contributed by George Fourlanos 
-  
+
   13 Nov 2000 jlim - removed all ora_* references.
 */
 
@@ -32,7 +32,7 @@ the 20th century (1950-1999). Setting the RR format as the default for all two-d
 year entries allows you to become year-2000 compliant. For example:
 NLS_DATE_FORMAT='RR-MM-DD'
 
-You can also modify the date format using the ALTER SESSION command. 
+You can also modify the date format using the ALTER SESSION command.
 */
 
 class ADODB_oci8 extends ADOConnection {
@@ -61,31 +61,31 @@ class ADODB_oci8 extends ADOConnection {
 	var $_hasOCIFetchStatement = false;
 	var $_getarray = false; // currently not working
 	var $leftOuter = '';  // oracle wierdness, $col = $value (+) for LEFT OUTER, $col (+)= $value for RIGHT OUTER
-	var $session_sharing_force_blob = false; // alter session on updateblob if set to true 
+	var $session_sharing_force_blob = false; // alter session on updateblob if set to true
 	var $firstrows = true; // enable first rows optimization on SelectLimit()
 	var $selectOffsetAlg1 = 100; // when to use 1st algorithm of selectlimit.
 	var $NLS_DATE_FORMAT = 'YYYY-MM-DD';  // To include time, use 'RRRR-MM-DD HH24:MI:SS'
  	var $useDBDateFormatForTextInput=false;
 	var $datetime = false; // MetaType('DATE') returns 'D' (datetime==false) or 'T' (datetime == true)
-	
+
 	// var $ansiOuter = true; // if oracle9
-    
-	function ADODB_oci8() 
+
+	function ADODB_oci8()
 	{
 		$this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200;
 	}
-	
+
 	/*  Function &MetaColumns($table) added by smondino@users.sourceforge.net*/
-	function &MetaColumns($table) 
+	function &MetaColumns($table)
 	{
 	global $ADODB_FETCH_MODE;
-	
+
 		$save = $ADODB_FETCH_MODE;
 		$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
 		if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
-		
+
 		$rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
-		
+
 		if (isset($savem)) $this->SetFetchMode($savem);
 		$ADODB_FETCH_MODE = $save;
 		if (!$rs) return false;
@@ -99,41 +99,41 @@ class ADODB_oci8 extends ADOConnection {
 			if ($rs->fields[1] == 'NUMBER' && $rs->fields[3] == 0) {
 				$fld->type ='INT';
 	     		$fld->max_length = $rs->fields[4];
-	    	}	
+	    	}
 		   	$fld->not_null = (strncmp($rs->fields[5], 'NOT',3) === 0);
 			$fld->binary = (strpos($fld->type,'BLOB') !== false);
 			$fld->default_value = $rs->fields[6];
-			
-			if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;	
+
+			if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
 			else $retarr[strtoupper($fld->name)] = $fld;
 			$rs->MoveNext();
 		}
 		$rs->Close();
 		return $retarr;
 	}
-	
+
 	function Time()
 	{
 		$rs =& $this->Execute("select TO_CHAR($this->sysTimeStamp,'YYYY-MM-DD HH24:MI:SS') from dual");
 		if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields));
-		
+
 		return false;
 	}
- 
+
 /*
 
   Multiple modes of connection are supported:
-  
+
   a. Local Database
     $conn->Connect(false,'scott','tiger');
-  
+
   b. From tnsnames.ora
-    $conn->Connect(false,'scott','tiger',$tnsname); 
-    $conn->Connect($tnsname,'scott','tiger'); 
-  
+    $conn->Connect(false,'scott','tiger',$tnsname);
+    $conn->Connect($tnsname,'scott','tiger');
+
   c. Server + service name
     $conn->Connect($serveraddress,'scott,'tiger',$service_name);
-  
+
   d. Server + SID
   	$conn->connectSID = true;
 	$conn->Connect($serveraddress,'scott,'tiger',$SID);
@@ -150,18 +150,18 @@ NATSOFT.DOMAIN =
 	  (SERVICE_NAME = natsoft.domain)
 	)
   )
-  
+
   There are 3 connection modes, 0 = non-persistent, 1 = persistent, 2 = force new connection
-	
+
 */
 	function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$mode=0)
 	{
 		if (!function_exists('OCIPLogon')) return false;
-		
-		
+
+
         $this->_errorMsg = false;
 		$this->_errorCode = false;
-		
+
 		if($argHostname) { // added by Jorma Tuomainen 
 			if (empty($argDatabasename)) $argDatabasename = $argHostname;
 			else {
@@ -172,7 +172,7 @@ NATSOFT.DOMAIN =
 			 	} else {
 					$argHostport="1521";
 	   			}
-				
+
 				if ($this->connectSID) {
 					$argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname
 					.")(PORT=$argHostport))(CONNECT_DATA=(SID=$argDatabasename)))";
@@ -181,7 +181,7 @@ NATSOFT.DOMAIN =
 					.")(PORT=$argHostport))(CONNECT_DATA=(SERVICE_NAME=$argDatabasename)))";
 			}
 		}
-				
+
  		//if ($argHostname) print "

Connect: 1st argument should be left blank for $this->databaseType

"; if ($mode==1) { $this->_connectionID = OCIPLogon($argUsername,$argPassword, $argDatabasename); @@ -195,14 +195,14 @@ NATSOFT.DOMAIN = if ($this->_initdate) { $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='".$this->NLS_DATE_FORMAT."'"); } - - // looks like: + + // looks like: // Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production With the Partitioning option JServer Release 8.1.7.0.0 - Production // $vers = OCIServerVersion($this->_connectionID); // if (strpos($vers,'8i') !== false) $this->ansiOuter = true; return true; } - + function ServerInfo() { $arr['compat'] = $this->GetOne('select value from sys.database_compatible_level'); @@ -215,36 +215,36 @@ NATSOFT.DOMAIN = { return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,1); } - - - + + + // returns true or false function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,2); } - + function _affectedrows() { if (is_resource($this->_stmt)) return @OCIRowCount($this->_stmt); return 0; } - - function IfNull( $field, $ifNull ) + + function IfNull( $field, $ifNull ) { return " NVL($field, $ifNull) "; // if Oracle } - + // format and return date string in database date format function DBDate($d) { if (empty($d) && $d !== 0) return 'null'; - + if (is_string($d)) $d = ADORecordSet::UnixDate($d); return "TO_DATE(".adodb_date($this->fmtDate,$d).",'".$this->NLS_DATE_FORMAT."')"; } - + // format and return date string in database timestamp format function DBTimeStamp($ts) { @@ -252,14 +252,14 @@ NATSOFT.DOMAIN = if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts); return 'TO_DATE('.adodb_date($this->fmtTimeStamp,$ts).",'RRRR-MM-DD, HH:MI:SS AM')"; } - - function RowLock($tables,$where) + + function RowLock($tables,$where) { if ($this->autoCommit) $this->BeginTrans(); return $this->GetOne("select 1 as ignore from $tables where $where for update"); } - - function &MetaTables($ttype=false,$showSchema=false,$mask=false) + + function &MetaTables($ttype=false,$showSchema=false,$mask=false) { if ($mask) { $save = $this->metaTablesSQL; @@ -267,34 +267,34 @@ NATSOFT.DOMAIN = $this->metaTablesSQL .= " AND table_name like $mask"; } $ret =& ADOConnection::MetaTables($ttype,$showSchema); - + if ($mask) { $this->metaTablesSQL = $save; } return $ret; } - + function BeginTrans() - { + { if ($this->transOff) return true; $this->transCnt += 1; $this->autoCommit = false; $this->_commit = OCI_DEFAULT; return true; } - - function CommitTrans($ok=true) - { + + function CommitTrans($ok=true) + { if ($this->transOff) return true; if (!$ok) return $this->RollbackTrans(); - + if ($this->transCnt) $this->transCnt -= 1; $ret = OCIcommit($this->_connectionID); $this->_commit = OCI_COMMIT_ON_SUCCESS; $this->autoCommit = true; return $ret; } - + function RollbackTrans() { if ($this->transOff) return true; @@ -304,14 +304,14 @@ NATSOFT.DOMAIN = $this->autoCommit = true; return $ret; } - - - function SelectDB($dbName) + + + function SelectDB($dbName) { return false; } - function ErrorMsg() + function ErrorMsg() { if ($this->_errorMsg !== false) return $this->_errorMsg; @@ -326,29 +326,29 @@ NATSOFT.DOMAIN = return $this->_errorMsg; } - function ErrorNo() + function ErrorNo() { if ($this->_errorCode !== false) return $this->_errorCode; - + if (is_resource($this->_stmt)) $arr = @OCIError($this->_stmt); if (empty($arr)) { $arr = @OCIError($this->_connectionID); if ($arr == false) $arr = @OCIError(); if ($arr == false) return ''; } - + $this->_errorMsg = $arr['message']; $this->_errorCode = $arr['code']; - + return $arr['code']; } - + // Format date column in sql string given an input format that understands Y M D function SQLDate($fmt, $col=false) - { + { if (!$col) $col = $this->sysTimeStamp; $s = 'TO_CHAR('.$col.",'"; - + $len = strlen($fmt); for ($i=0; $i < $len; $i++) { $ch = $fmt[$i]; @@ -361,11 +361,11 @@ NATSOFT.DOMAIN = case 'q': $s .= 'Q'; break; - + case 'M': $s .= 'Mon'; break; - + case 'm': $s .= 'MM'; break; @@ -373,28 +373,28 @@ NATSOFT.DOMAIN = case 'd': $s .= 'DD'; break; - + case 'H': $s.= 'HH24'; break; - + case 'h': $s .= 'HH'; break; - + case 'i': $s .= 'MI'; break; - + case 's': $s .= 'SS'; break; - + case 'a': case 'A': $s .= 'AM'; break; - + default: // handle escape characters... if ($ch == '\\') { @@ -403,25 +403,25 @@ NATSOFT.DOMAIN = } if (strpos('-/.:;, ',$ch) !== false) $s .= $ch; else $s .= '"'.$ch.'"'; - + } } return $s. "')"; } - - + + /* This algorithm makes use of - + a. FIRST_ROWS hint - The FIRST_ROWS hint explicitly chooses the approach to optimize response time, - that is, minimum resource usage to return the first row. Results will be returned - as soon as they are identified. + The FIRST_ROWS hint explicitly chooses the approach to optimize response time, + that is, minimum resource usage to return the first row. Results will be returned + as soon as they are identified. b. Uses rownum tricks to obtain only the required rows from a given offset. - As this uses complicated sql statements, we only use this if the $offset >= 100. + As this uses complicated sql statements, we only use this if the $offset >= 100. This idea by Tomas V V Cox. - + This implementation does not appear to work with oracle 8.0.5 or earlier. Comment out this function then, and the slower SelectLimit() in the base class will be used. */ @@ -434,16 +434,16 @@ NATSOFT.DOMAIN = else $sql = preg_replace('/^[ \t\n]*select/i','SELECT /*+FIRST_ROWS*/',$sql); } - + if ($offset < $this->selectOffsetAlg1) { - if ($nrows > 0) { + if ($nrows > 0) { if ($offset > 0) $nrows += $offset; //$inputarr['adodb_rownum'] = $nrows; if ($this->databaseType == 'oci8po') { $sql = "select * from ($sql) where rownum <= ?"; } else { $sql = "select * from ($sql) where rownum <= :adodb_offset"; - } + } $inputarr['adodb_offset'] = $nrows; $nrows = -1; } @@ -451,16 +451,16 @@ NATSOFT.DOMAIN = $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); return $rs; - + } else { // Algorithm by Tomas V V Cox, from PEAR DB oci8.php - + // Let Oracle return the name of the columns $q_fields = "SELECT * FROM ($sql) WHERE NULL = NULL"; if (!$stmt = OCIParse($this->_connectionID, $q_fields)) { return false; } - + if (is_array($inputarr)) { foreach($inputarr as $k => $v) { if (is_array($v)) { @@ -479,23 +479,23 @@ NATSOFT.DOMAIN = } } } - + if (!OCIExecute($stmt, OCI_DEFAULT)) { - OCIFreeStatement($stmt); + OCIFreeStatement($stmt); return false; } - + $ncols = OCINumCols($stmt); for ( $i = 1; $i <= $ncols; $i++ ) { $cols[] = '"'.OCIColumnName($stmt, $i).'"'; } $result = false; - - OCIFreeStatement($stmt); + + OCIFreeStatement($stmt); $fields = implode(',', $cols); $nrows += $offset; $offset += 1; // in Oracle rownum starts at 1 - + if ($this->databaseType == 'oci8po') { $sql = "SELECT $fields FROM". "(SELECT rownum as adodb_rownum, $fields FROM". @@ -506,17 +506,17 @@ NATSOFT.DOMAIN = "(SELECT rownum as adodb_rownum, $fields FROM". " ($sql) WHERE rownum <= :adodb_nrows". ") WHERE adodb_rownum >= :adodb_offset"; - } + } $inputarr['adodb_nrows'] = $nrows; $inputarr['adodb_offset'] = $offset; - + if ($secs2cache>0) $rs =& $this->CacheExecute($secs2cache, $sql,$inputarr); else $rs =& $this->Execute($sql,$inputarr); return $rs; } - + } - + /** * Usage: * Store BLOBs and CLOBs @@ -525,7 +525,7 @@ NATSOFT.DOMAIN = * * $conn->Execute('insert into TABLE (id,ablob) values(12,empty_blob())'); * $conn->UpdateBlob('TABLE', 'ablob', $varHoldingBlob, 'ID=12', 'BLOB'); - * + * * $blobtype supports 'BLOB' and 'CLOB', but you need to change to 'empty_clob()'. * * to get length of LOB: @@ -539,20 +539,20 @@ NATSOFT.DOMAIN = function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') { - + //if (strlen($val) < 4000) return $this->Execute("UPDATE $table SET $column=:blob WHERE $where",array('blob'=>$val)) != false; - + switch(strtoupper($blobtype)) { default: ADOConnection::outp("UpdateBlob: Unknown blobtype=$blobtype"); return false; case 'BLOB': $type = OCI_B_BLOB; break; case 'CLOB': $type = OCI_B_CLOB; break; } - - if ($this->databaseType == 'oci8po') + + if ($this->databaseType == 'oci8po') $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO ?"; - else + else $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO :blob"; - + $desc = OCINewDescriptor($this->_connectionID, OCI_D_LOB); $arr['blob'] = array($desc,-1,$type); if ($this->session_sharing_force_blob) $this->Execute('ALTER SESSION SET CURSOR_SHARING=EXACT'); @@ -563,11 +563,11 @@ NATSOFT.DOMAIN = $desc->free(); if ($commit) $this->CommitTrans(); if ($this->session_sharing_force_blob) $this->Execute('ALTER SESSION SET CURSOR_SHARING=FORCE'); - + if ($rez) $rs->Close(); return $rez; } - + /** * Usage: store file pointed to by $var in a blob */ @@ -578,67 +578,67 @@ NATSOFT.DOMAIN = case 'BLOB': $type = OCI_B_BLOB; break; case 'CLOB': $type = OCI_B_CLOB; break; } - - if ($this->databaseType == 'oci8po') + + if ($this->databaseType == 'oci8po') $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO ?"; - else + else $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO :blob"; - + $desc = OCINewDescriptor($this->_connectionID, OCI_D_LOB); $arr['blob'] = array($desc,-1,$type); - + $this->BeginTrans(); $rs = ADODB_oci8::Execute($sql,$arr); if ($rez = !empty($rs)) $desc->savefile($val); $desc->free(); $this->CommitTrans(); - + if ($rez) $rs->Close(); return $rez; } - + /* Example of usage: - + $stmt = $this->Prepare('insert into emp (empno, ename) values (:empno, :ename)'); */ function Prepare($sql,$cursor=false) { static $BINDNUM = 0; - + $stmt = OCIParse($this->_connectionID,$sql); if (!$stmt) return false; $BINDNUM += 1; - + if (@OCIStatementType($stmt) == 'BEGIN') { return array($sql,$stmt,0,$BINDNUM, ($cursor) ? OCINewCursor($this->_connectionID) : false); - } - + } + return array($sql,$stmt,0,$BINDNUM); } - + /* - Call an oracle stored procedure and return a cursor variable. - Convert the cursor variable into a recordset. + Call an oracle stored procedure and return a cursor variable. + Convert the cursor variable into a recordset. Concept by Robert Tuttle robert@ud.com - + Example: Note: we return a cursor variable in :RS2 $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:RS2); END;",'RS2'); - + $rs = $db->ExecuteCursor( - "BEGIN :RS2 = adodb.getdata(:VAR1); END;", + "BEGIN :RS2 = adodb.getdata(:VAR1); END;", 'RS2', array('VAR1' => 'Mr Bean')); - + */ function &ExecuteCursor($sql,$cursorName='rs',$params=false) { $stmt = ADODB_oci8::Prepare($sql,true); # true to allocate OCINewCursor - + if (is_array($stmt) && sizeof($stmt) >= 5) { $this->Parameter($stmt, $ignoreCur, $cursorName, false, -1, OCI_B_CURSOR); if ($params) { @@ -649,45 +649,45 @@ NATSOFT.DOMAIN = } return $this->Execute($stmt); } - + /* - Bind a variable -- very, very fast for executing repeated statements in oracle. + Bind a variable -- very, very fast for executing repeated statements in oracle. Better than using - for ($i = 0; $i < $max; $i++) { + for ($i = 0; $i < $max; $i++) { $p1 = ?; $p2 = ?; $p3 = ?; - $this->Execute("insert into table (col0, col1, col2) values (:0, :1, :2)", + $this->Execute("insert into table (col0, col1, col2) values (:0, :1, :2)", array($p1,$p2,$p3)); } - + Usage: $stmt = $DB->Prepare("insert into table (col0, col1, col2) values (:0, :1, :2)"); $DB->Bind($stmt, $p1); $DB->Bind($stmt, $p2); $DB->Bind($stmt, $p3); - for ($i = 0; $i < $max; $i++) { + for ($i = 0; $i < $max; $i++) { $p1 = ?; $p2 = ?; $p3 = ?; $DB->Execute($stmt); } - - Some timings: + + Some timings: ** Test table has 3 cols, and 1 index. Test to insert 1000 records Time 0.6081s (1644.60 inserts/sec) with direct OCIParse/OCIExecute Time 0.6341s (1577.16 inserts/sec) with ADOdb Prepare/Bind/Execute Time 1.5533s ( 643.77 inserts/sec) with pure SQL using Execute - + Now if PHP only had batch/bulk updating like Java or PL/SQL... - + Note that the order of parameters differs from OCIBindByName, because we default the names to :0, :1, :2 */ function Bind(&$stmt,&$var,$size=4000,$type=false,$name=false) { if (!is_array($stmt)) return false; - - if (($type == OCI_B_CURSOR) && sizeof($stmt) >= 5) { + + if (($type == OCI_B_CURSOR) && sizeof($stmt) >= 5) { return OCIBindByName($stmt[1],":".$name,$stmt[4],$size,$type); } - + if ($name == false) { if ($type !== false) $rez = OCIBindByName($stmt[1],":".$name,$var,$size,$type); else $rez = OCIBindByName($stmt[1],":".$stmt[2],$var,$size); // +1 byte for null terminator @@ -701,29 +701,29 @@ NATSOFT.DOMAIN = if ($type !== false) $rez = OCIBindByName($stmt[1],":".$name,$var,$size,$type); else $rez = OCIBindByName($stmt[1],":".$name,$var,$size); // +1 byte for null terminator } - + return $rez; } - + function Param($name) { return ':'.$name; } - - /* + + /* Usage: $stmt = $db->Prepare('select * from table where id =:myid and group=:group'); $db->Parameter($stmt,$id,'myid'); $db->Parameter($stmt,$group,'group'); $db->Execute($stmt); - + @param $stmt Statement returned by Prepare() or PrepareSP(). @param $var PHP variable to bind to @param $name Name of stored procedure variable name to bind to. @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8. @param [$maxLen] Holds an maximum length of the variable. @param [$type] The data type of $var. Legal values depend on driver. - + See OCIBindByName documentation at php.net. */ function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false) @@ -735,28 +735,28 @@ NATSOFT.DOMAIN = } return $this->Bind($stmt,$var,$maxLen,$type,$name); } - + /* returns query ID if successful, otherwise false this version supports: - + 1. $db->execute('select * from table'); - + 2. $db->prepare('insert into table (a,b,c) values (:0,:1,:2)'); $db->execute($prepared_statement, array(1,2,3)); - + 3. $db->execute('insert into table (a,b,c) values (:a,:b,:c)',array('a'=>1,'b'=>2,'c'=>3)); - + 4. $db->prepare('insert into table (a,b,c) values (:0,:1,:2)'); - $db->$bind($stmt,1); $db->bind($stmt,2); $db->bind($stmt,3); + $db->$bind($stmt,1); $db->bind($stmt,2); $db->bind($stmt,3); $db->execute($stmt); - */ + */ function _query($sql,$inputarr) { - + if (is_array($sql)) { // is prepared sql $stmt = $sql[1]; - + // we try to bind to permanent array, so that OCIBindByName is persistent // and carried out once only - note that max array element size is 4000 chars if (is_array($inputarr)) { @@ -777,12 +777,12 @@ NATSOFT.DOMAIN = } else { $stmt=OCIParse($this->_connectionID,$sql); } - + $this->_stmt = $stmt; if (!$stmt) return false; - + if (defined('ADODB_PREFETCH_ROWS')) @OCISetPrefetch($stmt,ADODB_PREFETCH_ROWS); - + if (is_array($inputarr)) { foreach($inputarr as $k => $v) { if (is_array($v)) { @@ -790,7 +790,7 @@ NATSOFT.DOMAIN = OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1]); else OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1],$v[2]); - + if ($this->debug==99) echo "name=:$k",' var='.$inputarr[$k][0],' len='.$v[1],' type='.$v[2],'
'; } else { $len = -1; @@ -803,20 +803,20 @@ NATSOFT.DOMAIN = } } } - + $this->_errorMsg = false; $this->_errorCode = false; if (OCIExecute($stmt,$this->_commit)) { - + switch (@OCIStatementType($stmt)) { case "SELECT": return $stmt; - + case "BEGIN": if (is_array($sql) && !empty($sql[4])) { $cursor = $sql[4]; if (is_resource($cursor)) { - $ok = OCIExecute($cursor); + $ok = OCIExecute($cursor); return $cursor; } return $stmt; @@ -835,7 +835,7 @@ NATSOFT.DOMAIN = } return false; } - + // returns true or false function _close() { @@ -844,11 +844,11 @@ NATSOFT.DOMAIN = $this->_stmt = false; $this->_connectionID = false; } - + function MetaPrimaryKeys($table, $owner=false,$internalKey=false) { if ($internalKey) return array('ROWID'); - + // tested with oracle 8.1.7 $table = strtoupper($table); if ($owner) { @@ -878,12 +878,12 @@ SELECT /*+ RULE */ distinct b.column_name } else return false; } - + // http://gis.mit.edu/classes/11.521/sqlnotes/referential_integrity.html function MetaForeignKeys($table, $owner=false) { global $ADODB_FETCH_MODE; - + $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; $table = $this->qstr(strtoupper($table)); @@ -892,14 +892,14 @@ SELECT /*+ RULE */ distinct b.column_name $tabp = 'user_'; } else $tabp = 'all_'; - + $owner = ' and owner='.$this->qstr(strtoupper($owner)); - - $sql = -"select constraint_name,r_owner,r_constraint_name + + $sql = +"select constraint_name,r_owner,r_constraint_name from {$tabp}constraints where constraint_type = 'R' and table_name = $table $owner"; - + $constraints =& $this->GetArray($sql); $arr = false; foreach($constraints as $constr) { @@ -908,32 +908,32 @@ SELECT /*+ RULE */ distinct b.column_name $rcons = $this->qstr($constr[2]); $cols = $this->GetArray("select column_name from {$tabp}cons_columns where constraint_name=$cons $owner order by position"); $tabcol = $this->GetArray("select table_name,column_name from {$tabp}cons_columns where owner=$rowner and constraint_name=$rcons order by position"); - - if ($cols && $tabcol) + + if ($cols && $tabcol) for ($i=0, $max=sizeof($cols); $i < $max; $i++) { $arr[$tabcol[$i][0]] = $cols[$i][0].'='.$tabcol[$i][1]; } } $ADODB_FETCH_MODE = $save; - + return $arr; } - + function CharMax() { return 4000; } - + function TextMax() { return 4000; } - + /** * Quotes a string. * An example is $db->qstr("Don't bother",magic_quotes_runtime()); - * + * * @param s the string to quote * @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc(). * This undoes the stupidity of magic quotes for GPC. @@ -941,21 +941,21 @@ SELECT /*+ RULE */ distinct b.column_name * @return quoted string to be sent back to database */ function qstr($s,$magic_quotes=false) - { + { $nofixquotes=false; - + if (is_array($s)) adodb_backtrace(); if ($this->noNullStrings && strlen($s)==0)$s = ' '; - if (!$magic_quotes) { + if (!$magic_quotes) { if ($this->replaceQuote[0] == '\\'){ $s = str_replace('\\','\\\\',$s); } return "'".str_replace("'",$this->replaceQuote,$s)."'"; } - + // undo magic quotes for " $s = str_replace('\\"','"',$s); - + if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything return "'$s'"; else {// change \' to '' for sybase/mssql @@ -963,7 +963,7 @@ SELECT /*+ RULE */ distinct b.column_name return "'".str_replace("\\'",$this->replaceQuote,$s)."'"; } } - + } /*-------------------------------------------------------------------------------------- @@ -976,10 +976,10 @@ class ADORecordset_oci8 extends ADORecordSet { var $bind=false; var $_fieldobjs; //var $_arr = false; - + function ADORecordset_oci8($queryID,$mode=false) { - if ($mode === false) { + if ($mode === false) { global $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE; } @@ -999,21 +999,21 @@ class ADORecordset_oci8 extends ADORecordSet { function Init() { if ($this->_inited) return; - + $this->_inited = true; if ($this->_queryID) { - + $this->_currentRow = 0; @$this->_initrs(); $this->EOF = !$this->_fetch(); - + /* // based on idea by Gaetano Giunta to detect unusual oracle errors // see http://phplens.com/lens/lensforum/msgs.php?id=6771 $err = OCIError($this->_queryID); if ($err && $this->connection->debug) ADOConnection::outp($err); */ - + if (!is_array($this->fields)) { $this->_numOfRows = 0; $this->fields = array(); @@ -1025,7 +1025,7 @@ class ADORecordset_oci8 extends ADORecordSet { $this->EOF = true; } } - + function _initrs() { $this->_numOfRows = -1; @@ -1057,39 +1057,39 @@ class ADORecordset_oci8 extends ADORecordSet { } return $fld; } - + /* For some reason, OCIcolumnname fails when called after _initrs() so we cache it */ function &FetchField($fieldOffset = -1) { return $this->_fieldobjs[$fieldOffset]; } - - + + // 10% speedup to move MoveNext to child class - function MoveNext() + function MoveNext() { //global $ADODB_EXTENSION;if ($ADODB_EXTENSION) return @adodb_movenext($this); - + if ($this->EOF) return false; - + $this->_currentRow++; if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) return true; $this->EOF = true; - + return false; - } - + } + /* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */ - function &GetArrayLimit($nrows,$offset=-1) + function &GetArrayLimit($nrows,$offset=-1) { if ($offset <= 0) { $arr =& $this->GetArray($nrows); return $arr; } - for ($i=1; $i < $offset; $i++) + for ($i=1; $i < $offset; $i++) if (!@OCIFetch($this->_queryID)) return array(); - + if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) return array(); $results = array(); $cnt = 0; @@ -1097,11 +1097,11 @@ class ADORecordset_oci8 extends ADORecordSet { $results[$cnt++] = $this->fields; $this->MoveNext(); } - + return $results; } - + /* Use associative array to get fields array */ function Fields($colname) { @@ -1112,10 +1112,10 @@ class ADORecordset_oci8 extends ADORecordSet { $this->bind[strtoupper($o->name)] = $i; } } - + return $this->fields[$this->bind[strtoupper($colname)]]; } - + function _seek($row) @@ -1123,7 +1123,7 @@ class ADORecordset_oci8 extends ADORecordSet { return false; } - function _fetch() + function _fetch() { return @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode); } @@ -1131,12 +1131,12 @@ class ADORecordset_oci8 extends ADORecordSet { /* 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() + function _close() { if ($this->connection->_stmt === $this->_queryID) $this->connection->_stmt = false; OCIFreeStatement($this->_queryID); $this->_queryID = false; - + } function MetaType($t,$len=-1) @@ -1156,29 +1156,29 @@ class ADORecordset_oci8 extends ADORecordSet { case 'NVARCHAR': case 'NVARCHAR2': if (isset($this) && $len <= $this->blobSize) return 'C'; - + case 'NCLOB': case 'LONG': case 'LONG VARCHAR': case 'CLOB': return 'X'; - + case 'LONG RAW': case 'LONG VARBINARY': case 'BLOB': return 'B'; - - case 'DATE': + + case 'DATE': return ($this->connection->datetime) ? 'T' : 'D'; - - + + case 'TIMESTAMP': return 'T'; - - case 'INT': + + case 'INT': case 'SMALLINT': - case 'INTEGER': + case 'INTEGER': return 'I'; - + default: return 'N'; } } diff --git a/lib/WikiDB/adodb/drivers/adodb-oci805.inc.php b/lib/WikiDB/adodb/drivers/adodb-oci805.inc.php index e4b9a8402..08ff26801 100644 --- a/lib/WikiDB/adodb/drivers/adodb-oci805.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-oci805.inc.php @@ -1,12 +1,12 @@ ADODB_oci8(); } - + function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) { // seems that oracle only supports 1 hint comment in 8i @@ -30,12 +30,12 @@ class ADODB_oci805 extends ADODB_oci8 { $sql = str_replace('/*+ ','/*+FIRST_ROWS ',$sql); else $sql = preg_replace('/^[ \t\n]*select/i','SELECT /*+FIRST_ROWS*/',$sql); - - /* - The following is only available from 8.1.5 because order by in inline views not + + /* + The following is only available from 8.1.5 because order by in inline views not available before then... http://www.jlcomp.demon.co.uk/faq/top_sql.html - if ($nrows > 0) { + if ($nrows > 0) { if ($offset > 0) $nrows += $offset; $sql = "select * from ($sql) where rownum <= $nrows"; $nrows = -1; @@ -46,7 +46,7 @@ class ADODB_oci805 extends ADODB_oci8 { } } -class ADORecordset_oci805 extends ADORecordset_oci8 { +class ADORecordset_oci805 extends ADORecordset_oci8 { var $databaseType = "oci805"; function ADORecordset_oci805($id,$mode=false) { diff --git a/lib/WikiDB/adodb/drivers/adodb-oci8po.inc.php b/lib/WikiDB/adodb/drivers/adodb-oci8po.inc.php index 05c1ca9f9..9d7e356df 100644 --- a/lib/WikiDB/adodb/drivers/adodb-oci8po.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-oci8po.inc.php @@ -1,12 +1,12 @@ Should some emulation of RecordCount() be implemented? - + */ include_once(ADODB_DIR.'/drivers/adodb-oci8.inc.php'); @@ -24,27 +24,27 @@ class ADODB_oci8po extends ADODB_oci8 { var $dataProvider = 'oci8'; var $metaColumnsSQL = "select lower(cname),coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"; //changed by smondino@users.sourceforge. net var $metaTablesSQL = "select lower(table_name),table_type from cat where table_type in ('TABLE','VIEW')"; - + function ADODB_oci8po() { $this->ADODB_oci8(); } - + function Param($name) { return '?'; } - + function Prepare($sql,$cursor=false) { $sqlarr = explode('?',$sql); $sql = $sqlarr[0]; for ($i = 1, $max = sizeof($sqlarr); $i < $max; $i++) { $sql .= ':'.($i-1) . $sqlarr[$i]; - } + } return ADODB_oci8::Prepare($sql,$cursor); } - + // emulate handling of parameters ? ?, replacing with :bind0 :bind1 function _query($sql,$inputarr) { @@ -53,7 +53,7 @@ class ADODB_oci8po extends ADODB_oci8 { if (is_array($sql)) { foreach($inputarr as $v) { $arr['bind'.$i++] = $v; - } + } } else { $sqlarr = explode('?',$sql); $sql = $sqlarr[0]; @@ -73,7 +73,7 @@ class ADODB_oci8po extends ADODB_oci8 { class ADORecordset_oci8po extends ADORecordset_oci8 { var $databaseType = 'oci8po'; - + function ADORecordset_oci8po($queryID,$mode=false) { $this->ADORecordset_oci8($queryID,$mode); @@ -82,7 +82,7 @@ class ADORecordset_oci8po extends ADORecordset_oci8 { function Fields($colname) { if ($this->fetchMode & OCI_ASSOC) return $this->fields[$colname]; - + if (!$this->bind) { $this->bind = array(); for ($i=0; $i < $this->_numOfFields; $i++) { @@ -92,7 +92,7 @@ class ADORecordset_oci8po extends ADORecordset_oci8 { } return $this->fields[$this->bind[strtoupper($colname)]]; } - + // lowercase field names... function &_FetchField($fieldOffset = -1) { @@ -110,14 +110,14 @@ class ADORecordset_oci8po extends ADORecordset_oci8 { } // 10% speedup to move MoveNext to child class - function MoveNext() + function MoveNext() { - - if (!$this->EOF) { + + if (!$this->EOF) { $this->_currentRow++; if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) { global $ADODB_ANSI_PADDING_OFF; - + if ($this->fetchMode & OCI_ASSOC) $this->_updatefields(); if (!empty($ADODB_ANSI_PADDING_OFF)) { foreach($this->fields as $k => $v) { @@ -129,15 +129,15 @@ class ADORecordset_oci8po extends ADORecordset_oci8 { $this->EOF = true; } return false; - } - + } + /* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */ - function &GetArrayLimit($nrows,$offset=-1) + function &GetArrayLimit($nrows,$offset=-1) { if ($offset <= 0) return $this->GetArray($nrows); - for ($i=1; $i < $offset; $i++) + for ($i=1; $i < $offset; $i++) if (!@OCIFetch($this->_queryID)) return array(); - + if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) return array(); if ($this->fetchMode & OCI_ASSOC) $this->_updatefields(); $results = array(); @@ -146,7 +146,7 @@ class ADORecordset_oci8po extends ADORecordset_oci8 { $results[$cnt++] = $this->fields; $this->MoveNext(); } - + return $results; } @@ -154,10 +154,10 @@ class ADORecordset_oci8po extends ADORecordset_oci8 { function _updatefields() { if (ADODB_ASSOC_CASE == 2) return; // native - + $arr = array(); $lowercase = (ADODB_ASSOC_CASE == 0); - + foreach($this->fields as $k => $v) { if (is_integer($k)) $arr[$k] = $v; else { @@ -169,13 +169,13 @@ class ADORecordset_oci8po extends ADORecordset_oci8 { } $this->fields = $arr; } - - function _fetch() + + function _fetch() { $ret = @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode); if ($ret) { global $ADODB_ANSI_PADDING_OFF; - + if ($this->fetchMode & OCI_ASSOC) $this->_updatefields(); if (!empty($ADODB_ANSI_PADDING_OFF)) { foreach($this->fields as $k => $v) { @@ -185,6 +185,6 @@ class ADORecordset_oci8po extends ADORecordset_oci8 { } return $ret; } - + } ?> \ No newline at end of file diff --git a/lib/WikiDB/adodb/drivers/adodb-odbc.inc.php b/lib/WikiDB/adodb/drivers/adodb-odbc.inc.php index 551cc7ca3..b78d532bc 100644 --- a/lib/WikiDB/adodb/drivers/adodb-odbc.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-odbc.inc.php @@ -1,23 +1,23 @@ _haserrorfunctions = ADODB_PHPVER >= 0x4050; $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200; } - + function ServerInfo() { - + if (!empty($this->host) && ADODB_PHPVER >= 0x4300) { $dsn = strtoupper($this->host); $first = true; $found = false; - + if (!function_exists('odbc_data_source')) return false; - + while(true) { - + $rez = odbc_data_source($this->_connectionID, $first ? SQL_FETCH_FIRST : SQL_FETCH_NEXT); $first = false; @@ -61,7 +61,7 @@ class ADODB_odbc extends ADOConnection { $found = true; break; } - } + } if (!$found) return ADOConnection::ServerInfo(); if (!isset($rez['version'])) $rez['version'] = ''; return $rez; @@ -70,7 +70,7 @@ class ADODB_odbc extends ADOConnection { } } - + function CreateSequence($seqname='adodbseq',$start=1) { if (empty($this->_genSeqSQL)) return false; @@ -79,22 +79,22 @@ class ADODB_odbc extends ADOConnection { $start -= 1; return $this->Execute("insert into $seqname values($start)"); } - + var $_dropSeqSQL = 'drop table %s'; function DropSequence($seqname) { if (empty($this->_dropSeqSQL)) return false; return $this->Execute(sprintf($this->_dropSeqSQL,$seqname)); } - + /* This algorithm is not very efficient, but works even if table locking is not available. - + Will return false if unable to generate an ID after $MAXLOOPS attempts. */ function GenID($seq='adodbseq',$start=1) - { + { // if you have to modify the parameter below, your database is overloaded, // or you need to implement generation of id's yourself! $MAXLOOPS = 100; @@ -102,14 +102,14 @@ class ADODB_odbc extends ADOConnection { while (--$MAXLOOPS>=0) { $num = $this->GetOne("select id from $seq"); if ($num === false) { - $this->Execute(sprintf($this->_genSeqSQL ,$seq)); + $this->Execute(sprintf($this->_genSeqSQL ,$seq)); $start -= 1; $num = '0'; $ok = $this->Execute("insert into $seq values($start)"); if (!$ok) return false; - } + } $this->Execute("update $seq set id=id+1 where id=$num"); - + if ($this->affected_rows() > 0) { $num += 1; $this->genID = $num; @@ -131,34 +131,34 @@ class ADODB_odbc extends ADOConnection { return @odbc_errormsg($this->_connectionID); } else return ADOConnection::ErrorMsg(); } - + function ErrorNo() { - + if ($this->_haserrorfunctions) { if ($this->_errorCode !== false) { // bug in 4.0.6, error number can be corrupted string (should be 6 digits) return (strlen($this->_errorCode)<=2) ? 0 : $this->_errorCode; } - if (empty($this->_connectionID)) $e = @odbc_error(); + if (empty($this->_connectionID)) $e = @odbc_error(); else $e = @odbc_error($this->_connectionID); - + // bug in 4.0.6, error number can be corrupted string (should be 6 digits) // so we check and patch if (strlen($e)<=2) return 0; return $e; } else return ADOConnection::ErrorNo(); } - - + + // returns true or false function _connect($argDSN, $argUsername, $argPassword, $argDatabasename) { global $php_errormsg; - + if (!function_exists('odbc_connect')) return false; - + if ($this->debug && $argDatabasename && $this->databaseType != 'vfp') { ADOConnection::outp("For odbc Connect(), $argDatabasename is not used. Place dsn in 1st parameter."); } @@ -167,18 +167,18 @@ class ADODB_odbc extends ADOConnection { else $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,$this->curmode); $this->_errorMsg = $php_errormsg; if (isset($this->connectStmt)) $this->Execute($this->connectStmt); - + //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; - + if (!function_exists('odbc_connect')) return false; - + $php_errormsg = ''; if ($this->debug && $argDatabasename) { ADOConnection::outp("For odbc PConnect(), $argDatabasename is not used. Place dsn in 1st parameter."); @@ -186,26 +186,26 @@ class ADODB_odbc extends ADOConnection { // print "dsn=$argDSN u=$argUsername p=$argPassword
"; flush(); if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword); else $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,$this->curmode); - + $this->_errorMsg = $php_errormsg; if ($this->_connectionID && $this->autoRollback) @odbc_rollback($this->_connectionID); if (isset($this->connectStmt)) $this->Execute($this->connectStmt); - + return $this->_connectionID != false; } function BeginTrans() - { + { if (!$this->hasTransactions) return false; - if ($this->transOff) return true; + if ($this->transOff) return true; $this->transCnt += 1; $this->_autocommit = false; return odbc_autocommit($this->_connectionID,false); } - - function CommitTrans($ok=true) - { - if ($this->transOff) return true; + + function CommitTrans($ok=true) + { + if ($this->transOff) return true; if (!$ok) return $this->RollbackTrans(); if ($this->transCnt) $this->transCnt -= 1; $this->_autocommit = true; @@ -213,35 +213,35 @@ class ADODB_odbc extends ADOConnection { odbc_autocommit($this->_connectionID,true); return $ret; } - + function RollbackTrans() { - if ($this->transOff) return true; + if ($this->transOff) return true; if ($this->transCnt) $this->transCnt -= 1; $this->_autocommit = true; $ret = odbc_rollback($this->_connectionID); odbc_autocommit($this->_connectionID,true); return $ret; } - + function MetaPrimaryKeys($table) { global $ADODB_FETCH_MODE; - + $savem = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; $qid = @odbc_primarykeys($this->_connectionID,'','',$table); - + if (!$qid) { $ADODB_FETCH_MODE = $savem; return false; } $rs = new ADORecordSet_odbc($qid); $ADODB_FETCH_MODE = $savem; - + if (!$rs) return false; $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change; - + $arr =& $rs->GetArray(); $rs->Close(); //print_r($arr); @@ -251,37 +251,37 @@ class ADODB_odbc extends ADOConnection { } return $arr2; } - - - + + + function &MetaTables($ttype=false) { global $ADODB_FETCH_MODE; - + $savem = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; $qid = odbc_tables($this->_connectionID); - + $rs = new ADORecordSet_odbc($qid); - + $ADODB_FETCH_MODE = $savem; if (!$rs) return false; - + $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change; - + $arr =& $rs->GetArray(); //print_r($arr); - + $rs->Close(); $arr2 = array(); - + if ($ttype) { $isview = strncmp($ttype,'V',1) === 0; } for ($i=0; $i < sizeof($arr); $i++) { if (!$arr[$i][2]) continue; $type = $arr[$i][3]; - if ($ttype) { + if ($ttype) { if ($isview) { if (strncmp($type,'V',1) === 0) $arr2[] = $arr[$i][2]; } else if (strncmp($type,'SYS',3) !== 0) $arr2[] = $arr[$i][2]; @@ -289,7 +289,7 @@ class ADODB_odbc extends ADOConnection { } return $arr2; } - + /* / SQL data type codes / #define SQL_UNKNOWN_TYPE 0 @@ -319,7 +319,7 @@ class ADODB_odbc extends ADOConnection { function ODBCTypes($t) { switch ((integer)$t) { - case 1: + case 1: case 12: case 0: case -95: @@ -330,11 +330,11 @@ class ADODB_odbc extends ADOConnection { return 'X'; case -4: //image return 'B'; - + case 91: case 11: return 'D'; - + case 92: case 93: case 9: return 'T'; @@ -342,36 +342,36 @@ class ADODB_odbc extends ADOConnection { case 5: case -6: return 'I'; - + case -11: // uniqidentifier return 'R'; case -7: //bit return 'L'; - + default: return 'N'; } } - + function &MetaColumns($table) { global $ADODB_FETCH_MODE; - + $table = strtoupper($table); $schema = false; $this->_findschema($table,$schema); - + $savem = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - + if (false) { // after testing, confirmed that the following does not work becoz of a bug $qid2 = odbc_tables($this->_connectionID); - $rs = new ADORecordSet_odbc($qid2); + $rs = new ADORecordSet_odbc($qid2); $ADODB_FETCH_MODE = $savem; if (!$rs) return false; $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change; $rs->_fetch(); - + while (!$rs->EOF) { if ($table == strtoupper($rs->fields[2])) { $q = $rs->fields[0]; @@ -381,7 +381,7 @@ class ADODB_odbc extends ADOConnection { $rs->MoveNext(); } $rs->Close(); - + $qid = odbc_columns($this->_connectionID,$q,$o,strtoupper($table),'%'); } else switch ($this->databaseType) { case 'access': @@ -389,23 +389,23 @@ class ADODB_odbc extends ADOConnection { case 'db2': $qid = odbc_columns($this->_connectionID); break; - + default: $qid = @odbc_columns($this->_connectionID,'%','%',strtoupper($table),'%'); if (empty($qid)) $qid = odbc_columns($this->_connectionID); break; } if (empty($qid)) return false; - + $rs = new ADORecordSet_odbc($qid); $ADODB_FETCH_MODE = $savem; - + if (!$rs) return false; - + $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change; $rs->_fetch(); $retarr = array(); - + /* $rs->fields indices 0 TABLE_QUALIFIER @@ -427,30 +427,30 @@ class ADODB_odbc extends ADOConnection { $fld = new ADOFieldObject(); $fld->name = $rs->fields[3]; $fld->type = $this->ODBCTypes($rs->fields[4]); - + // ref: http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnaraccgen/html/msdn_odk.asp // access uses precision to store length for char/varchar if ($fld->type == 'C' or $fld->type == 'X') { - if ($this->databaseType == 'access') + if ($this->databaseType == 'access') $fld->max_length = $rs->fields[6]; else if ($rs->fields[4] <= -95) // UNICODE $fld->max_length = $rs->fields[7]/2; else $fld->max_length = $rs->fields[7]; - } else + } else $fld->max_length = $rs->fields[7]; $fld->not_null = !empty($rs->fields[10]); $fld->scale = $rs->fields[8]; - $retarr[strtoupper($fld->name)] = $fld; + $retarr[strtoupper($fld->name)] = $fld; } else if (sizeof($retarr)>0) break; $rs->MoveNext(); } $rs->Close(); //-- crashes 4.03pl1 -- why? - + return $retarr; } - + function Prepare($sql) { if (! $this->_bindInputArray) return $sql; // no binding @@ -463,24 +463,24 @@ class ADODB_odbc extends ADOConnection { } /* returns queryID or false */ - function _query($sql,$inputarr=false) + function _query($sql,$inputarr=false) { GLOBAL $php_errormsg; $php_errormsg = ''; $this->_error = ''; - + if ($inputarr) { if (is_array($sql)) { $stmtid = $sql[1]; } else { $stmtid = odbc_prepare($this->_connectionID,$sql); - + if ($stmtid == false) { $this->_errorMsg = $php_errormsg; return false; } } - + if (! odbc_execute($stmtid,$inputarr)) { //@odbc_free_result($stmtid); if ($this->_haserrorfunctions) { @@ -489,7 +489,7 @@ class ADODB_odbc extends ADOConnection { } return false; } - + } else if (is_array($sql)) { $stmtid = $sql[1]; if (!odbc_execute($stmtid)) { @@ -502,7 +502,7 @@ class ADODB_odbc extends ADOConnection { } } else $stmtid = odbc_exec($this->_connectionID,$sql); - + $this->_lastAffectedRows = 0; if ($stmtid) { if (@odbc_num_fields($stmtid) == 0) { @@ -513,7 +513,7 @@ class ADODB_odbc extends ADOConnection { odbc_binmode($stmtid,$this->binmode); odbc_longreadlen($stmtid,$this->maxblobsize); } - + if ($this->_haserrorfunctions) { $this->_errorMsg = ''; $this->_errorCode = 0; @@ -532,9 +532,9 @@ class ADODB_odbc extends ADOConnection { /* Insert a null into the blob field of the table first. Then use UpdateBlob to store the blob. - + Usage: - + $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1'); */ @@ -542,7 +542,7 @@ class ADODB_odbc extends ADOConnection { { return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false; } - + // returns true or false function _close() { @@ -555,31 +555,31 @@ class ADODB_odbc extends ADOConnection { { return $this->_lastAffectedRows; } - + } - + /*-------------------------------------------------------------------------------------- Class Name: Recordset --------------------------------------------------------------------------------------*/ -class ADORecordSet_odbc extends ADORecordSet { - +class ADORecordSet_odbc extends ADORecordSet { + var $bind = false; - var $databaseType = "odbc"; + var $databaseType = "odbc"; var $dataProvider = "odbc"; var $useFetchArray; var $_has_stupid_odbc_fetch_api_change; - + function ADORecordSet_odbc($id,$mode=false) { - if ($mode === false) { + if ($mode === false) { global $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE; } $this->fetchMode = $mode; - + $this->_queryID = $id; - + // the following is required for mysql odbc driver in 4.3.1 -- why? $this->EOF = false; $this->_currentRow = -1; @@ -588,11 +588,11 @@ class ADORecordSet_odbc extends ADORecordSet { // returns the field object - function &FetchField($fieldOffset = -1) + function &FetchField($fieldOffset = -1) { - + $off=$fieldOffset+1; // offsets begin at 1 - + $o= new ADOFieldObject(); $o->name = @odbc_field_name($this->_queryID,$off); $o->type = @odbc_field_type($this->_queryID,$off); @@ -601,7 +601,7 @@ class ADORecordSet_odbc extends ADORecordSet { else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name); return $o; } - + /* Use associative array to get fields array */ function Fields($colname) { @@ -616,8 +616,8 @@ class ADORecordSet_odbc extends ADORecordSet { return $this->fields[$this->bind[strtoupper($colname)]]; } - - + + function _initrs() { global $ADODB_COUNTRECS; @@ -627,15 +627,15 @@ class ADORecordSet_odbc extends ADORecordSet { if ($this->_numOfRows == 0) $this->_numOfRows = -1; //$this->useFetchArray = $this->connection->useFetchArray; $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200; - } - + } + function _seek($row) { return false; } - + // speed up SelectLimit() by switching to ADODB_FETCH_NUM as ADODB_FETCH_ASSOC is emulated - function &GetArrayLimit($nrows,$offset=-1) + function &GetArrayLimit($nrows,$offset=-1) { if ($offset <= 0) { $rs =& $this->GetArray($nrows); @@ -645,30 +645,30 @@ class ADORecordSet_odbc extends ADORecordSet { $this->fetchMode = ADODB_FETCH_NUM; $this->Move($offset); $this->fetchMode = $savem; - + if ($this->fetchMode & ADODB_FETCH_ASSOC) { $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE); } - + $results = array(); $cnt = 0; while (!$this->EOF && $nrows != $cnt) { $results[$cnt++] = $this->fields; $this->MoveNext(); } - + return $results; } - - - function MoveNext() + + + function MoveNext() { - if ($this->_numOfRows != 0 && !$this->EOF) { + if ($this->_numOfRows != 0 && !$this->EOF) { $this->_currentRow++; $row = 0; if ($this->_has_stupid_odbc_fetch_api_change) $rez = @odbc_fetch_into($this->_queryID,$this->fields); - else + else $rez = @odbc_fetch_into($this->_queryID,$row,$this->fields); if ($rez) { if ($this->fetchMode & ADODB_FETCH_ASSOC) { @@ -680,16 +680,16 @@ class ADORecordSet_odbc extends ADORecordSet { $this->fields = false; $this->EOF = true; return false; - } - + } + function _fetch() { $row = 0; if ($this->_has_stupid_odbc_fetch_api_change) $rez = @odbc_fetch_into($this->_queryID,$this->fields,$row); - else + else $rez = @odbc_fetch_into($this->_queryID,$row,$this->fields); - + if ($rez) { if ($this->fetchMode & ADODB_FETCH_ASSOC) { $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE); @@ -699,10 +699,10 @@ class ADORecordSet_odbc extends ADORecordSet { $this->fields = false; return false; } - - function _close() + + function _close() { - return @odbc_free_result($this->_queryID); + return @odbc_free_result($this->_queryID); } } diff --git a/lib/WikiDB/adodb/drivers/adodb-odbc_mssql.inc.php b/lib/WikiDB/adodb/drivers/adodb-odbc_mssql.inc.php index 3e62bd31f..af4bfc4ea 100644 --- a/lib/WikiDB/adodb/drivers/adodb-odbc_mssql.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-odbc_mssql.inc.php @@ -1,14 +1,14 @@ ADODB_odbc(); - $this->curmode = SQL_CUR_USE_ODBC; + $this->curmode = SQL_CUR_USE_ODBC; } // crashes php... @@ -58,31 +58,31 @@ class ADODB_odbc_mssql extends ADODB_odbc { return $arr; } - function IfNull( $field, $ifNull ) + function IfNull( $field, $ifNull ) { return " ISNULL($field, $ifNull) "; // if MS SQL Server } - + function _insertid() { // SCOPE_IDENTITY() - // Returns the last IDENTITY value inserted into an IDENTITY column in - // the same scope. A scope is a module -- a stored procedure, trigger, - // function, or batch. Thus, two statements are in the same scope if + // Returns the last IDENTITY value inserted into an IDENTITY column in + // the same scope. A scope is a module -- a stored procedure, trigger, + // function, or batch. Thus, two statements are in the same scope if // they are in the same stored procedure, function, or batch. return $this->GetOne($this->identitySQL); } - - + + function MetaForeignKeys($table, $owner=false, $upper=false) { global $ADODB_FETCH_MODE; - + $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; $table = $this->qstr(strtoupper($table)); - - $sql = + + $sql = "select object_name(constid) as constraint_name, col_name(fkeyid, fkey) as column_name, object_name(rkeyid) as referenced_table_name, @@ -90,20 +90,20 @@ class ADODB_odbc_mssql extends ADODB_odbc { from sysforeignkeys where upper(object_name(fkeyid)) = $table order by constraint_name, referenced_table_name, keyno"; - + $constraints =& $this->GetArray($sql); - + $ADODB_FETCH_MODE = $save; - + $arr = false; foreach($constraints as $constr) { //print_r($constr); - $arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3]; + $arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3]; } if (!$arr) return false; - + $arr2 = false; - + foreach($arr as $k => $v) { foreach($v as $a => $b) { if ($upper) $a = strtoupper($a); @@ -112,8 +112,8 @@ order by constraint_name, referenced_table_name, keyno"; } return $arr2; } - - function &MetaTables($ttype=false,$showSchema=false,$mask=false) + + function &MetaTables($ttype=false,$showSchema=false,$mask=false) { if ($mask) {$this->debug=1; $save = $this->metaTablesSQL; @@ -121,38 +121,38 @@ order by constraint_name, referenced_table_name, keyno"; $this->metaTablesSQL .= " AND name like $mask"; } $ret =& ADOConnection::MetaTables($ttype,$showSchema); - + if ($mask) { $this->metaTablesSQL = $save; } return $ret; } - + function &MetaColumns($table) { return ADOConnection::MetaColumns($table); } - + function _query($sql,$inputarr) { if (is_string($sql)) $sql = str_replace('||','+',$sql); return ADODB_odbc::_query($sql,$inputarr); } - + // "Stein-Aksel Basma" // tested with MSSQL 2000 function &MetaPrimaryKeys($table) { $sql = "select k.column_name from information_schema.key_column_usage k, - information_schema.table_constraints tc + information_schema.table_constraints tc where tc.constraint_name = k.constraint_name and tc.constraint_type = 'PRIMARY KEY' and k.table_name = '$table'"; - + $a = $this->GetCol($sql); if ($a && sizeof($a)>0) return $a; - return false; + return false; } - + function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) { if ($nrows > 0 && $offset <= 0) { @@ -161,16 +161,16 @@ order by constraint_name, referenced_table_name, keyno"; $rs =& $this->Execute($sql,$inputarr); } else $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); - + return $rs; } - + // Format date column in sql string given an input format that understands Y M D function SQLDate($fmt, $col=false) - { + { if (!$col) $col = $this->sysTimeStamp; $s = ''; - + $len = strlen($fmt); for ($i=0; $i < $len; $i++) { if ($s) $s .= '+'; @@ -197,11 +197,11 @@ order by constraint_name, referenced_table_name, keyno"; case 'h': $s .= "substring(convert(char(14),$col,0),13,2)"; break; - + case 'H': $s .= "replace(str(datepart(hh,$col),2),' ','0')"; break; - + case 'i': $s .= "replace(str(datepart(mi,$col),2),' ','0')"; break; @@ -212,7 +212,7 @@ order by constraint_name, referenced_table_name, keyno"; case 'A': $s .= "substring(convert(char(19),$col,0),18,2)"; break; - + default: if ($ch == '\\') { $i++; @@ -225,15 +225,15 @@ order by constraint_name, referenced_table_name, keyno"; return $s; } -} - -class ADORecordSet_odbc_mssql extends ADORecordSet_odbc { - +} + +class ADORecordSet_odbc_mssql extends ADORecordSet_odbc { + var $databaseType = 'odbc_mssql'; - + function ADORecordSet_odbc_mssql($id,$mode=false) { return $this->ADORecordSet_odbc($id,$mode); - } + } } ?> \ No newline at end of file diff --git a/lib/WikiDB/adodb/drivers/adodb-odbc_oracle.inc.php b/lib/WikiDB/adodb/drivers/adodb-odbc_oracle.inc.php index 1a883dbae..4f71668e3 100644 --- a/lib/WikiDB/adodb/drivers/adodb-odbc_oracle.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-odbc_oracle.inc.php @@ -1,40 +1,40 @@ ADODB_odbc(); } - - function &MetaTables() + + function &MetaTables() { if ($this->metaTablesSQL) { $rs = $this->Execute($this->metaTablesSQL); @@ -49,11 +49,11 @@ class ADODB_odbc_oracle extends ADODB_odbc { } return false; } - - function &MetaColumns($table) + + function &MetaColumns($table) { if (!empty($this->metaColumnsSQL)) { - + $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table))); if ($rs === false) return false; @@ -63,15 +63,15 @@ class ADODB_odbc_oracle extends ADODB_odbc { $fld->name = $rs->fields[0]; $fld->type = $rs->fields[1]; $fld->max_length = $rs->fields[2]; - - - if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; + + + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; else $retarr[strtoupper($fld->name)] = $fld; - + $rs->MoveNext(); } $rs->Close(); - return $retarr; + return $retarr; } return false; } @@ -80,11 +80,11 @@ class ADODB_odbc_oracle extends ADODB_odbc { function _connect($argDSN, $argUsername, $argPassword, $argDatabasename) { global $php_errormsg; - + $php_errormsg = ''; $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,SQL_CUR_USE_ODBC ); $this->_errorMsg = $php_errormsg; - + $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'"); //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); return $this->_connectionID != false; @@ -96,17 +96,17 @@ class ADODB_odbc_oracle extends ADODB_odbc { $php_errormsg = ''; $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,SQL_CUR_USE_ODBC ); $this->_errorMsg = $php_errormsg; - + $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'"); //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); return $this->_connectionID != false; } -} - -class ADORecordSet_odbc_oracle extends ADORecordSet_odbc { - +} + +class ADORecordSet_odbc_oracle extends ADORecordSet_odbc { + var $databaseType = 'odbc_oracle'; - + function ADORecordSet_odbc_oracle($id,$mode=false) { return $this->ADORecordSet_odbc($id,$mode); diff --git a/lib/WikiDB/adodb/drivers/adodb-odbtp.inc.php b/lib/WikiDB/adodb/drivers/adodb-odbtp.inc.php index e9f7f05e8..0ff01a109 100644 --- a/lib/WikiDB/adodb/drivers/adodb-odbtp.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-odbtp.inc.php @@ -233,12 +233,12 @@ class ADODB_odbtp extends ADOConnection{ @odbtp_set_attr(ODB_ATTR_UNICODESQL, TRUE, $this->_connectionID); return true; } - + function _pconnect($HostOrInterface, $UserOrDSN='', $argPassword='', $argDatabase='') { return $this->_connect($HostOrInterface, $UserOrDSN, $argPassword, $argDatabase); } - + function SelectDB($dbName) { if (!@odbtp_select_db($dbName, $this->_connectionID)) { @@ -247,7 +247,7 @@ class ADODB_odbtp extends ADOConnection{ $this->databaseName = $dbName; return true; } - + function &MetaTables($ttype='',$showSchema=false,$mask=false) { global $ADODB_FETCH_MODE; @@ -265,7 +265,7 @@ class ADODB_odbtp extends ADOConnection{ } return $arr2; } - + function &MetaColumns($table,$upper=true) { global $ADODB_FETCH_MODE; @@ -280,7 +280,7 @@ class ADODB_odbtp extends ADOConnection{ $ADODB_FETCH_MODE = $savem; if (!$rs) return false; - + while (!$rs->EOF) { //print_r($rs->fields); if (strtoupper($rs->fields[2]) == $table) { @@ -299,7 +299,7 @@ class ADODB_odbtp extends ADOConnection{ break; $rs->MoveNext(); } - $rs->Close(); + $rs->Close(); return $retarr; } @@ -608,7 +608,7 @@ class ADORecordSet_odbtp extends ADORecordSet { $this->_currentRow = $this->_numOfRows - 1; return true; } - + function NextRecordSet() { if (!@odbtp_next_result($this->_queryID)) return false; diff --git a/lib/WikiDB/adodb/drivers/adodb-oracle.inc.php b/lib/WikiDB/adodb/drivers/adodb-oracle.inc.php index 1b55b0da5..828bea661 100644 --- a/lib/WikiDB/adodb/drivers/adodb-oracle.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-oracle.inc.php @@ -1,16 +1,16 @@ fmtDate,$d).",'YYYY-MM-DD')"; } - + // format and return date string in database timestamp format function DBTimeStamp($ts) { @@ -43,24 +43,24 @@ class ADODB_oracle extends ADOConnection { return 'TO_DATE('.adodb_date($this->fmtTimeStamp,$ts).",'RRRR-MM-DD, HH:MI:SS AM')"; } - + function BeginTrans() - { + { $this->autoCommit = false; ora_commitoff($this->_connectionID); return true; } - - function CommitTrans($ok=true) - { + + function CommitTrans($ok=true) + { if (!$ok) return $this->RollbackTrans(); $ret = ora_commit($this->_connectionID); ora_commiton($this->_connectionID); return $ret; } - + function RollbackTrans() { $ret = ora_rollback($this->_connectionID); @@ -70,21 +70,21 @@ class ADODB_oracle extends ADOConnection { /* there seems to be a bug in the oracle extension -- always returns ORA-00000 - no error */ - function ErrorMsg() + function ErrorMsg() { $this->_errorMsg = @ora_error($this->_curs); if (!$this->_errorMsg) $this->_errorMsg = @ora_error($this->_connectionID); return $this->_errorMsg; } - - function ErrorNo() + + function ErrorNo() { $err = @ora_errorcode($this->_curs); if (!$err) return @ora_errorcode($this->_connectionID); } - + // returns true or false function _connect($argHostname, $argUsername, $argPassword, $argDatabasename, $mode=0) @@ -144,12 +144,12 @@ class ADODB_oracle extends ADOConnection { function _query($sql,$inputarr=false) { $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; } @@ -177,15 +177,15 @@ class ADORecordset_oracle extends ADORecordSet { function ADORecordset_oracle($queryID,$mode=false) { - - if ($mode === false) { + + if ($mode === false) { global $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE; } $this->fetchMode = $mode; - + $this->_queryID = $queryID; - + $this->_inited = true; $this->fields = array(); if ($queryID) { @@ -197,7 +197,7 @@ class ADORecordset_oracle extends ADORecordSet { $this->_numOfFields = 0; $this->EOF = true; } - + return $this->_queryID; } @@ -227,10 +227,10 @@ class ADORecordset_oracle extends ADORecordSet { $this->bind[strtoupper($o->name)] = $i; } } - + return $this->fields[$this->bind[strtoupper($colname)]]; } - + function _initrs() { $this->_numOfRows = -1; @@ -246,14 +246,14 @@ class ADORecordset_oracle extends ADORecordSet { function _fetch($ignore_fields=false) { if ($this->fetchMode & ADODB_FETCH_ASSOC) return @ora_fetch_into($this->_queryID,$this->fields,ORA_FETCHINTO_NULLS|ORA_FETCHINTO_ASSOC); - else + else 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() + function _close() { return @ora_close($this->_queryID); } @@ -265,7 +265,7 @@ class ADORecordset_oracle extends ADORecordSet { $t = $fieldobj->type; $len = $fieldobj->max_length; } - + switch (strtoupper($t)) { case 'VARCHAR': case 'VARCHAR2': @@ -281,13 +281,13 @@ class ADORecordset_oracle extends ADORecordSet { case 'LONG VARBINARY': case 'BLOB': return 'B'; - + case 'DATE': return 'D'; - + //case 'T': return 'T'; - + case 'BIT': return 'L'; - case 'INT': + case 'INT': case 'SMALLINT': case 'INTEGER': return 'I'; default: return 'N'; diff --git a/lib/WikiDB/adodb/drivers/adodb-postgres.inc.php b/lib/WikiDB/adodb/drivers/adodb-postgres.inc.php index 40e733d16..c4d679a69 100644 --- a/lib/WikiDB/adodb/drivers/adodb-postgres.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-postgres.inc.php @@ -1,11 +1,11 @@ - jlim - changed concat operator to || and data types to MetaType to match documented pgsql types - see http://www.postgresql.org/devel-corner/docs/postgres/datatype.htm + jlim - changed concat operator to || and data types to MetaType to match documented pgsql types + see http://www.postgresql.org/devel-corner/docs/postgres/datatype.htm 22 Nov 2000 jlim - added changes to FetchField() and MetaTables() contributed by "raser" 27 Nov 2000 jlim - added changes to _connect/_pconnect from ideas by "Lennie" - 15 Dec 2000 jlim - added changes suggested by Additional code changes by "Eric G. Werk" egw@netguide.dk. + 15 Dec 2000 jlim - added changes suggested by Additional code changes by "Eric G. Werk" egw@netguide.dk. 31 Jan 2002 jlim - finally installed postgresql. testing 01 Mar 2001 jlim - Freek Dijkstra changes, also support for text type - + See http://www.varlena.com/varlena/GeneralBits/47.php - + -- What indexes are on my table? select * from pg_indexes where tablename = 'tablename'; - + -- What triggers are on my table? - select c.relname as "Table", t.tgname as "Trigger Name", + select c.relname as "Table", t.tgname as "Trigger Name", t.tgconstrname as "Constraint Name", t.tgenabled as "Enabled", t.tgisconstraint as "Is Constraint", cc.relname as "Referenced Table", p.proname as "Function Name" @@ -31,7 +31,7 @@ where t.tgfoid = p.oid and t.tgrelid = c.oid and t.tgconstrrelid = cc.oid and c.relname = 'tablename'; - + -- What constraints are on my table? select r.relname as "Table", c.conname as "Constraint Name", contype as "Constraint Type", conkey as "Key Columns", @@ -47,7 +47,7 @@ function adodb_addslashes($s) $len = strlen($s); if ($len == 0) return "''"; if (strncmp($s,"'",1) === 0 && substr(s,$len-1) == "'") return $s; // already quoted - + return "'".addslashes($s)."'"; } @@ -58,32 +58,32 @@ class ADODB_postgres64 extends ADOConnection{ var $_resultid = false; var $concat_operator='||'; var $metaDatabasesSQL = "select datname from pg_database where datname not in ('template0','template1') order by 1"; - var $metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%' union + var $metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%' union select viewname,'V' from pg_views where viewname not like 'pg\_%'"; //"select tablename from pg_tables where tablename not like 'pg_%' order by 1"; var $isoDates = true; // accepts dates in ISO format var $sysDate = "CURRENT_DATE"; var $sysTimeStamp = "CURRENT_TIMESTAMP"; var $blobEncodeType = 'C'; - var $metaColumnsSQL = "SELECT a.attname,t.typname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum - FROM pg_class c, pg_attribute a,pg_type t + var $metaColumnsSQL = "SELECT a.attname,t.typname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum + FROM pg_class c, pg_attribute a,pg_type t WHERE relkind = 'r' AND (c.relname='%s' or c.relname = lower('%s')) and a.attname not like '....%%' AND a.attnum > 0 AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum"; - var $metaColumnsSQL1 = "SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum -FROM pg_class c, pg_attribute a, pg_type t, pg_namespace n + var $metaColumnsSQL1 = "SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum +FROM pg_class c, pg_attribute a, pg_type t, pg_namespace n WHERE relkind = 'r' AND (c.relname='%s' or c.relname = lower('%s')) - and c.relnamespace=n.oid and n.nspname='%s' - and a.attname not like '....%%' AND a.attnum > 0 + and c.relnamespace=n.oid and n.nspname='%s' + and a.attname not like '....%%' AND a.attnum > 0 AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum"; - + // get primary key etc -- from Freek Dijkstra - var $metaKeySQL = "SELECT ic.relname AS index_name, a.attname AS column_name,i.indisunique AS unique_key, i.indisprimary AS primary_key + var $metaKeySQL = "SELECT ic.relname AS index_name, a.attname AS column_name,i.indisunique AS unique_key, i.indisprimary AS primary_key FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a WHERE bc.oid = i.indrelid AND ic.oid = i.indexrelid AND (i.indkey[0] = a.attnum OR i.indkey[1] = a.attnum OR i.indkey[2] = a.attnum OR i.indkey[3] = a.attnum OR i.indkey[4] = a.attnum OR i.indkey[5] = a.attnum OR i.indkey[6] = a.attnum OR i.indkey[7] = a.attnum) AND a.attrelid = bc.oid AND bc.relname = '%s'"; - + var $hasAffectedRows = true; var $hasLimit = false; // set to true for pgsql 7 only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10 - // below suggested by Freek Dijkstra + // below suggested by Freek Dijkstra var $true = 't'; // string that represents TRUE for a database var $false = 'f'; // string that represents FALSE for a database var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database @@ -97,33 +97,33 @@ WHERE relkind = 'r' AND (c.relname='%s' or c.relname = lower('%s')) var $random = 'random()'; /// random function var $autoRollback = true; // apparently pgsql does not autorollback properly before 4.3.4 // http://bugs.php.net/bug.php?id=25404 - + var $_bindInputArray = false; // requires postgresql 7.3+ and ability to modify database - - // The last (fmtTimeStamp is not entirely correct: - // PostgreSQL also has support for time zones, - // and writes these time in this format: "2001-03-01 18:59:26+02". - // There is no code for the "+02" time zone information, so I just left that out. - // I'm not familiar enough with both ADODB as well as Postgres + + // The last (fmtTimeStamp is not entirely correct: + // PostgreSQL also has support for time zones, + // and writes these time in this format: "2001-03-01 18:59:26+02". + // There is no code for the "+02" time zone information, so I just left that out. + // I'm not familiar enough with both ADODB as well as Postgres // to know what the concequences are. The other values are correct (wheren't in 0.94) - // -- Freek Dijkstra + // -- Freek Dijkstra - function ADODB_postgres64() + function ADODB_postgres64() { // changes the metaColumnsSQL, adds columns: attnum[6] } - + function ServerInfo() { if (isset($this->version)) return $this->version; - + $arr['description'] = $this->GetOne("select version()"); $arr['version'] = ADOConnection::_findvers($arr['description']); $this->version = $arr; return $arr; } /* - function IfNull( $field, $ifNull ) + function IfNull( $field, $ifNull ) { return " NULLIF($field, $ifNull) "; // if PGSQL } @@ -139,10 +139,10 @@ WHERE relkind = 'r' AND (c.relname='%s' or c.relname = lower('%s')) } return false; } - + /* Warning from http://www.php.net/manual/function.pg-getlastoid.php: -Using a OID as a unique identifier is not generally wise. -Unless you are very careful, you might end up with a tuple having +Using a OID as a unique identifier is not generally wise. +Unless you are very careful, you might end up with a tuple having a different OID if a database must be reloaded. */ function _insertid() { @@ -157,8 +157,8 @@ a different OID if a database must be reloaded. */ if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false; return pg_cmdtuples($this->_resultid); } - - + + // returns true/false function BeginTrans() { @@ -166,23 +166,23 @@ a different OID if a database must be reloaded. */ $this->transCnt += 1; return @pg_Exec($this->_connectionID, "begin"); } - - function RowLock($tables,$where) + + function RowLock($tables,$where) { if (!$this->transCnt) $this->BeginTrans(); return $this->GetOne("select 1 as ignore from $tables where $where for update"); } - // returns true/false. - function CommitTrans($ok=true) - { + // returns true/false. + function CommitTrans($ok=true) + { if ($this->transOff) return true; if (!$ok) return $this->RollbackTrans(); - + $this->transCnt -= 1; return @pg_Exec($this->_connectionID, "commit"); } - + // returns true/false function RollbackTrans() { @@ -190,24 +190,24 @@ a different OID if a database must be reloaded. */ $this->transCnt -= 1; return @pg_Exec($this->_connectionID, "rollback"); } - - function &MetaTables($ttype=false,$showSchema=false,$mask=false) - { + + function &MetaTables($ttype=false,$showSchema=false,$mask=false) + { if ($mask) { $save = $this->metaTablesSQL; $mask = $this->qstr(strtolower($mask)); $this->metaTablesSQL = " -select tablename,'T' from pg_tables where tablename like $mask union +select tablename,'T' from pg_tables where tablename like $mask union select viewname,'V' from pg_views where viewname like $mask"; } $ret =& ADOConnection::MetaTables($ttype,$showSchema); - + if ($mask) { $this->metaTablesSQL = $save; } return $ret; } - + /* // if magic quotes disabled, use pg_escape_string() function qstr($s,$magic_quotes=false) @@ -219,22 +219,22 @@ select viewname,'V' from pg_views where viewname like $mask"; if ($this->replaceQuote[0] == '\\'){ $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s); } - return "'".str_replace("'",$this->replaceQuote,$s)."'"; + return "'".str_replace("'",$this->replaceQuote,$s)."'"; } - + // undo magic quotes for " $s = str_replace('\\"','"',$s); return "'$s'"; } */ - - + + // Format date column in sql string given an input format that understands Y M D function SQLDate($fmt, $col=false) - { + { if (!$col) $col = $this->sysTimeStamp; $s = 'TO_CHAR('.$col.",'"; - + $len = strlen($fmt); for ($i=0; $i < $len; $i++) { $ch = $fmt[$i]; @@ -247,11 +247,11 @@ select viewname,'V' from pg_views where viewname like $mask"; case 'q': $s .= 'Q'; break; - + case 'M': $s .= 'Mon'; break; - + case 'm': $s .= 'MM'; break; @@ -259,28 +259,28 @@ select viewname,'V' from pg_views where viewname like $mask"; case 'd': $s .= 'DD'; break; - + case 'H': $s.= 'HH24'; break; - + case 'h': $s .= 'HH'; break; - + case 'i': $s .= 'MI'; break; - + case 's': $s .= 'SS'; break; - + case 'a': case 'A': $s .= 'AM'; break; - + default: // handle escape characters... if ($ch == '\\') { @@ -289,43 +289,43 @@ select viewname,'V' from pg_views where viewname like $mask"; } if (strpos('-/.:;, ',$ch) !== false) $s .= $ch; else $s .= '"'.$ch.'"'; - + } } return $s. "')"; } - - - - /* - * Load a Large Object from a file - * - the procedure stores the object id in the table and imports the object using - * postgres proprietary blob handling routines + + + + /* + * Load a Large Object from a file + * - the procedure stores the object id in the table and imports the object using + * postgres proprietary blob handling routines * * contributed by Mattia Rossi mattia@technologist.com * modified for safe mode by juraj chlebec - */ - function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB') - { - pg_exec ($this->_connectionID, "begin"); - + */ + function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB') + { + pg_exec ($this->_connectionID, "begin"); + $fd = fopen($path,'r'); $contents = fread($fd,filesize($path)); fclose($fd); - + $oid = pg_lo_create($this->_connectionID); $handle = pg_lo_open($this->_connectionID, $oid, 'w'); pg_lo_write($handle, $contents); pg_lo_close($handle); - - // $oid = pg_lo_import ($path); - pg_exec($this->_connectionID, "commit"); - $rs = ADOConnection::UpdateBlob($table,$column,$oid,$where,$blobtype); - $rez = !empty($rs); - return $rez; - } - - /* + + // $oid = pg_lo_import ($path); + pg_exec($this->_connectionID, "commit"); + $rs = ADOConnection::UpdateBlob($table,$column,$oid,$where,$blobtype); + $rez = !empty($rs); + return $rez; + } + + /* * If an OID is detected, then we use pg_lo_* to open the oid file and read the * real blob from the db using the oid supplied as a parameter. If you are storing * blobs using bytea, we autodetect and process it so this function is not needed. @@ -333,91 +333,91 @@ select viewname,'V' from pg_views where viewname like $mask"; * contributed by Mattia Rossi mattia@technologist.com * * see http://www.postgresql.org/idocs/index.php?largeobjects.html - */ - function BlobDecode( $blob) - { + */ + function BlobDecode( $blob) + { if (strlen($blob) > 24) return $blob; - - @pg_exec($this->_connectionID,"begin"); + + @pg_exec($this->_connectionID,"begin"); $fd = @pg_lo_open($this->_connectionID,$blob,"r"); if ($fd === false) { @pg_exec($this->_connectionID,"commit"); return $blob; } - $realblob = @pg_loreadall($fd); - @pg_loclose($fd); - @pg_exec($this->_connectionID,"commit"); + $realblob = @pg_loreadall($fd); + @pg_loclose($fd); + @pg_exec($this->_connectionID,"commit"); return $realblob; - } - - /* + } + + /* See http://www.postgresql.org/idocs/index.php?datatype-binary.html - - NOTE: SQL string literals (input strings) must be preceded with two backslashes - due to the fact that they must pass through two parsers in the PostgreSQL + + NOTE: SQL string literals (input strings) must be preceded with two backslashes + due to the fact that they must pass through two parsers in the PostgreSQL backend. */ function BlobEncode($blob) { if (ADODB_PHPVER >= 0x4200) return pg_escape_bytea($blob); - + /*92=backslash, 0=null, 39=single-quote*/ $badch = array(chr(92),chr(0),chr(39)); # \ null ' $fixch = array('\\\\134','\\\\000','\\\\047'); return adodb_str_replace($badch,$fixch,$blob); - + // note that there is a pg_escape_bytea function only for php 4.2.0 or later } - + function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') { // do not use bind params which uses qstr(), as blobencode() already quotes data return $this->Execute("UPDATE $table SET $column='".$this->BlobEncode($val)."'::bytea WHERE $where"); } - + function OffsetDate($dayFraction,$date=false) - { + { if (!$date) $date = $this->sysDate; return "($date+interval'$dayFraction days')"; } - + // for schema support, pass in the $table param "$schema.$tabname". // converts field names to lowercase, $upper is ignored - function &MetaColumns($table,$upper=true) + function &MetaColumns($table,$upper=true) { global $ADODB_FETCH_MODE; - + $schema = false; $this->_findschema($table,$schema); - + $table = strtolower($table); $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); - + if ($schema) $rs =& $this->Execute(sprintf($this->metaColumnsSQL1,$table,$table,$schema)); else $rs =& $this->Execute(sprintf($this->metaColumnsSQL,$table,$table)); if (isset($savem)) $this->SetFetchMode($savem); $ADODB_FETCH_MODE = $save; - + if ($rs === false) return false; - + if (!empty($this->metaKeySQL)) { // If we want the primary keys, we have to issue a separate query - // Of course, a modified version of the metaColumnsSQL query using a - // LEFT JOIN would have been much more elegant, but postgres does + // Of course, a modified version of the metaColumnsSQL query using a + // LEFT JOIN would have been much more elegant, but postgres does // not support OUTER JOINS. So here is the clumsy way. - + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; - + $rskey = $this->Execute(sprintf($this->metaKeySQL,($table))); // fetch all result in once for performance. $keys =& $rskey->GetArray(); if (isset($savem)) $this->SetFetchMode($savem); $ADODB_FETCH_MODE = $save; - + $rskey->Close(); unset($rskey); } @@ -429,7 +429,7 @@ select viewname,'V' from pg_views where viewname like $mask"; $rsdef = $this->Execute($sql); if (isset($savem)) $this->SetFetchMode($savem); $ADODB_FETCH_MODE = $save; - + if ($rsdef) { while (!$rsdef->EOF) { $num = $rsdef->fields['num']; @@ -447,16 +447,16 @@ select viewname,'V' from pg_views where viewname like $mask"; } unset($rsdef); } - + $retarr = array(); - while (!$rs->EOF) { + while (!$rs->EOF) { $fld = new ADOFieldObject(); $fld->name = $rs->fields[0]; $fld->type = $rs->fields[1]; $fld->max_length = $rs->fields[2]; if ($fld->max_length <= 0) $fld->max_length = $rs->fields[3]-4; if ($fld->max_length <= 0) $fld->max_length = -1; - + // dannym // 5 hasdefault; 6 num-of-column $fld->has_default = ($rs->fields[5] == 't'); @@ -468,41 +468,41 @@ select viewname,'V' from pg_views where viewname like $mask"; if ($rs->fields[4] == $this->true) { $fld->not_null = true; } - + // Freek if (is_array($keys)) { foreach($keys as $key) { - if ($fld->name == $key['column_name'] AND $key['primary_key'] == $this->true) + if ($fld->name == $key['column_name'] AND $key['primary_key'] == $this->true) $fld->primary_key = true; - if ($fld->name == $key['column_name'] AND $key['unique_key'] == $this->true) + if ($fld->name == $key['column_name'] AND $key['unique_key'] == $this->true) $fld->unique = true; // What name is more compatible? } } - - if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; + + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; else $retarr[($upper) ? strtoupper($fld->name) : $fld->name] = $fld; - + $rs->MoveNext(); } $rs->Close(); - return $retarr; - + return $retarr; + } function &MetaIndexes ($table, $primary = FALSE) { global $ADODB_FETCH_MODE; - + $schema = false; $this->_findschema($table,$schema); - + if ($schema) { // requires pgsql 7.3+ - pg_namespace used. $sql = ' -SELECT c.relname as "Name", i.indisunique as "Unique", i.indkey as "Columns" -FROM pg_catalog.pg_class c -JOIN pg_catalog.pg_index i ON i.indexrelid=c.oid +SELECT c.relname as "Name", i.indisunique as "Unique", i.indkey as "Columns" +FROM pg_catalog.pg_class c +JOIN pg_catalog.pg_index i ON i.indexrelid=c.oid JOIN pg_catalog.pg_class c2 ON c2.oid=i.indrelid - ,pg_namespace n + ,pg_namespace n WHERE c2.relname=\'%s\' and c.relnamespace=c2.relnamespace and c.relnamespace=n.oid and n.nspname=\'%s\' AND i.indisprimary=false'; } else { $sql = ' @@ -512,44 +512,44 @@ JOIN pg_catalog.pg_index i ON i.indexrelid=c.oid JOIN pg_catalog.pg_class c2 ON c2.oid=i.indrelid WHERE c2.relname=\'%s\''; } - + if ($primary == FALSE) { $sql .= ' AND i.indisprimary=false;'; } - + $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; if ($this->fetchMode !== FALSE) { $savem = $this->SetFetchMode(FALSE); } - + $rs = $this->Execute(sprintf($sql,$table,$schema)); - + if (isset($savem)) { $this->SetFetchMode($savem); } $ADODB_FETCH_MODE = $save; - + if (!is_object($rs)) { return FALSE; } - + $col_names = $this->MetaColumnNames($table); $indexes = array(); - + while ($row = $rs->FetchRow()) { $columns = array(); - + foreach (explode(' ', $row[2]) as $col) { $columns[] = $col_names[$col - 1]; } - + $indexes[$row[0]] = array( 'unique' => ($row[1] == 't'), 'columns' => $columns ); } - + return $indexes; } @@ -560,11 +560,11 @@ WHERE c2.relname=\'%s\''; // $db->Connect('host1','user1','secret'); function _connect($str,$user='',$pwd='',$db='',$ctype=0) { - + if (!function_exists('pg_pconnect')) return false; - + $this->_errorMsg = false; - + if ($user || $pwd || $db) { $user = adodb_addslashes($user); $pwd = adodb_addslashes($pwd); @@ -582,16 +582,16 @@ WHERE c2.relname=\'%s\''; } //if ($user) $linea = "user=$user host=$linea password=$pwd dbname=$db port=5432"; - + if ($ctype === 1) { // persistent $this->_connectionID = pg_pconnect($str); } else { if ($ctype === -1) { // nconnect, we trick pgsql ext by changing the connection str static $ncnt; - + if (empty($ncnt)) $ncnt = 1; else $ncnt += 1; - + $str .= str_repeat(' ',$ncnt); } $this->_connectionID = pg_connect($str); @@ -600,12 +600,12 @@ WHERE c2.relname=\'%s\''; $this->Execute("set datestyle='ISO'"); return true; } - + function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName) { return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabaseName,-1); } - + // returns true or false // // examples: @@ -615,28 +615,28 @@ WHERE c2.relname=\'%s\''; { return $this->_connect($str,$user,$pwd,$db,1); } - + // returns queryID or false function _query($sql,$inputarr) { - + if ($inputarr) { /* It appears that PREPARE/EXECUTE is slower for many queries. - + For query executed 1000 times: - "select id,firstname,lastname from adoxyz + "select id,firstname,lastname from adoxyz where firstname not like ? and lastname not like ? and id = ?" - + with plan = 1.51861286163 secs no plan = 1.26903700829 secs - + */ $plan = 'P'.md5($sql); - + $execp = ''; foreach($inputarr as $v) { if ($execp) $execp .= ','; @@ -646,10 +646,10 @@ WHERE c2.relname=\'%s\''; $execp .= $v; } } - + if ($execp) $exsql = "EXECUTE $plan ($execp)"; else $exsql = "EXECUTE $plan"; - + $rez = @pg_exec($this->_connectionID,$exsql); if (!$rez) { # Perhaps plan does not exist? Prepare/compile plan. @@ -672,12 +672,12 @@ WHERE c2.relname=\'%s\''; $sql .= $v.' $'.$i; $i++; } - $s = "PREPARE $plan ($params) AS ".substr($sql,0,strlen($sql)-2); + $s = "PREPARE $plan ($params) AS ".substr($sql,0,strlen($sql)-2); //adodb_pr($s); pg_exec($this->_connectionID,$s); echo $this->ErrorMsg(); } - + $rez = pg_exec($this->_connectionID,$exsql); } else { $this->_errorMsg = false; @@ -692,13 +692,13 @@ WHERE c2.relname=\'%s\''; $this->_resultid = $rez; return true; } - + return $rez; } - - /* Returns: the last error message from previous database operation */ - function ErrorMsg() + + /* Returns: the last error message from previous database operation */ + function ErrorMsg() { if ($this->_errorMsg !== false) return $this->_errorMsg; if (ADODB_PHPVER >= 0x4300) { @@ -706,7 +706,7 @@ WHERE c2.relname=\'%s\''; $this->_errorMsg = @pg_result_error($this->_resultid); if ($this->_errorMsg) return $this->_errorMsg; } - + if (!empty($this->_connectionID)) { $this->_errorMsg = @pg_last_error($this->_connectionID); } else $this->_errorMsg = @pg_last_error(); @@ -716,7 +716,7 @@ WHERE c2.relname=\'%s\''; } return $this->_errorMsg; } - + function ErrorNo() { $e = $this->ErrorMsg(); @@ -735,8 +735,8 @@ WHERE c2.relname=\'%s\''; $this->_connectionID = false; return true; } - - + + /* * Maximum size of C field */ @@ -744,7 +744,7 @@ WHERE c2.relname=\'%s\''; { return 1000000000; // should be 1 Gb? } - + /* * Maximum size of X field */ @@ -752,10 +752,10 @@ WHERE c2.relname=\'%s\''; { return 1000000000; // should be 1 Gb? } - - + + } - + /*-------------------------------------------------------------------------------------- Class Name: Recordset --------------------------------------------------------------------------------------*/ @@ -764,9 +764,9 @@ class ADORecordSet_postgres64 extends ADORecordSet{ var $_blobArr; var $databaseType = "postgres64"; var $canSeek = true; - function ADORecordSet_postgres64($queryID,$mode=false) + function ADORecordSet_postgres64($queryID,$mode=false) { - if ($mode === false) { + if ($mode === false) { global $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE; } @@ -780,7 +780,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{ } $this->ADORecordSet($queryID); } - + function &GetRowAssoc($upper=true) { if ($this->fetchMode == PGSQL_ASSOC && !$upper) return $this->fields; @@ -794,20 +794,20 @@ class ADORecordSet_postgres64 extends ADORecordSet{ $qid = $this->_queryID; $this->_numOfRows = ($ADODB_COUNTRECS)? @pg_numrows($qid):-1; $this->_numOfFields = @pg_numfields($qid); - + // cache types for blob decode check - for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { + for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { if (pg_fieldtype($qid,$i) == 'bytea') { $this->_blobArr[$i] = pg_fieldname($qid,$off); } - } + } } /* Use associative array to get fields array */ function Fields($colname) { if ($this->fetchMode != PGSQL_NUM) return @$this->fields[$colname]; - + if (!$this->bind) { $this->bind = array(); for ($i=0; $i < $this->_numOfFields; $i++) { @@ -818,28 +818,28 @@ class ADORecordSet_postgres64 extends ADORecordSet{ return $this->fields[$this->bind[strtoupper($colname)]]; } - function &FetchField($fieldOffset = 0) + function &FetchField($fieldOffset = 0) { $off=$fieldOffset; // offsets begin at 0 - + $o= new ADOFieldObject(); $o->name = @pg_fieldname($this->_queryID,$off); $o->type = @pg_fieldtype($this->_queryID,$off); $o->max_length = @pg_fieldsize($this->_queryID,$off); - return $o; + return $o; } function _seek($row) { return @pg_fetch_row($this->_queryID,$row); } - + function _decode($blob) { eval('$realblob="'.adodb_str_replace(array('"','$'),array('\"','\$'),$blob).'";'); - return $realblob; + return $realblob; } - + function _fixblobs() { if ($this->fetchMode == PGSQL_NUM || $this->fetchMode == PGSQL_BOTH) { @@ -853,9 +853,9 @@ class ADORecordSet_postgres64 extends ADORecordSet{ } } } - + // 10% speedup to move MoveNext to child class - function MoveNext() + function MoveNext() { if (!$this->EOF) { $this->_currentRow++; @@ -870,23 +870,23 @@ class ADORecordSet_postgres64 extends ADORecordSet{ $this->EOF = true; } return false; - } - + } + function _fetch() { - + if ($this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0) return false; $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode); - + if ($this->fields && isset($this->_blobArr)) $this->_fixblobs(); - + return (is_array($this->fields)); } - function _close() - { + function _close() + { return @pg_freeresult($this->_queryID); } @@ -907,43 +907,43 @@ class ADORecordSet_postgres64 extends ADORecordSet{ case 'BPCHAR': case '_VARCHAR': if ($len <= $this->blobSize) return 'C'; - + case 'TEXT': return 'X'; - + case 'IMAGE': // user defined type case 'BLOB': // user defined type case 'BIT': // This is a bit string, not a single bit, so don't return 'L' case 'VARBIT': case 'BYTEA': return 'B'; - + case 'BOOL': case 'BOOLEAN': return 'L'; - + case 'DATE': return 'D'; - + case 'TIME': case 'DATETIME': case 'TIMESTAMP': case 'TIMESTAMPTZ': return 'T'; - - case 'SMALLINT': - case 'BIGINT': - case 'INTEGER': - case 'INT8': + + case 'SMALLINT': + case 'BIGINT': + case 'INTEGER': + case 'INT8': case 'INT4': case 'INT2': if (isset($fieldobj) && empty($fieldobj->primary_key) && empty($fieldobj->unique)) return 'I'; - + case 'OID': case 'SERIAL': return 'R'; - + default: return 'N'; } diff --git a/lib/WikiDB/adodb/drivers/adodb-postgres7.inc.php b/lib/WikiDB/adodb/drivers/adodb-postgres7.inc.php index b92fe267f..8848815ce 100644 --- a/lib/WikiDB/adodb/drivers/adodb-postgres7.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-postgres7.inc.php @@ -1,11 +1,11 @@ ADODB_postgres64(); } - - // the following should be compat with postgresql 7.2, + + // the following should be compat with postgresql 7.2, // which makes obsolete the LIMIT limit,offset syntax - function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) + function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) { $offsetStr = ($offset >= 0) ? " OFFSET $offset" : ''; $limitStr = ($nrows >= 0) ? " LIMIT $nrows" : ''; @@ -35,7 +35,7 @@ class ADODB_postgres7 extends ADODB_postgres64 { $rs =& $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr); else $rs =& $this->Execute($sql."$limitStr$offsetStr",$inputarr); - + return $rs; } /* @@ -63,9 +63,9 @@ function MetaForeignKeys($table, $owner=false, $upper=false) c.relname = \''.strtolower($table).'\' ORDER BY t.tgrelid'; - + $rs = $this->Execute($sql); - + if ($rs && !$rs->EOF) { $arr =& $rs->GetArray(); $a = array(); @@ -113,13 +113,13 @@ SELECT t.tgargs as args } else { $a[] = array($data[2] => $data[4].'='.$data[5]); } - + } return $a; } else return false; } - + // 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 UNICODE database and server it on-site as WIN1251 etc. @@ -137,7 +137,7 @@ SELECT t.tgargs as args return $this->charSet; } } - + // SetCharSet - switch the client encoding function SetCharSet($charset_name) { @@ -151,7 +151,7 @@ SELECT t.tgargs as args } } - + /*-------------------------------------------------------------------------------------- Class Name: Recordset --------------------------------------------------------------------------------------*/ @@ -159,21 +159,21 @@ SELECT t.tgargs as args class ADORecordSet_postgres7 extends ADORecordSet_postgres64{ var $databaseType = "postgres7"; - - - function ADORecordSet_postgres7($queryID,$mode=false) + + + function ADORecordSet_postgres7($queryID,$mode=false) { $this->ADORecordSet_postgres64($queryID,$mode); } - + // 10% speedup to move MoveNext to child class - function MoveNext() + function MoveNext() { if (!$this->EOF) { $this->_currentRow++; if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) { $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode); - + if (is_array($this->fields)) { if ($this->fields && isset($this->_blobArr)) $this->_fixblobs(); return true; @@ -183,7 +183,7 @@ class ADORecordSet_postgres7 extends ADORecordSet_postgres64{ $this->EOF = true; } return false; - } + } } ?> \ No newline at end of file diff --git a/lib/WikiDB/adodb/drivers/adodb-proxy.inc.php b/lib/WikiDB/adodb/drivers/adodb-proxy.inc.php index 5aae407f5..34a91cc80 100644 --- a/lib/WikiDB/adodb/drivers/adodb-proxy.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-proxy.inc.php @@ -1,30 +1,30 @@ ADORecordset($id,$mode); } }; } // define - + ?> \ No newline at end of file diff --git a/lib/WikiDB/adodb/drivers/adodb-sapdb.inc.php b/lib/WikiDB/adodb/drivers/adodb-sapdb.inc.php index 9bdb762b7..2ea565560 100644 --- a/lib/WikiDB/adodb/drivers/adodb-sapdb.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-sapdb.inc.php @@ -1,13 +1,13 @@ curmode = SQL_CUR_USE_ODBC; $this->ADODB_odbc(); } - + /* SelectLimit implementation problems: - + The following will return random 10 rows as order by performed after "WHERE rowno<10" which is not ideal... - + select * from table where rowno < 10 order by 1 - + This means that we have to use the adoconnection base class SelectLimit when there is an "order by". - + See http://listserv.sap.com/pipermail/sapdb.general/2002-January/010405.html */ - + }; - -class ADORecordSet_sapdb extends ADORecordSet_odbc { - - var $databaseType = "sapdb"; - + +class ADORecordSet_sapdb extends ADORecordSet_odbc { + + var $databaseType = "sapdb"; + function ADORecordSet_sapdb($id,$mode=false) { $this->ADORecordSet_odbc($id,$mode); diff --git a/lib/WikiDB/adodb/drivers/adodb-sqlanywhere.inc.php b/lib/WikiDB/adodb/drivers/adodb-sqlanywhere.inc.php index 4c4158e01..15bbfa4d7 100644 --- a/lib/WikiDB/adodb/drivers/adodb-sqlanywhere.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-sqlanywhere.inc.php @@ -1,10 +1,10 @@ load_blobvar_from_var($blobVarName, $varName); @@ -50,9 +50,9 @@ if (!defined('ADODB_SYBASE_SQLANYWHERE')){ define('ADODB_SYBASE_SQLANYWHERE',1); class ADODB_sqlanywhere extends ADODB_odbc { - var $databaseType = "sqlanywhere"; + var $databaseType = "sqlanywhere"; var $hasInsertID = true; - + function ADODB_sqlanywhere() { $this->ADODB_odbc(); @@ -149,9 +149,9 @@ if (!defined('ADODB_SYBASE_SQLANYWHERE')){ } }; //class - class ADORecordSet_sqlanywhere extends ADORecordSet_odbc { + class ADORecordSet_sqlanywhere extends ADORecordSet_odbc { - var $databaseType = "sqlanywhere"; + var $databaseType = "sqlanywhere"; function ADORecordSet_sqlanywhere($id,$mode=false) { diff --git a/lib/WikiDB/adodb/drivers/adodb-sqlite.inc.php b/lib/WikiDB/adodb/drivers/adodb-sqlite.inc.php index 7ee00df8e..3b98c87f5 100644 --- a/lib/WikiDB/adodb/drivers/adodb-sqlite.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-sqlite.inc.php @@ -1,14 +1,14 @@ fmtDate)."'"; case 'sysTimeStamp' : return "'".date($this->sysTimeStamp)."'"; } }*/ - + function ServerInfo() { $arr['version'] = sqlite_libversion(); @@ -48,27 +48,27 @@ class ADODB_sqlite extends ADOConnection { $arr['encoding'] = sqlite_libencoding(); return $arr; } - + function BeginTrans() - { - if ($this->transOff) return true; + { + if ($this->transOff) return true; $ret = $this->Execute("BEGIN TRANSACTION"); $this->transCnt += 1; return true; } - - function CommitTrans($ok=true) - { - if ($this->transOff) return true; + + function CommitTrans($ok=true) + { + if ($this->transOff) return true; if (!$ok) return $this->RollbackTrans(); $ret = $this->Execute("COMMIT"); if ($this->transCnt>0)$this->transCnt -= 1; return !empty($ret); } - + function RollbackTrans() { - if ($this->transOff) return true; + if ($this->transOff) return true; $ret = $this->Execute("ROLLBACK"); if ($this->transCnt>0)$this->transCnt -= 1; return !empty($ret); @@ -78,68 +78,68 @@ class ADODB_sqlite extends ADOConnection { { return sqlite_last_insert_rowid($this->_connectionID); } - + function _affectedrows() { return sqlite_changes($this->_connectionID); } - - function ErrorMsg() + + function ErrorMsg() { if ($this->_logsql) return $this->_errorMsg; return ($this->_errorNo) ? sqlite_error_string($this->_errorNo) : ''; } - - function ErrorNo() + + function ErrorNo() { return $this->_errorNo; } - + function SQLDate($fmt, $col=false) { $fmt = $this->qstr($fmt); return ($col) ? "adodb_date2($fmt,$col)" : "adodb_date($fmt)"; } - + function &MetaColumns($tab) { global $ADODB_FETCH_MODE; - + $rs = $this->Execute("select * from $tab limit 1"); if (!$rs) 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; + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] =& $fld; else $arr[strtoupper($fld->name)] =& $fld; } $rs->Close(); return $arr; } - + function _createFunctions() { @sqlite_create_function($this->_connectionID, 'adodb_date', 'adodb_date', 1); @sqlite_create_function($this->_connectionID, 'adodb_date2', 'adodb_date2', 2); } - + // returns true or false function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) { if (!function_exists('sqlite_open')) return false; - + $this->_connectionID = sqlite_open($argDatabasename); if ($this->_connectionID === false) return false; $this->_createFunctions(); return true; } - + // returns true or false function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { if (!function_exists('sqlite_popen')) return false; - + $this->_connectionID = sqlite_popen($argDatabasename); if ($this->_connectionID === false) return false; $this->_createFunctions(); @@ -153,11 +153,11 @@ class ADODB_sqlite extends ADOConnection { if (!$rez) { $this->_errorNo = sqlite_last_error($this->_connectionID); } - + return $rez; } - - function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) + + function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) { $offsetStr = ($offset >= 0) ? " OFFSET $offset" : ''; $limitStr = ($nrows >= 0) ? " LIMIT $nrows" : ($offset >= 0 ? ' LIMIT 999999999' : ''); @@ -165,20 +165,20 @@ class ADODB_sqlite extends ADOConnection { $rs =& $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr); else $rs =& $this->Execute($sql."$limitStr$offsetStr",$inputarr); - + return $rs; } - + /* This algorithm is not very efficient, but works even if table locking is not available. - + Will return false if unable to generate an ID after $MAXLOOPS attempts. */ var $_genSeqSQL = "create table %s (id integer)"; - + function GenID($seq='adodbseq',$start=1) - { + { // if you have to modify the parameter below, your database is overloaded, // or you need to implement generation of id's yourself! $MAXLOOPS = 100; @@ -186,14 +186,14 @@ class ADODB_sqlite extends ADOConnection { while (--$MAXLOOPS>=0) { $num = $this->GetOne("select id from $seq"); if ($num === false) { - $this->Execute(sprintf($this->_genSeqSQL ,$seq)); + $this->Execute(sprintf($this->_genSeqSQL ,$seq)); $start -= 1; $num = '0'; $ok = $this->Execute("insert into $seq values($start)"); if (!$ok) return false; - } + } $this->Execute("update $seq set id=id+1 where id=$num"); - + if ($this->affected_rows() > 0) { $num += 1; $this->genID = $num; @@ -214,14 +214,14 @@ class ADODB_sqlite extends ADOConnection { $start -= 1; return $this->Execute("insert into $seqname values($start)"); } - + var $_dropSeqSQL = 'drop table %s'; function DropSequence($seqname) { if (empty($this->_dropSeqSQL)) return false; return $this->Execute(sprintf($this->_dropSeqSQL,$seqname)); } - + // returns true or false function _close() { @@ -242,8 +242,8 @@ class ADORecordset_sqlite extends ADORecordSet { function ADORecordset_sqlite($queryID,$mode=false) { - - if ($mode === false) { + + if ($mode === false) { global $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE; } @@ -252,9 +252,9 @@ class ADORecordset_sqlite extends ADORecordSet { case ADODB_FETCH_ASSOC: $this->fetchMode = SQLITE_ASSOC; break; default: $this->fetchMode = SQLITE_BOTH; break; } - + $this->_queryID = $queryID; - + $this->_inited = true; $this->fields = array(); if ($queryID) { @@ -266,7 +266,7 @@ class ADORecordset_sqlite extends ADORecordSet { $this->_numOfFields = 0; $this->EOF = true; } - + return $this->_queryID; } @@ -279,7 +279,7 @@ class ADORecordset_sqlite extends ADORecordSet { $fld->max_length = -1; return $fld; } - + function _initrs() { $this->_numOfRows = @sqlite_num_rows($this->_queryID); @@ -296,22 +296,22 @@ class ADORecordset_sqlite extends ADORecordSet { $this->bind[strtoupper($o->name)] = $i; } } - + return $this->fields[$this->bind[strtoupper($colname)]]; } - + function _seek($row) { return sqlite_seek($this->_queryID, $row); } - function _fetch($ignore_fields=false) + function _fetch($ignore_fields=false) { $this->fields = @sqlite_fetch_array($this->_queryID,$this->fetchMode); return !empty($this->fields); } - - function _close() + + function _close() { } diff --git a/lib/WikiDB/adodb/drivers/adodb-sybase.inc.php b/lib/WikiDB/adodb/drivers/adodb-sybase.inc.php index 549179b07..5c80a67d6 100644 --- a/lib/WikiDB/adodb/drivers/adodb-sybase.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-sybase.inc.php @@ -1,22 +1,22 @@ GetOne('select @@rowcount'); } - + function BeginTrans() - { - + { + if ($this->transOff) return true; $this->transCnt += 1; - + $this->Execute('BEGIN TRAN'); return true; } - - function CommitTrans($ok=true) - { + + function CommitTrans($ok=true) + { if ($this->transOff) return true; - + if (!$ok) return $this->RollbackTrans(); - + $this->transCnt -= 1; $this->Execute('COMMIT TRAN'); return true; } - + function RollbackTrans() { if ($this->transOff) return true; @@ -81,28 +81,28 @@ class ADODB_sybase extends ADOConnection { $this->Execute('ROLLBACK TRAN'); return true; } - + // http://www.isug.com/Sybase_FAQ/ASE/section6.1.html#6.1.4 - function RowLock($tables,$where) + function RowLock($tables,$where) { if (!$this->_hastrans) $this->BeginTrans(); $tables = str_replace(',',' HOLDLOCK,',$tables); return $this->GetOne("select top 1 null as ignore from $tables HOLDLOCK where $where"); - - } - + + } + function SelectDB($dbName) { $this->databaseName = $dbName; if ($this->_connectionID) { - return @sybase_select_db($dbName); + return @sybase_select_db($dbName); } - else return false; + else return false; } /* Returns: the last error message from previous database operation - Note: This function is NOT available for Microsoft SQL Server. */ + Note: This function is NOT available for Microsoft SQL Server. */ - function ErrorMsg() + function ErrorMsg() { if ($this->_logsql) return $this->_errorMsg; $this->_errorMsg = sybase_get_last_message(); @@ -113,36 +113,36 @@ class ADODB_sybase extends ADOConnection { function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) { if (!function_exists('sybase_connect')) return false; - + $this->_connectionID = sybase_connect($argHostname,$argUsername,$argPassword); if ($this->_connectionID === false) return false; if ($argDatabasename) return $this->SelectDB($argDatabasename); - return true; + return true; } // returns true or false function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { if (!function_exists('sybase_connect')) return false; - + $this->_connectionID = sybase_pconnect($argHostname,$argUsername,$argPassword); if ($this->_connectionID === false) return false; if ($argDatabasename) return $this->SelectDB($argDatabasename); - return true; + return true; } - + // returns query ID if successful, otherwise false function _query($sql,$inputarr) { global $ADODB_COUNTRECS; - + if ($ADODB_COUNTRECS == false && ADODB_PHPVER >= 0x4300) return sybase_unbuffered_query($sql,$this->_connectionID); else return sybase_query($sql,$this->_connectionID); } - + // See http://www.isug.com/Sybase_FAQ/ASE/section6.2.html#6.2.12 - function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) + function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) { if ($secs2cache > 0) {// we do not cache rowcount, so we have to load entire recordset $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); @@ -150,31 +150,31 @@ class ADODB_sybase extends ADOConnection { } $cnt = ($nrows > 0) ? $nrows : 0; if ($offset > 0 && $cnt) $cnt += $offset; - - $this->Execute("set rowcount $cnt"); + + $this->Execute("set rowcount $cnt"); $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); - $this->Execute("set rowcount 0"); - + $this->Execute("set rowcount 0"); + return $rs; } // returns true or false function _close() - { + { return @sybase_close($this->_connectionID); } - + function UnixDate($v) { return ADORecordSet_array_sybase::UnixDate($v); } - + function UnixTimeStamp($v) { return ADORecordSet_array_sybase::UnixTimeStamp($v); - } - - + } + + # Added 2003-10-05 by Chris Phillipson # Used ASA SQL Reference Manual -- http://sybooks.sybase.com/onlinebooks/group-aw/awg0800e/dbrfen8/@ebt-link;pt=16756?target=%25N%15_12018_START_RESTART_N%25 @@ -238,7 +238,7 @@ class ADODB_sybase extends ADOConnection { } return $s; } - + # Added 2003-10-07 by Chris Phillipson # Used ASA SQL Reference Manual -- http://sybooks.sybase.com/onlinebooks/group-aw/awg0800e/dbrfen8/@ebt-link;pt=5981;uf=0?target=0;window=new;showtoc=true;book=dbrfen8 # to convert similar Microsoft SQL*Server (mssql) API into Sybase compatible version @@ -256,7 +256,7 @@ class ADODB_sybase extends ADOConnection { return false; } } - + /*-------------------------------------------------------------------------------------- Class Name: Recordset --------------------------------------------------------------------------------------*/ @@ -265,16 +265,16 @@ $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 { +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); + 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,$mode=false) { - if ($mode === false) { + if ($mode === false) { global $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE; } @@ -282,12 +282,12 @@ class ADORecordset_sybase extends ADORecordSet { else $this->fetchMode = $mode; return $this->ADORecordSet($id,$mode); } - - /* Returns: an object containing field information. + + /* 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) + function &FetchField($fieldOffset = -1) { if ($fieldOffset != -1) { $o = @sybase_fetch_field($this->_queryID, $fieldOffset); @@ -299,20 +299,20 @@ class ADORecordset_sybase extends ADORecordSet { 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) + + function _seek($row) { return @sybase_data_seek($this->_queryID, $row); - } + } - function _fetch($ignore_fields=false) + function _fetch($ignore_fields=false) { if ($this->fetchMode == ADODB_FETCH_NUM) { $this->fields = @sybase_fetch_row($this->_queryID); @@ -332,19 +332,19 @@ class ADORecordset_sybase extends ADORecordSet { return false; } - + /* 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); + return @sybase_free_result($this->_queryID); } - + // sybase/mssql uses a default date like Dec 30 2000 12:00AM function UnixDate($v) { return ADORecordSet_array_sybase::UnixDate($v); } - + function UnixTimeStamp($v) { return ADORecordSet_array_sybase::UnixTimeStamp($v); @@ -356,25 +356,25 @@ class ADORecordSet_array_sybase extends ADORecordSet_array { { $this->ADORecordSet_array($id); } - + // sybase/mssql uses a default date like Dec 30 2000 12:00AM function UnixDate($v) { global $ADODB_sybase_mths; - + //Dec 30 2000 12:00AM if (!ereg( "([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})" ,$v, $rr)) return parent::UnixDate($v); - + if ($rr[3] <= TIMESTAMP_FIRST_YEAR) 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; @@ -383,11 +383,11 @@ class ADORecordSet_array_sybase extends ADORecordSet_array { 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] <= TIMESTAMP_FIRST_YEAR) return 0; - + $themth = substr(strtoupper($rr[1]),0,3); $themth = $ADODB_sybase_mths[$themth]; if ($themth <= 0) return false; - + switch (strtoupper($rr[6])) { case 'P': if ($rr[4]<12) $rr[4] += 12; diff --git a/lib/WikiDB/adodb/drivers/adodb-vfp.inc.php b/lib/WikiDB/adodb/drivers/adodb-vfp.inc.php index 5f5c1523d..0f761775d 100644 --- a/lib/WikiDB/adodb/drivers/adodb-vfp.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-vfp.inc.php @@ -1,13 +1,13 @@ ADODB_odbc(); } - + function Time() { return time(); } - - + + function BeginTrans() { return false;} - + // quote string to be sent back to database function qstr($s,$nofixquotes=false) { @@ -52,24 +52,24 @@ class ADODB_vfp extends ADODB_odbc { return "'".$s."'"; } - + // TOP requires ORDER BY for VFP function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) { $this->hasTop = preg_match('/ORDER[ \t\r\n]+BY/is',$sql) ? 'top' : false; return ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); } - + }; - -class ADORecordSet_vfp extends ADORecordSet_odbc { - - var $databaseType = "vfp"; - +class ADORecordSet_vfp extends ADORecordSet_odbc { + + var $databaseType = "vfp"; + + function ADORecordSet_vfp($id,$mode=false) { return $this->ADORecordSet_odbc($id,$mode); @@ -87,15 +87,15 @@ class ADORecordSet_vfp extends ADORecordSet_odbc { 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'; } } diff --git a/lib/WikiDB/backend.php b/lib/WikiDB/backend.php index fe458e098..1802f9e58 100644 --- a/lib/WikiDB/backend.php +++ b/lib/WikiDB/backend.php @@ -50,7 +50,7 @@ //:serial (types are scalars: strings, ints, bools) -*/ +*/ /** * A WikiDB_backend handles the storage and retrieval of data for a WikiDB. @@ -116,7 +116,7 @@ class WikiDB_backend function update_pagedata($pagename, $newdata) { trigger_error("virtual", E_USER_ERROR); } - + /** * Get the current version number for a page. @@ -128,7 +128,7 @@ class WikiDB_backend function get_latest_version($pagename) { trigger_error("virtual", E_USER_ERROR); } - + /** * Get preceding version number. * @@ -140,7 +140,7 @@ class WikiDB_backend function get_previous_version($pagename, $version) { trigger_error("virtual", E_USER_ERROR); } - + /** * Get revision meta-data and content. * @@ -267,7 +267,7 @@ class WikiDB_backend } $this->set_versiondata($pagename, $version, $data); } - + /** * Set links for page. * @@ -278,7 +278,7 @@ class WikiDB_backend function set_links($pagename, $links) { trigger_error("virtual", E_USER_ERROR); } - + /** * Find pages which link to or are linked from a page. * @@ -304,7 +304,7 @@ class WikiDB_backend include_once('lib/WikiDB/backend/dumb/AllRevisionsIter.php'); return new WikiDB_backend_dumb_AllRevisionsIter($this, $pagename); } - + /** * Get all pages in the database. * @@ -327,7 +327,7 @@ class WikiDB_backend function get_all_pages($include_defaulted, $orderby=false, $limit='', $exclude='') { trigger_error("virtual", E_USER_ERROR); } - + /** * Title or full text search. * @@ -523,7 +523,7 @@ class WikiDB_backend $search = strtolower(trim($search)); if (!$search) return array(array(),array()); - + $words = preg_split('/\s+/', $search); $exclude = array(); foreach ($words as $key => $word) { @@ -557,7 +557,7 @@ class WikiDB_backend return array(0, $limit); } } - + /** * Handle sortby requests for the DB iterator and table header links. * Prefix the column with + or - like "+pagename","-mtime", ... @@ -697,7 +697,7 @@ class WikiDB_backend_iterator if (!empty($this->_pages)) return count($this->_pages); else - return 0; + return 0; } function asArray() { @@ -711,7 +711,7 @@ class WikiDB_backend_iterator return $result; } } - + /** * limit - if empty the pagelist iterator will do nothing. * Some backends limit the result set itself (dba, file, flatfile), diff --git a/lib/WikiDB/backend/ADODB_mssql.php b/lib/WikiDB/backend/ADODB_mssql.php index ff6f284ca..bf216efef 100644 --- a/lib/WikiDB/backend/ADODB_mssql.php +++ b/lib/WikiDB/backend/ADODB_mssql.php @@ -27,7 +27,7 @@ extends WikiDB_backend_ADODB $this->_prefix = isset($dbparams['prefix']) ? $dbparams['prefix'] : ''; } - + /** * Pack tables. */ @@ -112,5 +112,5 @@ extends WikiDB_backend_ADODB // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/ADODB_mssqlnative.php b/lib/WikiDB/backend/ADODB_mssqlnative.php index 33992bed1..0d34bdc66 100644 --- a/lib/WikiDB/backend/ADODB_mssqlnative.php +++ b/lib/WikiDB/backend/ADODB_mssqlnative.php @@ -27,7 +27,7 @@ extends WikiDB_backend_ADODB $this->_prefix = isset($dbparams['prefix']) ? $dbparams['prefix'] : ''; } - + /** * Pack tables. */ @@ -111,7 +111,7 @@ extends WikiDB_backend_ADODB if ($relation) { $dbh->Execute("INSERT INTO $link_tbl (linkfrom, linkto, relation)" . " VALUES ($pageid, $linkid, $relation)"); - } else { + } else { $dbh->Execute("INSERT INTO $link_tbl (linkfrom, linkto)" . " VALUES ($pageid, $linkid)"); } @@ -199,7 +199,7 @@ extends WikiDB_backend_ADODB if ($relation) { $dbh->Execute("INSERT INTO $link_tbl (linkfrom, linkto, relation)" . " VALUES ($pageid, $linkid, $relation)"); - } else { + } else { $dbh->Execute("INSERT INTO $link_tbl (linkfrom, linkto)" . " VALUES ($pageid, $linkid)"); } @@ -244,5 +244,5 @@ extends WikiDB_backend_ADODB // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/ADODB_mysql.php b/lib/WikiDB/backend/ADODB_mysql.php index 23ae3436d..2703e9c1a 100644 --- a/lib/WikiDB/backend/ADODB_mysql.php +++ b/lib/WikiDB/backend/ADODB_mysql.php @@ -36,7 +36,7 @@ extends WikiDB_backend_ADODB function WikiDB_backend_ADODB_mysql($dbparams) { $this->WikiDB_backend_ADODB($dbparams); if (!$this->_dbh->_connectionID) return; - + $this->_serverinfo = $this->_dbh->ServerInfo(); if (!empty($this->_serverinfo['version'])) { $arr = explode('.',$this->_serverinfo['version']); @@ -62,7 +62,7 @@ extends WikiDB_backend_ADODB } } } - + /** * Kill timed out processes. ( so far only called on about every 50-th save. ) */ @@ -109,7 +109,7 @@ extends WikiDB_backend_ADODB if (!$result or $result[0] == 0) { trigger_error( "WARNING: Couldn't obtain application lock " . $lock . "\n
", E_USER_WARNING); - return; + return; } } if (DO_FULL_LOCK) { @@ -166,7 +166,7 @@ extends WikiDB_backend_ADODB return $cache[$pagename]; } } - + // attributes play this game. if ($pagename === '') return 0; @@ -199,10 +199,10 @@ extends WikiDB_backend_ADODB function set_versiondata($pagename, $version, $data) { $dbh = &$this->_dbh; $version_tbl = $this->_table_names['version_tbl']; - + $minor_edit = (int) !empty($data['is_minor_edit']); unset($data['is_minor_edit']); - + $mtime = (int)$data['mtime']; unset($data['mtime']); assert(!empty($mtime)); @@ -210,7 +210,7 @@ extends WikiDB_backend_ADODB @$content = (string) $data['%content']; unset($data['%content']); unset($data['%pagedata']); - + $this->lock(array('page','recent','version','nonempty')); $dbh->BeginTrans( ); $dbh->CommitLock($version_tbl); @@ -229,7 +229,7 @@ extends WikiDB_backend_ADODB else $dbh->RollbackTrans( ); $this->unlock(array('page','recent','version','nonempty')); } - + }; // Local Variables: @@ -238,5 +238,5 @@ extends WikiDB_backend_ADODB // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/ADODB_oci8po.php b/lib/WikiDB/backend/ADODB_oci8po.php index c31e28d08..630bd94a3 100644 --- a/lib/WikiDB/backend/ADODB_oci8po.php +++ b/lib/WikiDB/backend/ADODB_oci8po.php @@ -30,7 +30,7 @@ extends WikiDB_backend_ADODB $this->_prefix = isset($dbparams['prefix']) ? $dbparams['prefix'] : ''; } - + /** * Pack tables. */ @@ -96,7 +96,7 @@ extends WikiDB_backend_ADODB . "OR DBMS_LOB.INSTR(content, '$word') > 0"; } */ - + /** * Serialize data */ @@ -136,7 +136,7 @@ extends WikiDB_backend_ADODB $entry->user, $entry->request_method, $entry->request, - $entry->request_uri, + $entry->request_uri, $entry->request_args, $entry->_ncsa_time($entry->time), $entry->status, @@ -172,5 +172,5 @@ extends WikiDB_backend_ADODB_search // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/ADODB_postgres7.php b/lib/WikiDB/backend/ADODB_postgres7.php index 81824ea08..72a96d427 100644 --- a/lib/WikiDB/backend/ADODB_postgres7.php +++ b/lib/WikiDB/backend/ADODB_postgres7.php @@ -161,5 +161,5 @@ extends WikiDB_backend_ADODB_search // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/ADODB_sqlite.php b/lib/WikiDB/backend/ADODB_sqlite.php index c2f495ad6..6daddd8d5 100644 --- a/lib/WikiDB/backend/ADODB_sqlite.php +++ b/lib/WikiDB/backend/ADODB_sqlite.php @@ -26,7 +26,7 @@ extends WikiDB_backend_ADODB } $this->WikiDB_backend_ADODB($dbparams); } - + function _get_pageid($pagename, $create_if_missing = false) { $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; @@ -41,7 +41,7 @@ extends WikiDB_backend_ADODB $row = $dbh->GetRow($query); if (! $row ) { - // atomic version + // atomic version // TODO: we have auto-increment since sqlite-2.3.4 // http://www.sqlite.org/faq.html#q1 $rs = $dbh->Execute(sprintf("INSERT INTO $page_tbl" @@ -62,5 +62,5 @@ extends WikiDB_backend_ADODB // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/PearDB.php b/lib/WikiDB/backend/PearDB.php index 5cc120349..62d2f1f03 100644 --- a/lib/WikiDB/backend/PearDB.php +++ b/lib/WikiDB/backend/PearDB.php @@ -40,7 +40,7 @@ extends WikiDB_backend $ErrorManager->pushErrorHandler(new WikiMethodCb($this, '_pear_notice_filter')); $this->_pearerrhandler = true; } - + // Open connection to database $this->_dsn = $dbparams['dsn']; $this->_dbparams = $dbparams; @@ -59,7 +59,7 @@ extends WikiDB_backend isset($dbparams['_tryroot_from_upgrade']) // hack! ? E_USER_WARNING : E_USER_ERROR); if (isset($dbparams['_tryroot_from_upgrade'])) - return; + return; } $dbh->setErrorHandling(PEAR_ERROR_CALLBACK, array($this, '_pear_error_callback')); @@ -84,9 +84,9 @@ extends WikiDB_backend 'maxversion' => "MAX(version)", 'notempty' => "<>''", 'iscontent' => "content<>''"); - + } - + /** * Close database connection. */ @@ -120,7 +120,7 @@ extends WikiDB_backend . " AND pagename='%s'", $dbh->escapeSimple($pagename))); } - + function get_all_pagenames() { $dbh = &$this->_dbh; extract($this->_table_names); @@ -136,7 +136,7 @@ extends WikiDB_backend . " FROM $nonempty_tbl, $page_tbl" . " WHERE $nonempty_tbl.id=$page_tbl.id"); } - + function increaseHitCount($pagename) { $dbh = &$this->_dbh; // Hits is the only thing we can update in a fast manner. @@ -192,7 +192,7 @@ extends WikiDB_backend $data = array(); $this->_get_pageid($pagename, true); // Creates page record } - + $hits = !empty($data['hits']) ? (int)$data['hits'] : 0; unset($data['hits']); @@ -239,7 +239,7 @@ extends WikiDB_backend } function _get_pageid($pagename, $create_if_missing = false) { - + // check id_cache global $request; $cache =& $request->_dbi->_cache->_id_cache; @@ -254,7 +254,7 @@ extends WikiDB_backend $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; - + $query = sprintf("SELECT id FROM $page_tbl WHERE pagename='%s'", $dbh->escapeSimple($pagename)); @@ -291,7 +291,7 @@ extends WikiDB_backend function get_previous_version($pagename, $version) { $dbh = &$this->_dbh; extract($this->_table_names); - + return (int)$dbh->getOne(sprintf("SELECT version" . " FROM $version_tbl, $page_tbl" @@ -305,7 +305,7 @@ extends WikiDB_backend $dbh->escapeSimple($pagename), $version)); } - + /** * Get version data. * @@ -321,7 +321,7 @@ extends WikiDB_backend assert(is_string($pagename) and $pagename != ""); assert($version > 0); - + //trigger_error("GET_REVISION $pagename $version $want_content", E_USER_NOTICE); // FIXME: optimization: sometimes don't get page data? if ($want_content) { @@ -358,10 +358,10 @@ extends WikiDB_backend base64_decode($query_result['versiondata']); } $data = $this->_unserialize($query_result['versiondata']); - + $data['mtime'] = $query_result['mtime']; $data['is_minor_edit'] = !empty($query_result['minor_edit']); - + if (isset($query_result['content'])) $data['%content'] = $query_result['content']; elseif ($query_result['have_content']) @@ -387,10 +387,10 @@ extends WikiDB_backend function set_versiondata($pagename, $version, $data) { $dbh = &$this->_dbh; $version_tbl = $this->_table_names['version_tbl']; - + $minor_edit = (int) !empty($data['is_minor_edit']); unset($data['is_minor_edit']); - + $mtime = (int)$data['mtime']; unset($data['mtime']); assert(!empty($mtime)); @@ -399,7 +399,7 @@ extends WikiDB_backend unset($data['%content']); unset($data['%pagedata']); - + $this->lock(); $id = $this->_get_pageid($pagename, true); @@ -415,10 +415,10 @@ extends WikiDB_backend $this->_update_recent_table($id); $this->_update_nonempty_table($id); - + $this->unlock(); } - + /** * Delete an old revision of a page. */ @@ -469,7 +469,7 @@ extends WikiDB_backend function purge_page($pagename) { $dbh = &$this->_dbh; extract($this->_table_names); - + $this->lock(); if ( ($id = $this->_get_pageid($pagename, false)) ) { $dbh->query("DELETE FROM $nonempty_tbl WHERE id=$id"); @@ -543,7 +543,7 @@ extends WikiDB_backend } $this->unlock(); } - + /** * Find pages which link to or are linked from a page. * @@ -589,7 +589,7 @@ extends WikiDB_backend } else { $result = $dbh->query($sql); } - + return new WikiDB_backend_PearDB_iter($this, $result); } @@ -672,7 +672,7 @@ extends WikiDB_backend } return new WikiDB_backend_PearDB_iter($this, $result, $options); } - + /** * Title search. * Todo: exclude @@ -691,7 +691,7 @@ extends WikiDB_backend if (!class_exists($searchclass)) $searchclass = "WikiDB_backend_PearDB_search"; $searchobj = new $searchclass($search, $dbh); - + $table = "$nonempty_tbl, $page_tbl"; $join_clause = "$nonempty_tbl.id=$page_tbl.id"; $fields = $this->page_tbl_fields; @@ -709,7 +709,7 @@ extends WikiDB_backend $callback = new WikiMethodCb($searchobj, "_pagename_match_clause"); } $search_clause = $search->makeSqlClauseObj($callback); - + $sql = "SELECT $fields FROM $table" . " WHERE $join_clause" . " AND ($search_clause)" @@ -720,7 +720,7 @@ extends WikiDB_backend } else { $result = $dbh->query($sql); } - + $iter = new WikiDB_backend_PearDB_iter($this, $result); $iter->stoplisted = @$searchobj->stoplisted; return $iter; @@ -810,8 +810,8 @@ extends WikiDB_backend $pick = array(); if ($since) $pick[] = "mtime >= $since"; - - + + if ($include_all_revisions) { // Include all revisions of each page. $table = "$page_tbl, $version_tbl"; @@ -831,7 +831,7 @@ extends WikiDB_backend $join_clause = "$page_tbl.id=$recent_tbl.id"; $table .= ", $version_tbl"; $join_clause .= " AND $version_tbl.id=$page_tbl.id"; - + if ($exclude_major_revisions) { // Include only most recent minor revision $pick[] = 'version=latestminor'; @@ -916,7 +916,7 @@ extends WikiDB_backend function rename_page ($pagename, $to) { $dbh = &$this->_dbh; extract($this->_table_names); - + $this->lock(); if (($id = $this->_get_pageid($pagename, false)) ) { if ($new = $this->_get_pageid($to, false)) { @@ -976,7 +976,7 @@ extends WikiDB_backend //. " AND content<>''" . " AND content $notempty" . ( $pageid ? " AND $recent_tbl.id=$pageid" : "")); - + $this->unlock(); } @@ -1000,7 +1000,7 @@ extends WikiDB_backend function _lock_tables($write_lock) { trigger_error("virtual", E_USER_ERROR); } - + /** * Release a write lock on the tables in the SQL database. * @@ -1044,7 +1044,7 @@ extends WikiDB_backend function _unserialize($data) { return empty($data) ? array() : unserialize($data); } - + /** * Callback for PEAR (DB) errors. * @@ -1055,7 +1055,7 @@ extends WikiDB_backend function _pear_error_callback($error) { if ($this->_is_false_error($error)) return; - + $this->_dbh->setErrorHandling(PEAR_ERROR_PRINT); // prevent recursive loops. $this->close(); trigger_error($this->_pear_error_message($error), E_USER_ERROR); @@ -1084,13 +1084,13 @@ extends WikiDB_backend //" <--kludge for brain-dead syntax coloring return false; } - + if (! in_array('ismanip', get_class_methods('DB'))) { // Pear shipped with PHP 4.0.4pl1 (and before, presumably) // does not have the DB::isManip method. return true; } - + if (DB::isManip($query)) { // If Pear thinks it's an isManip then it wouldn't have thrown // the error we're testing for.... @@ -1187,7 +1187,7 @@ extends WikiDB_backend_iterator // This shouldn't happen, I thought. $backend->_pear_error_callback($query_result); } - + $this->_backend = &$backend; $this->_result = $query_result; $this->_options = $field_list; @@ -1198,7 +1198,7 @@ extends WikiDB_backend_iterator return false; return $this->_result->numRows(); } - + function next() { if (!$this->_result) return false; @@ -1208,7 +1208,7 @@ extends WikiDB_backend_iterator $this->free(); return false; } - + return $record; } @@ -1247,7 +1247,7 @@ extends WikiDB_backend_PearDB_generic_iter $this->free(); return false; } - + $pagedata = $backend->_extract_page_data($record); $rec = array('pagename' => $record['pagename'], 'pagedata' => $pagedata); @@ -1256,7 +1256,7 @@ extends WikiDB_backend_PearDB_generic_iter $rec['versiondata'] = $backend->_extract_version_data($record); $rec['version'] = $record['version']; } - + return $rec; } } @@ -1273,5 +1273,5 @@ class WikiDB_backend_PearDB_search extends WikiDB_backend_search_sql // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/PearDB_ffpgsql.php b/lib/WikiDB/backend/PearDB_ffpgsql.php index 4662e0773..17cb45ce0 100644 --- a/lib/WikiDB/backend/PearDB_ffpgsql.php +++ b/lib/WikiDB/backend/PearDB_ffpgsql.php @@ -109,7 +109,7 @@ extends WikiDB_backend_PearDB_pgsql $data = array(); $this->_get_pageid($pagename, true); // Creates page record } - + if (isset($data['hits'])) { $hits = (int)$data['hits']; unset($data['hits']); @@ -159,7 +159,7 @@ extends WikiDB_backend_PearDB_pgsql // assert(is_string($pagename) and $pagename != ""); // assert($version > 0); - + //trigger_error("GET_REVISION $pagename $version $want_content", E_USER_NOTICE); // FIXME: optimization: sometimes don't get page data? if ($want_content) { @@ -194,7 +194,7 @@ extends WikiDB_backend_PearDB_pgsql } function _get_pageid($pagename, $create_if_missing = false) { - + // check id_cache global $request; $cache =& $request->_dbi->_cache->_id_cache; @@ -210,7 +210,7 @@ extends WikiDB_backend_PearDB_pgsql $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; $pagename = PAGE_PREFIX.$pagename; - + $query = sprintf("SELECT id FROM $page_tbl WHERE pagename='%s'", $dbh->escapeSimple($pagename)); @@ -236,7 +236,7 @@ extends WikiDB_backend_PearDB_pgsql function purge_page($pagename) { $dbh = &$this->_dbh; extract($this->_table_names); - + $this->lock(); if ( ($id = $this->_get_pageid($pagename, false)) ) { $dbh->query("DELETE FROM $nonempty_tbl WHERE id=$id"); @@ -305,7 +305,7 @@ extends WikiDB_backend_PearDB_pgsql } else { $result = $dbh->query($sql); } - + return new WikiDB_backend_PearDB_iter($this, $result); } @@ -429,8 +429,8 @@ extends WikiDB_backend_PearDB_pgsql $pick = array(); if ($since) $pick[] = "mtime >= $since"; - - + + if ($include_all_revisions) { // Include all revisions of each page. $table = "$page_tbl, $version_tbl"; @@ -450,7 +450,7 @@ extends WikiDB_backend_PearDB_pgsql $join_clause = "$page_tbl.id=$recent_tbl.id"; $table .= ", $version_tbl"; $join_clause .= " AND $version_tbl.id=$page_tbl.id"; - + if ($exclude_major_revisions) { // Include only most recent minor revision $pick[] = 'version=latestminor'; @@ -531,7 +531,7 @@ extends WikiDB_backend_PearDB_pgsql function rename_page ($pagename, $to) { $dbh = &$this->_dbh; extract($this->_table_names); - + $this->lock(); if (($id = $this->_get_pageid($pagename, false)) ) { if ($new = $this->_get_pageid($to, false)) { @@ -591,7 +591,7 @@ extends WikiDB_backend_PearDB_pgsql if (!class_exists($searchclass)) $searchclass = "WikiDB_backend_PearDB_search"; $searchobj = new $searchclass($search, $dbh); - + $table = "$nonempty_tbl, $page_tbl"; $join_clause = "$nonempty_tbl.id=$page_tbl.id"; $fields = $this->page_tbl_fields; @@ -618,7 +618,7 @@ extends WikiDB_backend_PearDB_pgsql $search_clause = "substring(plugin_wiki_page.pagename from 0 for $len) = '$pat') AND ("; $search_clause .= $search->makeSqlClauseObj($callback); } - + $sql = "SELECT $fields FROM $table" . " WHERE $join_clause" . " AND ($search_clause)" @@ -629,7 +629,7 @@ extends WikiDB_backend_PearDB_pgsql } else { $result = $dbh->query($sql); } - + $iter = new WikiDB_backend_PearDB_iter($this, $result); $iter->stoplisted = @$searchobj->stoplisted; return $iter; @@ -706,5 +706,5 @@ extends WikiDB_backend_PearDB_pgsql_search // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/PearDB_mysql.php b/lib/WikiDB/backend/PearDB_mysql.php index 1b9e49afb..230b01997 100644 --- a/lib/WikiDB/backend/PearDB_mysql.php +++ b/lib/WikiDB/backend/PearDB_mysql.php @@ -42,7 +42,7 @@ extends WikiDB_backend_PearDB } } } - + /** * Kill timed out processes. ( so far only called on about every 50-th save. ) */ @@ -67,10 +67,10 @@ extends WikiDB_backend_PearDB function set_versiondata($pagename, $version, $data) { $dbh = &$this->_dbh; $version_tbl = $this->_table_names['version_tbl']; - + $minor_edit = (int) !empty($data['is_minor_edit']); unset($data['is_minor_edit']); - + $mtime = (int)$data['mtime']; unset($data['mtime']); assert(!empty($mtime)); @@ -78,7 +78,7 @@ extends WikiDB_backend_PearDB @$content = (string) $data['%content']; unset($data['%content']); unset($data['%pagedata']); - + $this->lock(); $id = $this->_get_pageid($pagename, true); // requires PRIMARY KEY (id,version)! @@ -163,7 +163,7 @@ extends WikiDB_backend_PearDB . ( $pageid ? " AND $recent_tbl.id=$pageid" : "")); } */ - + /** * Pack tables. */ @@ -231,5 +231,5 @@ extends WikiDB_backend_PearDB_search // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/PearDB_oci8.php b/lib/WikiDB/backend/PearDB_oci8.php index c8cedf636..9a3e02a3a 100644 --- a/lib/WikiDB/backend/PearDB_oci8.php +++ b/lib/WikiDB/backend/PearDB_oci8.php @@ -48,7 +48,7 @@ extends WikiDB_backend_PearDB_pgsql */ function _lock_tables($write_lock=true) { $dbh = &$this->_dbh; - + // Not sure if we really need to lock tables here, the Oracle row // locking mechanism should be more than enough // For the time being, lets stay on the safe side and lock... @@ -89,7 +89,7 @@ extends WikiDB_backend_PearDB_pgsql $entry->user, $entry->request_method, $entry->request, - $entry->request_uri, + $entry->request_uri, $entry->request_args, $entry->_ncsa_time($entry->time), $entry->status, @@ -125,5 +125,5 @@ extends WikiDB_backend_PearDB_search // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/PearDB_pgsql.php b/lib/WikiDB/backend/PearDB_pgsql.php index 39e6659a3..601006b15 100644 --- a/lib/WikiDB/backend/PearDB_pgsql.php +++ b/lib/WikiDB/backend/PearDB_pgsql.php @@ -42,7 +42,7 @@ extends WikiDB_backend_PearDB return true; // Ignore error return false; } - + /** * Pack tables. * NOTE: Only the table owner can do this. Either fix the schema or setup autovacuum. @@ -107,10 +107,10 @@ extends WikiDB_backend_PearDB function _todo_set_versiondata($pagename, $version, $data) { $dbh = &$this->_dbh; $version_tbl = $this->_table_names['version_tbl']; - + $minor_edit = (int) !empty($data['is_minor_edit']); unset($data['is_minor_edit']); - + $mtime = (int)$data['mtime']; unset($data['mtime']); assert(!empty($mtime)); @@ -118,7 +118,7 @@ extends WikiDB_backend_PearDB @$content = (string) $data['%content']; unset($data['%content']); unset($data['%pagedata']); - + $this->lock(); $id = $this->_get_pageid($pagename, true); $dbh->query(sprintf("DELETE FROM version WHERE id=%d AND version=%d", $id, $version)); @@ -147,7 +147,7 @@ extends WikiDB_backend_PearDB function _todo_rename_page ($pagename, $to) { $dbh = &$this->_dbh; extract($this->_table_names); - + $this->lock(); if (($id = $this->_get_pageid($pagename, false)) ) { if ($new = $this->_get_pageid($to, false)) { @@ -216,7 +216,7 @@ extends WikiDB_backend_PearDB if (!class_exists($searchclass)) $searchclass = "WikiDB_backend_PearDB_search"; $searchobj = new $searchclass($search, $dbh); - + $table = "$nonempty_tbl, $page_tbl"; $join_clause = "$nonempty_tbl.id=$page_tbl.id"; $fields = $this->page_tbl_fields; @@ -240,7 +240,7 @@ extends WikiDB_backend_PearDB $callback = new WikiMethodCb($searchobj, "_pagename_match_clause"); $search_clause = $search->makeSqlClauseObj($callback); } - + $sql = "SELECT $fields FROM $table" . " WHERE $join_clause" . " AND ($search_clause)" @@ -251,7 +251,7 @@ extends WikiDB_backend_PearDB } else { $result = $dbh->query($sql); } - + $iter = new WikiDB_backend_PearDB_iter($this, $result); $iter->stoplisted = @$searchobj->stoplisted; return $iter; @@ -291,7 +291,7 @@ select * from stat('select idxfti from version') order by ndoc desc, nentry desc see | 42 | 69 default | 39 | 124 */ - + /** * use tsearch2. See schemas/psql-tsearch2.sql and /usr/share/postgresql/contrib/tsearch2.sql * TODO: don't parse the words into nodes. rather replace "[ +]" with & and "-" with "!" and " or " with "|" @@ -323,5 +323,5 @@ select * from stat('select idxfti from version') order by ndoc desc, nentry desc // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/PearDB_sqlite.php b/lib/WikiDB/backend/PearDB_sqlite.php index 45a3c2a4f..ebd6de239 100644 --- a/lib/WikiDB/backend/PearDB_sqlite.php +++ b/lib/WikiDB/backend/PearDB_sqlite.php @@ -91,12 +91,12 @@ extends WikiDB_backend_PearDB } }; - + // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/cvs.php b/lib/WikiDB/backend/cvs.php index 9389f37b7..114d547ca 100644 --- a/lib/WikiDB/backend/cvs.php +++ b/lib/WikiDB/backend/cvs.php @@ -95,12 +95,12 @@ extends WikiDB_backend // doesn't exist, need to create it and the replace the wiki // document directory. $this->_mkdir( $this->_repository, 0775 ); - + // assume that the repository is a local directory, prefix :local: if ( !ereg( "^:local:", $this->_repository ) ) { $this->_repository = ":local:" . $this->_repository; } - + $cmdLine = sprintf( "cvs -d \"%s\" init", $this->_repository); $this->_execCommand( $cmdLine, $cmdOutput, true ); @@ -109,14 +109,14 @@ extends WikiDB_backend ."%s V R", $this->_docDir, $this->_repository, $this->_module_name ); $this->_execCommand( $cmdLine, $cmdOutput, true ); - + // remove the wiki directory and check it out from the // CVS repository $cmdLine = sprintf( "rm -fr %s; cd %s; cvs -d \"%s\" co %s", $this->_docDir, dirname($this->_docDir), $this->_repository, $this->_module_name); $this->_execCommand( $cmdLine, $cmdOutput, true ); - + // add the default pages using the update_pagedata $metaData = array(); $metaData[$AUTHOR] = "PhpWiki -- CVS Backend"; @@ -126,7 +126,7 @@ extends WikiDB_backend while ( $entry = readdir( $d ) ) { $filename = $dbparam[CVS_PAGE_SOURCE] . "/" . $entry; $this->_cvsDebug( sprintf("Found [%s] in [%s]", $entry, $dbparam[CVS_PAGE_SOURCE]) ); - + if ( is_file( $filename ) ) { $metaData[CMD_CONTENT] = join('',file($filename)); $this->update_pagedata( $entry, $metaData ); @@ -134,7 +134,7 @@ extends WikiDB_backend } closedir( $d ); } - + // ensure that the results of the is_dir are cleared clearstatcache(); } @@ -151,7 +151,7 @@ extends WikiDB_backend $metaFile = $this->_docDir . "/CVS/_" . $pagename; if ( file_exists( $metaFile ) ) { - + $megaHash = unserialize(join( '',$this->_readFileWithPath($metaFile))); @@ -258,7 +258,7 @@ extends WikiDB_backend function get_versiondata($pagename, $version, $want_content = false) { $this->_cvsDebug( "get_versiondata: [$pagename] [$version] [$want_content]" ); - + $filedata = ""; if ( $want_content ) { // retrieve the version from the repository @@ -266,7 +266,7 @@ extends WikiDB_backend $this->_repository, $version, $this->_module_name, $pagename ); $this->_execCommand( $cmdLine, $filedata, true ); - + // TODO: DEBUG: 5 is a magic number here, depending on the // TODO: DEBUG: version of cvs used here, 5 might have to // TODO: DEBUG: change. Basically find a more reliable way of @@ -302,7 +302,7 @@ extends WikiDB_backend foreach ( $rVal as $key => $value ) { $this->_cvsDebug( "$key == [$value]" ); } - + return $rVal; } @@ -321,14 +321,14 @@ extends WikiDB_backend $this->_cvsDebug( "delete_page [$pagename]") ; $filename = $this->_docDir . "/" . $pagename; $metaFile = $this->_docDir . "/CVS/_" . $pagename; - + // obtain a write block before deleting the file if ( $this->_deleteFile( $filename ) == false ) { return false; } - + $this->_deleteFile( $metaFile ); - + $this->_removePage( $pagename ); return true; @@ -439,7 +439,7 @@ extends WikiDB_backend arsort( $mp, SORT_NUMERIC ); } $returnVal = array(); - + while ( (list($key, $val) = each($a)) && $limit > 0 ) { $returnVal[] = $key; $limit--; @@ -474,7 +474,7 @@ extends WikiDB_backend } } else if ( isset( $params['since'] ) ) { while ( (list($key, $val) = each($a)) ) { - + if ( $val > $params['since'] ) { $returnVal[] = $key; } @@ -546,7 +546,7 @@ extends WikiDB_backend $this->_execCommand( $cmdLine, $cmdOutput, true ); return true; } - + // // ..-.-..-.-..-.-.. .--..-......-.--. --.-....----..... // The rest are all internal methods, not to be used @@ -628,7 +628,7 @@ extends WikiDB_backend $cmdLine = sprintf("cd %s; cvs remove %s 2>&1; cvs commit -m '%s' " ."%s 2>&1", $this->_docDir, $pagename, "remove page", $pagename ); - + $this->_execCommand( $cmdLine, $cmdRemoveOutput, true ); } @@ -702,7 +702,7 @@ extends WikiDB_backend else { $rVal = true; } - + return ($rVal && @mkdir( $path, $mode ) ); } @@ -722,7 +722,7 @@ extends WikiDB_backend function _deleteFile( $filename ) { if( $fd = fopen($filename, 'a') ) { - + $locked = flock($fd,2); // Exclusive blocking lock if (!$locked) { @@ -767,7 +767,7 @@ extends WikiDB_backend if ( $this->_debug_file == "" ) { return; } - + if ( !file_exists( $this->_debug_file ) ) { $this->_createFile( $this->_debug_file, 0755 ); } @@ -778,7 +778,7 @@ extends WikiDB_backend fclose( $fdlock ); return; } - + $fdappend = @fopen( $this->_debug_file, 'a' ); fwrite( $fdappend, ($msg . "\n") ); fclose( $fdappend ); @@ -899,7 +899,7 @@ extends WikiDB_backend $val = str_replace( "\\}", "}", $val ); $val = str_replace( "\\;", ";", $val ); $val = str_replace( "\\\"", "\"", $val ); - + return $val; } @@ -983,7 +983,7 @@ extends Cvs_Backend_Array_Iterator // TODO: searching files. $cmdLine = sprintf( "grep -E -i '%s' %s > /dev/null 2>&1", $searchString, $fileName ); - + return ( WikiDB_backend_cvs::_execCommand( $cmdLine, $cmdOutput, false ) == 0 ); } @@ -1020,5 +1020,5 @@ extends Cvs_Backend_Array_Iterator // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/dba.php b/lib/WikiDB/backend/dba.php index 4fe4ac20b..132ec3156 100644 --- a/lib/WikiDB/backend/dba.php +++ b/lib/WikiDB/backend/dba.php @@ -41,5 +41,5 @@ extends WikiDB_backend_dbaBase // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/dbaBase.php b/lib/WikiDB/backend/dbaBase.php index 3bc608baa93fc562c8b8a1b4bfa8d3a1f38aff39..43b5e45170a226a68dc8c1c74b4b151cd5632cd7 100644 GIT binary patch delta 155 zcmX^5h4JfW#tr?fn1kopxmkus5y1!UOf p%Cx0CASt_pagename = $pagename; $this->_lastversion = -1; } - + /** * Get next revision in sequence. * @@ -42,10 +42,10 @@ extends WikiDB_backend_iterator if ($version) $vdata = $backend->get_versiondata($pagename, $version); //$backend->unlock(); - + if ($version == 0) return false; - + if (is_string($vdata) and !empty($vdata)) { $vdata1 = @unserialize($vdata); if (empty($vdata1)) { @@ -58,7 +58,7 @@ extends WikiDB_backend_iterator $rev = array('versiondata' => $vdata, 'pagename' => $pagename, 'version' => $version); - + if (!empty($vdata['%pagedata'])) { $rev['pagedata'] = $vdata['%pagedata']; } @@ -73,5 +73,5 @@ extends WikiDB_backend_iterator // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/dumb/BackLinkIter.php b/lib/WikiDB/backend/dumb/BackLinkIter.php index 4a368c199..05a23e8bf 100644 --- a/lib/WikiDB/backend/dumb/BackLinkIter.php +++ b/lib/WikiDB/backend/dumb/BackLinkIter.php @@ -17,7 +17,7 @@ extends WikiDB_backend_iterator $this->_backend = &$backend; $this->_target = $pagename; } - + function next() { while ($page = $this->_pages->next()) { $pagename = $page['pagename']; @@ -30,7 +30,7 @@ extends WikiDB_backend_iterator } } } - + function free() { $this->_pages->free(); } diff --git a/lib/WikiDB/backend/dumb/MostPopularIter.php b/lib/WikiDB/backend/dumb/MostPopularIter.php index f184255f0..9a89cae1f 100644 --- a/lib/WikiDB/backend/dumb/MostPopularIter.php +++ b/lib/WikiDB/backend/dumb/MostPopularIter.php @@ -42,7 +42,7 @@ extends WikiDB_backend_iterator function next() { return array_shift($this->_pages); } - + function free() { unset($this->_pages); } diff --git a/lib/WikiDB/backend/dumb/MostRecentIter.php b/lib/WikiDB/backend/dumb/MostRecentIter.php index e4dd2feb5..09f13eb51 100644 --- a/lib/WikiDB/backend/dumb/MostRecentIter.php +++ b/lib/WikiDB/backend/dumb/MostRecentIter.php @@ -57,11 +57,11 @@ extends WikiDB_backend_iterator array_splice($this->_revisions, $limit); } } - + function next() { return array_shift($this->_revisions); } - + function free() { unset($this->_revisions); } @@ -85,5 +85,5 @@ function WikiDB_backend_dumb_MostRecentIter_sortf_rev($a, $b) { // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/dumb/TextSearchIter.php b/lib/WikiDB/backend/dumb/TextSearchIter.php index 2c36a876e..347e471ee 100644 --- a/lib/WikiDB/backend/dumb/TextSearchIter.php +++ b/lib/WikiDB/backend/dumb/TextSearchIter.php @@ -27,14 +27,14 @@ extends WikiDB_backend_iterator function _get_content(&$page) { $backend = &$this->_backend; $pagename = $page['pagename']; - + if (!isset($page['versiondata'])) { $version = $backend->get_latest_version($pagename); $page['versiondata'] = $backend->get_versiondata($pagename, $version, true); } return $page['versiondata']['%content']; } - + function _match(&$page) { $text = $page['pagename']; if ($result = $this->_search->match($text)) { // first match the pagename only @@ -71,7 +71,7 @@ extends WikiDB_backend_iterator }*/ if (is_array($page)) $page['score'] = $score; - else + else $page->score = $score; return $page; } @@ -90,5 +90,5 @@ extends WikiDB_backend_iterator // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/cvs.php b/lib/WikiDB/cvs.php index 00d3b9092..0ed428512 100644 --- a/lib/WikiDB/cvs.php +++ b/lib/WikiDB/cvs.php @@ -16,11 +16,11 @@ require_once( 'lib/WikiDB/backend/cvs.php' ); */ class WikiDB_cvs extends WikiDB -{ +{ var $_backend; /** - * Constructor requires the DB parameters. + * Constructor requires the DB parameters. */ function WikiDB_cvs( $dbparams ) { if (loadPhpExtension('cvsclient')) diff --git a/lib/WikiDB/dba.php b/lib/WikiDB/dba.php index c6b97799d..99c42e168 100644 --- a/lib/WikiDB/dba.php +++ b/lib/WikiDB/dba.php @@ -24,5 +24,5 @@ class WikiDB_dba extends WikiDB // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WysiwygEdit/FCKeditor.php b/lib/WysiwygEdit/FCKeditor.php index 00f276634..8e317ea2b 100644 --- a/lib/WysiwygEdit/FCKeditor.php +++ b/lib/WysiwygEdit/FCKeditor.php @@ -61,28 +61,28 @@ oFCKeditor.ReplaceTextarea(); $out = HTML( JavaScript(" var oFCKeditor = new FCKeditor( '$htmltextid' ) ; -oFCKeditor.Value = '" . $textarea->_content[0]->asXML() . "';" +oFCKeditor.Value = '" . $textarea->_content[0]->asXML() . "';" . $this->_jsdefault . " oFCKeditor.Create();"), - HTML::div(array("id" => $this->_wikitextid, + HTML::div(array("id" => $this->_wikitextid, 'style' => 'display:none'), $wikitext), "\n"); return $out; } - + /* textarea only */ function Textarea_Replace ($textarea, $wikitext, $name='edit[content]') { $htmltextid = $this->_htmltextid; $textarea->SetAttr('id', $htmltextid); $out = HTML($textarea, - HTML::div(array("id" => $this->_wikitextid, + HTML::div(array("id" => $this->_wikitextid, 'style' => 'display:none'), $wikitext), "\n"); return $out; } - + /* via the PHP object */ function Textarea_PHP ($textarea, $wikitext, $name='edit[content]') { global $LANG; @@ -98,8 +98,8 @@ oFCKeditor.Create();"), $this->oFCKeditor->Config['AutoDetectLanguage'] = true ; $this->oFCKeditor->Config['DefaultLanguage'] = $LANG; $this->oFCKeditor->Create(); - - return HTML::div(array("id" => $this->_wikitextid, + + return HTML::div(array("id" => $this->_wikitextid, 'style' => 'display:none'), $wikitext); } diff --git a/lib/WysiwygEdit/Wikiwyg.php b/lib/WysiwygEdit/Wikiwyg.php index 6d996824c..24b6f232e 100644 --- a/lib/WysiwygEdit/Wikiwyg.php +++ b/lib/WysiwygEdit/Wikiwyg.php @@ -38,7 +38,7 @@ class WysiwygEdit_Wikiwyg extends WysiwygEdit { (Javascript('', array('src' => $this->BasePath . '/' . $js, 'language' => 'JavaScript'))); } - $doubleClickToEdit = ($GLOBALS['request']->getPref('doubleClickEdit') or ENABLE_DOUBLECLICKEDIT) + $doubleClickToEdit = ($GLOBALS['request']->getPref('doubleClickEdit') or ENABLE_DOUBLECLICKEDIT) ? 'true' : 'false'; if ($GLOBALS['request']->getArg('mode') && $GLOBALS['request']->getArg('mode') == 'wysiwyg'){ return JavaScript($this->_jsdefault . " @@ -64,7 +64,7 @@ class WysiwygEdit_Wikiwyg extends WysiwygEdit { ], styleSelector: [ 'label', 'p', 'h2', 'h3', 'h4', 'pre' - ], + ], controlLabels: { save: '"._("Apply changes")."', cancel: '"._("Exit toolbar")."', @@ -72,12 +72,12 @@ class WysiwygEdit_Wikiwyg extends WysiwygEdit { h3: '"._("Title 2")."', h4: '"._("Title 3")."', verbatim: '"._("Verbatim")."', - toc: '"._("Table of Contents")."', - wikitext: '"._("Insert Wikitext section")."', - sup: '"._("Sup")."', + toc: '"._("Table of Contents")."', + wikitext: '"._("Insert Wikitext section")."', + sup: '"._("Sup")."', sub: '"._("Sub")."', - preview: '"._("Preview")."', - save_button:'"._("Save")."' + preview: '"._("Preview")."', + save_button:'"._("Save")."' } }, wysiwyg: { @@ -97,12 +97,12 @@ class WysiwygEdit_Wikiwyg extends WysiwygEdit { function Textarea ($textarea, $wikitext, $name='edit[content]') { global $request; - + $htmltextid = $this->_htmltextid; $textarea->SetAttr('id', $htmltextid); $iframe0 = new RawXml(''); if ($request->getArg('mode') and $request->getArg('mode') == 'wysiwyg'){ - $out = HTML(HTML::div(array('class' => 'hint'), + $out = HTML(HTML::div(array('class' => 'hint'), _("Warning: This Wikiwyg editor has only Beta quality!")), $textarea, $iframe0, @@ -122,8 +122,8 @@ class WysiwygEdit_Wikiwyg extends WysiwygEdit { return $text; } - /* - * No special PHP HTML->Wikitext conversion needed. This is done in js thanksfully. + /* + * No special PHP HTML->Wikitext conversion needed. This is done in js thanksfully. * Avoided in editpage.php: PageEditor->getContent */ function ConvertAfter($text) { @@ -145,8 +145,8 @@ class WikiToHtml { } function convert() { - require_once("lib/BlockParser.php"); - $xmlcontent = TransformText($this->_wikitext, 2.0, $this->_request->getArg('pagename')); + require_once("lib/BlockParser.php"); + $xmlcontent = TransformText($this->_wikitext, 2.0, $this->_request->getArg('pagename')); $this->_html = $xmlcontent->AsXML(); $this->replace_inside_html(); @@ -165,7 +165,7 @@ class WikiToHtml { if ($charset != 'utf-8') { if ($charset == 'iso-8959-1') { $this->_html = utf8_decode($this->_html); - } else { + } else { // check for iconv support loadPhpExtension("iconv"); $this->_html = iconv("UTF-8", $charset, $this->_html); @@ -180,19 +180,19 @@ class WikiToHtml { function replace_known_plugins() { // If match a plugin $pattern = '/\<\;\?plugin\s+RichTable(.*)\?\>\;/Umsi'; - $replace_string = "replace_rich_table"; + $replace_string = "replace_rich_table"; $this->_html = preg_replace_callback($pattern, $replace_string, $this->_html); } - + // Replace unknown plugins by keyword Wikitext { tag } function replace_unknown_plugins() { $pattern = '/(\<\;\?plugin[^?]*\?\>\;)/Usi'; - $replace_string = + $replace_string = '

Wikitext {
\1
}

'; - + $this->_html = preg_replace($pattern, $replace_string, $this->_html); @@ -202,51 +202,51 @@ class WikiToHtml { function clean_links() { // Existing links // FIXME: use VIRTUAL_PATH - $pattern = '/\])*\>/Umsi'; - $replace_string = ''; + $pattern = '/\])*\>/Umsi'; + $replace_string = ''; $this->_html = preg_replace($pattern, $replace_string, $this->_html) ; // Non existing links $pattern = '/\])*\>/Umsi'; $replace_string = ''; - + $this->_html = preg_replace($pattern, $replace_string, $this->_html) ; - // Clean underline + // Clean underline $pattern = '/\(.*)\<\/u\>(\.*\<\/a\>/Umsi'; - $replace_string = + $replace_string = '\2" style="color:blue;">\1'; - + $this->_html = preg_replace($pattern, $replace_string, $this->_html) ; } - + // Put unknown tags in Wikitext {} function replace_tags() { // Replace old table format ( non plugin ) $pattern = '/(\ {0,4}(?:\S.*)?\|\S+\s*$.*?\<\/p\>)/ms'; - $replace_string = + $replace_string = '

Wikitext {
\1
}

'; - + $this->_html = preg_replace($pattern, $replace_string, $this->_html); } - - // Replace \n by
only in + + // Replace \n by
only in // tag to keep formatting function clean_plugin() { $pattern = '/(\<\;\?plugin.*\?\>\;)/Umsei'; $replace_string = 'preg_replace("/\n/Ums","
","\1")'; - + $this->_html = preg_replace($pattern, $replace_string, - $this->_html) ; + $this->_html) ; } @@ -256,43 +256,43 @@ class WikiToHtml { $replace_string = '\1 \2 \3'; $this->_html = preg_replace($pattern, $replace_string, - $this->_html) ; - } + $this->_html) ; + } } // This is called to replace the RichTable plugin by an html table -// $matched contains html

tags so +// $matched contains html

tags so // they are deleted before the conversion. function replace_rich_table($matched) { $plugin = $matched[1]; $unknown_options = "/colspan|rowspan|width|height/"; - + // if the plugin contains one of the options bellow // it won't be converted if (preg_match($unknown_options,$plugin)) - return $matched[0]."\n"; + return $matched[0]."\n"; else { //Replace unused $pattern = '/\/Umsi'; $replace_string = ""; - + $plugin = preg_replace($pattern, $replace_string, - $plugin) ; - + $plugin) ; + //replace unused

by \n $pattern = '/\<\/p\>/Umsi'; $replace_string = "\n"; - + $plugin = preg_replace($pattern, $replace_string, - $plugin) ; - + $plugin) ; + $plugin = ""; - - require_once("lib/BlockParser.php"); - $xmlcontent = TransformText($plugin, 2.0, $GLOBALS['request']->getArg('pagename')); + + require_once("lib/BlockParser.php"); + $xmlcontent = TransformText($plugin, 2.0, $GLOBALS['request']->getArg('pagename')); return $xmlcontent->AsXML(); } } diff --git a/lib/WysiwygEdit/htmlarea2.php b/lib/WysiwygEdit/htmlarea2.php index 4eb6478af..ba35b64e9 100644 --- a/lib/WysiwygEdit/htmlarea2.php +++ b/lib/WysiwygEdit/htmlarea2.php @@ -26,7 +26,7 @@ if (win_ie_ver >= 5.5) { document.write(''); } else { - document.write('function editor_generate() { return false; }'); + document.write('function editor_generate() { return false; }'); } ", array('version' => 'JavaScript1.2', diff --git a/lib/WysiwygEdit/htmlarea3.php b/lib/WysiwygEdit/htmlarea3.php index 0b86a0635..b40c32b64 100644 --- a/lib/WysiwygEdit/htmlarea3.php +++ b/lib/WysiwygEdit/htmlarea3.php @@ -19,7 +19,7 @@ class WysiwygEdit_htmlarea3 extends WysiwygEdit { return new RawXml(' - + @@ -32,7 +32,7 @@ function initEditor() { // comment the following two lines to see how customization works editor.generate(); return false; - + // BEGIN: code that adds custom buttons var cfg = editor.config; // this is the default configuration function clickHandler(editor, buttonId) { @@ -56,7 +56,7 @@ function initEditor() { cfg.registerButton("my-date", "Insert date/time", _editor_url+"ed_custom.gif", false, clickHandler); cfg.registerButton("my-bold-em", "Toggle bold/italic", _editor_url+"ed_custom.gif", false, clickHandler); cfg.registerButton("my-hilite", "Hilite selection", _editor_url+"ed_custom.gif", false, clickHandler); - + cfg.registerButton("my-sample", "Class: sample", _editor_url+"ed_custom.gif", false, function(editor) { if (HTMLArea.is_ie) { @@ -78,11 +78,11 @@ function initEditor() { } } ); - + //cfg.pageStyle = "body { background-color: #efd; } .hilite { background-color: yellow; } "+ // ".sample { color: green; font-family: monospace; }"; // add the new button to the toolbar - //cfg.toolbar.push(["linebreak", "my-toc", "my-date", "my-bold-em", "my-hilite", "my-sample"]); + //cfg.toolbar.push(["linebreak", "my-toc", "my-date", "my-bold-em", "my-hilite", "my-sample"]); // END: code that adds custom buttons editor.generate(); diff --git a/lib/WysiwygEdit/spaw.php b/lib/WysiwygEdit/spaw.php index 314575772..473785c5d 100644 --- a/lib/WysiwygEdit/spaw.php +++ b/lib/WysiwygEdit/spaw.php @@ -35,7 +35,7 @@ class WysiwygEdit_spaw extends WysiwygEdit { $width='100%', // width $height='300px', // height $css_stylesheet='', // css stylesheet file for content - $dropdown_data='' // data for dropdowns (style, font, etc.) + $dropdown_data='' // data for dropdowns (style, font, etc.) */ $this->SPAW = new SPAW_Wysiwyg($id, $textarea->_content); $textarea->SetAttr('id', $name); diff --git a/lib/WysiwygEdit/tinymce.php b/lib/WysiwygEdit/tinymce.php index adc4d68c2..238d4a660 100644 --- a/lib/WysiwygEdit/tinymce.php +++ b/lib/WysiwygEdit/tinymce.php @@ -1,7 +1,7 @@ $this->_wikitextid, + HTML::div(array("id" => $this->_wikitextid, 'style'=>'display:none'), $wikitext),"\n"); //TODO: maybe some more custom links diff --git a/lib/XMLRPC/utils.php b/lib/XMLRPC/utils.php index 0243f8dfb..fc394251c 100644 --- a/lib/XMLRPC/utils.php +++ b/lib/XMLRPC/utils.php @@ -1,39 +1,39 @@ 'Japan1','supplement'=>2); $this->AddCIDFonts($family,$name,$cw,$CMap,$registry); } - + function AddSJIShwFont($family='SJIS-hw') { //Add SJIS font with half-width Latin @@ -101,7 +101,7 @@ class PDF_Japanese extends PDF { else parent::MultiCell($w,$h,$txt,$border,$align,$fill); } - + function SJISMultiCell($w,$h,$txt,$border=0,$align='L',$fill=0) { //Output text with automatic or explicit line breaks diff --git a/lib/nusoap/nusoap.php b/lib/nusoap/nusoap.php index 1064932f2..6f2fe15ab 100644 --- a/lib/nusoap/nusoap.php +++ b/lib/nusoap/nusoap.php @@ -75,7 +75,7 @@ class nusoap_base { * @access public */ var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; - + /** * set default encoding * @@ -104,9 +104,9 @@ class nusoap_base { * @var typemap * @access public */ - var $typemap = + var $typemap = array( - 'http://www.w3.org/2001/XMLSchema' => + 'http://www.w3.org/2001/XMLSchema' => array( 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double', 'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'', @@ -116,7 +116,7 @@ class nusoap_base { 'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer', 'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer', 'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''), - 'http://www.w3.org/1999/XMLSchema' => + 'http://www.w3.org/1999/XMLSchema' => array( 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', 'float'=>'double','dateTime'=>'string', @@ -125,7 +125,7 @@ class nusoap_base { 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'), 'http://xml.apache.org/xml-soap' => array('Map') ); - + /** * entities to convert * @@ -345,7 +345,7 @@ class nusoap_base { } return $xml; } - + /** * serialize message * @@ -402,7 +402,7 @@ class nusoap_base { return $str; } } - + /** * returns the prefix part of a prefixed string * returns false, if not prefixed @@ -450,7 +450,7 @@ function timestamp_to_iso8601($timestamp,$utc=true){ '([0-9]{2}):'. // minutes mm: '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss... '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's - + if(ereg($eregStr,$datestr,$regs)){ return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]); } @@ -512,7 +512,7 @@ class soap_fault extends nusoap_base { var $faultactor; var $faultstring; var $faultdetail; - + /** * constructor * @@ -527,7 +527,7 @@ class soap_fault extends nusoap_base { $this->faultstring = $faultstring; $this->faultdetail = $faultdetail; } - + /** * serialize a fault * @@ -568,7 +568,7 @@ class soap_fault extends nusoap_base { * @access public */ class XMLSchema extends nusoap_base { - + // files var $schema = ''; var $xml = ''; @@ -581,7 +581,7 @@ class XMLSchema extends nusoap_base { var $position; var $depth = 0; var $depth_array = array(); - + /** * constructor * @@ -672,7 +672,7 @@ class XMLSchema extends nusoap_base { $this->debug('XML parse error: '.$errstr); $this->setError('Parser error: '.$errstr); } - + xml_parser_free($this->parser); } else{ $this->debug('no xml passed to parseString()!!'); @@ -689,7 +689,7 @@ class XMLSchema extends nusoap_base { * @access private */ function schemaStartElement($parser, $name, $attrs) { - + // position in the total number of elements, starting from 0 $pos = $this->position++; $depth = $this->depth++; @@ -703,7 +703,7 @@ class XMLSchema extends nusoap_base { } else { $prefix = ''; } - + // loop thru attributes, expanding, and registering namespace declarations if(count($attrs) > 0){ foreach($attrs as $k => $v){ @@ -752,7 +752,7 @@ class XMLSchema extends nusoap_base { $aname = $attrs['ref']; $this->attributes[$attrs['ref']] = $attrs; } - + if(isset($this->currentComplexType)){ $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs; } elseif(isset($this->currentElement)){ @@ -876,7 +876,7 @@ class XMLSchema extends nusoap_base { * @access public */ function serializeSchema(){ - + $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion); $xml = ''; // complex types @@ -1048,7 +1048,7 @@ class XMLSchema extends nusoap_base { //$this->setError("No namespace registered for prefix '$prefix'"); return false; } - + /** * returns the prefix for a given namespace (or prefix) * or false if no prefixes registered for the given namespace @@ -1164,12 +1164,12 @@ class XMLSchema extends nusoap_base { } return $buffer; } - + /** * adds an XML Schema complex type to the WSDL types - * + * * example: array - * + * * addType( * 'ArrayOfstring', * 'complexType', @@ -1179,9 +1179,9 @@ class XMLSchema extends nusoap_base { * array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'), * 'xsd:string' * ); - * + * * example: PHP associative array ( SOAP Struct ) - * + * * addType( * 'SOAPStruct', * 'complexType', @@ -1189,7 +1189,7 @@ class XMLSchema extends nusoap_base { * 'all', * array('myVar'=> array('name'=>'myVar','type'=>'string') * ); - * + * * @param name * @param typeClass (complexType|simpleType|attribute) * @param phpType: currently supported are array and struct (php assoc array) @@ -1298,7 +1298,7 @@ class soap_transport_http extends nusoap_base { var $outgoing_payload = ''; var $incoming_payload = ''; var $useSOAPAction = true; - + /** * constructor */ @@ -1316,9 +1316,9 @@ class soap_transport_http extends nusoap_base { $this->port = 80; } } - + function connect($timeout){ - + // proxy if($this->proxyhost != '' && $this->proxyport != ''){ $host = $this->proxyhost; @@ -1333,7 +1333,7 @@ class soap_transport_http extends nusoap_base { $host = 'ssl://'.$host; $port = 443; } - + $this->debug("connection params: $host, $port"); // timeout if($timeout > 0){ @@ -1341,7 +1341,7 @@ class soap_transport_http extends nusoap_base { } else { $fp = fsockopen($host, $port, $this->errno, $this->error_str); } - + // test pointer if(!$fp) { $this->debug('Couldn\'t open socket connection to server '.$this->url.', Error: '.$this->error_str); @@ -1350,7 +1350,7 @@ class soap_transport_http extends nusoap_base { } return $fp; } - + /** * send the SOAP message via HTTP * @@ -1366,7 +1366,7 @@ class soap_transport_http extends nusoap_base { return false; } $this->debug('socket connected'); - + // start building outgoing payload: // swap url for path if going through a proxy if($this->proxyhost != '' && $this->proxyport != ''){ @@ -1401,14 +1401,14 @@ class soap_transport_http extends nusoap_base { $this->outgoing_payload .= "\r\n"; // add data $this->outgoing_payload .= $data; - + // send payload if(!fputs($fp, $this->outgoing_payload, strlen($this->outgoing_payload))) { $this->setError('couldn\'t write message data to socket'); $this->debug('Write error'); } $this->debug('wrote data to socket'); - + // get response $this->incoming_payload = ''; //$strlen = 0; @@ -1417,20 +1417,20 @@ class soap_transport_http extends nusoap_base { //$strlen += strlen($data); } $this->debug('received '.strlen($this->incoming_payload).' bytes of data from server'); - + // close filepointer fclose($fp); $this->debug('closed socket'); - + // connection was closed unexpectedly if($this->incoming_payload == ''){ $this->setError('no response from server'); return false; } - + $this->debug('received incoming payload: '.strlen($this->incoming_payload)); $data = $this->incoming_payload."\r\n\r\n\r\n\r\n"; - + // remove 100 header if(ereg('^HTTP/1.1 100',$data)){ if($pos = strpos($data,"\r\n\r\n") ){ @@ -1439,7 +1439,7 @@ class soap_transport_http extends nusoap_base { $data = ltrim(substr($data,$pos)); } }// - + // separate content from HTTP headers if( $pos = strpos($data,"\r\n\r\n") ){ $lb = "\r\n"; @@ -1463,7 +1463,7 @@ class soap_transport_http extends nusoap_base { } //print "headers:
$header_data

"; //print "data:
$data

"; - + // decode transfer-encoding if(isset($headers['Transfer-Encoding']) && $headers['Transfer-Encoding'] == 'chunked'){ //$timer->setMarker('starting to decode chunked content'); @@ -1474,7 +1474,7 @@ class soap_transport_http extends nusoap_base { //$timer->setMarker('finished decoding of chunked content'); //print "
\nde-chunked:\n---------------\n$data\n\n---------------\n
"; } - + // decode content-encoding if(isset($headers['Content-Encoding']) && $headers['Content-Encoding'] != ''){ if($headers['Content-Encoding'] == 'deflate' || $headers['Content-Encoding'] == 'gzip'){ @@ -1495,7 +1495,7 @@ class soap_transport_http extends nusoap_base { } } } - + if(strlen($data) == 0){ $this->debug('no data after headers!'); $this->setError('no data present after HTTP headers'); @@ -1505,7 +1505,7 @@ class soap_transport_http extends nusoap_base { return $data; } - + /** * send the SOAP message via HTTPS 1.0 using CURL * @@ -1543,17 +1543,17 @@ class soap_transport_http extends nusoap_base { } // persistent connection //curl_setopt($ch, CURL_HTTP_VERSION_1_1, true); - + // set timeout if($timeout != 0){ curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); } - + $credentials = ''; if($this->username != '') { $credentials = 'Authorization: Basic '.base64_encode("$this->username:$this->password").'\r\n'; } - + if($this->encoding != ''){ if(function_exists('gzdeflate')){ $encoding_headers = "Accept-Encoding: $this->encoding\r\n". @@ -1563,13 +1563,13 @@ class soap_transport_http extends nusoap_base { } } } - + if($this->proxyhost && $this->proxyport){ $this->outgoing_payload = "POST $this->url HTTP/$this->protocol_version\r\n"; } else { $this->outgoing_payload = "POST $this->path HTTP/$this->protocol_version\r\n"; } - + $this->outgoing_payload .= "User-Agent: $this->title v$this->version\r\n". "Host: ".$this->host."\r\n". @@ -1579,7 +1579,7 @@ class soap_transport_http extends nusoap_base { "Content-Length: ".strlen($data)."\r\n". "SOAPAction: \"$this->soapaction\""."\r\n\r\n". $data; - + // set payload curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->outgoing_payload); //$t->setMarker('set curl options, executing...'); @@ -1606,7 +1606,7 @@ class soap_transport_http extends nusoap_base { // close curl curl_close($ch); //$t->setMarker('closed curl'); - + // remove 100 header if(ereg('^HTTP/1.1 100',$data)){ if($pos = strpos($data,"\r\n\r\n") ){ @@ -1615,7 +1615,7 @@ class soap_transport_http extends nusoap_base { $data = ltrim(substr($data,$pos)); } }// - + // separate content from HTTP headers if( $pos = strpos($data,"\r\n\r\n") ){ $lb = "\r\n"; @@ -1640,7 +1640,7 @@ class soap_transport_http extends nusoap_base { $this->setError('no data present after HTTP headers.'); return false; } - + // decode transfer-encoding if($headers['Transfer-Encoding'] == 'chunked'){ if(!$data = $this->decodeChunked($data)){ @@ -1669,7 +1669,7 @@ class soap_transport_http extends nusoap_base { $this->incoming_payload = $header_data."\r\n\r\n".$data; return $data; } - + /** * if authenticating, set user credentials here * @@ -1681,7 +1681,7 @@ class soap_transport_http extends nusoap_base { $this->username = $username; $this->password = $password; } - + /** * set the soapaction value * @@ -1691,7 +1691,7 @@ class soap_transport_http extends nusoap_base { function setSOAPAction($soapaction) { $this->soapaction = $soapaction; } - + /** * use http encoding * @@ -1702,7 +1702,7 @@ class soap_transport_http extends nusoap_base { $this->encoding = $enc; $this->protocol_version = '1.1'; } - + /** * set proxy info here * @@ -1714,7 +1714,7 @@ class soap_transport_http extends nusoap_base { $this->proxyhost = $proxyhost; $this->proxyport = $proxyport; } - + /** * decode a string that is encoded w/ "chunked' transfer encoding * as defined in RFC2068 19.4.6 @@ -1727,7 +1727,7 @@ class soap_transport_http extends nusoap_base { // length := 0 $length = 0; $new = ''; - + // read chunk-size, chunk-extension (if any) and CRLF // get the position of the linebreak $chunkend = strpos($buffer,"\r\n") + 2; @@ -1736,9 +1736,9 @@ class soap_transport_http extends nusoap_base { $chunkstart = $chunkend; // while (chunk-size > 0) { while ($chunk_size > 0) { - + $chunkend = strpos( $buffer, "\r\n", $chunkstart + $chunk_size); - + // Just in case we got a broken connection if ($chunkend == FALSE) { $chunk = substr($buffer,$chunkstart); @@ -1747,7 +1747,7 @@ class soap_transport_http extends nusoap_base { $length += strlen($chunk); break; } - + // read chunk-data and CRLF $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart); // append chunk-data to entity-body @@ -1756,7 +1756,7 @@ class soap_transport_http extends nusoap_base { $length += strlen($chunk); // read chunk-size and CRLF $chunkstart = $chunkend + 2; - + $chunkend = strpos($buffer,"\r\n",$chunkstart)+2; if ($chunkend == FALSE) { break; //Just in case we got a broken connection @@ -1799,7 +1799,7 @@ class soap_server extends nusoap_base { var $wsdl = false; var $externalWSDLURL = false; var $debug_flag = true; - + /** * constructor * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to. @@ -1808,7 +1808,7 @@ class soap_server extends nusoap_base { * @access public */ function soap_server($wsdl=false){ - + // turn on debugging? global $debug; if(isset($debug)){ @@ -1824,7 +1824,7 @@ class soap_server extends nusoap_base { } } } - + /** * processes request and returns response * @@ -1852,12 +1852,12 @@ class soap_server extends nusoap_base { exit(); } } - + // print web interface if($data == '' && $this->wsdl){ print $this->webDescription(); } else { - + // $response is the serialized response message $response = $this->parse_request($data); $this->debug('server sending...'); @@ -2105,7 +2105,7 @@ class soap_server extends nusoap_base { if(false == $use) { $use = "encoded"; } - + $this->operations[] = array($name => array()); $this->operations[$name] = array( 'name' => $name, @@ -2270,11 +2270,11 @@ class soap_server extends nusoap_base { if(false == $namespace) { $namespace = "http://$SERVER_NAME/soap/$serviceName"; } - + if(false == $endpoint) { $endpoint = "http://$SERVER_NAME$SCRIPT_NAME"; } - + $this->wsdl = new wsdl; $this->wsdl->serviceName = $serviceName; $this->wsdl->endpoint = $endpoint; @@ -2297,13 +2297,13 @@ class soap_server extends nusoap_base { /** * parses a WSDL file, allows access to it's data, other utility methods - * + * * @author Dietrich Ayala * @version v 0.6.3 - * @access public + * @access public */ class wsdl extends XMLSchema { - var $wsdl; + var $wsdl; // define internal arrays of bindings, ports, operations, messages, etc. var $message = array(); var $complexTypes = array(); @@ -2319,9 +2319,9 @@ class wsdl extends XMLSchema { var $opData = array(); var $status = ''; var $documentation = false; - var $endpoint = ''; + var $endpoint = ''; // array of wsdl docs to import - var $import = array(); + var $import = array(); // parser vars var $parser; var $position = 0; @@ -2331,37 +2331,37 @@ class wsdl extends XMLSchema { // for getting wsdl var $proxyhost = ''; var $proxyport = ''; - + /** * constructor - * + * * @param string $wsdl WSDL document URL - * @access public + * @access public */ function wsdl($wsdl = '',$proxyhost=false,$proxyport=false){ $this->wsdl = $wsdl; $this->proxyhost = $proxyhost; $this->proxyport = $proxyport; - + // parse wsdl file if ($wsdl != "") { $this->debug('initial wsdl file: ' . $wsdl); $this->parseWSDL($wsdl); - } + } // imports if (sizeof($this->import) > 0) { foreach($this->import as $ns => $url) { $this->debug('importing wsdl from ' . $url); $this->parseWSDL($url); - } - } - } + } + } + } /** * parses the wsdl document - * + * * @param string $wsdl path or URL - * @access private + * @access private */ function parseWSDL($wsdl = '') { @@ -2369,15 +2369,15 @@ class wsdl extends XMLSchema { $this->debug('no wsdl passed to parseWSDL()!!'); $this->setError('no wsdl passed to parseWSDL()!!'); return false; - } + } $this->debug('getting ' . $wsdl); - + // parse $wsdl for url format $wsdl_props = parse_url($wsdl); if (isset($wsdl_props['host'])) { - + // get wsdl $tr = new soap_transport_http($wsdl); $tr->request_method = 'GET'; @@ -2397,7 +2397,7 @@ class wsdl extends XMLSchema { } unset($tr); /* $wsdl seems to be a valid url, not a file path, do an fsockopen/HTTP GET - $fsockopen_timeout = 30; + $fsockopen_timeout = 30; // check if a port value is supplied in url if (isset($wsdl_props['port'])) { // yes @@ -2413,8 +2413,8 @@ class wsdl extends XMLSchema { case ('http') : default : $wsdl_url_port = 80; - } - } + } + } // FIXME: should implement SSL/TLS support here if CURL is available if ($fp = fsockopen($wsdl_props['host'], $wsdl_url_port, $fsockopen_errnum, $fsockopen_errstr, $fsockopen_timeout)) { // perform HTTP GET for WSDL file @@ -2422,7 +2422,7 @@ class wsdl extends XMLSchema { $sHeader = "GET " . $wsdl_props['path']; if (isset($wsdl_props['query'])) { $sHeader .= "?" . $wsdl_props['query']; - } + } $sHeader .= " HTTP/1.0\r\n"; if (isset($wsdl_props['user'])) { @@ -2436,12 +2436,12 @@ class wsdl extends XMLSchema { // do nothing, just read/skip past HTTP headers // FIXME: should actually detect HTTP response code, and act accordingly if error // HTTP headers end with extra CRLF before content body - } + } // read in WSDL just like regular fopen() $wsdl_string = ''; while ($data = fread($fp, 32768)) { $wsdl_string .= $data; - } + } fclose($fp); } else { $this->setError('bad path to WSDL file.'); @@ -2454,21 +2454,21 @@ class wsdl extends XMLSchema { $wsdl_string = ''; while ($data = fread($fp, 32768)) { $wsdl_string .= $data; - } + } fclose($fp); } else { $this->setError('bad path to WSDL file.'); return false; - } + } } // end new code added // Create an XML parser. - $this->parser = xml_parser_create(); + $this->parser = xml_parser_create(); // Set the options for parsing the XML data. // xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); // Set the object for the parser. - xml_set_object($this->parser, $this); + xml_set_object($this->parser, $this); // Set the element handlers for the parser. xml_set_element_handler($this->parser, 'start_element', 'end_element'); xml_set_character_data_handler($this->parser, 'character_data'); @@ -2483,7 +2483,7 @@ class wsdl extends XMLSchema { $this->debug('XML parse error: ' . $errstr); $this->setError('Parser error: ' . $errstr); return false; - } + } // free the parser xml_parser_free($this->parser); // catch wsdl parse errors @@ -2495,11 +2495,11 @@ class wsdl extends XMLSchema { if (isset($bindingData['operations']) && is_array($bindingData['operations'])) { foreach($bindingData['operations'] as $operation => $data) { $this->debug('post-parse data gathering for ' . $operation); - $this->bindings[$binding]['operations'][$operation]['input'] = - isset($this->bindings[$binding]['operations'][$operation]['input']) ? + $this->bindings[$binding]['operations'][$operation]['input'] = + isset($this->bindings[$binding]['operations'][$operation]['input']) ? array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) : $this->portTypes[ $bindingData['portType'] ][$operation]['input']; - $this->bindings[$binding]['operations'][$operation]['output'] = + $this->bindings[$binding]['operations'][$operation]['output'] = isset($this->bindings[$binding]['operations'][$operation]['output']) ? array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) : $this->portTypes[ $bindingData['portType'] ][$operation]['output']; @@ -2515,19 +2515,19 @@ class wsdl extends XMLSchema { $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : ''; $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bindingData['portType'] ][$operation]['documentation']) ? $this->portTypes[ $bindingData['portType'] ][$operation]['documentation'] : ''; $this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : ''; - } - } + } + } } return true; - } + } /** * start-element handler - * + * * @param string $parser XML parser object * @param string $name element name * @param string $attrs associative array of attributes - * @access private + * @access private */ function start_element($parser, $name, $attrs) { @@ -2538,19 +2538,19 @@ class wsdl extends XMLSchema { } else { // position in the total number of elements, starting from 0 $pos = $this->position++; - $depth = $this->depth++; + $depth = $this->depth++; // set self as current value for this depth $this->depth_array[$depth] = $pos; - $this->message[$pos] = array('cdata' => ''); + $this->message[$pos] = array('cdata' => ''); // get element prefix if (ereg(':', $name)) { // get ns prefix - $prefix = substr($name, 0, strpos($name, ':')); + $prefix = substr($name, 0, strpos($name, ':')); // get ns - $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : ''; + $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : ''; // get unqualified name $name = substr(strstr($name, ':'), 1); - } + } if (count($attrs) > 0) { foreach($attrs as $k => $v) { @@ -2560,23 +2560,23 @@ class wsdl extends XMLSchema { $this->namespaces[$ns_prefix] = $v; } else { $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v; - } + } if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema') { $this->XMLSchemaVersion = $v; $this->namespaces['xsi'] = $v . '-instance'; - } - } // + } + } // // expand each attribute $k = strpos($k, ':') ? $this->expandQname($k) : $k; if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') { $v = strpos($v, ':') ? $this->expandQname($v) : $v; - } + } $eAttrs[$k] = $v; - } + } $attrs = $eAttrs; } else { $attrs = array(); - } + } // find status, register data switch ($this->status) { case 'message': @@ -2584,11 +2584,11 @@ class wsdl extends XMLSchema { if (isset($attrs['type'])) { $this->debug("msg " . $this->currentMessage . ": found part $attrs[name]: " . implode(',', $attrs)); $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type']; - } + } if (isset($attrs['element'])) { $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element']; - } - } + } + } break; case 'portType': switch ($name) { @@ -2597,25 +2597,25 @@ class wsdl extends XMLSchema { $this->debug("portType $this->currentPortType operation: $this->currentPortOperation"); if (isset($attrs['parameterOrder'])) { $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder']; - } + } break; case 'documentation': $this->documentation = true; - break; + break; // merge input/output data default: $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : ''; $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m; break; - } + } break; case 'binding': switch ($name) { - case 'binding': + case 'binding': // get ns prefix if (isset($attrs['style'])) { $this->bindings[$this->currentBinding]['prefix'] = $prefix; - } + } $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs); break; case 'header': @@ -2624,17 +2624,17 @@ class wsdl extends XMLSchema { case 'operation': if (isset($attrs['soapAction'])) { $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction']; - } + } if (isset($attrs['style'])) { $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style']; - } + } if (isset($attrs['name'])) { $this->currentOperation = $attrs['name']; $this->debug("current binding operation: $this->currentOperation"); $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name']; $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding; $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : ''; - } + } break; case 'input': $this->opStatus = 'input'; @@ -2647,9 +2647,9 @@ class wsdl extends XMLSchema { $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs); } else { $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs; - } + } break; - } + } break; case 'service': switch ($name) { @@ -2657,7 +2657,7 @@ class wsdl extends XMLSchema { $this->currentPort = $attrs['name']; $this->debug('current port: ' . $this->currentPort); $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']); - + break; case 'address': $this->ports[$this->currentPort]['location'] = $attrs['location']; @@ -2665,15 +2665,15 @@ class wsdl extends XMLSchema { $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace; $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location']; break; - } + } break; - } + } // set status switch ($name) { case "import": if (isset($attrs['location'])) { $this->import[$attrs['namespace']] = $attrs['location']; - } + } break; case 'types': $this->status = 'schema'; @@ -2695,11 +2695,11 @@ class wsdl extends XMLSchema { $this->currentBinding = $this->getLocalPart($attrs['name']); } else { $this->currentBinding = $attrs['name']; - } + } $this->status = 'binding'; $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']); $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']); - } + } break; case 'service': $this->serviceName = $attrs['name']; @@ -2709,70 +2709,70 @@ class wsdl extends XMLSchema { case 'definitions': foreach ($attrs as $name => $value) { $this->wsdl_info[$name] = $value; - } + } break; - } - } - } + } + } + } /** * end-element handler - * + * * @param string $parser XML parser object * @param string $name element name - * @access private + * @access private */ - function end_element($parser, $name){ + function end_element($parser, $name){ // unset schema status if (ereg('types$', $name) || ereg('schema$', $name)) { $this->status = ""; - } + } if ($this->status == 'schema') { $this->schemaEndElement($parser, $name); } else { // bring depth down a notch $this->depth--; - } + } // end documentation if ($this->documentation) { $this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation; $this->documentation = false; - } - } + } + } /** * element content handler - * + * * @param string $parser XML parser object * @param string $data element content - * @access private + * @access private */ function character_data($parser, $data) { $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0; if (isset($this->message[$pos]['cdata'])) { $this->message[$pos]['cdata'] .= $data; - } + } if ($this->documentation) { $this->documentation .= $data; - } - } - + } + } + function getBindingData($binding) { if (is_array($this->bindings[$binding])) { return $this->bindings[$binding]; - } + } } - + /** * returns an assoc array of operation names => operation data * NOTE: currently only supports multiple services of differing binding types * This method needs some work - * + * * @param string $bindingType eg: soap, smtp, dime (only soap is currently supported) - * @return array - * @access public + * @return array + * @access public */ function getOperations($bindingType = 'soap') { @@ -2786,17 +2786,17 @@ class wsdl extends XMLSchema { // get binding return $this->bindings[ $portData['binding'] ]['operations']; } - } + } return array(); - } - + } + /** * returns an associative array of data necessary for calling an operation - * + * * @param string $operation , name of operation * @param string $bindingType , type of binding eg: soap - * @return array - * @access public + * @return array + * @access public */ function getOperationData($operation, $bindingType = 'soap') { @@ -2813,44 +2813,44 @@ class wsdl extends XMLSchema { if ($operation == $bOperation) { $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation]; return $opData; - } - } + } + } } - } + } } - + /** * serialize the parsed wsdl - * + * * @return string , serialization of WSDL - * @access public + * @access public */ function serialize() { $xml = 'namespaces as $k => $v) { $xml .= " xmlns:$k=\"$v\""; - } + } // 10.9.02 - add poulter fix for wsdl and tns declarations if (isset($this->namespaces['wsdl'])) { $xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\""; - } + } if (isset($this->namespaces['tns'])) { $xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\""; - } - $xml .= '>'; + } + $xml .= '>'; // imports if (sizeof($this->import) > 0) { foreach($this->import as $ns => $url) { $xml .= ''; - } - } + } + } // types if (count($this->complexTypes)>=1) { $xml .= ''; $xml .= $this->serializeSchema(); $xml .= ''; - } + } // messages if (count($this->messages) >= 1) { foreach($this->messages as $msgName => $msgParts) { @@ -2866,17 +2866,17 @@ class wsdl extends XMLSchema { foreach($this->typemap as $ns => $types) { if (isset($types[$partType])) { $typePrefix = $this->getPrefixFromNamespace($ns); - } - } + } + } if (!isset($typePrefix)) { die("$partType has no namespace!"); - } - } + } + } $xml .= ''; - } + } $xml .= ''; - } - } + } + } // bindings & porttypes if (count($this->bindings) >= 1) { $binding_xml = ''; @@ -2894,17 +2894,17 @@ class wsdl extends XMLSchema { $portType_xml .= ''; $portType_xml .= ''; $portType_xml .= ''; - } + } $portType_xml .= ''; $binding_xml .= ''; - } + } $xml .= $portType_xml . $binding_xml; - } + } // services $xml .= ''; if (count($this->ports) >= 1) { @@ -2912,32 +2912,32 @@ class wsdl extends XMLSchema { $xml .= ''; $xml .= ''; $xml .= ''; - } - } + } + } $xml .= ''; return $xml . ''; - } - + } + /** * serialize a PHP value according to a WSDL message definition - * + * * TODO * - multi-ref serialization * - validate PHP values against type definitions, return errors if invalid - * + * * @param string $ type name * @param mixed $ param value * @return mixed new param or false if initial value didn't validate */ function serializeRPCParameters($operation, $direction, $parameters) { - $this->debug('in serializeRPCParameters with operation '.$operation.', direction '.$direction.' and '.count($parameters).' param(s), and xml schema version ' . $this->XMLSchemaVersion); - + $this->debug('in serializeRPCParameters with operation '.$operation.', direction '.$direction.' and '.count($parameters).' param(s), and xml schema version ' . $this->XMLSchemaVersion); + if ($direction != 'input' && $direction != 'output') { $this->debug('The value of the \$direction argument needs to be either "input" or "output"'); $this->setError('The value of the \$direction argument needs to be either "input" or "output"'); return false; - } + } if (!$opData = $this->getOperationData($operation)) { $this->debug('Unable to retrieve WSDL data for operation: ' . $operation); $this->setError('Unable to retrieve WSDL data for operation: ' . $operation); @@ -2947,7 +2947,7 @@ class wsdl extends XMLSchema { // set input params $xml = ''; if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) { - + $use = $opData[$direction]['use']; $this->debug("use=$use"); $this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)'); @@ -2967,17 +2967,17 @@ class wsdl extends XMLSchema { } } return $xml; - } - + } + /** * serializes a PHP value according a given type definition - * + * * @param string $name , name of type (part) * @param string $type , type of type, heh (type or element) * @param mixed $value , a native PHP value (parameter value) * @param string $use , use for part (encoded|literal) * @return string serialization - * @access public + * @access public */ function serializeType($name, $type, $value, $use='encoded') { @@ -2987,25 +2987,25 @@ class wsdl extends XMLSchema { $uqType = substr($type, strrpos($type, ':') + 1); $ns = substr($type, 0, strrpos($type, ':')); $this->debug("got a prefixed type: $uqType, $ns"); - + if($ns == $this->XMLSchemaVersion || ($this->getNamespaceFromPrefix($ns)) == $this->XMLSchemaVersion){ - + if ($uqType == 'boolean' && !$value) { $value = 0; } elseif ($uqType == 'boolean') { $value = 1; - } + } if ($this->charencoding && $uqType == 'string' && gettype($value) == 'string') { $value = htmlspecialchars($value); - } + } // it's a scalar if ($use == 'literal') { return "<$name>$value"; } else { return "<$name xsi:type=\"" . $this->getPrefixFromNamespace($this->XMLSchemaVersion) . ":$uqType\">$value"; } - } + } } else { $uqType = $type; } @@ -3018,7 +3018,7 @@ class wsdl extends XMLSchema { //} } $phpType = $typeDef['phpType']; - $this->debug("serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') ); + $this->debug("serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') ); // if php type == struct, map value to the element names if ($phpType == 'struct') { if (isset($typeDef['element']) && $typeDef['element']) { @@ -3035,9 +3035,9 @@ class wsdl extends XMLSchema { } else { $xml = "<$elementName$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">"; } - + if (isset($this->complexTypes[$uqType]['elements']) && is_array($this->complexTypes[$uqType]['elements'])) { - + //if (is_array($this->complexTypes[$uqType]['elements'])) { // toggle whether all elements are present - ideally should validate against schema if(count($this->complexTypes[$uqType]['elements']) != count($value)){ @@ -3063,7 +3063,7 @@ class wsdl extends XMLSchema { $xml .= $this->serialize_val($v, $eName, $this->getLocalPart($attrs['type']), null, $this->getNamespaceFromPrefix($this->getPrefix($attrs['type'])), false, $use); } } - } + } } $xml .= ""; } elseif ($phpType == 'array') { @@ -3073,11 +3073,11 @@ class wsdl extends XMLSchema { foreach($value as $v) { $cols = ',' . sizeof($v); $nv = array_merge($nv, $v); - } + } $value = $nv; } else { $cols = ''; - } + } if (is_array($value) && sizeof($value) >= 1) { $contents = ''; foreach($value as $k => $v) { @@ -3087,7 +3087,7 @@ class wsdl extends XMLSchema { $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use); } else { $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use); - } + } } $this->debug('contents: '.$this->varDump($contents)); } else { @@ -3110,17 +3110,17 @@ class wsdl extends XMLSchema { $this->debug('returning: '.$this->varDump($xml)); return $xml; } - + /** * register a service with the server - * - * @param string $methodname + * + * @param string $methodname * @param string $in assoc array of input values: key = param name, value = param type * @param string $out assoc array of output values: key = param name, value = param type - * @param string $namespace - * @param string $soapaction + * @param string $namespace + * @param string $soapaction * @param string $style (rpc|literal) - * @access public + * @access public */ function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '') { @@ -3128,7 +3128,7 @@ class wsdl extends XMLSchema { $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; } else { $encodingStyle = ''; - } + } // get binding $this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] = array( @@ -3151,7 +3151,7 @@ class wsdl extends XMLSchema { 'parts' => $out), 'namespace' => $namespace, 'transport' => 'http://schemas.xmlsoap.org/soap/http', - 'documentation' => $documentation); + 'documentation' => $documentation); // add portTypes // add messages if($in) @@ -3164,7 +3164,7 @@ class wsdl extends XMLSchema { $this->messages[$name.'Request'][$pName] = $pType; } } - + if($out) { foreach($out as $pName => $pType) @@ -3176,8 +3176,8 @@ class wsdl extends XMLSchema { } } return true; - } -} + } +} ?>endpointType = 'wsdl'; $this->wsdlFile = $this->endpoint; - + // instantiate wsdl object and parse wsdl file $this->debug('instantiating wsdl class with doc: '.$endpoint); $this->wsdl =& new wsdl($this->wsdlFile,$this->proxyhost,$this->proxyport); @@ -3716,7 +3716,7 @@ class pwsoapclient extends nusoap_base { $this->faultstring = ''; $this->faultcode = ''; $this->opData = array(); - + $this->debug("call: $operation, $params, $namespace, $soapAction, $headers, $rpcParams"); $this->debug("endpointType: $this->endpointType"); // if wsdl, get operation data and process parameters @@ -3735,7 +3735,7 @@ class pwsoapclient extends nusoap_base { $this->wsdl->namespaces['nu'] = $namespace; } // serialize payload - + if($opData['input']['use'] == 'literal') { if (is_null($rpcParams)) { $rpcParams = $this->defaultRpcParams; @@ -3792,7 +3792,7 @@ class pwsoapclient extends nusoap_base { } else { $this->return = $return; $this->debug('sent message successfully and got a(n) '.gettype($return).' back'); - + // fault? if(is_array($return) && isset($return['faultcode'])){ $this->debug('got fault'); @@ -3885,7 +3885,7 @@ class pwsoapclient extends nusoap_base { $response = $http->sendHTTPS($msg,$timeout); } else { $this->setError('CURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS'); - } + } } else { $this->setError('no http/s in endpoint url'); } @@ -3990,7 +3990,7 @@ class pwsoapclient extends nusoap_base { $this->username = $username; $this->password = $password; } - + /** * use HTTP encoding * @@ -4000,7 +4000,7 @@ class pwsoapclient extends nusoap_base { function setHTTPEncoding($enc='gzip, deflate'){ $this->http_encoding = $enc; } - + /** * use HTTP persistent connections if possible * @@ -4009,7 +4009,7 @@ class pwsoapclient extends nusoap_base { function useHTTPPersistentConnection(){ $this->persistentConnection = true; } - + /** * gets the default RPC parameter setting. * If true, default is that call params are like RPC even for document style. @@ -4032,7 +4032,7 @@ class pwsoapclient extends nusoap_base { function setDefaultRpcParams($rpcParams) { $this->defaultRpcParams = $rpcParams; } - + /** * dynamically creates proxy class, allowing user to directly call methods from wsdl * diff --git a/lib/pear/Cache.php b/lib/pear/Cache.php index 017ec4da6..a8d49dbb5 100644 --- a/lib/pear/Cache.php +++ b/lib/pear/Cache.php @@ -24,16 +24,16 @@ require_once('Cache/Error.php'); /** * Cache is a base class for cache implementations. * -* The pear cache module is a generic data cache which can be used to +* The pear cache module is a generic data cache which can be used to * cache script runs. The idea behind the cache is quite simple. If you have * the same input parameters for whatever tasks/algorithm you use you'll * usually get the same output. So why not caching templates, functions calls, * graphic generation etc. Caching certain actions e.g. XSLT tranformations -* saves you lots of time. +* saves you lots of time. * -* The design of the cache reminds of PHPLibs session implementation. A -* (PHPLib: session) controller uses storage container (PHPLib: ct_*.inc) to save -* certain data (PHPLib: session data). In contrast to the session stuff it's up to +* The design of the cache reminds of PHPLibs session implementation. A +* (PHPLib: session) controller uses storage container (PHPLib: ct_*.inc) to save +* certain data (PHPLib: session data). In contrast to the session stuff it's up to * you to generate an ID for the data to cache. If you're using the output cache * you might use the script name as a seed for cache::generateID(), if your using the * function cache you'd use an array with all function parameters. @@ -98,7 +98,7 @@ class Cache extends PEAR { * @access public */ var $gc_probability = 1; - + /** * Garbage collection: delete all entries not use for n seconds. * diff --git a/lib/pear/Cache/Container.php b/lib/pear/Cache/Container.php index 009067ca5..074ec9d0b 100644 --- a/lib/pear/Cache/Container.php +++ b/lib/pear/Cache/Container.php @@ -23,21 +23,21 @@ require_once 'Cache/Error.php'; /** * Common base class of all cache storage container. -* -* To speed up things we do a preload you should know about, otherwise it might +* +* To speed up things we do a preload you should know about, otherwise it might * play you a trick. The Cache controller classes (Cache/Cache, Cache/Output, ...) * usually do something like is (isCached($id) && !isExpired($id)) return $container->load($id). -* if you implement isCached(), isExpired() and load() straight ahead, each of this -* functions will result in a storage medium (db, file,...) access. This generates too much load. -* Now, a simple speculative preload should saves time in most cases. Whenever +* if you implement isCached(), isExpired() and load() straight ahead, each of this +* functions will result in a storage medium (db, file,...) access. This generates too much load. +* Now, a simple speculative preload should saves time in most cases. Whenever * one of the mentioned methods is invoked we preload the cached dataset into class variables. * That means that we have only one storage medium access for the sequence * (isCached($id) && !isExpired($id)) return $container->load($id). -* The bad thing is that the preloaded data might be outdated meanwhile, which is -* unlikely but for you power users, be warned. If you do not want the preload -* you should switch it off by setting the class variable $preload to false. Anyway, this is +* The bad thing is that the preloaded data might be outdated meanwhile, which is +* unlikely but for you power users, be warned. If you do not want the preload +* you should switch it off by setting the class variable $preload to false. Anyway, this is * not recommended! -* +* * @author Ulf Wendel * @version $Id$ * @package Cache @@ -71,28 +71,28 @@ class Cache_Container { /** * Expiration timestamp of a preloaded dataset. - * + * * @var integer 0 means never, endless */ var $expires = 0; /** * Value of a preloaded dataset. - * + * * @var string */ var $cachedata = ''; /** * Preloaded userdata field. - * + * * @var string */ var $userdata = ''; /** * Flag indicating that the dataset requested for preloading is unknown. - * + * * @var boolean */ var $unknown = true; @@ -103,21 +103,21 @@ class Cache_Container { * @var string base64 or slash */ var $encoding_mode = 'base64'; - + /** * Highwater mark - maximum space required by all cache entries. - * + * * Whenever the garbage collection runs it checks the amount of space * required by all cache entries. If it's more than n (highwater) bytes * the garbage collection deletes as many entries as necessary to reach the - * lowwater mark. - * + * lowwater mark. + * * @var int * @see lowwater */ - var $highwater = 2048000; - - + var $highwater = 2048000; + + /** * Lowwater mark * @@ -125,19 +125,19 @@ class Cache_Container { * @see highwater */ var $lowwater = 1536000; - - + + /** * Options that can be set in every derived class using it's constructor. - * + * * @var array */ var $allowed_options = array('encoding_mode', 'highwater', 'lowwater'); - - + + /** * Loads a dataset from the cache. - * + * * @param string dataset ID * @param string cache group * @return mixed dataset value or NULL on failure @@ -167,7 +167,7 @@ class Cache_Container { if ($this->preload) { if ($this->id != $id || $this->group != $group) $this->preload($id, $group); - + return $this->userdata; } else { list( , , $userdata) = $this->fetch($id, $group); @@ -177,25 +177,25 @@ class Cache_Container { /** * Checks if a dataset is expired. - * + * * @param string dataset ID * @param string cache group * @param integer maximum age timestamp - * @return boolean + * @return boolean * @access public */ function isExpired($id, $group, $max_age) { if ($this->preload) { if ($this->id != $id || $this->group != $group) $this->preload($id, $group); - + if ($this->unknown) return false; } else { // check if at all it is cached if (!$this->isCached($id, $group)) return false; - + // I'm lazy... list($this->expires, , ) = $this->fetch($id, $group); } @@ -250,7 +250,7 @@ class Cache_Container { /** * Stores a dataset. - * + * * @param string dataset ID * @param mixed data to store * @param mixed userdefined expire date @@ -271,13 +271,13 @@ class Cache_Container { /** * Removes a dataset. - * + * * @param string dataset ID * @param string cache group - * @return boolean + * @return boolean * @access public * @abstract - */ + */ function remove($id, $group) { $this->flushPreload($id, $group); return NULL; @@ -285,7 +285,7 @@ class Cache_Container { /** * Flushes the cache - removes all caches datasets from the cache. - * + * * @param string If a cache group is given only the group will be flushed * @return integer Number of removed datasets, -1 on failure * @access public @@ -298,10 +298,10 @@ class Cache_Container { /** * Checks if a dataset exists. - * + * * @param string dataset ID * @param string cache group - * @return boolean + * @return boolean * @access public * @abstract */ @@ -311,7 +311,7 @@ class Cache_Container { /** * Starts the garbage collection. - * + * * @access public * @abstract */ @@ -325,11 +325,11 @@ class Cache_Container { * @param string dataset ID * @param string cache group * @return boolean - */ + */ function preload($id, $group) { // whatever happens, remember the preloaded ID $this->id = $id; - $this->group = $group; + $this->group = $group; list($this->expires, $this->cachedata, $this->userdata) = $this->fetch($id, $group); @@ -349,10 +349,10 @@ class Cache_Container { * Flushes the internal preload buffer. * * save(), remove() and flush() must call this method - * to preevent differences between the preloaded values and + * to preevent differences between the preloaded values and * the real cache contents. * - * @param string dataset ID, if left out the preloaded values will be flushed. + * @param string dataset ID, if left out the preloaded values will be flushed. * If given the preloaded values will only be flushed if they are * equal to the given id and group * @param string cache group @@ -372,7 +372,7 @@ class Cache_Container { /** * Imports the requested datafields as object variables if allowed - * + * * @param array List of fields to be imported as object variables * @param array List of allowed datafields */ @@ -380,25 +380,25 @@ class Cache_Container { foreach ($allowed as $k => $field) if (isset($requested[$field])) $this->$field = $requested[$field]; - + } // end func setOptions /** * Encodes the data for the storage container. - * + * * @var mixed data to encode */ function encode($data) { - if ('base64' == $this->encoding_mode) + if ('base64' == $this->encoding_mode) return base64_encode(serialize($data)); - else + else return serialize($data); } // end func encode - + /** * Decodes the data from the storage container. - * + * * @var mixed */ function decode($data) { @@ -408,7 +408,7 @@ class Cache_Container { return unserialize($data); } // end func decode - + /** * Translates human readable/relative times in unixtime * @@ -448,8 +448,8 @@ class Cache_Container { $second = substr($expires, 12, 2); return mktime($hour, $minute, $second, $month, $day, $year); } - + } // end func getExpireAbsolute - + } // end class Container ?> diff --git a/lib/pear/Cache/Container/file.php b/lib/pear/Cache/Container/file.php index 86a5210a8..c6698b54a 100644 --- a/lib/pear/Cache/Container/file.php +++ b/lib/pear/Cache/Container/file.php @@ -65,18 +65,18 @@ class Cache_Container_file extends Cache_Container { * @var string */ var $filename_prefix = ''; - - + + /** * List of cache entries, used within a gc run - * + * * @var array */ var $entries; - + /** * Total number of bytes required by all cache entries, used within a gc run. - * + * * @var int */ var $total_size = 0; @@ -85,7 +85,7 @@ class Cache_Container_file extends Cache_Container { /** * Max Line Length of userdata * - * If set to 0, it will take the default + * If set to 0, it will take the default * ( 1024 in php 4.2, unlimited in php 4.3) * see http://ch.php.net/manual/en/function.fgets.php * for details @@ -102,7 +102,7 @@ class Cache_Container_file extends Cache_Container { function Cache_Container_file($options = '') { if (is_array($options)) $this->setOptions($options, array_merge($this->allowed_options, array('cache_dir', 'filename_prefix', 'max_userdata_linelength'))); - + clearstatcache(); if ($this->cache_dir) { @@ -120,7 +120,7 @@ class Cache_Container_file extends Cache_Container { } $this->entries = array(); $this->group_dirs = array(); - + } // end func contructor function fetch($id, $group) { @@ -252,27 +252,27 @@ class Cache_Container_file extends Cache_Container { $ok = $this->doGarbageCollection($maxlifetime, $this->cache_dir); - // check the space used by the cache entries + // check the space used by the cache entries if ($this->total_size > $this->highwater) { - + krsort($this->entries); reset($this->entries); - + while ($this->total_size > $this->lowwater && list($lastmod, $entry) = each($this->entries)) { if (@unlink($entry['file'])) $this->total_size -= $entry['size']; else new CacheError("Can't delete {$entry["file"]}. Check the permissions."); } - + } - + $this->entries = array(); $this->total_size = 0; - + return $ok; } // end func garbageCollection - + /** * Does the recursive gc procedure, protected. * @@ -282,7 +282,7 @@ class Cache_Container_file extends Cache_Container { * @throws Cache_Error */ function doGarbageCollection($maxlifetime, $dir) { - + if (!($dh = opendir($dir))) return new Cache_Error("Can't access cache directory '$dir'. Check permissions and path.", __FILE__, __LINE__); @@ -305,10 +305,10 @@ class Cache_Container_file extends Cache_Container { $expire = fgets($fh, 11); fclose($fh); $lastused = filemtime($file); - + $this->entries[$lastused] = array('file' => $file, 'size' => filesize($file)); $this->total_size += filesize($file); - + // remove if expired if (( ($expire && $expire <= time()) || ($lastused <= (time() - $maxlifetime)) ) && !unlink($file)) new Cache_Error("Can't unlink cache file '$file', skipping. Check permissions and path.", __FILE__, __LINE__); @@ -383,6 +383,6 @@ class Cache_Container_file extends Cache_Container { return $num_removed; } // end func deleteDir - + } // end class file ?> diff --git a/lib/pear/Cache/Container/imgfile.php b/lib/pear/Cache/Container/imgfile.php index 841131f8d..472d335ab 100644 --- a/lib/pear/Cache/Container/imgfile.php +++ b/lib/pear/Cache/Container/imgfile.php @@ -53,18 +53,18 @@ class Cache_Container_file extends Cache_Container { * @var string */ var $filename_prefix = ''; - - + + /** * List of cache entries, used within a gc run - * + * * @var array */ var $entries; - + /** * Total number of bytes required by all cache entries, used within a gc run. - * + * * @var int */ var $total_size = 0; @@ -77,7 +77,7 @@ class Cache_Container_file extends Cache_Container { function Cache_Container_file($options = '') { if (is_array($options)) $this->setOptions($options, array_merge($this->allowed_options, array('cache_dir', 'filename_prefix'))); - + clearstatcache(); if ($this->cache_dir) { @@ -87,7 +87,7 @@ class Cache_Container_file extends Cache_Container { $this->cache_dir = realpath( getcwd() . '/' . $this->cache_dir) . '/'; // check if a trailing slash is in cache_dir - if (!substr($this->cache_dir,-1) ) + if (!substr($this->cache_dir,-1) ) $this->cache_dir .= '/'; if (!file_exists($this->cache_dir) || !is_dir($this->cache_dir)) @@ -95,7 +95,7 @@ class Cache_Container_file extends Cache_Container { } $this->entries = array(); $this->group_dirs = array(); - + } // end func contructor function fetch($id, $group) { @@ -129,7 +129,7 @@ class Cache_Container_file extends Cache_Container { // touch without second param produced stupid entries... touch($file,time()); clearstatcache(); - + return array($expire, $cachedata, $userdata); } // end func fetch @@ -232,27 +232,27 @@ class Cache_Container_file extends Cache_Container { $ok = $this->doGarbageCollection($maxlifetime, $this->cache_dir); - // check the space used by the cache entries + // check the space used by the cache entries if ($this->total_size > $this->highwater) { - + krsort($this->entries); reset($this->entries); - + while ($this->total_size > $this->lowwater && list($lastmod, $entry) = each($this->entries)) { if (@unlink($entry['file'])) $this->total_size -= $entry['size']; else new CacheError("Can't delete {$entry["file"]}. Check the permissions."); } - + } - + $this->entries = array(); $this->total_size = 0; - + return $ok; } // end func garbageCollection - + /** * Does the recursive gc procedure, protected. * @@ -262,7 +262,7 @@ class Cache_Container_file extends Cache_Container { * @throws Cache_Error */ function doGarbageCollection($maxlifetime, $dir) { - + if (!($dh = opendir($dir))) return new Cache_Error("Can't access cache directory '$dir'. Check permissions and path.", __FILE__, __LINE__); @@ -296,13 +296,13 @@ class Cache_Container_file extends Cache_Container { $x = filesize($file.'.img'); $this->entries[$lastused] = array('file' => $file, 'size' => filesize($file)+$x); $this->total_size += filesize($file)+$x; - + // remove if expired if ( ($expire && $expire <= time()) || ($lastused <= (time() - $maxlifetime)) ) { - $ok = unlink($file); + $ok = unlink($file); if ( file_exists($file.'.img') ) $ok = $ok && unlink($file.'.img'); - if (!$ok) + if (!$ok) new Cache_Error("Can't unlink cache file '$file', skipping. Check permissions and path.", __FILE__, __LINE__); } //JOHANNES END @@ -377,6 +377,6 @@ class Cache_Container_file extends Cache_Container { return $num_removed; } // end func deleteDir - + } // end class file ?> diff --git a/lib/pear/Cache/Container/trifile.php b/lib/pear/Cache/Container/trifile.php index 15c4834d8..06193934e 100644 --- a/lib/pear/Cache/Container/trifile.php +++ b/lib/pear/Cache/Container/trifile.php @@ -46,14 +46,14 @@ class Cache_Container_trifile extends Cache_Container_file { $file = $this->getFilename($id, $group); if (!file_exists($file)) return array(NULL, NULL, NULL); - + return array( file_get_contents($this->_getExpFile($file)), file_get_contents($file), file_get_contents($this->_getUDFile($file)) ); } - + /** * Get the file to store cache data in. * @@ -66,7 +66,7 @@ class Cache_Container_trifile extends Cache_Container_file { $file = basename($file); return $dir.'/.'.$file; } - + /** * Get the file to store expiration data in. * @@ -77,7 +77,7 @@ class Cache_Container_trifile extends Cache_Container_file { { return $this->_getFile($file).'.exp'; } - + /** * Get the file to store user data in. * @@ -88,7 +88,7 @@ class Cache_Container_trifile extends Cache_Container_file { { return $this->_getFile($file).'.dat'; } - + /** * Cache file * @@ -128,17 +128,17 @@ class Cache_Container_trifile extends Cache_Container_file { // Save data if (!($fh = @fopen($file, 'wb'))) return new Cache_Error("Can't access '$file' to store cache data. Check access rights and path.", __FILE__, __LINE__); - + if ($this->fileLocking) { flock($fh, LOCK_EX); } - + fwrite($fh, $data); - + if($this->fileLocking) { flock($fh, LOCK_UN); } - + fclose($fh); return true; } diff --git a/lib/pear/Cache/Error.php b/lib/pear/Cache/Error.php index 4c2ed0cd0..afb620d0a 100644 --- a/lib/pear/Cache/Error.php +++ b/lib/pear/Cache/Error.php @@ -21,7 +21,7 @@ require_once 'PEAR.php'; /** * Cache Error class -* +* * @package Cache */ class Cache_Error extends PEAR_Error { @@ -29,23 +29,23 @@ class Cache_Error extends PEAR_Error { /** * Prefix of all error messages. - * + * * @var string */ var $error_message_prefix = 'Cache-Error: '; - + /** * Creates an cache error object. - * + * * @param string error message * @param string file where the error occured * @param string linenumber where the error occured */ function Cache_Error($msg, $file = __FILE__, $line = __LINE__) { - + $this->PEAR_Error(sprintf("%s [%s on line %d].", $msg, $file, $line)); - + } // end func Cache_Error - + } // end class Cache_Error ?> \ No newline at end of file diff --git a/lib/pear/Cache/Graphics.php b/lib/pear/Cache/Graphics.php index 51ae7388a..b8018f7a3 100644 --- a/lib/pear/Cache/Graphics.php +++ b/lib/pear/Cache/Graphics.php @@ -21,20 +21,20 @@ require_once 'Cache.php'; /** * Graphics disk cache. -* -* The usual way to create images is to pass some arguments that describe the image -* to a script that dynamically creates an image. For every image of a page +* +* The usual way to create images is to pass some arguments that describe the image +* to a script that dynamically creates an image. For every image of a page * a new PHP interpreter gets started. This is a good way to kill your webserver. -* -* When dealing with dynamically generated images you should not call another script +* +* When dealing with dynamically generated images you should not call another script * to generate the images but generate the images by the script that produces the page * that contains the images. This is a major improvement but it's only half the way. -* +* * There's no need to rerender an image on every request. A simple disk cache can reduce -* the computation time dramatically. This is what the class graphics_cache is for. -* +* the computation time dramatically. This is what the class graphics_cache is for. +* * Usage: -* +* * // create an instance of the graphics cache * $cache = new graphics_cache; * @@ -42,16 +42,16 @@ require_once 'Cache.php'; * * // compute an ID for your image based on typical parameters * $id = m5d( $size, $colors, $label); -* +* * // check if it's cached * if (!($link = $cache->getImageLink($id, 'gif'))) { -* +* * // hmmm, it's not cached, create it * ... * // cacheImageLink() and cacheImage() make the ImageGIF() call! * // cacheImage() returns the value of ImageGIF() [etc.], cacheImageLink() returns a URL * $link = $cache->cacheImageLink($id, $img, 'gif'); -* +* * } * * // Ok, let's build the ImageLink @@ -60,7 +60,7 @@ require_once 'Cache.php'; * * // for cacheImage(): * // header('Content-type: image/gif'); print $cache->cacheImage($id, $img, 'gif'); -* +* * * The class requires PHP 4.0.2+ [ImageType()]. Note that cacheImage() works with * the output buffer. Modify it if required! @@ -74,11 +74,11 @@ class Cache_Graphics extends Cache { /** * Cache URL prefix. - * + * * Make sure that the cache URL prefix points to the $cache_dir, otherwise - * your links will be broken. Use setCacheURL to specify the cache_url and + * your links will be broken. Use setCacheURL to specify the cache_url and * setCacheDir() for the cache_dir. - * + * * @var string * @see setCacheURL(), setCacheDir() */ @@ -87,10 +87,10 @@ class Cache_Graphics extends Cache { /** * Directory where cached files get stored. * s - * Make sure that the cache_dir is writable and offers enough space. Check + * Make sure that the cache_dir is writable and offers enough space. Check * also if your cache_url points to the directory. Use setCacheDir() to set * the variable. - * + * * @var string * @see setCacheDir(), setCacheURL() */ @@ -98,15 +98,15 @@ class Cache_Graphics extends Cache { /** * Nameprefix of cached files. - * - * Per default the prefix "graphics_" gets used. You might use this + * + * Per default the prefix "graphics_" gets used. You might use this * for versioning or to ease (manual) clean ups. * * @var string */ var $cache_file_prefix = 'graphics_'; - - + + /** * Cache container group. * @@ -114,59 +114,59 @@ class Cache_Graphics extends Cache { */ var $cache_group = 'graphics'; - + /** * Mapping from supported image type to a ImageType() constant. - * + * * Referr to the PHP manual for more informations on ImageType() - * + * * @var array * @link http://www.php.net/ImageType */ var $imagetypes = array( - 'gif' => IMG_GIF, + 'gif' => IMG_GIF, 'jpg' => IMG_JPG, 'png' => IMG_PNG, 'wbmp' => IMG_WBMP ); - + /** * Instantiates a cache file container. * */ function Cache_Graphics() { - + $this->Cache('file', array('cache_dir' => $this->cache_dir, 'filename_prefix' => $this->cache_file_prefix)); - + } // end constructor - + /** * Returns the content of a cached image file. - * + * * This function can be used to send the image directly to the browser. * Make sure that you send a correspondending header before sending the image itself. * - * Always try to get the image from the cache before you compute it. See + * Always try to get the image from the cache before you compute it. See * the class docs for an example. * * @param string Image-ID * @param string Image type: gif, jpg, png, wbmp * @return string Image file contents if a cached file exists otherwise an empty string * @see cacheImage() - */ + */ function getImage($id, $format = 'png') { $id = $this->generateID($id, $format); - + return $this->get($id, $this->cache_group); } // end func getImage - + /** * Returns an array with a link to the cached image and the image file path. - * - * Always try to get the image from the cache before you compute it. See + * + * Always try to get the image from the cache before you compute it. See * the class docs for an example. * * @param string Image-ID @@ -177,21 +177,21 @@ class Cache_Graphics extends Cache { */ function getImageLink($id, $format = 'png') { $id = $this->generateID($id, $format); - if (!$this->container->idExists($id, $this->cache_group)) + if (!$this->container->idExists($id, $this->cache_group)) return array(); $file = $this->cache_url . $this->cache_file_prefix . $id; return array($this->container->getFilename($id, $this->cache_group), $file); } // end func getImageLink - + /** * Create an image from the given image handler, cache it and return the file content. * * Always try to retrive the image from the cache before you compute it. - * - * Warning: this function uses the output buffer. If you expect collisions + * + * Warning: this function uses the output buffer. If you expect collisions * modify the code. * * @param string Image-ID. Used as a part of the cache filename. @@ -199,9 +199,9 @@ class Cache_Graphics extends Cache { * based on characteristic values such as the color, size etc. * @param string Image handler to create the image from. * @param string Image type: gif, jpg, png, wbmp. Also used as filename suffix. - * If an unsupported type is requested the functions tries to + * If an unsupported type is requested the functions tries to * fallback to a supported type before throwing an exeption. - * @return string Image content returned by ImageGIF/... + * @return string Image content returned by ImageGIF/... * @throws Cache_Error * @access public * @see getImage() @@ -228,10 +228,10 @@ class Cache_Graphics extends Cache { if ($image = $this->get($id, $this->cache_group)) return $image; - // save the image to the output buffer, write it to disk and + // save the image to the output buffer, write it to disk and // return the image. ob_end_clean(); - ob_start(); + ob_start(); if (strtoupper($format) == "JPG") { $genFormat = "JPEG"; @@ -253,7 +253,7 @@ class Cache_Graphics extends Cache { return $image; } // end func cacheImage - + /** * Create an image from the given image handler, cache it and return a url and the file path of the image. @@ -265,7 +265,7 @@ class Cache_Graphics extends Cache { * based on characteristic values such as the color, size etc. * @param string Image handler to create the image from. * @param string Image type: gif, jpg, png, wbmp. Also used as filename suffix. - * If an unsupported type is requested the functions tries to + * If an unsupported type is requested the functions tries to * fallback to a supported type before throwing an exeption. * @return array [ full path to the image file, image url ] * @throws Cache_Error @@ -281,7 +281,7 @@ class Cache_Graphics extends Cache { // Check if the requested image type is supported by the GD lib. // If not, try a callback to the first available image type. if (!isset($this->imagetypes[$format]) || !($types & $this->imagetypes[$format])) { - foreach ($this->imagetypes as $supported => $bitmask) + foreach ($this->imagetypes as $supported => $bitmask) if ($types & $bitmask) new Cache_Error("The build in GD lib does not support the image type $format. Fallback to $supported.", __FILE__, __LINE__); else @@ -308,29 +308,29 @@ class Cache_Graphics extends Cache { return array($ffile, $url); } // end func cacheImageLink - + /** - * Sets the URL prefix used when rendering HTML Tags. - * - * Make sure that the URL matches the cache directory, + * Sets the URL prefix used when rendering HTML Tags. + * + * Make sure that the URL matches the cache directory, * otherwise you'll get broken links. - * + * * @param string * @access public * @see setCacheDir() */ function setCacheURL($cache_url) { - if ($cache_url && '/' != substr($cache_url, 1)) + if ($cache_url && '/' != substr($cache_url, 1)) $cache_url .= '/'; - + $this->cache_url = $cache_url; - + } // end func setCacheURL - + /** * Sets the directory where to cache generated Images - * + * * @param string * @access public * @see setCacheURL() @@ -342,12 +342,12 @@ class Cache_Graphics extends Cache { $this->cache_dir = $cache_dir; $this->container->cache_dir = $cache_dir; } // end func setCacheDir - - + + function generateID($variable, $format = 'png') { return md5(serialize($variable)) . '.' . $format; } // end func generateID - - + + } // end class Cache_Graphics ?> diff --git a/lib/pear/DB/Pager.php b/lib/pear/DB/Pager.php index 0a88921fc..9739294b3 100644 --- a/lib/pear/DB/Pager.php +++ b/lib/pear/DB/Pager.php @@ -22,7 +22,7 @@ // // $Id$ /// -// Based on DB_Pager 0.7 from the pear.php.net repository. +// Based on DB_Pager 0.7 from the pear.php.net repository. // The only modifications made have been modification of the include paths. // // From Pear CVS: Id: Pager.php,v 1.3 2002/05/12 13:59:40 cox Exp diff --git a/lib/pear/DB/ifx.php b/lib/pear/DB/ifx.php index d317a3a19..5be280d9f 100644 --- a/lib/pear/DB/ifx.php +++ b/lib/pear/DB/ifx.php @@ -223,7 +223,7 @@ class DB_ifx extends DB_common } else { return 0; } - + } // }}} diff --git a/lib/pear/DB/ldap.php b/lib/pear/DB/ldap.php index b7c61ab5f..f4eeb8f4e 100644 --- a/lib/pear/DB/ldap.php +++ b/lib/pear/DB/ldap.php @@ -25,8 +25,8 @@ // // $Id$ // -// Based on DB 1.3 from the pear.php.net repository. -// The only modifications made have been modification of the include paths. +// Based on DB 1.3 from the pear.php.net repository. +// The only modifications made have been modification of the include paths. // // From Pear CVS: Id: ldap.php,v 1.9 2002/02/11 12:59:37 mj Exp @@ -49,7 +49,7 @@ class LDAP_result extends DB_result { // {{{ properties - + /** * data returned from ldap_entries() * @access private @@ -65,7 +65,7 @@ class LDAP_result extends DB_result * @access private */ var $_record = null; - + // }}} // {{{ constructor @@ -142,8 +142,8 @@ class LDAP_result extends DB_result } return DB_OK; } - - + + /** * Fetch and return a row of data (it uses driver->fetchInto for that) * @param int $fetchmode format of fetched row @@ -174,7 +174,7 @@ class LDAP_result extends DB_result * @return mixed DB_OK on success, NULL on no more rows or * a DB_Error object on error * - * @access public + * @access public */ function fetchInto(&$ar, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum = null) @@ -188,7 +188,7 @@ class LDAP_result extends DB_result } return DB_OK; } - + /** * return all records * @@ -200,7 +200,7 @@ class LDAP_result extends DB_result * @return mixed DB_OK on success, NULL on no more rows or * a DB_Error object on error * - * @access public + * @access public */ function fetchAll($fetchmode = DB_FETCHMODE_DEFAULT, $rownum = null) { @@ -225,13 +225,13 @@ class LDAP_result extends DB_result { return(strcmp(strtolower($this->_recordset[$a][$this->dbh->sorting]), strtolower($this->_recordset[$b][$this->dbh->sorting]))); } - + /** * Get the number of rows in a result set. * * @return int the number of rows, or a DB error * - * @access public + * @access public */ function numRows() { @@ -244,7 +244,7 @@ class LDAP_result extends DB_result * * @return bool true if a new result is available or false if not. * - * @access public + * @access public */ function nextResult() { @@ -255,7 +255,7 @@ class LDAP_result extends DB_result * Frees the resources allocated for this result set. * @return int error code * - * @access public + * @access public */ function free() { @@ -277,7 +277,7 @@ class LDAP_result extends DB_result /** * returns the actual rows number * @return integer - */ + */ function getRowCounter() { $this->getRows(); @@ -299,7 +299,7 @@ class LDAP_result extends DB_result class DB_ldap extends DB_common { // {{{ properties - + /** * LDAP connection * @access private @@ -582,7 +582,7 @@ class DB_ldap extends DB_common $this->limit_count = $count; return $query; } - + /** * Executes a query returning only a specified number of rows * @@ -703,7 +703,7 @@ class DB_ldap extends DB_common $this->q_params = $params; return(parent::getAssoc($query, $force_array, $data, $fetchmode, $group)); } - + /** * Fetch all the rows returned from a query. * @@ -726,7 +726,7 @@ class DB_ldap extends DB_common $this->q_params = $params; return(parent::getAll($query, $data, $fetchmode)); } - + function numRows($result) { return $result->numRows(); @@ -834,7 +834,7 @@ class DB_ldap extends DB_common } } } while ($repeat); - + if (DB::isError($data)) { return $data; } diff --git a/lib/pear/File_Passwd.php b/lib/pear/File_Passwd.php index 02954b73c..f71dbbda4 100644 --- a/lib/pear/File_Passwd.php +++ b/lib/pear/File_Passwd.php @@ -40,29 +40,29 @@ class File_Passwd { * @var array */ var $users ; - + /** * hash list of csv-users * @var array */ var $cvs ; - + /** * filehandle for lockfile * @var int */ var $fplock ; - + /** * locking state * @var boolean */ var $locked ; - + /** * name of the lockfile - * @var string - */ + * @var string + */ var $lockfile = './passwd.lock'; /** @@ -73,13 +73,13 @@ class File_Passwd { * oft the lockfile, not of the passwd file! ( Swapping $lock and $lockfile would * breaks bc to v1.3 and smaller). * Don't forget to call close() to save changes! - * + * * @param $file name of the passwd file * @param $lock if 'true' $lockfile will be locked * @param $lockfile name of the temp file, where changes are saved * * @access public - * @see close() + * @see close() */ function File_Passwd($file, $lock = 0, $lockfile = "") { @@ -104,7 +104,7 @@ class File_Passwd { flock($this->fplock, LOCK_EX); $this->locked = true; } - + $fp = fopen($file,'r') ; if( !$fp ) { return new PEAR_Error( "Couldn't open '$file'!", 1, PEAR_ERROR_RETURN) ; @@ -118,7 +118,7 @@ class File_Passwd { if (empty($array[1])) $array[1]=''; $this->users[$user] = trim($array[1]); if (count($array) >= 3) - $this->cvs[$user] = trim($array[2]); + $this->cvs[$user] = trim($array[2]); } } fclose($fp); @@ -171,15 +171,15 @@ class File_Passwd { * @param $user user id * * @return mixed returns PEAR_Error, if the user doesn't exists - * @access public + * @access public */ - + function delUser($user) { if (isset($this->users[$user]) && $this->locked) { unset($this->users[$user]); unset($this->cvs[$user]); } else { - return new PEAR_Error( "Couldn't delete user '$user', because the user doesn't exists!", 3, PEAR_ERROR_RETURN) ; + return new PEAR_Error( "Couldn't delete user '$user', because the user doesn't exists!", 3, PEAR_ERROR_RETURN) ; } } // end func delUser() @@ -190,7 +190,7 @@ class File_Passwd { * @param $pass password for user * * @return boolean true if password is ok - * @access public + * @access public */ function verifyPassword($user, $pass) { //if ($this->users[$user] == crypt($pass, substr($this->users[$user], 0, 2))) diff --git a/lib/pear/JSON.php b/lib/pear/JSON.php index 62020f937..489a83496 100644 --- a/lib/pear/JSON.php +++ b/lib/pear/JSON.php @@ -666,7 +666,7 @@ class Services_JSON // element in an associative array, // for now $parts = array(); - + if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) { // "name":value pair $key = $this->decode($parts[1]); @@ -802,5 +802,5 @@ if (class_exists('PEAR_Error')) { } } - + ?> diff --git a/lib/plugin/AtomFeed.php b/lib/plugin/AtomFeed.php index 419839a89..f5b722884 100644 --- a/lib/plugin/AtomFeed.php +++ b/lib/plugin/AtomFeed.php @@ -31,11 +31,11 @@ extends WikiPlugin function getName() { return _('AtomFeed'); } - + function getDescription() { return _('Atom Aggregator Plugin'); } - + function getDefaultArguments() { return array( 'feed' => "", @@ -45,16 +45,16 @@ extends WikiPlugin 'titleonly' => false ); } - + function run($dbi, $argstr, &$request, $basepage) { extract($this->getArgs($argstr, $request)); $parser = new AtomParser(); - + assert(!empty($url)); $parser->parse_url($url); - + $html = ''; - + $items = HTML::dl(); foreach ($parser->feed as $feed) { $title = HTML::h3(HTML::a(array('href' => $feed["links"]["0"]["href"]), $feed["title"])); @@ -62,14 +62,14 @@ extends WikiPlugin foreach($parser->entries as $entry) { $item = HTML::dt(HTML::a(array('href' => $entry["links"]["0"]["href"]), $entry["title"])); $items->pushContent($item); - + if (!$titleonly) { $description = HTML::dd(HTML::raw(html_entity_decode($entry["content"]))); } else { $description = HTML::dd(); } $items->pushContent($description); - + if ($maxitem > 0 && $counter >= $maxitem) { break; } diff --git a/lib/plugin/CreateToc.php b/lib/plugin/CreateToc.php index 22832aa5b..545889e8b 100644 --- a/lib/plugin/CreateToc.php +++ b/lib/plugin/CreateToc.php @@ -252,16 +252,16 @@ extends WikiPlugin if (preg_match('/^\s*{\|/', $content[$i])) { $insidetable = true; continue; - } else if (preg_match('/^\s*{{{/', $content[$i]) - || preg_match('/^\s*
/', $content[$i]) 
+            } else if (preg_match('/^\s*{{{/', $content[$i])
+                    || preg_match('/^\s*
/', $content[$i])
                     || preg_match('/^\s*/', $content[$i])) {
                $insideverbatim = true;
                continue;
             } else if (preg_match('/^\s*\|}/', $content[$i])) {
                $insidetable = false;
                continue;
-            } else if (preg_match('/^\s*}}}/', $content[$i]) 
-                    || preg_match('/^\s*<\/pre>/', $content[$i]) 
+            } else if (preg_match('/^\s*}}}/', $content[$i])
+                    || preg_match('/^\s*<\/pre>/', $content[$i])
                     || preg_match('/^\s*<\/verbatim>/', $content[$i])) {
                $insideverbatim = false;
                continue;
@@ -383,7 +383,7 @@ extends WikiPlugin
         if (($notoc) or ($liststyle == 'ol')) {
             $with_counter = 1;
         }
-        if ($firstlevelstyle and ($firstlevelstyle != 'number') 
+        if ($firstlevelstyle and ($firstlevelstyle != 'number')
                              and ($firstlevelstyle != 'letter')
                              and ($firstlevelstyle != 'roman')) {
             return $this->error(_("Error: firstlevelstyle must be 'number', 'letter' or 'roman'"));
diff --git a/lib/plugin/FacebookLike.php b/lib/plugin/FacebookLike.php
index eed571477..5b35cf767 100644
--- a/lib/plugin/FacebookLike.php
+++ b/lib/plugin/FacebookLike.php
@@ -49,7 +49,7 @@ extends WikiPlugin
     function run($dbi, $argstr, &$request, $basepage) {
         $args = $this->getArgs($argstr, $request);
         extract($args);
-        
+
         //$iframe = "";
         $urlargs = array(
                          "layout"     => $layout,
diff --git a/lib/removepage.php b/lib/removepage.php
index f45a580d9..e55344c68 100644
--- a/lib/removepage.php
+++ b/lib/removepage.php
@@ -9,8 +9,8 @@ function RemovePage (&$request) {
     $pagelink = WikiLink($page);
 
     if ($request->getArg('cancel')) {
-        $request->redirect(WikiURL($page, 
-                           array('warningmsg' => _('Remove cancelled')))); 
+        $request->redirect(WikiURL($page,
+                           array('warningmsg' => _('Remove cancelled'))));
         // noreturn
     }
 
diff --git a/passencrypt.php b/passencrypt.php
index 2c1bf7471..e5f550e49 100644
--- a/passencrypt.php
+++ b/passencrypt.php
@@ -33,7 +33,7 @@ with PhpWiki; if not, write to the Free Software Foundation, Inc.,
  * Seed the random number generator.
  *
  * better_srand() ensures the randomizer is seeded only once.
- * 
+ *
  * How random do you want it? See:
  * http://www.php.net/manual/en/function.srand.php
  * http://www.php.net/manual/en/function.mt-srand.php
@@ -43,7 +43,7 @@ function better_srand($seed = '') {
     if (!$wascalled) {
         if ($seed === '') {
             list($usec, $sec) = explode(" ", microtime());
-            if ($usec > 0.1) 
+            if ($usec > 0.1)
                 $seed = (double) $usec * $sec;
             else // once in a while use the combined LCG entropy
                 $seed = (double) 1000000 * substr(uniqid("", true), 13);
@@ -51,7 +51,7 @@ function better_srand($seed = '') {
         if (function_exists('mt_srand')) {
             mt_srand($seed); // mersenne twister
         } else {
-            srand($seed);    
+            srand($seed);
         }
         $wascalled = TRUE;
     }
@@ -64,7 +64,7 @@ function rand_ascii($length = 1) {
         // return only typeable 7 bit ascii, avoid quotes
         if (function_exists('mt_rand'))
             // the usually bad glibc srand()
-            $s .= chr(mt_rand(40, 126)); 
+            $s .= chr(mt_rand(40, 126));
         else
             $s .= chr(rand(40, 126));
     }
@@ -100,9 +100,9 @@ function random_good_password ($minlength = 5, $maxlength = 8) {
     return $newpass;
 }
 
-/** PHP5 deprecated old-style globals if !(bool)ini_get('register_long_arrays'). 
+/** PHP5 deprecated old-style globals if !(bool)ini_get('register_long_arrays').
   *  See Bug #1180115
-  * We want to work with those old ones instead of the new superglobals, 
+  * We want to work with those old ones instead of the new superglobals,
   * for easier coding.
   */
 foreach (array('SERVER','GET','POST','ENV') as $k) {
diff --git a/tests/unit/lib/AtomParserTest.php b/tests/unit/lib/AtomParserTest.php
index ff1cc5be8..fe00426af 100644
--- a/tests/unit/lib/AtomParserTest.php
+++ b/tests/unit/lib/AtomParserTest.php
@@ -48,7 +48,7 @@ extends phpwiki_TestCase
       
       
         
Millenium Spire, Dublin -
Geo coordinates: +
Geo coordinates: 53.349441 -6.260282
@@ -66,33 +66,33 @@ ATOM; $parser->parse($fake_atom_file); $this->assertFalse(count($parser->feed) == 0); - + $current_feed = $parser->feed[0]; $this->assertEquals("This is a fake feed", $current_feed["title"]); - + $this->assertFalse(count($current_feed["links"]) == 0); $this->assertEquals("http://www.phpwiki.org/fakeurl", $current_feed["links"][0]["href"]); $this->assertEquals("Cool feed", $current_feed["subtitle"]); $this->assertEquals("2010-05-15T01:00:00Z", $current_feed["updated"]); - + $this->assertFalse(count($current_feed["authors"]) == 0); - + $current_author = $current_feed["authors"][0]; $this->assertEquals("Sébastien Le Callonnec", $current_author["name"]); $this->assertEquals("slc_ie@yahoo.ie", $current_author["email"]); - + $this->assertFalse(count($parser->entries) == 0); - + $current_entry = $parser->entries[0]; $this->assertEquals("Foobar Éire", $current_entry["title"]); $this->assertEquals("http://maps.google.com/maps?f=q&sll=53.125728,-6.068907&ie=UTF8", $current_entry["links"][0]["href"]); $this->assertEquals("2010-05-15T01:00:00Z", $current_entry["updated"]); $this->assertEquals("2010-05-15T01:00:00Z", $current_entry["published"]); $this->assertEquals("tag:www.phpwiki.org,2010-05-15:/fakeurl/20100515223621", $current_entry["id"]); - + $payload =<<Millenium Spire, Dublin -
Geo coordinates: +
Geo coordinates: 53.349441 -6.260282
@@ -100,7 +100,7 @@ ATOM; CONTENT; $this->assertEquals($payload, $current_entry["content"]); } - + function testExtensiveAtomExampleFromRFC4287() { $fake_atom_file = << @@ -114,9 +114,9 @@ CONTENT; 2005-07-31T12:29:29Z tag:example.org,2003:3 - - Copyright (c) 2003, Mark Pilgrim @@ -125,7 +125,7 @@ CONTENT; Atom draft-07 snapshot - Joe Gregorio -

[Update: The Atom draft is finished.]

@@ -161,7 +161,7 @@ ATOM; $parser->parse($fake_atom_file); $this->assertFalse(count($parser->feed) == 0); - + $current_feed = $parser->feed[0]; $this->assertEquals("dive into mark", $current_feed["title"]); $this->assertEquals("Copyright (c) 2003, Mark Pilgrim", $current_feed["rights"]); @@ -169,44 +169,44 @@ ATOM; $this->assertEquals("2005-07-31T12:29:29Z", $current_feed["updated"]); $this->assertEquals("tag:example.org,2003:3", $current_feed["id"]); $this->assertEquals("Example Toolkit", $current_feed["generator"]); - + $this->assertTrue(count($current_feed["authors"]) == 0); $this->assertTrue(count($current_feed["contributors"]) == 0); - + $this->assertFalse(count($parser->entries) == 0); - + $current_entry = $parser->entries[0]; $this->assertEquals("Atom draft-07 snapshot", $current_entry["title"]); $this->assertEquals("2005-07-31T12:29:29Z", $current_entry["updated"]); $this->assertEquals("2003-12-13T08:29:29-04:00", $current_entry["published"]); $this->assertEquals("tag:example.org,2003:3.2397", $current_entry["id"]); $this->assertEquals(2, count($current_entry["links"])); - + $this->assertTrue(count($current_entry["authors"]) == 1); $this->assertTrue(count($current_entry["contributors"]) == 2); - + $current_author = $current_entry["authors"][0]; $this->assertEquals("Mark Pilgrim", $current_author["name"]); $this->assertEquals("f8dy@example.com", $current_author["email"]); - + $first_contributor = $current_entry["contributors"][0]; $second_contributor = $current_entry["contributors"][1]; - + $this->assertEquals("Sam Ruby", $first_contributor["name"]); $this->assertEquals("Joe Gregorio", $second_contributor["name"]); - + $first_link = $current_entry["links"][0]; $this->assertEquals("alternate", $first_link["rel"]); $this->assertEquals("text/html", $first_link["type"]); $this->assertEquals("http://example.org/2005/04/02/atom", $first_link["href"]); - + $second_link = $current_entry["links"][1]; $this->assertEquals("enclosure", $second_link["rel"]); $this->assertEquals("audio/mpeg", $second_link["type"]); $this->assertEquals("1337", $second_link["length"]); $this->assertEquals("http://example.org/audio/ph34r_my_podcast.mp3", $second_link["href"]); - + $payload = <<

[Update: The Atom draft is finished.]

diff --git a/tests/unit/lib/DumpHtml.php b/tests/unit/lib/DumpHtml.php index 1f6025e5b..ba44da005 100644 --- a/tests/unit/lib/DumpHtml.php +++ b/tests/unit/lib/DumpHtml.php @@ -17,7 +17,7 @@ class DumpHtml extends phpwiki_TestCase { $request->setArg('action', 'dumphtml'); unlink($cur_dir."/.dumphtml/$pagename.html"); DumpHtmlToDir($request); - $this->assertTrue(file_exists($cur_dir."/.dumphtml/$pagename.html")); + $this->assertTrue(file_exists($cur_dir."/.dumphtml/$pagename.html")); } /* at first dump some problematic pages */ @@ -46,7 +46,7 @@ class DumpHtml extends phpwiki_TestCase { //FIXME: LinkDatabase doesn't work for DumpHtmlToDir //$request->setArg('exclude','LinkDatabase'); // this does not work with format=text => exit DumpHtmlToDir($request); - $this->assertTrue(file_exists($cur_dir."/.dumphtml/".HOME_PAGE.".html")); + $this->assertTrue(file_exists($cur_dir."/.dumphtml/".HOME_PAGE.".html")); } } diff --git a/tests/unit/lib/HtmlParserTest.php b/tests/unit/lib/HtmlParserTest.php index 76ca3c5f5..87ac300af 100644 --- a/tests/unit/lib/HtmlParserTest.php +++ b/tests/unit/lib/HtmlParserTest.php @@ -47,5 +47,5 @@ class HtmlParserTest extends phpwiki_TestCase { // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/tests/unit/lib/InlineParserTest.php b/tests/unit/lib/InlineParserTest.php index fa37f54e3..d2a32cac5 100644 --- a/tests/unit/lib/InlineParserTest.php +++ b/tests/unit/lib/InlineParserTest.php @@ -52,7 +52,7 @@ class InlineParserTest extends phpwiki_TestCase { call_user_func(array(&$this, $this->_name)); } } - + function testNoWikiWords() { $str1 = 'This has no wiki words, and is all text.'; $xmlc1 = TransformInline($str1); @@ -75,12 +75,12 @@ class InlineParserTest extends phpwiki_TestCase { $this->assertEquals($ww, $c1[1]->asString()); $this->assertEquals('.', $c1[2]); } - + function _testLink($wiki, $expected = null) { if (is_null($expected)) { $ta = $this->_tests(); $expected = $ta[$wiki]; - } + } $xml = TransformInline($wiki); $this->assertTrue(isa($xml, 'XmlContent')); $expectobj = unserialize($expected); @@ -101,5 +101,5 @@ foreach (InlineParserTest::_tests() as $wiki => $expected) { // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/tests/unit/lib/SetupWiki.php b/tests/unit/lib/SetupWiki.php index 2ac257425..0146960a3 100644 --- a/tests/unit/lib/SetupWiki.php +++ b/tests/unit/lib/SetupWiki.php @@ -20,24 +20,24 @@ class SetupWiki extends phpwiki_TestCase { $request->setArg('source', false); $this->assertTrue($dbi->isWikiPage($pagename)); } - + /* PCRE memory problem (crash) with such big pages and anchored blocks */ /* // Broken since r.7418 function testOldMarkupTestPage() { $this->_loadPage('Help/OldMarkupTestPage'); }*/ - + /* ADODB set_links _id_cache error: IncludePagePlugin => HomePage */ function testIncludePagePlugin() { $this->_loadPage('Help/IncludePagePlugin'); } - + function testSetupWiki() { global $request; purge_testbox(); - + $dbi = $request->getDbh(); $dbi->purgePage('HomePage'); // possibly in cache $this->assertFalse($dbi->isWikiPage('HomePage')); @@ -47,7 +47,7 @@ class SetupWiki extends phpwiki_TestCase { LoadAny($request, $request->getArg('source')); $request->setArg('source', false); $request->setArg('overwrite', false); - + $this->assertTrue($dbi->isWikiPage('HomePage')); } } diff --git a/tests/unit/lib/TextSearchTest.php b/tests/unit/lib/TextSearchTest.php index 351f7ad0e..22d4aba8f 100644 --- a/tests/unit/lib/TextSearchTest.php +++ b/tests/unit/lib/TextSearchTest.php @@ -24,14 +24,14 @@ class TextSearchTest extends phpwiki_TestCase { $subpages = $dbi->titleSearch($query, $sortby, $limit, $exclude); // don't trust count() with limit - $this->assertTrue($subpages->count() > 0 and $subpages->count() <= 7, + $this->assertTrue($subpages->count() > 0 and $subpages->count() <= 7, "0 < count() <= 7"); $result = array(); // but the iterator should limit while ($page = $subpages->next()) $result[] = $page->getName(); $this->assertEquals(5, count($result), "limit 5"); - + } function testFulltextSearch() { @@ -71,7 +71,7 @@ class TextSearchTest extends phpwiki_TestCase { while ($page = $pages->next()) $result[] = $page->getName(); $this->assertTrue(in_array("TextFormattingRules", $result), "found case phrase"); - + } } diff --git a/tests/unit/lib/XmlRpcTest.php b/tests/unit/lib/XmlRpcTest.php index 539598942..bff8ae2a9 100644 --- a/tests/unit/lib/XmlRpcTest.php +++ b/tests/unit/lib/XmlRpcTest.php @@ -55,5 +55,5 @@ class XmlRpcTest extends phpwiki_TestCase { // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/tests/unit/lib/plugin/AllPagesTest.php b/tests/unit/lib/plugin/AllPagesTest.php index 0f86f97a5..d9d91062f 100644 --- a/tests/unit/lib/plugin/AllPagesTest.php +++ b/tests/unit/lib/plugin/AllPagesTest.php @@ -17,7 +17,7 @@ class AllPagesTest extends phpwiki_TestCase { $args = ""; $this->assertType('object', $request->_dbi, 'isa WikiDB'); /* -*/ +*/ $result = $lp->run($request->_dbi, $args, $request, "AllPages"); $this->assertType('object', $result, 'isa PageList'); $this->assertType('object', $request->_dbi, 'isa WikiDB'); @@ -28,7 +28,7 @@ class AllPagesTest extends phpwiki_TestCase { trigger_error("strange php bug\n",E_USER_WARNING); return; } - } + } $xml = $result->asXml(); $this->assertType('object', $result, 'isa XmlContent'); //$xml->asString(); diff --git a/tests/unit/lib/plugin/AtomFeedTest.php b/tests/unit/lib/plugin/AtomFeedTest.php index 8a2e31eb4..522cc5d75 100644 --- a/tests/unit/lib/plugin/AtomFeedTest.php +++ b/tests/unit/lib/plugin/AtomFeedTest.php @@ -30,12 +30,12 @@ class AtomFeedTest extends phpwiki_TestCase { var $atom_feed_plugin; - + public function setUp() { parent::setUp(); $this->atom_feed_plugin = new WikiPlugin_AtomFeed(); } - + public function testRunMaxItem() { global $request; $expected_html = <<
Foobar Éire
Millenium Spire, Dublin -
Geo coordinates: +
Geo coordinates: 53.349441 -6.260282
@@ -54,7 +54,7 @@ EXPECTED; $html = $this->atom_feed_plugin->run(null, 'url=file://' . dirname(__FILE__) . '/atom-example.xml maxitem=1', $request, '.'); $this->assertEquals($expected_html, trim(html_entity_decode($html->asXML()))); } - + public function testRunTitleOnly() { global $request; $expected_html = <<assertEquals("IncludePage", $lp->getName()); $dbi = $request->getDbh(); - $result = $lp->run($dbi, "page=$pagename section=Synopsis quiet=1", + $result = $lp->run($dbi, "page=$pagename section=Synopsis quiet=1", $request, "IncludePage"); $this->assertType('object', $result, 'isa HtmlElement'); //TODO: check content for found and extracted section diff --git a/tests/unit/lib/plugin/atom-example.xml b/tests/unit/lib/plugin/atom-example.xml index 927f3e03e..ee9badc30 100644 --- a/tests/unit/lib/plugin/atom-example.xml +++ b/tests/unit/lib/plugin/atom-example.xml @@ -16,7 +16,7 @@
Millenium Spire, Dublin -
Geo coordinates: +
Geo coordinates: 53.349441 -6.260282
@@ -32,7 +32,7 @@
Again Millenium Spire, Dublin -
Geo coordinates: +
Geo coordinates: 53.349441 -6.260282
@@ -48,7 +48,7 @@
Still Millenium Spire, Dublin -
Geo coordinates: +
Geo coordinates: 53.349441 -6.260282
@@ -64,7 +64,7 @@
Yet Again Millenium Spire, Dublin -
Geo coordinates: +
Geo coordinates: 53.349441 -6.260282
@@ -80,7 +80,7 @@
Yes, yes Millenium Spire, Dublin -
Geo coordinates: +
Geo coordinates: 53.349441 -6.260282
diff --git a/tests/unit/pcre-crash.php b/tests/unit/pcre-crash.php index 0671f3a24..d4788b071 100644 --- a/tests/unit/pcre-crash.php +++ b/tests/unit/pcre-crash.php @@ -28,7 +28,7 @@ $pat = "/\A( (?:.|\n)*?) (^ (?:[ \t]+\S (?:.*\s*\n[ \t]+\S)* | - \|(?:.*\n\|)* | [#*;]*(?:[*#]|;.*?:) | + \|(?:.*\n\|)* | [#*;]*(?:[*#]|;.*?:) | \[\s*(\d+)\s*\] | <\?plugin(?:-form)?\b.*\?>\s*$ | !{1,3}[^!]) diff --git a/tests/xmlrpc/interop-client.php b/tests/xmlrpc/interop-client.php index 89bfe3dbc..989d17e25 100644 --- a/tests/xmlrpc/interop-client.php +++ b/tests/xmlrpc/interop-client.php @@ -1,6 +1,6 @@ "; $params = array($args); $result = xu_rpc_http_concise(array(method => $method, - args => $params, - host => $server[host], - uri => $server[uri], - port => $server[port], + args => $params, + host => $server[host], + uri => $server[uri], + port => $server[port], debug => $debug, output => $output)); check_if_matches($method, $args, $result); @@ -128,9 +128,9 @@ function run_test($server, $debug, $output, $method, $args) { function run_no_param_test($server, $debug, $output, $method) { echo "
"; $result = xu_rpc_http_concise(array(method => $method, - host => $server[host], - uri => $server[uri], - port => $server[port], + host => $server[host], + uri => $server[uri], + port => $server[port], debug => $debug, output => $output)); @@ -140,7 +140,7 @@ function run_no_param_test($server, $debug, $output, $method) { else { fail($method, false, $result); } - + flush(); } @@ -170,7 +170,7 @@ function run_easy_tests($server, $debug=0, $output = null) { "varInt" => 3200, "varString" => "happy little string" ) )); - + $foo = "some base64 string"; xmlrpc_set_type($foo, "base64"); run_test($server, $debug, $output, "interopEchoTests.echoBase64", $foo); @@ -178,7 +178,7 @@ function run_easy_tests($server, $debug=0, $output = null) { $foo="19980717T14:08:55"; xmlrpc_set_type($foo, "datetime"); run_test($server, $debug, $output, "interopEchoTests.echoDate", $foo); - + run_no_param_test($server, $debug, $output, "interopEchoTests.noInParams"); } @@ -187,7 +187,7 @@ function ident($server, $debug=0, $output=null) { $result = xu_rpc_http_concise(array('method' => $method, 'host' => $server['host'], 'uri' => $server['uri'], - 'port' => $server['port'], + 'port' => $server['port'], 'debug' => $debug, 'output' => $output)); if ($result && $result['toolkitDocsUrl'] && !$result['faultCode']) { @@ -210,17 +210,17 @@ function run_stress_tests($server, $debug=0, $output=null) { run_test($server, $debug, $output, "interopEchoTests.echoString", "XML Comment in a string: "); run_test($server, $debug, $output, "interopEchoTests.echoInteger", 4200000000); run_test($server, $debug, $output, "interopEchoTests.echoFloat", 1.2); - run_test($server, $debug, $output, "interopEchoTests.echoStruct", + run_test($server, $debug, $output, "interopEchoTests.echoStruct", array("varFloat" => 1.2345, "varInt" => 186000, "varString" => "18 > 2 && 2 < 18 && 42 == the answer to life, the universe, and everything" )); - run_test($server, $debug, $output, "interopEchoTests.echoStringArray", + run_test($server, $debug, $output, "interopEchoTests.echoStringArray", array($decl_1, $decl_2, $decl_3, $decl_4, "non-ascii chars above 127 (165-170): ¥, ¦, §, ¨, ©, ª")); - run_test($server, $debug, $output, "interopEchoTests.echoIntegerArray", + run_test($server, $debug, $output, "interopEchoTests.echoIntegerArray", array(23, 234, 1, 0, -10, 999)); - run_test($server, $debug, $output, "interopEchoTests.echoFloatArray", + run_test($server, $debug, $output, "interopEchoTests.echoFloatArray", array(2.45, 9.9999)); - run_test($server, $debug, $output, "interopEchoTests.echoStructArray", + run_test($server, $debug, $output, "interopEchoTests.echoStructArray", array(array("varFloat" => 1.2345, "varInt" => 186000, "varString" => "non-print char (8): "), @@ -257,9 +257,9 @@ if ($server) { if ($server) { $title = $server['title']; echo "

Results for $title

"; - + ident($server, $debug, $output); - + if($GLOBALS['HTTP_GET_VARS']['stress'] == 1) { run_stress_tests($server, $debug, $output); } diff --git a/tests/xmlrpc/interop-server.php b/tests/xmlrpc/interop-server.php index 353a12c0b..60e243c96 100644 --- a/tests/xmlrpc/interop-server.php +++ b/tests/xmlrpc/interop-server.php @@ -27,11 +27,11 @@ function method_toolkit($method, $params) { // outer array = params, inner = struct. return array(toolkitDocsUrl => "http://xmlrpc-epi.sourceforge.net/", toolkitName => "xmlrpc-epi-php", - toolkitVersion => "0.26", // (need to implement xmlrpc_get_version() + toolkitVersion => "0.26", // (need to implement xmlrpc_get_version() toolkitOperatingSystem => $GLOBALS[MACHTYPE] ); } - + /* interopEchoTests.echoString (inputString) -- Sends a random string to the server, and checks that the response is a string whose value is the same as the string that was sent. @@ -75,7 +75,7 @@ if(!$request_xml) { else { // create server $xmlrpc_server = xmlrpc_server_create(); - + if($xmlrpc_server) { // register xmlrpc methods xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoBoolean", "method_echo"); @@ -120,7 +120,7 @@ else { //print_r($val); // parse xml and call method echo xmlrpc_server_call_method($xmlrpc_server, $request_xml, $response, array(output_type => "xml", version => "auto")); - + // free server resources $success = xmlrpc_server_destroy($xmlrpc_server); } @@ -226,7 +226,7 @@ END; - + diff --git a/tests/xmlrpc/validate-form.php b/tests/xmlrpc/validate-form.php index f9c71ba06..eb08d64f3 100644 --- a/tests/xmlrpc/validate-form.php +++ b/tests/xmlrpc/validate-form.php @@ -4,35 +4,35 @@ /* - This file is part of, or distributed with, libXMLRPC - a C library for + This file is part of, or distributed with, libXMLRPC - a C library for xml-encoded function calls. Author: Dan Libby (dan@libby.com) Epinions.com may be contacted at feedback@epinions-inc.com */ -/* - Copyright 2001 Epinions, Inc. +/* + Copyright 2001 Epinions, Inc. - Subject to the following 3 conditions, Epinions, Inc. permits you, free - of charge, to (a) use, copy, distribute, modify, perform and display this - software and associated documentation files (the "Software"), and (b) - permit others to whom the Software is furnished to do so as well. + Subject to the following 3 conditions, Epinions, Inc. permits you, free + of charge, to (a) use, copy, distribute, modify, perform and display this + software and associated documentation files (the "Software"), and (b) + permit others to whom the Software is furnished to do so as well. - 1) The above copyright notice and this permission notice shall be included - without modification in all copies or substantial portions of the - Software. + 1) The above copyright notice and this permission notice shall be included + without modification in all copies or substantial portions of the + Software. - 2) THE SOFTWARE IS PROVIDED "AS IS", WITHOUT ANY WARRANTY OR CONDITION OF - ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION ANY - IMPLIED WARRANTIES OF ACCURACY, MERCHANTABILITY, FITNESS FOR A PARTICULAR - PURPOSE OR NONINFRINGEMENT. + 2) THE SOFTWARE IS PROVIDED "AS IS", WITHOUT ANY WARRANTY OR CONDITION OF + ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION ANY + IMPLIED WARRANTIES OF ACCURACY, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE OR NONINFRINGEMENT. - 3) IN NO EVENT SHALL EPINIONS, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, - SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT - OF OR IN CONNECTION WITH THE SOFTWARE (HOWEVER ARISING, INCLUDING - NEGLIGENCE), EVEN IF EPINIONS, INC. IS AWARE OF THE POSSIBILITY OF SUCH - DAMAGES. + 3) IN NO EVENT SHALL EPINIONS, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT + OF OR IN CONNECTION WITH THE SOFTWARE (HOWEVER ARISING, INCLUDING + NEGLIGENCE), EVEN IF EPINIONS, INC. IS AWARE OF THE POSSIBILITY OF SUCH + DAMAGES. */ @@ -101,7 +101,7 @@ $test_cases = array( xml => ""), array( title => "arrayOfStructsTest", - desc => + desc => "This handler takes a single parameter, an array of structs, each of which contains at least three elements named moe, larry and curly, all s. Your handler must add all the struct elements named curly and return the result.", @@ -302,10 +302,10 @@ array( >, &, ' and \". Your handler must return a struct that contains five fields, all numbers: ctLeftAngleBrackets, - ctRightAngleBrackets, ctAmpersands, ctApostrophes, ctQuotes. + ctRightAngleBrackets, ctAmpersands, ctApostrophes, ctQuotes. To validate, the numbers must be correct", - xml => + xml => " validator1.countTheEntities @@ -614,7 +614,7 @@ array( array( title => "manyTypesTest", desc => "This handler takes six parameters, and returns an array containing all the parameters.", - xml => + xml => " validator1.manyTypesTest @@ -642,7 +642,7 @@ array( array( title => "moderateSizeArrayCheck", desc => "This handler takes a single parameter, which is an array containing between 100 and 200 elements. Each of the items is a string, your handler must return a string containing the concatenated text of the first and last elements.", - xml => + xml => " validator1.moderateSizeArrayCheck @@ -773,7 +773,7 @@ array(

Ken MacLeod: \"This description isn't clear, I expected '2000.April.1' when in fact it's '2000.04.01'. Adding a note saying that month and day are two-digits with leading 0s, and January is 01 would help.\" Done.", - xml => + xml => " validator1.nestedStructTest diff --git a/tests/xmlrpc/validate.php b/tests/xmlrpc/validate.php index 6ea6dbadd..d0cecb5a8 100644 --- a/tests/xmlrpc/validate.php +++ b/tests/xmlrpc/validate.php @@ -1,35 +1,35 @@ s. - * Your handler must add all the struct elements named curly and return the - * result. +/* + * This handler takes a single parameter, an array of structs, each of which + * contains at least three elements named moe, larry and curly, all s. + * Your handler must add all the struct elements named curly and return the + * result. */ function validator1_arrayOfStructsTest($method_name, $params, $app_data) { $iCurly = 0; @@ -51,17 +51,17 @@ function validator1_arrayOfStructsTest($method_name, $params, $app_data) { foreach(array_pop($params) as $iter) { $iCurly += $iter["curly"]; } - + return $iCurly; } /* - * This handler takes a single parameter, a string, that contains any number - * of predefined entities, namely <, >, &, ' and ". + * This handler takes a single parameter, a string, that contains any number + * of predefined entities, namely <, >, &, ' and ". * - * Your handler must return a struct that contains five fields, all numbers: - * ctLeftAngleBrackets, ctRightAngleBrackets, ctAmpersands, ctApostrophes, - * ctQuotes. + * Your handler must return a struct that contains five fields, all numbers: + * ctLeftAngleBrackets, ctRightAngleBrackets, ctAmpersands, ctApostrophes, + * ctQuotes. * * To validate, the numbers must be correct. */ @@ -81,9 +81,9 @@ function validator1_countTheEntities ($method_name, $params, $app_data) { } /* - * This handler takes a single parameter, a struct, containing at least three - * elements named moe, larry and curly, all s. Your handler must add the - * three numbers and return the result. + * This handler takes a single parameter, a struct, containing at least three + * elements named moe, larry and curly, all s. Your handler must add the + * three numbers and return the result. */ function validator1_easyStructTest ($method_name, $params, $app_data) { $iSum = 0; @@ -99,8 +99,8 @@ function validator1_easyStructTest ($method_name, $params, $app_data) { } /* - * This handler takes a single parameter, a struct. Your handler must return - * the struct. + * This handler takes a single parameter, a struct. Your handler must return + * the struct. */ function validator1_echoStructTest($method_name, $params, $app_data) { return $params[0]; @@ -108,12 +108,12 @@ function validator1_echoStructTest($method_name, $params, $app_data) { /* - * This handler takes six parameters, and returns an array containing all the - * parameters. + * This handler takes six parameters, and returns an array containing all the + * parameters. */ function validator1_manyTypesTest ($method_name, $params, $app_data) { $xArray = array(); - + foreach($params as $iter) { array_push($xArray, $iter); } @@ -123,10 +123,10 @@ function validator1_manyTypesTest ($method_name, $params, $app_data) { } /* - * This handler takes a single parameter, which is an array containing - * between 100 and 200 elements. Each of the items is a string, your handler - * must return a string containing the concatenated text of the first and - * last elements. + * This handler takes a single parameter, which is an array containing + * between 100 and 200 elements. Each of the items is a string, your handler + * must return a string containing the concatenated text of the first and + * last elements. */ function validator1_moderateSizeArrayCheck ($method_name, $params, $app_data) { $xArray = array_pop($params); @@ -138,16 +138,16 @@ function validator1_moderateSizeArrayCheck ($method_name, $params, $app_data) { } /* - * This handler takes a single parameter, a struct, that models a daily - * calendar. At the top level, there is one struct for each year. Each year - * is broken down into months, and months into days. Most of the days are - * empty in the struct you receive, but the entry for April 1, 2000 contains - * a least three elements named moe, larry and curly, all s. Your - * handler must add the three numbers and return the result. - * - * Ken MacLeod: "This description isn't clear, I expected '2000.April.1' when - * in fact it's '2000.04.01'. Adding a note saying that month and day are - * two-digits with leading 0s, and January is 01 would help." Done. + * This handler takes a single parameter, a struct, that models a daily + * calendar. At the top level, there is one struct for each year. Each year + * is broken down into months, and months into days. Most of the days are + * empty in the struct you receive, but the entry for April 1, 2000 contains + * a least three elements named moe, larry and curly, all s. Your + * handler must add the three numbers and return the result. + * + * Ken MacLeod: "This description isn't clear, I expected '2000.April.1' when + * in fact it's '2000.04.01'. Adding a note saying that month and day are + * two-digits with leading 0s, and January is 01 would help." Done. */ function validator1_nestedStructTest ($method_name, $params, $app_data) { @@ -166,9 +166,9 @@ function validator1_nestedStructTest ($method_name, $params, $app_data) { } /* - * This handler takes one parameter, and returns a struct containing three - * elements, times10, times100 and times1000, the result of multiplying the - * number by 10, 100 and 1000. + * This handler takes one parameter, and returns a struct containing three + * elements, times10, times100 and times1000, the result of multiplying the + * number by 10, 100 and 1000. */ function validator1_simpleStructReturnTest ($method_name, $params, $app_data) { $xStruct = array(); @@ -238,7 +238,7 @@ function validator1_simpleStructReturnTest ($method_name, $params, $app_data) { /* handle the request */ $response = xmlrpc_server_call_method($server, $request_xml, $response, $display); - + if($HTTP_POST_VARS[disp] === "html") { if($HTTP_POST_VARS[output_type] === "php") { echo "

\n"; diff --git a/tests/xmlrpc/xmlrpc-client.php b/tests/xmlrpc/xmlrpc-client.php index 03e527fc1..2b2d9837f 100644 --- a/tests/xmlrpc/xmlrpc-client.php +++ b/tests/xmlrpc/xmlrpc-client.php @@ -3,7 +3,7 @@ * Test the wiki XMLRPC interface methods. * This is a client app used to query most methods from our server. - * The interface specification is that discussed at + * The interface specification is that discussed at * http://www.ecyrd.com/JSPWiki/Wiki.jsp?page=WikiRPCInterface * Author: Reini Urban @@ -11,35 +11,35 @@ */ /* - This file is part of, or distributed with, libXMLRPC - a C library for + This file is part of, or distributed with, libXMLRPC - a C library for xml-encoded function calls. Author: Dan Libby (dan@libby.com) Epinions.com may be contacted at feedback@epinions-inc.com */ -/* - Copyright 2001 Epinions, Inc. +/* + Copyright 2001 Epinions, Inc. - Subject to the following 3 conditions, Epinions, Inc. permits you, free - of charge, to (a) use, copy, distribute, modify, perform and display this - software and associated documentation files (the "Software"), and (b) - permit others to whom the Software is furnished to do so as well. + Subject to the following 3 conditions, Epinions, Inc. permits you, free + of charge, to (a) use, copy, distribute, modify, perform and display this + software and associated documentation files (the "Software"), and (b) + permit others to whom the Software is furnished to do so as well. - 1) The above copyright notice and this permission notice shall be included - without modification in all copies or substantial portions of the - Software. + 1) The above copyright notice and this permission notice shall be included + without modification in all copies or substantial portions of the + Software. - 2) THE SOFTWARE IS PROVIDED "AS IS", WITHOUT ANY WARRANTY OR CONDITION OF - ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION ANY - IMPLIED WARRANTIES OF ACCURACY, MERCHANTABILITY, FITNESS FOR A PARTICULAR - PURPOSE OR NONINFRINGEMENT. + 2) THE SOFTWARE IS PROVIDED "AS IS", WITHOUT ANY WARRANTY OR CONDITION OF + ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION ANY + IMPLIED WARRANTIES OF ACCURACY, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE OR NONINFRINGEMENT. - 3) IN NO EVENT SHALL EPINIONS, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, - SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT - OF OR IN CONNECTION WITH THE SOFTWARE (HOWEVER ARISING, INCLUDING - NEGLIGENCE), EVEN IF EPINIONS, INC. IS AWARE OF THE POSSIBILITY OF SUCH - DAMAGES. + 3) IN NO EVENT SHALL EPINIONS, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT + OF OR IN CONNECTION WITH THE SOFTWARE (HOWEVER ARISING, INCLUDING + NEGLIGENCE), EVEN IF EPINIONS, INC. IS AWARE OF THE POSSIBILITY OF SUCH + DAMAGES. */ @@ -132,10 +132,10 @@ function run_test($server, $debug, $output, $method, $args='', $expected='') { if (!empty($HTTP_GET_VARS['start_debug'])) // zend ide support $server['uri'] .= "?start_debug=1"; $result = xu_rpc_http_concise(array('method' => $method, - 'args' => $params, - 'host' => $server['host'], - 'uri' => $server['uri'], - 'port' => $server['port'], + 'args' => $params, + 'host' => $server['host'], + 'uri' => $server['uri'], + 'port' => $server['port'], 'debug' => $debug, 'output' => $output)); check_if_matches($method, $expected, $result); @@ -150,9 +150,9 @@ function run_no_param_test($server, $debug, $output, $method) { if (!empty($HTTP_GET_VARS['start_debug'])) // zend ide support $server['uri'] .= "?start_debug=1"; $result = xu_rpc_http_concise(array('method' => $method, - 'host' => $server['host'], - 'uri' => $server['uri'], - 'port' => $server['port'], + 'host' => $server['host'], + 'uri' => $server['uri'], + 'port' => $server['port'], 'debug' => $debug, 'output' => $output)); @@ -162,7 +162,7 @@ function run_no_param_test($server, $debug, $output, $method) { else { fail($method, false, $result); } - + flush(); } @@ -173,11 +173,11 @@ function run_easy_tests($server, $debug=0, $output = null) { //global $wiki_dmap; run_test($server, $debug, $output, "wiki.getRPCVersionSupported", '', 1); - + // getRecentChanges of the last day: // Note: may crash with dba on index.php, not on RPC2.php run_test($server, $debug, $output, "wiki.getRecentChanges", iso8601_encode(time()-86400)); - + run_test($server, $debug, $output, "wiki.getPage", "HomePage", "* What is a WikiWikiWeb? A description of this application. * Learn HowToUseWiki and learn about AddingPages. * Use the SandBox page to experiment with Wiki pages. * Please sign your name in RecentVisitors. * See RecentChanges for the latest page additions and changes. * Find out which pages are MostPopular. * Read the ReleaseNotes and RecentReleases. * Administer this wiki via PhpWikiAdministration. * See more PhpWikiDocumentation."); run_test($server, $debug, $output, "wiki.getPageVersion", array("HomePage", 1)); run_test($server, $debug, $output, "wiki.getPageHTML", "HomePage"); @@ -187,10 +187,10 @@ function run_easy_tests($server, $debug=0, $output = null) { run_test($server, $debug, $output, "wiki.getPageInfoVersion", array("HomePage", 1)); run_test($server, $debug, $output, "wiki.listLinks", "HomePage"); - run_test($server, $debug, $output, "wiki.putPage", + run_test($server, $debug, $output, "wiki.putPage", array("PutPage", "new PutPage content", "XxXx"), array('code' => 200, 'version' => 1, 'message' => "Page PutPage version 1 created")); - run_test($server, $debug, $output, "wiki.putPage", + run_test($server, $debug, $output, "wiki.putPage", array("PutPage", "new PutPage content", "XxXx"), array('code' => 400, 'version' => 1, 'message' => "Page PutPage unchanged")); run_test($server, $debug, $output, "wiki.putPage", @@ -232,7 +232,7 @@ if ($server) { if ($server) { $title = $server['title']; echo "<h2><center>Results for $title</center></h2>"; - + if($GLOBALS['HTTP_GET_VARS']['stress'] == 1) { run_stress_tests($server, $debug, $output); } diff --git a/tests/xmlrpc/xmlrpc-introspect.php b/tests/xmlrpc/xmlrpc-introspect.php index 1e87ab1c3..6ebbe7776 100644 --- a/tests/xmlrpc/xmlrpc-introspect.php +++ b/tests/xmlrpc/xmlrpc-introspect.php @@ -4,8 +4,8 @@ * system.describeMethods Support * *********************************/ -/* public function. format method description. - * input = result from xmlrpc method "system.describeMethods" in a php array +/* public function. format method description. + * input = result from xmlrpc method "system.describeMethods" in a php array * result = html string suitable for display. */ function format_describe_methods_result($response) { @@ -187,7 +187,7 @@ function do_param($param, $bNewType=false, $bLinkUserTypes=true, $depth=0) { if ($bLinkUserTypes) { $type = "<a href='#$type'>$type</a>"; } - else { + else { /* hack to display user values inline. max depth check above. */ global $xi_type_hash; $newtype = $xi_type_hash[$type]; diff --git a/tests/xmlrpc/xmlrpc-servers.php b/tests/xmlrpc/xmlrpc-servers.php index 26bb80159..3fd222ca3 100644 --- a/tests/xmlrpc/xmlrpc-servers.php +++ b/tests/xmlrpc/xmlrpc-servers.php @@ -24,7 +24,7 @@ function get_user_server() { } function get_wiki_servers($include_user=true) { - $list = + $list = array ( array('title' => " local ", 'info_link' => "http://".$GLOBALS['SERVER_NAME'].dirname($GLOBALS['PHP_SELF'])."/../../index.php", @@ -79,7 +79,7 @@ function get_wiki_servers($include_user=true) { } function get_intro_useful_servers($include_user=true) { - $list = + $list = array ( array('title' => "xmlrpc-epi ( local! )", 'info_link' => "http://".$GLOBALS['SERVER_NAME'].dirname($GLOBALS['PHP_SELF'])."/interop-server.php", @@ -113,7 +113,7 @@ function get_intro_useful_servers($include_user=true) { } function get_introspection_servers($include_user=true) { - $list = + $list = array ( array('title' => "xmlrpc-epi interop server", 'info_link' => "http://".$GLOBALS['SERVER_NAME'].dirname($GLOBALS['PHP_SELF'])."/interop-server.php", @@ -142,7 +142,7 @@ function get_introspection_servers($include_user=true) { function get_interop_servers($include_user=true) { global $HTTP_SERVER_VARS; - $list = + $list = array ( array('title' => "local xmlrpc interop-server", 'info_link' => "http://".$GLOBALS['SERVER_NAME'].dirname($GLOBALS['PHP_SELF'])."/interop-server.php", @@ -228,12 +228,12 @@ function print_servers_form($server_list, $action_url=false, $print_user=true) { $title = "<a href='$link'>$title</a>"; } echo "<input type='radio' name='server' value='$key' $default>&nbsp;$title<br>"; - + if($type === "user") { echo "<DL><DT><DL><DT>host: <input type='text' name='user_host' size='50'></DT>" . "<DT>uri: <input type='text' name='user_uri' size='50'>" . "<DT>port: <input type='text' name='user_port' size='4' MAXLENGTH='4' VALUE='$port'></DT></DL></DT></DL>"; - + } } if ($GLOBALS['HTTP_GET_VARS']['start_debug']) diff --git a/themes/Hawaiian/lib/random.php b/themes/Hawaiian/lib/random.php index d556edc57..4f1fd4c1d 100644 --- a/themes/Hawaiian/lib/random.php +++ b/themes/Hawaiian/lib/random.php @@ -51,5 +51,5 @@ class imageSet extends fileSet { // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/MacOSX/images/index.php b/themes/MacOSX/images/index.php index 12d765438..15de50a6f 100644 --- a/themes/MacOSX/images/index.php +++ b/themes/MacOSX/images/index.php @@ -14,7 +14,7 @@ function changebg(color) { document.bgColor = backgroundcolor[color]; } </head><body bgcolor="#8888aa"> <?php $dir = opendir("."); -while($fileName = readdir($dir)) +while($fileName = readdir($dir)) if (!(strcmp(substr($fileName, -4), ".png"))) print("<img src=\"" . urlencode($fileName) . "\" alt=\"$fileName\" />\n"); ?> diff --git a/themes/MacOSX/lib/RecentChanges.php b/themes/MacOSX/lib/RecentChanges.php index 39e96f36d..4d451788b 100644 --- a/themes/MacOSX/lib/RecentChanges.php +++ b/themes/MacOSX/lib/RecentChanges.php @@ -9,7 +9,7 @@ require_once('lib/plugin/PageHistory.php'); function MacOSX_RC_revision_formatter (&$fmt, &$rev) { $class = 'rc-' . $fmt->importance($rev); - + return HTML::li(array('class' => $class), $fmt->diffLink($rev), ' ', $fmt->pageLink($rev), ' ', @@ -56,5 +56,5 @@ extends _PageHistory_HtmlFormatter // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/Portland/lib/RecentChanges.php b/themes/Portland/lib/RecentChanges.php index c5cc6a16b..15d9752a5 100644 --- a/themes/Portland/lib/RecentChanges.php +++ b/themes/Portland/lib/RecentChanges.php @@ -68,5 +68,5 @@ extends _PageHistory_HtmlFormatter // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/SpaceWiki/lib/RecentChanges.php b/themes/SpaceWiki/lib/RecentChanges.php index c4ebb1997..e873752ab 100644 --- a/themes/SpaceWiki/lib/RecentChanges.php +++ b/themes/SpaceWiki/lib/RecentChanges.php @@ -9,7 +9,7 @@ require_once('lib/plugin/PageHistory.php'); function SpaceWiki_RC_revision_formatter (&$fmt, &$rev) { $class = 'rc-' . $fmt->importance($rev); - + return HTML::li(array('class' => $class), $fmt->diffLink($rev), ' ', $fmt->pageLink($rev), ' ', @@ -79,5 +79,5 @@ extends _PageHistory_HtmlFormatter // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/Wordpress/lib/RecentChanges.php b/themes/Wordpress/lib/RecentChanges.php index 09dfc1bec..bc1235895 100644 --- a/themes/Wordpress/lib/RecentChanges.php +++ b/themes/Wordpress/lib/RecentChanges.php @@ -68,5 +68,5 @@ extends _PageHistory_HtmlFormatter // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/blog/lib/RecentChanges.php b/themes/blog/lib/RecentChanges.php index cd3b3b55d..6e9b3f483 100644 --- a/themes/blog/lib/RecentChanges.php +++ b/themes/blog/lib/RecentChanges.php @@ -47,5 +47,5 @@ extends _PageHistory_HtmlFormatter // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> -- 2.45.0