for Loic
This commit is contained in:
@@ -5,6 +5,11 @@ phpMyAdmin - Changelog
|
||||
$Id$
|
||||
$Source$
|
||||
|
||||
2002-07-25 Lo<4C>c Chapeaux <lolo@phpheaven.net>
|
||||
* coding standard: common.lib.php3, config.inc.php3, Documentation.html,
|
||||
header.inc.php3, sqlparser.data.php3, sqlparser.lib.php3,
|
||||
string.lib.php3, translators.html
|
||||
|
||||
2002-07-24 Marc Delisle <lem9@users.sourceforge.net>
|
||||
* new lang: slovenian, thanks to Kositer Uros (urosh)
|
||||
|
||||
|
@@ -47,7 +47,8 @@ $cfg['PmaAbsoluteUri_DisableWarning'] = FALSE;
|
||||
* Disable the default warning that is displayed on the DB Details Structure page if
|
||||
* any of the required Tables for the relationfeatures could not be found
|
||||
*/
|
||||
$cfg['PmaNoRelation_DisableWarning'] = FALSE;
|
||||
$cfg['PmaNoRelation_DisableWarning'] = FALSE;
|
||||
|
||||
|
||||
/**
|
||||
* Server(s) configuration
|
||||
@@ -283,6 +284,7 @@ $cfg['ModifyDeleteAtRight'] = FALSE; // show edit/delete links on right s
|
||||
$cfg['DefaultDisplay'] = 'horizontal'; // default display direction (horizontal|vertical)
|
||||
$cfg['RepeatCells'] = 100; // repeat header names every X cells? (0 = deactivate)
|
||||
|
||||
|
||||
/**
|
||||
* SQL Parser Settings
|
||||
*/
|
||||
@@ -308,7 +310,8 @@ $cfg['SQP']['fmtColor'] = array( // Syntax colouring data
|
||||
'quote_double' => 'inherit',
|
||||
'quote_single' => 'inherit',
|
||||
'quote_backtick' => 'inherit'
|
||||
);
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Available charsets for MySQL conversion. currently contains all which could
|
||||
@@ -422,6 +425,7 @@ if ($cfg['ShowFunctionFields']) {
|
||||
);
|
||||
} // end if
|
||||
|
||||
|
||||
/**
|
||||
* Unset magic_quotes_runtime - do not change!
|
||||
*/
|
||||
|
@@ -94,7 +94,7 @@ a.h1:visited {font-family: <?php echo $right_font_family; ?>; font-size: <?ph
|
||||
a.h1:hover {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo $font_bigger; ?>; font-weight: bold; color: #FF0000}
|
||||
a.drop:link {font-family: <?php echo $right_font_family; ?>; color: #ff0000}
|
||||
a.drop:visited {font-family: <?php echo $right_font_family; ?>; color: #ff0000}
|
||||
a.drop:hover {font-family: <?php echo $right_font_family; ?>; color: #ffffff; background-color:#ff0000; text-decoration:none}
|
||||
a.drop:hover {font-family: <?php echo $right_font_family; ?>; color: #ffffff; background-color:#ff0000; text-decoration: none}
|
||||
.nav {font-family: <?php echo $right_font_family; ?>; color: #000000}
|
||||
.warning {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo $font_size; ?>; font-weight: bold; color: #FF0000}
|
||||
td.topline {font-size: 1px}
|
||||
@@ -113,24 +113,24 @@ table.tabs {
|
||||
border-bottom: 1px solid #666;
|
||||
}
|
||||
|
||||
.syntax { font-family: sans-serif; font-size: small; }
|
||||
.syntax_comment { }
|
||||
.syntax_digit { }
|
||||
.syntax_digit_hex { }
|
||||
.syntax_digit_integer { }
|
||||
.syntax_digit_float { }
|
||||
.syntax_punct { }
|
||||
.syntax_alpha { text-transform: lowercase; }
|
||||
.syntax_alpha_columnType { text-transform: uppercase; }
|
||||
.syntax_alpha_columnAttrib { text-transform: uppercase; }
|
||||
.syntax_alpha_reservedWord { text-transform: uppercase; font-weight: bold; }
|
||||
.syntax_alpha_functionName { text-transform: uppercase; }
|
||||
.syntax_alpha_identifier { }
|
||||
.syntax_alpha_variable { }
|
||||
.syntax_quote { }
|
||||
.syntax_quote_backtick { }
|
||||
.syntax {font-family: sans-serif; font-size: <?php echo $font_smaller; ?>;}
|
||||
.syntax_comment {}
|
||||
.syntax_digit {}
|
||||
.syntax_digit_hex {}
|
||||
.syntax_digit_integer {}
|
||||
.syntax_digit_float {}
|
||||
.syntax_punct {}
|
||||
.syntax_alpha {text-transform: lowercase;}
|
||||
.syntax_alpha_columnType {text-transform: uppercase;}
|
||||
.syntax_alpha_columnAttrib {text-transform: uppercase;}
|
||||
.syntax_alpha_reservedWord {text-transform: uppercase; font-weight: bold;}
|
||||
.syntax_alpha_functionName {text-transform: uppercase;}
|
||||
.syntax_alpha_identifier {}
|
||||
.syntax_alpha_variable {}
|
||||
.syntax_quote {}
|
||||
.syntax_quote_backtick {}
|
||||
<?php
|
||||
echo PMA_SQP_BuildCssData();
|
||||
echo PMA_SQP_buildCssData();
|
||||
?>
|
||||
//-->
|
||||
</style>
|
||||
|
@@ -240,7 +240,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
||||
/**
|
||||
* format sql strings
|
||||
*
|
||||
* @param struct pre-parsed SQL structure
|
||||
* @param mixed pre-parsed SQL structure
|
||||
*
|
||||
* @return string the formatted sql
|
||||
*
|
||||
@@ -251,37 +251,36 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
||||
*
|
||||
* @author Robin Johnson <robbat2@users.sourceforge.net>
|
||||
*/
|
||||
function PMA_format_sql ($ParsedSQL)
|
||||
function PMA_formatSql($parsed_sql)
|
||||
{
|
||||
global $cfg;
|
||||
|
||||
// Check that we actually have a valid set of parsed data
|
||||
// well, not quite
|
||||
if(!is_array($ParsedSQL)) {
|
||||
// We don,t so just return the input directly
|
||||
if (!is_array($parsed_sql)) {
|
||||
// We don't so just return the input directly
|
||||
// This is intended to be used for when the SQL Parser is turned off
|
||||
return $ParsedSQL;
|
||||
return $parsed_sql;
|
||||
}
|
||||
|
||||
$formattedSQL = '';
|
||||
$formatted_sql = '';
|
||||
|
||||
switch($cfg['SQP']['fmtType']) {
|
||||
switch ($cfg['SQP']['fmtType']) {
|
||||
case 'none':
|
||||
$formattedSQL = PMA_SQP_FormatNone($ParsedSQL);
|
||||
$formatted_sql = PMA_SQP_formatNone($parsed_sql);
|
||||
break;
|
||||
case 'html':
|
||||
$formattedSQL = PMA_SQP_FormatHTML($ParsedSQL);
|
||||
$formatted_sql = PMA_SQP_formatHtml($parsed_sql);
|
||||
break;
|
||||
case 'text':
|
||||
$formattedSQL = PMA_SQP_FormatText($ParsedSQL);
|
||||
$formatted_sql = PMA_SQP_formatText($parsed_sql);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} // end switch
|
||||
|
||||
return $formattedSQL;
|
||||
|
||||
} // end of the "PMA_format_sql()" function
|
||||
} // end of the "PMA_formatSql()" function
|
||||
|
||||
|
||||
/**
|
||||
@@ -314,7 +313,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
||||
$the_query = $GLOBALS['sql_query'];
|
||||
}
|
||||
|
||||
$ParsedSQL = PMA_SQP_Parse($the_query);
|
||||
$parsed_sql = PMA_SQP_parse($the_query);
|
||||
|
||||
echo '<p><b>'. $GLOBALS['strError'] . '</b></p>' . "\n";
|
||||
// if the config password is wrong, or the MySQL server does not
|
||||
@@ -330,7 +329,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
||||
} // end if
|
||||
echo '</p>' . "\n"
|
||||
. '<p>' . "\n"
|
||||
. ' ' . PMA_format_sql($ParsedSQL) . "\n"
|
||||
. ' ' . PMA_formatSql($parsed_sql) . "\n"
|
||||
. '</p>' . "\n";
|
||||
} // end if
|
||||
if (!empty($error_message)) {
|
||||
@@ -1112,9 +1111,9 @@ if (typeof(document.getElementById) != 'undefined'
|
||||
$sqlnr = 1;
|
||||
if (!empty($GLOBALS['show_as_php'])) {
|
||||
$new_line = '";<br />' . "\n" . ' $sql .= "';
|
||||
} /* else if ($cfg['UseSyntaxColoring'] == FALSE) {
|
||||
$new_line = '<br />' . "\n";
|
||||
} */
|
||||
// } else if ($cfg['UseSyntaxColoring'] == FALSE) {
|
||||
// $new_line = '<br />' . "\n";
|
||||
}
|
||||
if (isset($new_line)) {
|
||||
$query_base = htmlspecialchars($GLOBALS['sql_query']);
|
||||
$query_base = ereg_replace("((\015\012)|(\015)|(\012))+", $new_line, $query_base);
|
||||
@@ -1123,10 +1122,10 @@ if (typeof(document.getElementById) != 'undefined'
|
||||
}
|
||||
if (!empty($GLOBALS['show_as_php'])) {
|
||||
$query_base = '$sql = "' . $query_base;
|
||||
// } else d$if ($cfg['UseSyntaxColoring']) {
|
||||
// } else if ($cfg['UseSyntaxColoring']) {
|
||||
} else {
|
||||
$ParsedSQL = PMA_SQP_Parse($query_base);
|
||||
$query_base = PMA_format_sql($ParsedSQL);
|
||||
$parsed_sql = PMA_SQP_parse($query_base);
|
||||
$query_base = PMA_formatSql($parsed_sql);
|
||||
}
|
||||
|
||||
// Prepares links that may be displayed to edit/explain the query
|
||||
@@ -1180,7 +1179,7 @@ if (typeof(document.getElementById) != 'undefined'
|
||||
// If a 'LIMIT' clause has been programatically added to the query
|
||||
// displays it
|
||||
if (!empty($GLOBALS['sql_limit_to_append'])) {
|
||||
echo PMA_format_sql(PMA_SQP_Parse($GLOBALS['sql_limit_to_append']));
|
||||
echo PMA_formatSql(PMA_SQP_parse($GLOBALS['sql_limit_to_append']));
|
||||
}
|
||||
if (!empty($GLOBALS['show_as_php'])) {
|
||||
echo '";';
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* $Id$ */
|
||||
|
||||
|
||||
/** SQL Parser Matching Data
|
||||
*
|
||||
* Copyright 2002 Robin Johnson <robbat2@users.sourceforge.net>
|
||||
@@ -10,13 +11,12 @@
|
||||
*
|
||||
* It has been extracted from the lex.h file in the MySQL BK tree
|
||||
* (around 4.0.2) as well as the MySQL documentation.
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('PMA_SQP_DATA_INCLUDED')) {
|
||||
define('PMA_SQP_DATA_INCLUDED', 1);
|
||||
|
||||
$PMA_SQPdata_FunctionName = array (
|
||||
$PMA_SQPdata_function_name = array (
|
||||
'ABS',
|
||||
'ACOS',
|
||||
'ADDDATE',
|
||||
@@ -152,10 +152,10 @@ if (!defined('PMA_SQP_DATA_INCLUDED')) {
|
||||
'WEEKDAY',
|
||||
'YEARWEEK'
|
||||
);
|
||||
//$PMA_SQPdata_FunctionNameLen = count($PMA_SQPdata_FunctionName);
|
||||
$PMA_SQPdata_FunctionNameLen = 134;
|
||||
//$PMA_SQPdata_function_name_cnt = count($PMA_SQPdata_function_name);
|
||||
$PMA_SQPdata_function_name_cnt = 134;
|
||||
|
||||
$PMA_SQPdata_ColumnAttrib = array (
|
||||
$PMA_SQPdata_column_attrib = array (
|
||||
'AUTO_INCREMENT',
|
||||
'BDB',
|
||||
'BERKELEYDB',
|
||||
@@ -172,10 +172,10 @@ if (!defined('PMA_SQP_DATA_INCLUDED')) {
|
||||
'VARYING',
|
||||
'ZEROFILL'
|
||||
);
|
||||
//$PMA_SQPdata_ColumnAttribLen = count($PMA_SQPdata_ColumnAttrib);
|
||||
$PMA_SQPdata_ColumnAttribLen = 15;
|
||||
//$PMA_SQPdata_column_attrib_cnt = count($PMA_SQPdata_column_attrib);
|
||||
$PMA_SQPdata_column_attrib_cnt = 15;
|
||||
|
||||
$PMA_SQPdata_ReservedWord = array (
|
||||
$PMA_SQPdata_reserved_word = array (
|
||||
'ACTION',
|
||||
'ADD',
|
||||
'AFTER',
|
||||
@@ -417,10 +417,10 @@ if (!defined('PMA_SQP_DATA_INCLUDED')) {
|
||||
'WRITE',
|
||||
'YEAR_MONTH'
|
||||
);
|
||||
//$PMA_SQPdata_ReservedWordLen = count($PMA_SQPdata_ReservedWord);
|
||||
$PMA_SQPdata_ReservedWordLen = 239;
|
||||
//$PMA_SQPdata_reserved_word_cnt = count($PMA_SQPdata_reserved_word);
|
||||
$PMA_SQPdata_reserved_word_cnt = 239;
|
||||
|
||||
$PMA_SQPdata_ColumnType = array (
|
||||
$PMA_SQPdata_column_type = array (
|
||||
'BIGINT',
|
||||
'BIT',
|
||||
'BLOB',
|
||||
@@ -465,10 +465,8 @@ if (!defined('PMA_SQP_DATA_INCLUDED')) {
|
||||
'VARCHAR',
|
||||
'YEAR'
|
||||
);
|
||||
//$PMA_SQPdata_ColumnTypeLen = count($PMA_SQPdata_ColumnType);
|
||||
$PMA_SQPdata_ColumnTypeLen = 43;
|
||||
|
||||
//$PMA_SQPdata_column_type_cnt = count($PMA_SQPdata_column_type);
|
||||
$PMA_SQPdata_column_type_cnt = 43;
|
||||
|
||||
} // $__PMA_SQP_DATA__
|
||||
|
||||
?>
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* $Id$ */
|
||||
|
||||
|
||||
/** SQL Parser Functions for phpMyAdmin
|
||||
*
|
||||
* Copyright 2002 Robin Johnson <robbat2@users.sourceforge.net>
|
||||
@@ -14,25 +15,23 @@
|
||||
* query, you need code like this up at the top:
|
||||
*
|
||||
* ($sql contains the query)
|
||||
* $parsedSQL = PMA_SQP_Parse($sql);
|
||||
* $parsed_sql = PMA_SQP_parse($sql);
|
||||
*
|
||||
* If you want to extract data from it then, you just need to run
|
||||
* $SQLinfo = PMA_SQP_Analyze($parsedSQL);
|
||||
* $sql_info = PMA_SQP_analyze($parsed_sql);
|
||||
* (returned structure of this function is being rewritten presently);
|
||||
*
|
||||
* If you want a pretty-printed version of the query, do:
|
||||
* $string = PMA_SQP_FormatHTML($parsedSQL);
|
||||
* $string = PMA_SQP_formatHtml($parsed_sql);
|
||||
* (note that that you need to have syntax.css.php3 included somehow in your
|
||||
* page for it to work, I recommend '<link rel="stylesheet" type="text/css"
|
||||
* href="syntax.css.php3" />' at the moment.)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
define('PMA_SQP_LIB_INCLUDED', 1);
|
||||
|
||||
|
||||
/**
|
||||
* Include the string libarry as we use it heavily
|
||||
*/
|
||||
@@ -43,31 +42,34 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
*/
|
||||
include('./libraries/sqlparser.data.php3');
|
||||
|
||||
if (!defined('DEBUGTIMING')) {
|
||||
function PMA_SQP_ArrayAdd(&$arr,$type,$data, &$arrsize)
|
||||
if (!defined('DEBUG_TIMING')) {
|
||||
function PMA_SQP_arrayAdd(&$arr, $type, $data, &$arrsize)
|
||||
{
|
||||
$arr[] = array( 'type' => $type, 'data' => $data );
|
||||
$arr[] = array('type' => $type, 'data' => $data);
|
||||
$arrsize++;
|
||||
}
|
||||
} // end of the "PMA_SQP_arrayAdd" function
|
||||
} else {
|
||||
function PMA_SQP_ArrayAdd(&$arr,$type,$data, &$arrsize)
|
||||
function PMA_SQP_arrayAdd(&$arr, $type, $data, &$arrsize)
|
||||
{
|
||||
global $timer;
|
||||
|
||||
$t = $timer;
|
||||
$arr[] = array( 'type' => $type, 'data' => $data , 'time' => $t );
|
||||
$arr[] = array('type' => $type, 'data' => $data , 'time' => $t);
|
||||
$timer = microtime();
|
||||
$arrsize++;
|
||||
}
|
||||
}
|
||||
} // end of the "PMA_SQP_arrayAdd" function
|
||||
} // end if... else...
|
||||
|
||||
function PMA_SQP_Parse($sql)
|
||||
|
||||
function PMA_SQP_parse($sql)
|
||||
{
|
||||
global $cfg;
|
||||
global $PMA_SQPdata_column_attrib, $PMA_SQPdata_reserved_word, $PMA_SQPdata_column_type, $PMA_SQPdata_function_name,
|
||||
$PMA_SQPdata_column_attrib_cnt, $PMA_SQPdata_reserved_word_cnt, $PMA_SQPdata_column_type_cnt, $PMA_SQPdata_function_name_cnt;
|
||||
|
||||
// if the SQL parser is disabled
|
||||
// just return the original query string
|
||||
if($cfg['SQP']['enable'] == FALSE) {
|
||||
echo 'FALSE';
|
||||
// if the SQL parser is disabled just return the original query string
|
||||
if ($cfg['SQP']['enable'] == FALSE) {
|
||||
// Debug : echo 'FALSE';
|
||||
return $sql;
|
||||
}
|
||||
|
||||
@@ -101,57 +103,59 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
8 => '>>',
|
||||
9 => '||',
|
||||
);
|
||||
|
||||
$allpunct_list_pair_size = 10; //count($allpunct_list_pair);
|
||||
$quote_list = "\'\"\`";
|
||||
$arraysize = 0;
|
||||
while($count2 < $len) {
|
||||
|
||||
while ($count2 < $len) {
|
||||
$c = $sql[$count2];
|
||||
$count1 = $count2;
|
||||
|
||||
if ( ($c == "\n") ) {
|
||||
if (($c == "\n")) {
|
||||
$count2++;
|
||||
PMA_SQP_ArrayAdd( $sql_array, 'white_newline', '', $arraysize);
|
||||
PMA_SQP_arrayAdd($sql_array, 'white_newline', '', $arraysize);
|
||||
continue;
|
||||
}
|
||||
|
||||
//check for white space
|
||||
if (PMA_STR_IsSpace($c)) {
|
||||
// Checks for white space
|
||||
if (PMA_STR_isSpace($c)) {
|
||||
$count2++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// check for comment lines.
|
||||
// Checks for comment lines.
|
||||
// MySQL style #
|
||||
// C style /* */
|
||||
// ANSI style --
|
||||
if ( ($c == '#') || (($count2+1 < $len) && ($c == '/') && ($sql[$count2+1] == '*')) || (($c == '-') && ($count2+2 < $len) && ($sql[$count2+1] == '-') && ($sql[$count2+2] == ' '))) {
|
||||
if (($c == '#')
|
||||
|| (($count2 + 1 < $len) && ($c == '/') && ($sql[$count2 + 1] == '*'))
|
||||
|| (($count2 + 2 < $len) && ($c == '-') && ($sql[$count2 + 1] == '-') && ($sql[$count2 + 2] == ' '))) {
|
||||
$count2++;
|
||||
$pos = 0;
|
||||
$type = 'bad';
|
||||
switch($c) {
|
||||
switch ($c) {
|
||||
case '#':
|
||||
$type = 'mysql';
|
||||
case '-':
|
||||
$type = 'ansi';
|
||||
$pos = strpos($sql,"\n",$count2);
|
||||
$pos = strpos($sql, "\n", $count2);
|
||||
break;
|
||||
case '/':
|
||||
$type = 'c';
|
||||
$pos = strpos($sql,"*/",$count2);
|
||||
$pos = strpos($sql, '*/', $count2);
|
||||
$pos += 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} // end switch
|
||||
$count2 = ($pos < $count2) ? $len : $pos;
|
||||
$str = substr($sql,$count1,$count2-$count1);
|
||||
PMA_SQP_ArrayAdd ( $sql_array, 'comment_'.$type, $str, $arraysize);
|
||||
$str = substr($sql, $count1, $count2 - $count1);
|
||||
PMA_SQP_arrayAdd($sql_array, 'comment_' . $type, $str, $arraysize);
|
||||
continue;
|
||||
}
|
||||
} // end if
|
||||
|
||||
//check for something inside quotation marks
|
||||
if (PMA_STR_StrInStr($c,$quote_list)) {
|
||||
// Checks for something inside quotation marks
|
||||
if (PMA_STR_strInStr($c, $quote_list)) {
|
||||
$startquotepos = $count2;
|
||||
$quotetype = $c;
|
||||
$count2++;
|
||||
@@ -161,88 +165,90 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
$oldpos = 0;
|
||||
do {
|
||||
$oldpos = $pos;
|
||||
$pos = strpos($sql,$quotetype,$oldpos);
|
||||
$pos = strpos($sql, $quotetype, $oldpos);
|
||||
// ($pos === FALSE)
|
||||
if (!is_integer($pos)) {
|
||||
trigger_error('Syntax: Unclosed quote ('.$quotetype.') at '.$startquotepos);
|
||||
trigger_error('Syntax: Unclosed quote (' . $quotetype . ') at ' . $startquotepos);
|
||||
return;
|
||||
}
|
||||
|
||||
//if the quote is the first character,
|
||||
//it can't be escaped, so don't do the rest of the code
|
||||
// If the quote is the first character, it can't be
|
||||
// escaped, so don't do the rest of the code
|
||||
if ($pos == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (PMA_STR_CharIsEscaped($sql,$pos)) {
|
||||
if (PMA_STR_charIsEscaped($sql, $pos)) {
|
||||
$pos ++;
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while ( $len > $pos );
|
||||
} while ($len > $pos); // end do
|
||||
|
||||
$count2 = $pos;
|
||||
$count2++;
|
||||
$type = 'quote_';
|
||||
switch($quotetype) {
|
||||
case "'":
|
||||
switch ($quotetype) {
|
||||
case '\'':
|
||||
$type .= 'single';
|
||||
break;
|
||||
case "\"":
|
||||
case '"':
|
||||
$type .= 'double';
|
||||
break;
|
||||
case "`":
|
||||
case '`':
|
||||
$type .= 'backtick';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$data = substr($sql, $count1, $count2-$count1);
|
||||
PMA_SQP_ArrayAdd ( $sql_array, $type, $data, $arraysize );
|
||||
} // end switch
|
||||
$data = substr($sql, $count1, $count2 - $count1);
|
||||
PMA_SQP_arrayAdd($sql_array, $type, $data, $arraysize);
|
||||
continue;
|
||||
}
|
||||
//check for brackets
|
||||
if (PMA_STR_StrInStr($c,$bracket_list)) {
|
||||
//all bracket tokens are only one item long
|
||||
|
||||
// Checks for brackets
|
||||
if (PMA_STR_strInStr($c, $bracket_list)) {
|
||||
// All bracket tokens are only one item long
|
||||
$count2++;
|
||||
$type_type = '';
|
||||
if (PMA_STR_StrInStr($c,'([{')) {
|
||||
if (PMA_STR_strInStr($c, '([{')) {
|
||||
$type_type = 'open';
|
||||
} else {
|
||||
$type_type = 'close';
|
||||
}
|
||||
|
||||
$type_style = '';
|
||||
if (PMA_STR_StrInStr($c,'()')) {
|
||||
if (PMA_STR_strInStr($c, '()')) {
|
||||
$type_style = 'round';
|
||||
} elseif (PMA_STR_StrInStr($c,'[]')) {
|
||||
} elseif (PMA_STR_strInStr($c, '[]')) {
|
||||
$type_style = 'square';
|
||||
} else {
|
||||
$type_style = 'curly';
|
||||
}
|
||||
|
||||
$type = 'punct_bracket_'.$type_type.'_'.$type_style;
|
||||
PMA_SQP_ArrayAdd ( $sql_array, $type, $c, $arraysize);
|
||||
$type = 'punct_bracket_' . $type_type . '_' . $type_style;
|
||||
PMA_SQP_arrayAdd($sql_array, $type, $c, $arraysize);
|
||||
continue;
|
||||
}
|
||||
//check for punct
|
||||
if (PMA_STR_StrInStr($c,$allpunct_list))
|
||||
{
|
||||
while( ($count2 < $len) && PMA_STR_StrInStr($sql[$count2],$allpunct_list) ) {
|
||||
|
||||
// Checks for punct
|
||||
if (PMA_STR_strInStr($c, $allpunct_list)) {
|
||||
while (($count2 < $len) && PMA_STR_strInStr($sql[$count2], $allpunct_list)) {
|
||||
$count2++;
|
||||
}
|
||||
$l = $count2-$count1;
|
||||
$l = $count2 - $count1;
|
||||
if ($l == 1) {
|
||||
$punct_data = $c;
|
||||
} else {
|
||||
$punct_data = substr($sql,$count1,$l);
|
||||
$punct_data = substr($sql, $count1, $l);
|
||||
}
|
||||
|
||||
//special case, sometimes, althought two characters are adjectent directly,
|
||||
//they ACTUALLY need to be seperate
|
||||
if ( $l == 1 ) {
|
||||
// Special case, sometimes, althought two characters are
|
||||
// adjectent directly, they ACTUALLY need to be seperate
|
||||
if ($l == 1) {
|
||||
$t_suffix = '';
|
||||
switch($punct_data) {
|
||||
switch ($punct_data) {
|
||||
case $punct_queryend:
|
||||
$t_suffix = '_queryend';
|
||||
break;
|
||||
@@ -255,134 +261,135 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
PMA_SQP_ArrayAdd ( $sql_array, 'punct'.$t_suffix, $punct_data, $arraysize);
|
||||
} elseif ( PMA_STR_BinarySearchInArr($punct_data,$allpunct_list_pair,$allpunct_list_pair_size)) {
|
||||
//Ok, we have one of the valid combined punct expressions
|
||||
PMA_SQP_ArrayAdd ( $sql_array, 'punct', $punct_data, $arraysize );
|
||||
} else {
|
||||
//bad luck, lets split it up more
|
||||
PMA_SQP_arrayAdd($sql_array, 'punct' . $t_suffix, $punct_data, $arraysize);
|
||||
}
|
||||
else if (PMA_STR_binarySearchInArr($punct_data, $allpunct_list_pair, $allpunct_list_pair_size)) {
|
||||
// Ok, we have one of the valid combined punct expressions
|
||||
PMA_SQP_arrayAdd($sql_array, 'punct', $punct_data, $arraysize);
|
||||
}
|
||||
else {
|
||||
// Bad luck, lets split it up more
|
||||
$first = $punct_data[0];
|
||||
$first2 = $punct_data[0].$punct_data[1];
|
||||
$last2 = $punct_data[$l-2].$punct_data[$l-1];
|
||||
$last = $punct_data[$l-1];
|
||||
if (($first == ',') || ($first == ';') || ($first == '.') || $first = '*') {
|
||||
$first2 = $punct_data[0] . $punct_data[1];
|
||||
$last2 = $punct_data[$l - 2] . $punct_data[$l - 1];
|
||||
$last = $punct_data[$l - 1];
|
||||
if (($first == ',') || ($first == ';') || ($first == '.') || ($first = '*')) {
|
||||
$count2 = $count1 + 1;
|
||||
$punct_data = $first;
|
||||
} elseif (($last2 == '/*') || ($last2 == '--')) {
|
||||
$count2-=2;
|
||||
$punct_data = substr($sql,$count1,$count2-$count1);
|
||||
} elseif (($last == '-') || ($last == '+') || ($last == '!')) {
|
||||
} else if (($last2 == '/*') || ($last2 == '--')) {
|
||||
$count2 -= 2;
|
||||
$punct_data = substr($sql, $count1, $count2 - $count1);
|
||||
} else if (($last == '-') || ($last == '+') || ($last == '!')) {
|
||||
$count2--;
|
||||
$punct_data = substr($sql,$count1,$count2-$count1);
|
||||
$punct_data = substr($sql, $count1, $count2 - $count1);
|
||||
} else {
|
||||
trigger_error('Syntax: Unknown punctation string ('.$punct_data.') at '.$count1);
|
||||
trigger_error('Syntax: Unknown punctation string (' . $punct_data . ') at ' . $count1);
|
||||
return;
|
||||
}
|
||||
PMA_SQP_ArrayAdd ( $sql_array, 'punct', $punct_data, $arraysize);
|
||||
PMA_SQP_arrayAdd($sql_array, 'punct', $punct_data, $arraysize);
|
||||
continue;
|
||||
} // end if... else if... else
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//check for alpha
|
||||
if (PMA_STR_IsSqlIdentifier($c,FALSE) || ($c == '@')) {
|
||||
|
||||
// Checks for alpha
|
||||
if (PMA_STR_isSqlIdentifier($c, FALSE) || ($c == '@')) {
|
||||
$count2 ++;
|
||||
$is_SQLvariable = ($c == '@');
|
||||
$is_Digit = (!$is_SQLvariable) && PMA_STR_IsDigit($c);
|
||||
$is_HexDigit = ($is_Digit) && ($c == '0') && ($sql[$count2] == 'x');
|
||||
$is_FloatDigit = FALSE;
|
||||
$is_FloatDigitExponent = FALSE;
|
||||
$is_sql_variable = ($c == '@');
|
||||
$is_digit = (!$is_sql_variable) && PMA_STR_isDigit($c);
|
||||
$is_hex_digit = ($is_digit) && ($c == '0') && ($sql[$count2] == 'x');
|
||||
$is_float_digit = FALSE;
|
||||
$is_float_digit_exponent = FALSE;
|
||||
|
||||
if ($is_HexDigit) {
|
||||
if ($is_hex_digit) {
|
||||
$count2++;
|
||||
}
|
||||
|
||||
|
||||
while(($count2 < $len) && PMA_STR_IsSqlIdentifier($sql[$count2],$is_SQLvariable || $is_Digit)) {
|
||||
while (($count2 < $len) && PMA_STR_isSqlIdentifier($sql[$count2], ($is_sql_variable || $is_digit))) {
|
||||
$c2 = $sql[$count2];
|
||||
if ($is_SQLvariable && ($c2 == '.')) {
|
||||
if ($is_sql_variable && ($c2 == '.')) {
|
||||
$count2++;
|
||||
continue;
|
||||
}
|
||||
if ($is_Digit && (!$is_HexDigit) && ($c2 == '.')) {
|
||||
if ($is_digit && (!$is_hex_digit) && ($c2 == '.')) {
|
||||
$count2++;
|
||||
if (!$is_FloatDigit) {
|
||||
$is_FloatDigit = TRUE;
|
||||
if (!$is_float_digit) {
|
||||
$is_float_digit = TRUE;
|
||||
continue;
|
||||
} else {
|
||||
trigger_error('Syntax: Invalid Identifer ('.substr($sql,$count1,$count2-$count1).') at '.$count1);
|
||||
trigger_error('Syntax: Invalid Identifer (' . substr($sql, $count1, $count2 - $count1) . ') at ' . $count1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ($is_Digit && (!$is_HexDigit) && (($c2 == 'e') || ($c2 == 'E'))) {
|
||||
if (!$is_FloatDigitExponent) {
|
||||
$is_FloatDigitExponent = TRUE;
|
||||
$is_FloatDigit = TRUE;
|
||||
if ($is_digit && (!$is_hex_digit) && (($c2 == 'e') || ($c2 == 'E'))) {
|
||||
if (!$is_float_digit_exponent) {
|
||||
$is_float_digit_exponent = TRUE;
|
||||
$is_float_digit = TRUE;
|
||||
$count2++;
|
||||
continue;
|
||||
} else {
|
||||
$is_Digit = FALSE;
|
||||
$is_FloatDigit = FALSE;
|
||||
$is_digit = FALSE;
|
||||
$is_float_digit = FALSE;
|
||||
}
|
||||
}
|
||||
if ( ($is_HexDigit && PMA_STR_IsHexDigit($c2)) || ($is_Digit && PMA_STR_IsDigit($c2))) {
|
||||
if (($is_hex_digit && PMA_STR_isHexDigit($c2)) || ($is_digit && PMA_STR_isDigit($c2))) {
|
||||
$count2++;
|
||||
continue;
|
||||
} else {
|
||||
$is_Digit = FALSE;
|
||||
$is_HexDigit = FALSE;
|
||||
$is_digit = FALSE;
|
||||
$is_hex_digit = FALSE;
|
||||
}
|
||||
|
||||
$count2++;
|
||||
}
|
||||
} // end while
|
||||
|
||||
|
||||
$l = $count2-$count1;
|
||||
$str = substr($sql,$count1,$l);
|
||||
$l = $count2 - $count1;
|
||||
$str = substr($sql, $count1, $l);
|
||||
|
||||
$type = '';
|
||||
if ($is_Digit) {
|
||||
if ($is_digit) {
|
||||
$type = 'digit';
|
||||
if ($is_FloatDigit) {
|
||||
if ($is_float_digit) {
|
||||
$type .= '_float';
|
||||
} elseif ($is_HexDigit) {
|
||||
} else if ($is_hex_digit) {
|
||||
$type .= '_hex';
|
||||
} else {
|
||||
$type .= '_integer';
|
||||
}
|
||||
} else {
|
||||
if ($is_SQLvariable != FALSE) {
|
||||
}
|
||||
else {
|
||||
if ($is_sql_variable != FALSE) {
|
||||
$type = 'alpha_variable';
|
||||
} else {
|
||||
$type = 'alpha';
|
||||
}
|
||||
}
|
||||
PMA_SQP_ArrayAdd ( $sql_array, $type, $str, $arraysize );
|
||||
} // end if... else....
|
||||
PMA_SQP_arrayAdd($sql_array, $type, $str, $arraysize);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
//DEBUG
|
||||
// DEBUG
|
||||
$count2++;
|
||||
echo 'You seem to have found a bug in the SQL parser.<br />Please submit a bug report with the data chunk below:<br />--BEGIN CUT--<br />';
|
||||
$debugstr = '$Id$<br />';
|
||||
$debugstr .= 'Why did we get here? '.$count1.' '.$count2.' '.$len.'<br />'."\n";
|
||||
$debugstr .= 'Leftover: '.substr($sql,$count1,$count2-$count1).'<br />'."\n";
|
||||
$debugstr .= 'A: '.$count1.' '.$count2.'<br />'."\n";
|
||||
$debugstr .= 'SQL: '.$sql;
|
||||
$encodedstr = nl2br(chunk_split(base64_encode(gzcompress($debugstr,9))));
|
||||
echo $encodedstr;
|
||||
echo '---END CUT---<br />';
|
||||
//$decodedstr = str_replace('<br />','', base64_decode(gzuncompress($encodedstr)));
|
||||
$decodedstr = gzuncompress(base64_decode(str_replace('<br />','',$encodedstr)));
|
||||
echo $decodedstr;
|
||||
echo "\n" . '<p>' . "\n";
|
||||
echo 'You seem to have found a bug in the SQL parser.<br />Please submit a bug report with the data chunk below:<br />' . "\n" . '--BEGIN CUT--<br />' . "\n";
|
||||
$debugstr = '$Id$<br />' . "\n";
|
||||
$debugstr .= 'Why did we get here? ' . $count1 . ' ' . $count2 . ' ' . $len . '<br />' . "\n";
|
||||
$debugstr .= 'Leftover: ' . substr($sql, $count1, $count2 - $count1) . '<br />' . "\n";
|
||||
$debugstr .= 'A: ' . $count1 . ' ' . $count2 . '<br />' . "\n";
|
||||
$debugstr .= 'SQL: ' . $sql;
|
||||
$encodedstr = nl2br(chunk_split(base64_encode(gzcompress($debugstr, 9))));
|
||||
echo $encodedstr . "\n";
|
||||
echo '---END CUT---<br /><br />' . "\n\n";
|
||||
//$decodedstr = str_replace('<br />', '', base64_decode(gzuncompress($encodedstr)));
|
||||
$decodedstr = gzuncompress(base64_decode(str_replace('<br />', '', $encodedstr)));
|
||||
echo $decodedstr . "\n";
|
||||
echo '</p>' . "\n";
|
||||
flush();
|
||||
ob_flush();
|
||||
die();
|
||||
} // end while ($count2 < $len)
|
||||
|
||||
}
|
||||
|
||||
global $PMA_SQPdata_ColumnAttrib, $PMA_SQPdata_ReservedWord, $PMA_SQPdata_ColumnType, $PMA_SQPdata_FunctionName,
|
||||
$PMA_SQPdata_ColumnAttribLen, $PMA_SQPdata_ReservedWordLen, $PMA_SQPdata_ColumnTypeLen, $PMA_SQPdata_FunctionNameLen;
|
||||
|
||||
if ($arraysize > 0) {
|
||||
$t_next = $sql_array[0]['type'];
|
||||
@@ -390,26 +397,27 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
$t_cur = NULL;
|
||||
}
|
||||
|
||||
for($i = 0; $i < $arraysize; $i++) {
|
||||
for ($i = 0; $i < $arraysize; $i++) {
|
||||
$t_prev = $t_cur;
|
||||
$t_cur = $t_next;
|
||||
if (($i+1)<$arraysize) {
|
||||
$t_next = $sql_array[$i+1]['type'];
|
||||
if (($i + 1) < $arraysize) {
|
||||
$t_next = $sql_array[$i + 1]['type'];
|
||||
} else {
|
||||
$t_next = NULL;
|
||||
}
|
||||
if ($t_cur == 'alpha') {
|
||||
$t_suffix = '_identifier';
|
||||
$d_cur_upper = strtoupper($sql_array[$i]['data']);
|
||||
if ( ($t_next == 'punct_qualifier') || ($t_prev == 'punct_qualifier')) {
|
||||
if (($t_next == 'punct_qualifier') || ($t_prev == 'punct_qualifier')) {
|
||||
$t_suffix = '_identifier';
|
||||
} elseif ( ($t_next == 'punct_bracket_open_round') && PMA_STR_BinarySearchInArr($d_cur_upper,$PMA_SQPdata_FunctionName,$PMA_SQPdata_FunctionNameLen)) {
|
||||
} else if (($t_next == 'punct_bracket_open_round')
|
||||
&& PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_function_name, $PMA_SQPdata_function_name_cnt)) {
|
||||
$t_suffix = '_functionName';
|
||||
} elseif (PMA_STR_BinarySearchInArr($d_cur_upper,$PMA_SQPdata_ReservedWord,$PMA_SQPdata_ReservedWordLen)) {
|
||||
} else if (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_reserved_word, $PMA_SQPdata_reserved_word_cnt)) {
|
||||
$t_suffix = '_reservedWord';
|
||||
} elseif (PMA_STR_BinarySearchInArr($d_cur_upper,$PMA_SQPdata_ColumnType,$PMA_SQPdata_ColumnTypeLen)) {
|
||||
} else if (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_column_type, $PMA_SQPdata_column_type_cnt)) {
|
||||
$t_suffix = '_columnType';
|
||||
} elseif (PMA_STR_BinarySearchInArr($d_cur_upper,$PMA_SQPdata_ColumnAttrib,$PMA_SQPdata_ColumnAttribLen)) {
|
||||
} else if (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_column_attrib, $PMA_SQPdata_column_attrib_cnt)) {
|
||||
$t_suffix = '_columnAttrib';
|
||||
} else {
|
||||
// Do nothing
|
||||
@@ -418,16 +426,16 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
}
|
||||
}
|
||||
|
||||
// Store the size of the array inside the array, as count() is a slow operation.
|
||||
// Stores the size of the array inside the array, as count() is a slow
|
||||
// operation.
|
||||
$sql_array['len'] = $arraysize;
|
||||
|
||||
// Send the data back
|
||||
// Sends the data back
|
||||
return $sql_array;
|
||||
|
||||
}
|
||||
} // end of the "PMA_SQP_parse()" function
|
||||
|
||||
|
||||
function PMA_SQP_Analyze($arr)
|
||||
function PMA_SQP_analyze($arr)
|
||||
{
|
||||
$result = array();
|
||||
$size = $arr['len'];
|
||||
@@ -442,7 +450,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
$subresult_empty = $subresult;
|
||||
$seek_queryend = FALSE;
|
||||
|
||||
$supportedQueryTypes = array(
|
||||
$supported_query_types = array(
|
||||
'SELECT',
|
||||
'UPDATE',
|
||||
'DELETE',
|
||||
@@ -460,9 +468,9 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
'ALTER'
|
||||
*/
|
||||
);
|
||||
$supportedQueryTypes_size = count($supportedQueryTypes);
|
||||
$supported_query_types_cnt = count($supported_query_types);
|
||||
|
||||
for($i=0;$i <= $size; $i++) {
|
||||
for ($i = 0; $i <= $size; $i++) {
|
||||
// High speed seek for locating the end of the current query
|
||||
if ($seek_queryend == TRUE) {
|
||||
if ($arr[$i]['type'] == 'punct_queryend') {
|
||||
@@ -472,7 +480,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
}
|
||||
}
|
||||
|
||||
switch($arr[$i]['type']) {
|
||||
switch ($arr[$i]['type']) {
|
||||
case 'punct_queryend':
|
||||
$result[] = $subresult;
|
||||
$subresult = $subresult_empty;
|
||||
@@ -483,25 +491,25 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
$subresult['querytype'] = strtoupper($arr[$i]['data']);
|
||||
}
|
||||
// Check if we support this type of query
|
||||
if (! PMA_STR_BinarySearchInArr($subresult['querytype'],$supportedQueryTypes,$supportedQueryTypes_size)) {
|
||||
if (!PMA_STR_binarySearchInArr($subresult['querytype'], $supported_query_types, $supported_query_types_cnt)) {
|
||||
// Skip ahead to the next one if we don't
|
||||
$seek_queryend = TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} // end switch
|
||||
|
||||
switch($subresult['querytype']) {
|
||||
switch ($subresult['querytype']) {
|
||||
case 'SELECT':
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} // end switch
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// They are are naughty and didn't have a trailing semi-colon, then still handle it properly
|
||||
// They are naughty and didn't have a trailing semi-colon,
|
||||
// then still handle it properly
|
||||
if ($subresult['querytype'] != '') {
|
||||
$result[] = $subresult;
|
||||
}
|
||||
@@ -509,21 +517,24 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
echo '<pre>';
|
||||
print_r($result);
|
||||
echo '</pre>';
|
||||
}
|
||||
} // end of the "PMA_SQP_analyze()" function
|
||||
|
||||
function PMA_SQP_FormatHTML_colorize($arr)
|
||||
|
||||
function PMA_SQP_formatHtml_colorize($arr)
|
||||
{
|
||||
$i = strpos($arr['type'],'_');
|
||||
$i = strpos($arr['type'], '_');
|
||||
$class = '';
|
||||
if ($i > 0) {
|
||||
$class = 'syntax_'.substr($arr['type'],0,$i).' ';
|
||||
$class = 'syntax_' . substr($arr['type'], 0, $i) . ' ';
|
||||
}
|
||||
|
||||
$class .= 'syntax_'.$arr['type'];
|
||||
return '<span class="'.$class.'">'.htmlspecialchars($arr['data']).'</span>';
|
||||
}
|
||||
$class .= 'syntax_' . $arr['type'];
|
||||
|
||||
function PMA_SQP_FormatHTML($arr)
|
||||
return '<span class="' . $class . '">' . htmlspecialchars($arr['data']) . '</span>';
|
||||
} // end of the "PMA_SQP_formatHtml_colorize()" function
|
||||
|
||||
|
||||
function PMA_SQP_formatHtml($arr)
|
||||
{
|
||||
$str = '<span class="syntax">';
|
||||
$indent = 0;
|
||||
@@ -531,10 +542,10 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
$functionlevel = 0;
|
||||
$infunction = FALSE;
|
||||
$space_punct_listsep = ' ';
|
||||
$space_punct_listsep_functionName = ' ';
|
||||
// $space_alpha_reservedWord = '<br />'."\n";
|
||||
$space_alpha_reservedWord = ' ';
|
||||
$keywordsWithBrackets = array(
|
||||
$space_punct_listsep_function_name = ' ';
|
||||
// $space_alpha_reserved_word = '<br />'."\n";
|
||||
$space_alpha_reserved_word = ' ';
|
||||
$keywords_with_brackets = array(
|
||||
'INDEX',
|
||||
'INTO',
|
||||
'KEY',
|
||||
@@ -543,15 +554,15 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
'REFERENCES',
|
||||
'UNIQUE'
|
||||
);
|
||||
//$keywordsWithBrackets_size = count($keywordsWithBrackets);
|
||||
$keywordsWithBrackets_size = 6;
|
||||
$keywordsForMath = array(
|
||||
// $keywords_with_brackets_cnt = count($keywords_with_brackets);
|
||||
$keywords_with_brackets_cnt = 6;
|
||||
$keywords_for_math = array(
|
||||
'AND',
|
||||
'NOT',
|
||||
'NULL',
|
||||
'OR'
|
||||
);
|
||||
$keywordsForMath_size = 4;
|
||||
$keywords_for_math_cnt = 4;
|
||||
|
||||
$arraysize = $arr['len'];
|
||||
$typearr = array();
|
||||
@@ -562,7 +573,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
$typearr[3] = $arr[0]['type'];
|
||||
}
|
||||
|
||||
for($i = 0; $i < $arraysize; $i++) {
|
||||
for ($i = 0; $i < $arraysize; $i++) {
|
||||
$before = '';
|
||||
$after = '';
|
||||
$indent = 0;
|
||||
@@ -573,19 +584,19 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
2 current
|
||||
3 next
|
||||
*/
|
||||
if (($i+1)<$arraysize) {
|
||||
//array_push($typearr,$arr[$i+1]['type']);
|
||||
if (($i + 1) < $arraysize) {
|
||||
// array_push($typearr, $arr[$i + 1]['type']);
|
||||
$typearr[4] = $arr[$i+1]['type'];
|
||||
} else {
|
||||
//array_push($typearr,NULL);
|
||||
//array_push($typearr, NULL);
|
||||
$typearr[4] = NULL;
|
||||
}
|
||||
|
||||
for($j=0;$j<4;$j++) {
|
||||
$typearr[$j] = $typearr[$j+1];
|
||||
for ($j=0; $j<4; $j++) {
|
||||
$typearr[$j] = $typearr[$j + 1];
|
||||
}
|
||||
|
||||
switch($typearr[2]) {
|
||||
switch ($typearr[2]) {
|
||||
case 'white_newline':
|
||||
// $after = '<br />';
|
||||
$before = '';
|
||||
@@ -593,22 +604,24 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
case 'punct_bracket_open_round':
|
||||
$bracketlevel++;
|
||||
$infunction = FALSE;
|
||||
//make sure this array is sorted!
|
||||
if ( ($typearr[1] == 'alpha_functionName') || ($typearr[1] == 'alpha_columnType') || ($typearr[1] == 'punct') || ($typearr[3] == 'digit_integer') || ($typearr[3] == 'digit_hex') || ($typearr[3] == 'digit_float') || ( ( $typearr[0] == 'alpha_reservedWord' ) && ( PMA_STR_BinarySearchInArr(strtoupper($arr[$i-2]['data']),$keywordsWithBrackets,$keywordsWithBrackets_size))) ) {
|
||||
// Make sure this array is sorted!
|
||||
if (($typearr[1] == 'alpha_functionName') || ($typearr[1] == 'alpha_columnType') || ($typearr[1] == 'punct')
|
||||
|| ($typearr[3] == 'digit_integer') || ($typearr[3] == 'digit_hex') || ($typearr[3] == 'digit_float')
|
||||
|| (($typearr[0] == 'alpha_reservedWord') && ( PMA_STR_binarySearchInArr(strtoupper($arr[$i - 2]['data']), $keywords_with_brackets, $keywords_with_brackets_cnt)))) {
|
||||
$functionlevel++;
|
||||
$infunction = TRUE;
|
||||
$after .= ' ';
|
||||
} else {
|
||||
$indent++;
|
||||
$after .= '<div class="syntax_indent'.$indent.'">';
|
||||
$after .= '<div class="syntax_indent' . $indent . '">';
|
||||
}
|
||||
break;
|
||||
case 'alpha_identifier':
|
||||
if(($typearr[1] == 'punct_qualifier') || ($typearr[3] == 'punct_qualifier')) {
|
||||
if (($typearr[1] == 'punct_qualifier') || ($typearr[3] == 'punct_qualifier')) {
|
||||
$after = '';
|
||||
$before = '';
|
||||
}
|
||||
if($typearr[3] == 'alpha_columnType') {
|
||||
if ($typearr[3] == 'alpha_columnType') {
|
||||
$after .= ' ';
|
||||
}
|
||||
break;
|
||||
@@ -618,19 +631,19 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
break;
|
||||
case 'punct_listsep':
|
||||
if ($infunction == TRUE) {
|
||||
$after .= $space_punct_listsep_functionName;
|
||||
$after .= $space_punct_listsep_function_name;
|
||||
} else {
|
||||
$after .= $space_punct_listsep;
|
||||
}
|
||||
break;
|
||||
case 'punct_queryend':
|
||||
if ( ($typearr[3] != 'comment_mysql')&& ($typearr[3] != 'comment_ansi') ) {
|
||||
if (($typearr[3] != 'comment_mysql') && ($typearr[3] != 'comment_ansi')) {
|
||||
$after .= '<br />';
|
||||
$after .= '<br />';
|
||||
}
|
||||
$space_punct_listsep = ' ';
|
||||
$space_punct_listsep_functionName = ' ';
|
||||
$space_alpha_reservedWord = ' ';
|
||||
$space_punct_listsep_function_name = ' ';
|
||||
$space_alpha_reserved_word = ' ';
|
||||
break;
|
||||
case 'comment_mysql':
|
||||
case 'comment_ansi':
|
||||
@@ -658,16 +671,16 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
break;
|
||||
case 'alpha_reservedWord':
|
||||
$upper = $arr[$i]['data'];
|
||||
if ( ($typearr[1] != 'alpha_reservedWord') && ($typearr[1] != 'punct_level_plus') && (!PMA_STR_BinarySearchInArr($upper,$keywordsForMath,$keywordsForMath_size))) {
|
||||
$before .= $space_alpha_reservedWord;
|
||||
if (($typearr[1] != 'alpha_reservedWord') && ($typearr[1] != 'punct_level_plus') && (!PMA_STR_binarySearchInArr($upper, $keywords_for_math, $keywords_for_math_cnt))) {
|
||||
$before .= $space_alpha_reserved_word;
|
||||
} else {
|
||||
$before .= ' ';
|
||||
}
|
||||
|
||||
switch($upper) {
|
||||
switch ($upper) {
|
||||
case 'CREATE':
|
||||
$space_punct_listsep = '<br />';
|
||||
$space_alpha_reservedWord = ' ';
|
||||
$space_alpha_reserved_word = ' ';
|
||||
break;
|
||||
case 'EXPLAIN':
|
||||
case 'DESCRIBE':
|
||||
@@ -681,38 +694,38 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
case 'ANALYZE':
|
||||
case 'ANALYSE':
|
||||
$space_punct_listsep = '<br />';
|
||||
$space_alpha_reservedWord = ' ';
|
||||
$space_alpha_reserved_word = ' ';
|
||||
break;
|
||||
case 'INSERT':
|
||||
case 'REPLACE':
|
||||
$space_punct_listsep = '<br />';
|
||||
$space_alpha_reservedWord = '<br />';
|
||||
$space_alpha_reserved_word = '<br />';
|
||||
break;
|
||||
case 'VALUES':
|
||||
$space_punct_listsep = ' ';
|
||||
$space_alpha_reservedWord = '<br />';
|
||||
$space_alpha_reserved_word = '<br />';
|
||||
break;
|
||||
case 'SELECT':
|
||||
$space_punct_listsep = ' ';
|
||||
$space_alpha_reservedWord = '<br />';
|
||||
$space_alpha_reserved_word = '<br />';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} // end switch ($upper)
|
||||
|
||||
$after .= " ";
|
||||
$after .= ' ';
|
||||
break;
|
||||
case 'digit_integer':
|
||||
case 'digit_float':
|
||||
case 'digit_hex':
|
||||
if($infunction && $typearr[3] == 'punct_bracket_close_round') {
|
||||
if ($infunction && $typearr[3] == 'punct_bracket_close_round') {
|
||||
$after .= ' ';
|
||||
}
|
||||
break;
|
||||
case 'quote_double':
|
||||
case 'quote_single':
|
||||
$before .= ' ';
|
||||
if($infunction && $typearr[3] == 'punct_bracket_close_round') {
|
||||
if ($infunction && $typearr[3] == 'punct_bracket_close_round') {
|
||||
$after .= ' ';
|
||||
}
|
||||
break;
|
||||
@@ -726,50 +739,59 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} // end switch ($typearr[2])
|
||||
|
||||
/* if ($typearr[3] != 'punct_qualifier') {
|
||||
/*
|
||||
if ($typearr[3] != 'punct_qualifier') {
|
||||
$after .= ' ';
|
||||
} */
|
||||
//$after .= "\n";
|
||||
$str .= $before.PMA_SQP_FormatHTML_colorize($arr[$i]).$after;
|
||||
}
|
||||
$after .= "\n";
|
||||
*/
|
||||
$str .= $before . PMA_SQP_formatHTML_colorize($arr[$i]) . $after;
|
||||
} // end for
|
||||
$str .= '</span>';
|
||||
|
||||
return $str;
|
||||
}
|
||||
} // end of the "PMA_SQP_formatHtml()" function
|
||||
|
||||
function PMA_SQP_BuildCssRule($classname,$property,$value)
|
||||
|
||||
function PMA_SQP_buildCssRule($classname, $property, $value)
|
||||
{
|
||||
return '.'.$classname.' { '.$property.': '.$value.'; } '."\n";
|
||||
}
|
||||
return '.' . $classname . ' { ' . $property . ': ' . $value . '; } ' . "\n";
|
||||
} // end of the "PMA_SQP_buildCssRule()" function
|
||||
|
||||
function PMA_SQP_BuildCssData()
|
||||
|
||||
function PMA_SQP_buildCssData()
|
||||
{
|
||||
global $cfg;
|
||||
|
||||
$css_string = '';
|
||||
foreach($cfg['SQP']['fmtColor'] as $key => $col) {
|
||||
$css_string .= PMA_SQP_BuildCssRule('syntax_'.$key, 'color', $col);
|
||||
while (list($key, $col) = each($cfg['SQP']['fmtColor'])) {
|
||||
$css_string .= PMA_SQP_buildCssRule('syntax_' . $key, 'color', $col);
|
||||
}
|
||||
for($i = 0; $i < 8; $i++) {
|
||||
$css_string .= PMA_SQP_BuildCssRule('syntax_indent'.$i, 'margin-left', ($i * $cfg['SQP']['fmtInd']).$cfg['SQP']['fmtIndUnit']);
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
$css_string .= PMA_SQP_buildCssRule('syntax_indent' . $i, 'margin-left', ($i * $cfg['SQP']['fmtInd']) . $cfg['SQP']['fmtIndUnit']);
|
||||
}
|
||||
|
||||
return $css_string;
|
||||
|
||||
}
|
||||
} // end of the "PMA_SQP_buildCssData()" function
|
||||
|
||||
|
||||
function PMA_SQP_FormatNone($arr)
|
||||
function PMA_SQP_formatNone($arr)
|
||||
{
|
||||
$formattedSQL = htmlspecialchars($arr['raw']);
|
||||
$formattedSQL = ereg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $formattedSQL);
|
||||
return $formattedSQL;
|
||||
}
|
||||
$formatted_sql = htmlspecialchars($arr['raw']);
|
||||
$formatted_sql = ereg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $formatted_sql);
|
||||
|
||||
function PMA_SQP_FormatText($arr)
|
||||
return $formatted_sql;
|
||||
} // end of the "PMA_SQP_formatNone()" function
|
||||
|
||||
|
||||
function PMA_SQP_formatText($arr)
|
||||
{
|
||||
/**
|
||||
* TODO WRITE THIS!
|
||||
*/
|
||||
return PMA_SQP_FormatNone($arr);
|
||||
}
|
||||
return PMA_SQP_formatNone($arr);
|
||||
} // end of the "PMA_SQP_formatText()" function
|
||||
|
||||
} // $__PMA_SQP_LIB__
|
||||
|
@@ -28,7 +28,7 @@ if (!defined('PMA_STR_LIB_INCLUDED')) {
|
||||
*
|
||||
* @return boolean whether the needle is in the haystack or not
|
||||
*/
|
||||
function PMA_STR_StrInStr($needle, $haystack)
|
||||
function PMA_STR_strInStr($needle, $haystack)
|
||||
{
|
||||
// strpos($haystack, $needle) !== FALSE
|
||||
// return (is_integer(strpos($haystack, $needle)));
|
||||
@@ -45,7 +45,7 @@ if (!defined('PMA_STR_LIB_INCLUDED')) {
|
||||
*
|
||||
* @return boolean whether the character is escaped or not
|
||||
*/
|
||||
function PMA_STR_charIsEscaped($string, $pos, $start=0)
|
||||
function PMA_STR_charIsEscaped($string, $pos, $start = 0)
|
||||
{
|
||||
$len = strlen($string);
|
||||
// Base case:
|
||||
@@ -67,7 +67,7 @@ if (!defined('PMA_STR_LIB_INCLUDED')) {
|
||||
}
|
||||
|
||||
return $escaped;
|
||||
} // end of the "PMA_STR_strInStr()" function
|
||||
} // end of the "PMA_STR_charIsEscaped()" function
|
||||
|
||||
|
||||
/**
|
||||
@@ -79,10 +79,10 @@ if (!defined('PMA_STR_LIB_INCLUDED')) {
|
||||
*
|
||||
* @return boolean whether the number is in the range or not
|
||||
*/
|
||||
function PMA_STR_NumberInRangeInclusive($num, $lower, $upper)
|
||||
function PMA_STR_numberInRangeInclusive($num, $lower, $upper)
|
||||
{
|
||||
return (($num >= $lower) && ($num <= $upper));
|
||||
} // end of the "PMA_STR_NumberInRangeInclusive()" function
|
||||
} // end of the "PMA_STR_numberInRangeInclusive()" function
|
||||
|
||||
|
||||
/**
|
||||
@@ -92,16 +92,16 @@ if (!defined('PMA_STR_LIB_INCLUDED')) {
|
||||
*
|
||||
* @return boolean whether the character is a digit or not
|
||||
*
|
||||
* @see PMA_STR_NumberInRangeInclusive()
|
||||
* @see PMA_STR_numberInRangeInclusive()
|
||||
*/
|
||||
function PMA_STR_IsDigit($c)
|
||||
function PMA_STR_isDigit($c)
|
||||
{
|
||||
$ord_zero = 48; //ord('0');
|
||||
$ord_nine = 57; //ord('9');
|
||||
$ord_c = ord($c);
|
||||
|
||||
return PMA_STR_NumberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
|
||||
} // end of the "PMA_STR_IsDigit()" function
|
||||
return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
|
||||
} // end of the "PMA_STR_isDigit()" function
|
||||
|
||||
|
||||
/**
|
||||
@@ -111,9 +111,9 @@ if (!defined('PMA_STR_LIB_INCLUDED')) {
|
||||
*
|
||||
* @return boolean whether the character is an hexadecimal digit or not
|
||||
*
|
||||
* @see PMA_STR_NumberInRangeInclusive()
|
||||
* @see PMA_STR_numberInRangeInclusive()
|
||||
*/
|
||||
function PMA_STR_IsHexDigit($c)
|
||||
function PMA_STR_isHexDigit($c)
|
||||
{
|
||||
$ord_Aupper = 65; //ord('A');
|
||||
$ord_Fupper = 70; //ord('F');
|
||||
@@ -123,10 +123,10 @@ if (!defined('PMA_STR_LIB_INCLUDED')) {
|
||||
$ord_nine = 57; //ord('9');
|
||||
$ord_c = ord($c);
|
||||
|
||||
return (PMA_STR_NumberInRangeInclusive($ord_c, $ord_zero, $ord_nine)
|
||||
|| PMA_STR_NumberInRangeInclusive($ord_c, $ord_Aupper, $ord_Fupper)
|
||||
|| PMA_STR_NumberInRangeInclusive($ord_c, $ord_Alower, $ord_Flower));
|
||||
} // end of the "PMA_STR_IsHexDigit()" function
|
||||
return (PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine)
|
||||
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_Aupper, $ord_Fupper)
|
||||
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_Alower, $ord_Flower));
|
||||
} // end of the "PMA_STR_isHexDigit()" function
|
||||
|
||||
|
||||
/**
|
||||
@@ -137,16 +137,16 @@ if (!defined('PMA_STR_LIB_INCLUDED')) {
|
||||
* @return boolean whether the character is an upper alphabetic one or
|
||||
* not
|
||||
*
|
||||
* @see PMA_STR_NumberInRangeInclusive()
|
||||
* @see PMA_STR_numberInRangeInclusive()
|
||||
*/
|
||||
function PMA_STR_IsUpper($c)
|
||||
function PMA_STR_isUpper($c)
|
||||
{
|
||||
$ord_zero = 65; //ord('A');
|
||||
$ord_nine = 90; //ord('Z');
|
||||
$ord_c = ord($c);
|
||||
|
||||
return PMA_STR_NumberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
|
||||
} // end of the "PMA_STR_IsUpper()" function
|
||||
return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
|
||||
} // end of the "PMA_STR_isUpper()" function
|
||||
|
||||
|
||||
/**
|
||||
@@ -157,16 +157,16 @@ if (!defined('PMA_STR_LIB_INCLUDED')) {
|
||||
* @return boolean whether the character is a lower alphabetic one or
|
||||
* not
|
||||
*
|
||||
* @see PMA_STR_NumberInRangeInclusive()
|
||||
* @see PMA_STR_numberInRangeInclusive()
|
||||
*/
|
||||
function PMA_STR_IsLower($c)
|
||||
function PMA_STR_isLower($c)
|
||||
{
|
||||
$ord_zero = 97; //ord('a');
|
||||
$ord_nine = 122; //ord('z');
|
||||
$ord_c = ord($c);
|
||||
|
||||
return PMA_STR_NumberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
|
||||
} // end of the "PMA_STR_IsLower()" function
|
||||
return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
|
||||
} // end of the "PMA_STR_isLower()" function
|
||||
|
||||
|
||||
/**
|
||||
@@ -176,13 +176,13 @@ if (!defined('PMA_STR_LIB_INCLUDED')) {
|
||||
*
|
||||
* @return boolean whether the character is an alphabetic one or not
|
||||
*
|
||||
* @see PMA_STR_IsUpper()
|
||||
* @see PMA_STR_IsLower()
|
||||
* @see PMA_STR_isUpper()
|
||||
* @see PMA_STR_isLower()
|
||||
*/
|
||||
function PMA_STR_IsAlpha($c)
|
||||
function PMA_STR_isAlpha($c)
|
||||
{
|
||||
return (PMA_STR_IsUpper($c) || PMA_STR_IsLower($c));
|
||||
} // end of the "PMA_STR_IsAlpha()" function
|
||||
return (PMA_STR_isUpper($c) || PMA_STR_isLower($c));
|
||||
} // end of the "PMA_STR_isAlpha()" function
|
||||
|
||||
|
||||
/**
|
||||
@@ -192,14 +192,14 @@ if (!defined('PMA_STR_LIB_INCLUDED')) {
|
||||
*
|
||||
* @return boolean whether the character is an alphanumeric one or not
|
||||
*
|
||||
* @see PMA_STR_IsUpper()
|
||||
* @see PMA_STR_IsLower()
|
||||
* @see PMA_STR_IsDigit()
|
||||
* @see PMA_STR_isUpper()
|
||||
* @see PMA_STR_isLower()
|
||||
* @see PMA_STR_isDigit()
|
||||
*/
|
||||
function PMA_STR_IsAlnum($c)
|
||||
function PMA_STR_isAlnum($c)
|
||||
{
|
||||
return (PMA_STR_IsUpper($c) || PMA_STR_IsLower($c) || PMA_STR_IsDigit($c));
|
||||
} // end of the "PMA_STR_IsAlnum()" function
|
||||
return (PMA_STR_isUpper($c) || PMA_STR_isLower($c) || PMA_STR_isDigit($c));
|
||||
} // end of the "PMA_STR_isAlnum()" function
|
||||
|
||||
|
||||
/**
|
||||
@@ -209,9 +209,9 @@ if (!defined('PMA_STR_LIB_INCLUDED')) {
|
||||
*
|
||||
* @return boolean whether the character is a space one or not
|
||||
*
|
||||
* @see PMA_STR_NumberInRangeInclusive()
|
||||
* @see PMA_STR_numberInRangeInclusive()
|
||||
*/
|
||||
function PMA_STR_IsSpace($c)
|
||||
function PMA_STR_isSpace($c)
|
||||
{
|
||||
$ord_space = 32; //ord(' ')
|
||||
$ord_tab = 9; //ord('\t')
|
||||
@@ -219,8 +219,8 @@ if (!defined('PMA_STR_LIB_INCLUDED')) {
|
||||
$ord_c = ord($c);
|
||||
|
||||
return (($ord_c == $ord_space)
|
||||
|| PMA_STR_NumberInRangeInclusive($ord_c, $ord_tab, $ord_CR));
|
||||
} // end of the "PMA_STR_IsSpace()" function
|
||||
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_tab, $ord_CR));
|
||||
} // end of the "PMA_STR_isSpace()" function
|
||||
|
||||
|
||||
/**
|
||||
@@ -231,14 +231,14 @@ if (!defined('PMA_STR_LIB_INCLUDED')) {
|
||||
*
|
||||
* @return boolean whether the character is an SQL identifier or not
|
||||
*
|
||||
* @see PMA_STR_IsAlnum()
|
||||
* @see PMA_STR_isAlnum()
|
||||
*/
|
||||
function PMA_STR_IsSqlIdentifier($c, $dot_is_valid = FALSE)
|
||||
function PMA_STR_isSqlIdentifier($c, $dot_is_valid = FALSE)
|
||||
{
|
||||
return (PMA_STR_IsAlnum($c)
|
||||
return (PMA_STR_isAlnum($c)
|
||||
|| ($c == '_') || ($c == '$')
|
||||
|| (($dot_is_valid != FALSE) && ($c == '.')));
|
||||
} // end of the "PMA_STR_IsSqlIdentifier()" function
|
||||
} // end of the "PMA_STR_isSqlIdentifier()" function
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -311,7 +311,6 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<tr>
|
||||
<td>Slovenian</td>
|
||||
<td>
|
||||
|
Reference in New Issue
Block a user