Use unicode non breakable space instead of  .
[phpmyadmin/crack.git] / sql.php
blobf2f4e5b8242a2bd42b83457bcb47b2f7b22e89fe
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/tbl_indexes.lib.php';
15 require_once './libraries/check_user_privileges.lib.php';
16 require_once './libraries/bookmark.lib.php';
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 } // end if (security checkings)
31 if (empty($goto)) {
32 $goto = (! strlen($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable'];
33 $is_gotofile = true;
34 } // 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 an 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_queryBookmarks($db,
56 $GLOBALS['cfg']['Bookmark'], '\'' . 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_addBookmarks($fields, $cfg['Bookmark'], (isset($bkm_all_users) && $bkm_all_users == 'true' ? true : false));
109 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . $goto);
110 } // end if
113 * Parse and analyze the query
115 require_once './libraries/parse_analyze.lib.php';
118 * Sets or modifies the $goto variable if required
120 if ($goto == 'sql.php') {
121 $is_gotofile = false;
122 $goto = 'sql.php?'
123 . PMA_generate_common_url($db, $table)
124 . '&amp;sql_query=' . urlencode($sql_query);
125 } // end if
129 * Go back to further page if table should not be dropped
131 if (isset($btnDrop) && $btnDrop == $strNo) {
132 if (!empty($back)) {
133 $goto = $back;
135 if ($is_gotofile) {
136 if (strpos($goto, 'db_') === 0 && strlen($table)) {
137 $table = '';
139 $active_page = $goto;
140 require './' . PMA_securePath($goto);
141 } else {
142 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto));
144 exit();
145 } // end if
149 * Displays the confirm page if required
151 * This part of the script is bypassed if $is_js_confirmed = 1 (already checked
152 * with js) because possible security issue is not so important here: at most,
153 * the confirm message isn't displayed.
155 * Also bypassed if only showing php code.or validating a SQL query
157 if (! $cfg['Confirm'] || isset($_REQUEST['is_js_confirmed']) || isset($btnDrop)
158 // if we are coming from a "Create PHP code" or a "Without PHP Code"
159 // dialog, we won't execute the query anyway, so don't confirm
160 //|| !empty($GLOBALS['show_as_php'])
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 or renamed -> left 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('@^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 && !preg_match('@[[:space:]]LIMIT[[:space:]0-9,-]+(;)?$@i', $sql_query)
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'])) {
294 PMA_DBI_query('SET PROFILING=1;');
297 // garvin: Measure query time.
298 // TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411
299 $querytime_before = array_sum(explode(' ', microtime()));
301 $result = @PMA_DBI_try_query($full_sql_query, null, PMA_DBI_QUERY_STORE);
303 $querytime_after = array_sum(explode(' ', microtime()));
305 $GLOBALS['querytime'] = $querytime_after - $querytime_before;
307 // Displays an error message if required and stop parsing the script
308 if ($error = PMA_DBI_getError()) {
309 if ($is_gotofile) {
310 if (strpos($goto, 'db_') === 0 && strlen($table)) {
311 $table = '';
313 $active_page = $goto;
314 $message = PMA_Message::rawError($error);
315 require './' . PMA_securePath($goto);
316 } else {
317 require_once './libraries/header.inc.php';
318 $full_err_url = (preg_match('@^(db|tbl)_@', $err_url))
319 ? $err_url . '&amp;show_query=1&amp;sql_query=' . urlencode($sql_query)
320 : $err_url;
321 PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
323 exit;
325 unset($error);
327 // Gets the number of rows affected/returned
328 // (This must be done immediately after the query because
329 // mysql_affected_rows() reports about the last query done)
331 if (!$is_affected) {
332 $num_rows = ($result) ? @PMA_DBI_num_rows($result) : 0;
333 } elseif (!isset($num_rows)) {
334 $num_rows = @PMA_DBI_affected_rows();
337 // Grabs the profiling results
338 if (isset($_SESSION['profiling'])) {
339 $profiling_results = PMA_DBI_fetch_result('SHOW PROFILE;');
342 // Checks if the current database has changed
343 // This could happen if the user sends a query like "USE `database`;"
345 * commented out auto-switching to active database - really required?
346 * bug #1814718 win: table list disappears (mixed case db names)
347 * https://sourceforge.net/support/tracker.php?aid=1814718
348 * @todo RELEASE test and comit or rollback before release
349 $current_db = PMA_DBI_fetch_value('SELECT DATABASE()');
350 if ($db !== $current_db) {
351 $db = $current_db;
352 $reload = 1;
354 unset($current_db);
357 // tmpfile remove after convert encoding appended by Y.Kawada
358 if (function_exists('PMA_kanji_file_conv')
359 && (isset($textfile) && file_exists($textfile))) {
360 unlink($textfile);
363 // Counts the total number of rows for the same 'SELECT' query without the
364 // 'LIMIT' clause that may have been programatically added
366 if (empty($sql_limit_to_append)) {
367 $unlim_num_rows = $num_rows;
368 // if we did not append a limit, set this to get a correct
369 // "Showing rows..." message
370 //$_SESSION['userconf']['max_rows'] = 'all';
371 } elseif ($is_select) {
373 // c o u n t q u e r y
375 // If we are "just browsing", there is only one table,
376 // and no where clause (or just 'WHERE 1 '),
377 // so we do a quick count (which uses MaxExactCount)
378 // because SQL_CALC_FOUND_ROWS
379 // is not quick on large InnoDB tables
381 // but do not count again if we did it previously
382 // due to $find_real_end == true
384 if (!$is_group
385 && !isset($analyzed_sql[0]['queryflags']['union'])
386 && !isset($analyzed_sql[0]['table_ref'][1]['table_name'])
387 && (empty($analyzed_sql[0]['where_clause'])
388 || $analyzed_sql[0]['where_clause'] == '1 ')
389 && !isset($find_real_end)
392 // "j u s t b r o w s i n g"
393 $unlim_num_rows = PMA_Table::countRecords($db, $table, true);
395 } else { // n o t " j u s t b r o w s i n g "
397 // add select expression after the SQL_CALC_FOUND_ROWS
399 // for UNION, just adding SQL_CALC_FOUND_ROWS
400 // after the first SELECT works.
402 // take the left part, could be:
403 // SELECT
404 // (SELECT
405 $count_query = PMA_SQP_formatHtml($parsed_sql, 'query_only', 0, $analyzed_sql[0]['position_of_first_select'] + 1);
406 $count_query .= ' SQL_CALC_FOUND_ROWS ';
407 // add everything that was after the first SELECT
408 $count_query .= PMA_SQP_formatHtml($parsed_sql, 'query_only', $analyzed_sql[0]['position_of_first_select']+1);
409 // ensure there is no semicolon at the end of the
410 // count query because we'll probably add
411 // a LIMIT 1 clause after it
412 $count_query = rtrim($count_query);
413 $count_query = rtrim($count_query, ';');
415 // if using SQL_CALC_FOUND_ROWS, add a LIMIT to avoid
416 // long delays. Returned count will be complete anyway.
417 // (but a LIMIT would disrupt results in an UNION)
419 if (!isset($analyzed_sql[0]['queryflags']['union'])) {
420 $count_query .= ' LIMIT 1';
423 // run the count query
425 PMA_DBI_try_query($count_query);
426 // if (mysql_error()) {
427 // void.
428 // I tried the case
429 // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`)
430 // UNION (SELECT `User`, `Host`, "%" AS "Db",
431 // `Select_priv`
432 // FROM `user`) ORDER BY `User`, `Host`, `Db`;
433 // and although the generated count_query is wrong
434 // the SELECT FOUND_ROWS() work! (maybe it gets the
435 // count from the latest query that worked)
437 // another case where the count_query is wrong:
438 // SELECT COUNT(*), f1 from t1 group by f1
439 // and you click to sort on count(*)
440 // }
441 $unlim_num_rows = PMA_DBI_fetch_value('SELECT FOUND_ROWS()');
442 } // end else "just browsing"
444 } else { // not $is_select
445 $unlim_num_rows = 0;
446 } // end rows total count
448 // garvin: if a table or database gets dropped, check column comments.
449 if (isset($purge) && $purge == '1') {
450 require_once './libraries/relation_cleanup.lib.php';
452 if (strlen($table) && strlen($db)) {
453 PMA_relationsCleanupTable($db, $table);
454 } elseif (strlen($db)) {
455 PMA_relationsCleanupDatabase($db);
456 } else {
457 // garvin: VOID. No DB/Table gets deleted.
458 } // end if relation-stuff
459 } // end if ($purge)
461 // garvin: If a column gets dropped, do relation magic.
462 if (isset($cpurge) && $cpurge == '1' && isset($purgekey)
463 && strlen($db) && strlen($table) && !empty($purgekey)) {
464 require_once './libraries/relation_cleanup.lib.php';
465 PMA_relationsCleanupColumn($db, $table, $purgekey);
467 } // end if column PMA_* purge
468 } // end else "didn't ask to see php code"
470 // No rows returned -> move back to the calling page
471 if ($num_rows < 1 || $is_affected) {
472 if ($is_delete) {
473 $message = PMA_Message::success('strRowsDeleted');
474 $message->addParam($num_rows);
475 } elseif ($is_insert) {
476 if ($is_replace) {
477 /* For replace we get DELETED + INSERTED row count, so we have to call it affected */
478 $message = PMA_Message::success('strRowsAffected');
479 $message->addParam($num_rows);
480 } else {
481 $message = PMA_Message::success('strRowsInserted');
482 $message->addParam($num_rows);
484 $insert_id = PMA_DBI_insert_id();
485 if ($insert_id != 0) {
486 // insert_id is id of FIRST record inserted in one insert, so if we inserted multiple rows, we had to increment this
487 $message->addMessage('[br]');
488 // need to use a temporary because the Message class
489 // currently supports adding parameters only to the first
490 // message
491 $_inserted = PMA_Message::notice('strInsertedRowId');
492 $_inserted->addParam($insert_id + $num_rows - 1);
493 $message->addMessage($_inserted);
495 } elseif ($is_affected) {
496 $message = PMA_Message::success('strRowsAffected');
497 $message->addParam($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 $strSuccess and sent with
505 // the form should not have priority over
506 // errors like $strEmptyResultSet
507 } elseif (!empty($zero_rows) && !$is_select) {
508 $message = PMA_Message::rawSuccess($zero_rows);
509 } elseif (!empty($GLOBALS['show_as_php'])) {
510 $message = PMA_Message::success('strShowingPhp');
511 } elseif (isset($GLOBALS['show_as_php'])) {
512 /* User disable showing as PHP, query is only displayed */
513 $message = PMA_Message::notice('strShowingSQL');
514 } elseif (!empty($GLOBALS['validatequery'])) {
515 $message = PMA_Message::notice('strValidateSQL');
516 } else {
517 $message = PMA_Message::success('strEmptyResultSet');
520 if (isset($GLOBALS['querytime'])) {
521 $_querytime = PMA_Message::notice('strQueryTime');
522 $_querytime->addParam($GLOBALS['querytime']);
523 $message->addMessage('(');
524 $message->addMessage($_querytime);
525 $message->addMessage(')');
528 if ($is_gotofile) {
529 $goto = PMA_securePath($goto);
530 // Checks for a valid target script
531 $is_db = $is_table = false;
532 include 'libraries/db_table_exists.lib.php';
533 if (strpos($goto, 'tbl_') === 0 && ! $is_table) {
534 if (strlen($table)) {
535 $table = '';
537 $goto = 'db_sql.php';
539 if (strpos($goto, 'db_') === 0 && ! $is_db) {
540 if (strlen($db)) {
541 $db = '';
543 $goto = 'main.php';
545 // Loads to target script
546 if (strpos($goto, 'db_') === 0
547 || strpos($goto, 'tbl_') === 0) {
548 $GLOBALS['js_include'][] = 'functions.js';
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 ('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 $GLOBALS['js_include'][] = 'functions.js';
575 unset($message);
576 if (strlen($table)) {
577 require './libraries/tbl_common.php';
578 $url_query .= '&amp;goto=tbl_sql.php&amp;back=tbl_sql.php';
579 require './libraries/tbl_info.inc.php';
580 require './libraries/tbl_links.inc.php';
581 } elseif (strlen($db)) {
582 require './libraries/db_common.inc.php';
583 require './libraries/db_info.inc.php';
584 } else {
585 require './libraries/server_common.inc.php';
586 require './libraries/server_links.inc.php';
590 if (strlen($db)) {
591 require_once './libraries/relation.lib.php';
592 $cfgRelation = PMA_getRelationsParam();
595 // Gets the list of fields properties
596 if (isset($result) && $result) {
597 $fields_meta = PMA_DBI_get_fields_meta($result);
598 $fields_cnt = count($fields_meta);
601 // Display previous update query (from tbl_replace)
602 if (isset($disp_query) && $cfg['ShowSQL'] == true) {
603 PMA_showMessage($disp_message, $disp_query, 'success');
606 if (isset($profiling_results)) {
607 PMA_profilingResults($profiling_results);
610 // Displays the results in a table
611 if (empty($disp_mode)) {
612 // see the "PMA_setDisplayMode()" function in
613 // libraries/display_tbl.lib.php
614 $disp_mode = 'urdr111101';
617 // hide edit and delete links for information_schema
618 if ($db == 'information_schema') {
619 $disp_mode = 'nnnn110111';
622 PMA_displayTable($result, $disp_mode, $analyzed_sql);
623 PMA_DBI_free_result($result);
625 // BEGIN INDEX CHECK See if indexes should be checked.
626 if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) {
627 foreach ($selected as $idx => $tbl_name) {
628 $check = PMA_check_indexes($tbl_name);
629 if (! empty($check)) {
631 <table border="0" cellpadding="2" cellspacing="0">
632 <tr>
633 <td class="tblHeaders" colspan="7"><?php printf($strIndexWarningTable, urldecode($tbl_name)); ?></td>
634 </tr>
635 <?php echo $check; ?>
636 </table>
637 <?php
640 } // End INDEX CHECK
642 // Bookmark support if required
643 if ($disp_mode[7] == '1'
644 && (isset($cfg['Bookmark']) && ! empty($cfg['Bookmark']['db']) && ! empty($cfg['Bookmark']['table']) && empty($id_bookmark))
645 && !empty($sql_query)) {
646 echo "\n";
648 $goto = 'sql.php?'
649 . PMA_generate_common_url($db, $table)
650 . '&amp;sql_query=' . urlencode($sql_query)
651 . '&amp;id_bookmark=1';
654 <form action="sql.php" method="post" onsubmit="return emptyFormElements(this, 'fields[label]');">
655 <?php echo PMA_generate_common_hidden_inputs(); ?>
656 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
657 <input type="hidden" name="fields[dbase]" value="<?php echo htmlspecialchars($db); ?>" />
658 <input type="hidden" name="fields[user]" value="<?php echo $cfg['Bookmark']['user']; ?>" />
659 <input type="hidden" name="fields[query]" value="<?php echo urlencode(isset($complete_query) ? $complete_query : $sql_query); ?>" />
660 <fieldset>
661 <legend><?php
662 echo ($cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_bookmark.png" width="16" height="16" alt="' . $strBookmarkThis . '" />' : '')
663 . $strBookmarkThis;
665 </legend>
667 <div class="formelement">
668 <label for="fields_label_"><?php echo $strBookmarkLabel; ?>:</label>
669 <input type="text" id="fields_label_" name="fields[label]" value="" />
670 </div>
672 <div class="formelement">
673 <input type="checkbox" name="bkm_all_users" id="bkm_all_users" value="true" />
674 <label for="bkm_all_users"><?php echo $strBookmarkAllUsers; ?></label>
675 </div>
677 <div class="clearfloat"></div>
678 </fieldset>
679 <fieldset class="tblFooters">
680 <input type="submit" name="store_bkm" value="<?php echo $strBookmarkThis; ?>" />
681 </fieldset>
682 </form>
683 <?php
684 } // end bookmark support
686 // Do print the page if required
687 if (isset($printview) && $printview == '1') {
689 <script type="text/javascript">
690 //<![CDATA[
691 // Do print the page
692 window.onload = function()
694 if (typeof(window.print) != 'undefined') {
695 window.print();
698 //]]>
699 </script>
700 <?php
701 } // end print case
702 } // end rows returned
705 * Displays the footer
707 require_once './libraries/footer.inc.php';