00001 <?php
00002
00003
00004
00038 if (!isset($is_minimum_common)) {
00039 $is_minimum_common = FALSE;
00040 }
00041
00042 if ($is_minimum_common == FALSE) {
00046 require_once('./libraries/string.lib.php');
00047
00051 require_once('./libraries/sqlparser.data.php');
00052 require_once('./libraries/mysql_charsets.lib.php');
00053 if (!isset($mysql_charsets)) {
00054 $mysql_charsets = array();
00055 $mysql_charsets_count = 0;
00056 $mysql_collations_flat = array();
00057 $mysql_collations_count = 0;
00058 }
00059
00060 if (!defined('DEBUG_TIMING')) {
00061 function PMA_SQP_arrayAdd(&$arr, $type, $data, &$arrsize)
00062 {
00063 $arr[] = array('type' => $type, 'data' => $data);
00064 $arrsize++;
00065 }
00066 } else {
00067 function PMA_SQP_arrayAdd(&$arr, $type, $data, &$arrsize)
00068 {
00069 global $timer;
00070
00071 $t = $timer;
00072 $arr[] = array('type' => $type, 'data' => $data , 'time' => $t);
00073 $timer = microtime();
00074 $arrsize++;
00075 }
00076 }
00077
00078
00084
00085 function PMA_SQP_resetError() {
00086 global $SQP_errorString;
00087 $SQP_errorString = '';
00088 unset($SQP_errorString);
00089 }
00090
00098
00099 function PMA_SQP_getErrorString() {
00100 global $SQP_errorString;
00101 return isset($SQP_errorString) ? $SQP_errorString : '';
00102 }
00103
00111
00112 function PMA_SQP_isError() {
00113 global $SQP_errorString;
00114 return isset($SQP_errorString) && !empty($SQP_errorString);
00115 }
00116
00126
00127 function PMA_SQP_throwError($message, $sql)
00128 {
00129
00130 global $SQP_errorString;
00131 $SQP_errorString = '<p>'.$GLOBALS['strSQLParserUserError'] . '</p>' . "\n"
00132 . '<pre>' . "\n"
00133 . 'ERROR: ' . $message . "\n"
00134 . 'SQL: ' . htmlspecialchars($sql) . "\n"
00135 . '</pre>' . "\n";
00136
00137 }
00138
00139
00148 function PMA_SQP_bug($message, $sql)
00149 {
00150 global $SQP_errorString;
00151 $debugstr = 'ERROR: ' . $message . "\n";
00152 $debugstr .= 'CVS: $Id: sqlparser.lib.php,v 2.6 2004/01/09 23:17:21 rabus Exp $' . "\n";
00153 $debugstr .= 'MySQL: '.PMA_MYSQL_STR_VERSION . "\n";
00154 $debugstr .= 'USR OS, AGENT, VER: ' . PMA_USR_OS . ' ' . PMA_USR_BROWSER_AGENT . ' ' . PMA_USR_BROWSER_VER . "\n";
00155 $debugstr .= 'PMA: ' . PMA_VERSION . "\n";
00156 $debugstr .= 'PHP VER,OS: ' . PMA_PHP_STR_VERSION . ' ' . PHP_OS . "\n";
00157 $debugstr .= 'LANG: ' . $GLOBALS['lang'] . "\n";
00158 $debugstr .= 'SQL: ' . htmlspecialchars($sql);
00159
00160 $encodedstr = $debugstr;
00161 if (@function_exists('gzcompress')) {
00162 $encodedstr = gzcompress($debugstr, 9);
00163 }
00164 $encodedstr = preg_replace("/(\015\012)|(\015)|(\012)/", '<br />' . "\n", chunk_split(base64_encode($encodedstr)));
00165
00166 $SQP_errorString .= $GLOBALS['strSQLParserBugMessage'] . '<br />' . "\n"
00167 . '----' . $GLOBALS['strBeginCut'] . '----' . '<br />' . "\n"
00168 . $encodedstr . "\n"
00169 . '----' . $GLOBALS['strEndCut'] . '----' . '<br />' . "\n";
00170
00171 $SQP_errorString .= '----' . $GLOBALS['strBeginRaw'] . '----<br />' . "\n"
00172 . '<pre>' . "\n"
00173 . $debugstr
00174 . '</pre>' . "\n"
00175 . '----' . $GLOBALS['strEndRaw'] . '----<br />' . "\n";
00176
00177 }
00178
00179
00203 function PMA_SQP_parse($sql)
00204 {
00205 global $cfg;
00206 global $PMA_SQPdata_column_attrib, $PMA_SQPdata_reserved_word, $PMA_SQPdata_column_type, $PMA_SQPdata_function_name,
00207 $PMA_SQPdata_column_attrib_cnt, $PMA_SQPdata_reserved_word_cnt, $PMA_SQPdata_column_type_cnt, $PMA_SQPdata_function_name_cnt;
00208 global $mysql_charsets, $mysql_collations_flat, $mysql_charsets_count, $mysql_collations_count;
00209
00210
00211 $sql = str_replace("\r\n", "\n", $sql);
00212 $sql = str_replace("\r", "\n", $sql);
00213
00214 $len = $GLOBALS['PMA_strlen']($sql);
00215 if ($len == 0) {
00216 return array();
00217 }
00218
00219 $sql_array = array();
00220 $sql_array['raw'] = $sql;
00221 $count1 = 0;
00222 $count2 = 0;
00223 $punct_queryend = ';';
00224 $punct_qualifier = '.';
00225 $punct_listsep = ',';
00226 $punct_level_plus = '(';
00227 $punct_level_minus = ')';
00228 $digit_floatdecimal = '.';
00229 $digit_hexset = 'x';
00230 $bracket_list = '()[]{}';
00231 $allpunct_list = '-,;:!?/.^~\*&%+<=>|';
00232 $allpunct_list_pair = array (
00233 0 => '!=',
00234 1 => '&&',
00235 2 => ':=',
00236 3 => '<<',
00237 4 => '<=',
00238 5 => '<=>',
00239 6 => '<>',
00240 7 => '>=',
00241 8 => '>>',
00242 9 => '||'
00243 );
00244 $allpunct_list_pair_size = 10;
00245 $quote_list = '\'"`';
00246 $arraysize = 0;
00247
00248 while ($count2 < $len) {
00249 $c = $sql[$count2];
00250 $count1 = $count2;
00251
00252 if (($c == "\n")) {
00253 $count2++;
00254 PMA_SQP_arrayAdd($sql_array, 'white_newline', '', $arraysize);
00255 continue;
00256 }
00257
00258 // Checks for white space
00259 if (PMA_STR_isSpace($c)) {
00260 $count2++;
00261 continue;
00262 }
00263
00264 // Checks for comment lines.
00265 // MySQL style #
00266 // C style /* */
00267 // ANSI style --
00268 if (($c == '#')
00269 || (($count2 + 1 < $len) && ($c == '/') && ($sql[$count2 + 1] == '*'))
00270 || (($count2 + 2 < $len) && ($c == '-') && ($sql[$count2 + 1] == '-') && (($sql[$count2 + 2] == ' ') || ($sql[$count2 + 2] == "\n")))) {
00271 $count2++;
00272 $pos = 0;
00273 $type = 'bad';
00274 switch ($c) {
00275 case '#':
00276 $type = 'mysql';
00277 case '-':
00278 $type = 'ansi';
00279 $pos = $GLOBALS['PMA_strpos']($sql, "\n", $count2);
00280 break;
00281 case '/':
00282 $type = 'c';
00283 $pos = $GLOBALS['PMA_strpos']($sql, '*/', $count2);
00284 $pos += 2;
00285 break;
00286 default:
00287 break;
00288 } // end switch
00289 $count2 = ($pos < $count2) ? $len : $pos;
00290 $str = $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1);
00291 PMA_SQP_arrayAdd($sql_array, 'comment_' . $type, $str, $arraysize);
00292 continue;
00293 } // end if
00294
00295 // Checks for something inside quotation marks
00296 if (PMA_STR_strInStr($c, $quote_list)) {
00297 $startquotepos = $count2;
00298 $quotetype = $c;
00299 $count2++;
00300 $escaped = FALSE;
00301 $escaped_escaped = FALSE;
00302 $pos = $count2;
00303 $oldpos = 0;
00304 do {
00305 $oldpos = $pos;
00306 $pos = $GLOBALS['PMA_strpos'](' ' . $sql, $quotetype, $oldpos + 1) - 1;
00307 // ($pos === FALSE)
00308 if ($pos < 0) {
00309 $debugstr = $GLOBALS['strSQPBugUnclosedQuote'] . ' @ ' . $startquotepos. "\n"
00310 . 'STR: ' . $quotetype;
00311 PMA_SQP_throwError($debugstr, $sql);
00312 return $sql;
00313 }
00314
00315 // If the quote is the first character, it can't be
00316 // escaped, so don't do the rest of the code
00317 if ($pos == 0) {
00318 break;
00319 }
00320
00321 // Checks for MySQL escaping using a \
00322 // And checks for ANSI escaping using the $quotetype character
00323 if (($pos < $len) && PMA_STR_charIsEscaped($sql, $pos)) {
00324 $pos ++;
00325 continue;
00326 } else if (($pos + 1 < $len) && ($sql[$pos] == $quotetype) && ($sql[$pos + 1] == $quotetype)) {
00327 $pos = $pos + 2;
00328 continue;
00329 } else {
00330 break;
00331 }
00332 } while ($len > $pos); // end do
00333
00334 $count2 = $pos;
00335 $count2++;
00336 $type = 'quote_';
00337 switch ($quotetype) {
00338 case '\'':
00339 $type .= 'single';
00340 break;
00341 case '"':
00342 $type .= 'double';
00343 break;
00344 case '`':
00345 $type .= 'backtick';
00346 break;
00347 default:
00348 break;
00349 }
00350 $data = $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1);
00351 PMA_SQP_arrayAdd($sql_array, $type, $data, $arraysize);
00352 continue;
00353 }
00354
00355
00356 if (PMA_STR_strInStr($c, $bracket_list)) {
00357
00358 $count2++;
00359 $type_type = '';
00360 if (PMA_STR_strInStr($c, '([{')) {
00361 $type_type = 'open';
00362 } else {
00363 $type_type = 'close';
00364 }
00365
00366 $type_style = '';
00367 if (PMA_STR_strInStr($c, '()')) {
00368 $type_style = 'round';
00369 } elseif (PMA_STR_strInStr($c, '[]')) {
00370 $type_style = 'square';
00371 } else {
00372 $type_style = 'curly';
00373 }
00374
00375 $type = 'punct_bracket_' . $type_type . '_' . $type_style;
00376 PMA_SQP_arrayAdd($sql_array, $type, $c, $arraysize);
00377 continue;
00378 }
00379
00380
00381 if (PMA_STR_strInStr($c, $allpunct_list)) {
00382 while (($count2 < $len) && PMA_STR_strInStr($sql[$count2], $allpunct_list)) {
00383 $count2++;
00384 }
00385 $l = $count2 - $count1;
00386 if ($l == 1) {
00387 $punct_data = $c;
00388 } else {
00389 $punct_data = $GLOBALS['PMA_substr']($sql, $count1, $l);
00390 }
00391
00392
00393
00394 if ($l == 1) {
00395 $t_suffix = '';
00396 switch ($punct_data) {
00397 case $punct_queryend:
00398 $t_suffix = '_queryend';
00399 break;
00400 case $punct_qualifier:
00401 $t_suffix = '_qualifier';
00402 break;
00403 case $punct_listsep:
00404 $t_suffix = '_listsep';
00405 break;
00406 default:
00407 break;
00408 }
00409 PMA_SQP_arrayAdd($sql_array, 'punct' . $t_suffix, $punct_data, $arraysize);
00410 }
00411 else if (PMA_STR_binarySearchInArr($punct_data, $allpunct_list_pair, $allpunct_list_pair_size)) {
00412
00413 PMA_SQP_arrayAdd($sql_array, 'punct', $punct_data, $arraysize);
00414 }
00415 else {
00416
00417 $first = $punct_data[0];
00418 $first2 = $punct_data[0] . $punct_data[1];
00419 $last2 = $punct_data[$l - 2] . $punct_data[$l - 1];
00420 $last = $punct_data[$l - 1];
00421 if (($first == ',') || ($first == ';') || ($first == '.') || ($first == '*')) {
00422 $count2 = $count1 + 1;
00423 $punct_data = $first;
00424 } else if (($last2 == '
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798 $words_ending_table_ref = array(
00799 'FOR',
00800 'GROUP',
00801 'HAVING',
00802 'LIMIT',
00803 'LOCK',
00804 'ORDER',
00805 'PROCEDURE',
00806 'UNION',
00807 'WHERE'
00808 );
00809 $words_ending_table_ref_cnt = 9;
00810
00811 $words_ending_clauses = array(
00812 'FOR',
00813 'LIMIT',
00814 'LOCK',
00815 'PROCEDURE',
00816 'UNION'
00817 );
00818 $words_ending_clauses_cnt = 5;
00819
00820
00821
00822
00823
00824 $supported_query_types = array(
00825 'SELECT'
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840 );
00841 $supported_query_types_cnt = count($supported_query_types);
00842
00843
00844
00845 for ($i = 0; $i < $size; $i++) {
00846
00847
00848
00849 if ($seek_queryend == TRUE) {
00850 if ($arr[$i]['type'] == 'punct_queryend') {
00851 $seek_queryend = FALSE;
00852 } else {
00853 continue;
00854 }
00855 }
00856
00857
00858
00859 if ($arr[$i]['type'] == 'punct_queryend') {
00860 $result[] = $subresult;
00861 $subresult = $subresult_empty;
00862 continue;
00863 }
00864
00865
00866 if ($arr[$i]['type'] == 'punct_bracket_open_round') {
00867 if ($in_extract) {
00868 $number_of_brackets_in_extract++;
00869 }
00870 }
00871
00872 if ($arr[$i]['type'] == 'punct_bracket_close_round') {
00873 if ($in_extract) {
00874 $number_of_brackets_in_extract--;
00875 if ($number_of_brackets_in_extract == 0) {
00876 $in_extract = FALSE;
00877 }
00878 }
00879 }
00880
00881 if ($arr[$i]['type'] == 'alpha_functionName') {
00882 $upper_data = strtoupper($arr[$i]['data']);
00883 if ($upper_data =='EXTRACT') {
00884 $in_extract = TRUE;
00885 $number_of_brackets_in_extract = 0;
00886 }
00887 }
00888
00889
00890 if ($arr[$i]['type'] == 'alpha_reservedWord') {
00891
00892 if ($subresult['querytype'] == '') {
00893 $subresult['querytype'] = strtoupper($arr[$i]['data']);
00894 }
00895
00896
00897 if (!PMA_STR_binarySearchInArr($subresult['querytype'], $supported_query_types, $supported_query_types_cnt)) {
00898
00899 $seek_queryend = TRUE;
00900 continue;
00901 }
00902
00903
00904 $upper_data = strtoupper($arr[$i]['data']);
00905
00906
00907 if ($upper_data == 'SELECT') {
00908 $seen_from = FALSE;
00909 $previous_was_identifier = FALSE;
00910 $current_select_expr = -1;
00911 $seen_end_of_table_ref = FALSE;
00912 }
00913
00914 if ($upper_data =='FROM' && !$in_extract) {
00915 $current_table_ref = -1;
00916 $seen_from = TRUE;
00917 $previous_was_identifier = FALSE;
00918 $save_table_ref = TRUE;
00919 }
00920
00921
00922
00923 }
00924
00925
00926 if (($arr[$i]['type'] == 'quote_backtick')
00927 || ($arr[$i]['type'] == 'quote_double')
00928 || ($arr[$i]['type'] == 'quote_single')
00929 || ($arr[$i]['type'] == 'alpha_identifier')) {
00930
00931 switch ($arr[$i]['type']) {
00932 case 'alpha_identifier':
00933 $identifier = $arr[$i]['data'];
00934 break;
00935
00936
00937
00938 case 'quote_backtick':
00939 $identifier = str_replace('`','',$arr[$i]['data']);
00940 break;
00941 case 'quote_double':
00942 $identifier = str_replace('"','',$arr[$i]['data']);
00943 break;
00944 case 'quote_single':
00945 $identifier = str_replace("'","",$arr[$i]['data']);
00946 break;
00947 }
00948
00949 if ($subresult['querytype'] == 'SELECT') {
00950 if (!$seen_from) {
00951 if ($previous_was_identifier && isset($chain)) {
00952
00953
00954
00955
00956
00957 $alias_for_select_expr = $identifier;
00958 } else {
00959 $chain[] = $identifier;
00960 $previous_was_identifier = TRUE;
00961
00962 }
00963 } else {
00964
00965 if ($save_table_ref && !$seen_end_of_table_ref) {
00966 if ($previous_was_identifier) {
00967
00968
00969 $alias_for_table_ref = $identifier;
00970 } else {
00971 $chain[] = $identifier;
00972 $previous_was_identifier = TRUE;
00973
00974 }
00975 }
00976 }
00977 }
00978 }
00979
00980
00981 if ($arr[$i]['type'] == 'punct_qualifier') {
00982
00983 $previous_was_identifier = FALSE;
00984 continue;
00985 }
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999 if (isset($chain) && !$seen_end_of_table_ref
01000 && ( (!$seen_from
01001 && $arr[$i]['type'] == 'punct_listsep')
01002 || ($arr[$i]['type'] == 'alpha_reservedWord' && $upper_data == 'FROM')) ) {
01003 $size_chain = count($chain);
01004 $current_select_expr++;
01005 $subresult['select_expr'][$current_select_expr] = array(
01006 'expr' => '',
01007 'alias' => '',
01008 'db' => '',
01009 'table_name' => '',
01010 'table_true_name' => '',
01011 'column' => ''
01012 );
01013
01014 if (!empty($alias_for_select_expr)) {
01015
01016 $subresult['select_expr'][$current_select_expr]['alias'] = $alias_for_select_expr;
01017 unset($alias_for_select_expr);
01018 }
01019
01020 $subresult['select_expr'][$current_select_expr]['column'] = $chain[$size_chain - 1];
01021 $subresult['select_expr'][$current_select_expr]['expr'] = $chain[$size_chain - 1];
01022
01023
01024 if ($size_chain > 1) {
01025 $subresult['select_expr'][$current_select_expr]['table_name'] = $chain[$size_chain - 2];
01026
01027 $subresult['select_expr'][$current_select_expr]['table_true_name'] = $chain[$size_chain - 2];
01028 $subresult['select_expr'][$current_select_expr]['expr']
01029 = $subresult['select_expr'][$current_select_expr]['table_name']
01030 . '.' . $subresult['select_expr'][$current_select_expr]['expr'];
01031 }
01032
01033
01034 if ($size_chain > 2) {
01035 $subresult['select_expr'][$current_select_expr]['db'] = $chain[$size_chain - 3];
01036 $subresult['select_expr'][$current_select_expr]['expr']
01037 = $subresult['select_expr'][$current_select_expr]['db']
01038 . '.' . $subresult['select_expr'][$current_select_expr]['expr'];
01039 }
01040 unset($chain);
01041
01042
01043 if (($arr[$i]['type'] == 'alpha_reservedWord')
01044 && ($upper_data != 'FROM')) {
01045 $previous_was_identifier = TRUE;
01046 }
01047
01048 }
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061 if (isset($chain) && $seen_from && $save_table_ref
01062 && ($arr[$i]['type'] == 'punct_listsep'
01063 || ($arr[$i]['type'] == 'alpha_reservedWord' && $upper_data!="AS")
01064 || $seen_end_of_table_ref
01065 || $i==$size-1 )) {
01066
01067 $size_chain = count($chain);
01068 $current_table_ref++;
01069 $subresult['table_ref'][$current_table_ref] = array(
01070 'expr' => '',
01071 'db' => '',
01072 'table_name' => '',
01073 'table_alias' => '',
01074 'table_true_name' => ''
01075 );
01076 if (!empty($alias_for_table_ref)) {
01077 $subresult['table_ref'][$current_table_ref]['table_alias'] = $alias_for_table_ref;
01078 unset($alias_for_table_ref);
01079 }
01080 $subresult['table_ref'][$current_table_ref]['table_name'] = $chain[$size_chain - 1];
01081
01082 $subresult['table_ref'][$current_table_ref]['table_true_name'] = $chain[$size_chain - 1];
01083 $subresult['table_ref'][$current_table_ref]['expr']
01084 = $subresult['table_ref'][$current_table_ref]['table_name'];
01085
01086 if ($size_chain > 1) {
01087 $subresult['table_ref'][$current_table_ref]['db'] = $chain[$size_chain - 2];
01088 $subresult['table_ref'][$current_table_ref]['expr']
01089 = $subresult['table_ref'][$current_table_ref]['db']
01090 . '.' . $subresult['table_ref'][$current_table_ref]['expr'];
01091 }
01092
01093
01094 $subresult['table_ref'][$current_table_ref]['expr']
01095 .= ' ' . $subresult['table_ref'][$current_table_ref]['table_alias'];
01096
01097 unset($chain);
01098 $previous_was_identifier = TRUE;
01099
01100
01101 }
01102
01103
01104
01105
01106
01107
01108 if (isset($current_table_ref) && ($seen_end_of_table_ref || $i == $size-1)) {
01109 for ($tr=0; $tr <= $current_table_ref; $tr++) {
01110 $alias = $subresult['table_ref'][$tr]['table_alias'];
01111 $truename = $subresult['table_ref'][$tr]['table_true_name'];
01112 for ($se=0; $se <= $current_select_expr; $se++) {
01113 if (!empty($alias) && $subresult['select_expr'][$se]['table_true_name']
01114 == $alias) {
01115 $subresult['select_expr'][$se]['table_true_name']
01116 = $truename;
01117 }
01118 }
01119
01120 }
01121 }
01122
01123
01124
01125
01126
01127 if (($arr[$i]['type'] != 'alpha_identifier')
01128 && ($arr[$i]['type'] != 'quote_double')
01129 && ($arr[$i]['type'] != 'quote_single')
01130 && ($arr[$i]['type'] != 'quote_backtick')) {
01131 $previous_was_identifier = FALSE;
01132 }
01133
01134
01135 if (($arr[$i]['type'] == 'alpha_reservedWord')
01136 && ($upper_data == 'AS')) {
01137 $previous_was_identifier = TRUE;
01138 }
01139
01140 if (($arr[$i]['type'] == 'alpha_reservedWord')
01141 && ($upper_data =='ON' || $upper_data =='USING')) {
01142 $save_table_ref = FALSE;
01143 }
01144
01145 if (($arr[$i]['type'] == 'alpha_reservedWord')
01146 && ($upper_data =='JOIN' || $upper_data =='FROM')) {
01147 $save_table_ref = TRUE;
01148 }
01149
01150
01151
01152 if (!$seen_end_of_table_ref) {
01153
01154
01155
01156 if (($i == $size-1)
01157 || ($arr[$i]['type'] == 'alpha_reservedWord'
01158 && PMA_STR_binarySearchInArr($upper_data, $words_ending_table_ref, $words_ending_table_ref_cnt))) {
01159 $seen_end_of_table_ref = TRUE;
01160
01161
01162
01163
01164 if (isset($save_table_ref) && $save_table_ref != FALSE) {
01165 $save_table_ref = TRUE;
01166 }
01167
01168 }
01169 }
01170
01171 if ($seen_end_of_table_ref) {
01172 $save_table_ref = FALSE;
01173 }
01174
01175 }
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209 if (isset($current_table_ref) && $current_table_ref > -1) {
01210 $subresult['queryflags']['select_from'] = 1;
01211 }
01212
01213 $seen_reserved_word = FALSE;
01214 $seen_group = FALSE;
01215 $seen_order = FALSE;
01216 $in_group_by = FALSE;
01217 $in_order_by = FALSE;
01218 $in_having = FALSE;
01219 $in_select_expr = FALSE;
01220 $in_where = FALSE;
01221 $in_from = FALSE;
01222
01223 for ($i = 0; $i < $size; $i++) {
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240 if ($arr[$i]['type'] == 'alpha_reservedWord') {
01241 $upper_data = strtoupper($arr[$i]['data']);
01242 if (!$seen_reserved_word) {
01243 $first_reserved_word = $upper_data;
01244 $subresult['querytype'] = $upper_data;
01245 $seen_reserved_word = TRUE;
01246
01247
01248
01249 if ($first_reserved_word=='DROP'
01250 || $first_reserved_word == 'DELETE'
01251 || $first_reserved_word == 'TRUNCATE') {
01252 $subresult['queryflags']['need_confirm'] = 1;
01253 }
01254
01255 if ($first_reserved_word=='SELECT'){
01256 $position_of_first_select = $i;
01257 }
01258
01259 } else {
01260 if ($upper_data=='DROP' && $first_reserved_word=='ALTER') {
01261 $subresult['queryflags']['need_confirm'] = 1;
01262 }
01263 }
01264
01265 if ($upper_data == 'SELECT') {
01266 $in_select_expr = TRUE;
01267 $select_expr_clause = '';
01268 }
01269 if ($upper_data == 'DISTINCT') {
01270 $subresult['queryflags']['distinct'] = 1;
01271 }
01272
01273 if ($upper_data == 'UNION') {
01274 $subresult['queryflags']['union'] = 1;
01275 }
01276
01277
01278 if ($upper_data == 'FROM' && isset($subresult['queryflags']['select_from']) && $subresult['queryflags']['select_from'] == 1) {
01279 $in_from = TRUE;
01280 $from_clause = '';
01281 $in_select_expr = FALSE;
01282 }
01283
01284
01285
01286
01287
01288
01289
01290
01291 if ($upper_data == 'GROUP') {
01292 $seen_group = TRUE;
01293 $seen_order = FALSE;
01294 $in_having = FALSE;
01295 $in_order_by = FALSE;
01296 $in_where = FALSE;
01297 $in_select_expr = FALSE;
01298 $in_from = FALSE;
01299 }
01300 if ($upper_data == 'ORDER') {
01301 $seen_order = TRUE;
01302 $seen_group = FALSE;
01303 $in_having = FALSE;
01304 $in_group_by = FALSE;
01305 $in_where = FALSE;
01306 $in_select_expr = FALSE;
01307 $in_from = FALSE;
01308 }
01309 if ($upper_data == 'HAVING') {
01310 $in_having = TRUE;
01311 $having_clause = '';
01312 $seen_group = FALSE;
01313 $seen_order = FALSE;
01314 $in_group_by = FALSE;
01315 $in_order_by = FALSE;
01316 $in_where = FALSE;
01317 $in_select_expr = FALSE;
01318 $in_from = FALSE;
01319 }
01320
01321 if ($upper_data == 'WHERE') {
01322 $in_where = TRUE;
01323 $where_clause = '';
01324 $where_clause_identifiers = array();
01325 $seen_group = FALSE;
01326 $seen_order = FALSE;
01327 $in_group_by = FALSE;
01328 $in_order_by = FALSE;
01329 $in_having = FALSE;
01330 $in_select_expr = FALSE;
01331 $in_from = FALSE;
01332 }
01333
01334 if ($upper_data == 'BY') {
01335 if ($seen_group) {
01336 $in_group_by = TRUE;
01337 $group_by_clause = '';
01338 }
01339 if ($seen_order) {
01340 $in_order_by = TRUE;
01341 $order_by_clause = '';
01342 }
01343 }
01344
01345
01346 if (PMA_STR_binarySearchInArr($upper_data, $words_ending_clauses, $words_ending_clauses_cnt)) {
01347
01348 $in_group_by = FALSE;
01349 $in_order_by = FALSE;
01350 $in_having = FALSE;
01351 $in_where = FALSE;
01352 $in_select_expr = FALSE;
01353 $in_from = FALSE;
01354 }
01355
01356 }
01357
01358
01359
01360
01361 $sep=' ';
01362 if ($arr[$i]['type'] == 'alpha_functionName') {
01363 $sep='';
01364 }
01365
01366 if ($in_select_expr && $upper_data != 'SELECT' && $upper_data != 'DISTINCT') {
01367 $select_expr_clause .= $arr[$i]['data'] . $sep;
01368 }
01369 if ($in_from && $upper_data != 'FROM') {
01370 $from_clause .= $arr[$i]['data'] . $sep;
01371 }
01372 if ($in_group_by && $upper_data != 'GROUP' && $upper_data != 'BY') {
01373 $group_by_clause .= $arr[$i]['data'] . $sep;
01374 }
01375 if ($in_order_by && $upper_data != 'ORDER' && $upper_data != 'BY') {
01376 $order_by_clause .= $arr[$i]['data'] . $sep;
01377 }
01378 if ($in_having && $upper_data != 'HAVING') {
01379 $having_clause .= $arr[$i]['data'] . $sep;
01380 }
01381 if ($in_where && $upper_data != 'WHERE') {
01382 $where_clause .= $arr[$i]['data'] . $sep;
01383
01384 if (($arr[$i]['type'] == 'quote_backtick')
01385 || ($arr[$i]['type'] == 'alpha_identifier')) {
01386 $where_clause_identifiers[] = $arr[$i]['data'];
01387 }
01388 }
01389
01390
01391 $upper_data='';
01392
01393 }
01394
01395
01396
01397
01398
01399
01400 $seen_foreign = FALSE;
01401 $seen_references = FALSE;
01402 $seen_constraint = FALSE;
01403 $in_bracket = FALSE;
01404 $foreign_key_number = -1;
01405
01406 for ($i = 0; $i < $size; $i++) {
01407
01408 if ($arr[$i]['type'] == 'alpha_reservedWord') {
01409 $upper_data = strtoupper($arr[$i]['data']);
01410
01411 if ($upper_data == 'CONSTRAINT') {
01412 $foreign_key_number++;
01413 $seen_foreign = FALSE;
01414 $seen_references = FALSE;
01415 $seen_constraint = TRUE;
01416 }
01417 if ($upper_data == 'FOREIGN') {
01418 $seen_foreign = TRUE;
01419 $seen_references = FALSE;
01420 $seen_constraint = FALSE;
01421 }
01422 if ($upper_data == 'REFERENCES') {
01423 $seen_foreign = FALSE;
01424 $seen_references = TRUE;
01425 $seen_constraint = FALSE;
01426 }
01427
01428
01429
01430
01431
01432
01433
01434
01435 if ($upper_data == 'ON') {
01436 unset($clause);
01437 if ($arr[$i+1]['type'] == 'alpha_reservedWord') {
01438 $second_upper_data = strtoupper($arr[$i+1]['data']);
01439 if ($second_upper_data == 'DELETE') {
01440 $clause = 'on_delete';
01441 }
01442 if ($second_upper_data == 'UPDATE') {
01443 $clause = 'on_update';
01444 }
01445 if (isset($clause)
01446 && ($arr[$i+2]['type'] == 'alpha_reservedWord'
01447
01448
01449
01450
01451
01452 || ($arr[$i+2]['type'] == 'alpha_identifier'
01453 && strtoupper($arr[$i+2]['data'])=='NO') )
01454 ) {
01455 $third_upper_data = strtoupper($arr[$i+2]['data']);
01456 if ($third_upper_data == 'CASCADE'
01457 || $third_upper_data == 'RESTRICT') {
01458 $value = $third_upper_data;
01459 } elseif ($third_upper_data == 'SET'
01460 || $third_upper_data == 'NO') {
01461 if ($arr[$i+3]['type'] == 'alpha_reservedWord') {
01462 $value = $third_upper_data . '_' . strtoupper($arr[$i+3]['data']);
01463 }
01464 }
01465 $foreign[$foreign_key_number][$clause] = $value;
01466 }
01467 }
01468 }
01469
01470 }
01471
01472 if ($arr[$i]['type'] == 'punct_bracket_open_round') {
01473 $in_bracket = TRUE;
01474 }
01475
01476 if ($arr[$i]['type'] == 'punct_bracket_close_round') {
01477 $in_bracket = FALSE;
01478 if ($seen_references) {
01479 $seen_references = FALSE;
01480 }
01481 }
01482
01483 if (($arr[$i]['type'] == 'quote_backtick')) {
01484
01485 if ($seen_constraint) {
01486
01487 $identifier = str_replace('`','',$arr[$i]['data']);
01488 $foreign[$foreign_key_number]['constraint'] = $identifier;
01489 }
01490 if ($seen_foreign && $in_bracket) {
01491
01492 $identifier = str_replace('`','',$arr[$i]['data']);
01493 $foreign[$foreign_key_number]['index_list'][] = $identifier;
01494 }
01495
01496 if ($seen_references) {
01497 $identifier = str_replace('`','',$arr[$i]['data']);
01498 if ($in_bracket) {
01499 $foreign[$foreign_key_number]['ref_index_list'][] = $identifier;
01500 } else {
01501
01502 $db_table = explode('.',$identifier);
01503 if (isset($db_table[1])) {
01504 $foreign[$foreign_key_number]['ref_db_name'] = $db_table[0];
01505 $foreign[$foreign_key_number]['ref_table_name'] = $db_table[1];
01506 } else {
01507 $foreign[$foreign_key_number]['ref_table_name'] = $db_table[0];
01508 }
01509 }
01510 }
01511 }
01512 }
01513
01514 if (isset($foreign)) {
01515 $subresult['foreign_keys'] = $foreign;
01516 }
01517
01518
01519 if (isset($select_expr_clause)) {
01520 $subresult['select_expr_clause'] = $select_expr_clause;
01521 }
01522 if (isset($from_clause)) {
01523 $subresult['from_clause'] = $from_clause;
01524 }
01525 if (isset($group_by_clause)) {
01526 $subresult['group_by_clause'] = $group_by_clause;
01527 }
01528 if (isset($order_by_clause)) {
01529 $subresult['order_by_clause'] = $order_by_clause;
01530 }
01531 if (isset($having_clause)) {
01532 $subresult['having_clause'] = $having_clause;
01533 }
01534 if (isset($where_clause)) {
01535 $subresult['where_clause'] = $where_clause;
01536 }
01537 if (isset($where_clause_identifiers)) {
01538 $subresult['where_clause_identifiers'] = $where_clause_identifiers;
01539 }
01540
01541 if (isset($position_of_first_select)) {
01542 $subresult['position_of_first_select'] = $position_of_first_select;
01543 }
01544
01545
01546
01547
01548 if ($subresult['querytype'] != '') {
01549 $result[] = $subresult;
01550 }
01551 return $result;
01552 }
01553
01554
01564 function PMA_SQP_formatHtml_colorize($arr)
01565 {
01566 $i = $GLOBALS['PMA_strpos']($arr['type'], '_');
01567 $class = '';
01568 if ($i > 0) {
01569 $class = 'syntax_' . $GLOBALS['PMA_substr']($arr['type'], 0, $i) . ' ';
01570 }
01571
01572 $class .= 'syntax_' . $arr['type'];
01573
01574
01575
01576
01577
01578 return '<span class="' . $class . '">' . htmlspecialchars($arr['data']) . '</span>';
01579 }
01580
01581
01594 function PMA_SQP_formatHtml($arr, $mode='color', $start_token=0,
01595 $number_of_tokens=-1)
01596 {
01597
01598 if (PMA_SQP_isError()) {
01599 return $arr;
01600 }
01601
01602 if (!is_array($arr)) {
01603 return $arr;
01604 }
01605
01606 switch ($mode) {
01607 case 'color':
01608 $str = '<span class="syntax">';
01609 $html_line_break = '<br />';
01610 break;
01611 case 'query_only':
01612 $str = '';
01613 $html_line_break = "\n";
01614 break;
01615 case 'text':
01616 $str = '';
01617 $html_line_break = '<br />';
01618 break;
01619 }
01620 $indent = 0;
01621 $bracketlevel = 0;
01622 $functionlevel = 0;
01623 $infunction = FALSE;
01624 $space_punct_listsep = ' ';
01625 $space_punct_listsep_function_name = ' ';
01626
01627 $space_alpha_reserved_word = ' ';
01628
01629 $keywords_with_brackets_1before = array(
01630 'INDEX',
01631 'KEY',
01632 'ON',
01633 'USING'
01634 );
01635 $keywords_with_brackets_1before_cnt = 4;
01636
01637 $keywords_with_brackets_2before = array(
01638 'IGNORE',
01639 'INDEX',
01640 'INTO',
01641 'KEY',
01642 'PRIMARY',
01643 'PROCEDURE',
01644 'REFERENCES',
01645 'UNIQUE',
01646 'USE'
01647 );
01648
01649 $keywords_with_brackets_2before_cnt = 9;
01650
01651
01652 $keywords_no_newline = array(
01653 'AND',
01654 'AS',
01655 'ASC',
01656 'DESC',
01657 'DISTINCT',
01658 'HOUR',
01659 'INTERVAL',
01660 'IS',
01661 'NOT',
01662 'NULL',
01663 'ON',
01664 'OR'
01665 );
01666 $keywords_no_newline_cnt = 12;
01667
01668
01669 $keywords_priv_list = array(
01670 'GRANT',
01671 'REVOKE'
01672 );
01673 $keywords_priv_list_cnt = 2;
01674
01675 if ($number_of_tokens == -1) {
01676 $arraysize = $arr['len'];
01677 } else {
01678 $arraysize = $number_of_tokens;
01679 }
01680 $typearr = array();
01681 if ($arraysize >= 0) {
01682 $typearr[0] = '';
01683 $typearr[1] = '';
01684 $typearr[2] = '';
01685
01686 $typearr[3] = $arr[$start_token]['type'];
01687 }
01688
01689 $in_priv_list = FALSE;
01690 for ($i = $start_token; $i < $arraysize; $i++) {
01691
01692 $before = '';
01693 $after = '';
01694 $indent = 0;
01695
01696
01697
01698
01699
01700
01701
01702 if (($i + 1) < $arraysize) {
01703
01704 $typearr[4] = $arr[$i + 1]['type'];
01705 } else {
01706
01707 $typearr[4] = '';
01708 }
01709
01710 for ($j=0; $j<4; $j++) {
01711 $typearr[$j] = $typearr[$j + 1];
01712 }
01713
01714 switch ($typearr[2]) {
01715 case 'white_newline':
01716
01717 $before = '';
01718 break;
01719 case 'punct_bracket_open_round':
01720 $bracketlevel++;
01721 $infunction = FALSE;
01722
01723 if (($typearr[1] == 'alpha_functionName') || ($typearr[1] == 'alpha_columnType') || ($typearr[1] == 'punct')
01724 || ($typearr[3] == 'digit_integer') || ($typearr[3] == 'digit_hex') || ($typearr[3] == 'digit_float')
01725 || (($typearr[0] == 'alpha_reservedWord')
01726 && PMA_STR_binarySearchInArr(strtoupper($arr[$i - 2]['data']), $keywords_with_brackets_2before, $keywords_with_brackets_2before_cnt))
01727 || (($typearr[1] == 'alpha_reservedWord')
01728 && PMA_STR_binarySearchInArr(strtoupper($arr[$i - 1]['data']), $keywords_with_brackets_1before, $keywords_with_brackets_1before_cnt))
01729 ) {
01730 $functionlevel++;
01731 $infunction = TRUE;
01732 $after .= ' ';
01733 } else {
01734 $indent++;
01735 $after .= ($mode != 'query_only' ? '<div class="syntax_indent' . $indent . '">' : ' ');
01736 }
01737 break;
01738 case 'alpha_identifier':
01739 if (($typearr[1] == 'punct_qualifier') || ($typearr[3] == 'punct_qualifier')) {
01740 $after = '';
01741 $before = '';
01742 }
01743 if (($typearr[3] == 'alpha_columnType') || ($typearr[3] == 'alpha_identifier')) {
01744 $after .= ' ';
01745 }
01746 break;
01747 case 'punct_qualifier':
01748 $before = '';
01749 $after = '';
01750 break;
01751 case 'punct_listsep':
01752 if ($infunction == TRUE) {
01753 $after .= $space_punct_listsep_function_name;
01754 } else {
01755 $after .= $space_punct_listsep;
01756 }
01757 break;
01758 case 'punct_queryend':
01759 if (($typearr[3] != 'comment_mysql') && ($typearr[3] != 'comment_ansi') && $typearr[3] != 'comment_c') {
01760 $after .= $html_line_break;
01761 $after .= $html_line_break;
01762 }
01763 $space_punct_listsep = ' ';
01764 $space_punct_listsep_function_name = ' ';
01765 $space_alpha_reserved_word = ' ';
01766 $in_priv_list = FALSE;
01767 break;
01768 case 'comment_mysql':
01769 case 'comment_ansi':
01770 $after .= $html_line_break;
01771 break;
01772 case 'punct':
01773 $before .= ' ';
01774
01775
01776
01777
01778
01779
01780
01781 if ($typearr[3] != 'digit_integer') {
01782 $after .= ' ';
01783 }
01784 break;
01785 case 'punct_bracket_close_round':
01786 $bracketlevel--;
01787 if ($infunction == TRUE) {
01788 $functionlevel--;
01789 $after .= ' ';
01790 $before .= ' ';
01791 } else {
01792 $indent--;
01793 $before .= ($mode != 'query_only' ? '</div>' : ' ');
01794 }
01795 $infunction = ($functionlevel > 0) ? TRUE : FALSE;
01796 break;
01797 case 'alpha_columnType':
01798 if ($typearr[3] == 'alpha_columnAttrib') {
01799 $after .= ' ';
01800 }
01801 if ($typearr[1] == 'alpha_columnType') {
01802 $before .= ' ';
01803 }
01804 break;
01805 case 'alpha_columnAttrib':
01806
01807
01808 if ($typearr[1] == 'alpha_identifier') {
01809 $before .= ' ';
01810 }
01811 if (($typearr[3] == 'alpha_columnAttrib') || ($typearr[3] == 'quote_single') || ($typearr[3] == 'digit_integer')) {
01812 $after .= ' ';
01813 }
01814
01815
01816
01817
01818 if (strtoupper($arr[$i]['data']) == 'BINARY'
01819 && $typearr[3] == 'alpha_identifier') {
01820 $after .= ' ';
01821 }
01822 break;
01823 case 'alpha_reservedWord':
01824 $arr[$i]['data'] = strtoupper($arr[$i]['data']);
01825 if ((($typearr[1] != 'alpha_reservedWord')
01826 || (($typearr[1] == 'alpha_reservedWord')
01827 && PMA_STR_binarySearchInArr(strtoupper($arr[$i - 1]['data']), $keywords_no_newline, $keywords_no_newline_cnt)))
01828 && ($typearr[1] != 'punct_level_plus')
01829 && (!PMA_STR_binarySearchInArr($arr[$i]['data'], $keywords_no_newline, $keywords_no_newline_cnt))) {
01830
01831
01832
01833
01834
01835
01836 if ($i > 0) {
01837 if (!$in_priv_list) {
01838 $before .= $space_alpha_reserved_word;
01839 }
01840 } else {
01841
01842
01843 if (PMA_STR_binarySearchInArr($arr[$i]['data'], $keywords_priv_list, $keywords_priv_list_cnt)) {
01844 $in_priv_list = TRUE;
01845 }
01846 }
01847 } else {
01848 $before .= ' ';
01849 }
01850
01851 switch ($arr[$i]['data']) {
01852 case 'CREATE':
01853 if (!$in_priv_list) {
01854 $space_punct_listsep = $html_line_break;
01855 $space_alpha_reserved_word = ' ';
01856 }
01857 break;
01858 case 'EXPLAIN':
01859 case 'DESCRIBE':
01860 case 'SET':
01861 case 'ALTER':
01862 case 'DELETE':
01863 case 'SHOW':
01864 case 'DROP':
01865 case 'UPDATE':
01866 case 'TRUNCATE':
01867 case 'ANALYZE':
01868 case 'ANALYSE':
01869 if (!$in_priv_list) {
01870 $space_punct_listsep = $html_line_break;
01871 $space_alpha_reserved_word = ' ';
01872 }
01873 break;
01874 case 'INSERT':
01875 case 'REPLACE':
01876 if (!$in_priv_list) {
01877 $space_punct_listsep = $html_line_break;
01878 $space_alpha_reserved_word = $html_line_break;
01879 }
01880 break;
01881 case 'VALUES':
01882 $space_punct_listsep = ' ';
01883 $space_alpha_reserved_word = $html_line_break;
01884 break;
01885 case 'SELECT':
01886 $space_punct_listsep = ' ';
01887 $space_alpha_reserved_word = $html_line_break;
01888 break;
01889 default:
01890 break;
01891 }
01892
01893 $after .= ' ';
01894 break;
01895 case 'digit_integer':
01896 case 'digit_float':
01897 case 'digit_hex':
01898
01899 if ($typearr[1] == 'alpha_reservedWord') {
01900 $after .= ' ';
01901 }
01902 if ($infunction && $typearr[3] == 'punct_bracket_close_round') {
01903 $after .= ' ';
01904 }
01905 break;
01906 case 'alpha_variable':
01907 $after = ' ';
01908 break;
01909 case 'quote_double':
01910 case 'quote_single':
01911
01912
01913
01914
01915
01916 if ($typearr[1]!='alpha_variable') {
01917 $before .= ' ';
01918 }
01919 if ($infunction && $typearr[3] == 'punct_bracket_close_round') {
01920 $after .= ' ';
01921 }
01922 break;
01923 case 'quote_backtick':
01924 if ($typearr[3] != 'punct_qualifier') {
01925 $after .= ' ';
01926 }
01927 if ($typearr[1] != 'punct_qualifier') {
01928 $before .= ' ';
01929 }
01930 break;
01931 default:
01932 break;
01933 }
01934
01935
01936
01937
01938
01939
01940
01941 $str .= $before . ($mode=='color' ? PMA_SQP_formatHTML_colorize($arr[$i]) : $arr[$i]['data']). $after;
01942 }
01943 if ($mode=='color') {
01944 $str .= '</span>';
01945 }
01946
01947 return $str;
01948 }
01949 }
01950
01964 function PMA_SQP_buildCssRule($classname, $property, $value)
01965 {
01966 $str = '.' . $classname . ' {';
01967 if ($value != '') {
01968 $str .= $property . ': ' . $value . ';';
01969 }
01970 $str .= '}' . "\n";
01971
01972 return $str;
01973 }
01974
01975
01987 function PMA_SQP_buildCssData()
01988 {
01989 global $cfg;
01990
01991 $css_string = '';
01992 foreach($cfg['SQP']['fmtColor'] AS $key => $col) {
01993 $css_string .= PMA_SQP_buildCssRule('syntax_' . $key, 'color', $col);
01994 }
01995
01996 for ($i = 0; $i < 8; $i++) {
01997 $css_string .= PMA_SQP_buildCssRule('syntax_indent' . $i, 'margin-left', ($i * $cfg['SQP']['fmtInd']) . $cfg['SQP']['fmtIndUnit']);
01998 }
01999
02000 return $css_string;
02001 }
02002
02003 if ($is_minimum_common == FALSE) {
02013 function PMA_SQP_formatNone($arr)
02014 {
02015 $formatted_sql = htmlspecialchars($arr['raw']);
02016 $formatted_sql = preg_replace("@((\015\012)|(\015)|(\012)){3,}@", "\n\n", $formatted_sql);
02017
02018 return $formatted_sql;
02019 }
02020
02021
02031 function PMA_SQP_formatText($arr)
02032 {
02036 return PMA_SQP_formatNone($arr);
02037 }
02038 }
02039
02040 ?>