Merge branch 'master' of git://phpmyadmin.git.sourceforge.net/gitroot/phpmyadmin/phpmyadmin
This commit is contained in:
commit
fdcedf728c
@ -206,7 +206,8 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
*/
|
||||
function PMA_SQP_parse($sql)
|
||||
{
|
||||
static $PMA_SQPdata_column_attrib, $PMA_SQPdata_reserved_word, $PMA_SQPdata_column_type;
|
||||
static $PMA_SQPdata_column_attrib, $PMA_SQPdata_reserved_word;
|
||||
static $PMA_SQPdata_column_type;
|
||||
static $PMA_SQPdata_function_name, $PMA_SQPdata_forbidden_word;
|
||||
global $mysql_charsets, $mysql_collations_flat;
|
||||
|
||||
@ -221,11 +222,21 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
|
||||
// Create local hashtables
|
||||
if (!isset($PMA_SQPdata_column_attrib_cnt)) {
|
||||
$PMA_SQPdata_column_attrib = array_flip($GLOBALS['PMA_SQPdata_column_attrib']);
|
||||
$PMA_SQPdata_function_name = array_flip($GLOBALS['PMA_SQPdata_function_name']);
|
||||
$PMA_SQPdata_reserved_word = array_flip($GLOBALS['PMA_SQPdata_reserved_word']);
|
||||
$PMA_SQPdata_forbidden_word = array_flip($GLOBALS['PMA_SQPdata_forbidden_word']);
|
||||
$PMA_SQPdata_column_type = array_flip($GLOBALS['PMA_SQPdata_column_type']);
|
||||
$PMA_SQPdata_column_attrib = array_flip(
|
||||
$GLOBALS['PMA_SQPdata_column_attrib']
|
||||
);
|
||||
$PMA_SQPdata_function_name = array_flip(
|
||||
$GLOBALS['PMA_SQPdata_function_name']
|
||||
);
|
||||
$PMA_SQPdata_reserved_word = array_flip(
|
||||
$GLOBALS['PMA_SQPdata_reserved_word']
|
||||
);
|
||||
$PMA_SQPdata_forbidden_word = array_flip(
|
||||
$GLOBALS['PMA_SQPdata_forbidden_word']
|
||||
);
|
||||
$PMA_SQPdata_column_type = array_flip(
|
||||
$GLOBALS['PMA_SQPdata_column_type']
|
||||
);
|
||||
}
|
||||
|
||||
$sql_array = array();
|
||||
@ -270,7 +281,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
$this_was_quote = false;
|
||||
|
||||
while ($count2 < $len) {
|
||||
$c = $GLOBALS['PMA_substr']($sql, $count2, 1);
|
||||
$c = PMA_substr($sql, $count2, 1);
|
||||
$count1 = $count2;
|
||||
|
||||
$previous_was_space = $this_was_space;
|
||||
@ -292,7 +303,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
}
|
||||
|
||||
// Checks for white space
|
||||
if ($GLOBALS['PMA_STR_isSpace']($c)) {
|
||||
if (PMA_STR_isSpace($c)) {
|
||||
$this_was_space = true;
|
||||
$count2++;
|
||||
continue;
|
||||
@ -302,10 +313,11 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
// MySQL style #
|
||||
// C style /* */
|
||||
// ANSI style --
|
||||
$next_c = PMA_substr($sql, $count2 + 1, 1);
|
||||
if (($c == '#')
|
||||
|| (($count2 + 1 < $len) && ($c == '/') && ($GLOBALS['PMA_substr']($sql, $count2 + 1, 1) == '*'))
|
||||
|| (($count2 + 2 == $len) && ($c == '-') && ($GLOBALS['PMA_substr']($sql, $count2 + 1, 1) == '-'))
|
||||
|| (($count2 + 2 < $len) && ($c == '-') && ($GLOBALS['PMA_substr']($sql, $count2 + 1, 1) == '-') && (($GLOBALS['PMA_substr']($sql, $count2 + 2, 1) <= ' ')))) {
|
||||
|| (($count2 + 1 < $len) && ($c == '/') && ($next_c == '*'))
|
||||
|| (($count2 + 2 == $len) && ($c == '-') && ($next_c == '-'))
|
||||
|| (($count2 + 2 < $len) && ($c == '-') && ($next_c == '-') && ((PMA_substr($sql, $count2 + 2, 1) <= ' ')))) {
|
||||
$count2++;
|
||||
$pos = 0;
|
||||
$type = 'bad';
|
||||
@ -314,24 +326,24 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
$type = 'mysql';
|
||||
case '-':
|
||||
$type = 'ansi';
|
||||
$pos = $GLOBALS['PMA_strpos']($sql, "\n", $count2);
|
||||
$pos = PMA_strpos($sql, "\n", $count2);
|
||||
break;
|
||||
case '/':
|
||||
$type = 'c';
|
||||
$pos = $GLOBALS['PMA_strpos']($sql, '*/', $count2);
|
||||
$pos = PMA_strpos($sql, '*/', $count2);
|
||||
$pos += 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} // end switch
|
||||
$count2 = ($pos < $count2) ? $len : $pos;
|
||||
$str = $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1);
|
||||
$str = PMA_substr($sql, $count1, $count2 - $count1);
|
||||
PMA_SQP_arrayAdd($sql_array, 'comment_' . $type, $str, $arraysize);
|
||||
continue;
|
||||
} // end if
|
||||
|
||||
// Checks for something inside quotation marks
|
||||
if ($GLOBALS['PMA_strpos']($quote_list, $c) !== false) {
|
||||
if (PMA_strpos($quote_list, $c) !== false) {
|
||||
$startquotepos = $count2;
|
||||
$quotetype = $c;
|
||||
$count2++;
|
||||
@ -341,7 +353,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
$oldpos = 0;
|
||||
do {
|
||||
$oldpos = $pos;
|
||||
$pos = $GLOBALS['PMA_strpos'](' ' . $sql, $quotetype, $oldpos + 1) - 1;
|
||||
$pos = PMA_strpos(' ' . $sql, $quotetype, $oldpos + 1) - 1;
|
||||
// ($pos === false)
|
||||
if ($pos < 0) {
|
||||
if ($c == '`') {
|
||||
@ -355,7 +367,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
*
|
||||
* SELECT * FROM `table`
|
||||
*/
|
||||
$pos_quote_separator = $GLOBALS['PMA_strpos'](' ' . $sql, $GLOBALS['sql_delimiter'], $oldpos + 1) - 1;
|
||||
$pos_quote_separator = PMA_strpos(' ' . $sql, $GLOBALS['sql_delimiter'], $oldpos + 1) - 1;
|
||||
if ($pos_quote_separator < 0) {
|
||||
$len += 1;
|
||||
$sql .= '`';
|
||||
@ -363,7 +375,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
$pos = $len;
|
||||
} else {
|
||||
$len += 1;
|
||||
$sql = $GLOBALS['PMA_substr']($sql, 0, $pos_quote_separator) . '`' . $GLOBALS['PMA_substr']($sql, $pos_quote_separator);
|
||||
$sql = PMA_substr($sql, 0, $pos_quote_separator) . '`' . PMA_substr($sql, $pos_quote_separator);
|
||||
$sql_array['raw'] = $sql;
|
||||
$pos = $pos_quote_separator;
|
||||
}
|
||||
@ -389,7 +401,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
if (($pos < $len) && PMA_STR_charIsEscaped($sql, $pos) && $c != '`') {
|
||||
$pos ++;
|
||||
continue;
|
||||
} elseif (($pos + 1 < $len) && ($GLOBALS['PMA_substr']($sql, $pos, 1) == $quotetype) && ($GLOBALS['PMA_substr']($sql, $pos + 1, 1) == $quotetype)) {
|
||||
} elseif (($pos + 1 < $len) && (PMA_substr($sql, $pos, 1) == $quotetype) && (PMA_substr($sql, $pos + 1, 1) == $quotetype)) {
|
||||
$pos = $pos + 2;
|
||||
continue;
|
||||
} else {
|
||||
@ -416,27 +428,27 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
default:
|
||||
break;
|
||||
} // end switch
|
||||
$data = $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1);
|
||||
$data = PMA_substr($sql, $count1, $count2 - $count1);
|
||||
PMA_SQP_arrayAdd($sql_array, $type, $data, $arraysize);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Checks for brackets
|
||||
if ($GLOBALS['PMA_strpos']($bracket_list, $c) !== false) {
|
||||
if (PMA_strpos($bracket_list, $c) !== false) {
|
||||
// All bracket tokens are only one item long
|
||||
$this_was_bracket = true;
|
||||
$count2++;
|
||||
$type_type = '';
|
||||
if ($GLOBALS['PMA_strpos']('([{', $c) !== false) {
|
||||
if (PMA_strpos('([{', $c) !== false) {
|
||||
$type_type = 'open';
|
||||
} else {
|
||||
$type_type = 'close';
|
||||
}
|
||||
|
||||
$type_style = '';
|
||||
if ($GLOBALS['PMA_strpos']('()', $c) !== false) {
|
||||
if (PMA_strpos('()', $c) !== false) {
|
||||
$type_style = 'round';
|
||||
} elseif ($GLOBALS['PMA_strpos']('[]', $c) !== false) {
|
||||
} elseif (PMA_strpos('[]', $c) !== false) {
|
||||
$type_style = 'square';
|
||||
} else {
|
||||
$type_style = 'curly';
|
||||
@ -463,7 +475,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
if (PMA_STR_isSqlIdentifier($c, false)
|
||||
|| $c == '@'
|
||||
|| ($c == '.'
|
||||
&& $GLOBALS['PMA_STR_isDigit']($GLOBALS['PMA_substr']($sql, $count2 + 1, 1))
|
||||
&& PMA_STR_isDigit(PMA_substr($sql, $count2 + 1, 1))
|
||||
&& ($previous_was_space || $previous_was_bracket || $previous_was_listsep))) {
|
||||
|
||||
/* DEBUG
|
||||
@ -481,8 +493,8 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
$is_identifier = $previous_was_punct;
|
||||
$is_sql_variable = $c == '@' && ! $previous_was_quote;
|
||||
$is_user = $c == '@' && $previous_was_quote;
|
||||
$is_digit = !$is_identifier && !$is_sql_variable && $GLOBALS['PMA_STR_isDigit']($c);
|
||||
$is_hex_digit = $is_digit && $c == '0' && $count2 < $len && $GLOBALS['PMA_substr']($sql, $count2, 1) == 'x';
|
||||
$is_digit = !$is_identifier && !$is_sql_variable && PMA_STR_isDigit($c);
|
||||
$is_hex_digit = $is_digit && $c == '0' && $count2 < $len && PMA_substr($sql, $count2, 1) == 'x';
|
||||
$is_float_digit = $c == '.';
|
||||
$is_float_digit_exponent = false;
|
||||
|
||||
@ -495,7 +507,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
echo '</pre>';
|
||||
*/
|
||||
|
||||
// Nijel: Fast skip is especially needed for huge BLOB data, requires PHP at least 4.3.0:
|
||||
// Fast skip is especially needed for huge BLOB data
|
||||
if ($is_hex_digit) {
|
||||
$count2++;
|
||||
$pos = strspn($sql, '0123456789abcdefABCDEF', $count2);
|
||||
@ -511,8 +523,8 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
unset($pos);
|
||||
}
|
||||
|
||||
while (($count2 < $len) && PMA_STR_isSqlIdentifier($GLOBALS['PMA_substr']($sql, $count2, 1), ($is_sql_variable || $is_digit))) {
|
||||
$c2 = $GLOBALS['PMA_substr']($sql, $count2, 1);
|
||||
while (($count2 < $len) && PMA_STR_isSqlIdentifier(PMA_substr($sql, $count2, 1), ($is_sql_variable || $is_digit))) {
|
||||
$c2 = PMA_substr($sql, $count2, 1);
|
||||
if ($is_sql_variable && ($c2 == '.')) {
|
||||
$count2++;
|
||||
continue;
|
||||
@ -540,7 +552,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
$is_float_digit = false;
|
||||
}
|
||||
}
|
||||
if (($is_hex_digit && PMA_STR_isHexDigit($c2)) || ($is_digit && $GLOBALS['PMA_STR_isDigit']($c2))) {
|
||||
if (($is_hex_digit && PMA_STR_isHexDigit($c2)) || ($is_digit && PMA_STR_isDigit($c2))) {
|
||||
$count2++;
|
||||
continue;
|
||||
} else {
|
||||
@ -552,7 +564,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
} // end while
|
||||
|
||||
$l = $count2 - $count1;
|
||||
$str = $GLOBALS['PMA_substr']($sql, $count1, $l);
|
||||
$str = PMA_substr($sql, $count1, $l);
|
||||
|
||||
$type = '';
|
||||
if ($is_digit || $is_float_digit || $is_hex_digit) {
|
||||
@ -577,15 +589,15 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
}
|
||||
|
||||
// Checks for punct
|
||||
if ($GLOBALS['PMA_strpos']($allpunct_list, $c) !== false) {
|
||||
while (($count2 < $len) && $GLOBALS['PMA_strpos']($allpunct_list, $GLOBALS['PMA_substr']($sql, $count2, 1)) !== false) {
|
||||
if (PMA_strpos($allpunct_list, $c) !== false) {
|
||||
while (($count2 < $len) && PMA_strpos($allpunct_list, PMA_substr($sql, $count2, 1)) !== false) {
|
||||
$count2++;
|
||||
}
|
||||
$l = $count2 - $count1;
|
||||
if ($l == 1) {
|
||||
$punct_data = $c;
|
||||
} else {
|
||||
$punct_data = $GLOBALS['PMA_substr']($sql, $count1, $l);
|
||||
$punct_data = PMA_substr($sql, $count1, $l);
|
||||
}
|
||||
|
||||
// Special case, sometimes, althought two characters are
|
||||
@ -627,12 +639,12 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
if (($first == ',') || ($first == ';') || ($first == '.') || ($first == '*')) {
|
||||
$count2 = $count1 + 1;
|
||||
$punct_data = $first;
|
||||
} elseif (($last2 == '/*') || (($last2 == '--') && ($count2 == $len || $GLOBALS['PMA_substr']($sql, $count2, 1) <= ' '))) {
|
||||
} elseif (($last2 == '/*') || (($last2 == '--') && ($count2 == $len || PMA_substr($sql, $count2, 1) <= ' '))) {
|
||||
$count2 -= 2;
|
||||
$punct_data = $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1);
|
||||
$punct_data = PMA_substr($sql, $count1, $count2 - $count1);
|
||||
} elseif (($last == '-') || ($last == '+') || ($last == '!')) {
|
||||
$count2--;
|
||||
$punct_data = $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1);
|
||||
$punct_data = PMA_substr($sql, $count1, $count2 - $count1);
|
||||
/**
|
||||
* @todo for negation operator, split in 2 tokens ?
|
||||
* "select x&~1 from t"
|
||||
@ -655,7 +667,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
$count2++;
|
||||
|
||||
$debugstr = 'C1 C2 LEN: ' . $count1 . ' ' . $count2 . ' ' . $len . "\n"
|
||||
. 'STR: ' . $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1) . "\n";
|
||||
. 'STR: ' . PMA_substr($sql, $count1, $count2 - $count1) . "\n";
|
||||
PMA_SQP_bug($debugstr, $sql);
|
||||
return $sql_array;
|
||||
|
||||
@ -2062,7 +2074,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
*/
|
||||
function PMA_SQP_formatHtml_colorize($arr)
|
||||
{
|
||||
$i = $GLOBALS['PMA_strpos']($arr['type'], '_');
|
||||
$i = PMA_strpos($arr['type'], '_');
|
||||
$class = '';
|
||||
if ($i > 0) {
|
||||
$class = 'syntax_' . PMA_substr($arr['type'], 0, $i) . ' ';
|
||||
|
||||
@ -19,38 +19,22 @@ if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$GLOBALS['PMA_allow_mbstr'] = @function_exists('mb_strlen');
|
||||
$GLOBALS['PMA_allow_ctype'] = @extension_loaded('ctype');
|
||||
|
||||
if ($GLOBALS['PMA_allow_mbstr']) {
|
||||
mb_internal_encoding('utf-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load proper code for handling input.
|
||||
*/
|
||||
if ($GLOBALS['PMA_allow_mbstr']) {
|
||||
$GLOBALS['PMA_strpos'] = 'mb_strpos';
|
||||
$GLOBALS['PMA_substr'] = 'mb_substr';
|
||||
if (@function_exists('mb_strlen')) {
|
||||
mb_internal_encoding('utf-8');
|
||||
require './libraries/string_mb.lib.php';
|
||||
} else {
|
||||
$GLOBALS['PMA_strpos'] = 'strpos';
|
||||
$GLOBALS['PMA_substr'] = 'substr';
|
||||
require './libraries/string_native.lib.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Load ctype handler.
|
||||
*/
|
||||
if ($GLOBALS['PMA_allow_ctype']) {
|
||||
$GLOBALS['PMA_STR_isAlnum'] = 'ctype_alnum';
|
||||
$GLOBALS['PMA_STR_isDigit'] = 'ctype_digit';
|
||||
$GLOBALS['PMA_STR_isSpace'] = 'ctype_space';
|
||||
if (@extension_loaded('ctype')) {
|
||||
require './libraries/string_type_ctype.lib.php';
|
||||
} else {
|
||||
$GLOBALS['PMA_STR_isAlnum'] = 'PMA_STR_isAlnum';
|
||||
$GLOBALS['PMA_STR_isDigit'] = 'PMA_STR_isDigit';
|
||||
$GLOBALS['PMA_STR_isSpace'] = 'PMA_STR_isSpace';
|
||||
require './libraries/string_type_native.lib.php';
|
||||
}
|
||||
|
||||
@ -107,7 +91,7 @@ function PMA_STR_numberInRangeInclusive($num, $lower, $upper)
|
||||
*/
|
||||
function PMA_STR_isSqlIdentifier($c, $dot_is_valid = false)
|
||||
{
|
||||
return ($GLOBALS['PMA_STR_isAlnum']($c)
|
||||
return (PMA_STR_isAlnum($c)
|
||||
|| ($ord_c = ord($c)) && $ord_c >= 192 && $ord_c != 215 && $ord_c != 249
|
||||
|| $c == '_'
|
||||
|| $c == '$'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user