From c13b092410898ec86a1ead371141c9d8fe17b050 Mon Sep 17 00:00:00 2001 From: chriskl Date: Wed, 10 Dec 2003 16:03:29 +0000 Subject: [PATCH] single db connection mega-commit. phpPgAdmin now only makes one connection to the database on the startup of each page, instead of 3pwd The whole app seems to be running a lot faster now, but there may be bugs remaingin... --- BUGS | 5 +- DEVELOPERS | 3 +- HISTORY | 4 ++ all_db.php | 5 +- bottombar.php | 7 +- browser.php | 10 +-- casts.php | 6 +- classes/Misc.php | 97 +++++++--------------------- classes/Reports.php | 11 +--- classes/database/ADODB_base.php | 9 ++- classes/database/BaseDB.php | 6 +- classes/database/Connection.php | 69 ++++++++++++++++++++ classes/database/Postgres.php | 22 ++----- classes/database/Postgres71.php | 12 ++-- classes/database/Postgres72.php | 12 ++-- classes/database/Postgres73.php | 14 ++-- classes/database/Postgres74.php | 12 ++-- classes/database/Postgres75.php | 12 ++-- constraints.php | 50 +++++++------- conversions.php | 6 +- database.php | 30 ++++----- dataexport.php | 32 ++++----- display.php | 32 ++++----- domains.php | 44 ++++++------- functions.php | 38 +++++------ indexes.php | 26 ++++---- info.php | 22 +++---- languages.php | 6 +- libraries/lib.inc.php | 111 ++++++++++++++------------------ operators.php | 18 +++--- privileges.php | 16 ++--- rules.php | 16 ++--- schema.php | 5 +- sequences.php | 26 ++++---- sql.php | 10 +-- sqledit.php | 4 +- tables.php | 54 ++++++++-------- tblproperties.php | 50 +++++++------- triggers.php | 34 +++++----- types.php | 26 ++++---- views.php | 46 ++++++------- 41 files changed, 495 insertions(+), 523 deletions(-) create mode 100755 classes/database/Connection.php diff --git a/BUGS b/BUGS index 38b7f9b3..27919576 100644 --- a/BUGS +++ b/BUGS @@ -15,7 +15,10 @@ fix constraint search to get domain and table constraints? dump sequences when dumping tables fix dumping clustering info can't edit SELECT results by oid -use LINK REL to speed up page loading times for CSS investigate phpPgInfo +Fix +--- + +* Does dropping a database work at all? diff --git a/DEVELOPERS b/DEVELOPERS index bf76c99c..48c3833a 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -72,8 +72,7 @@ HREFs and htmlspecialchars() variables in forms. COMMON VARIABLES ---------------- -$data - A data connection to the template1 database. -$localData - A data connection to the current database. +$data - A data connection to the current or default database. $misc - Contains miscellaneous functions. eg. printing headers and footers, etc. $lang - Global array containing translated strings. The strings in this array have already been converted to HTML, so you should not htmlspecialchars() them. diff --git a/HISTORY b/HISTORY index 01c41ef7..fec5f14b 100644 --- a/HISTORY +++ b/HISTORY @@ -4,6 +4,10 @@ phpPgAdmin History Version 3.3-dev --------------- +Features +* Large speed improvements by reducing number of database + connections and using external style sheet. + Bugs * Object browser fixed for databases with no schemas diff --git a/all_db.php b/all_db.php index c1cd9694..8ee0e904 100644 --- a/all_db.php +++ b/all_db.php @@ -3,7 +3,7 @@ /** * Manage databases within a server * - * $Id: all_db.php,v 1.18 2003/09/30 09:33:43 soranzo Exp $ + * $Id: all_db.php,v 1.19 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -17,7 +17,7 @@ * Show confirmation of drop and perform actual drop */ function doDrop($confirm) { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang, $_reload_drop_database; if ($confirm) { @@ -32,7 +32,6 @@ echo "\n"; } else { - $localData->close(); $status = $data->dropDatabase($_POST['database']); if ($status == 0) { $_reload_drop_database = true; diff --git a/bottombar.php b/bottombar.php index 6aa34620..cbb1258e 100644 --- a/bottombar.php +++ b/bottombar.php @@ -1,12 +1,13 @@ printHeader(); diff --git a/browser.php b/browser.php index daaad3db..ee3ab85e 100644 --- a/browser.php +++ b/browser.php @@ -5,7 +5,7 @@ * if you click on a database it shows a list of database objects in that * database. * - * $Id: browser.php,v 1.28 2003/12/05 07:29:58 chriskl Exp $ + * $Id: browser.php,v 1.29 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -36,7 +36,7 @@ * @param $schemanode Node onto which to add */ function addNodes(&$schemanode, $querystr) { - global $data, $localData, $misc, $lang, $conf; + global $data, $misc, $lang, $conf; // Session tracking $querystr .= '&' . SID; @@ -54,7 +54,7 @@ // Add table folder to schema $schemanode->addItem($table_node); - $tables = &$localData->getTables(); + $tables = &$data->getTables(); while (!$tables->EOF) { $return_url = urlencode("tblproperties.php?table=" . urlencode($tables->f[$data->tbFields['tbname']]) . "&{$querystr}"); $item_node = &new HTML_TreeNode(array( @@ -196,9 +196,9 @@ // If database supports schemas, add the extra level of hierarchy if ($data->hasSchemas()) { - $schemas = &$localData->getSchemas(); + $schemas = &$data->getSchemas(); while (!$schemas->EOF) { - $localData->setSchema($schemas->f[$data->nspFields['nspname']]); + $data->setSchema($schemas->f[$data->nspFields['nspname']]); // Construct database & schema query string $querystr = 'database=' . urlencode($databases->f[$data->dbFields['dbname']]). '&schema=' . urlencode($schemas->f[$data->nspFields['nspname']]); diff --git a/casts.php b/casts.php index a502a658..407a4c86 100644 --- a/casts.php +++ b/casts.php @@ -3,7 +3,7 @@ /** * Manage casts in a database * - * $Id: casts.php,v 1.3 2003/10/28 04:02:14 chriskl Exp $ + * $Id: casts.php,v 1.4 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -17,13 +17,13 @@ * Show default list of casts in the database */ function doDefault($msg = '') { - global $data, $localData, $misc, $database; + global $data, $misc, $database; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strcasts']}

