update
[phpmyadmin/crack.git] / sql.php3
blob23e92d417dfe5955bb0a0d1aa773b1aa524969b1
1 <?php
2 /* $Id$ */
5 /**
6 * Gets some core libraries
7 */
8 require('./libraries/grab_globals.lib.php3');
9 require('./libraries/common.lib.php3');
12 /**
13 * Defines the url to return to in case of error in a sql statement
15 // Security checkings
16 if (!empty($goto)) {
17 $is_gotofile = ereg_replace('^([^?]+).*$', '\\1', $goto);
18 if (!@file_exists('./' . $is_gotofile)) {
19 unset($goto);
20 } else {
21 $is_gotofile = ($is_gotofile == $goto);
23 } // end if (security checkings)
25 if (empty($goto)) {
26 $goto = (empty($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable'];
27 $is_gotofile = TRUE;
28 } // end if
29 if (!isset($err_url)) {
30 $err_url = (!empty($back) ? $back : $goto)
31 . '?lang=' . $lang
32 . '&amp;convcharset=' . $convcharset
33 . '&amp;server=' . $server
34 . (isset($db) ? '&amp;db=' . urlencode($db) : '')
35 . ((strpos(' ' . $goto, 'db_details') != 1 && isset($table)) ? '&amp;table=' . urlencode($table) : '');
36 } // end if
39 /**
40 * SK -- Patch
42 * Does some preliminary formatting of the $sql_query to avoid problems with
43 * eregi and split:
44 * 1) separates reserved words in $sql_str from the next backquoted or
45 * parenthesized expression with a space;
46 * 2) capitalizes reserved words
47 * 3) removes repeated spaces
49 * @param string original query
51 * @return string formatted query
53 function PMA_sqlFormat($sql_str) {
54 // Defines reserved words to deal with
55 $res_words_arr = array('DROP', 'SELECT', 'DELETE', 'UPDATE', 'INSERT', 'LOAD', 'EXPLAIN', 'SHOW', 'FROM', 'INTO', 'OUTFILE', 'DATA', 'REPLACE', 'CHECK', 'ANALYZE', 'REPAIR', 'OPTIMIZE', 'TABLE', 'ORDER', 'HAVING', 'LIMIT', 'GROUP', 'DISTINCT');
57 while (list(, $w) = each($res_words_arr)) {
58 // Separates a backquoted expression with spaces
59 $pattern = '[[:space:]]' . $w . '`([^`]*)`(.*)';
60 $replace = ' ' . $w . ' `\\1` \\2';
61 $sql_str = substr(eregi_replace($pattern, $replace, ' ' . $sql_str), 1);
63 // Separates a parenthesized expression with spaces
64 $pattern = '[[:space:]]' . $w . '\(([^)]*)\)(.*)';
65 $replace = ' ' . $w . ' (\\1) \\2';
66 $sql_str = substr(eregi_replace($pattern, $replace, ' ' . $sql_str), 1);
68 // Converts reservered words to upper case if not yet done
69 $sql_str = substr(eregi_replace('[[:space:]]' . $w . '[[:space:]]', ' ' . $w . ' ', ' ' . $sql_str), 1);
70 } // end while
72 // Removes repeated spaces
73 $sql_str = ereg_replace('[[:space:]]+', ' ', $sql_str);
75 // GROUP or ORDER: "BY" to uppercase too
76 $sql_str = eregi_replace('(GROUP|ORDER) BY', '\\1 BY', $sql_str);
78 return $sql_str;
79 } // end of the "PMA_sqlFormat()" function
82 /**
83 * Check rights in case of DROP DATABASE
85 * This test may be bypassed if $is_js_confirmed = 1 (already checked with js)
86 * but since a malicious user may pass this variable by url/form, we don't take
87 * into account this case.
89 if (!defined('PMA_CHK_DROP')
90 && !$cfg['AllowUserDropDatabase']
91 && eregi('DROP[[:space:]]+(IF EXISTS[[:space:]]+)?DATABASE[[:space:]]', $sql_query)) {
92 // Checks if the user is a Superuser
93 // TODO: set a global variable with this information
94 // loic1: optimized query
95 $result = @PMA_mysql_query('USE mysql');
96 if (PMA_mysql_error()) {
97 include('./header.inc.php3');
98 PMA_mysqlDie($strNoDropDatabases, '', '', $err_url);
99 } // end if
100 } // end if
104 * Bookmark add
106 if (isset($store_bkm)) {
107 if (get_magic_quotes_gpc()) {
108 $fields['label'] = stripslashes($fields['label']);
110 include('./libraries/bookmark.lib.php3');
111 PMA_addBookmarks($fields, $cfg['Bookmark']);
112 header('Location: ' . $cfg['PmaAbsoluteUri'] . $goto);
113 } // end if
117 * Gets the true sql query
119 // $sql_query has been urlencoded in the confirmation form for drop/delete
120 // queries or in the navigation bar for browsing among records
121 if (isset($btnDrop) || isset($navig)) {
122 $sql_query = urldecode($sql_query);
125 // SK -- Patch : Reformats query - adds spaces when omitted and removes extra
126 // spaces; converts reserved words to uppercase
127 $sql_query = PMA_sqlFormat($sql_query);
130 // If the query is a Select, extract the db and table names and modify
131 // $db and $table, to have correct page headers, links and left frame.
132 // db and table name may be enclosed with backquotes, db is optionnal,
133 // query may contain aliases.
134 // (todo: check for embedded comments...)
136 // (todo: if there are more than one table name in the Select:
137 // - do not extract the first table name
138 // - do not show a table name in the page header
139 // - do not display the sub-pages links)
141 $is_select = eregi('^SELECT[[:space:]]+', $sql_query);
142 if ($is_select) {
143 eregi('^SELECT[[:space:]]+(.*)[[:space:]]+FROM[[:space:]]+(`[^`]+`|[A-Za-z0-9_$]+)([\.]*)(`[^`]*`|[A-Za-z0-9_$]*)', $sql_query, $tmp);
145 if ($tmp[3] == '.') {
146 $prev_db = $db;
147 $db = str_replace('`', '', $tmp[2]);
148 $reload = ($db == $prev_db) ? 0 : 1;
149 $table = str_replace('`', '', $tmp[4]);
151 else {
152 $table = str_replace('`', '', $tmp[2]);
154 } // end if
158 * Sets or modifies the $goto variable if required
160 if ($goto == 'sql.php3') {
161 $goto = 'sql.php3'
162 . '?lang=' . $lang
163 . '&amp;convcharset=' . $convcharset
164 . '&amp;server=' . $server
165 . '&amp;db=' . urlencode($db)
166 . '&amp;table=' . urlencode($table)
167 . '&amp;pos=' . $pos
168 . '&amp;sql_query=' . urlencode($sql_query);
169 } // end if
173 * Go back to further page if table should not be dropped
175 if (isset($btnDrop) && $btnDrop == $strNo) {
176 if (!empty($back)) {
177 $goto = $back;
179 if ($is_gotofile) {
180 if (strpos(' ' . $goto, 'db_details') == 1 && !empty($table)) {
181 unset($table);
183 include('./' . ereg_replace('\.\.*', '.', $goto));
184 } else {
185 header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto));
187 exit();
188 } // end if
192 * Displays the confirm page if required
194 * This part of the script is bypassed if $is_js_confirmed = 1 (already checked
195 * with js) because possible security issue is not so important here: at most,
196 * the confirm message isn't displayed.
198 * Also bypassed if only showing php code.or validating a SQL query
200 if (!$cfg['Confirm']
201 || (isset($is_js_confirmed) && $is_js_confirmed)
202 || isset($btnDrop)
203 || !empty($GLOBALS['show_as_php'])
204 || !empty($GLOBALS['validatequery'])) {
205 $do_confirm = FALSE;
206 } else {
207 /* SQL-Parser-Analyzer */
208 $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));
211 if ($do_confirm) {
212 if (get_magic_quotes_gpc()) {
213 $stripped_sql_query = stripslashes($sql_query);
214 } else {
215 $stripped_sql_query = $sql_query;
217 include('./header.inc.php3');
218 echo $strDoYouReally . '&nbsp;:<br />' . "\n";
219 echo '<tt>' . htmlspecialchars($stripped_sql_query) . '</tt>&nbsp;?<br/>' . "\n";
221 <form action="sql.php3" method="post">
222 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
223 <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
224 <input type="hidden" name="server" value="<?php echo $server; ?>" />
225 <input type="hidden" name="db" value="<?php echo $db; ?>" />
226 <input type="hidden" name="table" value="<?php echo isset($table) ? $table : ''; ?>" />
227 <input type="hidden" name="sql_query" value="<?php echo urlencode($sql_query); ?>" />
228 <input type="hidden" name="zero_rows" value="<?php echo isset($zero_rows) ? $zero_rows : ''; ?>" />
229 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
230 <input type="hidden" name="back" value="<?php echo isset($back) ? $back : ''; ?>" />
231 <input type="hidden" name="reload" value="<?php echo isset($reload) ? $reload : 0; ?>" />
232 <input type="hidden" name="show_query" value="<?php echo isset($show_query) ? $show_query : ''; ?>" />
233 <input type="submit" name="btnDrop" value="<?php echo $strYes; ?>" />
234 <input type="submit" name="btnDrop" value="<?php echo $strNo; ?>" />
235 </form>
236 <?php
237 echo "\n";
238 } // end if
242 * Executes the query and displays results
244 else {
245 if (!isset($sql_query)) {
246 $sql_query = '';
247 } else if (get_magic_quotes_gpc()) {
248 $sql_query = stripslashes($sql_query);
250 // Defines some variables
251 // loic1: A table has to be created -> left frame should be reloaded
252 if ((!isset($reload) || $reload == 0)
253 && eregi('^CREATE TABLE[[:space:]]+(.*)', $sql_query)) {
254 $reload = 1;
256 // Gets the number of rows per page
257 if (!isset($session_max_rows)) {
258 $session_max_rows = $cfg['MaxRows'];
259 } else if ($session_max_rows != 'all') {
260 $cfg['MaxRows'] = $session_max_rows;
262 // Defines the display mode (horizontal/vertical) and header "frequency"
263 if (empty($disp_direction)) {
264 $disp_direction = $cfg['DefaultDisplay'];
266 if (empty($repeat_cells)) {
267 $repeat_cells = $cfg['RepeatCells'];
270 // SK -- Patch: $is_group added for use in calculation of total number of
271 // rows.
272 // $is_count is changed for more correct "LIMIT" clause
273 // appending in queries like
274 // "SELECT COUNT(...) FROM ... GROUP BY ..."
275 $is_explain = $is_count = $is_export = $is_delete = $is_insert = $is_affected = $is_show = $is_maint = $is_analyse = $is_group = $is_func = FALSE;
276 if ($is_select) { // see line 141
277 $is_func = !$is_group && (eregi('[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(', $sql_query));
278 $is_group = eregi('[[:space:]]+(GROUP BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+', $sql_query);
279 $is_count = !$is_group && (eregi('^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)', $sql_query));
280 $is_export = (eregi('[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+', $sql_query));
281 $is_analyse = (eregi('[[:space:]]+PROCEDURE[[:space:]]+ANALYSE\(', $sql_query));
282 } else if (eregi('^EXPLAIN[[:space:]]+', $sql_query)) {
283 $is_explain = TRUE;
284 } else if (eregi('^DELETE[[:space:]]+', $sql_query)) {
285 $is_delete = TRUE;
286 $is_affected = TRUE;
287 } else if (eregi('^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+', $sql_query)) {
288 $is_insert = TRUE;
289 $is_affected = TRUE;
290 } else if (eregi('^UPDATE[[:space:]]+', $sql_query)) {
291 $is_affected = TRUE;
292 } else if (eregi('^SHOW[[:space:]]+', $sql_query)) {
293 $is_show = TRUE;
294 } else if (eregi('^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+', $sql_query)) {
295 $is_maint = TRUE;
298 // Do append a "LIMIT" clause?
299 if (isset($pos)
300 && (!$cfg['ShowAll'] || $session_max_rows != 'all')
301 && $is_select
302 && !($is_count || $is_export || $is_func || $is_analyse)
303 && eregi('[[:space:]]FROM[[:space:]]', $sql_query)
304 && !eregi('[[:space:]]LIMIT[[:space:]0-9,-]+$', $sql_query)) {
305 $sql_limit_to_append = " LIMIT $pos, ".$cfg['MaxRows'];
306 if (eregi('(.*)([[:space:]](PROCEDURE[[:space:]](.*)|FOR[[:space:]]+UPDATE|LOCK[[:space:]]+IN[[:space:]]+SHARE[[:space:]]+MODE))$', $sql_query, $regs)) {
307 $full_sql_query = $regs[1] . $sql_limit_to_append . $regs[2];
308 } else {
309 $full_sql_query = $sql_query . $sql_limit_to_append;
311 } else {
312 $full_sql_query = $sql_query;
313 } // end if...else
315 PMA_mysql_select_db($db);
317 // If the query is a DELETE query with no WHERE clause, get the number of
318 // rows that will be deleted (mysql_affected_rows will always return 0 in
319 // this case)
320 if ($is_delete
321 && eregi('^DELETE([[:space:]].+)?([[:space:]]FROM[[:space:]](.+))$', $sql_query, $parts)
322 && !eregi('[[:space:]]WHERE[[:space:]]', $parts[3])) {
323 $cnt_all_result = @PMA_mysql_query('SELECT COUNT(*) as count' . $parts[2]);
324 if ($cnt_all_result) {
325 $num_rows = PMA_mysql_result($cnt_all_result, 0, 'count');
326 mysql_free_result($cnt_all_result);
327 } else {
328 $num_rows = 0;
331 // Executes the query
332 // Only if we didn't ask to see the php code (mikebeck)
333 if (!empty($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
334 unset($result);
335 $num_rows = 0;
337 else {
338 $result = @PMA_mysql_query($full_sql_query);
339 // Displays an error message if required and stop parsing the script
340 if (PMA_mysql_error()) {
341 $error = PMA_mysql_error();
342 include('./header.inc.php3');
343 $full_err_url = (ereg('^(db_details|tbl_properties)', $err_url))
344 ? $err_url . '&amp;show_query=1&amp;sql_query=' . urlencode($sql_query)
345 : $err_url;
346 PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
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 // Gets the number of rows affected/returned
356 if (!$is_affected) {
357 $num_rows = ($result) ? @mysql_num_rows($result) : 0;
358 } else if (!isset($num_rows)) {
359 $num_rows = @mysql_affected_rows();
362 // Counts the total number of rows for the same 'SELECT' query without the
363 // 'LIMIT' clause that may have been programatically added
364 if (empty($sql_limit_to_append)) {
365 $unlim_num_rows = $num_rows;
367 else if ($is_select) {
368 // SK -- Patch : correct calculations for GROUP BY, HAVING, DISTINCT
370 // Reads only the from-part of the query...
371 // NOTE: here the presence of LIMIT is impossible, HAVING and GROUP BY
372 // are necessary for correct calculation, and extra spaces and
373 // lowercase reserved words are removed, so we have a simple split
374 // pattern:
376 $array = split('[[:space:]]+(FROM|ORDER BY)[[:space:]]+', $sql_query);
378 // if $array[1] is empty here, there is an error in the query:
379 // "... FROM [ORDER BY ...]", but the query is already executed with
380 // success so this check is redundant???
382 if (!empty($array[1])) {
383 // ... and makes a count(*) to count the entries
384 // Special case: SELECT DISTINCT ... FROM ...
385 // the count of resulting rows can be found as:
386 // SELECT COUNT(DISTINCT ...) FROM ...
387 if (eregi('^SELECT DISTINCT(.*)', $array[0], $array_dist)) {
388 $count_what = 'DISTINCT ' . $array_dist[1];
389 } else {
390 $count_what = '*';
392 $count_query = 'SELECT COUNT(' . $count_what . ') AS count FROM ' . $array[1];
393 if ($cnt_all_result = mysql_query($count_query)) {
394 if ($is_group) {
395 $unlim_num_rows = @mysql_num_rows($cnt_all_result);
396 } else {
397 $unlim_num_rows = mysql_result($cnt_all_result, 0, 'count');
399 mysql_free_result($cnt_all_result);
401 } else {
402 $unlim_num_rows = 0;
404 } // end rows total count
405 } // end else "didn't ask to see php code"
407 // No rows returned -> move back to the calling page
408 if ($num_rows < 1 || $is_affected) {
409 if ($is_delete) {
410 $message = $strDeletedRows . '&nbsp;' . $num_rows;
411 } else if ($is_insert) {
412 $message = $strInsertedRows . '&nbsp;' . $num_rows;
413 } else if ($is_affected) {
414 $message = $strAffectedRows . '&nbsp;' . $num_rows;
415 } else if (!empty($zero_rows)) {
416 $message = $zero_rows;
417 } else if (!empty($GLOBALS['show_as_php'])) {
418 $message = $strPhp;
419 } else if (!empty($GLOBALS['validatequery'])) {
420 $message = $strValidateSQL;
421 } else {
422 $message = $strEmptyResultSet;
425 if ($is_gotofile) {
426 $goto = ereg_replace('\.\.*', '.', $goto);
427 // Checks for a valid target script
428 if (isset($table) && $table == '') {
429 unset($table);
431 if (isset($db) && $db == '') {
432 unset($db);
434 $is_db = $is_table = FALSE;
435 if (strpos(' ' . $goto, 'tbl_properties') == 1) {
436 if (!isset($table)) {
437 $goto = 'db_details.php3';
438 } else {
439 $is_table = @PMA_mysql_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'');
440 if (!($is_table && @mysql_numrows($is_table))) {
441 $goto = 'db_details.php3';
442 unset($table);
444 } // end if... else...
446 if (strpos(' ' . $goto, 'db_details') == 1) {
447 if (isset($table)) {
448 unset($table);
450 if (!isset($db)) {
451 $goto = 'main.php3';
452 } else {
453 $is_db = @PMA_mysql_select_db($db);
454 if (!$is_db) {
455 $goto = 'main.php3';
456 unset($db);
458 } // end if... else...
460 // Loads to target script
461 if (strpos(' ' . $goto, 'db_details') == 1
462 || strpos(' ' . $goto, 'tbl_properties') == 1) {
463 $js_to_run = 'functions.js';
465 if ($goto != 'main.php3') {
466 include('./header.inc.php3');
468 include('./' . $goto);
469 } // end if file_exist
470 else {
471 header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto) . '&message=' . urlencode($message));
472 } // end else
473 exit();
474 } // end no rows returned
476 // At least one row is returned -> displays a table with results
477 else {
478 // Displays the headers
479 if (isset($show_query)) {
480 unset($show_query);
482 if (isset($printview) && $printview == '1') {
483 include('./header_printview.inc.php3');
484 } else {
485 $js_to_run = 'functions.js';
486 unset($message);
487 if (!empty($table)) {
488 include('./tbl_properties_common.php3');
489 include('./tbl_properties_table_info.php3');
491 else {
492 include('./db_details_common.php3');
493 include('./db_details_db_info.php3');
495 include('./libraries/relation.lib.php3');
496 $cfgRelation = PMA_getRelationsParam();
499 // Gets the list of fields properties
500 if (isset($result) && $result) {
501 while ($field = PMA_mysql_fetch_field($result)) {
502 $fields_meta[] = $field;
504 $fields_cnt = count($fields_meta);
506 // Displays the results in a table
507 include('./libraries/display_tbl.lib.php3');
508 if (empty($disp_mode)) {
509 // see the "PMA_setDisplayMode()" function in
510 // libraries/display_tbl.lib.php3
511 $disp_mode = 'urdr111101';
513 PMA_displayTable($result, $disp_mode);
514 mysql_free_result($result);
516 if ($disp_mode[6] == '1' || $disp_mode[9] == '1') {
517 echo "\n";
518 echo '<p>' . "\n";
520 // Displays "Insert a new row" link if required
521 if ($disp_mode[6] == '1') {
522 $lnk_goto = 'sql.php3'
523 . '?lang=' . $lang
524 . '&amp;convcharset=' . $convcharset
525 . '&amp;server=' . $server
526 . '&amp;db=' . urlencode($db)
527 . '&amp;table=' . urlencode($table)
528 . '&amp;pos=' . $pos
529 . '&amp;session_max_rows=' . $session_max_rows
530 . '&amp;disp_direction=' . $disp_direction
531 . '&amp;repeat_cells=' . $repeat_cells
532 . '&amp;sql_query=' . urlencode($sql_query);
533 $url_query = '?lang=' . $lang
534 . '&amp;convcharset=' . $convcharset
535 . '&amp;server=' . $server
536 . '&amp;db=' . urlencode($db)
537 . '&amp;table=' . urlencode($table)
538 . '&amp;pos=' . $pos
539 . '&amp;session_max_rows=' . $session_max_rows
540 . '&amp;disp_direction=' . $disp_direction
541 . '&amp;repeat_cells=' . $repeat_cells
542 . '&amp;sql_query=' . urlencode($sql_query)
543 . '&amp;goto=' . urlencode($lnk_goto);
545 echo ' <!-- Insert a new row -->' . "\n"
546 . ' <a href="tbl_change.php3' . $url_query . '">' . $strInsertNewRow . '</a>';
547 if ($disp_mode[9] == '1') {
548 echo '<br />';
550 echo "\n";
551 } // end insert new row
553 // Displays "printable view" link if required
554 if ($disp_mode[9] == '1') {
555 $url_query = '?lang=' . $lang
556 . '&amp;convcharset=' . $convcharset
557 . '&amp;server=' . $server
558 . '&amp;db=' . urlencode($db)
559 . '&amp;table=' . urlencode($table)
560 . '&amp;pos=' . $pos
561 . '&amp;session_max_rows=' . $session_max_rows
562 . '&amp;disp_direction=' . $disp_direction
563 . '&amp;repeat_cells=' . $repeat_cells
564 . '&amp;printview=1'
565 . ((isset($dontlimitchars) && $dontlimitchars == '1') ? '&amp;dontlimitchars=1' : '')
566 . '&amp;sql_query=' . urlencode($sql_query);
567 echo ' <!-- Print view -->' . "\n"
568 . ' <a href="sql.php3' . $url_query . '" target="print_view">' . $strPrintView . '</a>' . "\n";
569 } // end displays "printable view"
571 echo '</p>' . "\n";
574 // Bookmark Support if required
575 if ($disp_mode[7] == '1'
576 && ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table'] && empty($id_bookmark))
577 && !empty($sql_query)) {
578 echo "\n";
580 $goto = 'sql.php3'
581 . '?lang=' . $lang
582 . '&amp;convcharset=' . $convcharset
583 . '&amp;server=' . $server
584 . '&amp;db=' . urlencode($db)
585 . '&amp;table=' . urlencode($table)
586 . '&amp;pos=' . $pos
587 . '&amp;session_max_rows=' . $session_max_rows
588 . '&amp;disp_direction=' . $disp_direction
589 . '&amp;repeat_cells=' . $repeat_cells
590 . '&amp;sql_query=' . urlencode($sql_query)
591 . '&amp;id_bookmark=1';
593 <!-- Bookmark the query -->
594 <form action="sql.php3" method="post" onsubmit="return emptyFormElements(this, 'fields[label]');">
595 <?php
596 echo "\n";
597 if ($disp_mode[3] == '1') {
598 echo ' <i>' . $strOr . '</i>' . "\n";
601 <br /><br />
602 <?php echo $strBookmarkLabel; ?>&nbsp;:
603 <input type="hidden" name="server" value="<?php echo $server; ?>" />
604 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
605 <input type="hidden" name="fields[dbase]" value="<?php echo $db; ?>" />
606 <input type="hidden" name="fields[user]" value="<?php echo $cfg['Bookmark']['user']; ?>" />
607 <input type="hidden" name="fields[query]" value="<?php echo urlencode($sql_query); ?>" />
608 <input type="text" name="fields[label]" value="" />
609 <input type="submit" name="store_bkm" value="<?php echo $strBookmarkThis; ?>" />
610 </form>
611 <?php
612 } // end bookmark support
614 // Do print the page if required
615 if (isset($printview) && $printview == '1') {
616 echo "\n";
618 <script type="text/javascript" language="javascript1.2">
619 <!--
620 // Do print the page
621 if (typeof(window.print) != 'undefined') {
622 window.print();
624 //-->
625 </script>
626 <?php
627 } // end print case
628 } // end rows returned
630 } // end executes the query
631 echo "\n\n";
635 * Displays the footer
637 require('./footer.inc.php3');