bug #1971221 [interface] tabindex not set correctly
[phpmyadmin/crack.git] / sql.php
blob281dc6c5cac7351e7d4ceba94e37e35c4543be05
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';
18 $GLOBALS['js_include'][] = 'mootools-domready.js';
20 /**
21 * Defines the url to return to in case of error in a sql statement
23 // Security checkings
24 if (!empty($goto)) {
25 $is_gotofile = preg_replace('@^([^?]+).*$@s', '\\1', $goto);
26 if (!@file_exists('./' . $is_gotofile)) {
27 unset($goto);
28 } else {
29 $is_gotofile = ($is_gotofile == $goto);
31 } // end if (security checkings)
33 if (empty($goto)) {
34 $goto = (! strlen($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable'];
35 $is_gotofile = true;
36 } // end if
37 if (!isset($err_url)) {
38 $err_url = (!empty($back) ? $back : $goto)
39 . '?' . PMA_generate_common_url($db)
40 . ((strpos(' ' . $goto, 'db_') != 1 && strlen($table)) ? '&amp;table=' . urlencode($table) : '');
41 } // end if
43 // Coming from a bookmark dialog
44 if (isset($fields['query'])) {
45 $sql_query = $fields['query'];
48 // This one is just to fill $db
49 if (isset($fields['dbase'])) {
50 $db = $fields['dbase'];
53 // Default to browse if no query set and we have table
54 // (needed for browsing from DefaultTabTable)
55 if (empty($sql_query) && strlen($table) && strlen($db)) {
56 require_once './libraries/bookmark.lib.php';
57 $book_sql_query = PMA_Bookmark_get($db, '\'' . PMA_sqlAddslashes($table) . '\'',
58 'label');
60 if (! empty($book_sql_query)) {
61 $sql_query = $book_sql_query;
62 } else {
63 $sql_query = 'SELECT * FROM ' . PMA_backquote($table);
65 unset($book_sql_query);
67 // set $goto to what will be displayed if query returns 0 rows
68 $goto = 'tbl_structure.php';
69 } else {
70 // Now we can check the parameters
71 PMA_checkParameters(array('sql_query'));
74 // instead of doing the test twice
75 $is_drop_database = preg_match('/DROP[[:space:]]+(DATABASE|SCHEMA)[[:space:]]+/i',
76 $sql_query);
78 /**
79 * Check rights in case of DROP DATABASE
81 * This test may be bypassed if $is_js_confirmed = 1 (already checked with js)
82 * but since a malicious user may pass this variable by url/form, we don't take
83 * into account this case.
85 if (!defined('PMA_CHK_DROP')
86 && !$cfg['AllowUserDropDatabase']
87 && $is_drop_database
88 && !$is_superuser) {
89 require_once './libraries/header.inc.php';
90 PMA_mysqlDie($strNoDropDatabases, '', '', $err_url);
91 } // end if
93 require_once './libraries/display_tbl.lib.php';
94 PMA_displayTable_checkConfigParams();
96 /**
97 * Need to find the real end of rows?
99 if (isset($find_real_end) && $find_real_end) {
100 $unlim_num_rows = PMA_Table::countRecords($db, $table, true, true);
101 $_SESSION['userconf']['pos'] = @((ceil($unlim_num_rows / $_SESSION['userconf']['max_rows']) - 1) * $_SESSION['userconf']['max_rows']);
106 * Bookmark add
108 if (isset($store_bkm)) {
109 PMA_Bookmark_save($fields, (isset($bkm_all_users) && $bkm_all_users == 'true' ? true : false));
110 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . $goto);
111 } // end if
114 * Parse and analyze the query
116 require_once './libraries/parse_analyze.lib.php';
119 * Sets or modifies the $goto variable if required
121 if ($goto == 'sql.php') {
122 $is_gotofile = false;
123 $goto = 'sql.php?'
124 . PMA_generate_common_url($db, $table)
125 . '&amp;sql_query=' . urlencode($sql_query);
126 } // end if
130 * Go back to further page if table should not be dropped
132 if (isset($btnDrop) && $btnDrop == $strNo) {
133 if (!empty($back)) {
134 $goto = $back;
136 if ($is_gotofile) {
137 if (strpos($goto, 'db_') === 0 && strlen($table)) {
138 $table = '';
140 $active_page = $goto;
141 require './' . PMA_securePath($goto);
142 } else {
143 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto));
145 exit();
146 } // end if
150 * Displays the confirm page if required
152 * This part of the script is bypassed if $is_js_confirmed = 1 (already checked
153 * with js) because possible security issue is not so important here: at most,
154 * the confirm message isn't displayed.
156 * Also bypassed if only showing php code.or validating a SQL query
158 if (! $cfg['Confirm'] || isset($_REQUEST['is_js_confirmed']) || isset($btnDrop)
159 // if we are coming from a "Create PHP code" or a "Without PHP Code"
160 // dialog, we won't execute the query anyway, so don't confirm
161 //|| !empty($GLOBALS['show_as_php'])
162 || isset($GLOBALS['show_as_php'])
163 || !empty($GLOBALS['validatequery'])) {
164 $do_confirm = false;
165 } else {
166 $do_confirm = isset($analyzed_sql[0]['queryflags']['need_confirm']);
169 if ($do_confirm) {
170 $stripped_sql_query = $sql_query;
171 require_once './libraries/header.inc.php';
172 if ($is_drop_database) {
173 echo '<h1 class="warning">' . $strDropDatabaseStrongWarning . '</h1>';
175 echo '<form action="sql.php" method="post">' . "\n"
176 .PMA_generate_common_hidden_inputs($db, $table);
178 <input type="hidden" name="sql_query" value="<?php echo htmlspecialchars($sql_query); ?>" />
179 <input type="hidden" name="zero_rows" value="<?php echo isset($zero_rows) ? PMA_sanitize($zero_rows) : ''; ?>" />
180 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
181 <input type="hidden" name="back" value="<?php echo isset($back) ? PMA_sanitize($back) : ''; ?>" />
182 <input type="hidden" name="reload" value="<?php echo isset($reload) ? PMA_sanitize($reload) : 0; ?>" />
183 <input type="hidden" name="purge" value="<?php echo isset($purge) ? PMA_sanitize($purge) : ''; ?>" />
184 <input type="hidden" name="cpurge" value="<?php echo isset($cpurge) ? PMA_sanitize($cpurge) : ''; ?>" />
185 <input type="hidden" name="purgekey" value="<?php echo isset($purgekey) ? PMA_sanitize($purgekey) : ''; ?>" />
186 <input type="hidden" name="show_query" value="<?php echo isset($show_query) ? PMA_sanitize($show_query) : ''; ?>" />
187 <?php
188 echo '<fieldset class="confirmation">' . "\n"
189 .' <legend>' . $strDoYouReally . '</legend>'
190 .' <tt>' . htmlspecialchars($stripped_sql_query) . '</tt>' . "\n"
191 .'</fieldset>' . "\n"
192 .'<fieldset class="tblFooters">' . "\n";
194 <input type="submit" name="btnDrop" value="<?php echo $strYes; ?>" id="buttonYes" />
195 <input type="submit" name="btnDrop" value="<?php echo $strNo; ?>" id="buttonNo" />
196 <?php
197 echo '</fieldset>' . "\n"
198 . '</form>' . "\n";
201 * Displays the footer and exit
203 require_once './libraries/footer.inc.php';
204 } // end if $do_confirm
207 // Defines some variables
208 // A table has to be created, renamed, dropped -> navi frame should be reloaded
210 * @todo use the parser/analyzer
213 if (empty($reload)
214 && preg_match('/^(CREATE|ALTER|DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $sql_query)) {
215 $reload = 1;
218 // SK -- Patch: $is_group added for use in calculation of total number of
219 // rows.
220 // $is_count is changed for more correct "LIMIT" clause
221 // appending in queries like
222 // "SELECT COUNT(...) FROM ... GROUP BY ..."
225 * @todo detect all this with the parser, to avoid problems finding
226 * those strings in comments or backquoted identifiers
229 $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;
230 if ($is_select) { // see line 141
231 $is_group = preg_match('@(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+@i', $sql_query);
232 $is_func = !$is_group && (preg_match('@[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(@i', $sql_query));
233 $is_count = !$is_group && (preg_match('@^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)@i', $sql_query));
234 $is_export = (preg_match('@[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+@i', $sql_query));
235 $is_analyse = (preg_match('@[[:space:]]+PROCEDURE[[:space:]]+ANALYSE@i', $sql_query));
236 } elseif (preg_match('@^EXPLAIN[[:space:]]+@i', $sql_query)) {
237 $is_explain = true;
238 } elseif (preg_match('@^DELETE[[:space:]]+@i', $sql_query)) {
239 $is_delete = true;
240 $is_affected = true;
241 } elseif (preg_match('@^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+@i', $sql_query)) {
242 $is_insert = true;
243 $is_affected = true;
244 if (preg_match('@^(REPLACE)[[:space:]]+@i', $sql_query)) {
245 $is_replace = true;
247 } elseif (preg_match('@^UPDATE[[:space:]]+@i', $sql_query)) {
248 $is_affected = true;
249 } elseif (preg_match('@^[[:space:]]*SHOW[[:space:]]+@i', $sql_query)) {
250 $is_show = true;
251 } elseif (preg_match('@^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+@i', $sql_query)) {
252 $is_maint = true;
255 // Do append a "LIMIT" clause?
256 if ((! $cfg['ShowAll'] || $_SESSION['userconf']['max_rows'] != 'all')
257 && ! ($is_count || $is_export || $is_func || $is_analyse)
258 && isset($analyzed_sql[0]['queryflags']['select_from'])
259 && ! isset($analyzed_sql[0]['queryflags']['offset'])
260 && empty($analyzed_sql[0]['limit_clause'])
262 $sql_limit_to_append = ' LIMIT ' . $_SESSION['userconf']['pos'] . ', ' . $_SESSION['userconf']['max_rows'] . " ";
264 $full_sql_query = $analyzed_sql[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_sql[0]['section_after_limit'];
266 * @todo pretty printing of this modified query
268 if (isset($display_query)) {
269 // if the analysis of the original query revealed that we found
270 // a section_after_limit, we now have to analyze $display_query
271 // to display it correctly
273 if (!empty($analyzed_sql[0]['section_after_limit']) && trim($analyzed_sql[0]['section_after_limit']) != ';') {
274 $analyzed_display_query = PMA_SQP_analyze(PMA_SQP_parse($display_query));
275 $display_query = $analyzed_display_query[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_display_query[0]['section_after_limit'];
279 } else {
280 $full_sql_query = $sql_query;
281 } // end if...else
283 if (strlen($db)) {
284 PMA_DBI_select_db($db);
287 // E x e c u t e t h e q u e r y
289 // Only if we didn't ask to see the php code (mikebeck)
290 if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
291 unset($result);
292 $num_rows = 0;
293 } else {
294 if (isset($_SESSION['profiling']) && PMA_profilingSupported()) {
295 PMA_DBI_query('SET PROFILING=1;');
298 // garvin: Measure query time.
299 // TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411
300 $querytime_before = array_sum(explode(' ', microtime()));
302 $result = @PMA_DBI_try_query($full_sql_query, null, PMA_DBI_QUERY_STORE);
304 $querytime_after = array_sum(explode(' ', microtime()));
306 $GLOBALS['querytime'] = $querytime_after - $querytime_before;
308 // Displays an error message if required and stop parsing the script
309 if ($error = PMA_DBI_getError()) {
310 if ($is_gotofile) {
311 if (strpos($goto, 'db_') === 0 && strlen($table)) {
312 $table = '';
314 $active_page = $goto;
315 $message = PMA_Message::rawError($error);
316 require './' . PMA_securePath($goto);
317 } else {
318 require_once './libraries/header.inc.php';
319 $full_err_url = (preg_match('@^(db|tbl)_@', $err_url))
320 ? $err_url . '&amp;show_query=1&amp;sql_query=' . urlencode($sql_query)
321 : $err_url;
322 PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
324 exit;
326 unset($error);
328 // Gets the number of rows affected/returned
329 // (This must be done immediately after the query because
330 // mysql_affected_rows() reports about the last query done)
332 if (!$is_affected) {
333 $num_rows = ($result) ? @PMA_DBI_num_rows($result) : 0;
334 } elseif (!isset($num_rows)) {
335 $num_rows = @PMA_DBI_affected_rows();
338 // Grabs the profiling results
339 if (isset($_SESSION['profiling']) && PMA_profilingSupported()) {
340 $profiling_results = PMA_DBI_fetch_result('SHOW PROFILE;');
343 // Checks if the current database has changed
344 // This could happen if the user sends a query like "USE `database`;"
346 * commented out auto-switching to active database - really required?
347 * bug #1814718 win: table list disappears (mixed case db names)
348 * https://sourceforge.net/support/tracker.php?aid=1814718
349 * @todo RELEASE test and comit or rollback before release
350 $current_db = PMA_DBI_fetch_value('SELECT DATABASE()');
351 if ($db !== $current_db) {
352 $db = $current_db;
353 $reload = 1;
355 unset($current_db);
358 // tmpfile remove after convert encoding appended by Y.Kawada
359 if (function_exists('PMA_kanji_file_conv')
360 && (isset($textfile) && file_exists($textfile))) {
361 unlink($textfile);
364 // Counts the total number of rows for the same 'SELECT' query without the
365 // 'LIMIT' clause that may have been programatically added
367 if (empty($sql_limit_to_append)) {
368 $unlim_num_rows = $num_rows;
369 // if we did not append a limit, set this to get a correct
370 // "Showing rows..." message
371 //$_SESSION['userconf']['max_rows'] = 'all';
372 } elseif ($is_select) {
374 // c o u n t q u e r y
376 // If we are "just browsing", there is only one table,
377 // and no where clause (or just 'WHERE 1 '),
378 // so we do a quick count (which uses MaxExactCount)
379 // because SQL_CALC_FOUND_ROWS
380 // is not quick on large InnoDB tables
382 // but do not count again if we did it previously
383 // due to $find_real_end == true
385 if (!$is_group
386 && !isset($analyzed_sql[0]['queryflags']['union'])
387 && !isset($analyzed_sql[0]['table_ref'][1]['table_name'])
388 && (empty($analyzed_sql[0]['where_clause'])
389 || $analyzed_sql[0]['where_clause'] == '1 ')
390 && !isset($find_real_end)
393 // "j u s t b r o w s i n g"
394 $unlim_num_rows = PMA_Table::countRecords($db, $table, true);
396 } else { // n o t " j u s t b r o w s i n g "
398 // add select expression after the SQL_CALC_FOUND_ROWS
400 // for UNION, just adding SQL_CALC_FOUND_ROWS
401 // after the first SELECT works.
403 // take the left part, could be:
404 // SELECT
405 // (SELECT
406 $count_query = PMA_SQP_formatHtml($parsed_sql, 'query_only', 0, $analyzed_sql[0]['position_of_first_select'] + 1);
407 $count_query .= ' SQL_CALC_FOUND_ROWS ';
408 // add everything that was after the first SELECT
409 $count_query .= PMA_SQP_formatHtml($parsed_sql, 'query_only', $analyzed_sql[0]['position_of_first_select']+1);
410 // ensure there is no semicolon at the end of the
411 // count query because we'll probably add
412 // a LIMIT 1 clause after it
413 $count_query = rtrim($count_query);
414 $count_query = rtrim($count_query, ';');
416 // if using SQL_CALC_FOUND_ROWS, add a LIMIT to avoid
417 // long delays. Returned count will be complete anyway.
418 // (but a LIMIT would disrupt results in an UNION)
420 if (!isset($analyzed_sql[0]['queryflags']['union'])) {
421 $count_query .= ' LIMIT 1';
424 // run the count query
426 PMA_DBI_try_query($count_query);
427 // if (mysql_error()) {
428 // void.
429 // I tried the case
430 // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`)
431 // UNION (SELECT `User`, `Host`, "%" AS "Db",
432 // `Select_priv`
433 // FROM `user`) ORDER BY `User`, `Host`, `Db`;
434 // and although the generated count_query is wrong
435 // the SELECT FOUND_ROWS() work! (maybe it gets the
436 // count from the latest query that worked)
438 // another case where the count_query is wrong:
439 // SELECT COUNT(*), f1 from t1 group by f1
440 // and you click to sort on count(*)
441 // }
442 $unlim_num_rows = PMA_DBI_fetch_value('SELECT FOUND_ROWS()');
443 } // end else "just browsing"
445 } else { // not $is_select
446 $unlim_num_rows = 0;
447 } // end rows total count
449 // garvin: if a table or database gets dropped, check column comments.
450 if (isset($purge) && $purge == '1') {
451 require_once './libraries/relation_cleanup.lib.php';
453 if (strlen($table) && strlen($db)) {
454 PMA_relationsCleanupTable($db, $table);
455 } elseif (strlen($db)) {
456 PMA_relationsCleanupDatabase($db);
457 } else {
458 // garvin: VOID. No DB/Table gets deleted.
459 } // end if relation-stuff
460 } // end if ($purge)
462 // garvin: If a column gets dropped, do relation magic.
463 if (isset($cpurge) && $cpurge == '1' && isset($purgekey)
464 && strlen($db) && strlen($table) && !empty($purgekey)) {
465 require_once './libraries/relation_cleanup.lib.php';
466 PMA_relationsCleanupColumn($db, $table, $purgekey);
468 } // end if column PMA_* purge
469 } // end else "didn't ask to see php code"
471 // No rows returned -> move back to the calling page
472 if ($num_rows < 1 || $is_affected) {
473 if ($is_delete) {
474 $message = PMA_Message::success('strRowsDeleted');
475 $message->addParam($num_rows);
476 } elseif ($is_insert) {
477 if ($is_replace) {
478 /* For replace we get DELETED + INSERTED row count, so we have to call it affected */
479 $message = PMA_Message::success('strRowsAffected');
480 $message->addParam($num_rows);
481 } else {
482 $message = PMA_Message::success('strRowsInserted');
483 $message->addParam($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('strInsertedRowId');
493 $_inserted->addParam($insert_id + $num_rows - 1);
494 $message->addMessage($_inserted);
496 } elseif ($is_affected) {
497 $message = PMA_Message::success('strRowsAffected');
498 $message->addParam($num_rows);
500 // Ok, here is an explanation for the !$is_select.
501 // The form generated by sql_query_form.lib.php
502 // and db_sql.php has many submit buttons
503 // on the same form, and some confusion arises from the
504 // fact that $zero_rows is sent for every case.
505 // The $zero_rows containing $strSuccess and sent with
506 // the form should not have priority over
507 // errors like $strEmptyResultSet
508 } elseif (!empty($zero_rows) && !$is_select) {
509 $message = PMA_Message::rawSuccess($zero_rows);
510 } elseif (!empty($GLOBALS['show_as_php'])) {
511 $message = PMA_Message::success('strShowingPhp');
512 } elseif (isset($GLOBALS['show_as_php'])) {
513 /* User disable showing as PHP, query is only displayed */
514 $message = PMA_Message::notice('strShowingSQL');
515 } elseif (!empty($GLOBALS['validatequery'])) {
516 $message = PMA_Message::notice('strValidateSQL');
517 } else {
518 $message = PMA_Message::success('strEmptyResultSet');
521 if (isset($GLOBALS['querytime'])) {
522 $_querytime = PMA_Message::notice('strQueryTime');
523 $_querytime->addParam($GLOBALS['querytime']);
524 $message->addMessage('(');
525 $message->addMessage($_querytime);
526 $message->addMessage(')');
529 if ($is_gotofile) {
530 $goto = PMA_securePath($goto);
531 // Checks for a valid target script
532 $is_db = $is_table = false;
533 include 'libraries/db_table_exists.lib.php';
534 if (strpos($goto, 'tbl_') === 0 && ! $is_table) {
535 if (strlen($table)) {
536 $table = '';
538 $goto = 'db_sql.php';
540 if (strpos($goto, 'db_') === 0 && ! $is_db) {
541 if (strlen($db)) {
542 $db = '';
544 $goto = 'main.php';
546 // Loads to target script
547 if (strpos($goto, 'db_') === 0
548 || strpos($goto, 'tbl_') === 0) {
549 $GLOBALS['js_include'][] = 'functions.js';
551 if ($goto != 'main.php') {
552 require_once './libraries/header.inc.php';
554 $active_page = $goto;
555 require './' . $goto;
556 } else {
557 // avoid a redirect loop when last record was deleted
558 if ('sql.php' == $cfg['DefaultTabTable']) {
559 $goto = str_replace('sql.php','tbl_structure.php',$goto);
561 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto) . '&message=' . urlencode($message));
562 } // end else
563 exit();
564 } // end no rows returned
566 // At least one row is returned -> displays a table with results
567 else {
568 // Displays the headers
569 if (isset($show_query)) {
570 unset($show_query);
572 if (isset($printview) && $printview == '1') {
573 require_once './libraries/header_printview.inc.php';
574 } else {
575 $GLOBALS['js_include'][] = 'functions.js';
576 unset($message);
577 if (strlen($table)) {
578 require './libraries/tbl_common.php';
579 $url_query .= '&amp;goto=tbl_sql.php&amp;back=tbl_sql.php';
580 require './libraries/tbl_info.inc.php';
581 require './libraries/tbl_links.inc.php';
582 } elseif (strlen($db)) {
583 require './libraries/db_common.inc.php';
584 require './libraries/db_info.inc.php';
585 } else {
586 require './libraries/server_common.inc.php';
587 require './libraries/server_links.inc.php';
591 if (strlen($db)) {
592 require_once './libraries/relation.lib.php';
593 $cfgRelation = PMA_getRelationsParam();
596 // Gets the list of fields properties
597 if (isset($result) && $result) {
598 $fields_meta = PMA_DBI_get_fields_meta($result);
599 $fields_cnt = count($fields_meta);
602 // Display previous update query (from tbl_replace)
603 if (isset($disp_query) && $cfg['ShowSQL'] == true) {
604 PMA_showMessage($disp_message, $disp_query, 'success');
607 if (isset($profiling_results)) {
608 PMA_profilingResults($profiling_results);
611 // Displays the results in a table
612 if (empty($disp_mode)) {
613 // see the "PMA_setDisplayMode()" function in
614 // libraries/display_tbl.lib.php
615 $disp_mode = 'urdr111101';
618 // hide edit and delete links for information_schema
619 if ($db == 'information_schema') {
620 $disp_mode = 'nnnn110111';
623 PMA_displayTable($result, $disp_mode, $analyzed_sql);
624 PMA_DBI_free_result($result);
626 // BEGIN INDEX CHECK See if indexes should be checked.
627 if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) {
628 foreach ($selected as $idx => $tbl_name) {
629 $check = PMA_Index::findDuplicates($tbl_name, $db);
630 if (! empty($check)) {
631 printf($strIndexWarningTable, $tbl_name);
632 echo $check;
635 } // End INDEX CHECK
637 // Bookmark support if required
638 if ($disp_mode[7] == '1'
639 && (! empty($cfg['Bookmark']) && empty($id_bookmark))
640 && !empty($sql_query)) {
641 echo "\n";
643 $goto = 'sql.php?'
644 . PMA_generate_common_url($db, $table)
645 . '&amp;sql_query=' . urlencode($sql_query)
646 . '&amp;id_bookmark=1';
649 <form action="sql.php" method="post" onsubmit="return emptyFormElements(this, 'fields[label]');">
650 <?php echo PMA_generate_common_hidden_inputs(); ?>
651 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
652 <input type="hidden" name="fields[dbase]" value="<?php echo htmlspecialchars($db); ?>" />
653 <input type="hidden" name="fields[user]" value="<?php echo $cfg['Bookmark']['user']; ?>" />
654 <input type="hidden" name="fields[query]" value="<?php echo urlencode(isset($complete_query) ? $complete_query : $sql_query); ?>" />
655 <fieldset>
656 <legend><?php
657 echo ($cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_bookmark.png" width="16" height="16" alt="' . $strBookmarkThis . '" />' : '')
658 . $strBookmarkThis;
660 </legend>
662 <div class="formelement">
663 <label for="fields_label_"><?php echo $strBookmarkLabel; ?>:</label>
664 <input type="text" id="fields_label_" name="fields[label]" value="" />
665 </div>
667 <div class="formelement">
668 <input type="checkbox" name="bkm_all_users" id="bkm_all_users" value="true" />
669 <label for="bkm_all_users"><?php echo $strBookmarkAllUsers; ?></label>
670 </div>
672 <div class="clearfloat"></div>
673 </fieldset>
674 <fieldset class="tblFooters">
675 <input type="submit" name="store_bkm" value="<?php echo $strBookmarkThis; ?>" />
676 </fieldset>
677 </form>
678 <?php
679 } // end bookmark support
681 // Do print the page if required
682 if (isset($printview) && $printview == '1') {
684 <script type="text/javascript">
685 //<![CDATA[
686 // Do print the page
687 window.onload = function()
689 if (typeof(window.print) != 'undefined') {
690 window.print();
693 //]]>
694 </script>
695 <?php
696 } // end print case
697 } // end rows returned
700 * Displays the footer
702 require_once './libraries/footer.inc.php';