\n"; $misc->printMsg($msg); - $casts = &$localData->getcasts(); + $casts = &$data->getcasts(); if ($casts->recordCount() > 0) { echo "\n"; diff --git a/classes/Misc.php b/classes/Misc.php index c4d666cd..683c5bbd 100644 --- a/classes/Misc.php +++ b/classes/Misc.php @@ -2,7 +2,7 @@ /** * Class to hold various commonly used functions * - * $Id: Misc.php,v 1.49 2003/12/10 14:23:39 chriskl Exp $ + * $Id: Misc.php,v 1.50 2003/12/10 16:03:30 chriskl Exp $ */ class Misc { @@ -137,81 +137,32 @@ /** * Creates a database accessor */ - function &getDatabaseAccessor($host, $port, $database, $username, $password) { + function &getDatabaseAccessor($database) { global $conf; - - $desc = null; - $type = $this->getDriver($host, $port, $username, $password, - $conf['servers'][$_SESSION['webdbServerID']]['type'], - $conf['servers'][$_SESSION['webdbServerID']]['defaultdb'], $desc); - include_once('classes/database/' . $type . '.php'); - $localData = new $type( $host, - $port, - $database, - $username, - $password); - - return $localData; - } - /** - * Gets the name of the correct database driver to use - * @param $host The hostname to connect to - * @param $port The port to connect to - * @param $user The username to use - * @param $password The password to use - * @param $type The ADODB database type name. - * @param $database The default database to which to connect - * @param (return-by-ref) $description A description of the database and version - * @return The class name of the driver eg. Postgres73 - * @return -1 Database functions not compiled in - * @return -2 Invalid database type - * @return -3 Database-specific failure - */ - function getDriver($host, $port, $user, $password, $type, $database, &$description) { - switch ($type) { - case 'postgres7': - // Check functions are loaded - if (!function_exists('pg_connect')) return -1; - - include_once('classes/database/ADODB_base.php'); - $adodb = new ADODB_base('postgres7'); - - $adodb->conn->connect(($host === null || $host == '') ? null : "{$host}:{$port}", $user, $password, $database); - - $sql = "SELECT VERSION() AS version"; - $field = $adodb->selectField($sql, 'version'); - - $params = explode(' ', $field); - if (!isset($params[1])) return -3; - - $version = $params[1]; // eg. 7.3.2 - $description = "PostgreSQL {$params[1]}"; - - // Detect version and choose appropriate database driver - // 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) - return 'Postgres74'; - elseif (strpos($version, '7.3') === 0) - return 'Postgres73'; - elseif (strpos($version, '7.2') === 0) - return 'Postgres72'; - elseif (strpos($version, '7.1') === 0) - return 'Postgres71'; - elseif (strpos($version, '7.0') === 0 - || strpos($version, '6.') === 0) - return 'Postgres'; - else - return 'Postgres75'; - - break; - default: - return -2; - } + // Create the connection object and make the connection + $_connection = new Connection( + $conf['servers'][$_SESSION['webdbServerID']]['host'], + $conf['servers'][$_SESSION['webdbServerID']]['port'], + $_SESSION['webdbUsername'], + $_SESSION['webdbPassword'], + $database + ); + + // 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($desc); + // XXX: NEED TO CHECK RETURN STATUS HERE + + // Create a database wrapper class for easy manipulation of the + // connection. + include_once('classes/database/' . $_type . '.php'); + $data = &new $_type($_connection->conn); + + return $data; } + /** * Prints the page header. If global variable $_no_output is * set then no header is drawn. @@ -239,7 +190,7 @@ // Theme echo "\n"; - if ($script) echo "\n {$script} \n"; + if ($script) echo "{$script}\n"; echo "\n"; } } diff --git a/classes/Reports.php b/classes/Reports.php index 43f90e95..e462a709 100644 --- a/classes/Reports.php +++ b/classes/Reports.php @@ -4,7 +4,7 @@ * the functions provided by the database driver exclusively, and hence * will work with any database without modification. * - * $Id: Reports.php,v 1.8 2003/11/05 08:32:03 chriskl Exp $ + * $Id: Reports.php,v 1.9 2003/12/10 16:03:30 chriskl Exp $ */ class Reports { @@ -14,17 +14,12 @@ /* Constructor */ function Reports() { - global $conf, $misc; + global $misc; // Create a new database access object. // @@ IF THE phppgadmin DATABASE DOES NOT EXIST THEN // @@ LOGIN FAILURE OCCURS - $this->driver = &$misc->getDatabaseAccessor( - $conf['servers'][$_SESSION['webdbServerID']]['host'], - $conf['servers'][$_SESSION['webdbServerID']]['port'], - 'phppgadmin', - $_SESSION['webdbUsername'], - $_SESSION['webdbPassword']); + $this->driver = &$misc->getDatabaseAccessor('phppgadmin'); } /** diff --git a/classes/database/ADODB_base.php b/classes/database/ADODB_base.php index 6993ed88..165f721a 100644 --- a/classes/database/ADODB_base.php +++ b/classes/database/ADODB_base.php @@ -3,7 +3,7 @@ /* * Parent class of all ADODB objects. * - * $Id: ADODB_base.php,v 1.14 2003/07/31 01:17:05 chriskl Exp $ + * $Id: ADODB_base.php,v 1.15 2003/12/10 16:03:30 chriskl Exp $ */ include_once('libraries/errorhandler.inc.php'); @@ -15,11 +15,10 @@ class ADODB_base { /** * Base constructor - * @param $fetchMode Defaults to associative. Override for different behaviour + * @param &$conn The connection object */ - function ADODB_base($type, $fetchMode = ADODB_FETCH_ASSOC) { - $this->conn = &ADONewConnection($type); - $this->conn->setFetchMode($fetchMode); + function ADODB_base(&$conn) { + $this->conn = $conn; } /** diff --git a/classes/database/BaseDB.php b/classes/database/BaseDB.php index 86b73a7f..1bbce9c5 100644 --- a/classes/database/BaseDB.php +++ b/classes/database/BaseDB.php @@ -4,15 +4,15 @@ * A class that implements the DB interface for Postgres * Note: This class uses ADODB and returns RecordSets. * - * $Id: BaseDB.php,v 1.34 2003/11/05 15:06:23 chriskl Exp $ + * $Id: BaseDB.php,v 1.35 2003/12/10 16:03:30 chriskl Exp $ */ include_once('classes/database/ADODB_base.php'); class BaseDB extends ADODB_base { - function BaseDB($type) { - $this->ADODB_base($type); + function BaseDB($conn) { + $this->ADODB_base($conn); } // Table functions diff --git a/classes/database/Connection.php b/classes/database/Connection.php new file mode 100755 index 00000000..7662c431 --- /dev/null +++ b/classes/database/Connection.php @@ -0,0 +1,69 @@ +conn = &ADONewConnection('postgres7'); + $this->conn->setFetchMode($fetchMode); + + // Ignore host if null + if ($host === null || $host == '') + $pghost = ''; + else + $pghost = "{$host}:{$port}"; + + $this->conn->connect($pghost, $user, $password, $database); + } + + /** + * 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 -3 Database-specific failure + */ + function getDriver(&$description) { + $adodb = new ADODB_base($this->conn); + + $sql = "SELECT VERSION() AS version"; + $field = $adodb->selectField($sql, 'version'); + + $params = explode(' ', $field); + if (!isset($params[1])) return -3; + + $version = $params[1]; // eg. 7.3.2 + $description = "PostgreSQL {$params[1]}"; + + // Detect version and choose appropriate database driver + // 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) + return 'Postgres74'; + elseif (strpos($version, '7.3') === 0) + return 'Postgres73'; + elseif (strpos($version, '7.2') === 0) + return 'Postgres72'; + elseif (strpos($version, '7.1') === 0) + return 'Postgres71'; + elseif (strpos($version, '7.0') === 0 + || strpos($version, '6.') === 0) + return 'Postgres'; + else + return 'Postgres75'; + } + +} diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index 74ebe2d4..a947cc3c 100755 --- a/classes/database/Postgres.php +++ b/classes/database/Postgres.php @@ -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.164 2003/11/19 02:12:47 chriskl Exp $ + * $Id: Postgres.php,v 1.165 2003/12/10 16:03:30 chriskl Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -126,22 +126,10 @@ class Postgres extends BaseDB { /** * Constructor - * @param $host The hostname to connect to - * @param $post The port number to connect to - * @param $database The database name to connect to. - * @param $user The user to connect as - * @param $password The password to use - */ - function Postgres($host, $port, $database, $user, $password) { - $this->BaseDB('postgres7'); - - // Ignore host if null - if ($host === null || $host == '') - $pghost = ''; - else - $pghost = "{$host}:{$port}"; - - $this->conn->connect($pghost, $user, $password, $database); + * @param $conn The database connection + */ + function Postgres($conn) { + $this->BaseDB($conn); } /** diff --git a/classes/database/Postgres71.php b/classes/database/Postgres71.php index f61ec541..f176e293 100644 --- a/classes/database/Postgres71.php +++ b/classes/database/Postgres71.php @@ -4,7 +4,7 @@ * A class that implements the DB interface for Postgres * Note: This class uses ADODB and returns RecordSets. * - * $Id: Postgres71.php,v 1.46 2003/11/05 15:06:24 chriskl Exp $ + * $Id: Postgres71.php,v 1.47 2003/12/10 16:03:30 chriskl Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -51,14 +51,10 @@ class Postgres71 extends Postgres { /** * Constructor - * @param $host The hostname to connect to - * @param $post The port number to connect to - * @param $database The database name to connect to - * @param $user The user to connect as - * @param $password The password to use + * @param $conn The database connection */ - function Postgres71($host, $port, $database, $user, $password) { - $this->Postgres($host, $port, $database, $user, $password); + function Postgres71($conn) { + $this->Postgres($conn); } /** diff --git a/classes/database/Postgres72.php b/classes/database/Postgres72.php index b4a64daa..51c73b96 100644 --- a/classes/database/Postgres72.php +++ b/classes/database/Postgres72.php @@ -4,7 +4,7 @@ * A class that implements the DB interface for Postgres * Note: This class uses ADODB and returns RecordSets. * - * $Id: Postgres72.php,v 1.52 2003/10/13 08:50:04 chriskl Exp $ + * $Id: Postgres72.php,v 1.53 2003/12/10 16:03:30 chriskl Exp $ */ @@ -28,14 +28,10 @@ class Postgres72 extends Postgres71 { /** * Constructor - * @param $host The hostname to connect to - * @param $post The port number to connect to - * @param $database The database name to connect to - * @param $user The user to connect as - * @param $password The password to use + * @param $conn The database connection */ - function Postgres72($host, $port, $database, $user, $password) { - $this->Postgres71($host, $port, $database, $user, $password); + function Postgres72($conn) { + $this->Postgres71($conn); // Correct the error in the encoding tables, that was // fixed in PostgreSQL 7.2 diff --git a/classes/database/Postgres73.php b/classes/database/Postgres73.php index 86d7c5f1..27a85148 100644 --- a/classes/database/Postgres73.php +++ b/classes/database/Postgres73.php @@ -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.81 2003/11/24 13:59:37 chriskl Exp $ + * $Id: Postgres73.php,v 1.82 2003/12/10 16:03:30 chriskl Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -46,17 +46,13 @@ class Postgres73 extends Postgres72 { var $selectOps = array('=' => 'i', '!=' => 'i', '<' => 'i', '>' => 'i', '<=' => 'i', '>=' => 'i', 'LIKE' => 'i', 'NOT LIKE' => 'i', 'ILIKE' => 'i', 'NOT ILIKE' => 'i', 'SIMILAR TO' => 'i', 'NOT SIMILAR TO' => 'i', '~' => 'i', '!~' => 'i', '~*' => 'i', '!~*' => 'i', 'IS NULL' => 'p', 'IS NOT NULL' => 'p', 'IN' => 'x', 'NOT IN' => 'x'); - + /** * Constructor - * @param $host The hostname to connect to - * @param $post The port number to connect to - * @param $database The database name to connect to - * @param $user The user to connect as - * @param $password The password to use + * @param $conn The database connection */ - function Postgres73($host, $port, $database, $user, $password) { - $this->Postgres72($host, $port, $database, $user, $password); + function Postgres73($conn) { + $this->Postgres72($conn); } // Schema functions diff --git a/classes/database/Postgres74.php b/classes/database/Postgres74.php index b87b6d37..81f1263c 100644 --- a/classes/database/Postgres74.php +++ b/classes/database/Postgres74.php @@ -4,7 +4,7 @@ * A class that implements the DB interface for Postgres * Note: This class uses ADODB and returns RecordSets. * - * $Id: Postgres74.php,v 1.19 2003/11/19 02:12:48 chriskl Exp $ + * $Id: Postgres74.php,v 1.20 2003/12/10 16:03:30 chriskl Exp $ */ include_once('classes/database/Postgres73.php'); @@ -19,14 +19,10 @@ class Postgres74 extends Postgres73 { /** * Constructor - * @param $host The hostname to connect to - * @param $post The port number to connect to - * @param $database The database name to connect to - * @param $user The user to connect as - * @param $password The password to use + * @param $conn The database connection */ - function Postgres74($host, $port, $database, $user, $password) { - $this->Postgres73($host, $port, $database, $user, $password); + function Postgres74($conn) { + $this->Postgres73($conn); } // Table functions diff --git a/classes/database/Postgres75.php b/classes/database/Postgres75.php index d423a430..00e22ae7 100755 --- a/classes/database/Postgres75.php +++ b/classes/database/Postgres75.php @@ -3,7 +3,7 @@ /** * PostgreSQL 7.5 support * - * $Id: Postgres75.php,v 1.1 2003/11/09 08:29:33 chriskl Exp $ + * $Id: Postgres75.php,v 1.2 2003/12/10 16:03:30 chriskl Exp $ */ include_once('classes/database/Postgres74.php'); @@ -15,14 +15,10 @@ class Postgres75 extends Postgres74 { /** * Constructor - * @param $host The hostname to connect to - * @param $post The port number to connect to - * @param $database The database name to connect to - * @param $user The user to connect as - * @param $password The password to use + * @param $conn The database connection */ - function Postgres75($host, $port, $database, $user, $password) { - $this->Postgres74($host, $port, $database, $user, $password); + function Postgres75($conn) { + $this->Postgres74($conn); } } diff --git a/constraints.php b/constraints.php index 69f1026d..a46384ee 100644 --- a/constraints.php +++ b/constraints.php @@ -3,7 +3,7 @@ /** * List constraints on a table * - * $Id: constraints.php,v 1.22 2003/10/08 02:14:24 chriskl Exp $ + * $Id: constraints.php,v 1.23 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -17,7 +17,7 @@ * Show confirmation of cluster index and perform actual cluster */ function doClusterIndex($confirm) { - global $localData, $database, $misc, $action; + global $database, $misc, $action; global $PHP_SELF, $lang; if ($confirm) { @@ -40,7 +40,7 @@ echo "\n"; } else { - $status = $localData->clusterIndex($_POST['constraint'], $_POST['table'], isset($_POST['analyze'])); + $status = $data->clusterIndex($_POST['constraint'], $_POST['table'], isset($_POST['analyze'])); if ($status == 0) doDefault($lang['strclusteredgood'] . ((isset($_POST['analyze']) ? ' ' . $lang['stranalyzegood'] : ''))); else @@ -52,7 +52,7 @@ * Confirm and then actually add a FOREIGN KEY constraint */ function addForeignKey($stage, $msg = '') { - global $PHP_SELF, $data, $localData, $misc; + global $PHP_SELF, $data, $data, $misc; global $lang; if (!isset($_POST['name'])) $_POST['name'] = ''; @@ -76,12 +76,12 @@ // Unserialize target and fetch appropriate table. This is a bit messy // because the table could be in another schema. - if ($localData->hasSchemas()) { - $localData->setSchema($_REQUEST['target']['schemaname']); + if ($data->hasSchemas()) { + $data->setSchema($_REQUEST['target']['schemaname']); } - $attrs = &$localData->getTableAttributes($_REQUEST['target']['tablename']); - if ($localData->hasSchemas()) { - $localData->setSchema($_REQUEST['schema']); + $attrs = &$data->getTableAttributes($_REQUEST['target']['tablename']); + if ($data->hasSchemas()) { + $data->setSchema($_REQUEST['schema']); } $selColumns = new XHTML_select('TableColumnList', true, 10); @@ -152,7 +152,7 @@ || sizeof($_POST['IndexColumnList']) == 0 || !isset($temp) || !is_array($temp) || sizeof($temp) == 0) addForeignKey(2, $lang['strfkneedscols']); else { - $status = $localData->addForeignKey($_POST['table'], $_POST['target']['schemaname'], $_POST['target']['tablename'], + $status = $data->addForeignKey($_POST['table'], $_POST['target']['schemaname'], $_POST['target']['tablename'], unserialize($_POST['SourceColumnList']), $_POST['IndexColumnList'], $_POST['upd_action'], $_POST['del_action'], $_POST['name']); if ($status == 0) doDefault($lang['strfkadded']); @@ -165,8 +165,8 @@ $misc->printVal($_REQUEST['table']), ": {$lang['straddfk']}\n"; $misc->printMsg($msg); - $attrs = &$localData->getTableAttributes($_REQUEST['table']); - $tables = &$localData->getTables(true); + $attrs = &$data->getTableAttributes($_REQUEST['table']); + $tables = &$data->getTables(true); $selColumns = new XHTML_select('TableColumnList', true, 10); $selColumns->set_style('width: 10em;'); @@ -206,7 +206,7 @@ $key = array('schemaname' => $tables->f['schemaname'], 'tablename' => $tables->f['tablename']); $key = serialize($key); echo "\n"; @@ -232,7 +232,7 @@ * Confirm and then actually add a PRIMARY KEY or UNIQUE constraint */ function addPrimaryOrUniqueKey($type, $confirm, $msg = '') { - global $PHP_SELF, $data, $localData, $misc; + global $PHP_SELF, $data, $data, $misc; global $lang; if (!isset($_POST['name'])) $_POST['name'] = ''; @@ -251,7 +251,7 @@ $misc->printVal($_REQUEST['table']), ": {$desc}\n"; $misc->printMsg($msg); - $attrs = &$localData->getTableAttributes($_REQUEST['table']); + $attrs = &$data->getTableAttributes($_REQUEST['table']); $selColumns = new XHTML_select('TableColumnList', true, 10); $selColumns->set_style('width: 10em;'); @@ -300,7 +300,7 @@ if (!isset($_POST['IndexColumnList']) || !is_array($_POST['IndexColumnList']) || sizeof($_POST['IndexColumnList']) == 0) addPrimaryOrUniqueKey($_POST['type'], true, $lang['strpkneedscols']); else { - $status = $localData->addPrimaryKey($_POST['table'], $_POST['IndexColumnList'], $_POST['name']); + $status = $data->addPrimaryKey($_POST['table'], $_POST['IndexColumnList'], $_POST['name']); if ($status == 0) doDefault($lang['strpkadded']); else @@ -312,7 +312,7 @@ if (!isset($_POST['IndexColumnList']) || !is_array($_POST['IndexColumnList']) || sizeof($_POST['IndexColumnList']) == 0) addPrimaryOrUniqueKey($_POST['type'], true, $lang['struniqneedscols']); else { - $status = $localData->addUniqueKey($_POST['table'], $_POST['IndexColumnList'], $_POST['name']); + $status = $data->addUniqueKey($_POST['table'], $_POST['IndexColumnList'], $_POST['name']); if ($status == 0) doDefault($lang['struniqadded']); else @@ -327,7 +327,7 @@ * Confirm and then actually add a CHECK constraint */ function addCheck($confirm, $msg = '') { - global $PHP_SELF, $data, $localData, $misc; + global $PHP_SELF, $data, $data, $misc; global $lang; if (!isset($_POST['name'])) $_POST['name'] = ''; @@ -361,7 +361,7 @@ if (trim($_POST['definition']) == '') addCheck(true, $lang['strcheckneedsdefinition']); else { - $status = $localData->addCheckConstraint($_POST['table'], + $status = $data->addCheckConstraint($_POST['table'], $_POST['definition'], $_POST['name']); if ($status == 0) doDefault($lang['strcheckadded']); @@ -375,7 +375,7 @@ * Show confirmation of drop and perform actual drop */ function doDrop($confirm) { - global $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; if ($confirm) { @@ -392,7 +392,7 @@ echo "\n"; echo $misc->form; // Show cascade drop option if supportd - if ($localData->hasDropBehavior()) { + if ($data->hasDropBehavior()) { echo "

