fix adodb connection routine for when password, host, username, port or dbname contai...
authorchriskl <chriskl>
Tue, 24 Dec 2002 05:45:37 +0000 (05:45 +0000)
committerchriskl <chriskl>
Tue, 24 Dec 2002 05:45:37 +0000 (05:45 +0000)
libraries/adodb/adodb-postgres.inc.php

index 91c1ce98133a33e1e3863c54c3ce0998972a142e..b981e46d7788e60195f26d6536174dc691ae50bb 100755 (executable)
@@ -180,16 +180,15 @@ a different OID if a database must be reloaded. */
                if ($user || $pwd || $db) {\r
                if ($str)  {\r
                                $host = split(":", $str);\r
-                               if ($host[0]) $str = "host=$host[0]";\r
+                               if ($host[0]) $str = "host='" . addslashes($host[0]) . "'";\r
                                else $str = 'localhost';\r
-                               if (isset($host[1])) $str .= " port=$host[1]";\r
+                               if (isset($host[1])) $str .= " port='" . addslashes($host[1]) . "'";\r
                        }\r
-                       if ($user) $str .= " user='{$user}'";\r
-                       if ($pwd)  $str .= " password='{$pwd}'";\r
-                       if ($db)   $str .= " dbname='{$db}'";\r
+                       if ($user) $str .= " user='" . addslashes($user) . "'";\r
+                       if ($pwd)  $str .= " password='" . addslashes($pwd) . "'";\r
+                       if ($db)   $str .= " dbname='" . addslashes($db) . "'";\r
                }\r
                \r
-               //if ($user) $linea = "user=$user host=$linea password=$pwd dbname=$db port=5432";\r
                $this->_connectionID = @pg_connect($str);\r
 \r
                if ($this->_connectionID === false) return false;\r
@@ -205,17 +204,19 @@ a different OID if a database must be reloaded. */
        function _pconnect($str,$user='',$pwd='',$db='')\r
        {\r
                if ($user || $pwd || $db) {\r
-                       if ($str)  {\r
+               if ($str)  {\r
                                $host = split(":", $str);\r
-                               if ($host[0]) $str = "host=$host[0]";\r
+                               if ($host[0]) $str = "host='" . addslashes($host[0]) . "'";\r
                                else $str = 'localhost';\r
-                               if (isset($host[1])) $str .= " port=$host[1]";\r
+                               if (isset($host[1])) $str .= " port='" . addslashes($host[1]) . "'";\r
                        }\r
-                       if ($user) $str .= " user='{$user}'";\r
-                       if ($pwd)  $str .= " password='{$pwd}'";\r
-                       if ($db)   $str .= " dbname='{$db}'";\r
-               }//print $str;\r
+                       if ($user) $str .= " user='" . addslashes($user) . "'";\r
+                       if ($pwd)  $str .= " password='" . addslashes($pwd) . "'";\r
+                       if ($db)   $str .= " dbname='" . addslashes($db) . "'";\r
+               }\r
+\r
                $this->_connectionID = @pg_pconnect($str);\r
+\r
                if ($this->_connectionID === false) return false;\r
                $this->Execute("set datestyle='ISO'");\r
                return true;\r