From 823d631bf32d7778ec9883ff2f0b193b954fe81e Mon Sep 17 00:00:00 2001 From: "Jehan-Guillaume (ioguix) de Rorthais" Date: Fri, 27 Nov 2009 09:40:14 +0100 Subject: [PATCH] Replace some deprecated fonctions in php 5.3. Patch by Jason Jackson --- classes/Misc.php | 2 +- classes/database/Connection.php | 2 +- classes/database/Postgres.php | 12 ++++++------ classes/database/Postgres73.php | 2 +- colproperties.php | 2 +- dataexport.php | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/classes/Misc.php b/classes/Misc.php index 62067bb7..08d4f6e5 100644 --- a/classes/Misc.php +++ b/classes/Misc.php @@ -1880,7 +1880,7 @@ // Due to annoying PHP bugs, shell arguments cannot be escaped // (command simply fails), so we cannot allow complex objects // to be dumped. - if (ereg('^[_.[:alnum:]]+$', $str)) + if (preg_match('/^[_.[:alnum:]]+$/', $str)) return $str; else { echo $lang['strcannotdumponwindows']; diff --git a/classes/database/Connection.php b/classes/database/Connection.php index e9006320..8a61b9f9 100755 --- a/classes/database/Connection.php +++ b/classes/database/Connection.php @@ -67,7 +67,7 @@ class Connection { $field = $adodb->selectField($sql, 'version'); // Check the platform, if it's mingw, set it - if (eregi(' mingw ', $field)) + if (preg_match('/ mingw /i', $field)) $this->platform = 'MINGW'; $params = explode(' ', $field); diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index a15a3b34..1b68a860 100755 --- a/classes/database/Postgres.php +++ b/classes/database/Postgres.php @@ -7177,7 +7177,7 @@ class Postgres extends ADODB_base { private function valid_dolquote($dquote) { // XXX: support multibyte - return (ereg('^[$][$]', $dquote) || ereg('^[$][_[:alpha:]][_[:alnum:]]*[$]', $dquote)); + return (preg_match('/^[$][$]/', $dquote) || preg_match('/^[$][_[:alpha:]][_[:alnum:]]*[$]/', $dquote)); } /** @@ -7370,9 +7370,9 @@ class Postgres extends ADODB_base { * of a dollar quote. */ // XXX: multibyte here - else if (ereg('^[_[:alpha:]]$', substr($line, $i, 1))) { + else if (preg_match('/^[_[:alpha:]]$/', substr($line, $i, 1))) { $sub = substr($line, $i, $thislen); - while (ereg('^[\$_A-Za-z0-9]$', $sub)) { + while (preg_match('/^[\$_A-Za-z0-9]$/', $sub)) { /* keep going while we still have identifier chars */ $this->advance_1($i, $prevlen, $thislen); $sub = substr($line, $i, $thislen); @@ -7510,7 +7510,7 @@ class Postgres extends ADODB_base { foreach ($orderby as $k => $v) { if ($first) $first = false; else $sql .= ', '; - if (ereg('^[0-9]+$', $k)) { + if (preg_match('/^[0-9]+$/', $k)) { $sql .= $k; } else { @@ -7549,7 +7549,7 @@ class Postgres extends ADODB_base { // If $type is TABLE, then generate the query switch ($type) { case 'TABLE': - if (ereg('^[0-9]+$', $sortkey) && $sortkey > 0) $orderby = array($sortkey => $sortdir); + if (preg_match('/^[0-9]+$/', $sortkey) && $sortkey > 0) $orderby = array($sortkey => $sortdir); else $orderby = array(); $query = $this->getSelectSQL($table, array(), array(), array(), $orderby); break; @@ -7606,7 +7606,7 @@ class Postgres extends ADODB_base { // Figure out ORDER BY. Sort key is always the column number (based from one) // of the column to order by. Only need to do this for non-TABLE queries - if ($type != 'TABLE' && ereg('^[0-9]+$', $sortkey) && $sortkey > 0) { + if ($type != 'TABLE' && preg_match('/^[0-9]+$/', $sortkey) && $sortkey > 0) { $orderby = " ORDER BY {$sortkey}"; // Add sort order if ($sortdir == 'desc') diff --git a/classes/database/Postgres73.php b/classes/database/Postgres73.php index 996383f5..a0565fe5 100644 --- a/classes/database/Postgres73.php +++ b/classes/database/Postgres73.php @@ -252,7 +252,7 @@ class Postgres73 extends Postgres74 { $grodata = $this->selectSet($sql); if ($grodata->fields['grolist'] !== null && $grodata->fields['grolist'] != '{}') { $members = $grodata->fields['grolist']; - $members = ereg_replace("\{|\}","",$members); + $members = preg_replace("/\{|\}/","",$members); $this->clean($members); $sql = "SELECT usename FROM pg_user WHERE usesysid IN ({$members}) ORDER BY usename"; diff --git a/colproperties.php b/colproperties.php index 7cf04144..dc582a0d 100644 --- a/colproperties.php +++ b/colproperties.php @@ -67,7 +67,7 @@ } // To figure out the length, look in the brackets :( // XXX: HACKY - if ($column->fields['type'] != $column->fields['base_type'] && ereg('\\(([0-9, ]*)\\)', $column->fields['type'], $bits)) { + if ($column->fields['type'] != $column->fields['base_type'] && preg_match('/\\(([0-9, ]*)\\)/', $column->fields['type'], $bits)) { $_REQUEST['length'] = $bits[1]; } else diff --git a/dataexport.php b/dataexport.php index ca6f7d32..b10d4882 100644 --- a/dataexport.php +++ b/dataexport.php @@ -129,7 +129,7 @@ $v = $data->escapeBytea($v); // We add an extra escaping slash onto octal encoded characters - $v = ereg_replace('\\\\([0-7]{3})', '\\\\\1', $v); + $v = preg_replace('/\\\\([0-7]{3})/', '\\\\\1', $v); if ($first) { echo ($v == null) ? '\\N' : $v; $first = false; @@ -232,7 +232,7 @@ // EXCEPT the 'special' ones like \r \n \t, etc. $v = addCSlashes($v, "\0..\37\177..\377"); // We add an extra escaping slash onto octal encoded characters - $v = ereg_replace('\\\\([0-7]{3})', '\\\1', $v); + $v = preg_replace('/\\\\([0-7]{3})/', '\\\1', $v); // Finally, escape all apostrophes $v = str_replace("'", "''", $v); } -- 2.39.5