Translation update done using Pootle.
[phpmyadmin/crack.git] / sql.php
blobc2b103123ce555524cda08d99b381c5821ab5b5e
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/Table.class.php';
14 require_once './libraries/check_user_privileges.lib.php';
15 require_once './libraries/bookmark.lib.php';
17 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
19 /**
20 * Defines the url to return to in case of error in a sql statement
22 // Security checkings
23 if (! empty($goto)) {
24 $is_gotofile = preg_replace('@^([^?]+).*$@s', '\\1', $goto);
25 if (! @file_exists('./' . $is_gotofile)) {
26 unset($goto);
27 } else {
28 $is_gotofile = ($is_gotofile == $goto);
30 } else {
31 $goto = (! strlen($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable'];
32 $is_gotofile = true;
33 } // end if
35 if (!isset($err_url)) {
36 $err_url = (!empty($back) ? $back : $goto)
37 . '?' . PMA_generate_common_url($db)
38 . ((strpos(' ' . $goto, 'db_') != 1 && strlen($table)) ? '&amp;table=' . urlencode($table) : '');
39 } // end if
41 // Coming from a bookmark dialog
42 if (isset($fields['query'])) {
43 $sql_query = $fields['query'];
46 // This one is just to fill $db
47 if (isset($fields['dbase'])) {
48 $db = $fields['dbase'];
51 // Default to browse if no query set and we have table
52 // (needed for browsing from DefaultTabTable)
53 if (empty($sql_query) && strlen($table) && strlen($db)) {
54 require_once './libraries/bookmark.lib.php';
55 $book_sql_query = PMA_Bookmark_get($db, '\'' . PMA_sqlAddslashes($table) . '\'',
56 'label');
58 if (! empty($book_sql_query)) {
59 $sql_query = $book_sql_query;
60 } else {
61 $sql_query = 'SELECT * FROM ' . PMA_backquote($table);
63 unset($book_sql_query);
65 // set $goto to what will be displayed if query returns 0 rows
66 $goto = 'tbl_structure.php';
67 } else {
68 // Now we can check the parameters
69 PMA_checkParameters(array('sql_query'));
72 // instead of doing the test twice
73 $is_drop_database = preg_match('/DROP[[:space:]]+(DATABASE|SCHEMA)[[:space:]]+/i',
74 $sql_query);
76 /**
77 * Check rights in case of DROP DATABASE
79 * This test may be bypassed if $is_js_confirmed = 1 (already checked with js)
80 * but since a malicious user may pass this variable by url/form, we don't take
81 * into account this case.
83 if (!defined('PMA_CHK_DROP')
84 && !$cfg['AllowUserDropDatabase']
85 && $is_drop_database
86 && !$is_superuser) {
87 require_once './libraries/header.inc.php';
88 PMA_mysqlDie(__('"DROP DATABASE" statements are disabled.'), '', '', $err_url);
89 } // end if
91 require_once './libraries/display_tbl.lib.php';
92 PMA_displayTable_checkConfigParams();
94 /**
95 * Need to find the real end of rows?
97 if (isset($find_real_end) && $find_real_end) {
98 $unlim_num_rows = PMA_Table::countRecords($db, $table, $force_exact = true);
99 $_SESSION['tmp_user_values']['pos'] = @((ceil($unlim_num_rows / $_SESSION['tmp_user_values']['max_rows']) - 1) * $_SESSION['tmp_user_values']['max_rows']);
104 * Bookmark add
106 if (isset($store_bkm)) {
107 PMA_Bookmark_save($fields, (isset($bkm_all_users) && $bkm_all_users == 'true' ? true : false));
108 // go back to sql.php to redisplay query; do not use &amp; in this case:
109 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . $goto . '&label=' . $fields['label']);
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 == __('No')) {
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 || isset($GLOBALS['show_as_php'])
161 || !empty($GLOBALS['validatequery'])) {
162 $do_confirm = false;
163 } else {
164 $do_confirm = isset($analyzed_sql[0]['queryflags']['need_confirm']);
167 if ($do_confirm) {
168 $stripped_sql_query = $sql_query;
169 require_once './libraries/header.inc.php';
170 if ($is_drop_database) {
171 echo '<h1 class="warning">' . __('You are about to DESTROY a complete database!') . '</h1>';
173 echo '<form action="sql.php" method="post">' . "\n"
174 .PMA_generate_common_hidden_inputs($db, $table);
176 <input type="hidden" name="sql_query" value="<?php echo htmlspecialchars($sql_query); ?>" />
177 <input type="hidden" name="zero_rows" value="<?php echo isset($zero_rows) ? PMA_sanitize($zero_rows) : ''; ?>" />
178 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
179 <input type="hidden" name="back" value="<?php echo isset($back) ? PMA_sanitize($back) : ''; ?>" />
180 <input type="hidden" name="reload" value="<?php echo isset($reload) ? PMA_sanitize($reload) : 0; ?>" />
181 <input type="hidden" name="purge" value="<?php echo isset($purge) ? PMA_sanitize($purge) : ''; ?>" />
182 <input type="hidden" name="cpurge" value="<?php echo isset($cpurge) ? PMA_sanitize($cpurge) : ''; ?>" />
183 <input type="hidden" name="purgekey" value="<?php echo isset($purgekey) ? PMA_sanitize($purgekey) : ''; ?>" />
184 <input type="hidden" name="show_query" value="<?php echo isset($show_query) ? PMA_sanitize($show_query) : ''; ?>" />
185 <?php
186 echo '<fieldset class="confirmation">' . "\n"
187 .' <legend>' . __('Do you really want to ') . '</legend>'
188 .' <tt>' . htmlspecialchars($stripped_sql_query) . '</tt>' . "\n"
189 .'</fieldset>' . "\n"
190 .'<fieldset class="tblFooters">' . "\n";
192 <input type="submit" name="btnDrop" value="<?php echo __('Yes'); ?>" id="buttonYes" />
193 <input type="submit" name="btnDrop" value="<?php echo __('No'); ?>" id="buttonNo" />
194 <?php
195 echo '</fieldset>' . "\n"
196 . '</form>' . "\n";
199 * Displays the footer and exit
201 require_once './libraries/footer.inc.php';
202 } // end if $do_confirm
205 // Defines some variables
206 // A table has to be created, renamed, dropped -> navi frame should be reloaded
208 * @todo use the parser/analyzer
211 if (empty($reload)
212 && preg_match('/^(CREATE|ALTER|DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $sql_query)) {
213 $reload = 1;
216 // SK -- Patch: $is_group added for use in calculation of total number of
217 // rows.
218 // $is_count is changed for more correct "LIMIT" clause
219 // appending in queries like
220 // "SELECT COUNT(...) FROM ... GROUP BY ..."
223 * @todo detect all this with the parser, to avoid problems finding
224 * those strings in comments or backquoted identifiers
227 $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;
228 if ($is_select) { // see line 141
229 $is_group = preg_match('@(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+@i', $sql_query);
230 $is_func = !$is_group && (preg_match('@[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(@i', $sql_query));
231 $is_count = !$is_group && (preg_match('@^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)@i', $sql_query));
232 $is_export = (preg_match('@[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+@i', $sql_query));
233 $is_analyse = (preg_match('@[[:space:]]+PROCEDURE[[:space:]]+ANALYSE@i', $sql_query));
234 } elseif (preg_match('@^EXPLAIN[[:space:]]+@i', $sql_query)) {
235 $is_explain = true;
236 } elseif (preg_match('@^DELETE[[:space:]]+@i', $sql_query)) {
237 $is_delete = true;
238 $is_affected = true;
239 } elseif (preg_match('@^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+@i', $sql_query)) {
240 $is_insert = true;
241 $is_affected = true;
242 if (preg_match('@^(REPLACE)[[:space:]]+@i', $sql_query)) {
243 $is_replace = true;
245 } elseif (preg_match('@^UPDATE[[:space:]]+@i', $sql_query)) {
246 $is_affected = true;
247 } elseif (preg_match('@^[[:space:]]*SHOW[[:space:]]+@i', $sql_query)) {
248 $is_show = true;
249 } elseif (preg_match('@^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+@i', $sql_query)) {
250 $is_maint = true;
253 // Do append a "LIMIT" clause?
254 if ((! $cfg['ShowAll'] || $_SESSION['tmp_user_values']['max_rows'] != 'all')
255 && ! ($is_count || $is_export || $is_func || $is_analyse)
256 && isset($analyzed_sql[0]['queryflags']['select_from'])
257 && ! isset($analyzed_sql[0]['queryflags']['offset'])
258 && empty($analyzed_sql[0]['limit_clause'])
260 $sql_limit_to_append = ' LIMIT ' . $_SESSION['tmp_user_values']['pos'] . ', ' . $_SESSION['tmp_user_values']['max_rows'] . " ";
262 $full_sql_query = $analyzed_sql[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_sql[0]['section_after_limit'];
264 * @todo pretty printing of this modified query
266 if (isset($display_query)) {
267 // if the analysis of the original query revealed that we found
268 // a section_after_limit, we now have to analyze $display_query
269 // to display it correctly
271 if (!empty($analyzed_sql[0]['section_after_limit']) && trim($analyzed_sql[0]['section_after_limit']) != ';') {
272 $analyzed_display_query = PMA_SQP_analyze(PMA_SQP_parse($display_query));
273 $display_query = $analyzed_display_query[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_display_query[0]['section_after_limit'];
277 } else {
278 $full_sql_query = $sql_query;
279 } // end if...else
281 if (strlen($db)) {
282 PMA_DBI_select_db($db);
285 // E x e c u t e t h e q u e r y
287 // Only if we didn't ask to see the php code (mikebeck)
288 if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
289 unset($result);
290 $num_rows = 0;
291 } else {
292 if (isset($_SESSION['profiling']) && PMA_profilingSupported()) {
293 PMA_DBI_query('SET PROFILING=1;');
296 // Measure query time.
297 // TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411
298 $querytime_before = array_sum(explode(' ', microtime()));
300 $result = @PMA_DBI_try_query($full_sql_query, null, PMA_DBI_QUERY_STORE);
302 $querytime_after = array_sum(explode(' ', microtime()));
304 $GLOBALS['querytime'] = $querytime_after - $querytime_before;
306 // Displays an error message if required and stop parsing the script
307 if ($error = PMA_DBI_getError()) {
308 if ($is_gotofile) {
309 if (strpos($goto, 'db_') === 0 && strlen($table)) {
310 $table = '';
312 $active_page = $goto;
313 $message = htmlspecialchars(PMA_Message::rawError($error));
315 * Go to target path.
317 require './' . PMA_securePath($goto);
318 } else {
320 * HTML header.
322 require_once './libraries/header.inc.php';
323 $full_err_url = (preg_match('@^(db|tbl)_@', $err_url))
324 ? $err_url . '&amp;show_query=1&amp;sql_query=' . urlencode($sql_query)
325 : $err_url;
326 PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
328 exit;
330 unset($error);
332 // Gets the number of rows affected/returned
333 // (This must be done immediately after the query because
334 // mysql_affected_rows() reports about the last query done)
336 if (!$is_affected) {
337 $num_rows = ($result) ? @PMA_DBI_num_rows($result) : 0;
338 } elseif (!isset($num_rows)) {
339 $num_rows = @PMA_DBI_affected_rows();
342 // Grabs the profiling results
343 if (isset($_SESSION['profiling']) && PMA_profilingSupported()) {
344 $profiling_results = PMA_DBI_fetch_result('SHOW PROFILE;');
347 // Checks if the current database has changed
348 // This could happen if the user sends a query like "USE `database`;"
350 * commented out auto-switching to active database - really required?
351 * bug #1814718 win: table list disappears (mixed case db names)
352 * https://sourceforge.net/support/tracker.php?aid=1814718
353 * @todo RELEASE test and comit or rollback before release
354 $current_db = PMA_DBI_fetch_value('SELECT DATABASE()');
355 if ($db !== $current_db) {
356 $db = $current_db;
357 $reload = 1;
359 unset($current_db);
362 // tmpfile remove after convert encoding appended by Y.Kawada
363 if (function_exists('PMA_kanji_file_conv')
364 && (isset($textfile) && file_exists($textfile))) {
365 unlink($textfile);
368 // Counts the total number of rows for the same 'SELECT' query without the
369 // 'LIMIT' clause that may have been programatically added
371 if (empty($sql_limit_to_append)) {
372 $unlim_num_rows = $num_rows;
373 // if we did not append a limit, set this to get a correct
374 // "Showing rows..." message
375 //$_SESSION['tmp_user_values']['max_rows'] = 'all';
376 } elseif ($is_select) {
378 // c o u n t q u e r y
380 // If we are "just browsing", there is only one table,
381 // and no WHERE clause (or just 'WHERE 1 '),
382 // we do a quick count (which uses MaxExactCount) because
383 // SQL_CALC_FOUND_ROWS is not quick on large InnoDB tables
385 // However, do not count again if we did it previously
386 // due to $find_real_end == true
388 if (!$is_group
389 && !isset($analyzed_sql[0]['queryflags']['union'])
390 && !isset($analyzed_sql[0]['table_ref'][1]['table_name'])
391 && (empty($analyzed_sql[0]['where_clause'])
392 || $analyzed_sql[0]['where_clause'] == '1 ')
393 && !isset($find_real_end)
396 // "j u s t b r o w s i n g"
397 $unlim_num_rows = PMA_Table::countRecords($db, $table);
399 } else { // n o t " j u s t b r o w s i n g "
401 // add select expression after the SQL_CALC_FOUND_ROWS
403 // for UNION, just adding SQL_CALC_FOUND_ROWS
404 // after the first SELECT works.
406 // take the left part, could be:
407 // SELECT
408 // (SELECT
409 $count_query = PMA_SQP_formatHtml($parsed_sql, 'query_only', 0, $analyzed_sql[0]['position_of_first_select'] + 1);
410 $count_query .= ' SQL_CALC_FOUND_ROWS ';
411 // add everything that was after the first SELECT
412 $count_query .= PMA_SQP_formatHtml($parsed_sql, 'query_only', $analyzed_sql[0]['position_of_first_select']+1);
413 // ensure there is no semicolon at the end of the
414 // count query because we'll probably add
415 // a LIMIT 1 clause after it
416 $count_query = rtrim($count_query);
417 $count_query = rtrim($count_query, ';');
419 // if using SQL_CALC_FOUND_ROWS, add a LIMIT to avoid
420 // long delays. Returned count will be complete anyway.
421 // (but a LIMIT would disrupt results in an UNION)
423 if (!isset($analyzed_sql[0]['queryflags']['union'])) {
424 $count_query .= ' LIMIT 1';
427 // run the count query
429 PMA_DBI_try_query($count_query);
430 // if (mysql_error()) {
431 // void.
432 // I tried the case
433 // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`)
434 // UNION (SELECT `User`, `Host`, "%" AS "Db",
435 // `Select_priv`
436 // FROM `user`) ORDER BY `User`, `Host`, `Db`;
437 // and although the generated count_query is wrong
438 // the SELECT FOUND_ROWS() work! (maybe it gets the
439 // count from the latest query that worked)
441 // another case where the count_query is wrong:
442 // SELECT COUNT(*), f1 from t1 group by f1
443 // and you click to sort on count(*)
444 // }
445 $unlim_num_rows = PMA_DBI_fetch_value('SELECT FOUND_ROWS()');
446 } // end else "just browsing"
448 } else { // not $is_select
449 $unlim_num_rows = 0;
450 } // end rows total count
452 // if a table or database gets dropped, check column comments.
453 if (isset($purge) && $purge == '1') {
455 * Cleanup relations.
457 require_once './libraries/relation_cleanup.lib.php';
459 if (strlen($table) && strlen($db)) {
460 PMA_relationsCleanupTable($db, $table);
461 } elseif (strlen($db)) {
462 PMA_relationsCleanupDatabase($db);
463 } else {
464 // VOID. No DB/Table gets deleted.
465 } // end if relation-stuff
466 } // end if ($purge)
468 // If a column gets dropped, do relation magic.
469 if (isset($cpurge) && $cpurge == '1' && isset($purgekey)
470 && strlen($db) && strlen($table) && !empty($purgekey)) {
471 require_once './libraries/relation_cleanup.lib.php';
472 PMA_relationsCleanupColumn($db, $table, $purgekey);
474 } // end if column PMA_* purge
475 } // end else "didn't ask to see php code"
477 // No rows returned -> move back to the calling page
478 if (0 == $num_rows || $is_affected) {
479 if ($is_delete) {
480 $message = PMA_Message::deleted_rows($num_rows);
481 } elseif ($is_insert) {
482 if ($is_replace) {
483 /* For replace we get DELETED + INSERTED row count, so we have to call it affected */
484 $message = PMA_Message::affected_rows($num_rows);
485 } else {
486 $message = PMA_Message::inserted_rows($num_rows);
488 $insert_id = PMA_DBI_insert_id();
489 if ($insert_id != 0) {
490 // insert_id is id of FIRST record inserted in one insert, so if we inserted multiple rows, we had to increment this
491 $message->addMessage('[br]');
492 // need to use a temporary because the Message class
493 // currently supports adding parameters only to the first
494 // message
495 $_inserted = PMA_Message::notice(__('Inserted row id: %1$d'));
496 $_inserted->addParam($insert_id + $num_rows - 1);
497 $message->addMessage($_inserted);
499 } elseif ($is_affected) {
500 $message = PMA_Message::affected_rows($num_rows);
502 // Ok, here is an explanation for the !$is_select.
503 // The form generated by sql_query_form.lib.php
504 // and db_sql.php has many submit buttons
505 // on the same form, and some confusion arises from the
506 // fact that $zero_rows is sent for every case.
507 // The $zero_rows containing a success message and sent with
508 // the form should not have priority over errors
509 } elseif (!empty($zero_rows) && !$is_select) {
510 $message = PMA_Message::rawSuccess(htmlspecialchars($zero_rows));
511 } elseif (!empty($GLOBALS['show_as_php'])) {
512 $message = PMA_Message::success(__('Showing as PHP code'));
513 } elseif (isset($GLOBALS['show_as_php'])) {
514 /* User disable showing as PHP, query is only displayed */
515 $message = PMA_Message::notice(__('Showing SQL query'));
516 } elseif (!empty($GLOBALS['validatequery'])) {
517 $message = PMA_Message::notice(__('Validate SQL'));
518 } else {
519 $message = PMA_Message::success(__('MySQL returned an empty result set (i.e. zero rows).'));
522 if (isset($GLOBALS['querytime'])) {
523 $_querytime = PMA_Message::notice(__('Query took %01.4f sec'));
524 $_querytime->addParam($GLOBALS['querytime']);
525 $message->addMessage('(');
526 $message->addMessage($_querytime);
527 $message->addMessage(')');
530 if ($is_gotofile) {
531 $goto = PMA_securePath($goto);
532 // Checks for a valid target script
533 $is_db = $is_table = false;
534 include 'libraries/db_table_exists.lib.php';
535 if (strpos($goto, 'tbl_') === 0 && ! $is_table) {
536 if (strlen($table)) {
537 $table = '';
539 $goto = 'db_sql.php';
541 if (strpos($goto, 'db_') === 0 && ! $is_db) {
542 if (strlen($db)) {
543 $db = '';
545 $goto = 'main.php';
547 // Loads to target script
548 if (strpos($goto, 'db_') === 0
549 || strpos($goto, 'tbl_') === 0) {
550 $GLOBALS['js_include'][] = 'functions.js';
552 if ($goto != 'main.php') {
553 require_once './libraries/header.inc.php';
555 $active_page = $goto;
556 require './' . $goto;
557 } else {
558 // avoid a redirect loop when last record was deleted
559 if (0 == $num_rows && 'sql.php' == $cfg['DefaultTabTable']) {
560 $goto = str_replace('sql.php','tbl_structure.php',$goto);
562 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto) . '&message=' . urlencode($message));
563 } // end else
564 exit();
565 } // end no rows returned
567 // At least one row is returned -> displays a table with results
568 else {
569 // Displays the headers
570 if (isset($show_query)) {
571 unset($show_query);
573 if (isset($printview) && $printview == '1') {
574 require_once './libraries/header_printview.inc.php';
575 } else {
576 $GLOBALS['js_include'][] = 'functions.js';
577 unset($message);
578 if (strlen($table)) {
579 require './libraries/tbl_common.php';
580 $url_query .= '&amp;goto=tbl_sql.php&amp;back=tbl_sql.php';
581 require './libraries/tbl_info.inc.php';
582 require './libraries/tbl_links.inc.php';
583 } elseif (strlen($db)) {
584 require './libraries/db_common.inc.php';
585 require './libraries/db_info.inc.php';
586 } else {
587 require './libraries/server_common.inc.php';
588 require './libraries/server_links.inc.php';
592 if (strlen($db)) {
593 require_once './libraries/relation.lib.php';
594 $cfgRelation = PMA_getRelationsParam();
597 // Gets the list of fields properties
598 if (isset($result) && $result) {
599 $fields_meta = PMA_DBI_get_fields_meta($result);
600 $fields_cnt = count($fields_meta);
603 // Display previous update query (from tbl_replace)
604 if (isset($disp_query) && $cfg['ShowSQL'] == true) {
605 PMA_showMessage($disp_message, $disp_query, 'success');
608 if (isset($profiling_results)) {
609 PMA_profilingResults($profiling_results);
612 // Displays the results in a table
613 if (empty($disp_mode)) {
614 // see the "PMA_setDisplayMode()" function in
615 // libraries/display_tbl.lib.php
616 $disp_mode = 'urdr111101';
619 // hide edit and delete links for information_schema
620 if ($db == 'information_schema') {
621 $disp_mode = 'nnnn110111';
624 if (isset($label)) {
625 $message = PMA_message::success(__('Bookmark %s created'));
626 $message->addParam($label);
627 $message->display();
630 PMA_displayTable($result, $disp_mode, $analyzed_sql);
631 PMA_DBI_free_result($result);
633 // BEGIN INDEX CHECK See if indexes should be checked.
634 if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) {
635 foreach ($selected as $idx => $tbl_name) {
636 $check = PMA_Index::findDuplicates($tbl_name, $db);
637 if (! empty($check)) {
638 printf(__('Problems with indexes of table `%s`'), $tbl_name);
639 echo $check;
642 } // End INDEX CHECK
644 // Bookmark support if required
645 if ($disp_mode[7] == '1'
646 && (! empty($cfg['Bookmark']) && empty($id_bookmark))
647 && !empty($sql_query)) {
648 echo "\n";
650 $goto = 'sql.php?'
651 . PMA_generate_common_url($db, $table)
652 . '&amp;sql_query=' . urlencode($sql_query)
653 . '&amp;id_bookmark=1';
656 <form action="sql.php" method="post" onsubmit="return emptyFormElements(this, 'fields[label]');">
657 <?php echo PMA_generate_common_hidden_inputs(); ?>
658 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
659 <input type="hidden" name="fields[dbase]" value="<?php echo htmlspecialchars($db); ?>" />
660 <input type="hidden" name="fields[user]" value="<?php echo $cfg['Bookmark']['user']; ?>" />
661 <input type="hidden" name="fields[query]" value="<?php echo urlencode(isset($complete_query) ? $complete_query : $sql_query); ?>" />
662 <fieldset>
663 <legend><?php
664 echo ($cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_bookmark.png" width="16" height="16" alt="' . __('Bookmark this SQL query') . '" />' : '')
665 . __('Bookmark this SQL query');
667 </legend>
669 <div class="formelement">
670 <label for="fields_label_"><?php echo __('Label'); ?>:</label>
671 <input type="text" id="fields_label_" name="fields[label]" value="" />
672 </div>
674 <div class="formelement">
675 <input type="checkbox" name="bkm_all_users" id="bkm_all_users" value="true" />
676 <label for="bkm_all_users"><?php echo __('Let every user access this bookmark'); ?></label>
677 </div>
679 <div class="clearfloat"></div>
680 </fieldset>
681 <fieldset class="tblFooters">
682 <input type="submit" name="store_bkm" value="<?php echo __('Bookmark this SQL query'); ?>" />
683 </fieldset>
684 </form>
685 <?php
686 } // end bookmark support
688 // Do print the page if required
689 if (isset($printview) && $printview == '1') {
691 <script type="text/javascript">
692 //<![CDATA[
693 // Do print the page
694 window.onload = function()
696 if (typeof(window.print) != 'undefined') {
697 window.print();
700 //]]>
701 </script>
702 <?php
703 } // end print case
704 } // end rows returned
707 * Displays the footer
709 require_once './libraries/footer.inc.php';