3.5.2-rc2
[phpmyadmin/crack.git] / sql.php
blobeabf89afd64bc54ac9bf698cd6b0d89e240c122b
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 * @version $Id$
7 * @package phpMyAdmin
8 */
10 /**
11 * Gets some core libraries
13 require_once './libraries/common.inc.php';
14 require_once './libraries/Table.class.php';
15 require_once './libraries/check_user_privileges.lib.php';
16 require_once './libraries/bookmark.lib.php';
18 $GLOBALS['js_include'][] = 'mootools.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 } else {
32 $goto = (! strlen($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable'];
33 $is_gotofile = true;
34 } // end if
36 if (!isset($err_url)) {
37 $err_url = (!empty($back) ? $back : $goto)
38 . '?' . PMA_generate_common_url($db)
39 . ((strpos(' ' . $goto, 'db_') != 1 && strlen($table)) ? '&amp;table=' . urlencode($table) : '');
40 } // end if
42 // Coming from a bookmark dialog
43 if (isset($fields['query'])) {
44 $sql_query = $fields['query'];
47 // This one is just to fill $db
48 if (isset($fields['dbase'])) {
49 $db = $fields['dbase'];
52 // Default to browse if no query set and we have table
53 // (needed for browsing from DefaultTabTable)
54 if (empty($sql_query) && strlen($table) && strlen($db)) {
55 require_once './libraries/bookmark.lib.php';
56 $book_sql_query = PMA_Bookmark_get($db, '\'' . PMA_sqlAddslashes($table) . '\'',
57 'label');
59 if (! empty($book_sql_query)) {
60 $sql_query = $book_sql_query;
61 } else {
62 $sql_query = 'SELECT * FROM ' . PMA_backquote($table);
64 unset($book_sql_query);
66 // set $goto to what will be displayed if query returns 0 rows
67 $goto = 'tbl_structure.php';
68 } else {
69 // Now we can check the parameters
70 PMA_checkParameters(array('sql_query'));
73 // instead of doing the test twice
74 $is_drop_database = preg_match('/DROP[[:space:]]+(DATABASE|SCHEMA)[[:space:]]+/i',
75 $sql_query);
77 /**
78 * Check rights in case of DROP DATABASE
80 * This test may be bypassed if $is_js_confirmed = 1 (already checked with js)
81 * but since a malicious user may pass this variable by url/form, we don't take
82 * into account this case.
84 if (!defined('PMA_CHK_DROP')
85 && !$cfg['AllowUserDropDatabase']
86 && $is_drop_database
87 && !$is_superuser) {
88 require_once './libraries/header.inc.php';
89 PMA_mysqlDie($strNoDropDatabases, '', '', $err_url);
90 } // end if
92 require_once './libraries/display_tbl.lib.php';
93 PMA_displayTable_checkConfigParams();
95 /**
96 * Need to find the real end of rows?
98 if (isset($find_real_end) && $find_real_end) {
99 $unlim_num_rows = PMA_Table::countRecords($db, $table, true, true);
100 $_SESSION['userconf']['pos'] = @((ceil($unlim_num_rows / $_SESSION['userconf']['max_rows']) - 1) * $_SESSION['userconf']['max_rows']);
105 * Bookmark add
107 if (isset($store_bkm)) {
108 PMA_Bookmark_save($fields, (isset($bkm_all_users) && $bkm_all_users == 'true' ? true : false));
109 // go back to sql.php to redisplay query; do not use &amp; in this case:
110 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . $goto . '&label=' . $fields['label']);
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 || isset($GLOBALS['show_as_php'])
162 || !empty($GLOBALS['validatequery'])) {
163 $do_confirm = false;
164 } else {
165 $do_confirm = isset($analyzed_sql[0]['queryflags']['need_confirm']);
168 if ($do_confirm) {
169 $stripped_sql_query = $sql_query;
170 require_once './libraries/header.inc.php';
171 if ($is_drop_database) {
172 echo '<h1 class="warning">' . $strDropDatabaseStrongWarning . '</h1>';
174 echo '<form action="sql.php" method="post">' . "\n"
175 .PMA_generate_common_hidden_inputs($db, $table);
177 <input type="hidden" name="sql_query" value="<?php echo htmlspecialchars($sql_query); ?>" />
178 <input type="hidden" name="zero_rows" value="<?php echo isset($zero_rows) ? PMA_sanitize($zero_rows) : ''; ?>" />
179 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
180 <input type="hidden" name="back" value="<?php echo isset($back) ? PMA_sanitize($back) : ''; ?>" />
181 <input type="hidden" name="reload" value="<?php echo isset($reload) ? PMA_sanitize($reload) : 0; ?>" />
182 <input type="hidden" name="purge" value="<?php echo isset($purge) ? PMA_sanitize($purge) : ''; ?>" />
183 <input type="hidden" name="cpurge" value="<?php echo isset($cpurge) ? PMA_sanitize($cpurge) : ''; ?>" />
184 <input type="hidden" name="purgekey" value="<?php echo isset($purgekey) ? PMA_sanitize($purgekey) : ''; ?>" />
185 <input type="hidden" name="show_query" value="<?php echo isset($show_query) ? PMA_sanitize($show_query) : ''; ?>" />
186 <?php
187 echo '<fieldset class="confirmation">' . "\n"
188 .' <legend>' . $strDoYouReally . '</legend>'
189 .' <tt>' . htmlspecialchars($stripped_sql_query) . '</tt>' . "\n"
190 .'</fieldset>' . "\n"
191 .'<fieldset class="tblFooters">' . "\n";
193 <input type="submit" name="btnDrop" value="<?php echo $strYes; ?>" id="buttonYes" />
194 <input type="submit" name="btnDrop" value="<?php echo $strNo; ?>" id="buttonNo" />
195 <?php
196 echo '</fieldset>' . "\n"
197 . '</form>' . "\n";
200 * Displays the footer and exit
202 require_once './libraries/footer.inc.php';
203 } // end if $do_confirm
206 // Defines some variables
207 // A table has to be created, renamed, dropped -> navi frame should be reloaded
209 * @todo use the parser/analyzer
212 if (empty($reload)
213 && preg_match('/^(CREATE|ALTER|DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $sql_query)) {
214 $reload = 1;
217 // SK -- Patch: $is_group added for use in calculation of total number of
218 // rows.
219 // $is_count is changed for more correct "LIMIT" clause
220 // appending in queries like
221 // "SELECT COUNT(...) FROM ... GROUP BY ..."
224 * @todo detect all this with the parser, to avoid problems finding
225 * those strings in comments or backquoted identifiers
228 $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;
229 if ($is_select) { // see line 141
230 $is_group = preg_match('@(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+@i', $sql_query);
231 $is_func = !$is_group && (preg_match('@[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(@i', $sql_query));
232 $is_count = !$is_group && (preg_match('@^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)@i', $sql_query));
233 $is_export = (preg_match('@[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+@i', $sql_query));
234 $is_analyse = (preg_match('@[[:space:]]+PROCEDURE[[:space:]]+ANALYSE@i', $sql_query));
235 } elseif (preg_match('@^EXPLAIN[[:space:]]+@i', $sql_query)) {
236 $is_explain = true;
237 } elseif (preg_match('@^DELETE[[:space:]]+@i', $sql_query)) {
238 $is_delete = true;
239 $is_affected = true;
240 } elseif (preg_match('@^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+@i', $sql_query)) {
241 $is_insert = true;
242 $is_affected = true;
243 if (preg_match('@^(REPLACE)[[:space:]]+@i', $sql_query)) {
244 $is_replace = true;
246 } elseif (preg_match('@^UPDATE[[:space:]]+@i', $sql_query)) {
247 $is_affected = true;
248 } elseif (preg_match('@^[[:space:]]*SHOW[[:space:]]+@i', $sql_query)) {
249 $is_show = true;
250 } elseif (preg_match('@^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+@i', $sql_query)) {
251 $is_maint = true;
254 // Do append a "LIMIT" clause?
255 if ((! $cfg['ShowAll'] || $_SESSION['userconf']['max_rows'] != 'all')
256 && ! ($is_count || $is_export || $is_func || $is_analyse)
257 && isset($analyzed_sql[0]['queryflags']['select_from'])
258 && ! isset($analyzed_sql[0]['queryflags']['offset'])
259 && empty($analyzed_sql[0]['limit_clause'])
261 $sql_limit_to_append = ' LIMIT ' . $_SESSION['userconf']['pos'] . ', ' . $_SESSION['userconf']['max_rows'] . " ";
263 $full_sql_query = $analyzed_sql[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_sql[0]['section_after_limit'];
265 * @todo pretty printing of this modified query
267 if (isset($display_query)) {
268 // if the analysis of the original query revealed that we found
269 // a section_after_limit, we now have to analyze $display_query
270 // to display it correctly
272 if (!empty($analyzed_sql[0]['section_after_limit']) && trim($analyzed_sql[0]['section_after_limit']) != ';') {
273 $analyzed_display_query = PMA_SQP_analyze(PMA_SQP_parse($display_query));
274 $display_query = $analyzed_display_query[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_display_query[0]['section_after_limit'];
278 } else {
279 $full_sql_query = $sql_query;
280 } // end if...else
282 if (strlen($db)) {
283 PMA_DBI_select_db($db);
286 // E x e c u t e t h e q u e r y
288 // Only if we didn't ask to see the php code (mikebeck)
289 if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
290 unset($result);
291 $num_rows = 0;
292 } else {
293 if (isset($_SESSION['profiling']) && PMA_profilingSupported()) {
294 PMA_DBI_query('SET PROFILING=1;');
297 // fisharebest: release the session lock, otherwise we won't be able to run other
298 // scripts until the query has finished (which could take a very long time).
299 // Note: footer.inc.php writes debug info to $_SESSION, so debuggers will have to wait.
300 if (empty($_SESSION['debug'])) {
301 session_write_close();
304 // garvin: Measure query time.
305 // TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411
306 $querytime_before = array_sum(explode(' ', microtime()));
308 $result = @PMA_DBI_try_query($full_sql_query, null, PMA_DBI_QUERY_STORE);
310 $querytime_after = array_sum(explode(' ', microtime()));
312 $GLOBALS['querytime'] = $querytime_after - $querytime_before;
314 // Displays an error message if required and stop parsing the script
315 if ($error = PMA_DBI_getError()) {
316 if ($is_gotofile) {
317 if (strpos($goto, 'db_') === 0 && strlen($table)) {
318 $table = '';
320 $active_page = $goto;
321 $message = htmlspecialchars(PMA_Message::rawError($error));
323 * Go to target path.
325 require './' . PMA_securePath($goto);
326 } else {
328 * HTML header.
330 require_once './libraries/header.inc.php';
331 $full_err_url = (preg_match('@^(db|tbl)_@', $err_url))
332 ? $err_url . '&amp;show_query=1&amp;sql_query=' . urlencode($sql_query)
333 : $err_url;
334 PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
336 exit;
338 unset($error);
340 // Gets the number of rows affected/returned
341 // (This must be done immediately after the query because
342 // mysql_affected_rows() reports about the last query done)
344 if (!$is_affected) {
345 $num_rows = ($result) ? @PMA_DBI_num_rows($result) : 0;
346 } elseif (!isset($num_rows)) {
347 $num_rows = @PMA_DBI_affected_rows();
350 // Grabs the profiling results
351 if (isset($_SESSION['profiling']) && PMA_profilingSupported()) {
352 $profiling_results = PMA_DBI_fetch_result('SHOW PROFILE;');
355 // Checks if the current database has changed
356 // This could happen if the user sends a query like "USE `database`;"
358 * commented out auto-switching to active database - really required?
359 * bug #1814718 win: table list disappears (mixed case db names)
360 * https://sourceforge.net/support/tracker.php?aid=1814718
361 * @todo RELEASE test and comit or rollback before release
362 $current_db = PMA_DBI_fetch_value('SELECT DATABASE()');
363 if ($db !== $current_db) {
364 $db = $current_db;
365 $reload = 1;
367 unset($current_db);
370 // tmpfile remove after convert encoding appended by Y.Kawada
371 if (function_exists('PMA_kanji_file_conv')
372 && (isset($textfile) && file_exists($textfile))) {
373 unlink($textfile);
376 // Counts the total number of rows for the same 'SELECT' query without the
377 // 'LIMIT' clause that may have been programatically added
379 if (empty($sql_limit_to_append)) {
380 $unlim_num_rows = $num_rows;
381 // if we did not append a limit, set this to get a correct
382 // "Showing rows..." message
383 //$_SESSION['userconf']['max_rows'] = 'all';
384 } elseif ($is_select) {
386 // c o u n t q u e r y
388 // If we are "just browsing", there is only one table,
389 // and no where clause (or just 'WHERE 1 '),
390 // so we do a quick count (which uses MaxExactCount)
391 // because SQL_CALC_FOUND_ROWS
392 // is not quick on large InnoDB tables
394 // but do not count again if we did it previously
395 // due to $find_real_end == true
397 if (!$is_group
398 && !isset($analyzed_sql[0]['queryflags']['union'])
399 && !isset($analyzed_sql[0]['table_ref'][1]['table_name'])
400 && (empty($analyzed_sql[0]['where_clause'])
401 || $analyzed_sql[0]['where_clause'] == '1 ')
402 && !isset($find_real_end)
405 // "j u s t b r o w s i n g"
406 $unlim_num_rows = PMA_Table::countRecords($db, $table, true);
408 } else { // n o t " j u s t b r o w s i n g "
410 // add select expression after the SQL_CALC_FOUND_ROWS
412 // for UNION, just adding SQL_CALC_FOUND_ROWS
413 // after the first SELECT works.
415 // take the left part, could be:
416 // SELECT
417 // (SELECT
418 $count_query = PMA_SQP_formatHtml($parsed_sql, 'query_only', 0, $analyzed_sql[0]['position_of_first_select'] + 1);
419 $count_query .= ' SQL_CALC_FOUND_ROWS ';
420 // add everything that was after the first SELECT
421 $count_query .= PMA_SQP_formatHtml($parsed_sql, 'query_only', $analyzed_sql[0]['position_of_first_select']+1);
422 // ensure there is no semicolon at the end of the
423 // count query because we'll probably add
424 // a LIMIT 1 clause after it
425 $count_query = rtrim($count_query);
426 $count_query = rtrim($count_query, ';');
428 // if using SQL_CALC_FOUND_ROWS, add a LIMIT to avoid
429 // long delays. Returned count will be complete anyway.
430 // (but a LIMIT would disrupt results in an UNION)
432 if (!isset($analyzed_sql[0]['queryflags']['union'])) {
433 $count_query .= ' LIMIT 1';
436 // run the count query
438 PMA_DBI_try_query($count_query);
439 // if (mysql_error()) {
440 // void.
441 // I tried the case
442 // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`)
443 // UNION (SELECT `User`, `Host`, "%" AS "Db",
444 // `Select_priv`
445 // FROM `user`) ORDER BY `User`, `Host`, `Db`;
446 // and although the generated count_query is wrong
447 // the SELECT FOUND_ROWS() work! (maybe it gets the
448 // count from the latest query that worked)
450 // another case where the count_query is wrong:
451 // SELECT COUNT(*), f1 from t1 group by f1
452 // and you click to sort on count(*)
453 // }
454 $unlim_num_rows = PMA_DBI_fetch_value('SELECT FOUND_ROWS()');
455 } // end else "just browsing"
457 } else { // not $is_select
458 $unlim_num_rows = 0;
459 } // end rows total count
461 // garvin: if a table or database gets dropped, check column comments.
462 if (isset($purge) && $purge == '1') {
464 * Cleanup relations.
466 require_once './libraries/relation_cleanup.lib.php';
468 if (strlen($table) && strlen($db)) {
469 PMA_relationsCleanupTable($db, $table);
470 } elseif (strlen($db)) {
471 PMA_relationsCleanupDatabase($db);
472 } else {
473 // garvin: VOID. No DB/Table gets deleted.
474 } // end if relation-stuff
475 } // end if ($purge)
477 // garvin: If a column gets dropped, do relation magic.
478 if (isset($cpurge) && $cpurge == '1' && isset($purgekey)
479 && strlen($db) && strlen($table) && !empty($purgekey)) {
480 require_once './libraries/relation_cleanup.lib.php';
481 PMA_relationsCleanupColumn($db, $table, $purgekey);
483 } // end if column PMA_* purge
484 } // end else "didn't ask to see php code"
486 // No rows returned -> move back to the calling page
487 if (0 == $num_rows || $is_affected) {
488 if ($is_delete) {
489 $message = PMA_Message::success('strRowsDeleted');
490 $message->addParam($num_rows);
491 } elseif ($is_insert) {
492 if ($is_replace) {
493 /* For replace we get DELETED + INSERTED row count, so we have to call it affected */
494 $message = PMA_Message::success('strRowsAffected');
495 $message->addParam($num_rows);
496 } else {
497 $message = PMA_Message::success('strRowsInserted');
498 $message->addParam($num_rows);
500 $insert_id = PMA_DBI_insert_id();
501 if ($insert_id != 0) {
502 // insert_id is id of FIRST record inserted in one insert, so if we inserted multiple rows, we had to increment this
503 $message->addMessage('[br]');
504 // need to use a temporary because the Message class
505 // currently supports adding parameters only to the first
506 // message
507 $_inserted = PMA_Message::notice('strInsertedRowId');
508 $_inserted->addParam($insert_id + $num_rows - 1);
509 $message->addMessage($_inserted);
511 } elseif ($is_affected) {
512 $message = PMA_Message::success('strRowsAffected');
513 $message->addParam($num_rows);
515 // Ok, here is an explanation for the !$is_select.
516 // The form generated by sql_query_form.lib.php
517 // and db_sql.php has many submit buttons
518 // on the same form, and some confusion arises from the
519 // fact that $zero_rows is sent for every case.
520 // The $zero_rows containing $strSuccess and sent with
521 // the form should not have priority over
522 // errors like $strEmptyResultSet
523 } elseif (!empty($zero_rows) && !$is_select) {
524 $message = PMA_Message::rawSuccess(htmlspecialchars($zero_rows));
525 } elseif (!empty($GLOBALS['show_as_php'])) {
526 $message = PMA_Message::success('strShowingPhp');
527 } elseif (isset($GLOBALS['show_as_php'])) {
528 /* User disable showing as PHP, query is only displayed */
529 $message = PMA_Message::notice('strShowingSQL');
530 } elseif (!empty($GLOBALS['validatequery'])) {
531 $message = PMA_Message::notice('strValidateSQL');
532 } else {
533 $message = PMA_Message::success('strEmptyResultSet');
536 if (isset($GLOBALS['querytime'])) {
537 $_querytime = PMA_Message::notice('strQueryTime');
538 $_querytime->addParam($GLOBALS['querytime']);
539 $message->addMessage('(');
540 $message->addMessage($_querytime);
541 $message->addMessage(')');
544 if ($is_gotofile) {
545 $goto = PMA_securePath($goto);
546 // Checks for a valid target script
547 $is_db = $is_table = false;
548 include 'libraries/db_table_exists.lib.php';
549 if (strpos($goto, 'tbl_') === 0 && ! $is_table) {
550 if (strlen($table)) {
551 $table = '';
553 $goto = 'db_sql.php';
555 if (strpos($goto, 'db_') === 0 && ! $is_db) {
556 if (strlen($db)) {
557 $db = '';
559 $goto = 'main.php';
561 // Loads to target script
562 if (strpos($goto, 'db_') === 0
563 || strpos($goto, 'tbl_') === 0) {
564 $GLOBALS['js_include'][] = 'functions.js';
566 if ($goto != 'main.php') {
567 require_once './libraries/header.inc.php';
569 $active_page = $goto;
570 require './' . $goto;
571 } else {
572 // avoid a redirect loop when last record was deleted
573 if (0 == $num_rows && 'sql.php' == $cfg['DefaultTabTable']) {
574 $goto = str_replace('sql.php','tbl_structure.php',$goto);
576 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto) . '&message=' . urlencode($message));
577 } // end else
578 exit();
579 } // end no rows returned
581 // At least one row is returned -> displays a table with results
582 else {
583 // Displays the headers
584 if (isset($show_query)) {
585 unset($show_query);
587 if (isset($printview) && $printview == '1') {
588 require_once './libraries/header_printview.inc.php';
589 } else {
590 $GLOBALS['js_include'][] = 'functions.js';
591 unset($message);
592 if (strlen($table)) {
593 require './libraries/tbl_common.php';
594 $url_query .= '&amp;goto=tbl_sql.php&amp;back=tbl_sql.php';
595 require './libraries/tbl_info.inc.php';
596 require './libraries/tbl_links.inc.php';
597 } elseif (strlen($db)) {
598 require './libraries/db_common.inc.php';
599 require './libraries/db_info.inc.php';
600 } else {
601 require './libraries/server_common.inc.php';
602 require './libraries/server_links.inc.php';
606 if (strlen($db)) {
607 require_once './libraries/relation.lib.php';
608 $cfgRelation = PMA_getRelationsParam();
611 // Gets the list of fields properties
612 if (isset($result) && $result) {
613 $fields_meta = PMA_DBI_get_fields_meta($result);
614 $fields_cnt = count($fields_meta);
617 // Display previous update query (from tbl_replace)
618 if (isset($disp_query) && $cfg['ShowSQL'] == true) {
619 PMA_showMessage($disp_message, $disp_query, 'success');
622 if (isset($profiling_results)) {
623 PMA_profilingResults($profiling_results);
626 // Displays the results in a table
627 if (empty($disp_mode)) {
628 // see the "PMA_setDisplayMode()" function in
629 // libraries/display_tbl.lib.php
630 $disp_mode = 'urdr111101';
633 // hide edit and delete links for information_schema
634 if ($db == 'information_schema') {
635 $disp_mode = 'nnnn110111';
638 if (isset($label)) {
639 $message = PMA_message::success('strBookmarkCreated');
640 $message->addParam($label);
641 $message->display();
644 PMA_displayTable($result, $disp_mode, $analyzed_sql);
645 PMA_DBI_free_result($result);
647 // BEGIN INDEX CHECK See if indexes should be checked.
648 if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) {
649 foreach ($selected as $idx => $tbl_name) {
650 $check = PMA_Index::findDuplicates($tbl_name, $db);
651 if (! empty($check)) {
652 printf($strIndexWarningTable, $tbl_name);
653 echo $check;
656 } // End INDEX CHECK
658 // Bookmark support if required
659 if ($disp_mode[7] == '1'
660 && (! empty($cfg['Bookmark']) && empty($id_bookmark))
661 && !empty($sql_query)) {
662 echo "\n";
664 $goto = 'sql.php?'
665 . PMA_generate_common_url($db, $table)
666 . '&amp;sql_query=' . urlencode($sql_query)
667 . '&amp;id_bookmark=1';
670 <form action="sql.php" method="post" onsubmit="return emptyFormElements(this, 'fields[label]');">
671 <?php echo PMA_generate_common_hidden_inputs(); ?>
672 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
673 <input type="hidden" name="fields[dbase]" value="<?php echo htmlspecialchars($db); ?>" />
674 <input type="hidden" name="fields[user]" value="<?php echo $cfg['Bookmark']['user']; ?>" />
675 <input type="hidden" name="fields[query]" value="<?php echo urlencode(isset($complete_query) ? $complete_query : $sql_query); ?>" />
676 <fieldset>
677 <legend><?php
678 echo ($cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_bookmark.png" width="16" height="16" alt="' . $strBookmarkThis . '" />' : '')
679 . $strBookmarkThis;
681 </legend>
683 <div class="formelement">
684 <label for="fields_label_"><?php echo $strBookmarkLabel; ?>:</label>
685 <input type="text" id="fields_label_" name="fields[label]" value="" />
686 </div>
688 <div class="formelement">
689 <input type="checkbox" name="bkm_all_users" id="bkm_all_users" value="true" />
690 <label for="bkm_all_users"><?php echo $strBookmarkAllUsers; ?></label>
691 </div>
693 <div class="clearfloat"></div>
694 </fieldset>
695 <fieldset class="tblFooters">
696 <input type="submit" name="store_bkm" value="<?php echo $strBookmarkThis; ?>" />
697 </fieldset>
698 </form>
699 <?php
700 } // end bookmark support
702 // Do print the page if required
703 if (isset($printview) && $printview == '1') {
705 <script type="text/javascript">
706 //<![CDATA[
707 // Do print the page
708 window.onload = function()
710 if (typeof(window.print) != 'undefined') {
711 window.print();
714 //]]>
715 </script>
716 <?php
717 } // end print case
718 } // end rows returned
721 * Displays the footer
723 require_once './libraries/footer.inc.php';