From 7c93e764233a987efec3aa0dfec32c2fbd3266f7 Mon Sep 17 00:00:00 2001 From: chriskl Date: Fri, 5 Sep 2003 04:58:14 +0000 Subject: [PATCH] put Find in SQL window and topbar. fix escaping bugs for pre 7.3. fix a few notices. fix hard coded string. column headers are now bold in browse mode, even tho they're links --- BUGS | 9 +--- HISTORY | 3 ++ TODO | 9 +++- classes/Misc.php | 14 +++++- classes/database/Postgres.php | 9 ++-- display.php | 4 +- sql.php | 93 ++++++++++++++++------------------- sqledit.php | 68 ++++++++++++++++++------- themes/default/global.css | 7 ++- topbar.php | 6 ++- 10 files changed, 133 insertions(+), 89 deletions(-) diff --git a/BUGS b/BUGS index ca65bff8..bc3f654c 100644 --- a/BUGS +++ b/BUGS @@ -1,11 +1,4 @@ -* Backport findObject to pre-7.3 -* Add db comments everywhere -* Add owner everywhere -* pg_dump feature!!! -* reports - unindexed fk's - - slow indexes * Get table comments for pre-7.3 * make getrowidentifier prefer unique indexes that don't allow nulls, and don't use partial indexes -* remove tblexport.php from cvs - +* Use explicit session names diff --git a/HISTORY b/HISTORY index c77a7584..19d9277f 100644 --- a/HISTORY +++ b/HISTORY @@ -39,6 +39,8 @@ Features: * Swedish translation from Stefan Malqvist * Add a robots.txt file to prevent search engine indexation * Italian translation update from Nicola Soranzo +* German update from Markus Bertheau +* Spanish update from Martin Marques Bug Fixes: * Lots of NULL value in table dump fixes (XML format changed slightly) @@ -50,6 +52,7 @@ Bug Fixes: * Fix saving and loading function volatility * Don't list domains under types * Lots of reports fixes (titles, page reloads, etc.) +* Selecting for NULL values in Select feature Version 3.0.1 ------------- diff --git a/TODO b/TODO index 27a2b500..df480a14 100644 --- a/TODO +++ b/TODO @@ -38,8 +38,8 @@ Tables ------ * Not using proper attFields array for attribute info (i was being lazy) -* Rename table -* Change table owner +* -Rename table +* -Change table owner * Cluster support * Vacuum & analyze (half done) @@ -116,6 +116,11 @@ Miscellaneous ------------- * Allow simultaneous logins to different clusters (mark gibson) +* Show comments for all objects +* Allow setting/dropping comments for all objects +* Show owner for all objects +* Allow changing owner for objects that have this feature (7.4+ generally) +* pg_dump integration Exotic ------ diff --git a/classes/Misc.php b/classes/Misc.php index b9527e5c..1251ec5a 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.42 2003/08/27 22:52:43 slubek Exp $ + * $Id: Misc.php,v 1.43 2003/09/05 04:58:14 chriskl Exp $ */ class Misc { @@ -313,6 +313,18 @@ echo "\n"; } + /** + * Display the navigation header for popup window + */ + function printPopUpNav() { + global $lang, $data; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
{$lang['strsql']}{$lang['strfind']}
\n"; + } + /** * Do multi-page navigation. Displays the prev, next and page options. * @param $page the page currently viewed diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index baf00ed5..863ecb70 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.143 2003/09/03 05:46:20 chriskl Exp $ + * $Id: Postgres.php,v 1.144 2003/09/05 04:58:14 chriskl Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -1590,9 +1590,10 @@ class Postgres extends BaseDB { global $conf; // Escape search term for ~* match - // @@ This needs to be improved - $term = str_replace('.', '\\.', $term); - $term = str_replace('*', '\\*', $term); + $special = array('.', '*', '^', '$', ':', '?', '+', ',', '=', '!', '[', ']', '(', ')', '{', '}', '<', '>', '-', '\\'); + foreach ($special as $v) { + $term = str_replace($v, "\\{$v}", $term); + } $this->clean($term); // Build SQL, excluding system relations as necessary diff --git a/display.php b/display.php index 1c00fc20..e94888be 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.25 2003/09/01 03:08:12 chriskl Exp $ + * $Id: display.php,v 1.26 2003/09/05 04:58:14 chriskl Exp $ */ // Include application functions @@ -79,7 +79,7 @@ echo " | {$lang['strsaveasreport']}\n"; } - if (is_object($rs) && $rs->recordCount() > 0) { + if (isset($rs) && is_object($rs) && $rs->recordCount() > 0) { echo " | href}\">{$lang['strdownload']}\n"; } diff --git a/sql.php b/sql.php index 2f69cc1e..d5d0e31b 100644 --- a/sql.php +++ b/sql.php @@ -5,10 +5,8 @@ * unless we implement a full SQL parser, there's no way of knowing * how many SQL statements have been strung together with semi-colons * @param $query The SQL query string to execute - * @param $return_url The return URL - * @param $return_desc The return link name * - * $Id: sql.php,v 1.9 2003/08/18 08:20:43 chriskl Exp $ + * $Id: sql.php,v 1.10 2003/09/05 04:58:14 chriskl Exp $ */ // Include application functions @@ -21,62 +19,57 @@ $misc->printDatabaseNav(); echo "

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

