Remove duplicated function getKeys(). Check PostgreSQL version >= 7.x . Rename a...
authorsoranzo <soranzo>
Mon, 7 Jun 2004 11:38:31 +0000 (11:38 +0000)
committersoranzo <soranzo>
Mon, 7 Jun 2004 11:38:31 +0000 (11:38 +0000)
classes/Misc.php
classes/database/Connection.php
classes/database/Postgres.php
classes/database/Postgres73.php
constraints.php
lang/english.php
lang/italian.php
lang/recoded/english.php
lang/recoded/italian.php
libraries/lib.inc.php
tables.php

index c6ed9841cfcb1acf4d0a68811cfb96dd72604994..77195289e807948c5bbdea954c4b488c9bc6b0fd 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.64 2004/06/06 08:50:27 chriskl Exp $
+        * $Id: Misc.php,v 1.65 2004/06/07 11:38:38 soranzo Exp $
         */
         
        class Misc {
                function printTitle($arr, $help = null) {
                        global $data, $lang;
 
-                       // Don't continue unles we are actually displaying something                    
+                       // Don't continue unless we are actually displaying something                   
                        if (!is_array($arr) || sizeof($arr) == 0) return;
                        
                        if ($help !== null && isset($data->help_page[$help])) {
                        echo "<!--\n";
                        echo "   document.{$object}.focus();\n";
                        echo "-->\n";
-                       echo "</script>\n";             
+                       echo "</script>\n";
                }
 
-        /**
-         * Converts a PHP.INI size variable to bytes.  Taken from publically available
-         * function by Chris DeRose, here: http://www.php.net/manual/en/configuration.directives.php#ini.file-uploads
-         * @param $strIniSize The PHP.INI variable
-         * @return size in bytes, false on failure
-         */
-        function inisizeToBytes($strIniSize) {
-           // This function will take the string value of an ini 'size' parameter,
-           // and return a double (64-bit float) representing the number of bytes that the parameter represents. Or false if $strIniSize is unparseable.
-           $a_IniParts = array();
-        
-           if (!is_string( $strIniSize ))
-               return false;
-        
-           if (!preg_match ('/^(\d+)([bkm]*)$/i', $strIniSize,$a_IniParts))
-               return false;
-          
-           $nSize    = (double) $a_IniParts[1];
-           $strUnit = strtolower($a_IniParts[2]);
-          
-           switch($strUnit) {
-               case 'm':
-                   return ($nSize * (double) 1048576);
-               case 'k':
-                   return ($nSize * (double) 1024);
-               case 'b':
-               default:
-                   return $nSize;
-           }
-        }               
+               /**
+                * Converts a PHP.INI size variable to bytes.  Taken from publically available
+                * function by Chris DeRose, here: http://www.php.net/manual/en/configuration.directives.php#ini.file-uploads
+                * @param $strIniSize The PHP.INI variable
+                * @return size in bytes, false on failure
+                */
+               function inisizeToBytes($strIniSize) {
+                       // This function will take the string value of an ini 'size' parameter,
+                       // and return a double (64-bit float) representing the number of bytes
+                       // that the parameter represents. Or false if $strIniSize is unparseable.
+                       $a_IniParts = array();
+
+                       if (!is_string($strIniSize))
+                               return false;
+
+                       if (!preg_match ('/^(\d+)([bkm]*)$/i', $strIniSize,$a_IniParts))
+                               return false;
+
+                       $nSize = (double) $a_IniParts[1];
+                       $strUnit = strtolower($a_IniParts[2]);
+
+                       switch($strUnit) {
+                               case 'm':
+                                       return ($nSize * (double) 1048576);
+                               case 'k':
+                                       return ($nSize * (double) 1024);
+                               case 'b':
+                               default:
+                                       return $nSize;
+                       }
+               }                
        }
 ?>
index d02f3112d0539dfd8dc0fb73e0d0447ad18cbbbd..7cab90be8afd50303d0e0d8a36109c10a818548a 100755 (executable)
@@ -3,7 +3,7 @@
 /**
  * Class to represent a database connection
  *
- * $Id: Connection.php,v 1.3 2004/04/17 12:59:04 chriskl Exp $
+ * $Id: Connection.php,v 1.4 2004/06/07 11:38:39 soranzo Exp $
  */
 
 include_once('./classes/database/ADODB_base.php');
@@ -33,6 +33,7 @@ class Connection {
         * Gets the name of the correct database driver to use
         * @param (return-by-ref) $description A description of the database and version
         * @return The class name of the driver eg. Postgres73
+        * @return null if version is < 7.0
         * @return -3 Database-specific failure
         */
        function getDriver(&$description) {
@@ -51,7 +52,9 @@ class Connection {
                // If unknown version, then default to latest driver
                // All 6.x versions default to oldest driver, even though
                // it won't work with those versions.
-               if (strpos($version, '7.4') === 0)
+               if ((int)substr($version, 0, 1) < 7)
+                       return null;
+               elseif (strpos($version, '7.4') === 0)
                        return 'Postgres74';
                elseif (strpos($version, '7.3') === 0)
                        return 'Postgres73';
@@ -59,8 +62,7 @@ class Connection {
                        return 'Postgres72';
                elseif (strpos($version, '7.1') === 0)
                        return 'Postgres71';
-               elseif (strpos($version, '7.0') === 0
-                               || strpos($version, '6.') === 0)
+               elseif (strpos($version, '7.0') === 0)
                        return 'Postgres';
                else
                        return 'Postgres75';
index 9342b39b9f6e5fb1b20e7580cdcfdc15e945f324..06a198c1651e0a4022be3f95a63be696076b1b51 100755 (executable)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres.php,v 1.221 2004/06/06 08:50:27 chriskl Exp $
+ * $Id: Postgres.php,v 1.222 2004/06/07 11:38:39 soranzo Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -421,11 +421,11 @@ class Postgres extends BaseDB {
                        else {
                                switch ($cons->f['contype']) {
                                        case 'p':
-                                               $keys = &$this->getKeys($table, explode(' ', $cons->f['indkey']));
+                                               $keys = &$this->getAttributeNames($table, explode(' ', $cons->f['indkey']));
                                                $sql .= "PRIMARY KEY (" . join(',', $keys) . ")";
                                                break;
                                        case 'u':
-                                               $keys = &$this->getKeys($table, explode(' ', $cons->f['indkey']));
+                                               $keys = &$this->getAttributeNames($table, explode(' ', $cons->f['indkey']));
                                                $sql .= "UNIQUE (" . join(',', $keys) . ")";
                                                break;
                                        default:
@@ -3346,37 +3346,6 @@ class Postgres extends BaseDB {
                return $this->execute($sql);
        }
 
-       /**
-        * A helper function for getConstraints that translates
-        * an array of attribute numbers to an array of field names.
-        * @param $table The name of the table
-        * @param $columsn An array of column ids
-        * @return An array of column names
-        */
-       function &getKeys($table, $colnums) {
-               $this->clean($table);
-               $this->arrayClean($colnums);
-
-               $sql = "SELECT attnum, attname FROM pg_attribute
-                       WHERE attnum IN ('" . join("','", $colnums) . "')
-                       AND attrelid = (SELECT oid FROM pg_class WHERE relname='{$table}')";
-
-               $rs = $this->selectSet($sql);
-
-               $temp = array();
-               while (!$rs->EOF) {
-                       $temp[$rs->f['attnum']] = $rs->f['attname'];
-                       $rs->moveNext();
-               }
-
-               $atts = array();
-               foreach ($colnums as $v) {
-                       $atts[] = '"' . $temp[$v] . '"';
-               }
-               
-               return $atts;
-       }
-
        /**
         * Returns a list of all constraints on a table
         * @param $table The table to find rules for
index 33467629bd0f3e0cf62d4f515b15167d07c83b9b..04f46d0309616fff431537e44bc702616999a936 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres73.php,v 1.119 2004/06/06 08:50:28 chriskl Exp $
+ * $Id: Postgres73.php,v 1.120 2004/06/07 11:38:39 soranzo Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -1016,39 +1016,6 @@ class Postgres73 extends Postgres72 {
                return $this->selectSet($sql);
         }
 
-       /**
-        * A helper function for getConstraints that translates
-        * an array of attribute numbers to an array of field names.
-        * @param $table The name of the table
-        * @param $columsn An array of column ids
-        * @return An array of column names
-        */
-       function &getKeys($table, $colnums) {
-               $this->clean($table);
-               $this->arrayClean($colnums);
-
-               $sql = "SELECT attnum, attname FROM pg_catalog.pg_attribute
-                       WHERE attnum IN ('" . join("','", $colnums) . "')
-                       AND attrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname='{$table}'
-                                       AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace
-                                       WHERE nspname='{$this->_schema}'))";
-
-               $rs = $this->selectSet($sql);
-
-               $temp = array();
-               while (!$rs->EOF) {
-                       $temp[$rs->f['attnum']] = $rs->f['attname'];
-                       $rs->moveNext();
-               }
-
-               $atts = array();
-               foreach ($colnums as $v) {
-                       $atts[] = '"' . $temp[$v] . '"';
-               }
-               
-               return $atts;
-       }
-
        /**
         * Returns a list of all constraints on a table
         * @param $table The table to find rules for
index bc5b77a156c36e676b5bddc5397263f0c3fca729..1c95bcc1e9db0580fbd6e4d97f2982c0a2ce6906 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List constraints on a table
         *
-        * $Id: constraints.php,v 1.28 2004/05/19 01:28:34 soranzo Exp $
+        * $Id: constraints.php,v 1.29 2004/06/07 11:38:31 soranzo Exp $
         */
 
        // Include application functions
                                if ($constraints->f['consrc'] !== null)
                                        echo $misc->printVal($constraints->f[$data->cnFields['consrc']]);
                                else {
-                                       $atts = &$data->getKeys($_REQUEST['table'], explode(' ', $constraints->f['indkey']));
+                                       $atts = &$data->getAttributeNames($_REQUEST['table'], explode(' ', $constraints->f['indkey']));
                                        echo ($constraints->f['contype'] == 'u') ? "UNIQUE (" : "PRIMARY KEY (";
                                        echo join(',', $atts);
                                        echo ")";
index b4fe251b5c6fe06b6979fd8d3cc66b08b6c4c2f7..36a4a59832629bdef291f7617d0bfc39d8ebf0d9 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.146 2004/06/06 08:50:28 chriskl Exp $
+        * $Id: english.php,v 1.147 2004/06/07 11:38:39 soranzo Exp $
         */
 
        // Language and character set
        $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
        $lang['strbadconfig'] = 'Your config.inc.php is out of date. You will need to regenerate it from the new config.inc.php-dist.';
        $lang['strnotloaded'] = 'Your PHP installation does not support PostgreSQL. You need to recompile PHP using the --with-pgsql configure option.';
+       $lang['strphpversionnotsupported'] = 'Version of PHP not supported. Please upgrade to version %s or later.';
+       $lang['strpostgresqlversionnotsupported'] = 'Version of PostgreSQL not supported. Please upgrade to version %s or later.';
        $lang['strbadschema'] = 'Invalid schema specified.';
        $lang['strbadencoding'] = 'Failed to set client encoding in database.';
        $lang['strsqlerror'] = 'SQL error:';
        $lang['strconfdeleterow'] = 'Are you sure you want to delete this row?';
        $lang['strrowdeleted'] = 'Row deleted.';
        $lang['strrowdeletedbad'] = 'Row deletion failed.';
-       $lang['strsaveandrepeat'] = 'Insert & Repeat';
+       $lang['strinsertandrepeat'] = 'Insert & Repeat';
        $lang['strfield'] = 'Field';
        $lang['strfields'] = 'Fields';
        $lang['strnumfields'] = 'Num. of fields';
index 4ac15b1a656ff76b012c1fe103f871a1bcee3f9f..e09e1ef752f64555292a7230d875cf8a29674125 100644 (file)
@@ -4,7 +4,7 @@
         * Italian language file, based on the english language file for phpPgAdmin.
         * Nicola Soranzo [nsoranzo@tiscali.it]
          *
-        * $Id: italian.php,v 1.31 2004/05/26 11:27:00 soranzo Exp $
+        * $Id: italian.php,v 1.32 2004/06/07 11:38:39 soranzo Exp $
         */
 
        // Language and character set - Lingua e set di caratteri
        $lang['strconfirm'] = 'Conferma';
        $lang['strexpression'] = 'Espressione';
        $lang['strellipsis'] = '...';
+       $lang['strseparator'] = ': ';
        $lang['strexpand'] = 'Espandi';
        $lang['strcollapse'] = 'Raccogli';
        $lang['strexplain'] = 'Explain';
        $lang['strfileimported'] = 'File importato.';
 
        // Error handling - Gestione degli errori
-       $lang['strnoframes'] = 'Devi usare un browser che supporti i frame per usare questa applicazione.';
-       $lang['strbadconfig'] = 'Il file config.inc.php è obsoleto. Devi rigenerarlo utilizzando il nuovo file config.inc.php-dist .';
-       $lang['strnotloaded'] = 'La tua installazione di PHP non supporta PostgreSQL. Devi ricompilare PHP usando l\'opzione di configurazione --with-pgsql .';
+       $lang['strnoframes'] = 'Per usare questa applicazione è necessario usare un browser che supporti i frame.';
+       $lang['strbadconfig'] = 'Il file config.inc.php è obsoleto. È necessario rigenerarlo utilizzando il nuovo file config.inc.php-dist .';
+       $lang['strnotloaded'] = 'La tua installazione di PHP non supporta PostgreSQL. È necessario ricompilare PHP usando l\'opzione di configurazione --with-pgsql .';
+       $lang['strphpversionnotsupported'] = 'Versione di PHP non supportata. È necessario aggiornarlo alla versione %s o successiva.';
+       $lang['strpostgresqlversionnotsupported'] = 'Versione di PostgreSQL non supportata. È necessario aggiornarlo alla versione %s o successiva.';
        $lang['strbadschema'] = 'Schema specificato non valido.';
        $lang['strbadencoding'] = 'Impostazione della codifica del client nel database fallito.';
        $lang['strsqlerror'] = 'Errore SQL:';
        $lang['strconfdeleterow'] = 'Sei sicuro di voler cancellare questa riga?';
        $lang['strrowdeleted'] = 'Riga cancellata.';
        $lang['strrowdeletedbad'] = 'Cancellazione della riga fallita.';
-       $lang['strsaveandrepeat'] = 'Salva e ripeti';
+       $lang['strinsertandrepeat'] = 'Inserisci e ripeti';
        $lang['strfield'] = 'Campo';
        $lang['strfields'] = 'Campi';
        $lang['strnumfields'] = 'Numero di campi';
index f2bffdae7cb41e04be9d43ae9e6877a737969534..3c3fd6e7548c67aa7acd34d2656173de44a09715 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.99 2004/06/06 08:50:28 chriskl Exp $
+        * $Id: english.php,v 1.100 2004/06/07 11:38:39 soranzo Exp $
         */
 
        // Language and character set
        $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
        $lang['strbadconfig'] = 'Your config.inc.php is out of date. You will need to regenerate it from the new config.inc.php-dist.';
        $lang['strnotloaded'] = 'Your PHP installation does not support PostgreSQL. You need to recompile PHP using the --with-pgsql configure option.';
+       $lang['strphpversionnotsupported'] = 'Version of PHP not supported. Please upgrade to version %s or later.';
+       $lang['strpostgresqlversionnotsupported'] = 'Version of PostgreSQL not supported. Please upgrade to version %s or later.';
        $lang['strbadschema'] = 'Invalid schema specified.';
        $lang['strbadencoding'] = 'Failed to set client encoding in database.';
        $lang['strsqlerror'] = 'SQL error:';
        $lang['strconfdeleterow'] = 'Are you sure you want to delete this row?';
        $lang['strrowdeleted'] = 'Row deleted.';
        $lang['strrowdeletedbad'] = 'Row deletion failed.';
-       $lang['strsaveandrepeat'] = 'Insert &amp; Repeat';
+       $lang['strinsertandrepeat'] = 'Insert &amp; Repeat';
        $lang['strfield'] = 'Field';
        $lang['strfields'] = 'Fields';
        $lang['strnumfields'] = 'Num. of fields';
index 747a3124722962eabc9c0b71e140ab18b31d977e..193647d7649da74ec9b995727c883e6e7e279c93 100644 (file)
@@ -4,7 +4,7 @@
         * Italian language file, based on the english language file for phpPgAdmin.
         * Nicola Soranzo [nsoranzo@tiscali.it]
          *
-        * $Id: italian.php,v 1.26 2004/05/26 11:27:00 soranzo Exp $
+        * $Id: italian.php,v 1.27 2004/06/07 11:38:39 soranzo Exp $
         */
 
        // Language and character set - Lingua e set di caratteri
        $lang['strconfirm'] = 'Conferma';
        $lang['strexpression'] = 'Espressione';
        $lang['strellipsis'] = '...';
+       $lang['strseparator'] = ': ';
        $lang['strexpand'] = 'Espandi';
        $lang['strcollapse'] = 'Raccogli';
        $lang['strexplain'] = 'Explain';
        $lang['strfileimported'] = 'File importato.';
 
        // Error handling - Gestione degli errori
-       $lang['strnoframes'] = 'Devi usare un browser che supporti i frame per usare questa applicazione.';
-       $lang['strbadconfig'] = 'Il file config.inc.php &egrave; obsoleto. Devi rigenerarlo utilizzando il nuovo file config.inc.php-dist .';
-       $lang['strnotloaded'] = 'La tua installazione di PHP non supporta PostgreSQL. Devi ricompilare PHP usando l\'opzione di configurazione --with-pgsql .';
+       $lang['strnoframes'] = 'Per usare questa applicazione &egrave; necessario usare un browser che supporti i frame.';
+       $lang['strbadconfig'] = 'Il file config.inc.php &egrave; obsoleto. &Egrave; necessario rigenerarlo utilizzando il nuovo file config.inc.php-dist .';
+       $lang['strnotloaded'] = 'La tua installazione di PHP non supporta PostgreSQL. &Egrave; necessario ricompilare PHP usando l\'opzione di configurazione --with-pgsql .';
+       $lang['strphpversionnotsupported'] = 'Versione di PHP non supportata. &Egrave; necessario aggiornarlo alla versione %s o successiva.';
+       $lang['strpostgresqlversionnotsupported'] = 'Versione di PostgreSQL non supportata. &Egrave; necessario aggiornarlo alla versione %s o successiva.';
        $lang['strbadschema'] = 'Schema specificato non valido.';
        $lang['strbadencoding'] = 'Impostazione della codifica del client nel database fallito.';
        $lang['strsqlerror'] = 'Errore SQL:';
        $lang['strconfdeleterow'] = 'Sei sicuro di voler cancellare questa riga?';
        $lang['strrowdeleted'] = 'Riga cancellata.';
        $lang['strrowdeletedbad'] = 'Cancellazione della riga fallita.';
-       $lang['strsaveandrepeat'] = 'Salva e ripeti';
+       $lang['strinsertandrepeat'] = 'Inserisci e ripeti';
        $lang['strfield'] = 'Campo';
        $lang['strfields'] = 'Campi';
        $lang['strnumfields'] = 'Numero di campi';
index 6e89afbf18a1334c0f578da594bfc3bdb775c18b..bcde1ab7aba462e750234f57e2283a44ec847f4f 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Function library read in upon startup
         *
-        * $Id: lib.inc.php,v 1.78 2004/06/06 06:34:28 chriskl Exp $
+        * $Id: lib.inc.php,v 1.79 2004/06/07 11:38:39 soranzo Exp $
         */
        
        // Set error reporting level to max
@@ -15,6 +15,9 @@
        // Application version
        $appVersion = '3.5-dev';
 
+       // PostgreSQL and PHP minimum version
+       $postgresqlMinVer = '7.0';
+       $phpMinVer = '4.1';
 
        // Check to see if the configuration file exists, if not, explain
        if (file_exists('conf/config.inc.php')) {
                // Get the name of the database driver we need to use.  The description
                // of the server is returned and placed into the conf array.
                $_type = $_connection->getDriver($conf['description']);
-               // XXX: NEED TO CHECK RETURN STATUS HERE
+               if ($_type === null) {
+                       printf($lang['strpostgresqlversionnotsupported'], $postgresqlMinVer);
+                       exit;
+               }
 
                // Create a database wrapper class for easy manipulation of the
                // connection.
index 34818191097751e4ab644ed0ad184612154ce904..d03363f440428f7d0991cab0ea760f395a02d0af 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tables.php,v 1.54 2004/06/06 08:50:27 chriskl Exp $
+        * $Id: tables.php,v 1.55 2004/06/07 11:38:38 soranzo Exp $
         */
 
        // Include application functions
                                        // Set up default value if there isn't one already
                                        if (!isset($_REQUEST['values'][$attrs->f['attname']]))
                                                $_REQUEST['values'][$attrs->f['attname']] = $attrs->f['adsrc'];
-                                       // Default format to 'LITERAL' if there is no default, otherwise
-                                       // default to 'EXPRESSION'...
+                                       // Default format to 'VALUE' if there is no default,
+                                       // otherwise default to 'EXPRESSION'
                                        if (!isset($_REQUEST['format'][$attrs->f['attname']]))
                                                $_REQUEST['format'][$attrs->f['attname']] = ($attrs->f['adsrc'] === null) ? 'VALUE' : 'EXPRESSION';
                                        // Continue drawing row
                        echo "<input type=\"hidden\" name=\"action\" value=\"insertrow\" />\n";
                        echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
                        echo $misc->form;
-                       echo "<p><input type=\"submit\" name=\"save\" value=\"{$lang['strinsert']}\" />\n";
-                       echo "<input type=\"submit\" name=\"saveandrepeat\" value=\"{$lang['strsaveandrepeat']}\" />\n";
+                       echo "<p><input type=\"submit\" name=\"insert\" value=\"{$lang['strinsert']}\" />\n";
+                       echo "<input type=\"submit\" name=\"insertandrepeat\" value=\"{$lang['strinsertandrepeat']}\" />\n";
                        echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
                        echo "</form>\n";
                }
                        $status = $data->insertRow($_POST['table'], $_POST['values'], 
                                                                                                $_POST['nulls'], $_POST['format'], $_POST['types']);
                        if ($status == 0) {
-                               if (isset($_POST['save']))
+                               if (isset($_POST['insert']))
                                        doDefault($lang['strrowinserted']);
                                else {
                                        $_REQUEST['values'] = array();