{$lang['strcascade']}

\n"; } echo "\n"; @@ -400,7 +400,7 @@ echo "\n"; } else { - $status = $localData->dropConstraint($_POST['constraint'], $_POST['table'], $_POST['type'], isset($_POST['cascade'])); + $status = $data->dropConstraint($_POST['constraint'], $_POST['table'], $_POST['type'], isset($_POST['cascade'])); if ($status == 0) doDefault($lang['strconstraintdropped']); else @@ -412,7 +412,7 @@ * List all the constraints on the table */ function doDefault($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF; global $lang; @@ -420,7 +420,7 @@ echo "

", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['strconstraints']}

\n"; $misc->printMsg($msg); - $constraints = &$localData->getConstraints($_REQUEST['table']); + $constraints = &$data->getConstraints($_REQUEST['table']); if ($constraints->recordCount() > 0) { echo "
\n"; @@ -443,7 +443,7 @@ if ($constraints->f['consrc'] !== null) echo $misc->printVal($constraints->f[$data->cnFields['consrc']]); else { - $atts = &$localData->getKeys($_REQUEST['table'], explode(' ', $constraints->f['indkey'])); + $atts = &$data->getKeys($_REQUEST['table'], explode(' ', $constraints->f['indkey'])); echo ($constraints->f['contype'] == 'u') ? "UNIQUE (" : "PRIMARY KEY ("; echo join(',', $atts); echo ")"; diff --git a/conversions.php b/conversions.php index 3ac2735e..a2b8b86a 100644 --- a/conversions.php +++ b/conversions.php @@ -3,7 +3,7 @@ /** * Manage conversions in a database * - * $Id: conversions.php,v 1.1 2003/10/27 06:37:25 chriskl Exp $ + * $Id: conversions.php,v 1.2 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -17,13 +17,13 @@ * Show default list of conversions in the database */ function doDefault($msg = '') { - global $data, $localData, $misc, $database; + global $data, $misc, $database; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strconversions']}

\n"; $misc->printMsg($msg); - $conversions = &$localData->getconversions(); + $conversions = &$data->getconversions(); if ($conversions->recordCount() > 0) { echo "
\n"; diff --git a/database.php b/database.php index 1269f04f..9b3efac1 100755 --- a/database.php +++ b/database.php @@ -3,7 +3,7 @@ /** * Manage schemas within a database * - * $Id: database.php,v 1.25 2003/11/15 11:09:32 chriskl Exp $ + * $Id: database.php,v 1.26 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -21,7 +21,7 @@ * Searches for a named database object */ function doFind($confirm = true, $msg = '') { - global $PHP_SELF, $data, $localData, $misc; + global $PHP_SELF, $data, $data, $misc; global $lang; if (!isset($_GET['term'])) $_GET['term'] = ''; @@ -41,7 +41,7 @@ // If a search term has been specified, then perform the search // and display the results, grouped by object type if ($_GET['term'] != '') { - $rs = &$localData->findObject($_GET['term']); + $rs = &$data->findObject($_GET['term']); if ($rs->recordCount() > 0) { $curr = ''; while (!$rs->EOF) { @@ -101,7 +101,7 @@ } // Generate schema prefix - if ($localData->hasSchemas()) + if ($data->hasSchemas()) $prefix = $rs->f['schemaname'] . '.'; else $prefix = ''; @@ -186,17 +186,17 @@ * Allow database administration and tuning tasks */ function doAdmin($action = '', $msg = '') { - global $PHP_SELF, $localData, $misc; + global $PHP_SELF, $data, $misc; global $lang; switch ($action) { case 'vacuum': - $status = $localData->vacuumDB(); + $status = $data->vacuumDB(); if ($status == 0) doAdmin('', $lang['strvacuumgood']); else doAdmin('', $lang['strvacuumbad']); break; case 'analyze': - $status = $localData->analyzeDB(); + $status = $data->analyzeDB(); if ($status == 0) doAdmin('', $lang['stranalyzegood']); else doAdmin('', $lang['stranalyzebad']); break; @@ -217,7 +217,7 @@ * Allow execution of arbitrary SQL statements on a database */ function doSQL() { - global $PHP_SELF, $localData, $misc; + global $PHP_SELF, $data, $misc; global $lang; if (!isset($_REQUEST['query'])) $_REQUEST['query'] = ''; @@ -240,7 +240,7 @@ * Show confirmation of drop and perform actual drop */ function doDrop($confirm) { - global $PHP_SELF, $data, $localData, $misc; + global $PHP_SELF, $data, $data, $misc; global $lang, $_reload_browser; if ($confirm) { @@ -254,7 +254,7 @@ echo "\n"; echo "\n"; // Show cascade drop option if supportd - if ($localData->hasDropBehavior()) { + if ($data->hasDropBehavior()) { echo "

{$lang['strcascade']}

\n"; } echo "\n"; @@ -262,7 +262,7 @@ echo "\n"; } else { - $status = $localData->dropSchema($_POST['schema'], isset($_POST['cascade'])); + $status = $data->dropSchema($_POST['schema'], isset($_POST['cascade'])); if ($status == 0) { $_reload_browser = true; doDefault($lang['strschemadropped']); @@ -320,12 +320,12 @@ * Actually creates the new schema in the database */ function doSaveCreate() { - global $localData, $lang, $_reload_browser; + global $data, $lang, $_reload_browser; // Check that they've given a name if ($_POST['formName'] == '') doCreate($lang['strschemaneedsname']); else { - $status = $localData->createSchema($_POST['formName'], $_POST['formAuth']); + $status = $data->createSchema($_POST['formName'], $_POST['formAuth']); if ($status == 0) { $_reload_browser = true; doDefault($lang['strschemacreated']); @@ -339,7 +339,7 @@ * Show default list of schemas in the server */ function doDefault($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; $misc->printDatabaseNav(); @@ -348,7 +348,7 @@ // Check that the DB actually supports schemas if ($data->hasSchemas()) { - $schemas = &$localData->getSchemas(); + $schemas = &$data->getSchemas(); if ($schemas->recordCount() > 0) { echo "
\n"; diff --git a/dataexport.php b/dataexport.php index a21eeda0..86cf7b23 100644 --- a/dataexport.php +++ b/dataexport.php @@ -3,7 +3,7 @@ /** * Does an export to the screen or as a download * - * $Id: dataexport.php,v 1.5 2003/10/12 13:08:59 soranzo Exp $ + * $Id: dataexport.php,v 1.6 2003/12/10 16:03:29 chriskl Exp $ */ $extensions = array( @@ -58,25 +58,25 @@ if (isset($_REQUEST['query'])) $_REQUEST['query'] = trim(unserialize($_REQUEST['query'])); // Set up the dump transaction - $status = $localData->beginDump(); + $status = $data->beginDump(); // If the dump is not dataonly then dump the structure prefix if ($_REQUEST['what'] != 'dataonly') - echo $localData->getTableDefPrefix($_REQUEST['table'], isset($clean)); + echo $data->getTableDefPrefix($_REQUEST['table'], isset($clean)); // If the dump is not structureonly then dump the actual data if ($_REQUEST['what'] != 'structureonly') { // Get database encoding - $dbEncoding = $localData->getDatabaseEncoding(); + $dbEncoding = $data->getDatabaseEncoding(); // Set fetch mode to NUM so that duplicate field names are properly returned - $localData->conn->setFetchMode(ADODB_FETCH_NUM); + $data->conn->setFetchMode(ADODB_FETCH_NUM); // Execute the query, if set, otherwise grab all rows from the table if (isset($_REQUEST['table'])) - $rs = &$localData->dumpRelation($_REQUEST['table'], isset($oids)); + $rs = &$data->dumpRelation($_REQUEST['table'], isset($oids)); else - $rs = $localData->conn->Execute($_REQUEST['query']); + $rs = $data->conn->Execute($_REQUEST['query']); if ($format == 'copy') { $data->fieldClean($_REQUEST['table']); @@ -108,7 +108,7 @@ echo "\r\n"; echo "\r\n"; echo "\t\r\n"; - echo "\tcodemap[$dbEncoding]}\" />\r\n"; + echo "\tcodemap[$dbEncoding]}\" />\r\n"; echo "\r\n"; echo "\r\n"; echo "
\r\n"; @@ -118,7 +118,7 @@ $j = 0; foreach ($rs->f as $k => $v) { $finfo = $rs->fetchField($j++); - if ($finfo->name == $localData->id && !isset($oids)) continue; + if ($finfo->name == $data->id && !isset($oids)) continue; echo "\t\t\r\n"; } } @@ -128,7 +128,7 @@ $j = 0; foreach ($rs->f as $k => $v) { $finfo = $rs->fetchField($j++); - if ($finfo->name == $localData->id && !isset($oids)) continue; + if ($finfo->name == $data->id && !isset($oids)) continue; echo "\t\t\r\n"; } echo "\t\r\n"; @@ -140,8 +140,8 @@ } elseif ($format == 'xml') { echo "codemap[$dbEncoding])) - echo " encoding=\"{$localData->codemap[$dbEncoding]}\""; + if (isset($data->codemap[$dbEncoding])) + echo " encoding=\"{$data->codemap[$dbEncoding]}\""; echo " ?>\n"; echo "\n"; if (!$rs->EOF) { @@ -182,7 +182,7 @@ $finfo = $rs->fetchField($j++); $k = $finfo->name; // SQL (INSERT) format cannot handle oids - // if ($k == $localData->id) continue; + // if ($k == $data->id) continue; // Output field $data->fieldClean($k); if ($first) echo "\"{$k}\""; @@ -252,12 +252,12 @@ // If the dump is not dataonly then dump the structure suffix if ($_REQUEST['what'] != 'dataonly') { // Set fetch mode back to ASSOC for the table suffix to work - $localData->conn->setFetchMode(ADODB_FETCH_ASSOC); - echo $localData->getTableDefSuffix($_REQUEST['table']); + $data->conn->setFetchMode(ADODB_FETCH_ASSOC); + echo $data->getTableDefSuffix($_REQUEST['table']); } // Finish the dump transaction - $status = $localData->endDump(); + $status = $data->endDump(); } else { if (!isset($msg)) $msg = null; diff --git a/display.php b/display.php index 4adef2a1..6c08a920 100644 --- a/display.php +++ b/display.php @@ -9,7 +9,7 @@ * @param $return_desc The return link name * @param $page The current page * - * $Id: display.php,v 1.32 2003/11/26 06:06:49 chriskl Exp $ + * $Id: display.php,v 1.33 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -24,7 +24,7 @@ * Show confirmation of edit and perform actual update */ function doEditRow($confirm, $msg = '') { - global $localData, $database, $misc; + global $database, $misc; global $lang; global $PHP_SELF; @@ -34,8 +34,8 @@ echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}: ", $misc->printVal($_REQUEST['table']), ": {$lang['streditrow']}

\n"; $misc->printMsg($msg); - $attrs = &$localData->getTableAttributes($_REQUEST['table']); - $rs = &$localData->browseRow($_REQUEST['table'], $key); + $attrs = &$data->getTableAttributes($_REQUEST['table']); + $rs = &$data->browseRow($_REQUEST['table'], $key); echo "
\n"; $error = true; @@ -49,7 +49,7 @@ $i = 0; while (!$attrs->EOF) { - $attrs->f['attnotnull'] = $localData->phpBool($attrs->f['attnotnull']); + $attrs->f['attnotnull'] = $data->phpBool($attrs->f['attnotnull']); $id = (($i % 2) == 0 ? '1' : '2'); // Initialise variables @@ -59,7 +59,7 @@ echo "
\n"; echo ""; echo ""; echo ""; - echo ""; echo "\n"; $i++; @@ -122,7 +122,7 @@ if (!isset($_POST['values'])) $_POST['values'] = array(); if (!isset($_POST['nulls'])) $_POST['nulls'] = array(); - $status = $localData->editRow($_POST['table'], $_POST['values'], $_POST['nulls'], + $status = $data->editRow($_POST['table'], $_POST['values'], $_POST['nulls'], $_POST['format'], $_POST['types'], unserialize($_POST['key'])); if ($status == 0) doBrowse($lang['strrowupdated']); @@ -138,7 +138,7 @@ * Show confirmation of drop and perform actual drop */ function doDelRow($confirm) { - global $localData, $database, $misc; + global $database, $misc; global $lang; global $PHP_SELF; @@ -170,7 +170,7 @@ echo "\n"; } else { - $status = $localData->deleteRow($_POST['table'], unserialize($_POST['key'])); + $status = $data->deleteRow($_POST['table'], unserialize($_POST['key'])); if ($status == 0) doBrowse($lang['strrowdeleted']); elseif ($status == -2) @@ -185,7 +185,7 @@ * Displays requested data */ function doBrowse() { - global $localData, $conf, $misc, $lang; + global $data, $conf, $misc, $lang; // If current page is not set, default to first page if (!isset($_REQUEST['page'])) $_REQUEST['page'] = 1; @@ -215,12 +215,12 @@ // Fetch unique row identifier, if this is a table browse request. if (isset($_REQUEST['table'])) - $key = $localData->getRowIdentifier($_REQUEST['table']); + $key = $data->getRowIdentifier($_REQUEST['table']); else $key = array(); // Retrieve page from query. $max_pages is returned by reference. - $rs = &$localData->browseQuery($type, + $rs = &$data->browseQuery($type, isset($_REQUEST['table']) ? $_REQUEST['table'] : null, isset($_REQUEST['query']) ? $_REQUEST['query'] : null, $_REQUEST['sortkey'], $_REQUEST['sortdir'], $_REQUEST['page'], @@ -260,14 +260,14 @@ $j = 0; foreach ($rs->f as $k => $v) { - if (isset($_REQUEST['table']) && $k == $localData->id && !$conf['show_oids']) { + if (isset($_REQUEST['table']) && $k == $data->id && !$conf['show_oids']) { $j++; continue; } $finfo = $rs->fetchField($j); // Display column headers with sorting options, unless we're PostgreSQL // 7.0 and it's a non-TABLE mode - if (!$localData->hasFullSubqueries() && $type != 'TABLE') { + if (!$data->hasFullSubqueries() && $type != 'TABLE') { echo "\n"; } else { @@ -314,7 +314,7 @@ $j = 0; foreach ($rs->f as $k => $v) { $finfo = $rs->fetchField($j++); - if (isset($_REQUEST['table']) && $k == $localData->id && !$conf['show_oids']) continue; + if (isset($_REQUEST['table']) && $k == $data->id && !$conf['show_oids']) continue; elseif ($v !== null && $v == '') echo ""; else { // Trim strings if over length diff --git a/domains.php b/domains.php index 4cd9748e..a6197f7b 100644 --- a/domains.php +++ b/domains.php @@ -3,7 +3,7 @@ /** * Manage domains in a database * - * $Id: domains.php,v 1.5 2003/09/09 06:23:12 chriskl Exp $ + * $Id: domains.php,v 1.6 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -17,9 +17,9 @@ * Function to save after altering a domain */ function doSaveAlter() { - global $localData, $lang; + global $data, $lang; - $status = $localData->alterDomain($_POST['domain'], $_POST['domdefault'], + $status = $data->alterDomain($_POST['domain'], $_POST['domdefault'], isset($_POST['domnotnull']), $_POST['domowner']); if ($status == 0) doProperties($lang['strdomainaltered']); @@ -31,14 +31,14 @@ * Allow altering a domain */ function doAlter($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strdomains']}: ", $misc->printVal($_REQUEST['domain']), ": {$lang['stralter']}

\n"; $misc->printMsg($msg); // Fetch domain info - $domaindata = &$localData->getDomain($_REQUEST['domain']); + $domaindata = &$data->getDomain($_REQUEST['domain']); // Fetch all users $users = &$data->getUsers(); @@ -87,7 +87,7 @@ * Confirm and then actually add a CHECK constraint */ function addCheck($confirm, $msg = '') { - global $PHP_SELF, $data, $localData, $misc; + global $PHP_SELF, $data, $data, $misc; global $lang; if (!isset($_POST['name'])) $_POST['name'] = ''; @@ -122,7 +122,7 @@ if (trim($_POST['definition']) == '') addCheck(true, $lang['strcheckneedsdefinition']); else { - $status = $localData->addDomainCheckConstraint($_POST['domain'], + $status = $data->addDomainCheckConstraint($_POST['domain'], $_POST['definition'], $_POST['name']); if ($status == 0) doProperties($lang['strcheckadded']); @@ -136,7 +136,7 @@ * Show confirmation of drop constraint and perform actual drop */ function doDropConstraint($confirm, $msg = '') { - global $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; if ($confirm) { @@ -152,7 +152,7 @@ echo "\n"; echo $misc->form; // Show cascade drop option if supportd - if ($localData->hasDropBehavior()) { + if ($data->hasDropBehavior()) { echo "

{$lang['strcascade']}

\n"; } echo "\n"; @@ -160,7 +160,7 @@ echo "\n"; } else { - $status = $localData->dropDomainConstraint($_POST['domain'], $_POST['constraint'], isset($_POST['cascade'])); + $status = $data->dropDomainConstraint($_POST['domain'], $_POST['constraint'], isset($_POST['cascade'])); if ($status == 0) doProperties($lang['strconstraintdropped']); else @@ -173,13 +173,13 @@ * Show properties for a domain. Allow manipulating constraints as well. */ function doProperties($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strdomains']}: ", $misc->printVal($_REQUEST['domain']), ": {$lang['strproperties']}

\n"; $misc->printMsg($msg); - $domaindata = &$localData->getDomain($_REQUEST['domain']); + $domaindata = &$data->getDomain($_REQUEST['domain']); if ($domaindata->recordCount() > 0) { // Display domain info @@ -199,7 +199,7 @@ // Display domain constraints if ($data->hasDomainConstraints()) { - $domaincons = &$localData->getDomainConstraints($_REQUEST['domain']); + $domaincons = &$data->getDomainConstraints($_REQUEST['domain']); if ($domaincons->recordCount() > 0) { echo "

{$lang['strconstraints']}

\n"; echo "
", $misc->printVal($finfo->name, true), "", $misc->printVal($v, true, $finfo->type), "
", $misc->printVal($attrs->f['attname']), "\n"; - echo $misc->printVal($localData->formatType($attrs->f['type'], $attrs->f['atttypmod'])); + echo $misc->printVal($data->formatType($attrs->f['type'], $attrs->f['atttypmod'])); echo "f['attname']), "]\" value=\"", htmlspecialchars($attrs->f['type']), "\" />\n"; @@ -80,7 +80,7 @@ else echo " ", $localData->printField("values[{$attrs->f['attname']}]", + echo "", $data->printField("values[{$attrs->f['attname']}]", $rs->f[$attrs->f['attname']], $attrs->f['type']), "
", $misc->printVal($finfo->name), " 
\n"; @@ -240,7 +240,7 @@ * Show confirmation of drop and perform actual drop */ function doDrop($confirm) { - global $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; if ($confirm) { @@ -252,7 +252,7 @@ echo "\n"; echo $misc->form; // Show cascade drop option if supportd - if ($localData->hasDropBehavior()) { + if ($data->hasDropBehavior()) { echo "

{$lang['strcascade']}

\n"; } echo "\n"; @@ -260,7 +260,7 @@ echo "\n"; } else { - $status = $localData->dropDomain($_POST['domain'], isset($_POST['cascade'])); + $status = $data->dropDomain($_POST['domain'], isset($_POST['cascade'])); if ($status == 0) doDefault($lang['strdomaindropped']); else @@ -273,7 +273,7 @@ * Displays a screen where they can enter a new domain */ function doCreate($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; if (!isset($_POST['domname'])) $_POST['domname'] = ''; @@ -281,7 +281,7 @@ if (!isset($_POST['domdefault'])) $_POST['domdefault'] = ''; if (!isset($_POST['domcheck'])) $_POST['domcheck'] = ''; - $types = &$localData->getTypes(true); + $types = &$data->getTypes(true); echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strdomains']}: {$lang['strcreatedomain']}

\n"; $misc->printMsg($msg); @@ -326,14 +326,14 @@ * Actually creates the new domain in the database */ function doSaveCreate() { - global $localData, $lang; + global $data, $lang; if (!isset($_POST['domcheck'])) $_POST['domcheck'] = ''; // Check that they've given a name and a definition if ($_POST['domname'] == '') doCreate($lang['strdomainneedsname']); else { - $status = $localData->createDomain($_POST['domname'], $_POST['domtype'], + $status = $data->createDomain($_POST['domname'], $_POST['domtype'], isset($_POST['domnotnull']), $_POST['domdefault'], $_POST['domcheck']); if ($status == 0) doDefault($lang['strdomaincreated']); @@ -346,13 +346,13 @@ * Show default list of domains in the database */ function doDefault($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strdomains']}

\n"; $misc->printMsg($msg); - $domains = &$localData->getDomains(); + $domains = &$data->getDomains(); if ($domains->recordCount() > 0) { echo "
\n"; diff --git a/functions.php b/functions.php index 760bb6b9..36f2aed4 100644 --- a/functions.php +++ b/functions.php @@ -3,7 +3,7 @@ /** * Manage functions in a database * - * $Id: functions.php,v 1.22 2003/10/27 05:43:18 chriskl Exp $ + * $Id: functions.php,v 1.23 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -17,9 +17,9 @@ * Function to save after editing a function */ function doSaveEdit() { - global $localData, $lang; + global $data, $lang; - $status = $localData->setFunction($_POST['function_oid'], $_POST['original_function'], $_POST['original_arguments'], + $status = $data->setFunction($_POST['function_oid'], $_POST['original_function'], $_POST['original_arguments'], $_POST['original_returns'], $_POST['formDefinition'], $_POST['original_lang'], $_POST['formProperties'], isset($_POST['original_setof']), true); if ($status == 0) @@ -32,20 +32,20 @@ * Function to allow editing of a Function */ function doEdit($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strfunctions']}: ", $misc->printVal($_REQUEST['function']), ": {$lang['stralter']}

\n"; $misc->printMsg($msg); - $fndata = &$localData->getFunction($_REQUEST['function_oid']); + $fndata = &$data->getFunction($_REQUEST['function_oid']); if ($fndata->recordCount() > 0) { $fndata->f[$data->fnFields['setof']] = $data->phpBool($fndata->f[$data->fnFields['setof']]); // Initialise variables if (!isset($_POST['formDefinition'])) $_POST['formDefinition'] = $fndata->f[$data->fnFields['fndef']]; - if (!isset($_POST['formProperties'])) $_POST['formProperties'] = $localData->getFunctionProperties($fndata->f); + if (!isset($_POST['formProperties'])) $_POST['formProperties'] = $data->getFunctionProperties($fndata->f); $func_full = $fndata->f[$data->fnFields['fnname']] . "(". $fndata->f[$data->fnFields['fnarguments']] .")"; echo "\n"; @@ -115,13 +115,13 @@ * Show read only properties of a function */ function doProperties($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strfunctions']}: ", $misc->printVal($_REQUEST['function']), ": {$lang['strproperties']}

\n"; $misc->printMsg($msg); - $funcdata = &$localData->getFunction($_REQUEST['function_oid']); + $funcdata = &$data->getFunction($_REQUEST['function_oid']); if ($funcdata->recordCount() > 0) { $funcdata->f[$data->fnFields['setof']] = $data->phpBool($funcdata->f[$data->fnFields['setof']]); @@ -141,7 +141,7 @@ echo "\n"; if (is_array($data->funcprops) && sizeof($data->funcprops) > 0) { // Fetch an array of the function properties - $funcprops = $localData->getFunctionProperties($funcdata->f); + $funcprops = $data->getFunctionProperties($funcdata->f); echo "\n"; echo "
", $misc->printVal($funcdata->f[$data->fnFields['fndef']]), "
{$lang['strproperties']}
\n"; foreach ($funcprops as $v) { @@ -164,7 +164,7 @@ * Show confirmation of drop and perform actual drop */ function doDrop($confirm) { - global $localData, $database, $misc; + global $database, $misc; global $PHP_SELF, $lang; if ($confirm) { @@ -178,7 +178,7 @@ echo "\n"; echo $misc->form; // Show cascade drop option if supportd - if ($localData->hasDropBehavior()) { + if ($data->hasDropBehavior()) { echo "

{$lang['strcascade']}

\n"; } echo "\n"; @@ -186,7 +186,7 @@ echo "\n"; } else { - $status = $localData->dropFunction($_POST['function_oid'], isset($_POST['cascade'])); + $status = $data->dropFunction($_POST['function_oid'], isset($_POST['cascade'])); if ($status == 0) doDefault($lang['strfunctiondropped']); else @@ -199,7 +199,7 @@ * Displays a screen where they can enter a new function */ function doCreate($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; if (!isset($_POST['formFunction'])) $_POST['formFunction'] = ''; @@ -210,8 +210,8 @@ if (!isset($_POST['formProperties'])) $_POST['formProperties'] = $data->defaultprops; if (!isset($_POST['formSetOf'])) $_POST['formSetOf'] = ''; - $types = &$localData->getTypes(true); - $langs = &$localData->getLanguages(true); + $types = &$data->getTypes(true); + $langs = &$data->getLanguages(true); echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strfunctions']}: {$lang['strcreatefunction']}

\n"; $misc->printMsg($msg); @@ -292,7 +292,7 @@ * Actually creates the new function in the database */ function doSaveCreate() { - global $localData, $lang; + global $data, $lang; // Set properties to an empty array if it doesn't exist (for db's without properties) if (!is_array($_POST['formProperties'])) $_POST['formProperties'] = array(); @@ -301,7 +301,7 @@ if ($_POST['formFunction'] == '') doCreate($lang['strfunctionneedsname']); elseif ($_POST['formDefinition'] == '') doCreate($lang['strfunctionneedsdef']); else { - $status = $localData->createFunction($_POST['formFunction'], $_POST['formArguments'] , + $status = $data->createFunction($_POST['formFunction'], $_POST['formArguments'] , $_POST['formReturns'] , $_POST['formDefinition'] , $_POST['formLanguage'], $_POST['formProperties'], $_POST['formSetOf'] == 'SETOF', false); if ($status == 0) @@ -315,13 +315,13 @@ * Show default list of functions in the database */ function doDefault($msg = '') { - global $data, $localData, $misc, $func; + global $data, $misc, $func; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strfunctions']}

\n"; $misc->printMsg($msg); - $funcs = &$localData->getFunctions(); + $funcs = &$data->getFunctions(); if ($funcs->recordCount() > 0) { echo "\n"; diff --git a/indexes.php b/indexes.php index 302ea206..b45db165 100644 --- a/indexes.php +++ b/indexes.php @@ -3,7 +3,7 @@ /** * List indexes on a table * - * $Id: indexes.php,v 1.19 2003/10/08 02:14:24 chriskl Exp $ + * $Id: indexes.php,v 1.20 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -17,7 +17,7 @@ * Show confirmation of cluster index and perform actual cluster */ function doClusterIndex($confirm) { - global $localData, $database, $misc, $action; + global $database, $misc, $action; global $PHP_SELF, $lang; if ($confirm) { @@ -40,7 +40,7 @@ echo "\n"; } else { - $status = $localData->clusterIndex($_POST['index'], $_POST['table'], isset($_POST['analyze'])); + $status = $data->clusterIndex($_POST['index'], $_POST['table'], isset($_POST['analyze'])); if ($status == 0) doDefault($lang['strclusteredgood'] . ((isset($_POST['analyze']) ? ' ' . $lang['stranalyzegood'] : ''))); else @@ -53,7 +53,7 @@ * Displays a screen where they can enter a new index */ function doCreateIndex($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; if (!isset($_POST['formIndexName'])) $_POST['formIndexName'] = ''; @@ -64,7 +64,7 @@ echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strindexes']}: {$lang['strcreateindex']}

\n"; $misc->printMsg($msg); - $attrs = &$localData->getTableAttributes($_REQUEST['table']); + $attrs = &$data->getTableAttributes($_REQUEST['table']); $selColumns = new XHTML_select("TableColumnList",true,10); $selColumns->set_style("width: 10em;"); @@ -106,7 +106,7 @@ echo ""; echo ""; echo "
{$lang['strindextype']}\n"; echo $misc->form; // Show cascade drop option if supportd - if ($localData->hasDropBehavior()) { + if ($data->hasDropBehavior()) { echo "

{$lang['strcascade']}

\n"; } echo "\n"; @@ -184,7 +184,7 @@ echo "\n"; } else { - $status = $localData->dropIndex($_POST['index'], isset($_POST['cascade'])); + $status = $data->dropIndex($_POST['index'], isset($_POST['cascade'])); if ($status == 0) doDefault($lang['strindexdropped']); else @@ -194,14 +194,14 @@ } function doDefault($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; $misc->printTableNav(); echo "

", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['strindexes']}

\n"; $misc->printMsg($msg); - $indexes = &$localData->getIndexes($_REQUEST['table']); + $indexes = &$data->getIndexes($_REQUEST['table']); if ($indexes->recordCount() > 0) { echo "\n"; diff --git a/info.php b/info.php index aa3f6a94..7b8512a9 100644 --- a/info.php +++ b/info.php @@ -3,7 +3,7 @@ /** * List extra information on a table * - * $Id: info.php,v 1.2 2003/10/13 01:42:04 chriskl Exp $ + * $Id: info.php,v 1.3 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -16,7 +16,7 @@ * List all the information on the table */ function doDefault($msg = '') { - global $localData, $misc; + global $data, $misc; global $lang; $misc->printTableNav(); @@ -24,9 +24,9 @@ $misc->printMsg($msg); // Fetch info - $referrers = &$localData->getReferrers($_REQUEST['table']); - $parents = &$localData->getTableParents($_REQUEST['table']); - $children = &$localData->getTableChildren($_REQUEST['table']); + $referrers = &$data->getReferrers($_REQUEST['table']); + $parents = &$data->getTableParents($_REQUEST['table']); + $children = &$data->getTableChildren($_REQUEST['table']); // Check that there is some info if (($referrers === -99 || ($referrers !== -99 && $referrers->recordCount() == 0)) @@ -39,7 +39,7 @@ echo "

{$lang['strreferringtables']}

\n"; echo "
\n"; echo "\t\n\t\t"; - if ($localData->hasSchemas()) { + if ($data->hasSchemas()) { echo ""; } echo ""; @@ -51,7 +51,7 @@ while (!$referrers->EOF) { $id = ( ($i % 2 ) == 0 ? '1' : '2' ); echo "\t\n\t\t"; - if ($localData->hasSchemas()) { + if ($data->hasSchemas()) { echo ""; } echo ""; @@ -73,7 +73,7 @@ echo "

{$lang['strparenttables']}

\n"; echo "
{$lang['strschema']}{$lang['strtable']}
", $misc->printVal($referrers->f['nspname']), "", $misc->printVal($referrers->f['relname']), "
\n"; echo "\t\n\t\t"; - if ($localData->hasSchemas()) { + if ($data->hasSchemas()) { echo ""; } echo "\t\t"; @@ -84,7 +84,7 @@ while (!$parents->EOF) { $id = ( ($i % 2 ) == 0 ? '1' : '2' ); echo "\t\n"; - if ($localData->hasSchemas()) { + if ($data->hasSchemas()) { echo "\t\t"; } echo ""; @@ -104,7 +104,7 @@ echo "

{$lang['strchildtables']}

\n"; echo "
{$lang['strschema']}{$lang['strtable']}
", $misc->printVal($parents->f['schemaname']), "", $misc->printVal($parents->f['relname']), "
\n"; echo "\t\n"; - if ($localData->hasSchemas()) { + if ($data->hasSchemas()) { echo ""; } echo "\t\t"; @@ -115,7 +115,7 @@ while (!$children->EOF) { $id = ( ($i % 2 ) == 0 ? '1' : '2' ); echo "\t\n"; - if ($localData->hasSchemas()) { + if ($data->hasSchemas()) { echo "\t\t"; } echo ""; diff --git a/languages.php b/languages.php index 4b527215..8aca7404 100644 --- a/languages.php +++ b/languages.php @@ -3,7 +3,7 @@ /** * Manage languages in a database * - * $Id: languages.php,v 1.1 2003/10/27 06:37:25 chriskl Exp $ + * $Id: languages.php,v 1.2 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -17,13 +17,13 @@ * Show default list of languages in the database */ function doDefault($msg = '') { - global $data, $localData, $misc, $database; + global $data, $misc, $database; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strlanguages']}

\n"; $misc->printMsg($msg); - $languages = &$localData->getlanguages(); + $languages = &$data->getlanguages(); if ($languages->recordCount() > 0) { echo "
{$lang['strschema']}{$lang['strtable']}
", $misc->printVal($children->f['schemaname']), "", $misc->printVal($children->f['relname']), "
\n"; diff --git a/libraries/lib.inc.php b/libraries/lib.inc.php index cf606b2e..5577b5f2 100644 --- a/libraries/lib.inc.php +++ b/libraries/lib.inc.php @@ -3,7 +3,7 @@ /** * Function library read in upon startup * - * $Id: lib.inc.php,v 1.68 2003/11/28 01:20:38 chriskl Exp $ + * $Id: lib.inc.php,v 1.69 2003/12/10 16:03:30 chriskl Exp $ */ // Set error reporting level to max @@ -13,7 +13,7 @@ $appName = 'phpPgAdmin'; // Application version - $appVersion = '3.2'; + $appVersion = '3.3-dev'; // Check to see if the configuration file exists, if not, explain @@ -132,85 +132,68 @@ // Import language file include("lang/recoded/" . strtolower($_SESSION['webdbLanguage']) . ".php"); - // Create data accessor object, if valid, and if necessary + // Check database support is properly compiled in + if (!function_exists('pg_connect')) { + echo $lang['strnotloaded']; + exit; + } + + // Create data accessor object, if necessary if (!isset($_no_db_connection)) { - if (isset($_SESSION['webdbServerID']) && isset($conf['servers'][$_SESSION['webdbServerID']])) { - if (!isset($conf['servers'][$_SESSION['webdbServerID']]['type'])) - $conf['servers'][$_SESSION['webdbServerID']]['type'] = 'postgres7'; - $_type = $misc->getDriver($conf['servers'][$_SESSION['webdbServerID']]['host'], - $conf['servers'][$_SESSION['webdbServerID']]['port'], - $_SESSION['webdbUsername'], - $_SESSION['webdbPassword'], - $conf['servers'][$_SESSION['webdbServerID']]['type'], - $conf['servers'][$_SESSION['webdbServerID']]['defaultdb'], - $conf['description']); - // Check return type - if ($_type == -1) { - echo $lang['strnotloaded']; + // Connect to the current database, or if one is not specified + // then connect to the default database. + if (isset($_REQUEST['database'])) + $_curr_db = $_REQUEST['database']; + else + $_curr_db = $conf['servers'][$_SESSION['webdbServerID']]['defaultdb']; + + // Create the connection object and make the connection + include_once('classes/database/Connection.php'); + $_connection = new Connection( + $conf['servers'][$_SESSION['webdbServerID']]['host'], + $conf['servers'][$_SESSION['webdbServerID']]['port'], + $_SESSION['webdbUsername'], + $_SESSION['webdbPassword'], + $_curr_db + ); + + // 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 + + // Create a database wrapper class for easy manipulation of the + // connection. + require_once('classes/database/' . $_type . '.php'); + $data = new $_type($_connection->conn); + + // If schema is defined and database supports schemas, then set the + // schema explicitly. + if (isset($_REQUEST['database']) && isset($_REQUEST['schema']) && $data->hasSchemas()) { + $status = $data->setSchema($_REQUEST['schema']); + if ($status != 0) { + echo $lang['strbadschema']; exit; } - // @@ NEED TO CHECK MORE RETURN VALS HERE - - require_once('classes/database/' . $_type . '.php'); - $data = new $_type($conf['servers'][$_SESSION['webdbServerID']]['host'], - $conf['servers'][$_SESSION['webdbServerID']]['port'], - $conf['servers'][$_SESSION['webdbServerID']]['defaultdb'], - $_SESSION['webdbUsername'], - $_SESSION['webdbPassword']); - } - - // Create local (database-specific) data accessor object, if valid - if (isset($_SESSION['webdbServerID']) && isset($conf['servers'][$_SESSION['webdbServerID']]) && isset($_REQUEST['database'])) { - require_once('classes/database/' . $_type . '.php'); - $localData = new $_type( $conf['servers'][$_SESSION['webdbServerID']]['host'], - $conf['servers'][$_SESSION['webdbServerID']]['port'], - $_REQUEST['database'], - $_SESSION['webdbUsername'], - $_SESSION['webdbPassword']); - - // If schema is defined and database supports schemas, then set the schema explicitly - if (isset($_REQUEST['schema']) && $localData->hasSchemas()) { - $status = $localData->setSchema($_REQUEST['schema']); - if ($status != 0) { - echo $lang['strbadschema']; - exit; - } - } - } - } - // Get database encoding - if (isset($localData)) { - $dbEncoding = $localData->getDatabaseEncoding(); + // Get database encoding + $dbEncoding = $data->getDatabaseEncoding(); // Set client encoding to database encoding if ($dbEncoding != '') { - $status = $localData->setClientEncoding($dbEncoding); + $status = $data->setClientEncoding($dbEncoding); if ($status != 0 && $status != -99) { echo $lang['strbadencoding']; exit; } // Override $lang['appcharset'] - if (isset($localData->codemap[$dbEncoding])) - $lang['appcharset'] = $localData->codemap[$dbEncoding]; + if (isset($data->codemap[$dbEncoding])) + $lang['appcharset'] = $data->codemap[$dbEncoding]; else $lang['appcharset'] = $dbEncoding; } } - // This experiment didn't quite work - try again later. - /* - else { - $status = $data->setClientEncoding('UNICODE'); - if ($status != 0) { - echo $lang['strbadencoding']; - exit; - } - - // Override $lang['appcharset'] - $lang['appcharset'] = $data->codemap['UNICODE']; - } - */ ?> diff --git a/operators.php b/operators.php index 0a9ae28e..50c7b434 100644 --- a/operators.php +++ b/operators.php @@ -3,7 +3,7 @@ /** * Manage operators in a database * - * $Id: operators.php,v 1.7 2003/10/26 10:59:16 chriskl Exp $ + * $Id: operators.php,v 1.8 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -17,14 +17,14 @@ * Show read only properties for an operator */ function doProperties($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['stroperators']}: ", $misc->printVal($_REQUEST['operator']), ": {$lang['strproperties']}

\n"; $misc->printMsg($msg); - $oprdata = &$localData->getOperator($_REQUEST['operator_oid']); - $oprdata->f['oprcanhash'] = $localData->phpBool($oprdata->f['oprcanhash']); + $oprdata = &$data->getOperator($_REQUEST['operator_oid']); + $oprdata->f['oprcanhash'] = $data->phpBool($oprdata->f['oprcanhash']); if ($oprdata->recordCount() > 0) { echo "
\n"; @@ -66,7 +66,7 @@ * Show confirmation of drop and perform actual drop */ function doDrop($confirm) { - global $localData, $database, $misc; + global $database, $misc; global $PHP_SELF, $lang; if ($confirm) { @@ -80,7 +80,7 @@ echo "\n"; echo $misc->form; // Show cascade drop option if supportd - if ($localData->hasDropBehavior()) { + if ($data->hasDropBehavior()) { echo "

{$lang['strcascade']}

\n"; } echo "\n"; @@ -88,7 +88,7 @@ echo "\n"; } else { - $status = $localData->dropOperator($_POST['operator_oid'], isset($_POST['cascade'])); + $status = $data->dropOperator($_POST['operator_oid'], isset($_POST['cascade'])); if ($status == 0) doDefault($lang['stroperatordropped']); else @@ -101,13 +101,13 @@ * Show default list of operators in the database */ function doDefault($msg = '') { - global $data, $localData, $misc, $database; + global $data, $misc, $database; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['stroperators']}

\n"; $misc->printMsg($msg); - $operators = &$localData->getOperators(); + $operators = &$data->getOperators(); if ($operators->recordCount() > 0) { echo "
\n"; diff --git a/privileges.php b/privileges.php index b9330e08..fae8342d 100644 --- a/privileges.php +++ b/privileges.php @@ -3,7 +3,7 @@ /** * Manage privileges in a database * - * $Id: privileges.php,v 1.19 2003/09/09 06:23:12 chriskl Exp $ + * $Id: privileges.php,v 1.20 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -19,7 +19,7 @@ * @param $msg (optional) A message to show */ function doAlter($confirm, $msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; if (!isset($_REQUEST['username'])) $_REQUEST['username'] = array(); @@ -29,7 +29,7 @@ // Set name switch ($_REQUEST['type']) { case 'function': - $fn = &$localData->getFunction($_REQUEST['object']); + $fn = &$data->getFunction($_REQUEST['object']); $data->fieldClean($fn->f[$data->fnFields['fnname']]); $name = $fn->f[$data->fnFields['fnname']] . "(". $fn->f[$data->fnFields['fnarguments']] .")"; break; @@ -39,9 +39,9 @@ if ($confirm) { // Get users from the database - $users = &$localData->getUsers(); + $users = &$data->getUsers(); // Get groups from the database - $groups = &$localData->getGroups(); + $groups = &$data->getGroups(); echo "

{$lang['strprivileges']}: ", $misc->printVal($name), ": {$lang['stralterprivs']}

\n"; $misc->printMsg($msg); @@ -111,7 +111,7 @@ echo "\n"; } else { - $status = $localData->setPrivileges(isset($_REQUEST['grant']) ? 'GRANT' : 'REVOKE', $_REQUEST['type'], $_REQUEST['object'], + $status = $data->setPrivileges(isset($_REQUEST['grant']) ? 'GRANT' : 'REVOKE', $_REQUEST['type'], $_REQUEST['object'], isset($_REQUEST['public']), $_REQUEST['username'], $_REQUEST['groupname'], array_keys($_REQUEST['privilege']), isset($_REQUEST['grantoption']), isset($_REQUEST['cascade'])); if ($status == 0) @@ -127,7 +127,7 @@ * Show permissions on a database, namespace, relation, language or function */ function doDefault($msg = '') { - global $data, $localData, $misc, $database; + global $data, $misc, $database; global $PHP_SELF, $lang; switch ($_REQUEST['type']) { @@ -149,7 +149,7 @@ $misc->printMsg($msg); // Get the privileges on the object, given its type - $privileges = $localData->getPrivileges($_REQUEST['object'], $_REQUEST['type']); + $privileges = $data->getPrivileges($_REQUEST['object'], $_REQUEST['type']); if (sizeof($privileges) > 0) { echo "
\n"; diff --git a/rules.php b/rules.php index f6830e85..7f0e8bca 100644 --- a/rules.php +++ b/rules.php @@ -3,7 +3,7 @@ /** * List rules on a table * - * $Id: rules.php,v 1.15 2003/10/26 10:59:16 chriskl Exp $ + * $Id: rules.php,v 1.16 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -16,7 +16,7 @@ * Confirm and then actually create a rule */ function createRule($confirm, $msg = '') { - global $PHP_SELF, $data, $localData, $misc; + global $PHP_SELF, $data, $data, $misc; global $lang; if (!isset($_POST['name'])) $_POST['name'] = ''; @@ -68,7 +68,7 @@ if (trim($_POST['name']) == '') createRule(true, $lang['strruleneedsname']); else { - $status = $localData->createRule($_POST['name'], + $status = $data->createRule($_POST['name'], $_POST['event'], $_POST['table'], $_POST['where'], isset($_POST['instead']), $_POST['type'], $_POST['raction']); if ($status == 0) @@ -83,7 +83,7 @@ * Show confirmation of drop and perform actual drop */ function doDrop($confirm) { - global $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; if ($confirm) { @@ -99,14 +99,14 @@ echo "\n"; echo $misc->form; // Show cascade drop option if supportd - if ($localData->hasDropBehavior()) { + if ($data->hasDropBehavior()) { echo "

{$lang['strcascade']}

\n"; } echo "\n"; echo "\n"; } else { - $status = $localData->dropRule($_POST['rule'], $_POST['table'], isset($_POST['cascade'])); + $status = $data->dropRule($_POST['rule'], $_POST['table'], isset($_POST['cascade'])); if ($status == 0) doDefault($lang['strruledropped']); else @@ -119,7 +119,7 @@ * List all the rules on the table */ function doDefault($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF; global $lang; @@ -127,7 +127,7 @@ echo "

", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['strrules']}

\n"; $misc->printMsg($msg); - $rules = &$localData->getRules($_REQUEST['table']); + $rules = &$data->getRules($_REQUEST['table']); if ($rules->recordCount() > 0) { echo "
\n"; diff --git a/schema.php b/schema.php index 77a4ebba..dfb5f433 100755 --- a/schema.php +++ b/schema.php @@ -3,10 +3,11 @@ /** * Display properties of a schema * - * $Id: schema.php,v 1.9 2003/10/27 05:43:18 chriskl Exp $ + * $Id: schema.php,v 1.10 2003/12/10 16:03:29 chriskl Exp $ */ - // Include application functions + // Include application functions (no db conn) + $_no_db_connection = true; include_once('libraries/lib.inc.php'); $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : ''; diff --git a/sequences.php b/sequences.php index 92ff97fb..c2297991 100644 --- a/sequences.php +++ b/sequences.php @@ -3,7 +3,7 @@ /** * Manage sequences in a database * - * $Id: sequences.php,v 1.14 2003/09/08 03:00:12 chriskl Exp $ + * $Id: sequences.php,v 1.15 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -17,14 +17,14 @@ * Display list of all sequences in the database/schema */ function doDefault($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strsequences']}

\n"; $misc->printMsg($msg); // Get all sequences - $sequences = &$localData->getSequences(); + $sequences = &$data->getSequences(); if (is_object($sequences) && $sequences->recordCount() > 0) { echo "
\n"; @@ -62,14 +62,14 @@ * Display the properties of a sequence */ function doProperties($msg = '') { - global $data, $localData, $misc, $PHP_SELF; + global $data, $misc, $PHP_SELF; global $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strsequences']} : ", $misc->printVal($_REQUEST['sequence']), ": {$lang['strproperties']}

\n"; $misc->printMsg($msg); // Fetch the sequence information - $sequence = &$localData->getSequence($_REQUEST['sequence']); + $sequence = &$data->getSequence($_REQUEST['sequence']); if (is_object($sequence) && $sequence->recordCount() > 0) { echo "
"; @@ -107,7 +107,7 @@ * Drop a sequence */ function doDrop($confirm, $msg = '') { - global $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; if ($confirm) { @@ -121,7 +121,7 @@ echo "\n"; echo $misc->form; // Show cascade drop option if supportd - if ($localData->hasDropBehavior()) { + if ($data->hasDropBehavior()) { echo "

{$lang['strcascade']}

\n"; } echo "\n"; @@ -129,7 +129,7 @@ echo "\n"; } else { - $status = $localData->dropSequence($_POST['sequence'], isset($_POST['cascade'])); + $status = $data->dropSequence($_POST['sequence'], isset($_POST['cascade'])); if ($status == 0) doDefault($lang['strsequencedropped']); else @@ -141,7 +141,7 @@ * Displays a screen where they can enter a new sequence */ function doCreateSequence($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; if (!isset($_POST['formSequenceName'])) $_POST['formSequenceName'] = ''; @@ -191,13 +191,13 @@ * Actually creates the new sequence in the database */ function doSaveCreateSequence() { - global $localData; + global $data; global $lang; // Check that they've given a name and at least one column if ($_POST['formSequenceName'] == '') doCreateSequence($lang['strsequenceneedsname']); else { - $status = $localData->createSequence($_POST['formSequenceName'], $_POST['formIncrement'], + $status = $data->createSequence($_POST['formSequenceName'], $_POST['formIncrement'], $_POST['formMinValue'], $_POST['formMaxValue'], $_POST['formStartValue']); if ($status == 0) { doDefault($lang['strsequencecreated']); @@ -211,10 +211,10 @@ * Resets a sequence */ function doReset() { - global $localData; + global $data; global $PHP_SELF, $lang; - $status = $localData->resetSequence($_REQUEST['sequence']); + $status = $data->resetSequence($_REQUEST['sequence']); if ($status == 0) doProperties($lang['strsequencereset']); else diff --git a/sql.php b/sql.php index 8c0236bb..7f8c0f55 100644 --- a/sql.php +++ b/sql.php @@ -6,7 +6,7 @@ * how many SQL statements have been strung together with semi-colons * @param $query The SQL query string to execute * - * $Id: sql.php,v 1.12 2003/11/15 11:09:32 chriskl Exp $ + * $Id: sql.php,v 1.13 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -26,9 +26,9 @@ } // Set fetch mode to NUM so that duplicate field names are properly returned - $localData->conn->setFetchMode(ADODB_FETCH_NUM); + $data->conn->setFetchMode(ADODB_FETCH_NUM); // Execute the query - $rs = $localData->conn->Execute($_POST['query']); + $rs = $data->conn->Execute($_POST['query']); // $rs will only be an object if there is no error if (is_object($rs)) { @@ -58,8 +58,8 @@ echo "

", $rs->recordCount(), " {$lang['strrows']}

\n"; } // Otherwise if any rows have been affected - elseif ($localData->conn->Affected_Rows() > 0) { - echo "

", $localData->conn->Affected_Rows(), " {$lang['strrowsaff']}

\n"; + elseif ($data->conn->Affected_Rows() > 0) { + echo "

", $data->conn->Affected_Rows(), " {$lang['strrowsaff']}

\n"; } // Else say success else echo "

{$lang['strsqlexecuted']}

\n"; diff --git a/sqledit.php b/sqledit.php index 98457d33..18af9871 100644 --- a/sqledit.php +++ b/sqledit.php @@ -3,7 +3,7 @@ /** * Alternative SQL editing window * - * $Id: sqledit.php,v 1.7 2003/10/31 02:36:49 chriskl Exp $ + * $Id: sqledit.php,v 1.8 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -65,7 +65,7 @@ * Allow execution of arbitrary SQL statements on a database */ function doDefault() { - global $PHP_SELF, $data, $localData, $misc; + global $PHP_SELF, $data, $data, $misc; global $lang, $conf; if (!isset($_POST['query'])) $_POST['query'] = ''; diff --git a/tables.php b/tables.php index 83938915..8e48ce23 100644 --- a/tables.php +++ b/tables.php @@ -3,7 +3,7 @@ /** * List tables in a database * - * $Id: tables.php,v 1.39 2003/11/05 08:32:03 chriskl Exp $ + * $Id: tables.php,v 1.40 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -16,7 +16,7 @@ * Displays a screen where they can enter a new table */ function doCreate($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; if (!isset($_REQUEST['stage'])) $_REQUEST['stage'] = 1; @@ -65,7 +65,7 @@ return; } - $types = &$localData->getTypes(true); + $types = &$data->getTypes(true); echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}: {$lang['strcreatetable']}

\n"; $misc->printMsg($msg); @@ -85,7 +85,7 @@ htmlspecialchars($_REQUEST['field'][$i]), "\" />"; echo ""; echo ""; - echo ""; + echo ""; echo ""; echo "\n"; $i++; @@ -246,7 +246,7 @@ // Verify that they haven't supplied a value for unary operators foreach ($_GET['ops'] as $k => $v) { - if ($localData->selectOps[$v] == 'p' && $_GET['values'][$k] != '') { + if ($data->selectOps[$v] == 'p' && $_GET['values'][$k] != '') { doSelectRows(true, $lang['strselectunary']); return; } @@ -256,7 +256,7 @@ doSelectRows(true, $lang['strselectneedscol']); else { // Generate query SQL - $query = $localData->getSelectSQL($_REQUEST['table'], array_keys($_GET['show']), + $query = $data->getSelectSQL($_REQUEST['table'], array_keys($_GET['show']), $_GET['values'], $_GET['ops']); $_REQUEST['query'] = $query; $_REQUEST['return_url'] = "tables.php?action=confselectrows&{$misc->href}&table={$_REQUEST['table']}"; @@ -273,7 +273,7 @@ * Ask for insert parameters and then actually insert row */ function doInsertRow($confirm, $msg = '') { - global $localData, $database, $misc; + global $database, $misc; global $lang; global $PHP_SELF; @@ -281,7 +281,7 @@ echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}: ", $misc->printVal($_REQUEST['table']), ": {$lang['strinsertrow']}

\n"; $misc->printMsg($msg); - $attrs = &$localData->getTableAttributes($_REQUEST['table']); + $attrs = &$data->getTableAttributes($_REQUEST['table']); echo "\n"; if ($attrs->recordCount() > 0) { @@ -294,7 +294,7 @@ $i = 0; while (!$attrs->EOF) { - $attrs->f['attnotnull'] = $localData->phpBool($attrs->f['attnotnull']); + $attrs->f['attnotnull'] = $data->phpBool($attrs->f['attnotnull']); // 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']; @@ -307,7 +307,7 @@ echo "\n"; echo ""; echo ""; echo ""; else echo " "; - echo ""; echo "\n"; $i++; @@ -344,7 +344,7 @@ if (!isset($_POST['values'])) $_POST['values'] = array(); if (!isset($_POST['nulls'])) $_POST['nulls'] = array(); - $status = $localData->insertRow($_POST['table'], $_POST['values'], + $status = $data->insertRow($_POST['table'], $_POST['values'], $_POST['nulls'], $_POST['format'], $_POST['types']); if ($status == 0) { if (isset($_POST['save'])) @@ -365,7 +365,7 @@ * Show confirmation of empty and perform actual empty */ function doEmpty($confirm) { - global $localData, $database, $misc; + global $database, $misc; global $lang; global $PHP_SELF; @@ -382,7 +382,7 @@ echo "\n"; } else { - $status = $localData->emptyTable($_POST['table']); + $status = $data->emptyTable($_POST['table']); if ($status == 0) doDefault($lang['strtableemptied']); else @@ -395,7 +395,7 @@ * Show confirmation of drop and perform actual drop */ function doDrop($confirm) { - global $localData, $database, $misc; + global $database, $misc; global $lang, $_reload_browser; global $PHP_SELF; @@ -409,7 +409,7 @@ echo "\n"; echo $misc->form; // Show cascade drop option if supportd - if ($localData->hasDropBehavior()) { + if ($data->hasDropBehavior()) { echo "

{$lang['strcascade']}

\n"; } echo "\n"; @@ -417,7 +417,7 @@ echo "\n"; } else { - $status = $localData->dropTable($_POST['table'], isset($_POST['cascade'])); + $status = $data->dropTable($_POST['table'], isset($_POST['cascade'])); if ($status == 0) { $_reload_browser = true; doDefault($lang['strtabledropped']); @@ -432,12 +432,12 @@ * Show default list of tables in the database */ function doDefault($msg = '') { - global $data, $misc, $localData; + global $data, $misc, $data; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}

\n"; - $tables = &$localData->getTables(); + $tables = &$data->getTables(); if ($tables->recordCount() > 0) { echo "
f['attname']), "]\"", isset($_REQUEST['show'][$attrs->f['attname']]) ? ' checked="checked"' : '', " />", $misc->printVal($attrs->f['attname']), "", $misc->printVal($localData->formatType($attrs->f['type'], $attrs->f['atttypmod'])), "", $misc->printVal($data->formatType($attrs->f['type'], $attrs->f['atttypmod'])), ""; echo "\n"; - echo "", $localData->printField("values[{$attrs->f['attname']}]", + echo "", $data->printField("values[{$attrs->f['attname']}]", $_REQUEST['values'][$attrs->f['attname']], $attrs->f['type']), "
", $misc->printVal($attrs->f['attname']), "\n"; - echo $misc->printVal($localData->formatType($attrs->f['type'], $attrs->f['atttypmod'])); + echo $misc->printVal($data->formatType($attrs->f['type'], $attrs->f['atttypmod'])); echo "f['attname']), "]\" value=\"", htmlspecialchars($attrs->f['type']), "\" />\n"; @@ -322,7 +322,7 @@ isset($_REQUEST['nulls'][$attrs->f['attname']]) ? ' checked="checked"' : '', " />", $localData->printField("values[{$attrs->f['attname']}]", + echo "", $data->printField("values[{$attrs->f['attname']}]", $_REQUEST['values'][$attrs->f['attname']], $attrs->f['type']), "
\n"; diff --git a/tblproperties.php b/tblproperties.php index 9b1e3060..8eb13295 100644 --- a/tblproperties.php +++ b/tblproperties.php @@ -3,7 +3,7 @@ /** * List tables in a database * - * $Id: tblproperties.php,v 1.30 2003/11/05 08:32:03 chriskl Exp $ + * $Id: tblproperties.php,v 1.31 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -16,12 +16,12 @@ * Function to save after altering a table */ function doSaveAlter() { - global $localData, $lang, $_reload_browser; + global $data, $lang, $_reload_browser; // For databases that don't allow owner change if (!isset($_POST['owner'])) $_POST['owner'] = ''; - $status = $localData->alterTable($_POST['table'], $_POST['name'], $_POST['owner'], $_POST['comment']); + $status = $data->alterTable($_POST['table'], $_POST['name'], $_POST['owner'], $_POST['comment']); if ($status == 0) { // Jump them to the new table name $_REQUEST['table'] = $_POST['name']; @@ -37,14 +37,14 @@ * Function to allow altering of a table */ function doAlter($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['stralter']}

\n"; $misc->printMsg($msg); // Fetch table info - $table = &$localData->getTable($_REQUEST['table']); + $table = &$data->getTable($_REQUEST['table']); // Fetch all users $users = &$data->getUsers(); @@ -87,11 +87,11 @@ } function doExport($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; // Determine whether or not the table has an object ID - $hasID = $localData->hasObjectID($_REQUEST['table']); + $hasID = $data->hasObjectID($_REQUEST['table']); $misc->printTableNav(); echo "

", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['strexport']}

\n"; @@ -149,7 +149,7 @@ * Displays a screen where they can add a column */ function doAddColumn($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; if (!isset($_REQUEST['stage'])) $_REQUEST['stage'] = 1; @@ -164,7 +164,7 @@ if (!isset($_POST['length'])) $_POST['length'] = ''; // Fetch all available types - $types = &$localData->getTypes(true); + $types = &$data->getTypes(true); echo "

", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['straddcolumn']}

\n"; @@ -199,7 +199,7 @@ break; case 2: - global $localData, $lang; + global $data, $lang; // Check inputs if (trim($_POST['field']) == '') { @@ -208,7 +208,7 @@ return; } - $status = $localData->addColumn($_POST['table'], $_POST['field'], + $status = $data->addColumn($_POST['table'], $_POST['field'], $_POST['type'], $_POST['length']); if ($status == 0) doDefault($lang['strcolumnadded']); @@ -227,7 +227,7 @@ * Displays a screen where they can alter a column */ function doProperties($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; if (!isset($_REQUEST['stage'])) $_REQUEST['stage'] = 1; @@ -246,8 +246,8 @@ echo "
\n"; echo ""; - $column = &$localData->getTableAttributes($_REQUEST['table'], $_REQUEST['column']); - $column->f['attnotnull'] = $localData->phpBool($column->f['attnotnull']); + $column = &$data->getTableAttributes($_REQUEST['table'], $_REQUEST['column']); + $column->f['attnotnull'] = $data->phpBool($column->f['attnotnull']); if (!isset($_REQUEST['default'])) { $_REQUEST['field'] = $column->f['attname']; @@ -257,7 +257,7 @@ echo ""; - echo ""; + echo ""; echo "\n"; echo ""; @@ -275,7 +275,7 @@ break; case 2: - global $localData, $lang; + global $data, $lang; // Check inputs if (trim($_REQUEST['field']) == '') { @@ -284,7 +284,7 @@ return; } - $status = $localData->alterColumn($_REQUEST['table'], $_REQUEST['column'], $_REQUEST['field'], + $status = $data->alterColumn($_REQUEST['table'], $_REQUEST['column'], $_REQUEST['field'], isset($_REQUEST['notnull']), $_REQUEST['default'], $_REQUEST['olddefault']); if ($status == 0) doDefault($lang['strcolumnaltered']); @@ -303,7 +303,7 @@ * Show confirmation of drop column and perform actual drop */ function doDrop($confirm) { - global $localData, $database, $misc; + global $data, $database, $misc; global $PHP_SELF, $lang; if ($confirm) { @@ -320,7 +320,7 @@ echo "\n"; echo $misc->form; // Show cascade drop option if supportd - if ($localData->hasDropBehavior()) { + if ($data->hasDropBehavior()) { echo "

{$lang['strcascade']}

\n"; } echo "\n"; @@ -328,7 +328,7 @@ echo "\n"; } else { - $status = $localData->dropColumn($_POST['table'], $_POST['column'], isset($_POST['cascade'])); + $status = $data->dropColumn($_POST['table'], $_POST['column'], isset($_POST['cascade'])); if ($status == 0) doDefault($lang['strcolumndropped']); else @@ -341,16 +341,16 @@ * Show default list of columns in the table */ function doDefault($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; $misc->printTableNav(); echo "

", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), "

\n"; // Get table - $tdata = &$localData->getTable($_REQUEST['table']); + $tdata = &$data->getTable($_REQUEST['table']); // Get columns - $attrs = &$localData->getTableAttributes($_REQUEST['table']); + $attrs = &$data->getTableAttributes($_REQUEST['table']); $misc->printMsg($msg); // Show comment if any @@ -368,10 +368,10 @@ $i = 0; while (!$attrs->EOF) { - $attrs->f['attnotnull'] = $localData->phpBool($attrs->f['attnotnull']); + $attrs->f['attnotnull'] = $data->phpBool($attrs->f['attnotnull']); $id = (($i % 2) == 0 ? '1' : '2'); echo "\n\t\n"; - echo "\t\n"; + echo "\t\n"; echo "\t\n"; echo "\t\n"; echo "\t
{$lang['strfield']}{$lang['strtype']}{$lang['strnotnull']}{$lang['strdefault']}
", $misc->printVal($localData->formatType($column->f['type'], $column->f['atttypmod'])), "", $misc->printVal($data->formatType($column->f['type'], $column->f['atttypmod'])), "
", $misc->printVal($attrs->f['attname']), "", $misc->printVal($localData->formatType($attrs->f['type'], $attrs->f['atttypmod'])), "", $misc->printVal($data->formatType($attrs->f['type'], $attrs->f['atttypmod'])), "", ($attrs->f['attnotnull'] ? 'NOT NULL' : ''), "", $misc->printVal($attrs->f['adsrc']), "href}&table=", urlencode($_REQUEST['table']), diff --git a/triggers.php b/triggers.php index 3a781614..6df2f481 100644 --- a/triggers.php +++ b/triggers.php @@ -3,7 +3,7 @@ /** * List triggers on a table * - * $Id: triggers.php,v 1.16 2003/07/30 07:02:29 chriskl Exp $ + * $Id: triggers.php,v 1.17 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -17,9 +17,9 @@ * Function to save after altering a trigger */ function doSaveAlter() { - global $localData, $lang; + global $data, $lang; - $status = $localData->alterTrigger($_POST['table'], $_POST['trigger'], $_POST['name']); + $status = $data->alterTrigger($_POST['table'], $_POST['trigger'], $_POST['name']); if ($status == 0) doDefault($lang['strtriggeraltered']); else @@ -30,13 +30,13 @@ * Function to allow altering of a trigger */ function doAlter($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strtriggers']}: ", $misc->printVal($_REQUEST['trigger']), ": {$lang['stralter']}

