This is not a know pseudoclass.
[phpmyadmin/crack.git] / sql.php
blob7cfd12b6e41f1b29c1f4e67856bdebcd3c97e19e
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @todo we must handle the case if sql.php is called directly with a query
5 * what returns 0 rows - to prevent cyclic redirects or includes
6 * @version $Id$
7 */
9 /**
10 * Gets some core libraries
12 require_once './libraries/common.inc.php';
13 require_once './libraries/Table.class.php';
14 require_once './libraries/check_user_privileges.lib.php';
15 require_once './libraries/bookmark.lib.php';
17 $GLOBALS['js_include'][] = 'mootools.js';
19 /**
20 * Defines the url to return to in case of error in a sql statement
22 // Security checkings
23 if (! empty($goto)) {
24 $is_gotofile = preg_replace('@^([^?]+).*$@s', '\\1', $goto);
25 if (! @file_exists('./' . $is_gotofile)) {
26 unset($goto);
27 } else {
28 $is_gotofile = ($is_gotofile == $goto);
30 } else {
31 $goto = (! strlen($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable'];
32 $is_gotofile = true;
33 } // end if
35 if (!isset($err_url)) {
36 $err_url = (!empty($back) ? $back : $goto)
37 . '?' . PMA_generate_common_url($db)
38 . ((strpos(' ' . $goto, 'db_') != 1 && strlen($table)) ? '&amp;table=' . urlencode($table) : '');
39 } // end if
41 // Coming from a bookmark dialog
42 if (isset($fields['query'])) {
43 $sql_query = $fields['query'];
46 // This one is just to fill $db
47 if (isset($fields['dbase'])) {
48 $db = $fields['dbase'];
51 // Default to browse if no query set and we have table
52 // (needed for browsing from DefaultTabTable)
53 if (empty($sql_query) && strlen($table) && strlen($db)) {
54 require_once './libraries/bookmark.lib.php';
55 $book_sql_query = PMA_Bookmark_get($db, '\'' . PMA_sqlAddslashes($table) . '\'',
56 'label');
58 if (! empty($book_sql_query)) {
59 $sql_query = $book_sql_query;
60 } else {
61 $sql_query = 'SELECT * FROM ' . PMA_backquote($table);
63 unset($book_sql_query);
65 // set $goto to what will be displayed if query returns 0 rows
66 $goto = 'tbl_structure.php';
67 } else {
68 // Now we can check the parameters
69 PMA_checkParameters(array('sql_query'));
72 // instead of doing the test twice
73 $is_drop_database = preg_match('/DROP[[:space:]]+(DATABASE|SCHEMA)[[:space:]]+/i',
74 $sql_query);
76 /**
77 * Check rights in case of DROP DATABASE
79 * This test may be bypassed if $is_js_confirmed = 1 (already checked with js)
80 * but since a malicious user may pass this variable by url/form, we don't take
81 * into account this case.
83 if (!defined('PMA_CHK_DROP')
84 && !$cfg['AllowUserDropDatabase']
85 && $is_drop_database
86 && !$is_superuser) {
87 require_once './libraries/header.inc.php';
88 PMA_mysqlDie($strNoDropDatabases, '', '', $err_url);
89 } // end if
91 require_once './libraries/display_tbl.lib.php';
92 PMA_displayTable_checkConfigParams();
94 /**
95 * Need to find the real end of rows?
97 if (isset($find_real_end) && $find_real_end) {
98 $unlim_num_rows = PMA_Table::countRecords($db, $table, true, true);
99 $_SESSION['userconf']['pos'] = @((ceil($unlim_num_rows / $_SESSION['userconf']['max_rows']) - 1) * $_SESSION['userconf']['max_rows']);
104 * Bookmark add
106 if (isset($store_bkm)) {
107 PMA_Bookmark_save($fields, (isset($bkm_all_users) && $bkm_all_users == 'true' ? true : false));
108 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . $goto);
109 } // end if
112 * Parse and analyze the query
114 require_once './libraries/parse_analyze.lib.php';
117 * Sets or modifies the $goto variable if required
119 if ($goto == 'sql.php') {
120 $is_gotofile = false;
121 $goto = 'sql.php?'
122 . PMA_generate_common_url($db, $table)
123 . '&amp;sql_query=' . urlencode($sql_query);
124 } // end if
128 * Go back to further page if table should not be dropped
130 if (isset($btnDrop) && $btnDrop == $strNo) {
131 if (!empty($back)) {
132 $goto = $back;
134 if ($is_gotofile) {
135 if (strpos($goto, 'db_') === 0 && strlen($table)) {
136 $table = '';
138 $active_page = $goto;
139 require './' . PMA_securePath($goto);
140 } else {
141 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto));
143 exit();
144 } // end if
148 * Displays the confirm page if required
150 * This part of the script is bypassed if $is_js_confirmed = 1 (already checked
151 * with js) because possible security issue is not so important here: at most,
152 * the confirm message isn't displayed.
154 * Also bypassed if only showing php code.or validating a SQL query
156 if (! $cfg['Confirm'] || isset($_REQUEST['is_js_confirmed']) || isset($btnDrop)
157 // if we are coming from a "Create PHP code" or a "Without PHP Code"
158 // dialog, we won't execute the query anyway, so don't confirm
159 || isset($GLOBALS['show_as_php'])
160 || !empty($GLOBALS['validatequery'])) {
161 $do_confirm = false;
162 } else {
163 $do_confirm = isset($analyzed_sql[0]['queryflags']['need_confirm']);
166 if ($do_confirm) {
167 $stripped_sql_query = $sql_query;
168 require_once './libraries/header.inc.php';
169 if ($is_drop_database) {
170 echo '<h1 class="warning">' . $strDropDatabaseStrongWarning . '</h1>';
172 echo '<form action="sql.php" method="post">' . "\n"
173 .PMA_generate_common_hidden_inputs($db, $table);
175 <input type="hidden" name="sql_query" value="<?php echo htmlspecialchars($sql_query); ?>" />
176 <input type="hidden" name="zero_rows" value="<?php echo isset($zero_rows) ? PMA_sanitize($zero_rows) : ''; ?>" />
177 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
178 <input type="hidden" name="back" value="<?php echo isset($back) ? PMA_sanitize($back) : ''; ?>" />
179 <input type="hidden" name="reload" value="<?php echo isset($reload) ? PMA_sanitize($reload) : 0; ?>" />
180 <input type="hidden" name="purge" value="<?php echo isset($purge) ? PMA_sanitize($purge) : ''; ?>" />
181 <input type="hidden" name="cpurge" value="<?php echo isset($cpurge) ? PMA_sanitize($cpurge) : ''; ?>" />
182 <input type="hidden" name="purgekey" value="<?php echo isset($purgekey) ? PMA_sanitize($purgekey) : ''; ?>" />
183 <input type="hidden" name="show_query" value="<?php echo isset($show_query) ? PMA_sanitize($show_query) : ''; ?>" />
184 <?php
185 echo '<fieldset class="confirmation">' . "\n"
186 .' <legend>' . $strDoYouReally . '</legend>'
187 .' <tt>' . htmlspecialchars($stripped_sql_query) . '</tt>' . "\n"
188 .'</fieldset>' . "\n"
189 .'<fieldset class="tblFooters">' . "\n";
191 <input type="submit" name="btnDrop" value="<?php echo $strYes; ?>" id="buttonYes" />
192 <input type="submit" name="btnDrop" value="<?php echo $strNo; ?>" id="buttonNo" />
193 <?php
194 echo '</fieldset>' . "\n"
195 . '</form>' . "\n";
198 * Displays the footer and exit
200 require_once './libraries/footer.inc.php';
201 } // end if $do_confirm
204 // Defines some variables
205 // A table has to be created, renamed, dropped -> navi frame should be reloaded
207 * @todo use the parser/analyzer
210 if (empty($reload)
211 && preg_match('/^(CREATE|ALTER|DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $sql_query)) {
212 $reload = 1;
215 // SK -- Patch: $is_group added for use in calculation of total number of
216 // rows.
217 // $is_count is changed for more correct "LIMIT" clause
218 // appending in queries like
219 // "SELECT COUNT(...) FROM ... GROUP BY ..."
222 * @todo detect all this with the parser, to avoid problems finding
223 * those strings in comments or backquoted identifiers
226 $is_explain = $is_count = $is_export = $is_delete = $is_insert = $is_affected = $is_show = $is_maint = $is_analyse = $is_group = $is_func = $is_replace = false;
227 if ($is_select) { // see line 141
228 $is_group = preg_match('@(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+@i', $sql_query);
229 $is_func = !$is_group && (preg_match('@[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(@i', $sql_query));
230 $is_count = !$is_group && (preg_match('@^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)@i', $sql_query));
231 $is_export = (preg_match('@[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+@i', $sql_query));
232 $is_analyse = (preg_match('@[[:space:]]+PROCEDURE[[:space:]]+ANALYSE@i', $sql_query));
233 } elseif (preg_match('@^EXPLAIN[[:space:]]+@i', $sql_query)) {
234 $is_explain = true;
235 } elseif (preg_match('@^DELETE[[:space:]]+@i', $sql_query)) {
236 $is_delete = true;
237 $is_affected = true;
238 } elseif (preg_match('@^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+@i', $sql_query)) {
239 $is_insert = true;
240 $is_affected = true;
241 if (preg_match('@^(REPLACE)[[:space:]]+@i', $sql_query)) {
242 $is_replace = true;
244 } elseif (preg_match('@^UPDATE[[:space:]]+@i', $sql_query)) {
245 $is_affected = true;
246 } elseif (preg_match('@^[[:space:]]*SHOW[[:space:]]+@i', $sql_query)) {
247 $is_show = true;
248 } elseif (preg_match('@^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+@i', $sql_query)) {
249 $is_maint = true;
252 // Do append a "LIMIT" clause?
253 if ((! $cfg['ShowAll'] || $_SESSION['userconf']['max_rows'] != 'all')
254 && ! ($is_count || $is_export || $is_func || $is_analyse)
255 && isset($analyzed_sql[0]['queryflags']['select_from'])
256 && ! isset($analyzed_sql[0]['queryflags']['offset'])
257 && empty($analyzed_sql[0]['limit_clause'])
259 $sql_limit_to_append = ' LIMIT ' . $_SESSION['userconf']['pos'] . ', ' . $_SESSION['userconf']['max_rows'] . " ";
261 $full_sql_query = $analyzed_sql[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_sql[0]['section_after_limit'];
263 * @todo pretty printing of this modified query
265 if (isset($display_query)) {
266 // if the analysis of the original query revealed that we found
267 // a section_after_limit, we now have to analyze $display_query
268 // to display it correctly
270 if (!empty($analyzed_sql[0]['section_after_limit']) && trim($analyzed_sql[0]['section_after_limit']) != ';') {
271 $analyzed_display_query = PMA_SQP_analyze(PMA_SQP_parse($display_query));
272 $display_query = $analyzed_display_query[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_display_query[0]['section_after_limit'];
276 } else {
277 $full_sql_query = $sql_query;
278 } // end if...else
280 if (strlen($db)) {
281 PMA_DBI_select_db($db);
284 // E x e c u t e t h e q u e r y
286 // Only if we didn't ask to see the php code (mikebeck)
287 if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
288 unset($result);
289 $num_rows = 0;
290 } else {
291 if (isset($_SESSION['profiling']) && PMA_profilingSupported()) {
292 PMA_DBI_query('SET PROFILING=1;');
295 // garvin: Measure query time.
296 // TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411
297 $querytime_before = array_sum(explode(' ', microtime()));
299 $result = @PMA_DBI_try_query($full_sql_query, null, PMA_DBI_QUERY_STORE);
301 $querytime_after = array_sum(explode(' ', microtime()));
303 $GLOBALS['querytime'] = $querytime_after - $querytime_before;
305 // Displays an error message if required and stop parsing the script
306 if ($error = PMA_DBI_getError()) {
307 if ($is_gotofile) {
308 if (strpos($goto, 'db_') === 0 && strlen($table)) {
309 $table = '';
311 $active_page = $goto;
312 $message = PMA_Message::rawError($error);
313 require './' . PMA_securePath($goto);
314 } else {
315 require_once './libraries/header.inc.php';
316 $full_err_url = (preg_match('@^(db|tbl)_@', $err_url))
317 ? $err_url . '&amp;show_query=1&amp;sql_query=' . urlencode($sql_query)
318 : $err_url;
319 PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
321 exit;
323 unset($error);
325 // Gets the number of rows affected/returned
326 // (This must be done immediately after the query because
327 // mysql_affected_rows() reports about the last query done)
329 if (!$is_affected) {
330 $num_rows = ($result) ? @PMA_DBI_num_rows($result) : 0;
331 } elseif (!isset($num_rows)) {
332 $num_rows = @PMA_DBI_affected_rows();
335 // Grabs the profiling results
336 if (isset($_SESSION['profiling']) && PMA_profilingSupported()) {
337 $profiling_results = PMA_DBI_fetch_result('SHOW PROFILE;');
340 // Checks if the current database has changed
341 // This could happen if the user sends a query like "USE `database`;"
343 * commented out auto-switching to active database - really required?
344 * bug #1814718 win: table list disappears (mixed case db names)
345 * https://sourceforge.net/support/tracker.php?aid=1814718
346 * @todo RELEASE test and comit or rollback before release
347 $current_db = PMA_DBI_fetch_value('SELECT DATABASE()');
348 if ($db !== $current_db) {
349 $db = $current_db;
350 $reload = 1;
352 unset($current_db);
355 // tmpfile remove after convert encoding appended by Y.Kawada
356 if (function_exists('PMA_kanji_file_conv')
357 && (isset($textfile) && file_exists($textfile))) {
358 unlink($textfile);
361 // Counts the total number of rows for the same 'SELECT' query without the
362 // 'LIMIT' clause that may have been programatically added
364 if (empty($sql_limit_to_append)) {
365 $unlim_num_rows = $num_rows;
366 // if we did not append a limit, set this to get a correct
367 // "Showing rows..." message
368 //$_SESSION['userconf']['max_rows'] = 'all';
369 } elseif ($is_select) {
371 // c o u n t q u e r y
373 // If we are "just browsing", there is only one table,
374 // and no where clause (or just 'WHERE 1 '),
375 // so we do a quick count (which uses MaxExactCount)
376 // because SQL_CALC_FOUND_ROWS
377 // is not quick on large InnoDB tables
379 // but do not count again if we did it previously
380 // due to $find_real_end == true
382 if (!$is_group
383 && !isset($analyzed_sql[0]['queryflags']['union'])
384 && !isset($analyzed_sql[0]['table_ref'][1]['table_name'])
385 && (empty($analyzed_sql[0]['where_clause'])
386 || $analyzed_sql[0]['where_clause'] == '1 ')
387 && !isset($find_real_end)
390 // "j u s t b r o w s i n g"
391 $unlim_num_rows = PMA_Table::countRecords($db, $table, true);
393 } else { // n o t " j u s t b r o w s i n g "
395 // add select expression after the SQL_CALC_FOUND_ROWS
397 // for UNION, just adding SQL_CALC_FOUND_ROWS
398 // after the first SELECT works.
400 // take the left part, could be:
401 // SELECT
402 // (SELECT
403 $count_query = PMA_SQP_formatHtml($parsed_sql, 'query_only', 0, $analyzed_sql[0]['position_of_first_select'] + 1);
404 $count_query .= ' SQL_CALC_FOUND_ROWS ';
405 // add everything that was after the first SELECT
406 $count_query .= PMA_SQP_formatHtml($parsed_sql, 'query_only', $analyzed_sql[0]['position_of_first_select']+1);
407 // ensure there is no semicolon at the end of the
408 // count query because we'll probably add
409 // a LIMIT 1 clause after it
410 $count_query = rtrim($count_query);
411 $count_query = rtrim($count_query, ';');
413 // if using SQL_CALC_FOUND_ROWS, add a LIMIT to avoid
414 // long delays. Returned count will be complete anyway.
415 // (but a LIMIT would disrupt results in an UNION)
417 if (!isset($analyzed_sql[0]['queryflags']['union'])) {
418 $count_query .= ' LIMIT 1';
421 // run the count query
423 PMA_DBI_try_query($count_query);
424 // if (mysql_error()) {
425 // void.
426 // I tried the case
427 // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`)
428 // UNION (SELECT `User`, `Host`, "%" AS "Db",
429 // `Select_priv`
430 // FROM `user`) ORDER BY `User`, `Host`, `Db`;
431 // and although the generated count_query is wrong
432 // the SELECT FOUND_ROWS() work! (maybe it gets the
433 // count from the latest query that worked)
435 // another case where the count_query is wrong:
436 // SELECT COUNT(*), f1 from t1 group by f1
437 // and you click to sort on count(*)
438 // }
439 $unlim_num_rows = PMA_DBI_fetch_value('SELECT FOUND_ROWS()');
440 } // end else "just browsing"
442 } else { // not $is_select
443 $unlim_num_rows = 0;
444 } // end rows total count
446 // garvin: if a table or database gets dropped, check column comments.
447 if (isset($purge) && $purge == '1') {
448 require_once './libraries/relation_cleanup.lib.php';
450 if (strlen($table) && strlen($db)) {
451 PMA_relationsCleanupTable($db, $table);
452 } elseif (strlen($db)) {
453 PMA_relationsCleanupDatabase($db);
454 } else {
455 // garvin: VOID. No DB/Table gets deleted.
456 } // end if relation-stuff
457 } // end if ($purge)
459 // garvin: If a column gets dropped, do relation magic.
460 if (isset($cpurge) && $cpurge == '1' && isset($purgekey)
461 && strlen($db) && strlen($table) && !empty($purgekey)) {
462 require_once './libraries/relation_cleanup.lib.php';
463 PMA_relationsCleanupColumn($db, $table, $purgekey);
465 } // end if column PMA_* purge
466 } // end else "didn't ask to see php code"
468 // No rows returned -> move back to the calling page
469 if ($num_rows < 1 || $is_affected) {
470 if ($is_delete) {
471 $message = PMA_Message::success('strRowsDeleted');
472 $message->addParam($num_rows);
473 } elseif ($is_insert) {
474 if ($is_replace) {
475 /* For replace we get DELETED + INSERTED row count, so we have to call it affected */
476 $message = PMA_Message::success('strRowsAffected');
477 $message->addParam($num_rows);
478 } else {
479 $message = PMA_Message::success('strRowsInserted');
480 $message->addParam($num_rows);
482 $insert_id = PMA_DBI_insert_id();
483 if ($insert_id != 0) {
484 // insert_id is id of FIRST record inserted in one insert, so if we inserted multiple rows, we had to increment this
485 $message->addMessage('[br]');
486 // need to use a temporary because the Message class
487 // currently supports adding parameters only to the first
488 // message
489 $_inserted = PMA_Message::notice('strInsertedRowId');
490 $_inserted->addParam($insert_id + $num_rows - 1);
491 $message->addMessage($_inserted);
493 } elseif ($is_affected) {
494 $message = PMA_Message::success('strRowsAffected');
495 $message->addParam($num_rows);
497 // Ok, here is an explanation for the !$is_select.
498 // The form generated by sql_query_form.lib.php
499 // and db_sql.php has many submit buttons
500 // on the same form, and some confusion arises from the
501 // fact that $zero_rows is sent for every case.
502 // The $zero_rows containing $strSuccess and sent with
503 // the form should not have priority over
504 // errors like $strEmptyResultSet
505 } elseif (!empty($zero_rows) && !$is_select) {
506 $message = PMA_Message::rawSuccess($zero_rows);
507 } elseif (!empty($GLOBALS['show_as_php'])) {
508 $message = PMA_Message::success('strShowingPhp');
509 } elseif (isset($GLOBALS['show_as_php'])) {
510 /* User disable showing as PHP, query is only displayed */
511 $message = PMA_Message::notice('strShowingSQL');
512 } elseif (!empty($GLOBALS['validatequery'])) {
513 $message = PMA_Message::notice('strValidateSQL');
514 } else {
515 $message = PMA_Message::success('strEmptyResultSet');
518 if (isset($GLOBALS['querytime'])) {
519 $_querytime = PMA_Message::notice('strQueryTime');
520 $_querytime->addParam($GLOBALS['querytime']);
521 $message->addMessage('(');
522 $message->addMessage($_querytime);
523 $message->addMessage(')');
526 if ($is_gotofile) {
527 $goto = PMA_securePath($goto);
528 // Checks for a valid target script
529 $is_db = $is_table = false;
530 include 'libraries/db_table_exists.lib.php';
531 if (strpos($goto, 'tbl_') === 0 && ! $is_table) {
532 if (strlen($table)) {
533 $table = '';
535 $goto = 'db_sql.php';
537 if (strpos($goto, 'db_') === 0 && ! $is_db) {
538 if (strlen($db)) {
539 $db = '';
541 $goto = 'main.php';
543 // Loads to target script
544 if (strpos($goto, 'db_') === 0
545 || strpos($goto, 'tbl_') === 0) {
546 $GLOBALS['js_include'][] = 'functions.js';
548 if ($goto != 'main.php') {
549 require_once './libraries/header.inc.php';
551 $active_page = $goto;
552 require './' . $goto;
553 } else {
554 // avoid a redirect loop when last record was deleted
555 if ('sql.php' == $cfg['DefaultTabTable']) {
556 $goto = str_replace('sql.php','tbl_structure.php',$goto);
558 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto) . '&message=' . urlencode($message));
559 } // end else
560 exit();
561 } // end no rows returned
563 // At least one row is returned -> displays a table with results
564 else {
565 // Displays the headers
566 if (isset($show_query)) {
567 unset($show_query);
569 if (isset($printview) && $printview == '1') {
570 require_once './libraries/header_printview.inc.php';
571 } else {
572 $GLOBALS['js_include'][] = 'functions.js';
573 unset($message);
574 if (strlen($table)) {
575 require './libraries/tbl_common.php';
576 $url_query .= '&amp;goto=tbl_sql.php&amp;back=tbl_sql.php';
577 require './libraries/tbl_info.inc.php';
578 require './libraries/tbl_links.inc.php';
579 } elseif (strlen($db)) {
580 require './libraries/db_common.inc.php';
581 require './libraries/db_info.inc.php';
582 } else {
583 require './libraries/server_common.inc.php';
584 require './libraries/server_links.inc.php';
588 if (strlen($db)) {
589 require_once './libraries/relation.lib.php';
590 $cfgRelation = PMA_getRelationsParam();
593 // Gets the list of fields properties
594 if (isset($result) && $result) {
595 $fields_meta = PMA_DBI_get_fields_meta($result);
596 $fields_cnt = count($fields_meta);
599 // Display previous update query (from tbl_replace)
600 if (isset($disp_query) && $cfg['ShowSQL'] == true) {
601 PMA_showMessage($disp_message, $disp_query, 'success');
604 if (isset($profiling_results)) {
605 PMA_profilingResults($profiling_results);
608 // Displays the results in a table
609 if (empty($disp_mode)) {
610 // see the "PMA_setDisplayMode()" function in
611 // libraries/display_tbl.lib.php
612 $disp_mode = 'urdr111101';
615 // hide edit and delete links for information_schema
616 if ($db == 'information_schema') {
617 $disp_mode = 'nnnn110111';
620 PMA_displayTable($result, $disp_mode, $analyzed_sql);
621 PMA_DBI_free_result($result);
623 // BEGIN INDEX CHECK See if indexes should be checked.
624 if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) {
625 foreach ($selected as $idx => $tbl_name) {
626 $check = PMA_Index::findDuplicates($tbl_name, $db);
627 if (! empty($check)) {
628 printf($strIndexWarningTable, $tbl_name);
629 echo $check;
632 } // End INDEX CHECK
634 // Bookmark support if required
635 if ($disp_mode[7] == '1'
636 && (! empty($cfg['Bookmark']) && empty($id_bookmark))
637 && !empty($sql_query)) {
638 echo "\n";
640 $goto = 'sql.php?'
641 . PMA_generate_common_url($db, $table)
642 . '&amp;sql_query=' . urlencode($sql_query)
643 . '&amp;id_bookmark=1';
646 <form action="sql.php" method="post" onsubmit="return emptyFormElements(this, 'fields[label]');">
647 <?php echo PMA_generate_common_hidden_inputs(); ?>
648 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
649 <input type="hidden" name="fields[dbase]" value="<?php echo htmlspecialchars($db); ?>" />
650 <input type="hidden" name="fields[user]" value="<?php echo $cfg['Bookmark']['user']; ?>" />
651 <input type="hidden" name="fields[query]" value="<?php echo urlencode(isset($complete_query) ? $complete_query : $sql_query); ?>" />
652 <fieldset>
653 <legend><?php
654 echo ($cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_bookmark.png" width="16" height="16" alt="' . $strBookmarkThis . '" />' : '')
655 . $strBookmarkThis;
657 </legend>
659 <div class="formelement">
660 <label for="fields_label_"><?php echo $strBookmarkLabel; ?>:</label>
661 <input type="text" id="fields_label_" name="fields[label]" value="" />
662 </div>
664 <div class="formelement">
665 <input type="checkbox" name="bkm_all_users" id="bkm_all_users" value="true" />
666 <label for="bkm_all_users"><?php echo $strBookmarkAllUsers; ?></label>
667 </div>
669 <div class="clearfloat"></div>
670 </fieldset>
671 <fieldset class="tblFooters">
672 <input type="submit" name="store_bkm" value="<?php echo $strBookmarkThis; ?>" />
673 </fieldset>
674 </form>
675 <?php
676 } // end bookmark support
678 // Do print the page if required
679 if (isset($printview) && $printview == '1') {
681 <script type="text/javascript">
682 //<![CDATA[
683 // Do print the page
684 window.onload = function()
686 if (typeof(window.print) != 'undefined') {
687 window.print();
690 //]]>
691 </script>
692 <?php
693 } // end print case
694 } // end rows returned
697 * Displays the footer
699 require_once './libraries/footer.inc.php';