added second optional parameter: $sql_query
This commit is contained in:
@@ -5,6 +5,10 @@ phpMyAdmin - ChangeLog
|
|||||||
$Id$
|
$Id$
|
||||||
$HeadURL$
|
$HeadURL$
|
||||||
|
|
||||||
|
2006-12-19 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
||||||
|
* libarsies/common.lib.php::PMA_showMessage():
|
||||||
|
added second optional parameter: $sql_query
|
||||||
|
|
||||||
2006-12-19 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
2006-12-19 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
||||||
* tbl_change.php, tbl_replace.php, include/tbl_replace_fields.inc.php:
|
* tbl_change.php, tbl_replace.php, include/tbl_replace_fields.inc.php:
|
||||||
refactored: made register_globals independent; added documentation;
|
refactored: made register_globals independent; added documentation;
|
||||||
|
@@ -1214,22 +1214,31 @@ if (typeof(window.parent) != 'undefined'
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a message at the top of the "main" (right) frame
|
* dsiplays the message und the query
|
||||||
*
|
* usally the message is the result of the query executed
|
||||||
* @param string the message to display
|
|
||||||
*
|
*
|
||||||
|
* @param string $message the message to display
|
||||||
|
* @param string $sql_query the query to display
|
||||||
* @global array the configuration array
|
* @global array the configuration array
|
||||||
*
|
* @uses $GLOBALS['cfg']
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function PMA_showMessage($message)
|
function PMA_showMessage($message, $sql_query = null)
|
||||||
{
|
{
|
||||||
global $cfg;
|
global $cfg;
|
||||||
|
|
||||||
// Sanitizes $message
|
if (null === $sql_query) {
|
||||||
$message = PMA_sanitize($message);
|
if (! empty($GLOBALS['display_query'])) {
|
||||||
|
$sql_query = $GLOBALS['display_query'];
|
||||||
|
} elseif ($cfg['SQP']['fmtType'] == 'none' && ! empty($GLOBALS['unparsed_sql'])) {
|
||||||
|
$sql_query = $GLOBALS['unparsed_sql'];
|
||||||
|
} else {
|
||||||
|
$sql_query = $GLOBALS['sql_query'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Corrects the tooltip text via JS if required
|
// Corrects the tooltip text via JS if required
|
||||||
|
// @todo this is REALLY the wrong place to do this - very unexpected here
|
||||||
if ( isset($GLOBALS['table']) && strlen($GLOBALS['table']) && $cfg['ShowTooltip']) {
|
if ( isset($GLOBALS['table']) && strlen($GLOBALS['table']) && $cfg['ShowTooltip']) {
|
||||||
$result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\'');
|
$result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\'');
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@@ -1241,17 +1250,17 @@ if (typeof(window.parent) != 'undefined'
|
|||||||
PMA_DBI_free_result($result);
|
PMA_DBI_free_result($result);
|
||||||
$uni_tbl = PMA_jsFormat($GLOBALS['db'] . '.' . $GLOBALS['table'], false);
|
$uni_tbl = PMA_jsFormat($GLOBALS['db'] . '.' . $GLOBALS['table'], false);
|
||||||
echo "\n";
|
echo "\n";
|
||||||
?>
|
echo '<script type="text/javascript" language="javascript">' . "\n";
|
||||||
<script type="text/javascript" language="javascript">
|
echo '//<![CDATA[' . "\n";
|
||||||
//<![CDATA[
|
echo "window.parent.updateTableTitle('" . $uni_tbl . "', '" . PMA_jsFormat($tooltip, false) . "');" . "\n";
|
||||||
window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFormat($tooltip, false); ?>');
|
echo '//]]>' . "\n";
|
||||||
//]]>
|
echo '</script>' . "\n";
|
||||||
</script>
|
|
||||||
<?php
|
|
||||||
} // end if
|
} // end if
|
||||||
} // end if ... elseif
|
} // end if ... elseif
|
||||||
|
|
||||||
// Checks if the table needs to be repaired after a TRUNCATE query.
|
// Checks if the table needs to be repaired after a TRUNCATE query.
|
||||||
|
// @todo this should only be done if isset($GLOBALS['sql_query']), what about $GLOBALS['display_query']???
|
||||||
|
// @todo this is REALLY the wrong place to do this - very unexpected here
|
||||||
if (isset($GLOBALS['table']) && isset($GLOBALS['sql_query'])
|
if (isset($GLOBALS['table']) && isset($GLOBALS['sql_query'])
|
||||||
&& $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) {
|
&& $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) {
|
||||||
if (!isset($tbl_status)) {
|
if (!isset($tbl_status)) {
|
||||||
@@ -1266,19 +1275,16 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($tbl_status);
|
unset($tbl_status);
|
||||||
?>
|
echo '<br />' . "\n";
|
||||||
<br />
|
|
||||||
<div align="<?php echo $GLOBALS['cell_align_left']; ?>">
|
echo '<div align="' . $GLOBALS['cell_align_left'] . '">' . "\n";
|
||||||
<?php
|
|
||||||
if (!empty($GLOBALS['show_error_header'])) {
|
if (!empty($GLOBALS['show_error_header'])) {
|
||||||
?>
|
echo '<div class="error">' . "\n";
|
||||||
<div class="error">
|
echo '<h1>' . $GLOBALS['strError'] . '</h1>' . "\n";
|
||||||
<h1><?php echo $GLOBALS['strError']; ?></h1>
|
|
||||||
<?php
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<div class="notice">';
|
echo '<div class="notice">';
|
||||||
echo $message;
|
echo PMA_sanitize($message);
|
||||||
if (isset($GLOBALS['special_message'])) {
|
if (isset($GLOBALS['special_message'])) {
|
||||||
echo PMA_sanitize($GLOBALS['special_message']);
|
echo PMA_sanitize($GLOBALS['special_message']);
|
||||||
unset($GLOBALS['special_message']);
|
unset($GLOBALS['special_message']);
|
||||||
@@ -1289,17 +1295,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
|||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cfg['ShowSQL'] == true
|
if ($cfg['ShowSQL'] == true && ! empty($sql_query)) {
|
||||||
&& (!empty($GLOBALS['sql_query']) || !empty($GLOBALS['display_query']))) {
|
|
||||||
if (!empty($GLOBALS['display_query'])) {
|
|
||||||
$local_query = $GLOBALS['display_query'];
|
|
||||||
} else {
|
|
||||||
if ($cfg['SQP']['fmtType'] == 'none' && !empty($GLOBALS['unparsed_sql'])) {
|
|
||||||
$local_query = $GLOBALS['unparsed_sql'];
|
|
||||||
} else {
|
|
||||||
$local_query = $GLOBALS['sql_query'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Basic url query part
|
// Basic url query part
|
||||||
$url_qpart = '?' . PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : '');
|
$url_qpart = '?' . PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : '');
|
||||||
|
|
||||||
@@ -1314,11 +1310,11 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
|||||||
}
|
}
|
||||||
if (isset($new_line)) {
|
if (isset($new_line)) {
|
||||||
/* SQL-Parser-Analyzer */
|
/* SQL-Parser-Analyzer */
|
||||||
$query_base = PMA_sqlAddslashes(htmlspecialchars($local_query), false, false, true);
|
$query_base = PMA_sqlAddslashes(htmlspecialchars($sql_query), false, false, true);
|
||||||
/* SQL-Parser-Analyzer */
|
/* SQL-Parser-Analyzer */
|
||||||
$query_base = preg_replace("@((\015\012)|(\015)|(\012))+@", $new_line, $query_base);
|
$query_base = preg_replace("@((\015\012)|(\015)|(\012))+@", $new_line, $query_base);
|
||||||
} else {
|
} else {
|
||||||
$query_base = $local_query;
|
$query_base = $sql_query;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse SQL if needed
|
// Parse SQL if needed
|
||||||
@@ -1339,7 +1335,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
|||||||
|
|
||||||
// Here we append the LIMIT added for navigation, to
|
// Here we append the LIMIT added for navigation, to
|
||||||
// enable its display. Adding it higher in the code
|
// enable its display. Adding it higher in the code
|
||||||
// to $local_query would create a problem when
|
// to $sql_query would create a problem when
|
||||||
// using the Refresh or Edit links.
|
// using the Refresh or Edit links.
|
||||||
|
|
||||||
// Only append it on SELECTs.
|
// Only append it on SELECTs.
|
||||||
@@ -1385,14 +1381,14 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
|||||||
&& (!empty($edit_target))) {
|
&& (!empty($edit_target))) {
|
||||||
|
|
||||||
if ($cfg['EditInWindow'] == true) {
|
if ($cfg['EditInWindow'] == true) {
|
||||||
$onclick = 'window.parent.focus_querywindow(\'' . PMA_jsFormat($local_query, false) . '\'); return false;';
|
$onclick = 'window.parent.focus_querywindow(\'' . PMA_jsFormat($sql_query, false) . '\'); return false;';
|
||||||
} else {
|
} else {
|
||||||
$onclick = '';
|
$onclick = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$edit_link = $edit_target
|
$edit_link = $edit_target
|
||||||
. $url_qpart
|
. $url_qpart
|
||||||
. '&sql_query=' . urlencode($local_query)
|
. '&sql_query=' . urlencode($sql_query)
|
||||||
. '&show_query=1#querybox';
|
. '&show_query=1#querybox';
|
||||||
$edit_link = ' [' . PMA_linkOrButton($edit_link, $GLOBALS['strEdit'], array('onclick' => $onclick)) . ']';
|
$edit_link = ' [' . PMA_linkOrButton($edit_link, $GLOBALS['strEdit'], array('onclick' => $onclick)) . ']';
|
||||||
} else {
|
} else {
|
||||||
@@ -1418,11 +1414,11 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
|||||||
. $explain_link_validate
|
. $explain_link_validate
|
||||||
. '&sql_query=';
|
. '&sql_query=';
|
||||||
|
|
||||||
if (preg_match('@^SELECT[[:space:]]+@i', $local_query)) {
|
if (preg_match('@^SELECT[[:space:]]+@i', $sql_query)) {
|
||||||
$explain_link .= urlencode('EXPLAIN ' . $local_query);
|
$explain_link .= urlencode('EXPLAIN ' . $sql_query);
|
||||||
$message = $GLOBALS['strExplain'];
|
$message = $GLOBALS['strExplain'];
|
||||||
} elseif (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $local_query)) {
|
} elseif (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $sql_query)) {
|
||||||
$explain_link .= urlencode(substr($local_query, 8));
|
$explain_link .= urlencode(substr($sql_query, 8));
|
||||||
$message = $GLOBALS['strNoExplain'];
|
$message = $GLOBALS['strNoExplain'];
|
||||||
} else {
|
} else {
|
||||||
$explain_link = '';
|
$explain_link = '';
|
||||||
@@ -1441,7 +1437,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
|||||||
$php_link = 'import.php'
|
$php_link = 'import.php'
|
||||||
. $url_qpart
|
. $url_qpart
|
||||||
. '&show_query=1'
|
. '&show_query=1'
|
||||||
. '&sql_query=' . urlencode($local_query)
|
. '&sql_query=' . urlencode($sql_query)
|
||||||
. '&show_as_php=';
|
. '&show_as_php=';
|
||||||
|
|
||||||
if (!empty($GLOBALS['show_as_php'])) {
|
if (!empty($GLOBALS['show_as_php'])) {
|
||||||
@@ -1458,7 +1454,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
|||||||
= 'import.php'
|
= 'import.php'
|
||||||
. $url_qpart
|
. $url_qpart
|
||||||
. '&show_query=1'
|
. '&show_query=1'
|
||||||
. '&sql_query=' . urlencode($local_query);
|
. '&sql_query=' . urlencode($sql_query);
|
||||||
$php_link .= ' [' . PMA_linkOrButton($runquery_link, $GLOBALS['strRunQuery']) . ']';
|
$php_link .= ' [' . PMA_linkOrButton($runquery_link, $GLOBALS['strRunQuery']) . ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1469,13 +1465,13 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
|||||||
// Refresh query
|
// Refresh query
|
||||||
if (isset($cfg['SQLQuery']['Refresh'])
|
if (isset($cfg['SQLQuery']['Refresh'])
|
||||||
&& $cfg['SQLQuery']['Refresh']
|
&& $cfg['SQLQuery']['Refresh']
|
||||||
&& preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $local_query)) {
|
&& preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $sql_query)) {
|
||||||
|
|
||||||
$refresh_link = 'import.php'
|
$refresh_link = 'import.php'
|
||||||
. $url_qpart
|
. $url_qpart
|
||||||
. '&show_query=1'
|
. '&show_query=1'
|
||||||
. (isset($_GET['pos']) ? '&pos=' . $_GET['pos'] : '')
|
. (isset($_GET['pos']) ? '&pos=' . $_GET['pos'] : '')
|
||||||
. '&sql_query=' . urlencode($local_query);
|
. '&sql_query=' . urlencode($sql_query);
|
||||||
$refresh_link = ' [' . PMA_linkOrButton($refresh_link, $GLOBALS['strRefresh']) . ']';
|
$refresh_link = ' [' . PMA_linkOrButton($refresh_link, $GLOBALS['strRefresh']) . ']';
|
||||||
} else {
|
} else {
|
||||||
$refresh_link = '';
|
$refresh_link = '';
|
||||||
@@ -1488,7 +1484,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
|||||||
$validate_link = 'import.php'
|
$validate_link = 'import.php'
|
||||||
. $url_qpart
|
. $url_qpart
|
||||||
. '&show_query=1'
|
. '&show_query=1'
|
||||||
. '&sql_query=' . urlencode($local_query)
|
. '&sql_query=' . urlencode($sql_query)
|
||||||
. '&validatequery=';
|
. '&validatequery=';
|
||||||
if (!empty($GLOBALS['validatequery'])) {
|
if (!empty($GLOBALS['validatequery'])) {
|
||||||
$validate_link .= '0';
|
$validate_link .= '0';
|
||||||
@@ -1501,7 +1497,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
|||||||
} else {
|
} else {
|
||||||
$validate_link = '';
|
$validate_link = '';
|
||||||
} //validator
|
} //validator
|
||||||
unset($local_query);
|
unset($sql_query);
|
||||||
|
|
||||||
// Displays the message
|
// Displays the message
|
||||||
echo '<fieldset class="">' . "\n";
|
echo '<fieldset class="">' . "\n";
|
||||||
@@ -1520,9 +1516,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
|||||||
echo '</fieldset>';
|
echo '</fieldset>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
echo '</div><br />' . "\n";
|
||||||
</div><br />
|
|
||||||
<?php
|
|
||||||
} // end of the 'PMA_showMessage()' function
|
} // end of the 'PMA_showMessage()' function
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user