\n"; $misc->printMsg($msg); - $triggerdata = &$localData->getTrigger($_REQUEST['table'], $_REQUEST['trigger']); + $triggerdata = &$data->getTrigger($_REQUEST['table'], $_REQUEST['trigger']); if ($triggerdata->recordCount() > 0) { @@ -64,7 +64,7 @@ * Show confirmation of drop and perform actual drop */ function doDrop($confirm) { - global $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; if ($confirm) { @@ -80,7 +80,7 @@ echo "\n"; echo $misc->form; // Show cascade drop option if supportd - if ($localData->hasDropBehavior()) { + if ($data->hasDropBehavior()) { echo "

{$lang['strcascade']}

\n"; } echo "\n"; @@ -88,7 +88,7 @@ echo "\n"; } else { - $status = $localData->dropTrigger($_POST['trigger'], $_POST['table'], isset($_POST['cascade'])); + $status = $data->dropTrigger($_POST['trigger'], $_POST['table'], isset($_POST['cascade'])); if ($status == 0) doDefault($lang['strtriggerdropped']); else @@ -101,14 +101,14 @@ * Let them create s.th. */ function doCreate($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; echo "

{$lang['strcreatetrigger']}

"; $misc->printMsg($msg); // Get all the functions that can be used in triggers - $funcs = &$localData->getTriggerFunctions(); + $funcs = &$data->getTriggerFunctions(); if ($funcs->recordCount() == 0) { doDefault($lang['strnofunctions']); return; @@ -123,11 +123,11 @@ /* Populate times */ $sel1 = new XHTML_Select('formExecTime'); - $sel1->set_data($localData->triggerExecTimes); + $sel1->set_data($data->triggerExecTimes); /* Populate events */ $sel2 = new XHTML_Select('formEvent'); - $sel2->set_data($localData->triggerEvents); + $sel2->set_data($data->triggerEvents); echo "
\n"; echo "\n"; @@ -158,7 +158,7 @@ * Actually creates the new trigger in the database */ function doSaveCreate() { - global $localData; + global $data; global $PHP_SELF, $lang; // Check that they've given a name and a definition @@ -170,7 +170,7 @@ elseif ($_POST['formEvent'] == '') doCreate(); else { - $status = &$localData->createTrigger($_POST['formTriggerName'], $_POST['table'], + $status = &$data->createTrigger($_POST['formTriggerName'], $_POST['table'], $_POST['formFunction'], $_POST['formExecTime'], $_POST['formEvent'], $_POST['formTriggerArgs']); if ($status == 0) @@ -184,7 +184,7 @@ * List all the triggers on the table */ function doDefault($msg = '') { - global $data, $localData, $misc, $database; + global $data, $misc, $database; global $PHP_SELF; global $lang; @@ -192,7 +192,7 @@ echo "

", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['strtriggers']}

\n"; $misc->printMsg($msg); - $triggers = &$localData->getTriggers($_REQUEST['table']); + $triggers = &$data->getTriggers($_REQUEST['table']); if ($triggers->recordCount() > 0) { echo "
\n"; @@ -208,7 +208,7 @@ if ($triggers->f[$data->tgFields['tgdef']] !== null) echo $misc->printVal($triggers->f[$data->tgFields['tgdef']]); else - echo $misc->printVal($localData->getTriggerDef($triggers->f)); + echo $misc->printVal($data->getTriggerDef($triggers->f)); echo "\n"; if ($data->hasAlterTrigger()) { echo "
href}&trigger=", urlencode($triggers->f[$data->tgFields['tgname']]), diff --git a/types.php b/types.php index b97a9b7a..3715dd9e 100644 --- a/types.php +++ b/types.php @@ -3,7 +3,7 @@ /** * Manage types in a database * - * $Id: types.php,v 1.11 2003/09/09 06:23:12 chriskl Exp $ + * $Id: types.php,v 1.12 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -17,13 +17,13 @@ * Show read only properties for a type */ function doProperties($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strtypes']}: ", $misc->printVal($_REQUEST['type']), ": {$lang['strproperties']}

\n"; $misc->printMsg($msg); - $typedata = &$localData->getType($_REQUEST['type']); + $typedata = &$data->getType($_REQUEST['type']); if ($typedata->recordCount() > 0) { $byval = $data->phpBool($typedata->f[$data->typFields['typbyval']]); @@ -51,7 +51,7 @@ * Show confirmation of drop and perform actual drop */ function doDrop($confirm) { - global $localData, $database, $misc; + global $database, $misc; global $PHP_SELF, $lang; if ($confirm) { @@ -64,7 +64,7 @@ echo "\n"; echo $misc->form; // Show cascade drop option if supportd - if ($localData->hasDropBehavior()) { + if ($data->hasDropBehavior()) { echo "

