diff --git a/ChangeLog b/ChangeLog index 05bafe86d..e09179367 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,11 @@ phpMyAdmin - Changelog $Id$ $Source$ +2002-07-25 Loïc Chapeaux + * 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 * new lang: slovenian, thanks to Kositer Uros (urosh) diff --git a/Documentation.html b/Documentation.html index 36aa0cd6e..2b41c79dc 100755 --- a/Documentation.html +++ b/Documentation.html @@ -2465,8 +2465,8 @@ Kristof Hamann, Thomas Kl Girish Nair, David Nordenberg, Bernard M. Piller, Laurent Haas, "Sakamoto", Yuval Sarna, www.securereality.com.au, Alvar Soome, Siu Sun, Peter Svec, Michael Tacelosky, Rachim Tamsjadi, -Kositer Uros, Luís V., Martijn W. van der Lee, Algis Vainauskas, -Daniel Villanueva, Vinay, Ignacio Vazquez-Abrams, Chee Wai, Jakub Wilk, +Kositer Uros, Luís V., Martijn W. van der Lee, Algis Vainauskas, +Daniel Villanueva, Vinay, Ignacio Vazquez-Abrams, Chee Wai, Jakub Wilk, Thomas Michael Winningham, Vilius Zigmantas. diff --git a/config.inc.php3 b/config.inc.php3 index 7230d5197..cb2d18745 100755 --- a/config.inc.php3 +++ b/config.inc.php3 @@ -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 */ @@ -290,25 +292,26 @@ $cfg['SQP']['enable'] = TRUE; // Totally turn off the SQL Parser ( $cfg['SQP']['fmtType'] = 'html'; // Pretty-printing style to use on queries (html, none) $cfg['SQP']['fmtInd'] = '1'; // Amount to indent each level (floats ok) $cfg['SQP']['fmtIndUnit'] = 'em'; // Units for indenting each level (CSS Types - {em,px,pt}) -$cfg['SQP']['fmtColor'] = array( // Syntax colouring data - 'comment' => '#808000', - 'digit' => 'inherit', - 'digit_hex' => 'teal', - 'digit_integer' => 'teal', - 'digit_float' => 'aqua', - 'punct' => 'fuchsia', - 'alpha' => 'inherit', - 'alpha_columnType' => '#FF9900', +$cfg['SQP']['fmtColor'] = array( // Syntax colouring data + 'comment' => '#808000', + 'digit' => 'inherit', + 'digit_hex' => 'teal', + 'digit_integer' => 'teal', + 'digit_float' => 'aqua', + 'punct' => 'fuchsia', + 'alpha' => 'inherit', + 'alpha_columnType' => '#FF9900', 'alpha_columnAttrib' => '#0000FF', 'alpha_reservedWord' => '#990099', 'alpha_functionName' => '#FF0000', - 'alpha_identifier' => 'black', - 'alpha_variable' => '#800000', - 'quote' => '#008000', - 'quote_double' => 'inherit', - 'quote_single' => 'inherit', - 'quote_backtick' => 'inherit' - ); + 'alpha_identifier' => 'black', + 'alpha_variable' => '#800000', + 'quote' => '#008000', + '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! */ diff --git a/header.inc.php3 b/header.inc.php3 index 8800cefc2..5a5ecf369 100755 --- a/header.inc.php3 +++ b/header.inc.php3 @@ -94,7 +94,7 @@ a.h1:visited {font-family: ; font-size: ; font-size: ; font-weight: bold; color: #FF0000} a.drop:link {font-family: ; color: #ff0000} a.drop:visited {font-family: ; color: #ff0000} -a.drop:hover {font-family: ; color: #ffffff; background-color:#ff0000; text-decoration:none} +a.drop:hover {font-family: ; color: #ffffff; background-color:#ff0000; text-decoration: none} .nav {font-family: ; color: #000000} .warning {font-family: ; 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: ;} +.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 {} //--> diff --git a/libraries/common.lib.php3 b/libraries/common.lib.php3 index 4a58ed327..4e2596e03 100644 --- a/libraries/common.lib.php3 +++ b/libraries/common.lib.php3 @@ -168,14 +168,14 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} /** * String handling */ - include('./libraries/string.lib.php3'); + include('./libraries/string.lib.php3'); + + /** + * SQL Parser data and code + */ + include('./libraries/sqlparser.data.php3'); + include('./libraries/sqlparser.lib.php3'); - /** - * SQL Parser data and code - */ - include('./libraries/sqlparser.data.php3'); - include('./libraries/sqlparser.lib.php3'); - // If zlib output compression is set in the php configuration file, no // output buffering should be run if (PMA_PHP_INT_VERSION < 40000 @@ -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 * @@ -249,39 +249,38 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} * * @access public * - * @author Robin Johnson + * @author Robin Johnson */ - 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 '

