From 071a0684421f1e3bf2ba6f3b025be1990834948d Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Tue, 18 Oct 2005 08:51:35 +0000 Subject: [PATCH] wrong handling of linebreaks in query: bug #1243888 --- ChangeLog | 3 + querywindow.php | 223 ++++++++++++++++++++++++++++-------------------- 2 files changed, 134 insertions(+), 92 deletions(-) diff --git a/ChangeLog b/ChangeLog index f7354da74..33ab145dd 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ phpMyAdmin - Changelog $Id$ $Source$ +2005-10-18 Sebastian Mendel + * querywindow.php: wrong handling of linebreaks in query: bug #1243888 + 2005-10-17 Michal Čihař * lang/czech: Translation fixes. * libraries/common.lib.php: Group databases by rightmost separator (bug diff --git a/querywindow.php b/querywindow.php index 09961ed1c..0585856af 100644 --- a/querywindow.php +++ b/querywindow.php @@ -19,16 +19,21 @@ if (!empty($db)) { require_once('./libraries/common.lib.php'); require_once './libraries/sql_query_form.lib.php'; require_once('./libraries/ob.lib.php'); -if ($cfg['OBGzip']) { +if ( $GLOBALS['cfg']['OBGzip'] ) { $ob_mode = PMA_outBufferModeGet(); - if ($ob_mode) { - PMA_outBufferPre($ob_mode); + if ( $ob_mode ) { + PMA_outBufferPre( $ob_mode ); } } require_once('./libraries/relation.lib.php'); $cfgRelation = PMA_getRelationsParam(); + +// initilize some variables +$_sql_history = array(); +$_input_query_history = array(); + /** * Get the list and number of available databases. * Skipped if no server selected: in this case no database should be displayed @@ -47,7 +52,6 @@ if ($server > 0) { require_once('./libraries/header_http.inc.php'); require_once('./libraries/header_meta_style.inc.php'); ?> - - bgcolor=""> + + bgcolor="">
'; - if ($propicon == 'both') { - $iconic_spacer = '
'; - } else { - $iconic_spacer = ''; - } - - $titles['Change'] = $iconic_spacer . '' . $strChange . ''; - - if ($propicon == 'both') { - $titles['Change'] .= ' ' . $strChange . ' 
'; + if ( 'both' === $GLOBALS['cfg']['PropertiesIconic'] ) { + $titles['Change'] .= $strChange; } } else { - $titles['Change'] = $strChange; + $titles['Change'] = $strChange; } // Hidden forms and query frame interaction stuff -if ( $cfg['QueryFrame'] && $cfg['QueryFrameJS'] ) { - - $input_query_history = array(); - $sql_history = array(); - $dup_sql = array(); +if ( $GLOBALS['cfg']['QueryFrame'] && $GLOBALS['cfg']['QueryFrameJS'] ) { if ( ! empty( $query_history_latest ) && ! empty( $query_history_latest_db ) ) { - if ( $cfg['QueryHistoryDB'] && $cfgRelation['historywork'] ) { - PMA_setHistory((isset($query_history_latest_db) ? $query_history_latest_db : ''), (isset($query_history_latest_table) ? $query_history_latest_table : ''), $cfg['Server']['user'], $query_history_latest); + if ( $GLOBALS['cfg']['QueryHistoryDB'] && $cfgRelation['historywork'] ) { + PMA_setHistory((isset($query_history_latest_db) ? $query_history_latest_db : ''), + (isset($query_history_latest_table) ? $query_history_latest_table : ''), + $GLOBALS['cfg']['Server']['user'], + $query_history_latest ); } - $input_query_history[] = ''; - $input_query_history[] = ''; - $input_query_history[] = ''; - - $sql_history[] = - '
  • ' - .'' . $titles['Change'] . '' - .' [' . htmlspecialchars($query_history_latest_db) . '] ' . urldecode($query_history_latest) . '' - .'
  • ' . "\n"; - + $_input_query_history[$query_history_latest] = array( + 'db' => $query_history_latest_db, + 'table' => isset($query_history_latest_table) ? $query_history_latest_table : '', + ); + + $_sql_history[$query_history_latest] = array( + 'db' => $query_history_latest_db, + 'table' => isset( $query_history_latest_table ) ? $query_history_latest_table : '', + ); + $sql_query = urldecode($query_history_latest); $db = $query_history_latest_db; $table = $query_history_latest_table; - $dup_sql[$query_history_latest] = true; } elseif ( ! empty( $query_history_latest ) ) { $sql_query = urldecode($query_history_latest); } @@ -213,17 +195,16 @@ if ( $cfg['QueryFrame'] && $cfg['QueryFrameJS'] ) { $show_query = 1; } - if ($cfg['QueryHistoryDB'] && $cfgRelation['historywork']) { + if ( $GLOBALS['cfg']['QueryHistoryDB'] && $cfgRelation['historywork'] ) { - $temp_history = PMA_getHistory($cfg['Server']['user']); + $temp_history = PMA_getHistory( $GLOBALS['cfg']['Server']['user'] ); if (is_array($temp_history) && count($temp_history) > 0) { foreach ($temp_history AS $history_nr => $history_array) { - if (!isset($dup_sql[$history_array['sqlquery']])) { - $sql_history[] = '
  • ' - . '' . $titles['Change'] . '' - . '[' . htmlspecialchars($history_array['db']) . '] ' . urldecode($history_array['sqlquery']) . '' - . '
  • ' . "\n"; - $dup_sql[$history_array['sqlquery']] = true; + if ( ! isset( $_sql_history[$history_array['sqlquery']] ) ) { + $_sql_history[$history_array['sqlquery']] = array( + 'db' => $history_array['db'], + 'table' => isset( $history_array['table'] ) ? $history_array['table'] : '', + ); } } } @@ -233,17 +214,15 @@ if ( $cfg['QueryFrame'] && $cfg['QueryFrameJS'] ) { if (isset($query_history) && is_array($query_history)) { $current_index = count($query_history); foreach ($query_history AS $query_no => $query_sql) { - if (!isset($dup_sql[$query_sql])) { - - $input_query_history[] = ''; - $input_query_history[] = ''; - $input_query_history[] = ''; - - $sql_history[] = '
  • ' - . '' . $titles['Change'] . '' - . '[' . htmlspecialchars($query_history_db[$query_no]) . '] ' . urldecode($query_sql) . '' - . '
  • ' . "\n"; - $dup_sql[$query_sql] = true; + if ( ! isset( $_input_query_history[$query_sql] ) ) { + $_input_query_history[$query_sql] = array( + 'db' => $query_history_db, + 'table' => isset($query_history_table) ? $query_history_table : '', + ); + $_sql_history[$query_sql] = array( + 'db' => $query_history_db[$query_no], + 'table' => isset( $query_history_table[$query_no] ) ? $query_history_table[$query_no] : '', + ); } // end if check if this item exists } // end while print history } // end if history exists @@ -287,28 +266,89 @@ unset( $sql_query ); PMA_sqlQueryForm( $query_to_display, $querydisplay_tab ); // Hidden forms and query frame interaction stuff -if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) { +if ( $GLOBALS['cfg']['QueryFrame'] && $GLOBALS['cfg']['QueryFrameJS'] ) { if (isset($auto_commit) && $auto_commit == 'true') { ?> 0) { + if ( count( $_sql_history ) > 0 + && ( $querydisplay_tab == 'history' || $querydisplay_tab == 'full' ) ) { + $tab = isset($querydisplay_tab) && $querydisplay_tab != 'full' ? 'sql' : 'full'; + echo $strQuerySQLHistory . ':
    ' . "\n" + .'' . "\n"; + } ?> -
      ' . implode('', $sql_history) . '
    '; ?> -
    - 0) { - echo implode("\n", $input_query_history); + $history ) { + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; } -?> + unset( $_input_query_history, $sql, $history ); + ?> @@ -321,7 +361,7 @@ if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
    -
    @@ -344,8 +384,7 @@ if (isset($userlink) && $userlink) { /** * Sends bufferized data */ -if (isset($cfg['OBGzip']) && $cfg['OBGzip'] - && isset($ob_mode) && $ob_mode) { +if ( $GLOBALS['cfg']['OBGzip'] && isset( $ob_mode ) && $ob_mode ) { PMA_outBufferPost($ob_mode); } ?>