From 9278aaeb178ad2b7a43c7710e169d81c8ccbd07e Mon Sep 17 00:00:00 2001 From: Robin Johnson Date: Wed, 7 Aug 2002 05:47:13 +0000 Subject: [PATCH] * libraries/sqlparser.lib.php3: - Converted code to use $str* variables - BUG() code cleaned up (PMA_SQP_BUG, PMA_SQP_throwError) - More PHP3 compatibility --- libraries/sqlparser.lib.php3 | 91 +++++++++++++++++++++++++++--------- 1 file changed, 69 insertions(+), 22 deletions(-) diff --git a/libraries/sqlparser.lib.php3 b/libraries/sqlparser.lib.php3 index 8437253ab..ba78122b3 100644 --- a/libraries/sqlparser.lib.php3 +++ b/libraries/sqlparser.lib.php3 @@ -61,6 +61,58 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { } // end if... else... + function PMA_SQP_throwError($message,$sql) + { + $debugstr = ''; + $debugstr .= 'ERROR: ' . $message . "\n"; + $debugstr .= 'SQL: ' . $sql; + + echo $GLOBALS['strSQLParserUserError'] . "
\n
" . $debugstr . "
"; + + flush(); + if (PMA_PHP_INT_VERSION >= 42000 && @function_exists('ob_flush')) { + ob_flush(); + } + + } + + function PMA_SQP_BUG($message,$sql) + { + + $debugstr = ''; + $debugstr .= 'ERROR: ' . $message . "\n"; + $debugstr .= 'CVS: $Id$' . "\n"; + $debugstr .= 'MySQL: '.PMA_MYSQL_STR_VERSION . "\n"; + $debugstr .= 'USR OS,AGENT,VER: ' . PMA_USR_OS . ' ' . PMA_USR_BROWSER_AGENT . ' ' . PMA_USR_BROWSER_VER . "\n"; + $debugstr .= 'PMA: ' . PMA_VERSION . "\n"; + $debugstr .= 'PHP VER,OS: ' . PMA_PHP_STR_VERSION . ' ' . PHP_OS . "\n"; + $debugstr .= 'SQL: ' . $sql; + $encodedstr = $debugstr; + if (PMA_PHP_INT_VERSION >= 40001 && @function_exists('gzcompress')) { + $encodedstr = gzcompress($debugstr, 9); + } + $encodedstr = nl2br(chunk_split(base64_encode($encodedstr))); + + echo $GLOBALS['strSQLParserBugMessage'] . "
\n" + . '----' . $GLOBALS['strBeginCut'] .'----' . "
\n" + . $encodedstr . "\n" + . '----' . $GLOBALS['strEndCut'] .'----' . "
\n"; + + flush(); + if (PMA_PHP_INT_VERSION >= 42000 && @function_exists('ob_flush')) { + ob_flush(); + } + + echo '----' . $GLOBALS['strBeginRaw'] .'----' . "
"
+             . $debugstr
+             . '
----' . $GLOBALS['strEndRaw'] .'----' . "
\n"; + + flush(); + if (PMA_PHP_INT_VERSION >= 42000 && @function_exists('ob_flush')) { + ob_flush(); + } + } + function PMA_SQP_parse($sql) { global $cfg; @@ -168,7 +220,9 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { $pos = strpos(' ' . $sql, $quotetype, $oldpos + 1) - 1; // ($pos === FALSE) if ($pos < 0) { - trigger_error('Syntax: Unclosed quote (' . $quotetype . ') at ' . $startquotepos); + $debugstr = $GLOBALS['strSQPBugUnclosedQuote'] . ' @ ' . $startquotepos. "\n" + . 'STR: ' . $quotetype; + PMA_SQP_throwError($debugstr,$sql); return; } @@ -288,7 +342,9 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { $count2--; $punct_data = substr($sql, $count1, $count2 - $count1); } else { - trigger_error('Syntax: Unknown punctation string (' . $punct_data . ') at ' . $count1); + $debugstr = $GLOBALS['strSQPBugUnknownPunctation'] . ' @ ' . $count1 . "\n" + . 'STR: ' . $punct_data; + PMA_SQP_throwError($debugstr,$sql); return; } PMA_SQP_arrayAdd($sql_array, 'punct', $punct_data, $arraysize); @@ -322,7 +378,9 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { $is_float_digit = TRUE; continue; } else { - trigger_error('Syntax: Invalid Identifer (' . substr($sql, $count1, $count2 - $count1) . ') at ' . $count1); + $debugstr = $GLOBALS['strSQPBugInvalidIdentifer'] . ' @ ' . $count1 . "\n" + . 'STR: ' . substr($sql, $count1, $count2 - $count1); + PMA_SQP_throwError($debugstr,$sql); return; } } @@ -376,25 +434,14 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { // DEBUG $count2++; - echo "\n" . '

' . "\n"; - echo 'You seem to have found a bug in the SQL parser.
Please submit a bug report with the data chunk below:
' . "\n" . '--BEGIN CUT--
' . "\n"; - $debugstr = '$Id$
' . "\n"; - $debugstr .= 'Why did we get here? ' . $count1 . ' ' . $count2 . ' ' . $len . '
' . "\n"; - $debugstr .= 'Leftover: ' . substr($sql, $count1, $count2 - $count1) . '
' . "\n"; - $debugstr .= 'A: ' . $count1 . ' ' . $count2 . '
' . "\n"; - $debugstr .= 'SQL: ' . $sql; - if (PMA_PHP_INT_VERSION >= 40001 && @function_exists('gzcompress')) { - $debugstr = gzcompress($debugstr, 9); - } - $encodedstr = nl2br(chunk_split(base64_encode($debugstr))); - echo $encodedstr . "\n"; - echo '---END CUT---

' . "\n\n"; - echo '

' . "\n"; - flush(); - if (PMA_PHP_INT_VERSION >= 42000 && @function_exists('ob_flush')) { - ob_flush(); - } - die(); + +// $debugstr .= + $debugstr = 'C1 C2 LEN:' . $count1 . ' ' . $count2 . ' ' . $len . "\n" + . 'STR: ' . substr($sql, $count1, $count2 - $count1) . "\n"; + PMA_SQP_BUG($debugstr,$sql); + + return; + } // end while ($count2 < $len)