From fc4b601b390336880d36b389f154567900566b35 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Fri, 17 Aug 2007 15:54:31 +0000 Subject: [PATCH] functions.inc.php: ensure link is open for when we do escape_string stuff; update pg_escape_string usage for php > 5.2.0 git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@32 a1433add-5e2c-0410-b055-b7f2511e0802 --- functions.inc.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/functions.inc.php b/functions.inc.php index fe24286d..ba6868dc 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -218,17 +218,27 @@ function escape_string ($string) } if (!is_numeric($string)) { + $link = db_connect(); if ($CONF['database_type'] == "mysql") { - $link = db_connect(); $escaped_string = mysql_real_escape_string($string, $link); } if ($CONF['database_type'] == "mysqli") { - $link = db_connect(); $escaped_string = mysqli_real_escape_string($link, $string); } - if ($CONF['database_type'] == "pgsql") $escaped_string = pg_escape_string($string); + if ($CONF['database_type'] == "pgsql") + { + // php 5.2+ allows for $link to be specified. + if (version_compare(phpversion(), "5.2.0", ">=")) + { + $escaped_string = pg_escape_string($link, $string); + } + else + { + $escaped_string = pg_escape_string($string); + } + } } else {