3 // vim: expandtab sw=4 ts=4 sts=4:
6 * Gets some core libraries
8 require('./libraries/grab_globals.lib.php3');
9 require('./libraries/common.lib.php3');
11 PMA_checkParameters(array('sql_query', 'db'));
14 * Defines the url to return to in case of error in a sql statement
18 $is_gotofile = ereg_replace('^([^?]+).*$', '\\1', $goto);
19 if (!@file_exists
('./' . $is_gotofile)) {
22 $is_gotofile = ($is_gotofile == $goto);
24 } // end if (security checkings)
27 $goto = (empty($table)) ?
$cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable'];
30 if (!isset($err_url)) {
31 $err_url = (!empty($back) ?
$back : $goto)
32 . '?' . PMA_generate_common_url(isset($db) ?
$db : '')
33 . ((strpos(' ' . $goto, 'db_details') != 1 && isset($table)) ?
'&table=' . urlencode($table) : '');
36 // Coming from a bookmark dialog
37 if (isset($fields['query'])) {
38 $sql_query = $fields['query'];
42 * Check rights in case of DROP DATABASE
44 * This test may be bypassed if $is_js_confirmed = 1 (already checked with js)
45 * but since a malicious user may pass this variable by url/form, we don't take
46 * into account this case.
48 if (!defined('PMA_CHK_DROP')
49 && !$cfg['AllowUserDropDatabase']
50 && eregi('DROP[[:space:]]+(IF EXISTS[[:space:]]+)?DATABASE[[:space:]]', $sql_query)) {
51 // Checks if the user is a Superuser
52 // TODO: set a global variable with this information
53 // loic1: optimized query
54 $result = @PMA_mysql_query
('USE mysql');
55 if (PMA_mysql_error()) {
56 include('./header.inc.php3');
57 PMA_mysqlDie($strNoDropDatabases, '', '', $err_url);
65 if (isset($store_bkm)) {
66 include('./libraries/bookmark.lib.php3');
67 PMA_addBookmarks($fields, $cfg['Bookmark']);
68 header('Location: ' . $cfg['PmaAbsoluteUri'] . $goto);
73 * Gets the true sql query
75 // $sql_query has been urlencoded in the confirmation form for drop/delete
76 // queries or in the navigation bar for browsing among records
77 if (isset($btnDrop) ||
isset($navig)) {
78 $sql_query = urldecode($sql_query);
85 $parsed_sql = PMA_SQP_parse($sql_query);
86 $analyzed_sql = PMA_SQP_analyze($parsed_sql);
87 // Bug #641765 - Robbat2 - 12 January 2003, 10:49PM
88 // Reverted - Robbat2 - 13 January 2003, 2:40PM
89 $sql_query = PMA_SQP_formatHtml($parsed_sql, 'query_only');
91 // old code did not work, for example, when there is a bracket
93 // so I guess it's ok to check for a real SELECT ... FROM
94 //$is_select = eregi('^SELECT[[:space:]]+', $sql_query);
95 $is_select = isset($analyzed_sql[0]['queryflags']['select_from']);
97 // If the query is a Select, extract the db and table names and modify
98 // $db and $table, to have correct page headers, links and left frame.
99 // db and table name may be enclosed with backquotes, db is optionnal,
100 // query may contain aliases.
102 // (TODO: if there are more than one table name in the Select:
103 // - do not extract the first table name
104 // - do not show a table name in the page header
105 // - do not display the sub-pages links)
109 if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])) {
110 $table = $analyzed_sql[0]['table_ref'][0]['table_true_name'];
112 if (isset($analyzed_sql[0]['table_ref'][0]['db'])
113 && !empty($analyzed_sql[0]['table_ref'][0]['db'])) {
114 $db = $analyzed_sql[0]['table_ref'][0]['db'];
119 $reload = ($db == $prev_db) ?
0 : 1;
123 * Sets or modifies the $goto variable if required
125 if ($goto == 'sql.php3') {
127 . PMA_generate_common_url($db, $table)
129 . '&sql_query=' . urlencode($sql_query);
134 * Go back to further page if table should not be dropped
136 if (isset($btnDrop) && $btnDrop == $strNo) {
141 if (strpos(' ' . $goto, 'db_details') == 1 && !empty($table)) {
144 $active_page = $goto;
145 include('./' . ereg_replace('\.\.*', '.', $goto));
147 header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&', '&', $goto));
154 * Displays the confirm page if required
156 * This part of the script is bypassed if $is_js_confirmed = 1 (already checked
157 * with js) because possible security issue is not so important here: at most,
158 * the confirm message isn't displayed.
160 * Also bypassed if only showing php code.or validating a SQL query
163 ||
(isset($is_js_confirmed) && $is_js_confirmed)
165 ||
!empty($GLOBALS['show_as_php'])
166 ||
!empty($GLOBALS['validatequery'])) {
169 //$do_confirm = (eregi('DROP[[:space:]]+(IF[[:space:]]+EXISTS[[:space:]]+)?(TABLE|DATABASE[[:space:]])|ALTER[[:space:]]+TABLE[[:space:]]+((`[^`]+`)|([A-Za-z0-9_$]+))[[:space:]]+DROP[[:space:]]|DELETE[[:space:]]+FROM[[:space:]]', $sql_query));
171 $do_confirm = isset($analyzed_sql[0]['queryflags']['need_confirm']);
175 $stripped_sql_query = $sql_query;
176 include('./header.inc.php3');
177 echo $strDoYouReally . ' :<br />' . "\n";
178 echo '<tt>' . htmlspecialchars($stripped_sql_query) . '</tt> ?<br/>' . "\n";
180 <form action
="sql.php3" method
="post">
181 <?php
echo PMA_generate_common_hidden_inputs($db, (isset($table)?
$table:'')); ?
>
182 <input type
="hidden" name
="sql_query" value
="<?php echo urlencode($sql_query); ?>" />
183 <input type
="hidden" name
="zero_rows" value
="<?php echo isset($zero_rows) ? $zero_rows : ''; ?>" />
184 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
185 <input type
="hidden" name
="back" value
="<?php echo isset($back) ? $back : ''; ?>" />
186 <input type
="hidden" name
="reload" value
="<?php echo isset($reload) ? $reload : 0; ?>" />
187 <input type
="hidden" name
="purge" value
="<?php echo isset($purge) ? $purge : ''; ?>" />
188 <input type
="hidden" name
="cpurge" value
="<?php echo isset($cpurge) ? $cpurge : ''; ?>" />
189 <input type
="hidden" name
="purgekey" value
="<?php echo isset($purgekey) ? $purgekey : ''; ?>" />
190 <input type
="hidden" name
="show_query" value
="<?php echo isset($show_query) ? $show_query : ''; ?>" />
191 <input type
="submit" name
="btnDrop" value
="<?php echo $strYes; ?>" />
192 <input type
="submit" name
="btnDrop" value
="<?php echo $strNo; ?>" />
200 * Executes the query and displays results
203 if (!isset($sql_query)) {
206 // Defines some variables
207 // loic1: A table has to be created -> left frame should be reloaded
208 if ((!isset($reload) ||
$reload == 0)
209 && eregi('^CREATE TABLE[[:space:]]+(.*)', $sql_query)) {
212 // Gets the number of rows per page
213 if (!isset($session_max_rows)) {
214 $session_max_rows = $cfg['MaxRows'];
215 } else if ($session_max_rows != 'all') {
216 $cfg['MaxRows'] = $session_max_rows;
218 // Defines the display mode (horizontal/vertical) and header "frequency"
219 if (empty($disp_direction)) {
220 $disp_direction = $cfg['DefaultDisplay'];
222 if (empty($repeat_cells)) {
223 $repeat_cells = $cfg['RepeatCells'];
226 // SK -- Patch: $is_group added for use in calculation of total number of
228 // $is_count is changed for more correct "LIMIT" clause
229 // appending in queries like
230 // "SELECT COUNT(...) FROM ... GROUP BY ..."
231 $is_explain = $is_count = $is_export = $is_delete = $is_insert = $is_affected = $is_show = $is_maint = $is_analyse = $is_group = $is_func = FALSE;
232 if ($is_select) { // see line 141
233 $is_group = eregi('(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+', $sql_query);
234 $is_func = !$is_group && (eregi('[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(', $sql_query));
235 $is_count = !$is_group && (eregi('^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)', $sql_query));
236 $is_export = (eregi('[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+', $sql_query));
237 $is_analyse = (eregi('[[:space:]]+PROCEDURE[[:space:]]+ANALYSE', $sql_query));
238 } else if (eregi('^EXPLAIN[[:space:]]+', $sql_query)) {
240 } else if (eregi('^DELETE[[:space:]]+', $sql_query)) {
243 } else if (eregi('^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+', $sql_query)) {
246 } else if (eregi('^UPDATE[[:space:]]+', $sql_query)) {
248 } else if (eregi('^SHOW[[:space:]]+', $sql_query)) {
250 } else if (eregi('^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+', $sql_query)) {
254 // Do append a "LIMIT" clause?
256 && (!$cfg['ShowAll'] ||
$session_max_rows != 'all')
257 && !($is_count ||
$is_export ||
$is_func ||
$is_analyse)
258 && isset($analyzed_sql[0]['queryflags']['select_from'])
259 && !eregi('[[:space:]]LIMIT[[:space:]0-9,-]+$', $sql_query)) {
260 $sql_limit_to_append = " LIMIT $pos, ".$cfg['MaxRows'];
261 if (eregi('(.*)([[:space:]](PROCEDURE[[:space:]](.*)|FOR[[:space:]]+UPDATE|LOCK[[:space:]]+IN[[:space:]]+SHARE[[:space:]]+MODE))$', $sql_query, $regs)) {
262 $full_sql_query = $regs[1] . $sql_limit_to_append . $regs[2];
264 $full_sql_query = $sql_query . $sql_limit_to_append;
267 $full_sql_query = $sql_query;
270 PMA_mysql_select_db($db);
272 // If the query is a DELETE query with no WHERE clause, get the number of
273 // rows that will be deleted (mysql_affected_rows will always return 0 in
276 && eregi('^DELETE([[:space:]].+)?([[:space:]]FROM[[:space:]](.+))$', $sql_query, $parts)
277 && !eregi('[[:space:]]WHERE[[:space:]]', $parts[3])) {
278 $cnt_all_result = @PMA_mysql_query
('SELECT COUNT(*) as count' . $parts[2]);
279 if ($cnt_all_result) {
280 $num_rows = PMA_mysql_result($cnt_all_result, 0, 'count');
281 mysql_free_result($cnt_all_result);
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'])) {
295 // garvin: Measure query time. TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411
296 list($usec, $sec) = explode(' ',microtime());
297 $querytime_before = ((float)$usec +
(float)$sec);
299 $result = @PMA_mysql_query
($full_sql_query);
301 list($usec, $sec) = explode(' ',microtime());
302 $querytime_after = ((float)$usec +
(float)$sec);
304 $GLOBALS['querytime'] = $querytime_after - $querytime_before;
306 // Displays an error message if required and stop parsing the script
307 if (PMA_mysql_error()) {
308 $error = PMA_mysql_error();
309 include('./header.inc.php3');
310 $full_err_url = (ereg('^(db_details|tbl_properties)', $err_url))
311 ?
$err_url . '&show_query=1&sql_query=' . urlencode($sql_query)
313 PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
316 // Gets the number of rows affected/returned
317 // (This must be done immediately after the query because
318 // mysql_affected_rows() reports about the last query done)
321 $num_rows = ($result) ? @mysql_num_rows
($result) : 0;
322 } else if (!isset($num_rows)) {
323 $num_rows = @mysql_affected_rows
();
326 // Checks if the current database has changed
327 // This could happen if the user sends a query like "USE `database`;"
328 $res = PMA_mysql_query('SELECT DATABASE() AS "db";');
329 $row = PMA_mysql_fetch_array($res);
330 if ($db != $row['db']) {
334 @mysql_free_result
($res);
338 // tmpfile remove after convert encoding appended by Y.Kawada
339 if (function_exists('PMA_kanji_file_conv')
340 && (isset($textfile) && file_exists($textfile))) {
344 // Counts the total number of rows for the same 'SELECT' query without the
345 // 'LIMIT' clause that may have been programatically added
347 if (empty($sql_limit_to_append)) {
348 $unlim_num_rows = $num_rows;
350 else if ($is_select) {
352 // c o u n t q u e r y
354 // If we are "just browsing", there is only one table,
355 // and no where clause (or just 'WHERE 1 '),
356 // so we do a quick count (which uses MaxExactCount)
357 // because SQL_CALC_FOUND_ROWS
358 // is not quick on large InnoDB tables
361 && !isset($analyzed_sql[0]['queryflags']['union'])
362 && !isset($analyzed_sql[0]['table_ref'][1]['table_name'])
363 && (empty($analyzed_sql[0]['where_clause'])
364 ||
$analyzed_sql[0]['where_clause'] == '1 ')) {
366 // "j u s t b r o w s i n g"
367 $unlim_num_rows = PMA_countRecords($db, $table, TRUE);
369 } else { // n o t " j u s t b r o w s i n g "
371 if (PMA_MYSQL_INT_VERSION
< 40000) {
372 if (eregi('DISTINCT(.*)', $sql_query)) {
373 $count_what = 'DISTINCT ' . $analyzed_sql[0]['select_expr_clause'];
378 $count_query = 'SELECT COUNT(' . $count_what . ') AS count';
381 // add the remaining of select expression if there is
382 // a GROUP BY or HAVING clause
383 if (PMA_MYSQL_INT_VERSION
< 40000
385 && (!empty($analyzed_sql[0]['group_by_clause'])
386 ||
!empty($analyzed_sql[0]['having_clause']))) {
387 $count_query .= ' ,' . $analyzed_sql[0]['select_expr_clause'];
390 if (PMA_MYSQL_INT_VERSION
>= 40000) {
391 // add select expression after the SQL_CALC_FOUND_ROWS
392 // if (eregi('DISTINCT(.*)', $sql_query)) {
393 // $count_query .= 'DISTINCT ' . $analyzed_sql[0]['select_expr_clause'];
395 //$count_query .= $analyzed_sql[0]['select_expr_clause'];
397 // for UNION, just adding SQL_CALC_FOUND_ROWS
398 // after the first SELECT works.
400 // take the left part, could be:
403 $count_query = PMA_SQP_formatHtml($parsed_sql, 'query_only', 0, $analyzed_sql[0]['position_of_first_select'] +
1);
404 $count_query .= ' SQL_CALC_FOUND_ROWS ';
406 // add everything that was after the first SELECT
407 $count_query .= PMA_SQP_formatHtml($parsed_sql, 'query_only', $analyzed_sql[0]['position_of_first_select']+
1);
409 } else { // PMA_MYSQL_INT_VERSION < 40000
411 if (!empty($analyzed_sql[0]['from_clause'])) {
412 $count_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
414 if (!empty($analyzed_sql[0]['where_clause'])) {
415 $count_query .= ' WHERE ' . $analyzed_sql[0]['where_clause'];
417 if (!empty($analyzed_sql[0]['group_by_clause'])) {
418 $count_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause'];
420 if (!empty($analyzed_sql[0]['having_clause'])) {
421 $count_query .= ' HAVING ' . $analyzed_sql[0]['having_clause'];
425 // if using SQL_CALC_FOUND_ROWS, add a LIMIT to avoid
426 // long delays. Returned count will be complete anyway.
427 // (but a LIMIT would disrupt results in an UNION)
429 if (PMA_MYSQL_INT_VERSION
>= 40000
430 && !isset($analyzed_sql[0]['queryflags']['union'])) {
431 $count_query .= ' LIMIT 1';
434 // run the count query
435 //DEBUG echo "trace cq=" . $count_query . "<br/>";
437 if (PMA_MYSQL_INT_VERSION
< 40000) {
438 if ($cnt_all_result = PMA_mysql_query($count_query)) {
440 // if ($count_what == '*') {
441 $unlim_num_rows = @mysql_num_rows
($cnt_all_result);
443 $unlim_num_rows = PMA_mysql_result($cnt_all_result, 0, 'count');
445 mysql_free_result($cnt_all_result);
449 // there are some cases where the generated
450 // count_query (for MySQL 3) is wrong,
452 //TODO: use a big unlimited query to get
453 // the correct number of rows (depending
454 // on a config variable?)
459 PMA_mysql_query($count_query);
461 // void. I tried the case
462 // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`)
463 // UNION (SELECT `User`, `Host`, "%" AS "Db",
465 // FROM `user`) ORDER BY `User`, `Host`, `Db`;
466 // and although the generated count_query is wrong
467 // the SELECT FOUND_ROWS() work!
469 $cnt_all_result = PMA_mysql_query('SELECT FOUND_ROWS() as count');
470 $unlim_num_rows = PMA_mysql_result($cnt_all_result,0,'count');
472 } // end else "just browsing"
474 } else { // not $is_select
476 } // end rows total count
478 // garvin: if a table or database gets dropped, check column comments.
479 if (isset($purge) && $purge == '1') {
480 include('./libraries/relation_cleanup.lib.php3');
482 if (isset($table) && isset($db) && !empty($table) && !empty($db)) {
483 PMA_relationsCleanupTable($db, $table);
484 } elseif (isset($db) && !empty($db)) {
485 PMA_relationsCleanupDatabase($db);
487 // garvin: VOID. No DB/Table gets deleted.
488 } // end if relation-stuff
491 // garvin: If a column gets dropped, do relation magic.
492 if (isset($cpurge) && $cpurge == '1' && isset($purgekey)
493 && isset($db) && isset($table)
494 && !empty($db) && !empty($table) && !empty($purgekey)) {
495 include('./libraries/relation_cleanup.lib.php3');
496 PMA_relationsCleanupColumn($db, $table, $purgekey);
498 } // end if column PMA_* purge
499 } // end else "didn't ask to see php code"
502 // No rows returned -> move back to the calling page
503 if ($num_rows < 1 ||
$is_affected) {
505 $message = $strDeletedRows . ' ' . $num_rows;
506 } else if ($is_insert) {
507 $message = $strInsertedRows . ' ' . $num_rows;
508 $insert_id = mysql_insert_id();
509 if ($insert_id != 0) {
510 $message .= '<br />'.$strInsertedRowId . ' ' . $insert_id;
512 } else if ($is_affected) {
513 $message = $strAffectedRows . ' ' . $num_rows;
514 } else if (!empty($zero_rows)) {
515 $message = $zero_rows;
516 } else if (!empty($GLOBALS['show_as_php'])) {
518 } else if (!empty($GLOBALS['validatequery'])) {
519 $message = $strValidateSQL;
521 $message = $strEmptyResultSet;
524 $message .= ' ' . (isset($GLOBALS['querytime']) ?
'(' . sprintf($strQueryTime, $GLOBALS['querytime']) . ')' : '');
527 $goto = ereg_replace('\.\.*', '.', $goto);
528 // Checks for a valid target script
529 if (isset($table) && $table == '') {
532 if (isset($db) && $db == '') {
535 $is_db = $is_table = FALSE;
536 if (strpos(' ' . $goto, 'tbl_properties') == 1) {
537 if (!isset($table)) {
538 $goto = 'db_details.php3';
540 $is_table = @PMA_mysql_query
('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'');
541 if (!($is_table && @mysql_numrows
($is_table))) {
542 $goto = 'db_details.php3';
545 } // end if... else...
547 if (strpos(' ' . $goto, 'db_details') == 1) {
554 $is_db = @PMA_mysql_select_db
($db);
559 } // end if... else...
561 // Loads to target script
562 if (strpos(' ' . $goto, 'db_details') == 1
563 ||
strpos(' ' . $goto, 'tbl_properties') == 1) {
564 $js_to_run = 'functions.js';
566 if ($goto != 'main.php3') {
567 include('./header.inc.php3');
569 $active_page = $goto;
570 include('./' . $goto);
571 } // end if file_exist
573 header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&', '&', $goto) . '&message=' . urlencode($message));
576 } // end no rows returned
578 // At least one row is returned -> displays a table with results
580 // Displays the headers
581 if (isset($show_query)) {
584 if (isset($printview) && $printview == '1') {
585 include('./header_printview.inc.php3');
587 $js_to_run = 'functions.js';
589 if (!empty($table)) {
590 include('./tbl_properties_common.php3');
591 $url_query .= '&goto=tbl_properties.php3&back=tbl_properties.php3';
592 include('./tbl_properties_table_info.php3');
595 include('./db_details_common.php3');
596 include('./db_details_db_info.php3');
598 include('./libraries/relation.lib.php3');
599 $cfgRelation = PMA_getRelationsParam();
602 // Gets the list of fields properties
603 if (isset($result) && $result) {
604 while ($field = PMA_mysql_fetch_field($result)) {
605 $fields_meta[] = $field;
607 $fields_cnt = count($fields_meta);
610 // Display previous update query (from tbl_replace)
611 if (isset($disp_query) && $cfg['ShowSQL'] == TRUE) {
612 $tmp_sql_query = $GLOBALS['sql_query'];
613 $tmp_sql_limit_to_append = (isset($GLOBALS['sql_limit_to_append'])?
$GLOBALS['sql_limit_to_append']:'');
614 $GLOBALS['sql_query'] = $disp_query;
615 $GLOBALS['sql_limit_to_append'] = '';
616 PMA_showMessage($disp_message);
617 $GLOBALS['sql_query'] = $tmp_sql_query;
618 $GLOBALS['sql_limit_to_append'] = $tmp_sql_limit_to_append;
621 // Displays the results in a table
622 include('./libraries/display_tbl.lib.php3');
623 if (empty($disp_mode)) {
624 // see the "PMA_setDisplayMode()" function in
625 // libraries/display_tbl.lib.php3
626 $disp_mode = 'urdr111101';
628 if (!isset($dontlimitchars)) {
632 PMA_displayTable($result, $disp_mode, $analyzed_sql);
633 mysql_free_result($result);
635 if ($disp_mode[6] == '1' ||
$disp_mode[9] == '1') {
639 // Displays "Insert a new row" link if required
640 if ($disp_mode[6] == '1') {
641 $lnk_goto = 'sql.php3?'
642 . PMA_generate_common_url($db, $table)
644 . '&session_max_rows=' . $session_max_rows
645 . '&disp_direction=' . $disp_direction
646 . '&repeat_cells=' . $repeat_cells
647 . '&dontlimitchars=' . $dontlimitchars
648 . '&sql_query=' . urlencode($sql_query);
650 . PMA_generate_common_url($db, $table)
652 . '&session_max_rows=' . $session_max_rows
653 . '&disp_direction=' . $disp_direction
654 . '&repeat_cells=' . $repeat_cells
655 . '&dontlimitchars=' . $dontlimitchars
656 . '&sql_query=' . urlencode($sql_query)
657 . '&goto=' . urlencode($lnk_goto);
659 echo ' <!-- Insert a new row -->' . "\n"
660 . ' <a href="tbl_change.php3' . $url_query . '">' . $strInsertNewRow . '</a>';
661 if ($disp_mode[9] == '1') {
665 } // end insert new row
667 // Displays "printable view" link if required
668 if ($disp_mode[9] == '1') {
670 . PMA_generate_common_url($db, $table)
672 . '&session_max_rows=' . $session_max_rows
673 . '&disp_direction=' . $disp_direction
674 . '&repeat_cells=' . $repeat_cells
676 . ((isset($dontlimitchars) && $dontlimitchars == '1') ?
'&dontlimitchars=1' : '')
677 . '&sql_query=' . urlencode($sql_query);
678 echo ' <!-- Print view -->' . "\n"
679 . ' <a href="sql.php3' . $url_query . '" target="print_view">' . $strPrintView . '</a>' . "\n";
680 } // end displays "printable view"
685 // Export link, if only one table
686 // (the url_query has extra parameters that won't be used to export)
687 if (!isset($printview)) {
688 if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name']) && !isset($analyzed_sql[0]['table_ref'][1]['table_true_name'])) {
689 $single_table = '&single_table=true';
693 echo ' <!-- Export -->' . "\n"
694 . ' <a href="tbl_properties_export.php3' . $url_query
695 . '&unlim_num_rows=' . $unlim_num_rows
697 . '">' . $strExport . '</a>' . "\n";
700 // Bookmark Support if required
701 if ($disp_mode[7] == '1'
702 && ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table'] && empty($id_bookmark))
703 && !empty($sql_query)) {
707 . PMA_generate_common_url($db, $table)
709 . '&session_max_rows=' . $session_max_rows
710 . '&disp_direction=' . $disp_direction
711 . '&repeat_cells=' . $repeat_cells
712 . '&dontlimitchars=' . $dontlimitchars
713 . '&sql_query=' . urlencode($sql_query)
714 . '&id_bookmark=1';
716 <!-- Bookmark the query
-->
717 <form action
="sql.php3" method
="post" onsubmit
="return emptyFormElements(this, 'fields[label]');">
720 if ($disp_mode[3] == '1') {
721 echo ' <i>' . $strOr . '</i>' . "\n";
725 <?php
echo $strBookmarkLabel; ?
> 
;:
726 <?php
echo PMA_generate_common_hidden_inputs(); ?
>
727 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
728 <input type
="hidden" name
="fields[dbase]" value
="<?php echo htmlspecialchars($db); ?>" />
729 <input type
="hidden" name
="fields[user]" value
="<?php echo $cfg['Bookmark']['user']; ?>" />
730 <input type
="hidden" name
="fields[query]" value
="<?php echo urlencode($sql_query); ?>" />
731 <input type
="text" name
="fields[label]" value
="" />
732 <input type
="submit" name
="store_bkm" value
="<?php echo $strBookmarkThis; ?>" />
735 } // end bookmark support
737 // Do print the page if required
738 if (isset($printview) && $printview == '1') {
741 <script type
="text/javascript" language
="javascript1.2">
744 if (typeof(window
.print) != 'undefined') {
751 } // end rows returned
753 } // end executes the query
758 * Displays the footer
760 require('./footer.inc.php3');