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');
13 * Defines the url to return to in case of error in a sql statement
17 $is_gotofile = ereg_replace('^([^?]+).*$', '\\1', $goto);
18 if (!@file_exists
('./' . $is_gotofile)) {
21 $is_gotofile = ($is_gotofile == $goto);
23 } // end if (security checkings)
26 $goto = (empty($table)) ?
$cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable'];
29 if (!isset($err_url)) {
30 $err_url = (!empty($back) ?
$back : $goto)
31 . '?' . PMA_generate_common_url(isset($db) ?
$db : '')
32 . ((strpos(' ' . $goto, 'db_details') != 1 && isset($table)) ?
'&table=' . urlencode($table) : '');
35 // Coming from a bookmark dialog
36 if (isset($fields['query'])) {
37 $sql_query = $fields['query'];
40 // This one is just to fill $db
41 if (isset($fields['dbase'])) {
42 $db = $fields['dbase'];
45 // Now we can check the parameters
46 PMA_checkParameters(array('sql_query', 'db'));
50 * Check rights in case of DROP DATABASE
52 * This test may be bypassed if $is_js_confirmed = 1 (already checked with js)
53 * but since a malicious user may pass this variable by url/form, we don't take
54 * into account this case.
56 if (!defined('PMA_CHK_DROP')
57 && !$cfg['AllowUserDropDatabase']
58 && eregi('DROP[[:space:]]+DATABASE[[:space:]]+', $sql_query)) {
59 // Checks if the user is a Superuser
60 // TODO: set a global variable with this information
61 // loic1: optimized query
62 $result = @PMA_mysql_query
('USE mysql');
63 if (PMA_mysql_error()) {
64 include('./header.inc.php3');
65 PMA_mysqlDie($strNoDropDatabases, '', '', $err_url);
73 if (isset($store_bkm)) {
74 include('./libraries/bookmark.lib.php3');
75 PMA_addBookmarks($fields, $cfg['Bookmark'], (isset($bkm_all_users) && $bkm_all_users == 'true' ?
true : false));
76 header('Location: ' . $cfg['PmaAbsoluteUri'] . $goto);
81 * Gets the true sql query
83 // $sql_query has been urlencoded in the confirmation form for drop/delete
84 // queries or in the navigation bar for browsing among records
85 if (isset($btnDrop) ||
isset($navig)) {
86 $sql_query = urldecode($sql_query);
93 $GLOBALS['unparsed_sql'] = $sql_query;
94 $parsed_sql = PMA_SQP_parse($sql_query);
95 $analyzed_sql = PMA_SQP_analyze($parsed_sql);
96 // Bug #641765 - Robbat2 - 12 January 2003, 10:49PM
97 // Reverted - Robbat2 - 13 January 2003, 2:40PM
98 $sql_query = PMA_SQP_formatHtml($parsed_sql, 'query_only');
100 // old code did not work, for example, when there is a bracket
102 // so I guess it's ok to check for a real SELECT ... FROM
103 //$is_select = eregi('^SELECT[[:space:]]+', $sql_query);
104 $is_select = isset($analyzed_sql[0]['queryflags']['select_from']);
106 // If the query is a Select, extract the db and table names and modify
107 // $db and $table, to have correct page headers, links and left frame.
108 // db and table name may be enclosed with backquotes, db is optionnal,
109 // query may contain aliases.
111 // (TODO: if there are more than one table name in the Select:
112 // - do not extract the first table name
113 // - do not show a table name in the page header
114 // - do not display the sub-pages links)
118 if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])) {
119 $table = $analyzed_sql[0]['table_ref'][0]['table_true_name'];
121 if (isset($analyzed_sql[0]['table_ref'][0]['db'])
122 && !empty($analyzed_sql[0]['table_ref'][0]['db'])) {
123 $db = $analyzed_sql[0]['table_ref'][0]['db'];
128 $reload = ($db == $prev_db) ?
0 : 1;
132 * Sets or modifies the $goto variable if required
134 if ($goto == 'sql.php3') {
136 . PMA_generate_common_url($db, $table)
138 . '&sql_query=' . urlencode($sql_query);
143 * Go back to further page if table should not be dropped
145 if (isset($btnDrop) && $btnDrop == $strNo) {
150 if (strpos(' ' . $goto, 'db_details') == 1 && !empty($table)) {
153 $active_page = $goto;
154 include('./' . ereg_replace('\.\.*', '.', $goto));
156 header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&', '&', $goto));
163 * Displays the confirm page if required
165 * This part of the script is bypassed if $is_js_confirmed = 1 (already checked
166 * with js) because possible security issue is not so important here: at most,
167 * the confirm message isn't displayed.
169 * Also bypassed if only showing php code.or validating a SQL query
172 ||
(isset($is_js_confirmed) && $is_js_confirmed)
175 // if we are coming from a "Create PHP code" or a "Without PHP Code"
176 // dialog, we won't execute the query anyway, so don't confirm
177 //|| !empty($GLOBALS['show_as_php'])
178 ||
isset($GLOBALS['show_as_php'])
180 ||
!empty($GLOBALS['validatequery'])) {
183 //$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));
185 $do_confirm = isset($analyzed_sql[0]['queryflags']['need_confirm']);
189 $stripped_sql_query = $sql_query;
190 include('./header.inc.php3');
191 echo $strDoYouReally . ' :<br />' . "\n";
192 echo '<tt>' . htmlspecialchars($stripped_sql_query) . '</tt> ?<br/>' . "\n";
194 <form action
="sql.php3" method
="post">
195 <?php
echo PMA_generate_common_hidden_inputs($db, (isset($table)?
$table:'')); ?
>
196 <input type
="hidden" name
="sql_query" value
="<?php echo urlencode($sql_query); ?>" />
197 <input type
="hidden" name
="zero_rows" value
="<?php echo isset($zero_rows) ? $zero_rows : ''; ?>" />
198 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
199 <input type
="hidden" name
="back" value
="<?php echo isset($back) ? $back : ''; ?>" />
200 <input type
="hidden" name
="reload" value
="<?php echo isset($reload) ? $reload : 0; ?>" />
201 <input type
="hidden" name
="purge" value
="<?php echo isset($purge) ? $purge : ''; ?>" />
202 <input type
="hidden" name
="cpurge" value
="<?php echo isset($cpurge) ? $cpurge : ''; ?>" />
203 <input type
="hidden" name
="purgekey" value
="<?php echo isset($purgekey) ? $purgekey : ''; ?>" />
204 <input type
="hidden" name
="show_query" value
="<?php echo isset($show_query) ? $show_query : ''; ?>" />
205 <input type
="submit" name
="btnDrop" value
="<?php echo $strYes; ?>" />
206 <input type
="submit" name
="btnDrop" value
="<?php echo $strNo; ?>" />
214 * Executes the query and displays results
217 if (!isset($sql_query)) {
220 // Defines some variables
221 // loic1: A table has to be created -> left frame should be reloaded
222 if ((!isset($reload) ||
$reload == 0)
223 && eregi('^CREATE TABLE[[:space:]]+(.*)', $sql_query)) {
226 // Gets the number of rows per page
227 if (empty($session_max_rows)) {
228 $session_max_rows = $cfg['MaxRows'];
229 } else if ($session_max_rows != 'all') {
230 $cfg['MaxRows'] = $session_max_rows;
232 // Defines the display mode (horizontal/vertical) and header "frequency"
233 if (empty($disp_direction)) {
234 $disp_direction = $cfg['DefaultDisplay'];
236 if (empty($repeat_cells)) {
237 $repeat_cells = $cfg['RepeatCells'];
240 // SK -- Patch: $is_group added for use in calculation of total number of
242 // $is_count is changed for more correct "LIMIT" clause
243 // appending in queries like
244 // "SELECT COUNT(...) FROM ... GROUP BY ..."
246 // TODO: detect all this with the parser, to avoid problems finding
247 // those strings in comments or backquoted identifiers
249 $is_explain = $is_count = $is_export = $is_delete = $is_insert = $is_affected = $is_show = $is_maint = $is_analyse = $is_group = $is_func = FALSE;
250 if ($is_select) { // see line 141
251 $is_group = eregi('(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+', $sql_query);
252 $is_func = !$is_group && (eregi('[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(', $sql_query));
253 $is_count = !$is_group && (eregi('^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)', $sql_query));
254 $is_export = (eregi('[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+', $sql_query));
255 $is_analyse = (eregi('[[:space:]]+PROCEDURE[[:space:]]+ANALYSE', $sql_query));
256 } else if (eregi('^EXPLAIN[[:space:]]+', $sql_query)) {
258 } else if (eregi('^DELETE[[:space:]]+', $sql_query)) {
261 } else if (eregi('^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+', $sql_query)) {
264 } else if (eregi('^UPDATE[[:space:]]+', $sql_query)) {
266 } else if (eregi('^SHOW[[:space:]]+', $sql_query)) {
268 } else if (eregi('^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+', $sql_query)) {
272 // Do append a "LIMIT" clause?
274 && (!$cfg['ShowAll'] ||
$session_max_rows != 'all')
275 && !($is_count ||
$is_export ||
$is_func ||
$is_analyse)
276 && isset($analyzed_sql[0]['queryflags']['select_from'])
277 && !eregi('[[:space:]]LIMIT[[:space:]0-9,-]+$', $sql_query)) {
278 $sql_limit_to_append = " LIMIT $pos, ".$cfg['MaxRows'];
279 if (eregi('(.*)([[:space:]](PROCEDURE[[:space:]](.*)|FOR[[:space:]]+UPDATE|LOCK[[:space:]]+IN[[:space:]]+SHARE[[:space:]]+MODE))$', $sql_query, $regs)) {
280 $full_sql_query = $regs[1] . $sql_limit_to_append . $regs[2];
282 $full_sql_query = $sql_query . $sql_limit_to_append;
285 $full_sql_query = $sql_query;
288 PMA_mysql_select_db($db);
290 // If the query is a DELETE query with no WHERE clause, get the number of
291 // rows that will be deleted (mysql_affected_rows will always return 0 in
294 && eregi('^DELETE([[:space:]].+)?([[:space:]]FROM[[:space:]](.+))$', $sql_query, $parts)
295 && !eregi('[[:space:]]WHERE[[:space:]]', $parts[3])) {
296 $cnt_all_result = @PMA_mysql_query
('SELECT COUNT(*) as count' . $parts[2]);
297 if ($cnt_all_result) {
298 $num_rows = PMA_mysql_result($cnt_all_result, 0, 'count');
299 mysql_free_result($cnt_all_result);
305 // E x e c u t e t h e q u e r y
307 // Only if we didn't ask to see the php code (mikebeck)
308 if (isset($GLOBALS['show_as_php']) ||
!empty($GLOBALS['validatequery'])) {
313 // garvin: Measure query time. TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411
314 list($usec, $sec) = explode(' ',microtime());
315 $querytime_before = ((float)$usec +
(float)$sec);
317 $result = @PMA_mysql_query
($full_sql_query);
319 list($usec, $sec) = explode(' ',microtime());
320 $querytime_after = ((float)$usec +
(float)$sec);
322 $GLOBALS['querytime'] = $querytime_after - $querytime_before;
324 // Displays an error message if required and stop parsing the script
325 if (PMA_mysql_error()) {
326 $error = PMA_mysql_error();
327 include('./header.inc.php3');
328 $full_err_url = (ereg('^(db_details|tbl_properties)', $err_url))
329 ?
$err_url . '&show_query=1&sql_query=' . urlencode($sql_query)
331 PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
334 // Gets the number of rows affected/returned
335 // (This must be done immediately after the query because
336 // mysql_affected_rows() reports about the last query done)
339 $num_rows = ($result) ? @mysql_num_rows
($result) : 0;
340 } else if (!isset($num_rows)) {
341 $num_rows = @mysql_affected_rows
();
344 // Checks if the current database has changed
345 // This could happen if the user sends a query like "USE `database`;"
346 $res = PMA_mysql_query('SELECT DATABASE() AS "db";');
347 $row = PMA_mysql_fetch_array($res);
348 if ($db != $row['db']) {
352 @mysql_free_result
($res);
356 // tmpfile remove after convert encoding appended by Y.Kawada
357 if (function_exists('PMA_kanji_file_conv')
358 && (isset($textfile) && file_exists($textfile))) {
362 // Counts the total number of rows for the same 'SELECT' query without the
363 // 'LIMIT' clause that may have been programatically added
365 if (empty($sql_limit_to_append)) {
366 $unlim_num_rows = $num_rows;
367 // if we did not append a limit, set this to get a correct
368 // "Showing rows..." message
369 $GLOBALS['session_max_rows'] = 'all';
371 else if ($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
382 && !isset($analyzed_sql[0]['queryflags']['union'])
383 && !isset($analyzed_sql[0]['table_ref'][1]['table_name'])
384 && (empty($analyzed_sql[0]['where_clause'])
385 ||
$analyzed_sql[0]['where_clause'] == '1 ')) {
387 // "j u s t b r o w s i n g"
388 $unlim_num_rows = PMA_countRecords($db, $table, TRUE);
390 } else { // n o t " j u s t b r o w s i n g "
392 if (PMA_MYSQL_INT_VERSION
< 40000) {
393 // TODO: detect DISTINCT in the parser
394 if (eregi('DISTINCT(.*)', $sql_query)) {
395 $count_what = 'DISTINCT ' . $analyzed_sql[0]['select_expr_clause'];
400 $count_query = 'SELECT COUNT(' . $count_what . ') AS count';
403 // add the remaining of select expression if there is
404 // a GROUP BY or HAVING clause
405 if (PMA_MYSQL_INT_VERSION
< 40000
407 && (!empty($analyzed_sql[0]['group_by_clause'])
408 ||
!empty($analyzed_sql[0]['having_clause']))) {
409 $count_query .= ' ,' . $analyzed_sql[0]['select_expr_clause'];
412 if (PMA_MYSQL_INT_VERSION
>= 40000) {
413 // add select expression after the SQL_CALC_FOUND_ROWS
414 // if (eregi('DISTINCT(.*)', $sql_query)) {
415 // $count_query .= 'DISTINCT ' . $analyzed_sql[0]['select_expr_clause'];
417 //$count_query .= $analyzed_sql[0]['select_expr_clause'];
419 // for UNION, just adding SQL_CALC_FOUND_ROWS
420 // after the first SELECT works.
422 // take the left part, could be:
425 $count_query = PMA_SQP_formatHtml($parsed_sql, 'query_only', 0, $analyzed_sql[0]['position_of_first_select'] +
1);
426 $count_query .= ' SQL_CALC_FOUND_ROWS ';
428 // add everything that was after the first SELECT
429 $count_query .= PMA_SQP_formatHtml($parsed_sql, 'query_only', $analyzed_sql[0]['position_of_first_select']+
1);
431 } else { // PMA_MYSQL_INT_VERSION < 40000
433 if (!empty($analyzed_sql[0]['from_clause'])) {
434 $count_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
436 if (!empty($analyzed_sql[0]['where_clause'])) {
437 $count_query .= ' WHERE ' . $analyzed_sql[0]['where_clause'];
439 if (!empty($analyzed_sql[0]['group_by_clause'])) {
440 $count_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause'];
442 if (!empty($analyzed_sql[0]['having_clause'])) {
443 $count_query .= ' HAVING ' . $analyzed_sql[0]['having_clause'];
447 // if using SQL_CALC_FOUND_ROWS, add a LIMIT to avoid
448 // long delays. Returned count will be complete anyway.
449 // (but a LIMIT would disrupt results in an UNION)
451 if (PMA_MYSQL_INT_VERSION
>= 40000
452 && !isset($analyzed_sql[0]['queryflags']['union'])) {
453 $count_query .= ' LIMIT 1';
456 // run the count query
457 //DEBUG echo "trace cq=" . $count_query . "<br/>";
459 if (PMA_MYSQL_INT_VERSION
< 40000) {
460 if ($cnt_all_result = PMA_mysql_query($count_query)) {
461 if ($is_group && $count_what == '*') {
462 $unlim_num_rows = @mysql_num_rows
($cnt_all_result);
464 $unlim_num_rows = PMA_mysql_result($cnt_all_result, 0, 'count');
466 mysql_free_result($cnt_all_result);
470 // there are some cases where the generated
471 // count_query (for MySQL 3) is wrong,
473 //TODO: use a big unlimited query to get
474 // the correct number of rows (depending
475 // on a config variable?)
480 PMA_mysql_query($count_query);
482 // void. I tried the case
483 // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`)
484 // UNION (SELECT `User`, `Host`, "%" AS "Db",
486 // FROM `user`) ORDER BY `User`, `Host`, `Db`;
487 // and although the generated count_query is wrong
488 // the SELECT FOUND_ROWS() work!
490 $cnt_all_result = PMA_mysql_query('SELECT FOUND_ROWS() as count');
491 $unlim_num_rows = PMA_mysql_result($cnt_all_result,0,'count');
493 } // end else "just browsing"
495 } else { // not $is_select
497 } // end rows total count
499 // garvin: if a table or database gets dropped, check column comments.
500 if (isset($purge) && $purge == '1') {
501 include('./libraries/relation_cleanup.lib.php3');
503 if (isset($table) && isset($db) && !empty($table) && !empty($db)) {
504 PMA_relationsCleanupTable($db, $table);
505 } elseif (isset($db) && !empty($db)) {
506 PMA_relationsCleanupDatabase($db);
508 // garvin: VOID. No DB/Table gets deleted.
509 } // end if relation-stuff
512 // garvin: If a column gets dropped, do relation magic.
513 if (isset($cpurge) && $cpurge == '1' && isset($purgekey)
514 && isset($db) && isset($table)
515 && !empty($db) && !empty($table) && !empty($purgekey)) {
516 include('./libraries/relation_cleanup.lib.php3');
517 PMA_relationsCleanupColumn($db, $table, $purgekey);
519 } // end if column PMA_* purge
520 } // end else "didn't ask to see php code"
523 // No rows returned -> move back to the calling page
524 if ($num_rows < 1 ||
$is_affected) {
526 $message = $strDeletedRows . ' ' . $num_rows;
527 } else if ($is_insert) {
528 $message = $strInsertedRows . ' ' . $num_rows;
529 $insert_id = mysql_insert_id();
530 if ($insert_id != 0) {
531 $message .= '<br />'.$strInsertedRowId . ' ' . $insert_id;
533 } else if ($is_affected) {
534 $message = $strAffectedRows . ' ' . $num_rows;
535 } else if (!empty($zero_rows)) {
536 $message = $zero_rows;
537 } else if (!empty($GLOBALS['show_as_php'])) {
539 } else if (!empty($GLOBALS['validatequery'])) {
540 $message = $strValidateSQL;
542 $message = $strEmptyResultSet;
545 $message .= ' ' . (isset($GLOBALS['querytime']) ?
'(' . sprintf($strQueryTime, $GLOBALS['querytime']) . ')' : '');
548 $goto = ereg_replace('\.\.*', '.', $goto);
549 // Checks for a valid target script
550 if (isset($table) && $table == '') {
553 if (isset($db) && $db == '') {
556 $is_db = $is_table = FALSE;
557 if (strpos(' ' . $goto, 'tbl_properties') == 1) {
558 if (!isset($table)) {
559 $goto = 'db_details.php3';
561 $is_table = @PMA_mysql_query
('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'');
562 if (!($is_table && @mysql_numrows
($is_table))) {
563 $goto = 'db_details.php3';
566 } // end if... else...
568 if (strpos(' ' . $goto, 'db_details') == 1) {
575 $is_db = @PMA_mysql_select_db
($db);
580 } // end if... else...
582 // Loads to target script
583 if (strpos(' ' . $goto, 'db_details') == 1
584 ||
strpos(' ' . $goto, 'tbl_properties') == 1) {
585 $js_to_run = 'functions.js';
587 if ($goto != 'main.php3') {
588 include('./header.inc.php3');
590 $active_page = $goto;
591 include('./' . $goto);
592 } // end if file_exist
594 header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&', '&', $goto) . '&message=' . urlencode($message));
597 } // end no rows returned
599 // At least one row is returned -> displays a table with results
601 // Displays the headers
602 if (isset($show_query)) {
605 if (isset($printview) && $printview == '1') {
606 include('./header_printview.inc.php3');
608 $js_to_run = 'functions.js';
610 if (!empty($table)) {
611 include('./tbl_properties_common.php3');
612 $url_query .= '&goto=tbl_properties.php3&back=tbl_properties.php3';
613 include('./tbl_properties_table_info.php3');
616 include('./db_details_common.php3');
617 include('./db_details_db_info.php3');
619 include('./libraries/relation.lib.php3');
620 $cfgRelation = PMA_getRelationsParam();
623 // Gets the list of fields properties
624 if (isset($result) && $result) {
625 while ($field = PMA_mysql_fetch_field($result)) {
626 $fields_meta[] = $field;
628 $fields_cnt = count($fields_meta);
631 // Display previous update query (from tbl_replace)
632 if (isset($disp_query) && $cfg['ShowSQL'] == TRUE) {
633 $tmp_sql_query = $GLOBALS['sql_query'];
634 $tmp_sql_limit_to_append = (isset($GLOBALS['sql_limit_to_append'])?
$GLOBALS['sql_limit_to_append']:'');
635 $GLOBALS['sql_query'] = $disp_query;
636 $GLOBALS['sql_limit_to_append'] = '';
637 PMA_showMessage($disp_message);
638 $GLOBALS['sql_query'] = $tmp_sql_query;
639 $GLOBALS['sql_limit_to_append'] = $tmp_sql_limit_to_append;
642 // Displays the results in a table
643 include('./libraries/display_tbl.lib.php3');
644 if (empty($disp_mode)) {
645 // see the "PMA_setDisplayMode()" function in
646 // libraries/display_tbl.lib.php3
647 $disp_mode = 'urdr111101';
649 if (!isset($dontlimitchars)) {
653 PMA_displayTable($result, $disp_mode, $analyzed_sql);
654 mysql_free_result($result);
656 if ($disp_mode[6] == '1' ||
$disp_mode[9] == '1') {
660 // Displays "Insert a new row" link if required
661 if ($disp_mode[6] == '1') {
662 $lnk_goto = 'sql.php3?'
663 . PMA_generate_common_url($db, $table)
665 . '&session_max_rows=' . $session_max_rows
666 . '&disp_direction=' . $disp_direction
667 . '&repeat_cells=' . $repeat_cells
668 . '&dontlimitchars=' . $dontlimitchars
669 . '&sql_query=' . urlencode($sql_query);
671 . PMA_generate_common_url($db, $table)
673 . '&session_max_rows=' . $session_max_rows
674 . '&disp_direction=' . $disp_direction
675 . '&repeat_cells=' . $repeat_cells
676 . '&dontlimitchars=' . $dontlimitchars
677 . '&sql_query=' . urlencode($sql_query)
678 . '&goto=' . urlencode($lnk_goto);
680 echo ' <!-- Insert a new row -->' . "\n"
681 . ' <a href="tbl_change.php3' . $url_query . '">' . $strInsertNewRow . '</a>';
682 if ($disp_mode[9] == '1') {
686 } // end insert new row
688 // Displays "printable view" link if required
689 if ($disp_mode[9] == '1') {
691 . PMA_generate_common_url($db, $table)
693 . '&session_max_rows=' . $session_max_rows
694 . '&disp_direction=' . $disp_direction
695 . '&repeat_cells=' . $repeat_cells
697 . '&sql_query=' . urlencode($sql_query);
698 echo ' <!-- Print view -->' . "\n"
699 . ' <a href="sql.php3' . $url_query
700 . ((isset($dontlimitchars) && $dontlimitchars == '1') ?
'&dontlimitchars=1' : '')
701 . '" target="print_view">' . $strPrintView . '</a>' . "\n";
702 if (!$dontlimitchars) {
703 echo ' <br />' . "\n"
704 . ' <a href="sql.php3' . $url_query
705 . '&dontlimitchars=1'
706 . '" target="print_view">' . $strPrintViewFull . '</a>' . "\n";
708 } // end displays "printable view"
713 // Export link, if only one table
714 // (the url_query has extra parameters that won't be used to export)
715 if (!isset($printview)) {
716 if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name']) && !isset($analyzed_sql[0]['table_ref'][1]['table_true_name'])) {
717 $single_table = '&single_table=true';
721 echo ' <!-- Export -->' . "\n"
722 . ' <a href="tbl_properties_export.php3' . $url_query
723 . '&unlim_num_rows=' . $unlim_num_rows
725 . '">' . $strExport . '</a>' . "\n";
728 // Bookmark Support if required
729 if ($disp_mode[7] == '1'
730 && ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table'] && empty($id_bookmark))
731 && !empty($sql_query)) {
735 . PMA_generate_common_url($db, $table)
737 . '&session_max_rows=' . $session_max_rows
738 . '&disp_direction=' . $disp_direction
739 . '&repeat_cells=' . $repeat_cells
740 . '&dontlimitchars=' . $dontlimitchars
741 . '&sql_query=' . urlencode($sql_query)
742 . '&id_bookmark=1';
744 <!-- Bookmark the query
-->
745 <form action
="sql.php3" method
="post" onsubmit
="return emptyFormElements(this, 'fields[label]');">
748 if ($disp_mode[3] == '1') {
749 echo ' <i>' . $strOr . '</i>' . "\n";
753 <?php
echo $strBookmarkLabel; ?
>:
754 <?php
echo PMA_generate_common_hidden_inputs(); ?
>
755 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
756 <input type
="hidden" name
="fields[dbase]" value
="<?php echo htmlspecialchars($db); ?>" />
757 <input type
="hidden" name
="fields[user]" value
="<?php echo $cfg['Bookmark']['user']; ?>" />
758 <input type
="hidden" name
="fields[query]" value
="<?php echo urlencode(isset($complete_query) ? $complete_query : $sql_query); ?>" />
759 <input type
="text" name
="fields[label]" value
="" />
760 <input type
="checkbox" name
="bkm_all_users" id
="bkm_all_users" value
="true" /><label
for="bkm_all_users"><?php
echo $strBookmarkAllUsers; ?
></label
>
761 <input type
="submit" name
="store_bkm" value
="<?php echo $strBookmarkThis; ?>" />
764 } // end bookmark support
766 // Do print the page if required
767 if (isset($printview) && $printview == '1') {
770 <script type
="text/javascript" language
="javascript1.2">
773 if (typeof(window
.print) != 'undefined') {
780 } // end rows returned
782 } // end executes the query
786 * Displays the footer
788 require('./footer.inc.php3');