/**
* 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;
+ }
+ }
}
?>
/**
* 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');
* 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) {
// 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';
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';
* 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???
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:
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
* 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???
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
/**
* 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 ")";
* 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';
* 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';
* 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 & Repeat';
+ $lang['strinsertandrepeat'] = 'Insert & Repeat';
$lang['strfield'] = 'Field';
$lang['strfields'] = 'Fields';
$lang['strnumfields'] = 'Num. of fields';
* 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 è 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';
/**
* 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
// 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.
/**
* 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();