{$lang['strcascade']}

\n"; } echo "\n"; @@ -72,7 +72,7 @@ echo "\n"; } else { - $status = $localData->dropType($_POST['type'], isset($_POST['cascade'])); + $status = $data->dropType($_POST['type'], isset($_POST['cascade'])); if ($status == 0) doDefault($lang['strtypedropped']); else @@ -85,7 +85,7 @@ * Displays a screen where they can enter a new type */ function doCreate($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; if (!isset($_POST['typname'])) $_POST['typname'] = ''; @@ -99,8 +99,8 @@ if (!isset($_POST['typstorage'])) $_POST['typstorage'] = $data->typStorageDef; // Retrieve all functions and types in the database - $funcs = &$localData->getFunctions(true); - $types = &$localData->getTypes(); + $funcs = &$data->getFunctions(true); + $types = &$data->getTypes(); echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strtypes']}: {$lang['strcreatetype']}

\n"; $misc->printMsg($msg); @@ -177,7 +177,7 @@ * Actually creates the new type in the database */ function doSaveCreate() { - global $localData; + global $data; global $lang; // Check that they've given a name and a length. @@ -186,7 +186,7 @@ if ($_POST['typname'] == '') doCreate($lang['strtypeneedsname']); elseif ($_POST['typlen'] == '') doCreate($lang['strtypeneedslen']); else { - $status = $localData->createType( + $status = $data->createType( $_POST['typname'], $_POST['typin'], $_POST['typout'], @@ -209,13 +209,13 @@ * Show default list of types in the database */ function doDefault($msg = '') { - global $data, $localData, $misc, $database; + global $data, $misc, $database; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strtypes']}

