Translation update done using Pootle.
[phpmyadmin-themes.git] / sql.php
blob12c6ac5823ade142d82df11989c9812360a056f8
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 * that returns 0 rows - to prevent cyclic redirects or includes
6 * @package phpMyAdmin
7 */
9 /**
10 * Gets some core libraries
12 require_once './libraries/common.inc.php';
13 require_once './libraries/check_user_privileges.lib.php';
14 require_once './libraries/bookmark.lib.php';
16 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
18 /**
19 * Defines the url to return to in case of error in a sql statement
21 // Security checkings
22 if (! empty($goto)) {
23 $is_gotofile = preg_replace('@^([^?]+).*$@s', '\\1', $goto);
24 if (! @file_exists('./' . $is_gotofile)) {
25 unset($goto);
26 } else {
27 $is_gotofile = ($is_gotofile == $goto);
29 } else {
30 $goto = (! strlen($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable'];
31 $is_gotofile = true;
32 } // end if
34 if (!isset($err_url)) {
35 $err_url = (!empty($back) ? $back : $goto)
36 . '?' . PMA_generate_common_url($db)
37 . ((strpos(' ' . $goto, 'db_') != 1 && strlen($table)) ? '&amp;table=' . urlencode($table) : '');
38 } // end if
40 // Coming from a bookmark dialog
41 if (isset($fields['query'])) {
42 $sql_query = $fields['query'];
45 // This one is just to fill $db
46 if (isset($fields['dbase'])) {
47 $db = $fields['dbase'];
50 // Default to browse if no query set and we have table
51 // (needed for browsing from DefaultTabTable)
52 if (empty($sql_query) && strlen($table) && strlen($db)) {
53 require_once './libraries/bookmark.lib.php';
54 $book_sql_query = PMA_Bookmark_get($db, '\'' . PMA_sqlAddslashes($table) . '\'',
55 'label');
57 if (! empty($book_sql_query)) {
58 $sql_query = $book_sql_query;
59 } else {
60 $sql_query = 'SELECT * FROM ' . PMA_backquote($table);
62 unset($book_sql_query);
64 // set $goto to what will be displayed if query returns 0 rows
65 $goto = 'tbl_structure.php';
66 } else {
67 // Now we can check the parameters
68 PMA_checkParameters(array('sql_query'));
71 // instead of doing the test twice
72 $is_drop_database = preg_match('/DROP[[:space:]]+(DATABASE|SCHEMA)[[:space:]]+/i',
73 $sql_query);
75 /**
76 * Check rights in case of DROP DATABASE
78 * This test may be bypassed if $is_js_confirmed = 1 (already checked with js)
79 * but since a malicious user may pass this variable by url/form, we don't take
80 * into account this case.
82 if (!defined('PMA_CHK_DROP')
83 && !$cfg['AllowUserDropDatabase']
84 && $is_drop_database
85 && !$is_superuser) {
86 require_once './libraries/header.inc.php';
87 PMA_mysqlDie(__('"DROP DATABASE" statements are disabled.'), '', '', $err_url);
88 } // end if
90 require_once './libraries/display_tbl.lib.php';
91 PMA_displayTable_checkConfigParams();
93 /**
94 * Need to find the real end of rows?
96 if (isset($find_real_end) && $find_real_end) {
97 $unlim_num_rows = PMA_Table::countRecords($db, $table, $force_exact = true);
98 $_SESSION['tmp_user_values']['pos'] = @((ceil($unlim_num_rows / $_SESSION['tmp_user_values']['max_rows']) - 1) * $_SESSION['tmp_user_values']['max_rows']);
103 * Bookmark add
105 if (isset($store_bkm)) {
106 PMA_Bookmark_save($fields, (isset($bkm_all_users) && $bkm_all_users == 'true' ? true : false));
107 // go back to sql.php to redisplay query; do not use &amp; in this case:
108 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . $goto . '&label=' . $fields['label']);
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 == __('No')) {
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">' . __('You are about to DESTROY a complete database!') . '</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, true) : ''; ?>" />
177 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
178 <input type="hidden" name="back" value="<?php echo isset($back) ? PMA_sanitize($back, true) : ''; ?>" />
179 <input type="hidden" name="reload" value="<?php echo isset($reload) ? PMA_sanitize($reload, true) : 0; ?>" />
180 <input type="hidden" name="purge" value="<?php echo isset($purge) ? PMA_sanitize($purge, true) : ''; ?>" />
181 <input type="hidden" name="dropped_column" value="<?php echo isset($dropped_column) ? PMA_sanitize($dropped_column, true) : ''; ?>" />
182 <input type="hidden" name="show_query" value="<?php echo isset($show_query) ? PMA_sanitize($show_query, true) : ''; ?>" />
183 <?php
184 echo '<fieldset class="confirmation">' . "\n"
185 .' <legend>' . __('Do you really want to ') . '</legend>'
186 .' <tt>' . htmlspecialchars($stripped_sql_query) . '</tt>' . "\n"
187 .'</fieldset>' . "\n"
188 .'<fieldset class="tblFooters">' . "\n";
190 <input type="submit" name="btnDrop" value="<?php echo __('Yes'); ?>" id="buttonYes" />
191 <input type="submit" name="btnDrop" value="<?php echo __('No'); ?>" id="buttonNo" />
192 <?php
193 echo '</fieldset>' . "\n"
194 . '</form>' . "\n";
197 * Displays the footer and exit
199 require './libraries/footer.inc.php';
200 } // end if $do_confirm
203 // Defines some variables
204 // A table has to be created, renamed, dropped -> navi frame should be reloaded
206 * @todo use the parser/analyzer
209 if (empty($reload)
210 && preg_match('/^(CREATE|ALTER|DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $sql_query)) {
211 $reload = 1;
214 // SK -- Patch: $is_group added for use in calculation of total number of
215 // rows.
216 // $is_count is changed for more correct "LIMIT" clause
217 // appending in queries like
218 // "SELECT COUNT(...) FROM ... GROUP BY ..."
221 * @todo detect all this with the parser, to avoid problems finding
222 * those strings in comments or backquoted identifiers
225 $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;
226 if ($is_select) { // see line 141
227 $is_group = preg_match('@(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+@i', $sql_query);
228 $is_func = !$is_group && (preg_match('@[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(@i', $sql_query));
229 $is_count = !$is_group && (preg_match('@^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)@i', $sql_query));
230 $is_export = (preg_match('@[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+@i', $sql_query));
231 $is_analyse = (preg_match('@[[:space:]]+PROCEDURE[[:space:]]+ANALYSE@i', $sql_query));
232 } elseif (preg_match('@^EXPLAIN[[:space:]]+@i', $sql_query)) {
233 $is_explain = true;
234 } elseif (preg_match('@^DELETE[[:space:]]+@i', $sql_query)) {
235 $is_delete = true;
236 $is_affected = true;
237 } elseif (preg_match('@^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+@i', $sql_query)) {
238 $is_insert = true;
239 $is_affected = true;
240 if (preg_match('@^(REPLACE)[[:space:]]+@i', $sql_query)) {
241 $is_replace = true;
243 } elseif (preg_match('@^UPDATE[[:space:]]+@i', $sql_query)) {
244 $is_affected = true;
245 } elseif (preg_match('@^[[:space:]]*SHOW[[:space:]]+@i', $sql_query)) {
246 $is_show = true;
247 } elseif (preg_match('@^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+@i', $sql_query)) {
248 $is_maint = true;
251 // Do append a "LIMIT" clause?
252 if ((! $cfg['ShowAll'] || $_SESSION['tmp_user_values']['max_rows'] != 'all')
253 && ! ($is_count || $is_export || $is_func || $is_analyse)
254 && isset($analyzed_sql[0]['queryflags']['select_from'])
255 && ! isset($analyzed_sql[0]['queryflags']['offset'])
256 && empty($analyzed_sql[0]['limit_clause'])
258 $sql_limit_to_append = ' LIMIT ' . $_SESSION['tmp_user_values']['pos'] . ', ' . $_SESSION['tmp_user_values']['max_rows'] . " ";
260 $full_sql_query = $analyzed_sql[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_sql[0]['section_after_limit'];
262 * @todo pretty printing of this modified query
264 if (isset($display_query)) {
265 // if the analysis of the original query revealed that we found
266 // a section_after_limit, we now have to analyze $display_query
267 // to display it correctly
269 if (!empty($analyzed_sql[0]['section_after_limit']) && trim($analyzed_sql[0]['section_after_limit']) != ';') {
270 $analyzed_display_query = PMA_SQP_analyze(PMA_SQP_parse($display_query));
271 $display_query = $analyzed_display_query[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_display_query[0]['section_after_limit'];
275 } else {
276 $full_sql_query = $sql_query;
277 } // end if...else
279 if (strlen($db)) {
280 PMA_DBI_select_db($db);
283 // E x e c u t e t h e q u e r y
285 // Only if we didn't ask to see the php code (mikebeck)
286 if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
287 unset($result);
288 $num_rows = 0;
289 } else {
290 if (isset($_SESSION['profiling']) && PMA_profilingSupported()) {
291 PMA_DBI_query('SET PROFILING=1;');
294 // Measure query time.
295 // TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411
296 $querytime_before = array_sum(explode(' ', microtime()));
298 $result = @PMA_DBI_try_query($full_sql_query, null, PMA_DBI_QUERY_STORE);
300 $querytime_after = array_sum(explode(' ', microtime()));
302 $GLOBALS['querytime'] = $querytime_after - $querytime_before;
304 // Displays an error message if required and stop parsing the script
305 if ($error = PMA_DBI_getError()) {
306 if ($is_gotofile) {
307 if (strpos($goto, 'db_') === 0 && strlen($table)) {
308 $table = '';
310 $active_page = $goto;
311 $message = htmlspecialchars(PMA_Message::rawError($error));
313 * Go to target path.
315 require './' . PMA_securePath($goto);
316 } else {
318 * HTML header.
320 require_once './libraries/header.inc.php';
321 $full_err_url = (preg_match('@^(db|tbl)_@', $err_url))
322 ? $err_url . '&amp;show_query=1&amp;sql_query=' . urlencode($sql_query)
323 : $err_url;
324 PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
326 exit;
328 unset($error);
330 // Gets the number of rows affected/returned
331 // (This must be done immediately after the query because
332 // mysql_affected_rows() reports about the last query done)
334 if (!$is_affected) {
335 $num_rows = ($result) ? @PMA_DBI_num_rows($result) : 0;
336 } elseif (!isset($num_rows)) {
337 $num_rows = @PMA_DBI_affected_rows();
340 // Grabs the profiling results
341 if (isset($_SESSION['profiling']) && PMA_profilingSupported()) {
342 $profiling_results = PMA_DBI_fetch_result('SHOW PROFILE;');
345 // Checks if the current database has changed
346 // This could happen if the user sends a query like "USE `database`;"
348 * commented out auto-switching to active database - really required?
349 * bug #1814718 win: table list disappears (mixed case db names)
350 * https://sourceforge.net/support/tracker.php?aid=1814718
351 * @todo RELEASE test and comit or rollback before release
352 $current_db = PMA_DBI_fetch_value('SELECT DATABASE()');
353 if ($db !== $current_db) {
354 $db = $current_db;
355 $reload = 1;
357 unset($current_db);
360 // tmpfile remove after convert encoding appended by Y.Kawada
361 if (function_exists('PMA_kanji_file_conv')
362 && (isset($textfile) && file_exists($textfile))) {
363 unlink($textfile);
366 // Counts the total number of rows for the same 'SELECT' query without the
367 // 'LIMIT' clause that may have been programatically added
369 if (empty($sql_limit_to_append)) {
370 $unlim_num_rows = $num_rows;
371 // if we did not append a limit, set this to get a correct
372 // "Showing rows..." message
373 //$_SESSION['tmp_user_values']['max_rows'] = 'all';
374 } elseif ($is_select) {
376 // c o u n t q u e r y
378 // If we are "just browsing", there is only one table,
379 // and no WHERE clause (or just 'WHERE 1 '),
380 // we do a quick count (which uses MaxExactCount) because
381 // SQL_CALC_FOUND_ROWS is not quick on large InnoDB tables
383 // However, do not count again if we did it previously
384 // due to $find_real_end == true
386 if (!$is_group
387 && !isset($analyzed_sql[0]['queryflags']['union'])
388 && !isset($analyzed_sql[0]['table_ref'][1]['table_name'])
389 && (empty($analyzed_sql[0]['where_clause'])
390 || $analyzed_sql[0]['where_clause'] == '1 ')
391 && !isset($find_real_end)
394 // "j u s t b r o w s i n g"
395 $unlim_num_rows = PMA_Table::countRecords($db, $table);
397 } else { // n o t " j u s t b r o w s i n g "
399 // add select expression after the SQL_CALC_FOUND_ROWS
401 // for UNION, just adding SQL_CALC_FOUND_ROWS
402 // after the first SELECT works.
404 // take the left part, could be:
405 // SELECT
406 // (SELECT
407 $count_query = PMA_SQP_formatHtml($parsed_sql, 'query_only', 0, $analyzed_sql[0]['position_of_first_select'] + 1);
408 $count_query .= ' SQL_CALC_FOUND_ROWS ';
409 // add everything that was after the first SELECT
410 $count_query .= PMA_SQP_formatHtml($parsed_sql, 'query_only', $analyzed_sql[0]['position_of_first_select']+1);
411 // ensure there is no semicolon at the end of the
412 // count query because we'll probably add
413 // a LIMIT 1 clause after it
414 $count_query = rtrim($count_query);
415 $count_query = rtrim($count_query, ';');
417 // if using SQL_CALC_FOUND_ROWS, add a LIMIT to avoid
418 // long delays. Returned count will be complete anyway.
419 // (but a LIMIT would disrupt results in an UNION)
421 if (!isset($analyzed_sql[0]['queryflags']['union'])) {
422 $count_query .= ' LIMIT 1';
425 // run the count query
427 PMA_DBI_try_query($count_query);
428 // if (mysql_error()) {
429 // void.
430 // I tried the case
431 // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`)
432 // UNION (SELECT `User`, `Host`, "%" AS "Db",
433 // `Select_priv`
434 // FROM `user`) ORDER BY `User`, `Host`, `Db`;
435 // and although the generated count_query is wrong
436 // the SELECT FOUND_ROWS() work! (maybe it gets the
437 // count from the latest query that worked)
439 // another case where the count_query is wrong:
440 // SELECT COUNT(*), f1 from t1 group by f1
441 // and you click to sort on count(*)
442 // }
443 $unlim_num_rows = PMA_DBI_fetch_value('SELECT FOUND_ROWS()');
444 } // end else "just browsing"
446 } else { // not $is_select
447 $unlim_num_rows = 0;
448 } // end rows total count
450 // if a table or database gets dropped, check column comments.
451 if (isset($purge) && $purge == '1') {
453 * Cleanup relations.
455 require_once './libraries/relation_cleanup.lib.php';
457 if (strlen($table) && strlen($db)) {
458 PMA_relationsCleanupTable($db, $table);
459 } elseif (strlen($db)) {
460 PMA_relationsCleanupDatabase($db);
461 } else {
462 // VOID. No DB/Table gets deleted.
463 } // end if relation-stuff
464 } // end if ($purge)
466 // If a column gets dropped, do relation magic.
467 if (isset($dropped_column) && strlen($db) && strlen($table) && !empty($dropped_column)) {
468 require_once './libraries/relation_cleanup.lib.php';
469 PMA_relationsCleanupColumn($db, $table, $dropped_column);
471 } // end if column was dropped
472 } // end else "didn't ask to see php code"
474 // No rows returned -> move back to the calling page
475 if (0 == $num_rows || $is_affected) {
476 if ($is_delete) {
477 $message = PMA_Message::deleted_rows($num_rows);
478 } elseif ($is_insert) {
479 if ($is_replace) {
480 /* For replace we get DELETED + INSERTED row count, so we have to call it affected */
481 $message = PMA_Message::affected_rows($num_rows);
482 } else {
483 $message = PMA_Message::inserted_rows($num_rows);
485 $insert_id = PMA_DBI_insert_id();
486 if ($insert_id != 0) {
487 // insert_id is id of FIRST record inserted in one insert, so if we inserted multiple rows, we had to increment this
488 $message->addMessage('[br]');
489 // need to use a temporary because the Message class
490 // currently supports adding parameters only to the first
491 // message
492 $_inserted = PMA_Message::notice(__('Inserted row id: %1$d'));
493 $_inserted->addParam($insert_id + $num_rows - 1);
494 $message->addMessage($_inserted);
496 } elseif ($is_affected) {
497 $message = PMA_Message::affected_rows($num_rows);
499 // Ok, here is an explanation for the !$is_select.
500 // The form generated by sql_query_form.lib.php
501 // and db_sql.php has many submit buttons
502 // on the same form, and some confusion arises from the
503 // fact that $zero_rows is sent for every case.
504 // The $zero_rows containing a success message and sent with
505 // the form should not have priority over errors
506 } elseif (!empty($zero_rows) && !$is_select) {
507 $message = PMA_Message::rawSuccess(htmlspecialchars($zero_rows));
508 } elseif (!empty($GLOBALS['show_as_php'])) {
509 $message = PMA_Message::success(__('Showing as PHP code'));
510 } elseif (isset($GLOBALS['show_as_php'])) {
511 /* User disable showing as PHP, query is only displayed */
512 $message = PMA_Message::notice(__('Showing SQL query'));
513 } elseif (!empty($GLOBALS['validatequery'])) {
514 $message = PMA_Message::notice(__('Validated SQL'));
515 } else {
516 $message = PMA_Message::success(__('MySQL returned an empty result set (i.e. zero rows).'));
519 if (isset($GLOBALS['querytime'])) {
520 $_querytime = PMA_Message::notice(__('Query took %01.4f sec'));
521 $_querytime->addParam($GLOBALS['querytime']);
522 $message->addMessage('(');
523 $message->addMessage($_querytime);
524 $message->addMessage(')');
527 if ($is_gotofile) {
528 $goto = PMA_securePath($goto);
529 // Checks for a valid target script
530 $is_db = $is_table = false;
531 if (isset($_REQUEST['purge'])) {
532 $table = '';
533 unset($url_params['table']);
535 include 'libraries/db_table_exists.lib.php';
537 if (strpos($goto, 'tbl_') === 0 && ! $is_table) {
538 if (strlen($table)) {
539 $table = '';
541 $goto = 'db_sql.php';
543 if (strpos($goto, 'db_') === 0 && ! $is_db) {
544 if (strlen($db)) {
545 $db = '';
547 $goto = 'main.php';
549 // Loads to target script
550 if ($goto != 'main.php') {
551 require_once './libraries/header.inc.php';
553 $active_page = $goto;
554 require './' . $goto;
555 } else {
556 // avoid a redirect loop when last record was deleted
557 if (0 == $num_rows && 'sql.php' == $cfg['DefaultTabTable']) {
558 $goto = str_replace('sql.php','tbl_structure.php',$goto);
560 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto) . '&message=' . urlencode($message));
561 } // end else
562 exit();
563 } // end no rows returned
565 // At least one row is returned -> displays a table with results
566 else {
567 // Displays the headers
568 if (isset($show_query)) {
569 unset($show_query);
571 if (isset($printview) && $printview == '1') {
572 require_once './libraries/header_printview.inc.php';
573 } else {
574 unset($message);
575 if (strlen($table)) {
576 require './libraries/tbl_common.php';
577 $url_query .= '&amp;goto=tbl_sql.php&amp;back=tbl_sql.php';
578 require './libraries/tbl_info.inc.php';
579 require './libraries/tbl_links.inc.php';
580 } elseif (strlen($db)) {
581 require './libraries/db_common.inc.php';
582 require './libraries/db_info.inc.php';
583 } else {
584 require './libraries/server_common.inc.php';
585 require './libraries/server_links.inc.php';
589 if (strlen($db)) {
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 if (isset($label)) {
621 $message = PMA_message::success(__('Bookmark %s created'));
622 $message->addParam($label);
623 $message->display();
626 PMA_displayTable($result, $disp_mode, $analyzed_sql);
627 PMA_DBI_free_result($result);
629 // BEGIN INDEX CHECK See if indexes should be checked.
630 if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) {
631 foreach ($selected as $idx => $tbl_name) {
632 $check = PMA_Index::findDuplicates($tbl_name, $db);
633 if (! empty($check)) {
634 printf(__('Problems with indexes of table `%s`'), $tbl_name);
635 echo $check;
638 } // End INDEX CHECK
640 // Bookmark support if required
641 if ($disp_mode[7] == '1'
642 && (! empty($cfg['Bookmark']) && empty($id_bookmark))
643 && !empty($sql_query)) {
644 echo "\n";
646 $goto = 'sql.php?'
647 . PMA_generate_common_url($db, $table)
648 . '&amp;sql_query=' . urlencode($sql_query)
649 . '&amp;id_bookmark=1';
652 <form action="sql.php" method="post" onsubmit="return emptyFormElements(this, 'fields[label]');">
653 <?php echo PMA_generate_common_hidden_inputs(); ?>
654 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
655 <input type="hidden" name="fields[dbase]" value="<?php echo htmlspecialchars($db); ?>" />
656 <input type="hidden" name="fields[user]" value="<?php echo $cfg['Bookmark']['user']; ?>" />
657 <input type="hidden" name="fields[query]" value="<?php echo urlencode(isset($complete_query) ? $complete_query : $sql_query); ?>" />
658 <fieldset>
659 <legend><?php
660 echo ($cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_bookmark.png" width="16" height="16" alt="' . __('Bookmark this SQL query') . '" />' : '')
661 . __('Bookmark this SQL query');
663 </legend>
665 <div class="formelement">
666 <label for="fields_label_"><?php echo __('Label'); ?>:</label>
667 <input type="text" id="fields_label_" name="fields[label]" value="" />
668 </div>
670 <div class="formelement">
671 <input type="checkbox" name="bkm_all_users" id="bkm_all_users" value="true" />
672 <label for="bkm_all_users"><?php echo __('Let every user access this bookmark'); ?></label>
673 </div>
675 <div class="clearfloat"></div>
676 </fieldset>
677 <fieldset class="tblFooters">
678 <input type="submit" name="store_bkm" value="<?php echo __('Bookmark this SQL query'); ?>" />
679 </fieldset>
680 </form>
681 <?php
682 } // end bookmark support
684 // Do print the page if required
685 if (isset($printview) && $printview == '1') {
687 <script type="text/javascript">
688 //<![CDATA[
689 // Do print the page
690 window.onload = function()
692 if (typeof(window.print) != 'undefined') {
693 window.print();
696 //]]>
697 </script>
698 <?php
699 } // end print case
700 } // end rows returned
703 * Displays the footer
705 require './libraries/footer.inc.php';