\n"; - $_POST['query'] = trim($_POST['query']); - if ($_POST['query'] != '') { - - // NOTE: This is a quick hack! - if (isset($_POST['explain'])) { - // TODO: Is there a generic (non PostgreSQL specific) way to do this - $_POST['query'] = 'EXPLAIN '.$_POST['query']; - } - - // Set fetch mode to NUM so that duplicate field names are properly returned - $localData->conn->setFetchMode(ADODB_FETCH_NUM); - // Execute the query - $rs = $localData->conn->Execute($_POST['query']); + // NOTE: This is a quick hack! + if (isset($_POST['explain'])) { + // TODO: Is there a generic (non PostgreSQL specific) way to do this + $_POST['query'] = 'EXPLAIN '.$_POST['query']; + } + + // Set fetch mode to NUM so that duplicate field names are properly returned + $localData->conn->setFetchMode(ADODB_FETCH_NUM); + // Execute the query + $rs = $localData->conn->Execute($_POST['query']); + + // $rs will only be an object if there is no error + if (is_object($rs)) { + // Now, depending on what happened do various things - // $rs will only be an object if there is no error - if (is_object($rs)) { - // Now, depending on what happened do various things + // First, if rows returned, then display the results + if ($rs->recordCount() > 0) { + echo "\n"; + foreach ($rs->f as $k => $v) { + $finfo = $rs->fetchField($k); + echo ""; + } - // First, if rows returned, then display the results - if ($rs->recordCount() > 0) { - echo "
", $misc->printVal($finfo->name), "
\n"; + $i = 0; + while (!$rs->EOF) { + $id = (($i % 2) == 0 ? '1' : '2'); + echo "\n"; foreach ($rs->f as $k => $v) { $finfo = $rs->fetchField($k); - echo ""; - } - - $i = 0; - while (!$rs->EOF) { - $id = (($i % 2) == 0 ? '1' : '2'); - echo "\n"; - foreach ($rs->f as $k => $v) { - $finfo = $rs->fetchField($k); - echo ""; - } - echo "\n"; - $rs->moveNext(); - $i++; - } - echo "
", $misc->printVal($finfo->name), "
", $misc->printVal($v, true, $finfo->type), "
\n"; - 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"; + echo "", $misc->printVal($v, true, $finfo->type), ""; + } + echo "\n"; + $rs->moveNext(); + $i++; } - // Else say success - else echo "

{$lang['strsqlexecuted']}

\n"; + echo "\n"; + 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"; } + // Else say success + else echo "

{$lang['strsqlexecuted']}

\n"; } - else echo "

{$lang['strinvalidparam']}

\n"; echo "

