update
[phpmyadmin/crack.git] / sql.php3
blobd5eae68b77120267dd37ff6256de3b73ad4d0673
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
4 error_reporting(E_ALL);
5 /**
6 * Gets some core libraries
7 */
8 require('./libraries/grab_globals.lib.php3');
9 require('./libraries/common.lib.php3');
11 /**
12 * Defines the url to return to in case of error in a sql statement
14 // Security checkings
15 if (!empty($goto)) {
16 $is_gotofile = ereg_replace('^([^?]+).*$', '\\1', $goto);
17 if (!@file_exists('./' . $is_gotofile)) {
18 unset($goto);
19 } else {
20 $is_gotofile = ($is_gotofile == $goto);
22 } // end if (security checkings)
24 if (empty($goto)) {
25 $goto = (empty($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable'];
26 $is_gotofile = TRUE;
27 } // end if
28 if (!isset($err_url)) {
29 $err_url = (!empty($back) ? $back : $goto)
30 . '?' . PMA_generate_common_url(isset($db) ? $db : '')
31 . ((strpos(' ' . $goto, 'db_details') != 1 && isset($table)) ? '&amp;table=' . urlencode($table) : '');
32 } // end if
34 // Coming from a bookmark dialog
35 if (isset($fields['query'])) {
36 $sql_query = $fields['query'];
39 /**
40 * Check rights in case of DROP DATABASE
42 * This test may be bypassed if $is_js_confirmed = 1 (already checked with js)
43 * but since a malicious user may pass this variable by url/form, we don't take
44 * into account this case.
46 if (!defined('PMA_CHK_DROP')
47 && !$cfg['AllowUserDropDatabase']
48 && eregi('DROP[[:space:]]+(IF EXISTS[[:space:]]+)?DATABASE[[:space:]]', $sql_query)) {
49 // Checks if the user is a Superuser
50 // TODO: set a global variable with this information
51 // loic1: optimized query
52 $result = @PMA_mysql_query('USE mysql');
53 if (PMA_mysql_error()) {
54 include('./header.inc.php3');
55 PMA_mysqlDie($strNoDropDatabases, '', '', $err_url);
56 } // end if
57 } // end if
60 /**
61 * Bookmark add
63 if (isset($store_bkm)) {
64 if (get_magic_quotes_gpc()) {
65 $fields['label'] = stripslashes($fields['label']);
67 include('./libraries/bookmark.lib.php3');
68 PMA_addBookmarks($fields, $cfg['Bookmark']);
69 header('Location: ' . $cfg['PmaAbsoluteUri'] . $goto);
70 } // end if
73 /**
74 * Gets the true sql query
76 // $sql_query has been urlencoded in the confirmation form for drop/delete
77 // queries or in the navigation bar for browsing among records
78 if (isset($btnDrop) || isset($navig)) {
79 $sql_query = urldecode($sql_query);
82 /**
83 * Reformat the query
86 $parsed_sql = PMA_SQP_parse((get_magic_quotes_gpc() ? stripslashes($sql_query) : $sql_query));
87 $analyzed_sql = PMA_SQP_analyze($parsed_sql);
88 // Bug #641765 - Robbat2 - 12 January 2003, 10:49PM
89 // Reverted - Robbat2 - 13 January 2003, 2:40PM
90 $sql_query = PMA_SQP_formatHtml($parsed_sql, 'query_only');
92 // here we are sure that SELECT is uppercase
93 $is_select = eregi('^SELECT[[:space:]]+', $sql_query);
95 // If the query is a Select, extract the db and table names and modify
96 // $db and $table, to have correct page headers, links and left frame.
97 // db and table name may be enclosed with backquotes, db is optionnal,
98 // query may contain aliases.
100 // (TODO: if there are more than one table name in the Select:
101 // - do not extract the first table name
102 // - do not show a table name in the page header
103 // - do not display the sub-pages links)
105 //if ($is_select) {
106 // eregi('^SELECT[[:space:]]+(.*)[[:space:]]+FROM[[:space:]]+(`[^`]+`|[A-Za-z0-9_$]+)([\.]*)(`[^`]*`|[A-Za-z0-9_$]*)', $sql_query, $tmp);
108 // if ($tmp[3] == '.') {
109 // $prev_db = $db;
110 // $db = str_replace('`', '', $tmp[2]);
111 // $reload = ($db == $prev_db) ? 0 : 1;
112 // $table = str_replace('`', '', $tmp[4]);
113 // }
114 // else {
115 // $table = str_replace('`', '', $tmp[2]);
116 // }
117 //} // end if
119 if ($is_select) {
120 $prev_db = $db;
121 if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])) {
122 $table = $analyzed_sql[0]['table_ref'][0]['table_true_name'];
124 if (isset($analyzed_sql[0]['table_ref'][0]['db'])
125 && !empty($analyzed_sql[0]['table_ref'][0]['db'])) {
126 $db = $analyzed_sql[0]['table_ref'][0]['db'];
128 else {
129 $db = $prev_db;
131 $reload = ($db == $prev_db) ? 0 : 1;
135 * Sets or modifies the $goto variable if required
137 if ($goto == 'sql.php3') {
138 $goto = 'sql.php3?'
139 . PMA_generate_common_url($db, $table)
140 . '&amp;pos=' . $pos
141 . '&amp;sql_query=' . urlencode($sql_query);
142 } // end if
146 * Go back to further page if table should not be dropped
148 if (isset($btnDrop) && $btnDrop == $strNo) {
149 if (!empty($back)) {
150 $goto = $back;
152 if ($is_gotofile) {
153 if (strpos(' ' . $goto, 'db_details') == 1 && !empty($table)) {
154 unset($table);
156 include('./' . ereg_replace('\.\.*', '.', $goto));
157 } else {
158 header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto));
160 exit();
161 } // end if
165 * Displays the confirm page if required
167 * This part of the script is bypassed if $is_js_confirmed = 1 (already checked
168 * with js) because possible security issue is not so important here: at most,
169 * the confirm message isn't displayed.
171 * Also bypassed if only showing php code.or validating a SQL query
173 if (!$cfg['Confirm']
174 || (isset($is_js_confirmed) && $is_js_confirmed)
175 || isset($btnDrop)
176 || !empty($GLOBALS['show_as_php'])
177 || !empty($GLOBALS['validatequery'])) {
178 $do_confirm = FALSE;
179 } else {
180 //$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));
182 $do_confirm = isset($analyzed_sql[0]['queryflags']['need_confirm']);
185 if ($do_confirm) {
186 // already stripped at beginning of script
187 //$stripped_sql_query = (get_magic_quotes_gpc() ? stripslashes($sql_query) : $sql_query);
188 $stripped_sql_query = $sql_query;
189 include('./header.inc.php3');
190 echo $strDoYouReally . '&nbsp;:<br />' . "\n";
191 echo '<tt>' . htmlspecialchars($stripped_sql_query) . '</tt>&nbsp;?<br/>' . "\n";
193 <form action="sql.php3" method="post">
194 <?php echo PMA_generate_common_hidden_inputs($db, (isset($table)?$table:'')); ?>
195 <input type="hidden" name="sql_query" value="<?php echo urlencode(addslashes($sql_query)); ?>" />
196 <input type="hidden" name="zero_rows" value="<?php echo isset($zero_rows) ? $zero_rows : ''; ?>" />
197 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
198 <input type="hidden" name="back" value="<?php echo isset($back) ? $back : ''; ?>" />
199 <input type="hidden" name="reload" value="<?php echo isset($reload) ? $reload : 0; ?>" />
200 <input type="hidden" name="show_query" value="<?php echo isset($show_query) ? $show_query : ''; ?>" />
201 <input type="submit" name="btnDrop" value="<?php echo $strYes; ?>" />
202 <input type="submit" name="btnDrop" value="<?php echo $strNo; ?>" />
203 </form>
204 <?php
205 echo "\n";
206 } // end if
210 * Executes the query and displays results
212 else {
213 if (!isset($sql_query)) {
214 $sql_query = '';
216 // already stripped at beginning of script
217 // else if (get_magic_quotes_gpc()) {
218 // $sql_query = stripslashes($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)) {
224 $reload = 1;
226 // Gets the number of rows per page
227 if (!isset($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
241 // rows.
242 // $is_count is changed for more correct "LIMIT" clause
243 // appending in queries like
244 // "SELECT COUNT(...) FROM ... GROUP BY ..."
245 $is_explain = $is_count = $is_export = $is_delete = $is_insert = $is_affected = $is_show = $is_maint = $is_analyse = $is_group = $is_func = FALSE;
246 if ($is_select) { // see line 141
247 $is_group = eregi('[[:space:]]+(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+', $sql_query);
249 $is_func = !$is_group && (eregi('[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(', $sql_query));
250 $is_count = !$is_group && (eregi('^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)', $sql_query));
251 $is_export = (eregi('[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+', $sql_query));
252 $is_analyse = (eregi('[[:space:]]+PROCEDURE[[:space:]]+ANALYSE\(', $sql_query));
253 } else if (eregi('^EXPLAIN[[:space:]]+', $sql_query)) {
254 $is_explain = TRUE;
255 } else if (eregi('^DELETE[[:space:]]+', $sql_query)) {
256 $is_delete = TRUE;
257 $is_affected = TRUE;
258 } else if (eregi('^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+', $sql_query)) {
259 $is_insert = TRUE;
260 $is_affected = TRUE;
261 } else if (eregi('^UPDATE[[:space:]]+', $sql_query)) {
262 $is_affected = TRUE;
263 } else if (eregi('^SHOW[[:space:]]+', $sql_query)) {
264 $is_show = TRUE;
265 } else if (eregi('^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+', $sql_query)) {
266 $is_maint = TRUE;
269 // Do append a "LIMIT" clause?
270 if (isset($pos)
271 && (!$cfg['ShowAll'] || $session_max_rows != 'all')
272 && !($is_count || $is_export || $is_func || $is_analyse)
274 //&& $is_select
275 //&& eregi('[[:space:]]FROM[[:space:]]', $sql_query)
277 && isset($analyzed_sql[0]['queryflags']['select_from'])
279 && !eregi('[[:space:]]LIMIT[[:space:]0-9,-]+$', $sql_query)) {
280 $sql_limit_to_append = " LIMIT $pos, ".$cfg['MaxRows'];
281 if (eregi('(.*)([[:space:]](PROCEDURE[[:space:]](.*)|FOR[[:space:]]+UPDATE|LOCK[[:space:]]+IN[[:space:]]+SHARE[[:space:]]+MODE))$', $sql_query, $regs)) {
282 $full_sql_query = $regs[1] . $sql_limit_to_append . $regs[2];
283 } else {
284 $full_sql_query = $sql_query . $sql_limit_to_append;
286 } else {
287 $full_sql_query = $sql_query;
288 } // end if...else
290 PMA_mysql_select_db($db);
292 // If the query is a DELETE query with no WHERE clause, get the number of
293 // rows that will be deleted (mysql_affected_rows will always return 0 in
294 // this case)
295 if ($is_delete
296 && eregi('^DELETE([[:space:]].+)?([[:space:]]FROM[[:space:]](.+))$', $sql_query, $parts)
297 && !eregi('[[:space:]]WHERE[[:space:]]', $parts[3])) {
298 $cnt_all_result = @PMA_mysql_query('SELECT COUNT(*) as count' . $parts[2]);
299 if ($cnt_all_result) {
300 $num_rows = PMA_mysql_result($cnt_all_result, 0, 'count');
301 mysql_free_result($cnt_all_result);
302 } else {
303 $num_rows = 0;
307 // E x e c u t e t h e q u e r y
309 // Only if we didn't ask to see the php code (mikebeck)
310 if (!empty($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
311 unset($result);
312 $num_rows = 0;
314 else {
315 $result = @PMA_mysql_query($full_sql_query);
317 // Displays an error message if required and stop parsing the script
318 if (PMA_mysql_error()) {
319 $error = PMA_mysql_error();
320 include('./header.inc.php3');
321 $full_err_url = (ereg('^(db_details|tbl_properties)', $err_url))
322 ? $err_url . '&amp;show_query=1&amp;sql_query=' . urlencode($sql_query)
323 : $err_url;
324 PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
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) ? @mysql_num_rows($result) : 0;
333 } else if (!isset($num_rows)) {
334 $num_rows = @mysql_affected_rows();
337 // Checks if the current database has changed
338 // This could happen if the user sends a query like "USE `database`;"
339 $res = PMA_mysql_query('SELECT DATABASE() AS "db";');
340 $row = PMA_mysql_fetch_array($res);
341 if ($db != $row['db']) {
342 $db = $row['db'];
343 $reload = 1;
345 @mysql_free_result($res);
346 unset($res);
347 unset($row);
349 // tmpfile remove after convert encoding appended by Y.Kawada
350 if (function_exists('PMA_kanji_file_conv')
351 && (isset($textfile) && file_exists($textfile))) {
352 unlink($textfile);
355 // Counts the total number of rows for the same 'SELECT' query without the
356 // 'LIMIT' clause that may have been programatically added
357 if (empty($sql_limit_to_append)) {
358 $unlim_num_rows = $num_rows;
360 else if ($is_select) {
361 // SK -- Patch : correct calculations for GROUP BY, HAVING, DISTINCT
363 // Reads only the from-part of the query...
364 // NOTE: here the presence of LIMIT is impossible, HAVING and GROUP BY
365 // are necessary for correct calculation, and extra spaces and
366 // lowercase reserved words are removed, so we have a simple split
367 // pattern:
369 $array = split('[[:space:]]+(FROM|ORDER BY)[[:space:]]+', $sql_query);
371 // if $array[1] is empty here, there is an error in the query:
372 // "... FROM [ORDER BY ...]", but the query is already executed with
373 // success so this check is redundant???
375 if (!empty($array[1])) {
376 // ... and makes a count(*) to count the entries
377 // Special case: SELECT DISTINCT ... FROM ...
378 // the count of resulting rows can be found as:
379 // SELECT COUNT(DISTINCT ...) FROM ...
380 if (eregi('^SELECT DISTINCT(.*)', $array[0], $array_dist)) {
381 $count_what = 'DISTINCT ' . $array_dist[1];
382 } else {
383 $count_what = '*';
385 $count_query = 'SELECT COUNT(' . $count_what . ') AS count FROM ' . $array[1];
386 if ($cnt_all_result = mysql_query($count_query)) {
387 if ($is_group) {
388 $unlim_num_rows = @mysql_num_rows($cnt_all_result);
389 } else {
390 $unlim_num_rows = mysql_result($cnt_all_result, 0, 'count');
392 mysql_free_result($cnt_all_result);
394 } else {
395 $unlim_num_rows = 0;
397 } // end rows total count
398 } // end else "didn't ask to see php code"
401 // No rows returned -> move back to the calling page
402 if ($num_rows < 1 || $is_affected) {
403 if ($is_delete) {
404 $message = $strDeletedRows . '&nbsp;' . $num_rows;
405 } else if ($is_insert) {
406 $message = $strInsertedRows . '&nbsp;' . $num_rows;
407 } else if ($is_affected) {
408 $message = $strAffectedRows . '&nbsp;' . $num_rows;
409 } else if (!empty($zero_rows)) {
410 $message = $zero_rows;
411 } else if (!empty($GLOBALS['show_as_php'])) {
412 $message = $strPhp;
413 } else if (!empty($GLOBALS['validatequery'])) {
414 $message = $strValidateSQL;
415 } else {
416 $message = $strEmptyResultSet;
419 if ($is_gotofile) {
420 $goto = ereg_replace('\.\.*', '.', $goto);
421 // Checks for a valid target script
422 if (isset($table) && $table == '') {
423 unset($table);
425 if (isset($db) && $db == '') {
426 unset($db);
428 $is_db = $is_table = FALSE;
429 if (strpos(' ' . $goto, 'tbl_properties') == 1) {
430 if (!isset($table)) {
431 $goto = 'db_details.php3';
432 } else {
433 $is_table = @PMA_mysql_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'');
434 if (!($is_table && @mysql_numrows($is_table))) {
435 $goto = 'db_details.php3';
436 unset($table);
438 } // end if... else...
440 if (strpos(' ' . $goto, 'db_details') == 1) {
441 if (isset($table)) {
442 unset($table);
444 if (!isset($db)) {
445 $goto = 'main.php3';
446 } else {
447 $is_db = @PMA_mysql_select_db($db);
448 if (!$is_db) {
449 $goto = 'main.php3';
450 unset($db);
452 } // end if... else...
454 // Loads to target script
455 if (strpos(' ' . $goto, 'db_details') == 1
456 || strpos(' ' . $goto, 'tbl_properties') == 1) {
457 $js_to_run = 'functions.js';
459 if ($goto != 'main.php3') {
460 include('./header.inc.php3');
462 include('./' . $goto);
463 } // end if file_exist
464 else {
465 header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto) . '&message=' . urlencode($message));
466 } // end else
467 exit();
468 } // end no rows returned
470 // At least one row is returned -> displays a table with results
471 else {
472 // Displays the headers
473 if (isset($show_query)) {
474 unset($show_query);
476 if (isset($printview) && $printview == '1') {
477 include('./header_printview.inc.php3');
478 } else {
479 $js_to_run = 'functions.js';
480 unset($message);
481 if (!empty($table)) {
482 include('./tbl_properties_common.php3');
483 $url_query .= '&amp;goto=tbl_properties.php3&amp;back=tbl_properties.php3';
484 include('./tbl_properties_table_info.php3');
486 else {
487 include('./db_details_common.php3');
488 include('./db_details_db_info.php3');
490 include('./libraries/relation.lib.php3');
491 $cfgRelation = PMA_getRelationsParam();
494 // Gets the list of fields properties
495 if (isset($result) && $result) {
496 while ($field = PMA_mysql_fetch_field($result)) {
497 $fields_meta[] = $field;
499 $fields_cnt = count($fields_meta);
502 // Display previous update query (from tbl_replace)
503 if (isset($disp_query) && $cfg['ShowSQL'] == TRUE) {
504 $tmp_sql_query = $GLOBALS['sql_query'];
505 $tmp_sql_limit_to_append = $GLOBALS['sql_limit_to_append'];
506 $GLOBALS['sql_query'] = stripslashes($disp_query);
507 $GLOBALS['sql_limit_to_append'] = '';
508 PMA_showMessage($disp_message);
509 $GLOBALS['sql_query'] = $tmp_sql_query;
510 $GLOBALS['sql_limit_to_append'] = $tmp_sql_limit_to_append;
513 // Displays the results in a table
514 include('./libraries/display_tbl.lib.php3');
515 if (empty($disp_mode)) {
516 // see the "PMA_setDisplayMode()" function in
517 // libraries/display_tbl.lib.php3
518 $disp_mode = 'urdr111101';
520 if (!isset($dontlimitchars)) {
521 $dontlimitchars = 0;
524 PMA_displayTable($result, $disp_mode, $analyzed_sql);
525 mysql_free_result($result);
527 if ($disp_mode[6] == '1' || $disp_mode[9] == '1') {
528 echo "\n";
529 echo '<p>' . "\n";
531 // Displays "Insert a new row" link if required
532 if ($disp_mode[6] == '1') {
533 $lnk_goto = 'sql.php3?'
534 . PMA_generate_common_url($db, $table)
535 . '&amp;pos=' . $pos
536 . '&amp;session_max_rows=' . $session_max_rows
537 . '&amp;disp_direction=' . $disp_direction
538 . '&amp;repeat_cells=' . $repeat_cells
539 . '&amp;dontlimitchars=' . $dontlimitchars
540 . '&amp;sql_query=' . urlencode($sql_query);
541 $url_query = '?'
542 . PMA_generate_common_url($db, $table)
543 . '&amp;pos=' . $pos
544 . '&amp;session_max_rows=' . $session_max_rows
545 . '&amp;disp_direction=' . $disp_direction
546 . '&amp;repeat_cells=' . $repeat_cells
547 . '&amp;dontlimitchars=' . $dontlimitchars
548 . '&amp;sql_query=' . urlencode($sql_query)
549 . '&amp;goto=' . urlencode($lnk_goto);
551 echo ' <!-- Insert a new row -->' . "\n"
552 . ' <a href="tbl_change.php3' . $url_query . '">' . $strInsertNewRow . '</a>';
553 if ($disp_mode[9] == '1') {
554 echo '<br />';
556 echo "\n";
557 } // end insert new row
559 // Displays "printable view" link if required
560 if ($disp_mode[9] == '1') {
561 $url_query = '?'
562 . PMA_generate_common_url($db, $table)
563 . '&amp;pos=' . $pos
564 . '&amp;session_max_rows=' . $session_max_rows
565 . '&amp;disp_direction=' . $disp_direction
566 . '&amp;repeat_cells=' . $repeat_cells
567 . '&amp;printview=1'
568 . ((isset($dontlimitchars) && $dontlimitchars == '1') ? '&amp;dontlimitchars=1' : '')
569 . '&amp;sql_query=' . urlencode($sql_query);
570 echo ' <!-- Print view -->' . "\n"
571 . ' <a href="sql.php3' . $url_query . '" target="print_view">' . $strPrintView . '</a>' . "\n";
572 } // end displays "printable view"
574 echo '</p>' . "\n";
577 // Export link, if only one table
578 // (the url_query has extra parameters that won't be used to export)
579 if (!isset($printview)
580 && isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])
581 && !isset($analyzed_sql[0]['table_ref'][1]['table_true_name'])) {
582 echo ' <!-- Export -->' . "\n"
583 . ' <a href="tbl_properties_export.php3' . $url_query . '&amp;unlim_num_rows=' . $unlim_num_rows . '">' . $strExport . '</a>' . "\n";
586 // Bookmark Support if required
587 if ($disp_mode[7] == '1'
588 && ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table'] && empty($id_bookmark))
589 && !empty($sql_query)) {
590 echo "\n";
592 $goto = 'sql.php3?'
593 . PMA_generate_common_url($db, $table)
594 . '&amp;pos=' . $pos
595 . '&amp;session_max_rows=' . $session_max_rows
596 . '&amp;disp_direction=' . $disp_direction
597 . '&amp;repeat_cells=' . $repeat_cells
598 . '&amp;dontlimitchars=' . $dontlimitchars
599 . '&amp;sql_query=' . urlencode($sql_query)
600 . '&amp;id_bookmark=1';
602 <!-- Bookmark the query -->
603 <form action="sql.php3" method="post" onsubmit="return emptyFormElements(this, 'fields[label]');">
604 <?php
605 echo "\n";
606 if ($disp_mode[3] == '1') {
607 echo ' <i>' . $strOr . '</i>' . "\n";
610 <br /><br />
611 <?php echo $strBookmarkLabel; ?>&nbsp;:
612 <?php echo PMA_generate_common_hidden_inputs(); ?>
613 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
614 <input type="hidden" name="fields[dbase]" value="<?php echo htmlspecialchars($db); ?>" />
615 <input type="hidden" name="fields[user]" value="<?php echo $cfg['Bookmark']['user']; ?>" />
616 <input type="hidden" name="fields[query]" value="<?php echo urlencode($sql_query); ?>" />
617 <input type="text" name="fields[label]" value="" />
618 <input type="submit" name="store_bkm" value="<?php echo $strBookmarkThis; ?>" />
619 </form>
620 <?php
621 } // end bookmark support
623 // Do print the page if required
624 if (isset($printview) && $printview == '1') {
625 echo "\n";
627 <script type="text/javascript" language="javascript1.2">
628 <!--
629 // Do print the page
630 if (typeof(window.print) != 'undefined') {
631 window.print();
633 //-->
634 </script>
635 <?php
636 } // end print case
637 } // end rows returned
639 } // end executes the query
640 echo "\n\n";
644 * Displays the footer
646 require('./footer.inc.php3');