enabled Syntaxcoloring for SQL Statements. This can be turned off in config.inc.php3
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
ChangeLog_till_2.2.6.tar.gz
|
ChangeLog_till_2.2.6.tar.gz
|
||||||
config.inc.developer.php3
|
config.inc.developer.php3
|
||||||
|
phpmyadmin.wpj
|
@@ -226,6 +226,14 @@ $cfg['ModifyDeleteAtRight'] = FALSE; // show edit/delete links on right s
|
|||||||
$cfg['DefaultDisplay'] = 'horizontal'; // default display direction (horizontal|vertical)
|
$cfg['DefaultDisplay'] = 'horizontal'; // default display direction (horizontal|vertical)
|
||||||
$cfg['RepeatCells'] = 100; // repeat header names every X cells? (0 = deactivate)
|
$cfg['RepeatCells'] = 100; // repeat header names every X cells? (0 = deactivate)
|
||||||
|
|
||||||
|
$cfg['UseSyntaxColoring'] = TRUE; // use syntaxcoloring on output of SQL, might be a little slower
|
||||||
|
// Colors used for Syntaxcoloring of SQL Statements
|
||||||
|
$cfg['colorFunctions'] = 'red';
|
||||||
|
$cfg['colorKeywords'] = 'blue';
|
||||||
|
$cfg['colorStrings'] = 'green';
|
||||||
|
$cfg['colorColType'] = '#FF9900';
|
||||||
|
$cfg['colorAdd'] = '#9999CC';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MySQL settings
|
* MySQL settings
|
||||||
@@ -294,11 +302,62 @@ if ($cfg['ShowFunctionFields']) {
|
|||||||
'TO_DAYS',
|
'TO_DAYS',
|
||||||
'UNIX_TIMESTAMP',
|
'UNIX_TIMESTAMP',
|
||||||
'USER',
|
'USER',
|
||||||
'WEEKDAY'
|
'WEEKDAY',
|
||||||
|
'CONCAT'
|
||||||
);
|
);
|
||||||
} // end if
|
} // end if
|
||||||
|
|
||||||
|
if($cfg['UseSyntaxColoring']) {
|
||||||
|
$cfg['keywords']=array(
|
||||||
|
'SELECT',
|
||||||
|
'INSERT',
|
||||||
|
'LEFT',
|
||||||
|
'UPDATE',
|
||||||
|
'REPLACE',
|
||||||
|
'EXPLAIN',
|
||||||
|
'FROM',
|
||||||
|
'WHERE',
|
||||||
|
'LIMIT',
|
||||||
|
'INTO',
|
||||||
|
'ALTER',
|
||||||
|
'ADD',
|
||||||
|
'DROP',
|
||||||
|
'GROUP',
|
||||||
|
'ORDER',
|
||||||
|
'CHANGE',
|
||||||
|
'CREATE',
|
||||||
|
'DELETE'
|
||||||
|
);
|
||||||
|
} // end if
|
||||||
|
if($cfg['UseSyntaxColoring']) {
|
||||||
|
$cfg['additional']=array(
|
||||||
|
'TABLE',
|
||||||
|
'DEFAULT',
|
||||||
|
'NULL',
|
||||||
|
'NOT',
|
||||||
|
'INDEX',
|
||||||
|
'PRIMARY',
|
||||||
|
'KEY',
|
||||||
|
'UNIQUE',
|
||||||
|
'BINARY',
|
||||||
|
'UNSIGNED',
|
||||||
|
'ZEROFILL',
|
||||||
|
'AUTO_INCREMENT',
|
||||||
|
'AND',
|
||||||
|
'OR',
|
||||||
|
'DISTINCT',
|
||||||
|
'DISTINCTROW',
|
||||||
|
'BY',
|
||||||
|
'ON',
|
||||||
|
'JOIN',
|
||||||
|
'BETWEEN',
|
||||||
|
'BETWEEN',
|
||||||
|
'IN',
|
||||||
|
'IF',
|
||||||
|
'ELSE',
|
||||||
|
'SET'
|
||||||
|
);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Unset magic_quotes_runtime - do not change!
|
* Unset magic_quotes_runtime - do not change!
|
||||||
*/
|
*/
|
||||||
|
@@ -34,6 +34,8 @@ if (!defined('PMA_COMMON_LIB_INCLUDED')){
|
|||||||
* the PMA_mysqlDie() function must be before the connection to db but after
|
* the PMA_mysqlDie() function must be before the connection to db but after
|
||||||
* mysql extension has been loaded
|
* mysql extension has been loaded
|
||||||
*
|
*
|
||||||
|
* the PMA_mysqlDie() function needs the PMA_format_sql() Function
|
||||||
|
*
|
||||||
* ... so the required order is:
|
* ... so the required order is:
|
||||||
*
|
*
|
||||||
* - parsing of the configuration file
|
* - parsing of the configuration file
|
||||||
@@ -41,6 +43,7 @@ if (!defined('PMA_COMMON_LIB_INCLUDED')){
|
|||||||
* MySQL release number)
|
* MySQL release number)
|
||||||
* - load of mysql extension (if necessary)
|
* - load of mysql extension (if necessary)
|
||||||
* - definition of PMA_sqlAddslashes()
|
* - definition of PMA_sqlAddslashes()
|
||||||
|
* - definition of PMA_format_sql()
|
||||||
* - definition of PMA_mysqlDie()
|
* - definition of PMA_mysqlDie()
|
||||||
* - definition of PMA_isInto()
|
* - definition of PMA_isInto()
|
||||||
* - definition of PMA_setFontSizes()
|
* - definition of PMA_setFontSizes()
|
||||||
@@ -189,6 +192,84 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
|||||||
return $a_string;
|
return $a_string;
|
||||||
} // end of the 'PMA_sqlAddslashes()' function
|
} // end of the 'PMA_sqlAddslashes()' function
|
||||||
|
|
||||||
|
/**
|
||||||
|
* format sql strings
|
||||||
|
*
|
||||||
|
* @param string sql
|
||||||
|
*
|
||||||
|
* @return string the formatted sql
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*
|
||||||
|
* @author Mike Beck<mikebeck@users.sourceforge.net>
|
||||||
|
*/
|
||||||
|
function PMA_format_sql ($sql) {
|
||||||
|
global $cfg;
|
||||||
|
|
||||||
|
$_sfuncs = '^' . implode('$|^', $cfg['Functions']) . '$';
|
||||||
|
$_skeyw = '^' . implode('$|^', $cfg['keywords']) . '$';
|
||||||
|
$_scoltype = '^' . implode('$|^', $cfg['ColumnTypes']) . '$';
|
||||||
|
$_add = '^' . implode('$|^', $cfg['additional']) . '$';
|
||||||
|
// first of all lets remove all newlines - we'll add our own later
|
||||||
|
|
||||||
|
$sql = str_replace("\n", ' ', $sql);
|
||||||
|
// there should always be blanks around = and after , ()
|
||||||
|
$sql = str_replace('=', ' = ', $sql);
|
||||||
|
$sql = str_replace(',', ', ', $sql);
|
||||||
|
$sql = str_replace(')', ' ) ', $sql);
|
||||||
|
$sql = str_replace('(', ' ( ', $sql);
|
||||||
|
// now split everything by the blanks
|
||||||
|
$_sql_parts=explode(' ',$sql);
|
||||||
|
// start a loop over the parts check each word and put them back into $sql
|
||||||
|
$sql = '';
|
||||||
|
while (list($_num,$_word) = each($_sql_parts)) {
|
||||||
|
// we might have added to many blanks when checking for = and ,
|
||||||
|
// which might lead to empty members in the array
|
||||||
|
if(strlen($_word)==0){continue;}
|
||||||
|
// Anything inside quots might be more than one word
|
||||||
|
// so as we splitted by the blanks we have to try to get those parts back
|
||||||
|
// together
|
||||||
|
if (substr($_word, 0, 1) == '\'' || substr($_word, 0, 1) == '"') {
|
||||||
|
// start of a string
|
||||||
|
$_temp = $_word;
|
||||||
|
} else {
|
||||||
|
if(isset($_temp) && strlen($_temp)>0){
|
||||||
|
// we are continuing a string
|
||||||
|
$_temp .= $_word;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(substr($_word, strlen($_word)-1, 1) == '\''
|
||||||
|
|| substr($_word, strlen($_word)-1, 1) == '"') {
|
||||||
|
// End of a String
|
||||||
|
$_word = '<font color="' . $cfg['colorStrings'] . '">' . $_temp . '</font>';
|
||||||
|
$_temp = '';
|
||||||
|
} else {
|
||||||
|
// no String
|
||||||
|
if(eregi($_sfuncs, $_word)) {
|
||||||
|
$_word = '<font color="' . $cfg['colorFunctions'].'">' . $_word . '</font>';
|
||||||
|
} else {
|
||||||
|
if(eregi($_skeyw, $_word)) {
|
||||||
|
$_word = "\n".'<font color="' . $cfg['colorKeywords'].'">' . $_word . '</font>';
|
||||||
|
} else {
|
||||||
|
if(eregi($_scoltype, $_word)) {
|
||||||
|
$_word = '<font color="' . $cfg['colorColType'].'">' . $_word . '</font>';
|
||||||
|
} else {
|
||||||
|
if(eregi($_add, $_word)) {
|
||||||
|
$_word = '<font color="' . $cfg['colorAdd'].'">' . $_word . '</font>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!isset($_temp) || strlen($_temp) == 0) {
|
||||||
|
if($_num != 0 && $_word != '(') {
|
||||||
|
$sql .= ' ';
|
||||||
|
}
|
||||||
|
$sql .= $_word;
|
||||||
|
}
|
||||||
|
} // End while
|
||||||
|
return $sql;
|
||||||
|
} // End of PMA_format_sql function
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a MySQL error message in the right frame.
|
* Displays a MySQL error message in the right frame.
|
||||||
@@ -203,7 +284,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
|||||||
function PMA_mysqlDie($error_message = '', $the_query = '',
|
function PMA_mysqlDie($error_message = '', $the_query = '',
|
||||||
$is_modify_link = TRUE, $back_url = '')
|
$is_modify_link = TRUE, $back_url = '')
|
||||||
{
|
{
|
||||||
|
global $cfg;
|
||||||
if (empty($GLOBALS['is_header_sent'])) {
|
if (empty($GLOBALS['is_header_sent'])) {
|
||||||
// rabus: If we include header.inc.php3 here, we get a huge set of
|
// rabus: If we include header.inc.php3 here, we get a huge set of
|
||||||
// "Undefined variable" errors (see bug #549570)!
|
// "Undefined variable" errors (see bug #549570)!
|
||||||
@@ -231,7 +312,11 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
|||||||
. '<a href="db_details.php3?lang=' . $GLOBALS['lang'] . '&server=' . urlencode($GLOBALS['server']) . '&db=' . urlencode($GLOBALS['db']) . '&sql_query=' . urlencode($the_query) . '&show_query=y">' . $GLOBALS['strEdit'] . '</a>'
|
. '<a href="db_details.php3?lang=' . $GLOBALS['lang'] . '&server=' . urlencode($GLOBALS['server']) . '&db=' . urlencode($GLOBALS['db']) . '&sql_query=' . urlencode($the_query) . '&show_query=y">' . $GLOBALS['strEdit'] . '</a>'
|
||||||
. ']' . "\n";
|
. ']' . "\n";
|
||||||
} // end if
|
} // end if
|
||||||
echo '<pre>' . "\n" . $query_base . "\n" . '</pre>' . "\n";
|
if($cfg['UseSyntaxColoring']){
|
||||||
|
echo '<pre>' . "\n" . PMA_format_sql($query_base) . "\n" . '</pre>' . "\n";
|
||||||
|
} else {
|
||||||
|
echo '<pre>' . "\n" . $query_base . "\n" . '</pre>' . "\n";
|
||||||
|
}
|
||||||
echo '</p>' . "\n";
|
echo '</p>' . "\n";
|
||||||
} // end if
|
} // end if
|
||||||
if (!empty($error_message)) {
|
if (!empty($error_message)) {
|
||||||
@@ -902,6 +987,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
|||||||
*/
|
*/
|
||||||
function PMA_showMessage($message)
|
function PMA_showMessage($message)
|
||||||
{
|
{
|
||||||
|
global $cfg;
|
||||||
// Reloads the navigation frame via JavaScript if required
|
// Reloads the navigation frame via JavaScript if required
|
||||||
if (isset($GLOBALS['reload']) && $GLOBALS['reload']) {
|
if (isset($GLOBALS['reload']) && $GLOBALS['reload']) {
|
||||||
echo "\n";
|
echo "\n";
|
||||||
@@ -975,13 +1061,17 @@ if (typeof(document.getElementById) != 'undefined'
|
|||||||
$sqlnr = 1;
|
$sqlnr = 1;
|
||||||
if (!empty($GLOBALS['show_as_php'])) {
|
if (!empty($GLOBALS['show_as_php'])) {
|
||||||
$new_line = '";<br />' . "\n" . ' $sql .= "';
|
$new_line = '";<br />' . "\n" . ' $sql .= "';
|
||||||
} else {
|
}else{
|
||||||
$new_line = '<br />' . "\n" . ' ';
|
$new_line = "\n";
|
||||||
}
|
}
|
||||||
$query_base = htmlspecialchars($GLOBALS['sql_query']);
|
$query_base = htmlspecialchars($GLOBALS['sql_query']);
|
||||||
$query_base = ereg_replace("((\015\012)|(\015)|(\012))+", $new_line, $query_base);
|
$query_base = ereg_replace("((\015\012)|(\015)|(\012))+", $new_line, $query_base);
|
||||||
if (!empty($GLOBALS['show_as_php'])) {
|
if (!empty($GLOBALS['show_as_php'])) {
|
||||||
$query_base = '$sql = "' . $query_base;
|
$query_base = '$sql = "' . $query_base;
|
||||||
|
} else {
|
||||||
|
if($cfg['UseSyntaxColoring']) {
|
||||||
|
$query_base = PMA_format_sql($query_base);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepares links that may be displayed to edit/explain the query
|
// Prepares links that may be displayed to edit/explain the query
|
||||||
|
@@ -353,7 +353,7 @@ if ($sql_query != '') {
|
|||||||
$a_sql_query = $pieces[$i];
|
$a_sql_query = $pieces[$i];
|
||||||
$result = mysql_query($a_sql_query);
|
$result = mysql_query($a_sql_query);
|
||||||
if ($result == FALSE) { // readdump failed
|
if ($result == FALSE) { // readdump failed
|
||||||
$my_die = $a_sql_query;
|
$my_die = PMA_format_sql($a_sql_query);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!isset($reload) && eregi('^(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)', $a_sql_query)) {
|
if (!isset($reload) && eregi('^(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)', $a_sql_query)) {
|
||||||
|
2
sql.php3
2
sql.php3
@@ -508,7 +508,7 @@ else {
|
|||||||
|
|
||||||
// Do print the page if required
|
// Do print the page if required
|
||||||
if (isset($printview) && $printview == '1') {
|
if (isset($printview) && $printview == '1') {
|
||||||
echo "\n";
|
echo "\n";
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" language="javascript1.2">
|
<script type="text/javascript" language="javascript1.2">
|
||||||
<!--
|
<!--
|
||||||
|
Reference in New Issue
Block a user