'. $GLOBALS['strError'] . '

' . "\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 '

' . "\n" . '

' . "\n" - . ' ' . PMA_format_sql($ParsedSQL) . "\n" + . ' ' . PMA_formatSql($parsed_sql) . "\n" . '

' . "\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 = '";
' . "\n" . ' $sql .= "'; - } /* else if ($cfg['UseSyntaxColoring'] == FALSE) { - $new_line = '
' . "\n"; - } */ +// } else if ($cfg['UseSyntaxColoring'] == FALSE) { +// $new_line = '
' . "\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 '";'; diff --git a/libraries/sqlparser.data.php3 b/libraries/sqlparser.data.php3 index f3287503b..e198c3d20 100644 --- a/libraries/sqlparser.data.php3 +++ b/libraries/sqlparser.data.php3 @@ -1,22 +1,22 @@ * http://www.orbis-terrarum.net/?l=people.robbat2 * - * This data is used by the SQL Parser to recognize keywords - * - * It has been extracted from the lex.h file in the MySQL BK tree - * (around 4.0.2) as well as the MySQL documentation. + * This data is used by the SQL Parser to recognize keywords * + * 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__ - ?> diff --git a/libraries/sqlparser.lib.php3 b/libraries/sqlparser.lib.php3 index 4d086664a..07f247531 100644 --- a/libraries/sqlparser.lib.php3 +++ b/libraries/sqlparser.lib.php3 @@ -1,12 +1,13 @@ * http://www.orbis-terrarum.net/?l=people.robbat2 * - * These functions define an SQL parser system, capable of understanding and + * These functions define an SQL parser system, capable of understanding and * extracting data from a MySQL type SQL query. * * The basic procedure for using the new SQL parser: @@ -14,82 +15,83 @@ * 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 '' at the moment.) - * */ if (!defined('PMA_SQP_LIB_INCLUDED')) { define('PMA_SQP_LIB_INCLUDED', 1); - /** * Include the string libarry as we use it heavily */ include('./libraries/string.lib.php3'); - + /** * Include data for the SQL Parser */ 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 ); + + $t = $timer; + $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; - - // if the SQL parser is disabled - // just return the original query string - if($cfg['SQP']['enable'] == FALSE) { - echo 'FALSE'; + 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) { + // Debug : echo 'FALSE'; return $sql; } - + $len = strlen($sql); if ($len == 0) { return array(); } - - $sql_array = array(); - $sql_array['raw'] = $sql; - $count1 = 0; - $count2 = 0; - $punct_queryend = ';'; - $punct_qualifier = '.'; - $punct_listsep = ','; - $punct_level_plus = '('; - $punct_level_minus = ')'; - $digit_floatdecimal = '.'; - $digit_hexset = 'x'; - $bracket_list = '()[]{}'; - $allpunct_list = '-,;:!?/.^~\*&%+<=>|'; - $allpunct_list_pair = array ( + + $sql_array = array(); + $sql_array['raw'] = $sql; + $count1 = 0; + $count2 = 0; + $punct_queryend = ';'; + $punct_qualifier = '.'; + $punct_listsep = ','; + $punct_level_plus = '('; + $punct_level_minus = ')'; + $digit_floatdecimal = '.'; + $digit_hexset = 'x'; + $bracket_list = '()[]{}'; + $allpunct_list = '-,;:!?/.^~\*&%+<=>|'; + $allpunct_list_pair = array ( 0 => '!=', 1 => '&&', 2 => ':=', @@ -101,153 +103,157 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { 8 => '>>', 9 => '||', ); - $allpunct_list_pair_size = 10; //count($allpunct_list_pair); - $quote_list = "\'\"\`"; - $arraysize = 0; - while($count2 < $len) { - $c = $sql[$count2]; + $quote_list = "\'\"\`"; + $arraysize = 0; + + 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] == ' '))) { + // ANSI style -- + 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) { - case '#': - $type = 'mysql'; - case '-': + $pos = 0; + $type = 'bad'; + switch ($c) { + case '#': + $type = 'mysql'; + case '-': $type = 'ansi'; - $pos = strpos($sql,"\n",$count2); + $pos = strpos($sql, "\n", $count2); break; - case '/': + case '/': $type = 'c'; - $pos = strpos($sql,"*/",$count2); - $pos += 2; + $pos = strpos($sql, '*/', $count2); + $pos += 2; break; - default: + default: break; - } + } // end switch $count2 = ($pos < $count2) ? $len : $pos; - $str = substr($sql,$count1,$count2-$count1); - PMA_SQP_ArrayAdd ( $sql_array, 'comment_'.$type, $str, $arraysize); - continue; - } + $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)) { - $startquotepos = $count2; - $quotetype = $c; + // Checks for something inside quotation marks + if (PMA_STR_strInStr($c, $quote_list)) { + $startquotepos = $count2; + $quotetype = $c; $count2++; - $escaped = FALSE; + $escaped = FALSE; $escaped_escaped = FALSE; - $pos = $count2; - $oldpos = 0; + $pos = $count2; + $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 = $pos; $count2++; - $type = 'quote_'; - switch($quotetype) { - case "'": - $type .= 'single'; + $type = 'quote_'; + switch ($quotetype) { + case '\'': + $type .= 'single'; break; - case "\"": + case '"': $type .= 'double'; break; - case "`": - $type .= 'backtick'; + case '`': + $type .= 'backtick'; break; - default: + 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,'([{')) { + $type_type = ''; + if (PMA_STR_strInStr($c, '([{')) { $type_type = 'open'; - } else { + } else { $type_type = 'close'; } - $type_style = ''; - if (PMA_STR_StrInStr($c,'()')) { + + $type_style = ''; + if (PMA_STR_strInStr($c, '()')) { $type_style = 'round'; - } elseif (PMA_STR_StrInStr($c,'[]')) { + } elseif (PMA_STR_strInStr($c, '[]')) { $type_style = 'square'; - } else { + } 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 ) { - $t_suffix = ''; - switch($punct_data) { + // Special case, sometimes, althought two characters are + // adjectent directly, they ACTUALLY need to be seperate + if ($l == 1) { + $t_suffix = ''; + switch ($punct_data) { case $punct_queryend: - $t_suffix = '_queryend'; + $t_suffix = '_queryend'; break; case $punct_qualifier: - $t_suffix = '_qualifier'; + $t_suffix = '_qualifier'; break; case $punct_listsep: $t_suffix = '_listsep'; @@ -255,194 +261,196 @@ 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 - $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 = '*') { - $count2 = $count1 + 1; + 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 = '*')) { + $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); - } else { - trigger_error('Syntax: Unknown punctation string ('.$punct_data.') at '.$count1); + $punct_data = substr($sql, $count1, $count2 - $count1); + } else { + trigger_error('Syntax: Unknown punctation string (' . $punct_data . ') at ' . $count1); return; } - PMA_SQP_ArrayAdd ( $sql_array, 'punct', $punct_data, $arraysize); - continue; - } + PMA_SQP_arrayAdd($sql_array, 'punct', $punct_data, $arraysize); + continue; + } // end if... else if... else continue; } - //check 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; - if ($is_HexDigit) { + // Checks for alpha + if (PMA_STR_isSqlIdentifier($c, FALSE) || ($c == '@')) { + $count2 ++; + $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_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); + } else { + 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; + } else { + $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; + } else { + $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) { - $type = 'digit'; - if ($is_FloatDigit) { + $type = ''; + if ($is_digit) { + $type = 'digit'; + 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 { + } 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.
Please submit a bug report with the data chunk below:
--BEGIN CUT--
'; - $debugstr = '$Id$
'; - $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; - $encodedstr = nl2br(chunk_split(base64_encode(gzcompress($debugstr,9)))); - echo $encodedstr; - echo '---END CUT---
'; - //$decodedstr = str_replace('
','', base64_decode(gzuncompress($encodedstr))); - $decodedstr = gzuncompress(base64_decode(str_replace('
','',$encodedstr))); - echo $decodedstr; + 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; + $encodedstr = nl2br(chunk_split(base64_encode(gzcompress($debugstr, 9)))); + echo $encodedstr . "\n"; + echo '---END CUT---