\n"; $misc->printMsg($msg); - $types = &$localData->getTypes(); + $types = &$data->getTypes(); if ($types->recordCount() > 0) { echo "\n"; diff --git a/views.php b/views.php index 6f11bb9a..e4cd592d 100644 --- a/views.php +++ b/views.php @@ -3,7 +3,7 @@ /** * Manage views in a database * - * $Id: views.php,v 1.24 2003/11/05 08:32:03 chriskl Exp $ + * $Id: views.php,v 1.25 2003/12/10 16:03:29 chriskl Exp $ */ // Include application functions @@ -17,7 +17,7 @@ * Ask for select parameters and perform select */ function doSelectRows($confirm, $msg = '') { - global $localData, $database, $misc; + global $database, $misc; global $lang; global $PHP_SELF; @@ -25,7 +25,7 @@ echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strviews']}: ", $misc->printVal($_REQUEST['view']), ": {$lang['strselect']}

\n"; $misc->printMsg($msg); - $attrs = &$localData->getTableAttributes($_REQUEST['view']); + $attrs = &$data->getTableAttributes($_REQUEST['view']); echo "\n"; if ($attrs->recordCount() > 0) { @@ -50,7 +50,7 @@ $i = 0; while (!$attrs->EOF) { - $attrs->f['attnotnull'] = $localData->phpBool($attrs->f['attnotnull']); + $attrs->f['attnotnull'] = $data->phpBool($attrs->f['attnotnull']); // Set up default value if there isn't one already if (!isset($_REQUEST['values'][$attrs->f['attname']])) $_REQUEST['values'][$attrs->f['attname']] = null; @@ -63,15 +63,15 @@ echo "f['attname']), "]\"", isset($_REQUEST['show'][$attrs->f['attname']]) ? ' checked="checked"' : '', " />"; echo ""; - echo ""; + echo ""; echo ""; echo "\n"; $i++; @@ -97,7 +97,7 @@ // Verify that they haven't supplied a value for unary operators foreach ($_GET['ops'] as $k => $v) { - if ($localData->selectOps[$v] == 'p' && $_GET['values'][$k] != '') { + if ($data->selectOps[$v] == 'p' && $_GET['values'][$k] != '') { doSelectRows(true, $lang['strselectunary']); return; } @@ -107,7 +107,7 @@ doSelectRows(true, $lang['strselectneedscol']); else { // Generate query SQL - $query = $localData->getSelectSQL($_REQUEST['view'], array_keys($_GET['show']), + $query = $data->getSelectSQL($_REQUEST['view'], array_keys($_GET['show']), $_GET['values'], $_GET['ops']); $_REQUEST['query'] = $query; $_REQUEST['return_url'] = "views.php?action=confselectrows&{$misc->href}&view={$_REQUEST['view']}"; @@ -124,9 +124,9 @@ * Function to save after editing a view */ function doSaveEdit() { - global $localData, $lang; + global $data, $lang; - $status = $localData->setView($_POST['view'], $_POST['formDefinition']); + $status = $data->setView($_POST['view'], $_POST['formDefinition']); if ($status == 0) doProperties($lang['strviewupdated']); else @@ -137,13 +137,13 @@ * Function to allow editing of a view */ function doEdit($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strviews']}: ", $misc->printVal($_REQUEST['view']), ": {$lang['stredit']}

