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