' . "\n\n"; + //$decodedstr = str_replace('
', '', base64_decode(gzuncompress($encodedstr))); + $decodedstr = gzuncompress(base64_decode(str_replace('
', '', $encodedstr))); + echo $decodedstr . "\n"; + echo '

' . "\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']; - $t_prev = NULL; - $t_cur = NULL; + $t_prev = NULL; + $t_cur = NULL; } - 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']; - } else { + 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']; + } 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_cur == 'alpha') { + $t_suffix = '_identifier'; + $d_cur_upper = strtoupper($sql_array[$i]['data']); + 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 } $sql_array[$i]['type'] .= $t_suffix; } - } + } - // 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) - { - $result = array(); - $size = $arr['len']; - $subresult = array( - 'querytype' => '', - 'list_db' => array(), - 'list_tbl' => array(), + function PMA_SQP_analyze($arr) + { + $result = array(); + $size = $arr['len']; + $subresult = array( + 'querytype' => '', + 'list_db' => array(), + 'list_tbl' => array(), 'list_tbl_alias' => array(), - 'list_col' => array(), + 'list_col' => array(), 'list_col_alias' => array(), ); $subresult_empty = $subresult; - $seek_queryend = FALSE; + $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,9 +480,9 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { } } - switch($arr[$i]['type']) { + switch ($arr[$i]['type']) { case 'punct_queryend': - $result[] = $subresult; + $result[] = $subresult; $subresult = $subresult_empty; break; case 'alpha_reservedWord': @@ -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; - } + 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,32 +517,35 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { echo '
';
         print_r($result);
         echo '