\n"; $misc->printMsg($msg); - $viewdata = &$localData->getView($_REQUEST['view']); + $viewdata = &$data->getView($_REQUEST['view']); if ($viewdata->recordCount() > 0) { @@ -169,13 +169,13 @@ * Show read only properties for a view */ function doProperties($msg = '') { - global $data, $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strviews']}: ", $misc->printVal($_REQUEST['view']), ": {$lang['strproperties']}

\n"; $misc->printMsg($msg); - $viewdata = &$localData->getView($_REQUEST['view']); + $viewdata = &$data->getView($_REQUEST['view']); if ($viewdata->recordCount() > 0) { echo "
", $misc->printVal($attrs->f['attname']), "", $misc->printVal($localData->formatType($attrs->f['type'], $attrs->f['atttypmod'])), "", $misc->printVal($data->formatType($attrs->f['type'], $attrs->f['atttypmod'])), ""; echo "\n"; - echo "", $localData->printField("values[{$attrs->f['attname']}]", + echo "", $data->printField("values[{$attrs->f['attname']}]", $_REQUEST['values'][$attrs->f['attname']], $attrs->f['type']), "
\n"; @@ -196,7 +196,7 @@ * Show confirmation of drop and perform actual drop */ function doDrop($confirm) { - global $localData, $misc; + global $data, $misc; global $PHP_SELF, $lang; if ($confirm) { @@ -208,7 +208,7 @@ echo "\n"; echo $misc->form; // Show cascade drop option if supportd - if ($localData->hasDropBehavior()) { + if ($data->hasDropBehavior()) { echo "

{$lang['strcascade']}

\n"; } echo "\n"; @@ -216,7 +216,7 @@ echo "\n"; } else { - $status = $localData->dropView($_POST['view'], isset($_POST['cascade'])); + $status = $data->dropView($_POST['view'], isset($_POST['cascade'])); if ($status == 0) doDefault($lang['strviewdropped']); else @@ -229,7 +229,7 @@ * Displays a screen where they can enter a new view */ function doCreate($msg = '') { - global $data, $localData, $misc, $conf; + global $data, $misc, $conf; global $PHP_SELF, $lang; if (!isset($_REQUEST['formView'])) $_REQUEST['formView'] = ''; @@ -260,13 +260,13 @@ * Actually creates the new view in the database */ function doSaveCreate() { - global $localData, $lang; + global $data, $lang; // Check that they've given a name and a definition if ($_POST['formView'] == '') doCreate($lang['strviewneedsname']); elseif ($_POST['formDefinition'] == '') doCreate($lang['strviewneedsdef']); else { - $status = $localData->createView($_POST['formView'], $_POST['formDefinition'], false); + $status = $data->createView($_POST['formView'], $_POST['formDefinition'], false); if ($status == 0) doDefault($lang['strviewcreated']); else @@ -278,14 +278,14 @@ * Show default list of views in the database */ function doDefault($msg = '') { - global $data, $localData, $misc, $conf; + global $data, $misc, $conf; global $PHP_SELF, $lang; echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strviews']}

\n"; //$misc->printHelp("/tutorial-views.html"); $misc->printMsg($msg); - $views = &$localData->getViews(); + $views = &$data->getViews(); if ($views->recordCount() > 0) { echo "
\n"; -- 2.39.5