{$lang['strback']}"; - if ($conf['show_reports'] && is_object($rs) && $rs->recordCount() > 0) { - echo " | Save As Report"; + "&action=sql\">{$lang['strback']}"; + if ($conf['show_reports'] && isset($rs) && is_object($rs) && $rs->recordCount() > 0) { + echo " | {$lang['strsaveasreport']}"; } echo "

\n"; diff --git a/sqledit.php b/sqledit.php index 442ad660..e732b45d 100644 --- a/sqledit.php +++ b/sqledit.php @@ -3,7 +3,7 @@ /** * Alternative SQL editing window * - * $Id: sqledit.php,v 1.2 2003/08/12 01:57:21 chriskl Exp $ + * $Id: sqledit.php,v 1.3 2003/09/05 04:58:14 chriskl Exp $ */ // Include application functions @@ -14,21 +14,14 @@ $PHP_SELF = $_SERVER['PHP_SELF']; /** - * Allow execution of arbitrary SQL statements on a database + * Private function to display list of databases */ - function doDefault() { - global $PHP_SELF, $data, $localData, $misc; - global $lang, $conf; - - if (!isset($_POST['query'])) $_POST['query'] = ''; - + function _printDatabases() { + global $data, $lang, $conf; + // Get the list of all databases $databases = &$data->getDatabases(); - echo "

{$lang['strsql']}

\n"; - - echo "
\n"; - if ($databases->recordCount() > 0) { echo "

{$lang['strdatabase']}: \n"; - } + } + } + + /** + * Searches for a named database object + */ + function doFind() { + global $PHP_SELF, $data, $misc; + global $lang; + + if (!isset($_GET['term'])) $_GET['term'] = ''; + + $misc->printPopUpNav(); + echo "

{$lang['strfind']}

\n"; + + echo "\n"; + _printDatabases(); + echo "

_maxNameLen}\" />\n"; + echo "\n"; + echo $misc->form; + echo "\n"; + echo "

\n"; + } + + /** + * Allow execution of arbitrary SQL statements on a database + */ + function doDefault() { + global $PHP_SELF, $data, $localData, $misc; + global $lang, $conf; + + if (!isset($_POST['query'])) $_POST['query'] = ''; + + $misc->printPopUpNav(); + echo "

{$lang['strsql']}

\n"; + + echo "
\n"; + _printDatabases(); echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; - $rows = isset($_REQUEST['rows']) ? $_REQUEST['rows'] : 20; + $rows = isset($_REQUEST['rows']) ? $_REQUEST['rows'] : 17; echo "

\n"; echo $misc->form; -// HMMM: Not sure what the back link could do in this situation, any ideas? - -// echo "\n"; -// echo "\n"; echo "
\n"; } @@ -71,6 +97,10 @@ echo "\n"; switch ($action) { + case 'find': + doFind(); + break; + case 'sql': default: doDefault(); break; diff --git a/themes/default/global.css b/themes/default/global.css index cbbdd233..d27d26cf 100644 --- a/themes/default/global.css +++ b/themes/default/global.css @@ -1,7 +1,7 @@ /** * Default style sheet * - * $Id: global.css,v 1.14 2003/08/18 08:07:53 chriskl Exp $ + * $Id: global.css,v 1.15 2003/09/05 04:58:15 chriskl Exp $ */ /** ELEMENTS */ @@ -108,6 +108,11 @@ th.data font-size: smaller; /* 0.9em */ } +th.data a:active, th.data a:link, th.data a:visited, th.data a:hover +{ + font-weight: bold; +} + td.topbar { background-color: #CECF9C; diff --git a/topbar.php b/topbar.php index bad49fe9..6806e22a 100755 --- a/topbar.php +++ b/topbar.php @@ -3,7 +3,7 @@ /** * Top menu for phpPgAdmin * - * $Id: topbar.php,v 1.15 2003/08/04 06:18:10 chriskl Exp $ + * $Id: topbar.php,v 1.16 2003/09/05 04:58:14 chriskl Exp $ */ // Include application functions @@ -39,7 +39,9 @@ | | + onclick="window.open('sqledit.php?action=sql','sqledit','toobar=no,width=700,height=420,resizable=yes,scrollbars=yes').focus(); return false;"> | + | -- 2.39.5