'; - } + } // end of the "PMA_SQP_analyze()" function - function PMA_SQP_FormatHTML_colorize($arr) - { - $i = strpos($arr['type'],'_'); - $class = ''; + + function PMA_SQP_formatHtml_colorize($arr) + { + $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 ''.htmlspecialchars($arr['data']).''; - } + $class .= 'syntax_' . $arr['type']; - function PMA_SQP_FormatHTML($arr) - { - $str = ''; - $indent = 0; - $bracketlevel = 0; - $functionlevel = 0; - $infunction = FALSE; - $space_punct_listsep = ' '; - $space_punct_listsep_functionName = ' '; - // $space_alpha_reservedWord = '
'."\n"; - $space_alpha_reservedWord = ' '; - $keywordsWithBrackets = array( + return '' . htmlspecialchars($arr['data']) . ''; + } // end of the "PMA_SQP_formatHtml_colorize()" function + + + function PMA_SQP_formatHtml($arr) + { + $str = ''; + $indent = 0; + $bracketlevel = 0; + $functionlevel = 0; + $infunction = FALSE; + $space_punct_listsep = ' '; + $space_punct_listsep_function_name = ' '; + // $space_alpha_reserved_word = '
'."\n"; + $space_alpha_reserved_word = ' '; + $keywords_with_brackets = array( 'INDEX', 'INTO', 'KEY', @@ -543,18 +554,18 @@ 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(); + $typearr = array(); if ($arraysize >= 0) { $typearr[0] = NULL; $typearr[1] = NULL; @@ -562,112 +573,114 @@ 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 = ''; + $after = ''; $indent = 0; - // array_shift($typearr); + // array_shift($typearr); /* 0 prev2 1 prev 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); + } else { + //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 = '
'; - $before = ''; +// $after = '
'; + $before = ''; break; 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 { + $after .= ' '; + } else { $indent++; - $after .= '
'; + $after .= '
'; } break; case 'alpha_identifier': - if(($typearr[1] == 'punct_qualifier') || ($typearr[3] == 'punct_qualifier')) { - $after = ''; - $before = ''; + if (($typearr[1] == 'punct_qualifier') || ($typearr[3] == 'punct_qualifier')) { + $after = ''; + $before = ''; } - if($typearr[3] == 'alpha_columnType') { - $after .= ' '; + if ($typearr[3] == 'alpha_columnType') { + $after .= ' '; } - break; + break; case 'punct_qualifier': - $before = ''; - $after = ''; + $before = ''; + $after = ''; break; case 'punct_listsep': if ($infunction == TRUE) { - $after .= $space_punct_listsep_functionName; - } else { - $after .= $space_punct_listsep; + $after .= $space_punct_listsep_function_name; + } else { + $after .= $space_punct_listsep; } break; case 'punct_queryend': - if ( ($typearr[3] != 'comment_mysql')&& ($typearr[3] != 'comment_ansi') ) { - $after .= '
'; - $after .= '
'; + if (($typearr[3] != 'comment_mysql') && ($typearr[3] != 'comment_ansi')) { + $after .= '
'; + $after .= '
'; } - $space_punct_listsep = ' '; - $space_punct_listsep_functionName = ' '; - $space_alpha_reservedWord = ' '; + $space_punct_listsep = ' '; + $space_punct_listsep_function_name = ' '; + $space_alpha_reserved_word = ' '; break; case 'comment_mysql': case 'comment_ansi': - $after .= '
'; + $after .= '
'; break; case 'punct': - $after .= ' '; - $before .= ' '; + $after .= ' '; + $before .= ' '; break; case 'punct_bracket_close_round': $bracketlevel--; if ($infunction == TRUE) { $functionlevel--; - $after .= ' '; - } else { + $after .= ' '; + } else { $indent--; - $before .= '
'; + $before .= '
'; } - $infunction = ($functionlevel > 0) ? TRUE : FALSE; + $infunction = ($functionlevel > 0) ? TRUE : FALSE; break; case 'alpha_columnType': if ($typearr[3] == 'alpha_columnAttrib') { - $after .= ' '; + $after .= ' '; } 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; + $upper = $arr[$i]['data']; + 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 .= ' '; + $before .= ' '; } - switch($upper) { + switch ($upper) { case 'CREATE': - $space_punct_listsep = '
'; - $space_alpha_reservedWord = ' '; + $space_punct_listsep = '
'; + $space_alpha_reserved_word = ' '; break; case 'EXPLAIN': case 'DESCRIBE': @@ -680,96 +693,105 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { case 'TRUNCATE': case 'ANALYZE': case 'ANALYSE': - $space_punct_listsep = '
'; - $space_alpha_reservedWord = ' '; + $space_punct_listsep = '
'; + $space_alpha_reserved_word = ' '; break; case 'INSERT': case 'REPLACE': - $space_punct_listsep = '
'; - $space_alpha_reservedWord = '
'; + $space_punct_listsep = '
'; + $space_alpha_reserved_word = '
'; break; case 'VALUES': - $space_punct_listsep = ' '; - $space_alpha_reservedWord = '
'; + $space_punct_listsep = ' '; + $space_alpha_reserved_word = '
'; break; case 'SELECT': - $space_punct_listsep = ' '; - $space_alpha_reservedWord = '
'; + $space_punct_listsep = ' '; + $space_alpha_reserved_word = '
'; 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') { - $after .= ' '; + 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') { - $after .= ' '; + $before .= ' '; + if ($infunction && $typearr[3] == 'punct_bracket_close_round') { + $after .= ' '; } break; case 'quote_backtick': if ($typearr[3] != 'punct_qualifier') { - $after .= ' '; + $after .= ' '; } if ($typearr[1] != 'punct_qualifier') { - $before .= ' '; + $before .= ' '; } break; default: break; + } // end switch ($typearr[2]) + +/* + if ($typearr[3] != 'punct_qualifier') { + $after .= ' '; } - -/* 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 .= '
'; + 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); + + $css_string = ''; + 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) - { - $formattedSQL = htmlspecialchars($arr['raw']); - $formattedSQL = ereg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $formattedSQL); - return $formattedSQL; - } - - function PMA_SQP_FormatText($arr) - { + function PMA_SQP_formatNone($arr) + { + $formatted_sql = htmlspecialchars($arr['raw']); + $formatted_sql = ereg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $formatted_sql); + + 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__ diff --git a/libraries/string.lib.php3 b/libraries/string.lib.php3 index 8656aa7d9..9df06d241 100644 --- a/libraries/string.lib.php3 +++ b/libraries/string.lib.php3 @@ -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,18 +209,18 @@ 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') - $ord_CR = 13; //ord('\n') - $ord_c = ord($c); + $ord_tab = 9; //ord('\t') + $ord_CR = 13; //ord('\n') + $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 /** diff --git a/translators.html b/translators.html index c1c2e30a0..1fe0e81d9 100644 --- a/translators.html +++ b/translators.html @@ -311,7 +311,6 @@ - Slovenian